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.kernel.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.kernel.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.kernel.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.kernel.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.kernel.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.kernel.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.kernel.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.kernel.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.kernel.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.kernel.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.kernel.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.kernel.model.Role> getUserRelatedRoles(
197                    long userId,
198                    java.util.List<com.liferay.portal.kernel.model.Group> groups)
199                    throws com.liferay.portal.kernel.exception.PortalException {
200                    return getService().getUserRelatedRoles(userId, groups);
201            }
202    
203            /**
204            * Returns all the roles associated with the user.
205            *
206            * @param userId the primary key of the user
207            * @return the roles associated with the user
208            */
209            public static java.util.List<com.liferay.portal.kernel.model.Role> getUserRoles(
210                    long userId) throws com.liferay.portal.kernel.exception.PortalException {
211                    return getService().getUserRoles(userId);
212            }
213    
214            /**
215            * Returns <code>true</code> if the user is associated with the named
216            * regular role.
217            *
218            * @param userId the primary key of the user
219            * @param companyId the primary key of the company
220            * @param name the name of the role
221            * @param inherited whether to include the user's inherited roles in the
222            search
223            * @return <code>true</code> if the user is associated with the regular
224            role; <code>false</code> otherwise
225            */
226            public static boolean hasUserRole(long userId, long companyId,
227                    java.lang.String name, boolean inherited)
228                    throws com.liferay.portal.kernel.exception.PortalException {
229                    return getService().hasUserRole(userId, companyId, name, inherited);
230            }
231    
232            /**
233            * Returns <code>true</code> if the user has any one of the named regular
234            * roles.
235            *
236            * @param userId the primary key of the user
237            * @param companyId the primary key of the company
238            * @param names the names of the roles
239            * @param inherited whether to include the user's inherited roles in the
240            search
241            * @return <code>true</code> if the user has any one of the regular roles;
242            <code>false</code> otherwise
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                    return getService().hasUserRoles(userId, companyId, names, inherited);
248            }
249    
250            public static java.util.List<com.liferay.portal.kernel.model.Role> search(
251                    long companyId, java.lang.String keywords, java.lang.Integer[] types,
252                    java.util.LinkedHashMap<java.lang.String, java.lang.Object> params,
253                    int start, int end,
254                    com.liferay.portal.kernel.util.OrderByComparator<com.liferay.portal.kernel.model.Role> obc) {
255                    return getService()
256                                       .search(companyId, keywords, types, params, start, end, obc);
257            }
258    
259            public static int searchCount(long companyId, java.lang.String keywords,
260                    java.lang.Integer[] types,
261                    java.util.LinkedHashMap<java.lang.String, java.lang.Object> params) {
262                    return getService().searchCount(companyId, keywords, types, params);
263            }
264    
265            /**
266            * Removes the matching roles associated with the user. The user is
267            * reindexed after the roles are removed.
268            *
269            * @param userId the primary key of the user
270            * @param roleIds the primary keys of the roles
271            */
272            public static void unsetUserRoles(long userId, long[] roleIds)
273                    throws com.liferay.portal.kernel.exception.PortalException {
274                    getService().unsetUserRoles(userId, roleIds);
275            }
276    
277            /**
278            * Updates the role with the primary key.
279            *
280            * @param roleId the primary key of the role
281            * @param name the role's new name
282            * @param titleMap the new localized titles (optionally <code>null</code>)
283            to replace those existing for the role
284            * @param descriptionMap the new localized descriptions (optionally
285            <code>null</code>) to replace those existing for the role
286            * @param subtype the role's new subtype (optionally <code>null</code>)
287            * @param serviceContext the service context to be applied (optionally
288            <code>null</code>). Can set the expando bridge attributes for the
289            role.
290            * @return the role with the primary key
291            */
292            public static com.liferay.portal.kernel.model.Role updateRole(long roleId,
293                    java.lang.String name,
294                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
295                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
296                    java.lang.String subtype,
297                    com.liferay.portal.kernel.service.ServiceContext serviceContext)
298                    throws com.liferay.portal.kernel.exception.PortalException {
299                    return getService()
300                                       .updateRole(roleId, name, titleMap, descriptionMap, subtype,
301                            serviceContext);
302            }
303    
304            public static RoleService getService() {
305                    if (_service == null) {
306                            _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName());
307    
308                            ReferenceRegistry.registerReference(RoleServiceUtil.class,
309                                    "_service");
310                    }
311    
312                    return _service;
313            }
314    
315            private static RoleService _service;
316    }