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