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.kernel.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 <code>true</code> if the user is associated with the named 046 * regular role. 047 * 048 * @param userId the primary key of the user 049 * @param companyId the primary key of the company 050 * @param name the name of the role 051 * @param inherited whether to include the user's inherited roles in the 052 search 053 * @return <code>true</code> if the user is associated with the regular 054 role; <code>false</code> otherwise 055 */ 056 public static boolean hasUserRole(long userId, long companyId, 057 java.lang.String name, boolean inherited) 058 throws com.liferay.portal.kernel.exception.PortalException { 059 return getService().hasUserRole(userId, companyId, name, inherited); 060 } 061 062 /** 063 * Returns <code>true</code> if the user has any one of the named regular 064 * roles. 065 * 066 * @param userId the primary key of the user 067 * @param companyId the primary key of the company 068 * @param names the names of the roles 069 * @param inherited whether to include the user's inherited roles in the 070 search 071 * @return <code>true</code> if the user has any one of the regular roles; 072 <code>false</code> otherwise 073 */ 074 public static boolean hasUserRoles(long userId, long companyId, 075 java.lang.String[] names, boolean inherited) 076 throws com.liferay.portal.kernel.exception.PortalException { 077 return getService().hasUserRoles(userId, companyId, names, inherited); 078 } 079 080 /** 081 * Adds a role. The user is reindexed after role is added. 082 * 083 * @param className the name of the class for which the role is created 084 * @param classPK the primary key of the class for which the role is 085 created (optionally <code>0</code>) 086 * @param name the role's name 087 * @param titleMap the role's localized titles (optionally 088 <code>null</code>) 089 * @param descriptionMap the role's localized descriptions (optionally 090 <code>null</code>) 091 * @param type the role's type (optionally <code>0</code>) 092 * @param subtype the role's subtype (optionally <code>null</code>) 093 * @param serviceContext the service context to be applied (optionally 094 <code>null</code>). Can set the expando bridge attributes for the 095 role. 096 * @return the role 097 */ 098 public static com.liferay.portal.kernel.model.Role addRole( 099 java.lang.String className, long classPK, java.lang.String name, 100 java.util.Map<java.util.Locale, java.lang.String> titleMap, 101 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 102 int type, java.lang.String subtype, ServiceContext serviceContext) 103 throws com.liferay.portal.kernel.exception.PortalException { 104 return getService() 105 .addRole(className, classPK, name, titleMap, descriptionMap, 106 type, subtype, serviceContext); 107 } 108 109 public static com.liferay.portal.kernel.model.Role fetchRole(long roleId) 110 throws com.liferay.portal.kernel.exception.PortalException { 111 return getService().fetchRole(roleId); 112 } 113 114 /** 115 * Returns the role with the name in the company. 116 * 117 * <p> 118 * The method searches the system roles map first for default roles. If a 119 * role with the name is not found, then the method will query the database. 120 * </p> 121 * 122 * @param companyId the primary key of the company 123 * @param name the role's name 124 * @return the role with the name 125 */ 126 public static com.liferay.portal.kernel.model.Role getRole(long companyId, 127 java.lang.String name) 128 throws com.liferay.portal.kernel.exception.PortalException { 129 return getService().getRole(companyId, name); 130 } 131 132 /** 133 * Returns the role with the primary key. 134 * 135 * @param roleId the primary key of the role 136 * @return the role with the primary key 137 */ 138 public static com.liferay.portal.kernel.model.Role getRole(long roleId) 139 throws com.liferay.portal.kernel.exception.PortalException { 140 return getService().getRole(roleId); 141 } 142 143 /** 144 * Updates the role with the primary key. 145 * 146 * @param roleId the primary key of the role 147 * @param name the role's new name 148 * @param titleMap the new localized titles (optionally <code>null</code>) 149 to replace those existing for the role 150 * @param descriptionMap the new localized descriptions (optionally 151 <code>null</code>) to replace those existing for the role 152 * @param subtype the role's new subtype (optionally <code>null</code>) 153 * @param serviceContext the service context to be applied (optionally 154 <code>null</code>). Can set the expando bridge attributes for the 155 role. 156 * @return the role with the primary key 157 */ 158 public static com.liferay.portal.kernel.model.Role updateRole(long roleId, 159 java.lang.String name, 160 java.util.Map<java.util.Locale, java.lang.String> titleMap, 161 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 162 java.lang.String subtype, ServiceContext serviceContext) 163 throws com.liferay.portal.kernel.exception.PortalException { 164 return getService() 165 .updateRole(roleId, name, titleMap, descriptionMap, subtype, 166 serviceContext); 167 } 168 169 public static int searchCount(long companyId, java.lang.String keywords, 170 java.lang.Integer[] types, 171 java.util.LinkedHashMap<java.lang.String, java.lang.Object> params) { 172 return getService().searchCount(companyId, keywords, types, params); 173 } 174 175 /** 176 * Returns the OSGi service identifier. 177 * 178 * @return the OSGi service identifier 179 */ 180 public static java.lang.String getOSGiServiceIdentifier() { 181 return getService().getOSGiServiceIdentifier(); 182 } 183 184 /** 185 * Returns all the roles associated with the group. 186 * 187 * @param groupId the primary key of the group 188 * @return the roles associated with the group 189 */ 190 public static java.util.List<com.liferay.portal.kernel.model.Role> getGroupRoles( 191 long groupId) 192 throws com.liferay.portal.kernel.exception.PortalException { 193 return getService().getGroupRoles(groupId); 194 } 195 196 public static java.util.List<com.liferay.portal.kernel.model.Role> getRoles( 197 int type, java.lang.String subtype) 198 throws com.liferay.portal.kernel.exception.PortalException { 199 return getService().getRoles(type, subtype); 200 } 201 202 public static java.util.List<com.liferay.portal.kernel.model.Role> getRoles( 203 long companyId, int[] types) 204 throws com.liferay.portal.kernel.exception.PortalException { 205 return getService().getRoles(companyId, types); 206 } 207 208 /** 209 * Returns all the user's roles within the user group. 210 * 211 * @param userId the primary key of the user 212 * @param groupId the primary key of the group 213 * @return the user's roles within the user group 214 */ 215 public static java.util.List<com.liferay.portal.kernel.model.Role> getUserGroupGroupRoles( 216 long userId, long groupId) 217 throws com.liferay.portal.kernel.exception.PortalException { 218 return getService().getUserGroupGroupRoles(userId, groupId); 219 } 220 221 /** 222 * Returns all the user's roles within the user group. 223 * 224 * @param userId the primary key of the user 225 * @param groupId the primary key of the group 226 * @return the user's roles within the user group 227 */ 228 public static java.util.List<com.liferay.portal.kernel.model.Role> getUserGroupRoles( 229 long userId, long groupId) 230 throws com.liferay.portal.kernel.exception.PortalException { 231 return getService().getUserGroupRoles(userId, groupId); 232 } 233 234 /** 235 * Returns the union of all the user's roles within the groups. 236 * 237 * @param userId the primary key of the user 238 * @param groups the groups (optionally <code>null</code>) 239 * @return the union of all the user's roles within the groups 240 */ 241 public static java.util.List<com.liferay.portal.kernel.model.Role> getUserRelatedRoles( 242 long userId, 243 java.util.List<com.liferay.portal.kernel.model.Group> groups) 244 throws com.liferay.portal.kernel.exception.PortalException { 245 return getService().getUserRelatedRoles(userId, groups); 246 } 247 248 /** 249 * Returns all the roles associated with the user. 250 * 251 * @param userId the primary key of the user 252 * @return the roles associated with the user 253 */ 254 public static java.util.List<com.liferay.portal.kernel.model.Role> getUserRoles( 255 long userId) throws com.liferay.portal.kernel.exception.PortalException { 256 return getService().getUserRoles(userId); 257 } 258 259 public static java.util.List<com.liferay.portal.kernel.model.Role> search( 260 long companyId, java.lang.String keywords, java.lang.Integer[] types, 261 java.util.LinkedHashMap<java.lang.String, java.lang.Object> params, 262 int start, int end, 263 com.liferay.portal.kernel.util.OrderByComparator<com.liferay.portal.kernel.model.Role> obc) { 264 return getService() 265 .search(companyId, keywords, types, params, start, end, obc); 266 } 267 268 /** 269 * Adds the roles to the user. The user is reindexed after the roles are 270 * added. 271 * 272 * @param userId the primary key of the user 273 * @param roleIds the primary keys of the roles 274 */ 275 public static void addUserRoles(long userId, long[] roleIds) 276 throws com.liferay.portal.kernel.exception.PortalException { 277 getService().addUserRoles(userId, roleIds); 278 } 279 280 /** 281 * Deletes the role with the primary key and its associated permissions. 282 * 283 * @param roleId the primary key of the role 284 */ 285 public static void deleteRole(long roleId) 286 throws com.liferay.portal.kernel.exception.PortalException { 287 getService().deleteRole(roleId); 288 } 289 290 /** 291 * Removes the matching roles associated with the user. The user is 292 * reindexed after the roles are removed. 293 * 294 * @param userId the primary key of the user 295 * @param roleIds the primary keys of the roles 296 */ 297 public static void unsetUserRoles(long userId, long[] roleIds) 298 throws com.liferay.portal.kernel.exception.PortalException { 299 getService().unsetUserRoles(userId, roleIds); 300 } 301 302 public static RoleService getService() { 303 if (_service == null) { 304 _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName()); 305 306 ReferenceRegistry.registerReference(RoleServiceUtil.class, 307 "_service"); 308 } 309 310 return _service; 311 } 312 313 private static RoleService _service; 314 }