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