001    /**
002     * Copyright (c) 2000-2011 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 com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.jsonwebservice.JSONWebService;
020    import com.liferay.portal.kernel.transaction.Isolation;
021    import com.liferay.portal.kernel.transaction.Propagation;
022    import com.liferay.portal.kernel.transaction.Transactional;
023    
024    /**
025     * The interface for the role remote service.
026     *
027     * <p>
028     * 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.
029     * </p>
030     *
031     * @author Brian Wing Shun Chan
032     * @see RoleServiceUtil
033     * @see com.liferay.portal.service.base.RoleServiceBaseImpl
034     * @see com.liferay.portal.service.impl.RoleServiceImpl
035     * @generated
036     */
037    @JSONWebService
038    @Transactional(isolation = Isolation.PORTAL, rollbackFor =  {
039            PortalException.class, SystemException.class})
040    public interface RoleService {
041            /*
042             * NOTE FOR DEVELOPERS:
043             *
044             * 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.
045             */
046    
047            /**
048            * Adds a role. The user is reindexed after role is added.
049            *
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            * @return the role
057            * @throws PortalException if a user with the primary key could not be
058            found, if the user did not have permission to add roles, if the
059            class name or the role name were invalid, or if the role is a
060            duplicate
061            * @throws SystemException if a system exception occurred
062            */
063            public com.liferay.portal.model.Role addRole(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)
067                    throws com.liferay.portal.kernel.exception.PortalException,
068                            com.liferay.portal.kernel.exception.SystemException;
069    
070            /**
071            * Adds the roles to the user. The user is reindexed after the roles are
072            * added.
073            *
074            * @param userId the primary key of the user
075            * @param roleIds the primary keys of the roles
076            * @throws PortalException if a user with the primary key could not be
077            found or if the user did not have permission to assign members
078            to one of the roles
079            * @throws SystemException if a system exception occurred
080            */
081            public void addUserRoles(long userId, long[] roleIds)
082                    throws com.liferay.portal.kernel.exception.PortalException,
083                            com.liferay.portal.kernel.exception.SystemException;
084    
085            /**
086            * Deletes the role with the primary key and its associated permissions.
087            *
088            * @param roleId the primary key of the role
089            * @throws PortalException if the user did not have permission to delete
090            the role, if a role with the primary key could not be found, if
091            the role is a default system role, or if the role's resource
092            could not be found
093            * @throws SystemException if a system exception occurred
094            */
095            public void deleteRole(long roleId)
096                    throws com.liferay.portal.kernel.exception.PortalException,
097                            com.liferay.portal.kernel.exception.SystemException;
098    
099            /**
100            * Returns all the roles associated with the group.
101            *
102            * @param groupId the primary key of the group
103            * @return the roles associated with the group
104            * @throws SystemException if a system exception occurred
105            */
106            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
107            public java.util.List<com.liferay.portal.model.Role> getGroupRoles(
108                    long groupId)
109                    throws com.liferay.portal.kernel.exception.SystemException;
110    
111            /**
112            * Returns the role with the primary key.
113            *
114            * @param roleId the primary key of the role
115            * @return the role with the primary key
116            * @throws PortalException if a role with the primary key could not be
117            found or if the user did not have permission to view the role
118            * @throws SystemException if a system exception occurred
119            */
120            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
121            public com.liferay.portal.model.Role getRole(long roleId)
122                    throws com.liferay.portal.kernel.exception.PortalException,
123                            com.liferay.portal.kernel.exception.SystemException;
124    
125            /**
126            * Returns the role with the name in the company.
127            *
128            * <p>
129            * The method searches the system roles map first for default roles. If a
130            * role with the name is not found, then the method will query the
131            * database.
132            * </p>
133            *
134            * @param companyId the primary key of the company
135            * @param name the role's name
136            * @return the role with the name
137            * @throws PortalException if a role with the name could not be found in
138            the company or if the user did not have permission to view the
139            role
140            * @throws SystemException if a system exception occurred
141            */
142            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
143            public com.liferay.portal.model.Role getRole(long companyId,
144                    java.lang.String name)
145                    throws com.liferay.portal.kernel.exception.PortalException,
146                            com.liferay.portal.kernel.exception.SystemException;
147    
148            /**
149            * Returns all the user's roles within the user group.
150            *
151            * @param userId the primary key of the user
152            * @param groupId the primary key of the group
153            * @return the user's roles within the user group
154            * @throws SystemException if a system exception occurred
155            */
156            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
157            public java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles(
158                    long userId, long groupId)
159                    throws com.liferay.portal.kernel.exception.SystemException;
160    
161            /**
162            * Returns all the user's roles within the user group.
163            *
164            * @param userId the primary key of the user
165            * @param groupId the primary key of the group
166            * @return the user's roles within the user group
167            * @throws SystemException if a system exception occurred
168            */
169            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
170            public java.util.List<com.liferay.portal.model.Role> getUserGroupRoles(
171                    long userId, long groupId)
172                    throws com.liferay.portal.kernel.exception.SystemException;
173    
174            /**
175            * Returns the union of all the user's roles within the groups.
176            *
177            * @param userId the primary key of the user
178            * @param groups the groups (optionally <code>null</code>)
179            * @return the union of all the user's roles within the groups
180            * @throws SystemException if a system exception occurred
181            */
182            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
183            public java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles(
184                    long userId, java.util.List<com.liferay.portal.model.Group> groups)
185                    throws com.liferay.portal.kernel.exception.SystemException;
186    
187            /**
188            * Returns all the roles associated with the user.
189            *
190            * @param userId the primary key of the user
191            * @return the roles associated with the user
192            * @throws SystemException if a system exception occurred
193            */
194            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
195            public java.util.List<com.liferay.portal.model.Role> getUserRoles(
196                    long userId) throws com.liferay.portal.kernel.exception.SystemException;
197    
198            /**
199            * Returns <code>true</code> if the user is associated with the named
200            * regular role.
201            *
202            * @param userId the primary key of the user
203            * @param companyId the primary key of the company
204            * @param name the name of the role
205            * @param inherited whether to include the user's inherited roles in the
206            search
207            * @return <code>true</code> if the user is associated with the regular
208            role; <code>false</code> otherwise
209            * @throws PortalException if a role with the name could not be found in
210            the company or if a default user for the company could not be
211            found
212            * @throws SystemException if a system exception occurred
213            */
214            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
215            public boolean hasUserRole(long userId, long companyId,
216                    java.lang.String name, boolean inherited)
217                    throws com.liferay.portal.kernel.exception.PortalException,
218                            com.liferay.portal.kernel.exception.SystemException;
219    
220            /**
221            * Returns <code>true</code> if the user has any one of the named regular
222            * roles.
223            *
224            * @param userId the primary key of the user
225            * @param companyId the primary key of the company
226            * @param names the names of the roles
227            * @param inherited whether to include the user's inherited roles in the
228            search
229            * @return <code>true</code> if the user has any one of the regular roles;
230            <code>false</code> otherwise
231            * @throws PortalException if any one of the roles with the names could not
232            be found in the company or if the default user for the company
233            could not be found
234            * @throws SystemException if a system exception occurred
235            */
236            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
237            public boolean hasUserRoles(long userId, long companyId,
238                    java.lang.String[] names, boolean inherited)
239                    throws com.liferay.portal.kernel.exception.PortalException,
240                            com.liferay.portal.kernel.exception.SystemException;
241    
242            /**
243            * Removes the matching roles associated with the user. The user is
244            * reindexed after the roles are removed.
245            *
246            * @param userId the primary key of the user
247            * @param roleIds the primary keys of the roles
248            * @throws PortalException if a user with the primary key could not be
249            found, if the user did not have permission to remove members
250            from a role, or if a role with any one of the primary keys could
251            not be found
252            * @throws SystemException if a system exception occurred
253            */
254            public void unsetUserRoles(long userId, long[] roleIds)
255                    throws com.liferay.portal.kernel.exception.PortalException,
256                            com.liferay.portal.kernel.exception.SystemException;
257    
258            /**
259            * Updates the role with the primary key.
260            *
261            * @param roleId the primary key of the role
262            * @param name the role's new name
263            * @param titleMap the new localized titles (optionally <code>null</code>)
264            to replace those existing for the role
265            * @param descriptionMap the new localized descriptions (optionally
266            <code>null</code>) to replace those existing for the role
267            * @param subtype the role's new subtype (optionally <code>null</code>)
268            * @return the role with the primary key
269            * @throws PortalException if the user did not have permission to update
270            the role, if a role with the primary could not be found, or if
271            the role's name was invalid
272            * @throws SystemException if a system exception occurred
273            */
274            public com.liferay.portal.model.Role updateRole(long roleId,
275                    java.lang.String name,
276                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
277                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
278                    java.lang.String subtype)
279                    throws com.liferay.portal.kernel.exception.PortalException,
280                            com.liferay.portal.kernel.exception.SystemException;
281    }