001 /** 002 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. 003 * 004 * The contents of this file are subject to the terms of the Liferay Enterprise 005 * Subscription License ("License"). You may not use this file except in 006 * compliance with the License. You can obtain a copy of the License by 007 * contacting Liferay, Inc. See the License for the specific language governing 008 * permissions and limitations under the License, including but not limited to 009 * distribution rights of the Software. 010 * 011 * 012 * 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 * Returns the Spring bean ID for this bean. 046 * 047 * @return the Spring bean ID for this bean 048 */ 049 public static java.lang.String getBeanIdentifier() { 050 return getService().getBeanIdentifier(); 051 } 052 053 /** 054 * Sets the Spring bean ID for this bean. 055 * 056 * @param beanIdentifier the Spring bean ID for this bean 057 */ 058 public static void setBeanIdentifier(java.lang.String beanIdentifier) { 059 getService().setBeanIdentifier(beanIdentifier); 060 } 061 062 /** 063 * Adds a role. The user is reindexed after role is added. 064 * 065 * @param className the name of the class for which the role is created 066 * @param classPK the primary key of the class for which the role is 067 created (optionally <code>0</code>) 068 * @param name the role's name 069 * @param titleMap the role's localized titles (optionally 070 <code>null</code>) 071 * @param descriptionMap the role's localized descriptions (optionally 072 <code>null</code>) 073 * @param type the role's type (optionally <code>0</code>) 074 * @param subtype the role's subtype (optionally <code>null</code>) 075 * @param serviceContext the service context to be applied (optionally 076 <code>null</code>). Can set the expando bridge attributes for the 077 role. 078 * @return the role 079 * @throws PortalException if a user with the primary key could not be 080 found, if the user did not have permission to add roles, if the 081 class name or the role name were invalid, or if the role is a 082 duplicate 083 * @throws SystemException if a system exception occurred 084 */ 085 public static com.liferay.portal.model.Role addRole( 086 java.lang.String className, long classPK, java.lang.String name, 087 java.util.Map<java.util.Locale, java.lang.String> titleMap, 088 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 089 int type, java.lang.String subtype, 090 com.liferay.portal.service.ServiceContext serviceContext) 091 throws com.liferay.portal.kernel.exception.PortalException, 092 com.liferay.portal.kernel.exception.SystemException { 093 return getService() 094 .addRole(className, classPK, name, titleMap, descriptionMap, 095 type, subtype, serviceContext); 096 } 097 098 /** 099 * Adds a role. The user is reindexed after role is added. 100 * 101 * @param name the role's name 102 * @param titleMap the role's localized titles (optionally 103 <code>null</code>) 104 * @param descriptionMap the role's localized descriptions (optionally 105 <code>null</code>) 106 * @param type the role's type (optionally <code>0</code>) 107 * @return the role 108 * @throws PortalException if a user with the primary key could not be 109 found, if the user did not have permission to add roles, if 110 the class name or the role name were invalid, or if the role 111 is a duplicate 112 * @throws SystemException if a system exception occurred 113 * @deprecated As of 6.2.0, replaced by {@link #addRole(String, long, 114 String, Map, Map, int, String, ServiceContext)} 115 */ 116 public static com.liferay.portal.model.Role addRole(java.lang.String name, 117 java.util.Map<java.util.Locale, java.lang.String> titleMap, 118 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 119 int type) 120 throws com.liferay.portal.kernel.exception.PortalException, 121 com.liferay.portal.kernel.exception.SystemException { 122 return getService().addRole(name, titleMap, descriptionMap, type); 123 } 124 125 /** 126 * Adds the roles to the user. The user is reindexed after the roles are 127 * added. 128 * 129 * @param userId the primary key of the user 130 * @param roleIds the primary keys of the roles 131 * @throws PortalException if a user with the primary key could not be found 132 or if the user did not have permission to assign members to one 133 of the roles 134 * @throws SystemException if a system exception occurred 135 */ 136 public static void addUserRoles(long userId, long[] roleIds) 137 throws com.liferay.portal.kernel.exception.PortalException, 138 com.liferay.portal.kernel.exception.SystemException { 139 getService().addUserRoles(userId, roleIds); 140 } 141 142 /** 143 * Deletes the role with the primary key and its associated permissions. 144 * 145 * @param roleId the primary key of the role 146 * @throws PortalException if the user did not have permission to delete the 147 role, if a role with the primary key could not be found, if the 148 role is a default system role, or if the role's resource could 149 not be found 150 * @throws SystemException if a system exception occurred 151 */ 152 public static void deleteRole(long roleId) 153 throws com.liferay.portal.kernel.exception.PortalException, 154 com.liferay.portal.kernel.exception.SystemException { 155 getService().deleteRole(roleId); 156 } 157 158 /** 159 * Returns all the roles associated with the group. 160 * 161 * @param groupId the primary key of the group 162 * @return the roles associated with the group 163 * @throws PortalException if a portal exception occurred 164 * @throws SystemException if a system exception occurred 165 */ 166 public static java.util.List<com.liferay.portal.model.Role> getGroupRoles( 167 long groupId) 168 throws com.liferay.portal.kernel.exception.PortalException, 169 com.liferay.portal.kernel.exception.SystemException { 170 return getService().getGroupRoles(groupId); 171 } 172 173 public static java.util.List<com.liferay.portal.model.Role> getGroupRolesAndTeamRoles( 174 long companyId, java.lang.String keywords, 175 java.util.List<java.lang.String> excludedNames, int[] types, 176 long excludedTeamRoleId, long teamGroupId, int start, int end) 177 throws com.liferay.portal.kernel.exception.SystemException { 178 return getService() 179 .getGroupRolesAndTeamRoles(companyId, keywords, 180 excludedNames, types, excludedTeamRoleId, teamGroupId, start, end); 181 } 182 183 public static int getGroupRolesAndTeamRolesCount(long companyId, 184 java.lang.String keywords, 185 java.util.List<java.lang.String> excludedNames, int[] types, 186 long excludedTeamRoleId, long teamGroupId) 187 throws com.liferay.portal.kernel.exception.SystemException { 188 return getService() 189 .getGroupRolesAndTeamRolesCount(companyId, keywords, 190 excludedNames, types, excludedTeamRoleId, teamGroupId); 191 } 192 193 /** 194 * Returns the role with the primary key. 195 * 196 * @param roleId the primary key of the role 197 * @return the role with the primary key 198 * @throws PortalException if a role with the primary key could not be found 199 or if the user did not have permission to view the role 200 * @throws SystemException if a system exception occurred 201 */ 202 public static com.liferay.portal.model.Role getRole(long roleId) 203 throws com.liferay.portal.kernel.exception.PortalException, 204 com.liferay.portal.kernel.exception.SystemException { 205 return getService().getRole(roleId); 206 } 207 208 /** 209 * Returns the role with the name in the company. 210 * 211 * <p> 212 * The method searches the system roles map first for default roles. If a 213 * role with the name is not found, then the method will query the database. 214 * </p> 215 * 216 * @param companyId the primary key of the company 217 * @param name the role's name 218 * @return the role with the name 219 * @throws PortalException if a role with the name could not be found in the 220 company or if the user did not have permission to view the role 221 * @throws SystemException if a system exception occurred 222 */ 223 public static com.liferay.portal.model.Role getRole(long companyId, 224 java.lang.String name) 225 throws com.liferay.portal.kernel.exception.PortalException, 226 com.liferay.portal.kernel.exception.SystemException { 227 return getService().getRole(companyId, name); 228 } 229 230 /** 231 * Returns all the user's roles within the user group. 232 * 233 * @param userId the primary key of the user 234 * @param groupId the primary key of the group 235 * @return the user's roles within the user group 236 * @throws PortalException if a portal exception occurred 237 * @throws SystemException if a system exception occurred 238 */ 239 public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles( 240 long userId, long groupId) 241 throws com.liferay.portal.kernel.exception.PortalException, 242 com.liferay.portal.kernel.exception.SystemException { 243 return getService().getUserGroupGroupRoles(userId, groupId); 244 } 245 246 /** 247 * Returns all the user's roles within the user group. 248 * 249 * @param userId the primary key of the user 250 * @param groupId the primary key of the group 251 * @return the user's roles within the user group 252 * @throws PortalException if a portal exception occurred 253 * @throws SystemException if a system exception occurred 254 */ 255 public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles( 256 long userId, long groupId) 257 throws com.liferay.portal.kernel.exception.PortalException, 258 com.liferay.portal.kernel.exception.SystemException { 259 return getService().getUserGroupRoles(userId, groupId); 260 } 261 262 /** 263 * Returns the union of all the user's roles within the groups. 264 * 265 * @param userId the primary key of the user 266 * @param groups the groups (optionally <code>null</code>) 267 * @return the union of all the user's roles within the groups 268 * @throws PortalException if a portal exception occurred 269 * @throws SystemException if a system exception occurred 270 */ 271 public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles( 272 long userId, java.util.List<com.liferay.portal.model.Group> groups) 273 throws com.liferay.portal.kernel.exception.PortalException, 274 com.liferay.portal.kernel.exception.SystemException { 275 return getService().getUserRelatedRoles(userId, groups); 276 } 277 278 /** 279 * Returns all the roles associated with the user. 280 * 281 * @param userId the primary key of the user 282 * @return the roles associated with the user 283 * @throws PortalException if a portal exception occurred 284 * @throws SystemException if a system exception occurred 285 */ 286 public static java.util.List<com.liferay.portal.model.Role> getUserRoles( 287 long userId) 288 throws com.liferay.portal.kernel.exception.PortalException, 289 com.liferay.portal.kernel.exception.SystemException { 290 return getService().getUserRoles(userId); 291 } 292 293 /** 294 * Returns <code>true</code> if the user is associated with the named 295 * regular role. 296 * 297 * @param userId the primary key of the user 298 * @param companyId the primary key of the company 299 * @param name the name of the role 300 * @param inherited whether to include the user's inherited roles in the 301 search 302 * @return <code>true</code> if the user is associated with the regular 303 role; <code>false</code> otherwise 304 * @throws PortalException if a role with the name could not be found in the 305 company or if a default user for the company could not be found 306 * @throws SystemException if a system exception occurred 307 */ 308 public static boolean hasUserRole(long userId, long companyId, 309 java.lang.String name, boolean inherited) 310 throws com.liferay.portal.kernel.exception.PortalException, 311 com.liferay.portal.kernel.exception.SystemException { 312 return getService().hasUserRole(userId, companyId, name, inherited); 313 } 314 315 /** 316 * Returns <code>true</code> if the user has any one of the named regular 317 * roles. 318 * 319 * @param userId the primary key of the user 320 * @param companyId the primary key of the company 321 * @param names the names of the roles 322 * @param inherited whether to include the user's inherited roles in the 323 search 324 * @return <code>true</code> if the user has any one of the regular roles; 325 <code>false</code> otherwise 326 * @throws PortalException if any one of the roles with the names could not 327 be found in the company or if the default user for the company 328 could not be found 329 * @throws SystemException if a system exception occurred 330 */ 331 public static boolean hasUserRoles(long userId, long companyId, 332 java.lang.String[] names, boolean inherited) 333 throws com.liferay.portal.kernel.exception.PortalException, 334 com.liferay.portal.kernel.exception.SystemException { 335 return getService().hasUserRoles(userId, companyId, names, inherited); 336 } 337 338 public static java.util.List<com.liferay.portal.model.Role> search( 339 long companyId, java.lang.String keywords, java.lang.Integer[] types, 340 java.util.LinkedHashMap<java.lang.String, java.lang.Object> params, 341 int start, int end, 342 com.liferay.portal.kernel.util.OrderByComparator obc) 343 throws com.liferay.portal.kernel.exception.SystemException { 344 return getService() 345 .search(companyId, keywords, types, params, start, end, obc); 346 } 347 348 public static int searchCount(long companyId, java.lang.String keywords, 349 java.lang.Integer[] types, 350 java.util.LinkedHashMap<java.lang.String, java.lang.Object> params) 351 throws com.liferay.portal.kernel.exception.SystemException { 352 return getService().searchCount(companyId, keywords, types, params); 353 } 354 355 /** 356 * Removes the matching roles associated with the user. The user is 357 * reindexed after the roles are removed. 358 * 359 * @param userId the primary key of the user 360 * @param roleIds the primary keys of the roles 361 * @throws PortalException if a user with the primary key could not be 362 found, if the user did not have permission to remove members from 363 a role, or if a role with any one of the primary keys could not 364 be found 365 * @throws SystemException if a system exception occurred 366 */ 367 public static void unsetUserRoles(long userId, long[] roleIds) 368 throws com.liferay.portal.kernel.exception.PortalException, 369 com.liferay.portal.kernel.exception.SystemException { 370 getService().unsetUserRoles(userId, roleIds); 371 } 372 373 /** 374 * Updates the role with the primary key. 375 * 376 * @param roleId the primary key of the role 377 * @param name the role's new name 378 * @param titleMap the new localized titles (optionally <code>null</code>) 379 to replace those existing for the role 380 * @param descriptionMap the new localized descriptions (optionally 381 <code>null</code>) to replace those existing for the role 382 * @param subtype the role's new subtype (optionally <code>null</code>) 383 * @param serviceContext the service context to be applied (optionally 384 <code>null</code>). Can set the expando bridge attributes for the 385 role. 386 * @return the role with the primary key 387 * @throws PortalException if the user did not have permission to update the 388 role, if a role with the primary could not be found, or if the 389 role's name was invalid 390 * @throws SystemException if a system exception occurred 391 */ 392 public static com.liferay.portal.model.Role updateRole(long roleId, 393 java.lang.String name, 394 java.util.Map<java.util.Locale, java.lang.String> titleMap, 395 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 396 java.lang.String subtype, 397 com.liferay.portal.service.ServiceContext serviceContext) 398 throws com.liferay.portal.kernel.exception.PortalException, 399 com.liferay.portal.kernel.exception.SystemException { 400 return getService() 401 .updateRole(roleId, name, titleMap, descriptionMap, subtype, 402 serviceContext); 403 } 404 405 public static RoleService getService() { 406 if (_service == null) { 407 _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName()); 408 409 ReferenceRegistry.registerReference(RoleServiceUtil.class, 410 "_service"); 411 } 412 413 return _service; 414 } 415 416 /** 417 * @deprecated As of 6.2.0 418 */ 419 public void setService(RoleService service) { 420 } 421 422 private static RoleService _service; 423 }