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