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