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.exception.PortalException;
020    import com.liferay.portal.kernel.exception.SystemException;
021    import com.liferay.portal.kernel.jsonwebservice.JSONWebService;
022    import com.liferay.portal.kernel.security.access.control.AccessControlled;
023    import com.liferay.portal.kernel.transaction.Isolation;
024    import com.liferay.portal.kernel.transaction.Propagation;
025    import com.liferay.portal.kernel.transaction.Transactional;
026    
027    /**
028     * Provides the remote service interface for Role. Methods of this
029     * service are expected to have security checks based on the propagated JAAS
030     * credentials because this service can be accessed remotely.
031     *
032     * @author Brian Wing Shun Chan
033     * @see RoleServiceUtil
034     * @see com.liferay.portal.service.base.RoleServiceBaseImpl
035     * @see com.liferay.portal.service.impl.RoleServiceImpl
036     * @generated
037     */
038    @AccessControlled
039    @JSONWebService
040    @ProviderType
041    @Transactional(isolation = Isolation.PORTAL, rollbackFor =  {
042            PortalException.class, SystemException.class})
043    public interface RoleService extends BaseService {
044            /*
045             * NOTE FOR DEVELOPERS:
046             *
047             * Never modify or reference this interface directly. Always use {@link RoleServiceUtil} to access the role remote service. Add custom service methods to {@link com.liferay.portal.service.impl.RoleServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
048             */
049    
050            /**
051            * Adds a role. The user is reindexed after role is added.
052            *
053            * @param className the name of the class for which the role is created
054            * @param classPK the primary key of the class for which the role is
055            created (optionally <code>0</code>)
056            * @param name the role's name
057            * @param titleMap the role's localized titles (optionally
058            <code>null</code>)
059            * @param descriptionMap the role's localized descriptions (optionally
060            <code>null</code>)
061            * @param type the role's type (optionally <code>0</code>)
062            * @param subtype the role's subtype (optionally <code>null</code>)
063            * @param serviceContext the service context to be applied (optionally
064            <code>null</code>). Can set the expando bridge attributes for the
065            role.
066            * @return the role
067            * @throws PortalException if a user with the primary key could not be
068            found, if the user did not have permission to add roles, if the
069            class name or the role name were invalid, or if the role is a
070            duplicate
071            */
072            public com.liferay.portal.model.Role addRole(java.lang.String className,
073                    long classPK, java.lang.String name,
074                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
075                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
076                    int type, java.lang.String subtype,
077                    com.liferay.portal.service.ServiceContext serviceContext)
078                    throws PortalException;
079    
080            /**
081            * Adds a role. The user is reindexed after role is added.
082            *
083            * @param name the role's name
084            * @param titleMap the role's localized titles (optionally
085            <code>null</code>)
086            * @param descriptionMap the role's localized descriptions (optionally
087            <code>null</code>)
088            * @param type the role's type (optionally <code>0</code>)
089            * @return the role
090            * @throws PortalException if a user with the primary key could not be
091            found, if the user did not have permission to add roles, if
092            the class name or the role name were invalid, or if the role
093            is a duplicate
094            * @deprecated As of 6.2.0, replaced by {@link #addRole(String, long,
095            String, Map, Map, int, String, ServiceContext)}
096            */
097            @java.lang.Deprecated
098            public com.liferay.portal.model.Role addRole(java.lang.String name,
099                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
100                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
101                    int type) throws PortalException;
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 void addUserRoles(long userId, long[] roleIds)
114                    throws PortalException;
115    
116            /**
117            * Deletes the role with the primary key and its associated permissions.
118            *
119            * @param roleId the primary key of the role
120            * @throws PortalException if the user did not have permission to delete the
121            role, if a role with the primary key could not be found, if the
122            role is a default system role, or if the role's resource could
123            not be found
124            */
125            public void deleteRole(long roleId) throws PortalException;
126    
127            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
128            public com.liferay.portal.model.Role fetchRole(long roleId)
129                    throws PortalException;
130    
131            /**
132            * Returns the Spring bean ID for this bean.
133            *
134            * @return the Spring bean ID for this bean
135            */
136            public java.lang.String getBeanIdentifier();
137    
138            /**
139            * Returns all the roles associated with the group.
140            *
141            * @param groupId the primary key of the group
142            * @return the roles associated with the group
143            * @throws PortalException if a portal exception occurred
144            */
145            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
146            public java.util.List<com.liferay.portal.model.Role> getGroupRoles(
147                    long groupId) throws PortalException;
148    
149            /**
150            * Returns the role with the name in the company.
151            *
152            * <p>
153            * The method searches the system roles map first for default roles. If a
154            * role with the name is not found, then the method will query the database.
155            * </p>
156            *
157            * @param companyId the primary key of the company
158            * @param name the role's name
159            * @return the role with the name
160            * @throws PortalException if a role with the name could not be found in the
161            company or if the user did not have permission to view the role
162            */
163            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
164            public com.liferay.portal.model.Role getRole(long companyId,
165                    java.lang.String name) throws PortalException;
166    
167            /**
168            * Returns the role with the primary key.
169            *
170            * @param roleId the primary key of the role
171            * @return the role with the primary key
172            * @throws PortalException if a role with the primary key could not be found
173            or if the user did not have permission to view the role
174            */
175            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
176            public com.liferay.portal.model.Role getRole(long roleId)
177                    throws PortalException;
178    
179            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
180            public java.util.List<com.liferay.portal.model.Role> getRoles(
181                    long companyId, int[] types) throws PortalException;
182    
183            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
184            public java.util.List<com.liferay.portal.model.Role> getRoles(int type,
185                    java.lang.String subtype) throws PortalException;
186    
187            /**
188            * Returns all the user's roles within the user group.
189            *
190            * @param userId the primary key of the user
191            * @param groupId the primary key of the group
192            * @return the user's roles within the user group
193            * @throws PortalException if a portal exception occurred
194            */
195            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
196            public java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles(
197                    long userId, long groupId) throws PortalException;
198    
199            /**
200            * Returns all the user's roles within the user group.
201            *
202            * @param userId the primary key of the user
203            * @param groupId the primary key of the group
204            * @return the user's roles within the user group
205            * @throws PortalException if a portal exception occurred
206            */
207            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
208            public java.util.List<com.liferay.portal.model.Role> getUserGroupRoles(
209                    long userId, long groupId) throws PortalException;
210    
211            /**
212            * Returns the union of all the user's roles within the groups.
213            *
214            * @param userId the primary key of the user
215            * @param groups the groups (optionally <code>null</code>)
216            * @return the union of all the user's roles within the groups
217            * @throws PortalException if a portal exception occurred
218            */
219            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
220            public java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles(
221                    long userId, java.util.List<com.liferay.portal.model.Group> groups)
222                    throws PortalException;
223    
224            /**
225            * Returns all the roles associated with the user.
226            *
227            * @param userId the primary key of the user
228            * @return the roles associated with the user
229            * @throws PortalException if a portal exception occurred
230            */
231            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
232            public java.util.List<com.liferay.portal.model.Role> getUserRoles(
233                    long userId) throws PortalException;
234    
235            /**
236            * Returns <code>true</code> if the user is associated with the named
237            * regular role.
238            *
239            * @param userId the primary key of the user
240            * @param companyId the primary key of the company
241            * @param name the name of the role
242            * @param inherited whether to include the user's inherited roles in the
243            search
244            * @return <code>true</code> if the user is associated with the regular
245            role; <code>false</code> otherwise
246            * @throws PortalException if a role with the name could not be found in the
247            company or if a default user for the company could not be found
248            */
249            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
250            public boolean hasUserRole(long userId, long companyId,
251                    java.lang.String name, boolean inherited) throws PortalException;
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            */
268            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
269            public boolean hasUserRoles(long userId, long companyId,
270                    java.lang.String[] names, boolean inherited) throws PortalException;
271    
272            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
273            public java.util.List<com.liferay.portal.model.Role> search(
274                    long companyId, java.lang.String keywords, java.lang.Integer[] types,
275                    java.util.LinkedHashMap<java.lang.String, java.lang.Object> params,
276                    int start, int end,
277                    com.liferay.portal.kernel.util.OrderByComparator<com.liferay.portal.model.Role> obc);
278    
279            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
280            public int searchCount(long companyId, java.lang.String keywords,
281                    java.lang.Integer[] types,
282                    java.util.LinkedHashMap<java.lang.String, java.lang.Object> params);
283    
284            /**
285            * Sets the Spring bean ID for this bean.
286            *
287            * @param beanIdentifier the Spring bean ID for this bean
288            */
289            public void setBeanIdentifier(java.lang.String beanIdentifier);
290    
291            /**
292            * Removes the matching roles associated with the user. The user is
293            * reindexed after the roles are removed.
294            *
295            * @param userId the primary key of the user
296            * @param roleIds the primary keys of the roles
297            * @throws PortalException if a user with the primary key could not be
298            found, if the user did not have permission to remove members from
299            a role, or if a role with any one of the primary keys could not
300            be found
301            */
302            public void unsetUserRoles(long userId, long[] roleIds)
303                    throws PortalException;
304    
305            /**
306            * Updates the role with the primary key.
307            *
308            * @param roleId the primary key of the role
309            * @param name the role's new name
310            * @param titleMap the new localized titles (optionally <code>null</code>)
311            to replace those existing for the role
312            * @param descriptionMap the new localized descriptions (optionally
313            <code>null</code>) to replace those existing for the role
314            * @param subtype the role's new subtype (optionally <code>null</code>)
315            * @param serviceContext the service context to be applied (optionally
316            <code>null</code>). Can set the expando bridge attributes for the
317            role.
318            * @return the role with the primary key
319            * @throws PortalException if the user did not have permission to update the
320            role, if a role with the primary could not be found, or if the
321            role's name was invalid
322            */
323            public com.liferay.portal.model.Role updateRole(long roleId,
324                    java.lang.String name,
325                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
326                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
327                    java.lang.String subtype,
328                    com.liferay.portal.service.ServiceContext serviceContext)
329                    throws PortalException;
330    }