001 /** 002 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.service; 016 017 import aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil; 020 import com.liferay.portal.kernel.util.ReferenceRegistry; 021 022 /** 023 * Provides the remote service utility for Role. This utility wraps 024 * {@link com.liferay.portal.service.impl.RoleServiceImpl} and is the 025 * primary access point for service operations in application layer code running 026 * on a remote server. Methods of this service are expected to have security 027 * checks based on the propagated JAAS credentials because this service can be 028 * accessed remotely. 029 * 030 * @author Brian Wing Shun Chan 031 * @see RoleService 032 * @see com.liferay.portal.service.base.RoleServiceBaseImpl 033 * @see com.liferay.portal.service.impl.RoleServiceImpl 034 * @generated 035 */ 036 @ProviderType 037 public class RoleServiceUtil { 038 /* 039 * NOTE FOR DEVELOPERS: 040 * 041 * Never modify this class directly. Add custom service methods to {@link com.liferay.portal.service.impl.RoleServiceImpl} and rerun ServiceBuilder to regenerate this class. 042 */ 043 044 /** 045 * Adds a role. The user is reindexed after role is added. 046 * 047 * @param className the name of the class for which the role is created 048 * @param classPK the primary key of the class for which the role is 049 created (optionally <code>0</code>) 050 * @param name the role's name 051 * @param titleMap the role's localized titles (optionally 052 <code>null</code>) 053 * @param descriptionMap the role's localized descriptions (optionally 054 <code>null</code>) 055 * @param type the role's type (optionally <code>0</code>) 056 * @param subtype the role's subtype (optionally <code>null</code>) 057 * @param serviceContext the service context to be applied (optionally 058 <code>null</code>). Can set the expando bridge attributes for the 059 role. 060 * @return the role 061 */ 062 public static com.liferay.portal.model.Role addRole( 063 java.lang.String className, long classPK, java.lang.String name, 064 java.util.Map<java.util.Locale, java.lang.String> titleMap, 065 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 066 int type, java.lang.String subtype, 067 com.liferay.portal.service.ServiceContext serviceContext) 068 throws com.liferay.portal.kernel.exception.PortalException { 069 return getService() 070 .addRole(className, classPK, name, titleMap, descriptionMap, 071 type, subtype, serviceContext); 072 } 073 074 /** 075 * Adds a role. The user is reindexed after role is added. 076 * 077 * @param name the role's name 078 * @param titleMap the role's localized titles (optionally 079 <code>null</code>) 080 * @param descriptionMap the role's localized descriptions (optionally 081 <code>null</code>) 082 * @param type the role's type (optionally <code>0</code>) 083 * @return the role 084 * @deprecated As of 6.2.0, replaced by {@link #addRole(String, long, 085 String, Map, Map, int, String, ServiceContext)} 086 */ 087 @Deprecated 088 public static com.liferay.portal.model.Role addRole(java.lang.String name, 089 java.util.Map<java.util.Locale, java.lang.String> titleMap, 090 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 091 int type) throws com.liferay.portal.kernel.exception.PortalException { 092 return getService().addRole(name, titleMap, descriptionMap, type); 093 } 094 095 /** 096 * Adds the roles to the user. The user is reindexed after the roles are 097 * added. 098 * 099 * @param userId the primary key of the user 100 * @param roleIds the primary keys of the roles 101 */ 102 public static void addUserRoles(long userId, long[] roleIds) 103 throws com.liferay.portal.kernel.exception.PortalException { 104 getService().addUserRoles(userId, roleIds); 105 } 106 107 /** 108 * Deletes the role with the primary key and its associated permissions. 109 * 110 * @param roleId the primary key of the role 111 */ 112 public static void deleteRole(long roleId) 113 throws com.liferay.portal.kernel.exception.PortalException { 114 getService().deleteRole(roleId); 115 } 116 117 public static com.liferay.portal.model.Role fetchRole(long roleId) 118 throws com.liferay.portal.kernel.exception.PortalException { 119 return getService().fetchRole(roleId); 120 } 121 122 /** 123 * Returns all the roles associated with the group. 124 * 125 * @param groupId the primary key of the group 126 * @return the roles associated with the group 127 */ 128 public static java.util.List<com.liferay.portal.model.Role> getGroupRoles( 129 long groupId) 130 throws com.liferay.portal.kernel.exception.PortalException { 131 return getService().getGroupRoles(groupId); 132 } 133 134 /** 135 * Returns the OSGi service identifier. 136 * 137 * @return the OSGi service identifier 138 */ 139 public static java.lang.String getOSGiServiceIdentifier() { 140 return getService().getOSGiServiceIdentifier(); 141 } 142 143 /** 144 * Returns the role with the name in the company. 145 * 146 * <p> 147 * The method searches the system roles map first for default roles. If a 148 * role with the name is not found, then the method will query the database. 149 * </p> 150 * 151 * @param companyId the primary key of the company 152 * @param name the role's name 153 * @return the role with the name 154 */ 155 public static com.liferay.portal.model.Role getRole(long companyId, 156 java.lang.String name) 157 throws com.liferay.portal.kernel.exception.PortalException { 158 return getService().getRole(companyId, name); 159 } 160 161 /** 162 * Returns the role with the primary key. 163 * 164 * @param roleId the primary key of the role 165 * @return the role with the primary key 166 */ 167 public static com.liferay.portal.model.Role getRole(long roleId) 168 throws com.liferay.portal.kernel.exception.PortalException { 169 return getService().getRole(roleId); 170 } 171 172 public static java.util.List<com.liferay.portal.model.Role> getRoles( 173 long companyId, int[] types) 174 throws com.liferay.portal.kernel.exception.PortalException { 175 return getService().getRoles(companyId, types); 176 } 177 178 public static java.util.List<com.liferay.portal.model.Role> getRoles( 179 int type, java.lang.String subtype) 180 throws com.liferay.portal.kernel.exception.PortalException { 181 return getService().getRoles(type, subtype); 182 } 183 184 /** 185 * Returns all the user's roles within the user group. 186 * 187 * @param userId the primary key of the user 188 * @param groupId the primary key of the group 189 * @return the user's roles within the user group 190 */ 191 public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles( 192 long userId, long groupId) 193 throws com.liferay.portal.kernel.exception.PortalException { 194 return getService().getUserGroupGroupRoles(userId, groupId); 195 } 196 197 /** 198 * Returns all the user's roles within the user group. 199 * 200 * @param userId the primary key of the user 201 * @param groupId the primary key of the group 202 * @return the user's roles within the user group 203 */ 204 public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles( 205 long userId, long groupId) 206 throws com.liferay.portal.kernel.exception.PortalException { 207 return getService().getUserGroupRoles(userId, groupId); 208 } 209 210 /** 211 * Returns the union of all the user's roles within the groups. 212 * 213 * @param userId the primary key of the user 214 * @param groups the groups (optionally <code>null</code>) 215 * @return the union of all the user's roles within the groups 216 */ 217 public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles( 218 long userId, java.util.List<com.liferay.portal.model.Group> groups) 219 throws com.liferay.portal.kernel.exception.PortalException { 220 return getService().getUserRelatedRoles(userId, groups); 221 } 222 223 /** 224 * Returns all the roles associated with the user. 225 * 226 * @param userId the primary key of the user 227 * @return the roles associated with the user 228 */ 229 public static java.util.List<com.liferay.portal.model.Role> getUserRoles( 230 long userId) throws com.liferay.portal.kernel.exception.PortalException { 231 return getService().getUserRoles(userId); 232 } 233 234 /** 235 * Returns <code>true</code> if the user is associated with the named 236 * regular role. 237 * 238 * @param userId the primary key of the user 239 * @param companyId the primary key of the company 240 * @param name the name of the role 241 * @param inherited whether to include the user's inherited roles in the 242 search 243 * @return <code>true</code> if the user is associated with the regular 244 role; <code>false</code> otherwise 245 */ 246 public static boolean hasUserRole(long userId, long companyId, 247 java.lang.String name, boolean inherited) 248 throws com.liferay.portal.kernel.exception.PortalException { 249 return getService().hasUserRole(userId, companyId, name, inherited); 250 } 251 252 /** 253 * Returns <code>true</code> if the user has any one of the named regular 254 * roles. 255 * 256 * @param userId the primary key of the user 257 * @param companyId the primary key of the company 258 * @param names the names of the roles 259 * @param inherited whether to include the user's inherited roles in the 260 search 261 * @return <code>true</code> if the user has any one of the regular roles; 262 <code>false</code> otherwise 263 */ 264 public static boolean hasUserRoles(long userId, long companyId, 265 java.lang.String[] names, boolean inherited) 266 throws com.liferay.portal.kernel.exception.PortalException { 267 return getService().hasUserRoles(userId, companyId, names, inherited); 268 } 269 270 public static java.util.List<com.liferay.portal.model.Role> search( 271 long companyId, java.lang.String keywords, java.lang.Integer[] types, 272 java.util.LinkedHashMap<java.lang.String, java.lang.Object> params, 273 int start, int end, 274 com.liferay.portal.kernel.util.OrderByComparator<com.liferay.portal.model.Role> obc) { 275 return getService() 276 .search(companyId, keywords, types, params, start, end, obc); 277 } 278 279 public static int searchCount(long companyId, java.lang.String keywords, 280 java.lang.Integer[] types, 281 java.util.LinkedHashMap<java.lang.String, java.lang.Object> params) { 282 return getService().searchCount(companyId, keywords, types, params); 283 } 284 285 /** 286 * Removes the matching roles associated with the user. The user is 287 * reindexed after the roles are removed. 288 * 289 * @param userId the primary key of the user 290 * @param roleIds the primary keys of the roles 291 */ 292 public static void unsetUserRoles(long userId, long[] roleIds) 293 throws com.liferay.portal.kernel.exception.PortalException { 294 getService().unsetUserRoles(userId, roleIds); 295 } 296 297 /** 298 * Updates the role with the primary key. 299 * 300 * @param roleId the primary key of the role 301 * @param name the role's new name 302 * @param titleMap the new localized titles (optionally <code>null</code>) 303 to replace those existing for the role 304 * @param descriptionMap the new localized descriptions (optionally 305 <code>null</code>) to replace those existing for the role 306 * @param subtype the role's new subtype (optionally <code>null</code>) 307 * @param serviceContext the service context to be applied (optionally 308 <code>null</code>). Can set the expando bridge attributes for the 309 role. 310 * @return the role with the primary key 311 */ 312 public static com.liferay.portal.model.Role updateRole(long roleId, 313 java.lang.String name, 314 java.util.Map<java.util.Locale, java.lang.String> titleMap, 315 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 316 java.lang.String subtype, 317 com.liferay.portal.service.ServiceContext serviceContext) 318 throws com.liferay.portal.kernel.exception.PortalException { 319 return getService() 320 .updateRole(roleId, name, titleMap, descriptionMap, subtype, 321 serviceContext); 322 } 323 324 public static RoleService getService() { 325 if (_service == null) { 326 _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName()); 327 328 ReferenceRegistry.registerReference(RoleServiceUtil.class, 329 "_service"); 330 } 331 332 return _service; 333 } 334 335 private static RoleService _service; 336 }