001 /** 002 * Copyright (c) 2000-2011 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 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 073 found or if the user did not have permission to assign members 074 to one 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 088 the role, if a role with the primary key could not be found, if 089 the role is a default system role, or if the role's resource 090 could 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 120 found 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 135 * database. 136 * </p> 137 * 138 * @param companyId the primary key of the company 139 * @param name the role's name 140 * @return the role with the name 141 * @throws PortalException if a role with the name could not be found in 142 the company or if the user did not have permission to view the 143 role 144 * @throws SystemException if a system exception occurred 145 */ 146 public static com.liferay.portal.model.Role getRole(long companyId, 147 java.lang.String name) 148 throws com.liferay.portal.kernel.exception.PortalException, 149 com.liferay.portal.kernel.exception.SystemException { 150 return getService().getRole(companyId, name); 151 } 152 153 /** 154 * Returns all the user's roles within the user group. 155 * 156 * @param userId the primary key of the user 157 * @param groupId the primary key of the group 158 * @return the user's roles within the user group 159 * @throws PortalException if a portal exception occurred 160 * @throws SystemException if a system exception occurred 161 */ 162 public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles( 163 long userId, long groupId) 164 throws com.liferay.portal.kernel.exception.PortalException, 165 com.liferay.portal.kernel.exception.SystemException { 166 return getService().getUserGroupGroupRoles(userId, groupId); 167 } 168 169 /** 170 * Returns all the user's roles within the user group. 171 * 172 * @param userId the primary key of the user 173 * @param groupId the primary key of the group 174 * @return the user's roles within the user group 175 * @throws PortalException if a portal exception occurred 176 * @throws SystemException if a system exception occurred 177 */ 178 public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles( 179 long userId, long groupId) 180 throws com.liferay.portal.kernel.exception.PortalException, 181 com.liferay.portal.kernel.exception.SystemException { 182 return getService().getUserGroupRoles(userId, groupId); 183 } 184 185 /** 186 * Returns the union of all the user's roles within the groups. 187 * 188 * @param userId the primary key of the user 189 * @param groups the groups (optionally <code>null</code>) 190 * @return the union of all the user's roles within the groups 191 * @throws PortalException if a portal exception occurred 192 * @throws SystemException if a system exception occurred 193 */ 194 public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles( 195 long userId, java.util.List<com.liferay.portal.model.Group> groups) 196 throws com.liferay.portal.kernel.exception.PortalException, 197 com.liferay.portal.kernel.exception.SystemException { 198 return getService().getUserRelatedRoles(userId, groups); 199 } 200 201 /** 202 * Returns all the roles associated with the user. 203 * 204 * @param userId the primary key of the user 205 * @return the roles associated with the user 206 * @throws PortalException if a portal exception occurred 207 * @throws SystemException if a system exception occurred 208 */ 209 public static java.util.List<com.liferay.portal.model.Role> getUserRoles( 210 long userId) 211 throws com.liferay.portal.kernel.exception.PortalException, 212 com.liferay.portal.kernel.exception.SystemException { 213 return getService().getUserRoles(userId); 214 } 215 216 /** 217 * Returns <code>true</code> if the user is associated with the named 218 * regular role. 219 * 220 * @param userId the primary key of the user 221 * @param companyId the primary key of the company 222 * @param name the name of the role 223 * @param inherited whether to include the user's inherited roles in the 224 search 225 * @return <code>true</code> if the user is associated with the regular 226 role; <code>false</code> otherwise 227 * @throws PortalException if a role with the name could not be found in 228 the company or if a default user for the company could not be 229 found 230 * @throws SystemException if a system exception occurred 231 */ 232 public static boolean hasUserRole(long userId, long companyId, 233 java.lang.String name, boolean inherited) 234 throws com.liferay.portal.kernel.exception.PortalException, 235 com.liferay.portal.kernel.exception.SystemException { 236 return getService().hasUserRole(userId, companyId, name, inherited); 237 } 238 239 /** 240 * Returns <code>true</code> if the user has any one of the named regular 241 * roles. 242 * 243 * @param userId the primary key of the user 244 * @param companyId the primary key of the company 245 * @param names the names of the roles 246 * @param inherited whether to include the user's inherited roles in the 247 search 248 * @return <code>true</code> if the user has any one of the regular roles; 249 <code>false</code> otherwise 250 * @throws PortalException if any one of the roles with the names could not 251 be found in the company or if the default user for the company 252 could not be found 253 * @throws SystemException if a system exception occurred 254 */ 255 public static boolean hasUserRoles(long userId, long companyId, 256 java.lang.String[] names, boolean inherited) 257 throws com.liferay.portal.kernel.exception.PortalException, 258 com.liferay.portal.kernel.exception.SystemException { 259 return getService().hasUserRoles(userId, companyId, names, inherited); 260 } 261 262 /** 263 * Removes the matching roles associated with the user. The user is 264 * reindexed after the roles are removed. 265 * 266 * @param userId the primary key of the user 267 * @param roleIds the primary keys of the roles 268 * @throws PortalException if a user with the primary key could not be 269 found, if the user did not have permission to remove members 270 from a role, or if a role with any one of the primary keys could 271 not be found 272 * @throws SystemException if a system exception occurred 273 */ 274 public static void unsetUserRoles(long userId, long[] roleIds) 275 throws com.liferay.portal.kernel.exception.PortalException, 276 com.liferay.portal.kernel.exception.SystemException { 277 getService().unsetUserRoles(userId, roleIds); 278 } 279 280 /** 281 * Updates the role with the primary key. 282 * 283 * @param roleId the primary key of the role 284 * @param name the role's new name 285 * @param titleMap the new localized titles (optionally <code>null</code>) 286 to replace those existing for the role 287 * @param descriptionMap the new localized descriptions (optionally 288 <code>null</code>) to replace those existing for the role 289 * @param subtype the role's new subtype (optionally <code>null</code>) 290 * @return the role with the primary key 291 * @throws PortalException if the user did not have permission to update 292 the role, if a role with the primary could not be found, or if 293 the role's name was invalid 294 * @throws SystemException if a system exception occurred 295 */ 296 public static com.liferay.portal.model.Role updateRole(long roleId, 297 java.lang.String name, 298 java.util.Map<java.util.Locale, java.lang.String> titleMap, 299 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 300 java.lang.String subtype) 301 throws com.liferay.portal.kernel.exception.PortalException, 302 com.liferay.portal.kernel.exception.SystemException { 303 return getService() 304 .updateRole(roleId, name, titleMap, descriptionMap, subtype); 305 } 306 307 public static RoleService getService() { 308 if (_service == null) { 309 _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName()); 310 311 ReferenceRegistry.registerReference(RoleServiceUtil.class, 312 "_service"); 313 MethodCache.remove(RoleService.class); 314 } 315 316 return _service; 317 } 318 319 public void setService(RoleService service) { 320 MethodCache.remove(RoleService.class); 321 322 _service = service; 323 324 ReferenceRegistry.registerReference(RoleServiceUtil.class, "_service"); 325 MethodCache.remove(RoleService.class); 326 } 327 328 private static RoleService _service; 329 }