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