001 /** 002 * Copyright (c) 2000-2013 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 * 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 /** 174 * Returns the role with the primary key. 175 * 176 * @param roleId the primary key of the role 177 * @return the role with the primary key 178 * @throws PortalException if a role with the primary key could not be found 179 or if the user did not have permission to view the role 180 * @throws SystemException if a system exception occurred 181 */ 182 public static com.liferay.portal.model.Role getRole(long roleId) 183 throws com.liferay.portal.kernel.exception.PortalException, 184 com.liferay.portal.kernel.exception.SystemException { 185 return getService().getRole(roleId); 186 } 187 188 /** 189 * Returns the role with the name in the company. 190 * 191 * <p> 192 * The method searches the system roles map first for default roles. If a 193 * role with the name is not found, then the method will query the database. 194 * </p> 195 * 196 * @param companyId the primary key of the company 197 * @param name the role's name 198 * @return the role with the name 199 * @throws PortalException if a role with the name could not be found in the 200 company or if the user did not have permission to view the role 201 * @throws SystemException if a system exception occurred 202 */ 203 public static com.liferay.portal.model.Role getRole(long companyId, 204 java.lang.String name) 205 throws com.liferay.portal.kernel.exception.PortalException, 206 com.liferay.portal.kernel.exception.SystemException { 207 return getService().getRole(companyId, name); 208 } 209 210 /** 211 * Returns all the user's roles within the user group. 212 * 213 * @param userId the primary key of the user 214 * @param groupId the primary key of the group 215 * @return the user's roles within the user group 216 * @throws PortalException if a portal exception occurred 217 * @throws SystemException if a system exception occurred 218 */ 219 public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles( 220 long userId, long groupId) 221 throws com.liferay.portal.kernel.exception.PortalException, 222 com.liferay.portal.kernel.exception.SystemException { 223 return getService().getUserGroupGroupRoles(userId, groupId); 224 } 225 226 /** 227 * Returns all the user's roles within the user group. 228 * 229 * @param userId the primary key of the user 230 * @param groupId the primary key of the group 231 * @return the user's roles within the user group 232 * @throws PortalException if a portal exception occurred 233 * @throws SystemException if a system exception occurred 234 */ 235 public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles( 236 long userId, long groupId) 237 throws com.liferay.portal.kernel.exception.PortalException, 238 com.liferay.portal.kernel.exception.SystemException { 239 return getService().getUserGroupRoles(userId, groupId); 240 } 241 242 /** 243 * Returns the union of all the user's roles within the groups. 244 * 245 * @param userId the primary key of the user 246 * @param groups the groups (optionally <code>null</code>) 247 * @return the union of all the user's roles within the groups 248 * @throws PortalException if a portal exception occurred 249 * @throws SystemException if a system exception occurred 250 */ 251 public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles( 252 long userId, java.util.List<com.liferay.portal.model.Group> groups) 253 throws com.liferay.portal.kernel.exception.PortalException, 254 com.liferay.portal.kernel.exception.SystemException { 255 return getService().getUserRelatedRoles(userId, groups); 256 } 257 258 /** 259 * Returns all the roles associated with the user. 260 * 261 * @param userId the primary key of the user 262 * @return the roles associated with the user 263 * @throws PortalException if a portal exception occurred 264 * @throws SystemException if a system exception occurred 265 */ 266 public static java.util.List<com.liferay.portal.model.Role> getUserRoles( 267 long userId) 268 throws com.liferay.portal.kernel.exception.PortalException, 269 com.liferay.portal.kernel.exception.SystemException { 270 return getService().getUserRoles(userId); 271 } 272 273 /** 274 * Returns <code>true</code> if the user is associated with the named 275 * regular role. 276 * 277 * @param userId the primary key of the user 278 * @param companyId the primary key of the company 279 * @param name the name of the role 280 * @param inherited whether to include the user's inherited roles in the 281 search 282 * @return <code>true</code> if the user is associated with the regular 283 role; <code>false</code> otherwise 284 * @throws PortalException if a role with the name could not be found in the 285 company or if a default user for the company could not be found 286 * @throws SystemException if a system exception occurred 287 */ 288 public static boolean hasUserRole(long userId, long companyId, 289 java.lang.String name, boolean inherited) 290 throws com.liferay.portal.kernel.exception.PortalException, 291 com.liferay.portal.kernel.exception.SystemException { 292 return getService().hasUserRole(userId, companyId, name, inherited); 293 } 294 295 /** 296 * Returns <code>true</code> if the user has any one of the named regular 297 * roles. 298 * 299 * @param userId the primary key of the user 300 * @param companyId the primary key of the company 301 * @param names the names of the roles 302 * @param inherited whether to include the user's inherited roles in the 303 search 304 * @return <code>true</code> if the user has any one of the regular roles; 305 <code>false</code> otherwise 306 * @throws PortalException if any one of the roles with the names could not 307 be found in the company or if the default user for the company 308 could not be found 309 * @throws SystemException if a system exception occurred 310 */ 311 public static boolean hasUserRoles(long userId, long companyId, 312 java.lang.String[] names, boolean inherited) 313 throws com.liferay.portal.kernel.exception.PortalException, 314 com.liferay.portal.kernel.exception.SystemException { 315 return getService().hasUserRoles(userId, companyId, names, inherited); 316 } 317 318 /** 319 * Removes the matching roles associated with the user. The user is 320 * reindexed after the roles are removed. 321 * 322 * @param userId the primary key of the user 323 * @param roleIds the primary keys of the roles 324 * @throws PortalException if a user with the primary key could not be 325 found, if the user did not have permission to remove members from 326 a role, or if a role with any one of the primary keys could not 327 be found 328 * @throws SystemException if a system exception occurred 329 */ 330 public static void unsetUserRoles(long userId, long[] roleIds) 331 throws com.liferay.portal.kernel.exception.PortalException, 332 com.liferay.portal.kernel.exception.SystemException { 333 getService().unsetUserRoles(userId, roleIds); 334 } 335 336 /** 337 * Updates the role with the primary key. 338 * 339 * @param roleId the primary key of the role 340 * @param name the role's new name 341 * @param titleMap the new localized titles (optionally <code>null</code>) 342 to replace those existing for the role 343 * @param descriptionMap the new localized descriptions (optionally 344 <code>null</code>) to replace those existing for the role 345 * @param subtype the role's new subtype (optionally <code>null</code>) 346 * @param serviceContext the service context to be applied (optionally 347 <code>null</code>). Can set the expando bridge attributes for the 348 role. 349 * @return the role with the primary key 350 * @throws PortalException if the user did not have permission to update the 351 role, if a role with the primary could not be found, or if the 352 role's name was invalid 353 * @throws SystemException if a system exception occurred 354 */ 355 public static com.liferay.portal.model.Role updateRole(long roleId, 356 java.lang.String name, 357 java.util.Map<java.util.Locale, java.lang.String> titleMap, 358 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 359 java.lang.String subtype, 360 com.liferay.portal.service.ServiceContext serviceContext) 361 throws com.liferay.portal.kernel.exception.PortalException, 362 com.liferay.portal.kernel.exception.SystemException { 363 return getService() 364 .updateRole(roleId, name, titleMap, descriptionMap, subtype, 365 serviceContext); 366 } 367 368 public static RoleService getService() { 369 if (_service == null) { 370 _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName()); 371 372 ReferenceRegistry.registerReference(RoleServiceUtil.class, 373 "_service"); 374 } 375 376 return _service; 377 } 378 379 /** 380 * @deprecated As of 6.2.0 381 */ 382 public void setService(RoleService service) { 383 } 384 385 private static RoleService _service; 386 }