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