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 * @throws PortalException if a user with the primary key could not be 062 found, if the user did not have permission to add roles, if the 063 class name or the role name were invalid, or if the role is a 064 duplicate 065 */ 066 public static com.liferay.portal.model.Role addRole( 067 java.lang.String className, long classPK, java.lang.String name, 068 java.util.Map<java.util.Locale, java.lang.String> titleMap, 069 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 070 int type, java.lang.String subtype, 071 com.liferay.portal.service.ServiceContext serviceContext) 072 throws com.liferay.portal.kernel.exception.PortalException { 073 return getService() 074 .addRole(className, classPK, name, titleMap, descriptionMap, 075 type, subtype, serviceContext); 076 } 077 078 /** 079 * Adds a role. The user is reindexed after role is added. 080 * 081 * @param name the role's name 082 * @param titleMap the role's localized titles (optionally 083 <code>null</code>) 084 * @param descriptionMap the role's localized descriptions (optionally 085 <code>null</code>) 086 * @param type the role's type (optionally <code>0</code>) 087 * @return the role 088 * @throws PortalException if a user with the primary key could not be 089 found, if the user did not have permission to add roles, if 090 the class name or the role name were invalid, or if the role 091 is a duplicate 092 * @deprecated As of 6.2.0, replaced by {@link #addRole(String, long, 093 String, Map, Map, int, String, ServiceContext)} 094 */ 095 @Deprecated 096 public static com.liferay.portal.model.Role addRole(java.lang.String name, 097 java.util.Map<java.util.Locale, java.lang.String> titleMap, 098 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 099 int type) throws com.liferay.portal.kernel.exception.PortalException { 100 return getService().addRole(name, titleMap, descriptionMap, type); 101 } 102 103 /** 104 * Adds the roles to the user. The user is reindexed after the roles are 105 * added. 106 * 107 * @param userId the primary key of the user 108 * @param roleIds the primary keys of the roles 109 * @throws PortalException if a user with the primary key could not be found 110 or if the user did not have permission to assign members to one 111 of the roles 112 */ 113 public static void addUserRoles(long userId, long[] roleIds) 114 throws com.liferay.portal.kernel.exception.PortalException { 115 getService().addUserRoles(userId, roleIds); 116 } 117 118 /** 119 * Deletes the role with the primary key and its associated permissions. 120 * 121 * @param roleId the primary key of the role 122 * @throws PortalException if the user did not have permission to delete the 123 role, if a role with the primary key could not be found, if the 124 role is a default system role, or if the role's resource could 125 not be found 126 */ 127 public static void deleteRole(long roleId) 128 throws com.liferay.portal.kernel.exception.PortalException { 129 getService().deleteRole(roleId); 130 } 131 132 /** 133 * Returns the Spring bean ID for this bean. 134 * 135 * @return the Spring bean ID for this bean 136 */ 137 public static java.lang.String getBeanIdentifier() { 138 return getService().getBeanIdentifier(); 139 } 140 141 /** 142 * Returns all the roles associated with the group. 143 * 144 * @param groupId the primary key of the group 145 * @return the roles associated with the group 146 * @throws PortalException if a portal exception occurred 147 */ 148 public static java.util.List<com.liferay.portal.model.Role> getGroupRoles( 149 long groupId) 150 throws com.liferay.portal.kernel.exception.PortalException { 151 return getService().getGroupRoles(groupId); 152 } 153 154 /** 155 * Returns the role with the name in the company. 156 * 157 * <p> 158 * The method searches the system roles map first for default roles. If a 159 * role with the name is not found, then the method will query the database. 160 * </p> 161 * 162 * @param companyId the primary key of the company 163 * @param name the role's name 164 * @return the role with the name 165 * @throws PortalException if a role with the name could not be found in the 166 company or if the user did not have permission to view the role 167 */ 168 public static com.liferay.portal.model.Role getRole(long companyId, 169 java.lang.String name) 170 throws com.liferay.portal.kernel.exception.PortalException { 171 return getService().getRole(companyId, name); 172 } 173 174 /** 175 * Returns the role with the primary key. 176 * 177 * @param roleId the primary key of the role 178 * @return the role with the primary key 179 * @throws PortalException if a role with the primary key could not be found 180 or if the user did not have permission to view the role 181 */ 182 public static com.liferay.portal.model.Role getRole(long roleId) 183 throws com.liferay.portal.kernel.exception.PortalException { 184 return getService().getRole(roleId); 185 } 186 187 /** 188 * Returns all the user's roles within the user group. 189 * 190 * @param userId the primary key of the user 191 * @param groupId the primary key of the group 192 * @return the user's roles within the user group 193 * @throws PortalException if a portal exception occurred 194 */ 195 public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles( 196 long userId, long groupId) 197 throws com.liferay.portal.kernel.exception.PortalException { 198 return getService().getUserGroupGroupRoles(userId, groupId); 199 } 200 201 /** 202 * Returns all the user's roles within the user group. 203 * 204 * @param userId the primary key of the user 205 * @param groupId the primary key of the group 206 * @return the user's roles within the user group 207 * @throws PortalException if a portal exception occurred 208 */ 209 public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles( 210 long userId, long groupId) 211 throws com.liferay.portal.kernel.exception.PortalException { 212 return getService().getUserGroupRoles(userId, groupId); 213 } 214 215 /** 216 * Returns the union of all the user's roles within the groups. 217 * 218 * @param userId the primary key of the user 219 * @param groups the groups (optionally <code>null</code>) 220 * @return the union of all the user's roles within the groups 221 * @throws PortalException if a portal exception occurred 222 */ 223 public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles( 224 long userId, java.util.List<com.liferay.portal.model.Group> groups) 225 throws com.liferay.portal.kernel.exception.PortalException { 226 return getService().getUserRelatedRoles(userId, groups); 227 } 228 229 /** 230 * Returns all the roles associated with the user. 231 * 232 * @param userId the primary key of the user 233 * @return the roles associated with the user 234 * @throws PortalException if a portal exception occurred 235 */ 236 public static java.util.List<com.liferay.portal.model.Role> getUserRoles( 237 long userId) throws com.liferay.portal.kernel.exception.PortalException { 238 return getService().getUserRoles(userId); 239 } 240 241 /** 242 * Returns <code>true</code> if the user is associated with the named 243 * regular role. 244 * 245 * @param userId the primary key of the user 246 * @param companyId the primary key of the company 247 * @param name the name of the role 248 * @param inherited whether to include the user's inherited roles in the 249 search 250 * @return <code>true</code> if the user is associated with the regular 251 role; <code>false</code> otherwise 252 * @throws PortalException if a role with the name could not be found in the 253 company or if a default user for the company could not be found 254 */ 255 public static boolean hasUserRole(long userId, long companyId, 256 java.lang.String name, boolean inherited) 257 throws com.liferay.portal.kernel.exception.PortalException { 258 return getService().hasUserRole(userId, companyId, name, inherited); 259 } 260 261 /** 262 * Returns <code>true</code> if the user has any one of the named regular 263 * roles. 264 * 265 * @param userId the primary key of the user 266 * @param companyId the primary key of the company 267 * @param names the names of the roles 268 * @param inherited whether to include the user's inherited roles in the 269 search 270 * @return <code>true</code> if the user has any one of the regular roles; 271 <code>false</code> otherwise 272 * @throws PortalException if any one of the roles with the names could not 273 be found in the company or if the default user for the company 274 could not be found 275 */ 276 public static boolean hasUserRoles(long userId, long companyId, 277 java.lang.String[] names, boolean inherited) 278 throws com.liferay.portal.kernel.exception.PortalException { 279 return getService().hasUserRoles(userId, companyId, names, inherited); 280 } 281 282 /** 283 * Sets the Spring bean ID for this bean. 284 * 285 * @param beanIdentifier the Spring bean ID for this bean 286 */ 287 public static void setBeanIdentifier(java.lang.String beanIdentifier) { 288 getService().setBeanIdentifier(beanIdentifier); 289 } 290 291 /** 292 * Removes the matching roles associated with the user. The user is 293 * reindexed after the roles are removed. 294 * 295 * @param userId the primary key of the user 296 * @param roleIds the primary keys of the roles 297 * @throws PortalException if a user with the primary key could not be 298 found, if the user did not have permission to remove members from 299 a role, or if a role with any one of the primary keys could not 300 be found 301 */ 302 public static void unsetUserRoles(long userId, long[] roleIds) 303 throws com.liferay.portal.kernel.exception.PortalException { 304 getService().unsetUserRoles(userId, roleIds); 305 } 306 307 /** 308 * Updates the role with the primary key. 309 * 310 * @param roleId the primary key of the role 311 * @param name the role's new name 312 * @param titleMap the new localized titles (optionally <code>null</code>) 313 to replace those existing for the role 314 * @param descriptionMap the new localized descriptions (optionally 315 <code>null</code>) to replace those existing for the role 316 * @param subtype the role's new subtype (optionally <code>null</code>) 317 * @param serviceContext the service context to be applied (optionally 318 <code>null</code>). Can set the expando bridge attributes for the 319 role. 320 * @return the role with the primary key 321 * @throws PortalException if the user did not have permission to update the 322 role, if a role with the primary could not be found, or if the 323 role's name was invalid 324 */ 325 public static com.liferay.portal.model.Role updateRole(long roleId, 326 java.lang.String name, 327 java.util.Map<java.util.Locale, java.lang.String> titleMap, 328 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 329 java.lang.String subtype, 330 com.liferay.portal.service.ServiceContext serviceContext) 331 throws com.liferay.portal.kernel.exception.PortalException { 332 return getService() 333 .updateRole(roleId, name, titleMap, descriptionMap, subtype, 334 serviceContext); 335 } 336 337 public static RoleService getService() { 338 if (_service == null) { 339 _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName()); 340 341 ReferenceRegistry.registerReference(RoleServiceUtil.class, 342 "_service"); 343 } 344 345 return _service; 346 } 347 348 /** 349 * @deprecated As of 6.2.0 350 */ 351 @Deprecated 352 public void setService(RoleService service) { 353 } 354 355 private static RoleService _service; 356 }