001 /** 002 * Copyright (c) 2000-2012 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 com.liferay.portal.kernel.bean.PortalBeanLocatorUtil; 018 import com.liferay.portal.kernel.util.MethodCache; 019 import com.liferay.portal.kernel.util.ReferenceRegistry; 020 021 /** 022 * The utility for the role remote service. This utility wraps {@link com.liferay.portal.service.impl.RoleServiceImpl} and is the primary access point for service operations in application layer code running on a remote server. 023 * 024 * <p> 025 * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS credentials because this service can be accessed remotely. 026 * </p> 027 * 028 * @author Brian Wing Shun Chan 029 * @see RoleService 030 * @see com.liferay.portal.service.base.RoleServiceBaseImpl 031 * @see com.liferay.portal.service.impl.RoleServiceImpl 032 * @generated 033 */ 034 public class RoleServiceUtil { 035 /* 036 * NOTE FOR DEVELOPERS: 037 * 038 * Never modify this class directly. Add custom service methods to {@link com.liferay.portal.service.impl.RoleServiceImpl} and rerun ServiceBuilder to regenerate this class. 039 */ 040 041 /** 042 * Adds a role. The user is reindexed after role is added. 043 * 044 * @param name the role's name 045 * @param titleMap the role's localized titles (optionally 046 <code>null</code>) 047 * @param descriptionMap the role's localized descriptions (optionally 048 <code>null</code>) 049 * @param type the role's type (optionally <code>0</code>) 050 * @return the role 051 * @throws PortalException if a user with the primary key could not be 052 found, if the user did not have permission to add roles, if the 053 class name or the role name were invalid, or if the role is a 054 duplicate 055 * @throws SystemException if a system exception occurred 056 */ 057 public static com.liferay.portal.model.Role addRole(java.lang.String name, 058 java.util.Map<java.util.Locale, java.lang.String> titleMap, 059 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 060 int type) 061 throws com.liferay.portal.kernel.exception.PortalException, 062 com.liferay.portal.kernel.exception.SystemException { 063 return getService().addRole(name, titleMap, descriptionMap, type); 064 } 065 066 /** 067 * Adds the roles to the user. The user is reindexed after the roles are 068 * added. 069 * 070 * @param userId the primary key of the user 071 * @param roleIds the primary keys of the roles 072 * @throws PortalException if a user with the primary key could not be found 073 or if the user did not have permission to assign members to one 074 of the roles 075 * @throws SystemException if a system exception occurred 076 */ 077 public static void addUserRoles(long userId, long[] roleIds) 078 throws com.liferay.portal.kernel.exception.PortalException, 079 com.liferay.portal.kernel.exception.SystemException { 080 getService().addUserRoles(userId, roleIds); 081 } 082 083 /** 084 * Deletes the role with the primary key and its associated permissions. 085 * 086 * @param roleId the primary key of the role 087 * @throws PortalException if the user did not have permission to delete the 088 role, if a role with the primary key could not be found, if the 089 role is a default system role, or if the role's resource could 090 not be found 091 * @throws SystemException if a system exception occurred 092 */ 093 public static void deleteRole(long roleId) 094 throws com.liferay.portal.kernel.exception.PortalException, 095 com.liferay.portal.kernel.exception.SystemException { 096 getService().deleteRole(roleId); 097 } 098 099 /** 100 * Returns all the roles associated with the group. 101 * 102 * @param groupId the primary key of the group 103 * @return the roles associated with the group 104 * @throws PortalException if a portal exception occurred 105 * @throws SystemException if a system exception occurred 106 */ 107 public static java.util.List<com.liferay.portal.model.Role> getGroupRoles( 108 long groupId) 109 throws com.liferay.portal.kernel.exception.PortalException, 110 com.liferay.portal.kernel.exception.SystemException { 111 return getService().getGroupRoles(groupId); 112 } 113 114 /** 115 * Returns the role with the primary key. 116 * 117 * @param roleId the primary key of the role 118 * @return the role with the primary key 119 * @throws PortalException if a role with the primary key could not be found 120 or if the user did not have permission to view the role 121 * @throws SystemException if a system exception occurred 122 */ 123 public static com.liferay.portal.model.Role getRole(long roleId) 124 throws com.liferay.portal.kernel.exception.PortalException, 125 com.liferay.portal.kernel.exception.SystemException { 126 return getService().getRole(roleId); 127 } 128 129 /** 130 * Returns the role with the name in the company. 131 * 132 * <p> 133 * The method searches the system roles map first for default roles. If a 134 * role with the name is not found, then the method will query the database. 135 * </p> 136 * 137 * @param companyId the primary key of the company 138 * @param name the role's name 139 * @return the role with the name 140 * @throws PortalException if a role with the name could not be found in the 141 company or if the user did not have permission to view the role 142 * @throws SystemException if a system exception occurred 143 */ 144 public static com.liferay.portal.model.Role getRole(long companyId, 145 java.lang.String name) 146 throws com.liferay.portal.kernel.exception.PortalException, 147 com.liferay.portal.kernel.exception.SystemException { 148 return getService().getRole(companyId, name); 149 } 150 151 /** 152 * Returns all the user's roles within the user group. 153 * 154 * @param userId the primary key of the user 155 * @param groupId the primary key of the group 156 * @return the user's roles within the user group 157 * @throws PortalException if a portal exception occurred 158 * @throws SystemException if a system exception occurred 159 */ 160 public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles( 161 long userId, long groupId) 162 throws com.liferay.portal.kernel.exception.PortalException, 163 com.liferay.portal.kernel.exception.SystemException { 164 return getService().getUserGroupGroupRoles(userId, groupId); 165 } 166 167 /** 168 * Returns all the user's roles within the user group. 169 * 170 * @param userId the primary key of the user 171 * @param groupId the primary key of the group 172 * @return the user's roles within the user group 173 * @throws PortalException if a portal exception occurred 174 * @throws SystemException if a system exception occurred 175 */ 176 public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles( 177 long userId, long groupId) 178 throws com.liferay.portal.kernel.exception.PortalException, 179 com.liferay.portal.kernel.exception.SystemException { 180 return getService().getUserGroupRoles(userId, groupId); 181 } 182 183 /** 184 * Returns the union of all the user's roles within the groups. 185 * 186 * @param userId the primary key of the user 187 * @param groups the groups (optionally <code>null</code>) 188 * @return the union of all the user's roles within the groups 189 * @throws PortalException if a portal exception occurred 190 * @throws SystemException if a system exception occurred 191 */ 192 public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles( 193 long userId, java.util.List<com.liferay.portal.model.Group> groups) 194 throws com.liferay.portal.kernel.exception.PortalException, 195 com.liferay.portal.kernel.exception.SystemException { 196 return getService().getUserRelatedRoles(userId, groups); 197 } 198 199 /** 200 * Returns all the roles associated with the user. 201 * 202 * @param userId the primary key of the user 203 * @return the roles associated with the user 204 * @throws PortalException if a portal exception occurred 205 * @throws SystemException if a system exception occurred 206 */ 207 public static java.util.List<com.liferay.portal.model.Role> getUserRoles( 208 long userId) 209 throws com.liferay.portal.kernel.exception.PortalException, 210 com.liferay.portal.kernel.exception.SystemException { 211 return getService().getUserRoles(userId); 212 } 213 214 /** 215 * Returns <code>true</code> if the user is associated with the named 216 * regular role. 217 * 218 * @param userId the primary key of the user 219 * @param companyId the primary key of the company 220 * @param name the name of the role 221 * @param inherited whether to include the user's inherited roles in the 222 search 223 * @return <code>true</code> if the user is associated with the regular 224 role; <code>false</code> otherwise 225 * @throws PortalException if a role with the name could not be found in the 226 company or if a default user for the company could not be found 227 * @throws SystemException if a system exception occurred 228 */ 229 public static boolean hasUserRole(long userId, long companyId, 230 java.lang.String name, boolean inherited) 231 throws com.liferay.portal.kernel.exception.PortalException, 232 com.liferay.portal.kernel.exception.SystemException { 233 return getService().hasUserRole(userId, companyId, name, inherited); 234 } 235 236 /** 237 * Returns <code>true</code> if the user has any one of the named regular 238 * roles. 239 * 240 * @param userId the primary key of the user 241 * @param companyId the primary key of the company 242 * @param names the names of the roles 243 * @param inherited whether to include the user's inherited roles in the 244 search 245 * @return <code>true</code> if the user has any one of the regular roles; 246 <code>false</code> otherwise 247 * @throws PortalException if any one of the roles with the names could not 248 be found in the company or if the default user for the company 249 could not be found 250 * @throws SystemException if a system exception occurred 251 */ 252 public static boolean hasUserRoles(long userId, long companyId, 253 java.lang.String[] names, boolean inherited) 254 throws com.liferay.portal.kernel.exception.PortalException, 255 com.liferay.portal.kernel.exception.SystemException { 256 return getService().hasUserRoles(userId, companyId, names, inherited); 257 } 258 259 /** 260 * Removes the matching roles associated with the user. The user is 261 * reindexed after the roles are removed. 262 * 263 * @param userId the primary key of the user 264 * @param roleIds the primary keys of the roles 265 * @throws PortalException if a user with the primary key could not be 266 found, if the user did not have permission to remove members from 267 a role, or if a role with any one of the primary keys could not 268 be found 269 * @throws SystemException if a system exception occurred 270 */ 271 public static void unsetUserRoles(long userId, long[] roleIds) 272 throws com.liferay.portal.kernel.exception.PortalException, 273 com.liferay.portal.kernel.exception.SystemException { 274 getService().unsetUserRoles(userId, roleIds); 275 } 276 277 /** 278 * Updates the role with the primary key. 279 * 280 * @param roleId the primary key of the role 281 * @param name the role's new name 282 * @param titleMap the new localized titles (optionally <code>null</code>) 283 to replace those existing for the role 284 * @param descriptionMap the new localized descriptions (optionally 285 <code>null</code>) to replace those existing for the role 286 * @param subtype the role's new subtype (optionally <code>null</code>) 287 * @return the role with the primary key 288 * @throws PortalException if the user did not have permission to update the 289 role, if a role with the primary could not be found, or if the 290 role's name was invalid 291 * @throws SystemException if a system exception occurred 292 */ 293 public static com.liferay.portal.model.Role updateRole(long roleId, 294 java.lang.String name, 295 java.util.Map<java.util.Locale, java.lang.String> titleMap, 296 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 297 java.lang.String subtype) 298 throws com.liferay.portal.kernel.exception.PortalException, 299 com.liferay.portal.kernel.exception.SystemException { 300 return getService() 301 .updateRole(roleId, name, titleMap, descriptionMap, subtype); 302 } 303 304 public static RoleService getService() { 305 if (_service == null) { 306 _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName()); 307 308 ReferenceRegistry.registerReference(RoleServiceUtil.class, 309 "_service"); 310 MethodCache.remove(RoleService.class); 311 } 312 313 return _service; 314 } 315 316 public void setService(RoleService service) { 317 MethodCache.remove(RoleService.class); 318 319 _service = service; 320 321 ReferenceRegistry.registerReference(RoleServiceUtil.class, "_service"); 322 MethodCache.remove(RoleService.class); 323 } 324 325 private static RoleService _service; 326 }