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            */
062            public static com.liferay.portal.model.Role addRole(
063                    java.lang.String className, long classPK, java.lang.String name,
064                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
065                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
066                    int type, java.lang.String subtype,
067                    com.liferay.portal.service.ServiceContext serviceContext)
068                    throws com.liferay.portal.kernel.exception.PortalException {
069                    return getService()
070                                       .addRole(className, classPK, name, titleMap, descriptionMap,
071                            type, subtype, serviceContext);
072            }
073    
074            /**
075            * Adds the roles to the user. The user is reindexed after the roles are
076            * added.
077            *
078            * @param userId the primary key of the user
079            * @param roleIds the primary keys of the roles
080            */
081            public static void addUserRoles(long userId, long[] roleIds)
082                    throws com.liferay.portal.kernel.exception.PortalException {
083                    getService().addUserRoles(userId, roleIds);
084            }
085    
086            /**
087            * Deletes the role with the primary key and its associated permissions.
088            *
089            * @param roleId the primary key of the role
090            */
091            public static void deleteRole(long roleId)
092                    throws com.liferay.portal.kernel.exception.PortalException {
093                    getService().deleteRole(roleId);
094            }
095    
096            public static com.liferay.portal.model.Role fetchRole(long roleId)
097                    throws com.liferay.portal.kernel.exception.PortalException {
098                    return getService().fetchRole(roleId);
099            }
100    
101            /**
102            * Returns all the roles associated with the group.
103            *
104            * @param groupId the primary key of the group
105            * @return the roles associated with the group
106            */
107            public static java.util.List<com.liferay.portal.model.Role> getGroupRoles(
108                    long groupId)
109                    throws com.liferay.portal.kernel.exception.PortalException {
110                    return getService().getGroupRoles(groupId);
111            }
112    
113            /**
114            * Returns the OSGi service identifier.
115            *
116            * @return the OSGi service identifier
117            */
118            public static java.lang.String getOSGiServiceIdentifier() {
119                    return getService().getOSGiServiceIdentifier();
120            }
121    
122            /**
123            * Returns the role with the name in the company.
124            *
125            * <p>
126            * The method searches the system roles map first for default roles. If a
127            * role with the name is not found, then the method will query the database.
128            * </p>
129            *
130            * @param companyId the primary key of the company
131            * @param name the role's name
132            * @return the role with the name
133            */
134            public static com.liferay.portal.model.Role getRole(long companyId,
135                    java.lang.String name)
136                    throws com.liferay.portal.kernel.exception.PortalException {
137                    return getService().getRole(companyId, name);
138            }
139    
140            /**
141            * Returns the role with the primary key.
142            *
143            * @param roleId the primary key of the role
144            * @return the role with the primary key
145            */
146            public static com.liferay.portal.model.Role getRole(long roleId)
147                    throws com.liferay.portal.kernel.exception.PortalException {
148                    return getService().getRole(roleId);
149            }
150    
151            public static java.util.List<com.liferay.portal.model.Role> getRoles(
152                    long companyId, int[] types)
153                    throws com.liferay.portal.kernel.exception.PortalException {
154                    return getService().getRoles(companyId, types);
155            }
156    
157            public static java.util.List<com.liferay.portal.model.Role> getRoles(
158                    int type, java.lang.String subtype)
159                    throws com.liferay.portal.kernel.exception.PortalException {
160                    return getService().getRoles(type, subtype);
161            }
162    
163            /**
164            * Returns all the user's roles within the user group.
165            *
166            * @param userId the primary key of the user
167            * @param groupId the primary key of the group
168            * @return the user's roles within the user group
169            */
170            public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles(
171                    long userId, long groupId)
172                    throws com.liferay.portal.kernel.exception.PortalException {
173                    return getService().getUserGroupGroupRoles(userId, groupId);
174            }
175    
176            /**
177            * Returns all the user's roles within the user group.
178            *
179            * @param userId the primary key of the user
180            * @param groupId the primary key of the group
181            * @return the user's roles within the user group
182            */
183            public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles(
184                    long userId, long groupId)
185                    throws com.liferay.portal.kernel.exception.PortalException {
186                    return getService().getUserGroupRoles(userId, groupId);
187            }
188    
189            /**
190            * Returns the union of all the user's roles within the groups.
191            *
192            * @param userId the primary key of the user
193            * @param groups the groups (optionally <code>null</code>)
194            * @return the union of all the user's roles within the groups
195            */
196            public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles(
197                    long userId, java.util.List<com.liferay.portal.model.Group> groups)
198                    throws com.liferay.portal.kernel.exception.PortalException {
199                    return getService().getUserRelatedRoles(userId, groups);
200            }
201    
202            /**
203            * Returns all the roles associated with the user.
204            *
205            * @param userId the primary key of the user
206            * @return the roles associated with the user
207            */
208            public static java.util.List<com.liferay.portal.model.Role> getUserRoles(
209                    long userId) throws com.liferay.portal.kernel.exception.PortalException {
210                    return getService().getUserRoles(userId);
211            }
212    
213            /**
214            * Returns <code>true</code> if the user is associated with the named
215            * regular role.
216            *
217            * @param userId the primary key of the user
218            * @param companyId the primary key of the company
219            * @param name the name of the role
220            * @param inherited whether to include the user's inherited roles in the
221            search
222            * @return <code>true</code> if the user is associated with the regular
223            role; <code>false</code> otherwise
224            */
225            public static boolean hasUserRole(long userId, long companyId,
226                    java.lang.String name, boolean inherited)
227                    throws com.liferay.portal.kernel.exception.PortalException {
228                    return getService().hasUserRole(userId, companyId, name, inherited);
229            }
230    
231            /**
232            * Returns <code>true</code> if the user has any one of the named regular
233            * roles.
234            *
235            * @param userId the primary key of the user
236            * @param companyId the primary key of the company
237            * @param names the names of the roles
238            * @param inherited whether to include the user's inherited roles in the
239            search
240            * @return <code>true</code> if the user has any one of the regular roles;
241            <code>false</code> otherwise
242            */
243            public static boolean hasUserRoles(long userId, long companyId,
244                    java.lang.String[] names, boolean inherited)
245                    throws com.liferay.portal.kernel.exception.PortalException {
246                    return getService().hasUserRoles(userId, companyId, names, inherited);
247            }
248    
249            public static java.util.List<com.liferay.portal.model.Role> search(
250                    long companyId, java.lang.String keywords, java.lang.Integer[] types,
251                    java.util.LinkedHashMap<java.lang.String, java.lang.Object> params,
252                    int start, int end,
253                    com.liferay.portal.kernel.util.OrderByComparator<com.liferay.portal.model.Role> obc) {
254                    return getService()
255                                       .search(companyId, keywords, types, params, start, end, obc);
256            }
257    
258            public static int searchCount(long companyId, java.lang.String keywords,
259                    java.lang.Integer[] types,
260                    java.util.LinkedHashMap<java.lang.String, java.lang.Object> params) {
261                    return getService().searchCount(companyId, keywords, types, params);
262            }
263    
264            /**
265            * Removes the matching roles associated with the user. The user is
266            * reindexed after the roles are removed.
267            *
268            * @param userId the primary key of the user
269            * @param roleIds the primary keys of the roles
270            */
271            public static void unsetUserRoles(long userId, long[] roleIds)
272                    throws com.liferay.portal.kernel.exception.PortalException {
273                    getService().unsetUserRoles(userId, roleIds);
274            }
275    
276            /**
277            * Updates the role with the primary key.
278            *
279            * @param roleId the primary key of the role
280            * @param name the role's new name
281            * @param titleMap the new localized titles (optionally <code>null</code>)
282            to replace those existing for the role
283            * @param descriptionMap the new localized descriptions (optionally
284            <code>null</code>) to replace those existing for the role
285            * @param subtype the role's new subtype (optionally <code>null</code>)
286            * @param serviceContext the service context to be applied (optionally
287            <code>null</code>). Can set the expando bridge attributes for the
288            role.
289            * @return the role with the primary key
290            */
291            public static com.liferay.portal.model.Role updateRole(long roleId,
292                    java.lang.String name,
293                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
294                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
295                    java.lang.String subtype,
296                    com.liferay.portal.service.ServiceContext serviceContext)
297                    throws com.liferay.portal.kernel.exception.PortalException {
298                    return getService()
299                                       .updateRole(roleId, name, titleMap, descriptionMap, subtype,
300                            serviceContext);
301            }
302    
303            public static RoleService getService() {
304                    if (_service == null) {
305                            _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName());
306    
307                            ReferenceRegistry.registerReference(RoleServiceUtil.class,
308                                    "_service");
309                    }
310    
311                    return _service;
312            }
313    
314            private static RoleService _service;
315    }