001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 name the role's name
062            * @param titleMap the role's localized titles (optionally
063            <code>null</code>)
064            * @param descriptionMap the role's localized descriptions (optionally
065            <code>null</code>)
066            * @param type the role's type (optionally <code>0</code>)
067            * @return the role
068            * @throws PortalException if a user with the primary key could not be
069            found, if the user did not have permission to add roles, if the
070            class name or the role name were invalid, or if the role is a
071            duplicate
072            * @throws SystemException if a system exception occurred
073            */
074            public static com.liferay.portal.model.Role addRole(java.lang.String name,
075                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
076                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
077                    int type)
078                    throws com.liferay.portal.kernel.exception.PortalException,
079                            com.liferay.portal.kernel.exception.SystemException {
080                    return getService().addRole(name, titleMap, descriptionMap, type);
081            }
082    
083            /**
084            * Adds the roles to the user. The user is reindexed after the roles are
085            * added.
086            *
087            * @param userId the primary key of the user
088            * @param roleIds the primary keys of the roles
089            * @throws PortalException if a user with the primary key could not be found
090            or if the user did not have permission to assign members to one
091            of the roles
092            * @throws SystemException if a system exception occurred
093            */
094            public static void addUserRoles(long userId, long[] roleIds)
095                    throws com.liferay.portal.kernel.exception.PortalException,
096                            com.liferay.portal.kernel.exception.SystemException {
097                    getService().addUserRoles(userId, roleIds);
098            }
099    
100            /**
101            * Deletes the role with the primary key and its associated permissions.
102            *
103            * @param roleId the primary key of the role
104            * @throws PortalException if the user did not have permission to delete the
105            role, if a role with the primary key could not be found, if the
106            role is a default system role, or if the role's resource could
107            not be found
108            * @throws SystemException if a system exception occurred
109            */
110            public static void deleteRole(long roleId)
111                    throws com.liferay.portal.kernel.exception.PortalException,
112                            com.liferay.portal.kernel.exception.SystemException {
113                    getService().deleteRole(roleId);
114            }
115    
116            /**
117            * Returns all the roles associated with the group.
118            *
119            * @param groupId the primary key of the group
120            * @return the roles associated with the group
121            * @throws PortalException if a portal exception occurred
122            * @throws SystemException if a system exception occurred
123            */
124            public static java.util.List<com.liferay.portal.model.Role> getGroupRoles(
125                    long groupId)
126                    throws com.liferay.portal.kernel.exception.PortalException,
127                            com.liferay.portal.kernel.exception.SystemException {
128                    return getService().getGroupRoles(groupId);
129            }
130    
131            /**
132            * Returns the role with the primary key.
133            *
134            * @param roleId the primary key of the role
135            * @return the role with the primary key
136            * @throws PortalException if a role with the primary key could not be found
137            or if the user did not have permission to view the role
138            * @throws SystemException if a system exception occurred
139            */
140            public static com.liferay.portal.model.Role getRole(long roleId)
141                    throws com.liferay.portal.kernel.exception.PortalException,
142                            com.liferay.portal.kernel.exception.SystemException {
143                    return getService().getRole(roleId);
144            }
145    
146            /**
147            * Returns the role with the name in the company.
148            *
149            * <p>
150            * The method searches the system roles map first for default roles. If a
151            * role with the name is not found, then the method will query the database.
152            * </p>
153            *
154            * @param companyId the primary key of the company
155            * @param name the role's name
156            * @return the role with the name
157            * @throws PortalException if a role with the name could not be found in the
158            company or if the user did not have permission to view the role
159            * @throws SystemException if a system exception occurred
160            */
161            public static com.liferay.portal.model.Role getRole(long companyId,
162                    java.lang.String name)
163                    throws com.liferay.portal.kernel.exception.PortalException,
164                            com.liferay.portal.kernel.exception.SystemException {
165                    return getService().getRole(companyId, name);
166            }
167    
168            /**
169            * Returns all the user's roles within the user group.
170            *
171            * @param userId the primary key of the user
172            * @param groupId the primary key of the group
173            * @return the user's roles within the user group
174            * @throws PortalException if a portal exception occurred
175            * @throws SystemException if a system exception occurred
176            */
177            public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles(
178                    long userId, long groupId)
179                    throws com.liferay.portal.kernel.exception.PortalException,
180                            com.liferay.portal.kernel.exception.SystemException {
181                    return getService().getUserGroupGroupRoles(userId, groupId);
182            }
183    
184            /**
185            * Returns all the user's roles within the user group.
186            *
187            * @param userId the primary key of the user
188            * @param groupId the primary key of the group
189            * @return the user's roles within the user group
190            * @throws PortalException if a portal exception occurred
191            * @throws SystemException if a system exception occurred
192            */
193            public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles(
194                    long userId, long groupId)
195                    throws com.liferay.portal.kernel.exception.PortalException,
196                            com.liferay.portal.kernel.exception.SystemException {
197                    return getService().getUserGroupRoles(userId, groupId);
198            }
199    
200            /**
201            * Returns the union of all the user's roles within the groups.
202            *
203            * @param userId the primary key of the user
204            * @param groups the groups (optionally <code>null</code>)
205            * @return the union of all the user's roles within the groups
206            * @throws PortalException if a portal exception occurred
207            * @throws SystemException if a system exception occurred
208            */
209            public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles(
210                    long userId, java.util.List<com.liferay.portal.model.Group> groups)
211                    throws com.liferay.portal.kernel.exception.PortalException,
212                            com.liferay.portal.kernel.exception.SystemException {
213                    return getService().getUserRelatedRoles(userId, groups);
214            }
215    
216            /**
217            * Returns all the roles associated with the user.
218            *
219            * @param userId the primary key of the user
220            * @return the roles associated with the user
221            * @throws PortalException if a portal exception occurred
222            * @throws SystemException if a system exception occurred
223            */
224            public static java.util.List<com.liferay.portal.model.Role> getUserRoles(
225                    long userId)
226                    throws com.liferay.portal.kernel.exception.PortalException,
227                            com.liferay.portal.kernel.exception.SystemException {
228                    return getService().getUserRoles(userId);
229            }
230    
231            /**
232            * Returns <code>true</code> if the user is associated with the named
233            * regular role.
234            *
235            * @param userId the primary key of the user
236            * @param companyId the primary key of the company
237            * @param name the name of the role
238            * @param inherited whether to include the user's inherited roles in the
239            search
240            * @return <code>true</code> if the user is associated with the regular
241            role; <code>false</code> otherwise
242            * @throws PortalException if a role with the name could not be found in the
243            company or if a default user for the company could not be found
244            * @throws SystemException if a system exception occurred
245            */
246            public static boolean hasUserRole(long userId, long companyId,
247                    java.lang.String name, boolean inherited)
248                    throws com.liferay.portal.kernel.exception.PortalException,
249                            com.liferay.portal.kernel.exception.SystemException {
250                    return getService().hasUserRole(userId, companyId, name, inherited);
251            }
252    
253            /**
254            * Returns <code>true</code> if the user has any one of the named regular
255            * roles.
256            *
257            * @param userId the primary key of the user
258            * @param companyId the primary key of the company
259            * @param names the names of the roles
260            * @param inherited whether to include the user's inherited roles in the
261            search
262            * @return <code>true</code> if the user has any one of the regular roles;
263            <code>false</code> otherwise
264            * @throws PortalException if any one of the roles with the names could not
265            be found in the company or if the default user for the company
266            could not be found
267            * @throws SystemException if a system exception occurred
268            */
269            public static boolean hasUserRoles(long userId, long companyId,
270                    java.lang.String[] names, boolean inherited)
271                    throws com.liferay.portal.kernel.exception.PortalException,
272                            com.liferay.portal.kernel.exception.SystemException {
273                    return getService().hasUserRoles(userId, companyId, names, inherited);
274            }
275    
276            /**
277            * Removes the matching roles associated with the user. The user is
278            * reindexed after the roles are removed.
279            *
280            * @param userId the primary key of the user
281            * @param roleIds the primary keys of the roles
282            * @throws PortalException if a user with the primary key could not be
283            found, if the user did not have permission to remove members from
284            a role, or if a role with any one of the primary keys could not
285            be found
286            * @throws SystemException if a system exception occurred
287            */
288            public static void unsetUserRoles(long userId, long[] roleIds)
289                    throws com.liferay.portal.kernel.exception.PortalException,
290                            com.liferay.portal.kernel.exception.SystemException {
291                    getService().unsetUserRoles(userId, roleIds);
292            }
293    
294            /**
295            * Updates the role with the primary key.
296            *
297            * @param roleId the primary key of the role
298            * @param name the role's new name
299            * @param titleMap the new localized titles (optionally <code>null</code>)
300            to replace those existing for the role
301            * @param descriptionMap the new localized descriptions (optionally
302            <code>null</code>) to replace those existing for the role
303            * @param subtype the role's new subtype (optionally <code>null</code>)
304            * @return the role with the primary key
305            * @throws PortalException if the user did not have permission to update the
306            role, if a role with the primary could not be found, or if the
307            role's name was invalid
308            * @throws SystemException if a system exception occurred
309            */
310            public static com.liferay.portal.model.Role updateRole(long roleId,
311                    java.lang.String name,
312                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
313                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
314                    java.lang.String subtype)
315                    throws com.liferay.portal.kernel.exception.PortalException,
316                            com.liferay.portal.kernel.exception.SystemException {
317                    return getService()
318                                       .updateRole(roleId, name, titleMap, descriptionMap, subtype);
319            }
320    
321            public static RoleService getService() {
322                    if (_service == null) {
323                            _service = (RoleService)PortalBeanLocatorUtil.locate(RoleService.class.getName());
324    
325                            ReferenceRegistry.registerReference(RoleServiceUtil.class,
326                                    "_service");
327                    }
328    
329                    return _service;
330            }
331    
332            /**
333             * @deprecated
334             */
335            public void setService(RoleService service) {
336            }
337    
338            private static RoleService _service;
339    }