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.cache.thread.local.ThreadLocalCachable;
020    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
021    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
022    import com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery;
023    import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
024    import com.liferay.portal.kernel.dao.orm.Projection;
025    import com.liferay.portal.kernel.exception.PortalException;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.search.Indexable;
028    import com.liferay.portal.kernel.search.IndexableType;
029    import com.liferay.portal.kernel.spring.aop.Skip;
030    import com.liferay.portal.kernel.systemevent.SystemEvent;
031    import com.liferay.portal.kernel.transaction.Isolation;
032    import com.liferay.portal.kernel.transaction.Propagation;
033    import com.liferay.portal.kernel.transaction.Transactional;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.model.Group;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.model.Role;
038    import com.liferay.portal.model.SystemEventConstants;
039    import com.liferay.portal.model.Team;
040    
041    import com.liferay.portlet.exportimport.lar.PortletDataContext;
042    
043    import java.io.Serializable;
044    
045    import java.util.LinkedHashMap;
046    import java.util.List;
047    import java.util.Locale;
048    import java.util.Map;
049    
050    /**
051     * Provides the local service interface for Role. Methods of this
052     * service will not have security checks based on the propagated JAAS
053     * credentials because this service can only be accessed from within the same
054     * VM.
055     *
056     * @author Brian Wing Shun Chan
057     * @see RoleLocalServiceUtil
058     * @see com.liferay.portal.service.base.RoleLocalServiceBaseImpl
059     * @see com.liferay.portal.service.impl.RoleLocalServiceImpl
060     * @generated
061     */
062    @ProviderType
063    @Transactional(isolation = Isolation.PORTAL, rollbackFor =  {
064            PortalException.class, SystemException.class})
065    public interface RoleLocalService extends BaseLocalService,
066            PersistedModelLocalService {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this interface directly. Always use {@link RoleLocalServiceUtil} to access the role local service. Add custom service methods to {@link com.liferay.portal.service.impl.RoleLocalServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
071             */
072            public void addGroupRole(long groupId, Role role);
073    
074            public void addGroupRole(long groupId, long roleId);
075    
076            public void addGroupRoles(long groupId, List<Role> Roles);
077    
078            public void addGroupRoles(long groupId, long[] roleIds);
079    
080            /**
081            * Adds the role to the database. Also notifies the appropriate model listeners.
082            *
083            * @param role the role
084            * @return the role that was added
085            */
086            @Indexable(type = IndexableType.REINDEX)
087            public Role addRole(Role role);
088    
089            /**
090            * Adds a role with additional parameters. The user is reindexed after role
091            * is added.
092            *
093            * @param userId the primary key of the user
094            * @param className the name of the class for which the role is created
095            (optionally <code>null</code>)
096            * @param classPK the primary key of the class for which the role is
097            created (optionally <code>0</code>)
098            * @param name the role's name
099            * @param titleMap the role's localized titles (optionally
100            <code>null</code>)
101            * @param descriptionMap the role's localized descriptions (optionally
102            <code>null</code>)
103            * @param type the role's type (optionally <code>0</code>)
104            * @param subtype the role's subtype (optionally <code>null</code>)
105            * @param serviceContext the service context to be applied (optionally
106            <code>null</code>). Can set expando bridge attributes for the
107            role.
108            * @return the role
109            */
110            public Role addRole(long userId, java.lang.String className, long classPK,
111                    java.lang.String name, Map<Locale, java.lang.String> titleMap,
112                    Map<Locale, java.lang.String> descriptionMap, int type,
113                    java.lang.String subtype,
114                    com.liferay.portal.service.ServiceContext serviceContext)
115                    throws PortalException;
116    
117            public void addUserRole(long userId, Role role);
118    
119            public void addUserRole(long userId, long roleId);
120    
121            /**
122            * @throws PortalException
123            */
124            public void addUserRoles(long userId, List<Role> Roles)
125                    throws PortalException;
126    
127            /**
128            * @throws PortalException
129            */
130            public void addUserRoles(long userId, long[] roleIds)
131                    throws PortalException;
132    
133            /**
134            * Checks to ensure that the system roles map has appropriate default roles
135            * in each company.
136            */
137            public void checkSystemRoles() throws PortalException;
138    
139            /**
140            * Checks to ensure that the system roles map has appropriate default roles
141            * in the company.
142            *
143            * @param companyId the primary key of the company
144            */
145            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
146            public void checkSystemRoles(long companyId) throws PortalException;
147    
148            public void clearGroupRoles(long groupId);
149    
150            public void clearUserRoles(long userId);
151    
152            /**
153            * Creates a new role with the primary key. Does not add the role to the database.
154            *
155            * @param roleId the primary key for the new role
156            * @return the new role
157            */
158            public Role createRole(long roleId);
159    
160            public void deleteGroupRole(long groupId, Role role);
161    
162            public void deleteGroupRole(long groupId, long roleId);
163    
164            public void deleteGroupRoles(long groupId, List<Role> Roles);
165    
166            public void deleteGroupRoles(long groupId, long[] roleIds);
167    
168            /**
169            * @throws PortalException
170            */
171            @Override
172            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
173                    throws PortalException;
174    
175            /**
176            * Deletes the role from the database. Also notifies the appropriate model listeners.
177            *
178            * @param role the role
179            * @return the role that was removed
180            * @throws PortalException
181            */
182            @Indexable(type = IndexableType.DELETE)
183            @SystemEvent(action = SystemEventConstants.ACTION_SKIP, type = SystemEventConstants.TYPE_DELETE)
184            public Role deleteRole(Role role) throws PortalException;
185    
186            /**
187            * Deletes the role with the primary key from the database. Also notifies the appropriate model listeners.
188            *
189            * @param roleId the primary key of the role
190            * @return the role that was removed
191            * @throws PortalException if a role with the primary key could not be found
192            */
193            @Indexable(type = IndexableType.DELETE)
194            public Role deleteRole(long roleId) throws PortalException;
195    
196            public void deleteUserRole(long userId, Role role);
197    
198            public void deleteUserRole(long userId, long roleId);
199    
200            public void deleteUserRoles(long userId, List<Role> Roles);
201    
202            public void deleteUserRoles(long userId, long[] roleIds);
203    
204            public DynamicQuery dynamicQuery();
205    
206            /**
207            * Performs a dynamic query on the database and returns the matching rows.
208            *
209            * @param dynamicQuery the dynamic query
210            * @return the matching rows
211            */
212            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery);
213    
214            /**
215            * Performs a dynamic query on the database and returns a range of the matching rows.
216            *
217            * <p>
218            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RoleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
219            * </p>
220            *
221            * @param dynamicQuery the dynamic query
222            * @param start the lower bound of the range of model instances
223            * @param end the upper bound of the range of model instances (not inclusive)
224            * @return the range of matching rows
225            */
226            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
227                    int end);
228    
229            /**
230            * Performs a dynamic query on the database and returns an ordered range of the matching rows.
231            *
232            * <p>
233            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RoleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
234            * </p>
235            *
236            * @param dynamicQuery the dynamic query
237            * @param start the lower bound of the range of model instances
238            * @param end the upper bound of the range of model instances (not inclusive)
239            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
240            * @return the ordered range of matching rows
241            */
242            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
243                    int end, OrderByComparator<T> orderByComparator);
244    
245            /**
246            * Returns the number of rows matching the dynamic query.
247            *
248            * @param dynamicQuery the dynamic query
249            * @return the number of rows matching the dynamic query
250            */
251            public long dynamicQueryCount(DynamicQuery dynamicQuery);
252    
253            /**
254            * Returns the number of rows matching the dynamic query.
255            *
256            * @param dynamicQuery the dynamic query
257            * @param projection the projection to apply to the query
258            * @return the number of rows matching the dynamic query
259            */
260            public long dynamicQueryCount(DynamicQuery dynamicQuery,
261                    Projection projection);
262    
263            /**
264            * Returns the role with the name in the company.
265            *
266            * <p>
267            * The method searches the system roles map first for default roles. If a
268            * role with the name is not found, then the method will query the database.
269            * </p>
270            *
271            * @param companyId the primary key of the company
272            * @param name the role's name
273            * @return Returns the role with the name or <code>null</code> if a role
274            with the name could not be found in the company
275            */
276            @Skip
277            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
278            public Role fetchRole(long companyId, java.lang.String name);
279    
280            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
281            public Role fetchRole(long roleId);
282    
283            /**
284            * Returns the role with the matching UUID and company.
285            *
286            * @param uuid the role's UUID
287            * @param companyId the primary key of the company
288            * @return the matching role, or <code>null</code> if a matching role could not be found
289            */
290            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
291            public Role fetchRoleByUuidAndCompanyId(java.lang.String uuid,
292                    long companyId);
293    
294            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
295            public ActionableDynamicQuery getActionableDynamicQuery();
296    
297            /**
298            * Returns the default role for the group with the primary key.
299            *
300            * <p>
301            * If the group is a site, then the default role is {@link
302            * RoleConstants#SITE_MEMBER}. If the group is an organization, then the
303            * default role is {@link RoleConstants#ORGANIZATION_USER}. If the group is
304            * a user or user group, then the default role is {@link
305            * RoleConstants#POWER_USER}. For all other group types, the default role is
306            * {@link RoleConstants#USER}.
307            * </p>
308            *
309            * @param groupId the primary key of the group
310            * @return the default role for the group with the primary key
311            */
312            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
313            public Role getDefaultGroupRole(long groupId) throws PortalException;
314    
315            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
316            public ExportActionableDynamicQuery getExportActionableDynamicQuery(
317                    PortletDataContext portletDataContext);
318    
319            /**
320            * Returns the groupIds of the groups associated with the role.
321            *
322            * @param roleId the roleId of the role
323            * @return long[] the groupIds of groups associated with the role
324            */
325            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
326            public long[] getGroupPrimaryKeys(long roleId);
327    
328            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
329            public List<Role> getGroupRelatedRoles(long groupId)
330                    throws PortalException;
331    
332            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
333            public List<Role> getGroupRoles(long groupId);
334    
335            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
336            public List<Role> getGroupRoles(long groupId, int start, int end);
337    
338            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
339            public List<Role> getGroupRoles(long groupId, int start, int end,
340                    OrderByComparator<Role> orderByComparator);
341    
342            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
343            public int getGroupRolesCount(long groupId);
344    
345            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
346            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery();
347    
348            /**
349            * Returns the OSGi service identifier.
350            *
351            * @return the OSGi service identifier
352            */
353            public java.lang.String getOSGiServiceIdentifier();
354    
355            @Override
356            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
357            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
358                    throws PortalException;
359    
360            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
361            public List<Role> getResourceBlockRoles(long resourceBlockId,
362                    java.lang.String className, java.lang.String actionId);
363    
364            /**
365            * Returns a map of role names to associated action IDs for the named
366            * resource in the company within the permission scope.
367            *
368            * @param companyId the primary key of the company
369            * @param name the resource name
370            * @param scope the permission scope
371            * @param primKey the primary key of the resource's class
372            * @return the role names and action IDs
373            * @see com.liferay.portal.service.persistence.RoleFinder#findByC_N_S_P(
374            long, String, int, String)
375            */
376            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
377            public Map<java.lang.String, List<java.lang.String>> getResourceRoles(
378                    long companyId, java.lang.String name, int scope,
379                    java.lang.String primKey);
380    
381            /**
382            * Returns all the roles associated with the action ID in the company within
383            * the permission scope.
384            *
385            * @param companyId the primary key of the company
386            * @param name the resource name
387            * @param scope the permission scope
388            * @param primKey the primary key of the resource's class
389            * @param actionId the name of the resource action
390            * @return the roles
391            * @see com.liferay.portal.service.persistence.RoleFinder#findByC_N_S_P_A(
392            long, String, int, String, String)
393            */
394            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
395            public List<Role> getResourceRoles(long companyId, java.lang.String name,
396                    int scope, java.lang.String primKey, java.lang.String actionId);
397    
398            /**
399            * Returns the role with the name in the company.
400            *
401            * <p>
402            * The method searches the system roles map first for default roles. If a
403            * role with the name is not found, then the method will query the database.
404            * </p>
405            *
406            * @param companyId the primary key of the company
407            * @param name the role's name
408            * @return the role with the name
409            */
410            @Skip
411            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
412            public Role getRole(long companyId, java.lang.String name)
413                    throws PortalException;
414    
415            /**
416            * Returns the role with the primary key.
417            *
418            * @param roleId the primary key of the role
419            * @return the role
420            * @throws PortalException if a role with the primary key could not be found
421            */
422            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
423            public Role getRole(long roleId) throws PortalException;
424    
425            /**
426            * Returns the role with the matching UUID and company.
427            *
428            * @param uuid the role's UUID
429            * @param companyId the primary key of the company
430            * @return the matching role
431            * @throws PortalException if a matching role could not be found
432            */
433            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
434            public Role getRoleByUuidAndCompanyId(java.lang.String uuid, long companyId)
435                    throws PortalException;
436    
437            /**
438            * Returns all the roles in the company.
439            *
440            * @param companyId the primary key of the company
441            * @return the roles in the company
442            */
443            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
444            public List<Role> getRoles(long companyId);
445    
446            /**
447            * Returns all the roles with the types.
448            *
449            * @param companyId the primary key of the company
450            * @param types the role types (optionally <code>null</code>)
451            * @return the roles with the types
452            */
453            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
454            public List<Role> getRoles(long companyId, int[] types);
455    
456            /**
457            * Returns all the roles with the primary keys.
458            *
459            * @param roleIds the primary keys of the roles
460            * @return the roles with the primary keys
461            */
462            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
463            public List<Role> getRoles(long[] roleIds) throws PortalException;
464    
465            /**
466            * Returns a range of all the roles.
467            *
468            * <p>
469            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RoleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
470            * </p>
471            *
472            * @param start the lower bound of the range of roles
473            * @param end the upper bound of the range of roles (not inclusive)
474            * @return the range of roles
475            */
476            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
477            public List<Role> getRoles(int start, int end);
478    
479            /**
480            * Returns all the roles of the type and subtype.
481            *
482            * @param type the role's type (optionally <code>0</code>)
483            * @param subtype the role's subtype (optionally <code>null</code>)
484            * @return the roles of the type and subtype
485            */
486            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
487            public List<Role> getRoles(int type, java.lang.String subtype);
488    
489            /**
490            * Returns the number of roles.
491            *
492            * @return the number of roles
493            */
494            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
495            public int getRolesCount();
496    
497            /**
498            * Returns all the roles of the subtype.
499            *
500            * @param subtype the role's subtype (optionally <code>null</code>)
501            * @return the roles of the subtype
502            */
503            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
504            public List<Role> getSubtypeRoles(java.lang.String subtype);
505    
506            /**
507            * Returns the number of roles of the subtype.
508            *
509            * @param subtype the role's subtype (optionally <code>null</code>)
510            * @return the number of roles of the subtype
511            */
512            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
513            public int getSubtypeRolesCount(java.lang.String subtype);
514    
515            /**
516            * Returns the team role in the company.
517            *
518            * @param companyId the primary key of the company
519            * @param teamId the primary key of the team
520            * @return the team role in the company
521            */
522            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
523            public Role getTeamRole(long companyId, long teamId)
524                    throws PortalException;
525    
526            /**
527            * Returns the team role map for the group.
528            *
529            * @param groupId the primary key of the group
530            * @return the team role map for the group
531            */
532            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
533            public Map<Team, Role> getTeamRoleMap(long groupId)
534                    throws PortalException;
535    
536            /**
537            * Returns the team roles in the group.
538            *
539            * @param groupId the primary key of the group
540            * @return the team roles in the group
541            */
542            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
543            public List<Role> getTeamRoles(long groupId) throws PortalException;
544    
545            /**
546            * Returns the team roles in the group, excluding the specified role IDs.
547            *
548            * @param groupId the primary key of the group
549            * @param excludedRoleIds the primary keys of the roles to exclude
550            (optionally <code>null</code>)
551            * @return the team roles in the group, excluding the specified role IDs
552            */
553            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
554            public List<Role> getTeamRoles(long groupId, long[] excludedRoleIds)
555                    throws PortalException;
556    
557            /**
558            * Returns all the roles of the type.
559            *
560            * @param type the role's type (optionally <code>0</code>)
561            * @return the range of the roles of the type
562            */
563            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
564            public List<Role> getTypeRoles(int type);
565    
566            /**
567            * Returns a range of all the roles of the type.
568            *
569            * @param type the role's type (optionally <code>0</code>)
570            * @param start the lower bound of the range of roles to return
571            * @param end the upper bound of the range of roles to return (not
572            inclusive)
573            * @return the range of the roles of the type
574            */
575            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
576            public List<Role> getTypeRoles(int type, int start, int end);
577    
578            /**
579            * Returns the number of roles of the type.
580            *
581            * @param type the role's type (optionally <code>0</code>)
582            * @return the number of roles of the type
583            */
584            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
585            public int getTypeRolesCount(int type);
586    
587            /**
588            * Returns all the user's roles within the user group.
589            *
590            * @param userId the primary key of the user
591            * @param groupId the primary key of the group
592            * @return the user's roles within the user group
593            * @see com.liferay.portal.service.persistence.RoleFinder#findByUserGroupGroupRole(
594            long, long)
595            */
596            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
597            public List<Role> getUserGroupGroupRoles(long userId, long groupId);
598    
599            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
600            public List<Role> getUserGroupGroupRoles(long userId, long groupId,
601                    int start, int end);
602    
603            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
604            public int getUserGroupGroupRolesCount(long userId, long groupId);
605    
606            /**
607            * Returns all the user's roles within the user group.
608            *
609            * @param userId the primary key of the user
610            * @param groupId the primary key of the group
611            * @return the user's roles within the user group
612            * @see com.liferay.portal.service.persistence.RoleFinder#findByUserGroupRole(
613            long, long)
614            */
615            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
616            public List<Role> getUserGroupRoles(long userId, long groupId);
617    
618            /**
619            * Returns the userIds of the users associated with the role.
620            *
621            * @param roleId the roleId of the role
622            * @return long[] the userIds of users associated with the role
623            */
624            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
625            public long[] getUserPrimaryKeys(long roleId);
626    
627            /**
628            * Returns all the user's roles within the group.
629            *
630            * @param userId the primary key of the user
631            * @param groupId the primary key of the group
632            * @return the user's roles within the group
633            * @see com.liferay.portal.service.persistence.RoleFinder#findByU_G(long,
634            long)
635            */
636            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
637            public List<Role> getUserRelatedRoles(long userId, long groupId);
638    
639            /**
640            * Returns the union of all the user's roles within the groups.
641            *
642            * @param userId the primary key of the user
643            * @param groupIds the primary keys of the groups
644            * @return the union of all the user's roles within the groups
645            * @see com.liferay.portal.service.persistence.RoleFinder#findByU_G(long,
646            long[])
647            */
648            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
649            public List<Role> getUserRelatedRoles(long userId, long[] groupIds);
650    
651            /**
652            * Returns the union of all the user's roles within the groups.
653            *
654            * @param userId the primary key of the user
655            * @param groups the groups (optionally <code>null</code>)
656            * @return the union of all the user's roles within the groups
657            * @see com.liferay.portal.service.persistence.RoleFinder#findByU_G(long,
658            List)
659            */
660            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
661            public List<Role> getUserRelatedRoles(long userId, List<Group> groups);
662    
663            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
664            public List<Role> getUserRoles(long userId);
665    
666            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
667            public List<Role> getUserRoles(long userId, int start, int end);
668    
669            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
670            public List<Role> getUserRoles(long userId, int start, int end,
671                    OrderByComparator<Role> orderByComparator);
672    
673            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
674            public int getUserRolesCount(long userId);
675    
676            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
677            public boolean hasGroupRole(long groupId, long roleId);
678    
679            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
680            public boolean hasGroupRoles(long groupId);
681    
682            /**
683            * Returns <code>true</code> if the user is associated with the named
684            * regular role.
685            *
686            * @param userId the primary key of the user
687            * @param companyId the primary key of the company
688            * @param name the name of the role
689            * @param inherited whether to include the user's inherited roles in the
690            search
691            * @return <code>true</code> if the user is associated with the regular
692            role; <code>false</code> otherwise
693            */
694            @ThreadLocalCachable
695            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
696            public boolean hasUserRole(long userId, long companyId,
697                    java.lang.String name, boolean inherited) throws PortalException;
698    
699            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
700            public boolean hasUserRole(long userId, long roleId);
701    
702            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
703            public boolean hasUserRoles(long userId);
704    
705            /**
706            * Returns <code>true</code> if the user has any one of the named regular
707            * roles.
708            *
709            * @param userId the primary key of the user
710            * @param companyId the primary key of the company
711            * @param names the names of the roles
712            * @param inherited whether to include the user's inherited roles in the
713            search
714            * @return <code>true</code> if the user has any one of the regular roles;
715            <code>false</code> otherwise
716            */
717            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
718            public boolean hasUserRoles(long userId, long companyId,
719                    java.lang.String[] names, boolean inherited) throws PortalException;
720    
721            /**
722            * Returns a role with the name in the company.
723            *
724            * @param companyId the primary key of the company
725            * @param name the role's name (optionally <code>null</code>)
726            * @return the role with the name, or <code>null</code> if a role with the
727            name could not be found in the company
728            */
729            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
730            public Role loadFetchRole(long companyId, java.lang.String name);
731    
732            /**
733            * Returns a role with the name in the company.
734            *
735            * @param companyId the primary key of the company
736            * @param name the role's name
737            * @return the role with the name in the company
738            */
739            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
740            public Role loadGetRole(long companyId, java.lang.String name)
741                    throws PortalException;
742    
743            /**
744            * Returns an ordered range of all the roles that match the keywords, types,
745            * and params.
746            *
747            * <p>
748            * Useful when paginating results. Returns a maximum of <code>end -
749            * start</code> instances. <code>start</code> and <code>end</code> are not
750            * primary keys, they are indexes in the result set. Thus, <code>0</code>
751            * refers to the first result in the set. Setting both <code>start</code>
752            * and <code>end</code> to {@link
753            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
754            * result set.
755            * </p>
756            *
757            * @param companyId the primary key of the company
758            * @param keywords the keywords (space separated), which may occur in the
759            role's name or description (optionally <code>null</code>)
760            * @param types the role types (optionally <code>null</code>)
761            * @param params the finder parameters. Can specify values for the
762            "usersRoles" key. For more information, see {@link
763            com.liferay.portal.service.persistence.RoleFinder}
764            * @param start the lower bound of the range of roles to return
765            * @param end the upper bound of the range of roles to return (not
766            inclusive)
767            * @param obc the comparator to order the roles (optionally
768            <code>null</code>)
769            * @return the ordered range of the matching roles, ordered by
770            <code>obc</code>
771            * @see com.liferay.portal.service.persistence.RoleFinder
772            */
773            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
774            public List<Role> search(long companyId, java.lang.String keywords,
775                    java.lang.Integer[] types,
776                    LinkedHashMap<java.lang.String, java.lang.Object> params, int start,
777                    int end, OrderByComparator<Role> obc);
778    
779            /**
780            * Returns an ordered range of all the roles that match the keywords and
781            * types.
782            *
783            * <p>
784            * Useful when paginating results. Returns a maximum of <code>end -
785            * start</code> instances. <code>start</code> and <code>end</code> are not
786            * primary keys, they are indexes in the result set. Thus, <code>0</code>
787            * refers to the first result in the set. Setting both <code>start</code>
788            * and <code>end</code> to {@link
789            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
790            * result set.
791            * </p>
792            *
793            * @param companyId the primary key of the company
794            * @param keywords the keywords (space separated), which may occur in the
795            role's name or description (optionally <code>null</code>)
796            * @param types the role types (optionally <code>null</code>)
797            * @param start the lower bound of the range of roles to return
798            * @param end the upper bound of the range of roles to return (not
799            inclusive)
800            * @param obc the comparator to order the roles (optionally
801            <code>null</code>)
802            * @return the ordered range of the matching roles, ordered by
803            <code>obc</code>
804            * @see com.liferay.portal.service.persistence.RoleFinder
805            */
806            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
807            public List<Role> search(long companyId, java.lang.String keywords,
808                    java.lang.Integer[] types, int start, int end,
809                    OrderByComparator<Role> obc);
810    
811            /**
812            * Returns an ordered range of all the roles that match the name,
813            * description, types, and params.
814            *
815            * <p>
816            * Useful when paginating results. Returns a maximum of <code>end -
817            * start</code> instances. <code>start</code> and <code>end</code> are not
818            * primary keys, they are indexes in the result set. Thus, <code>0</code>
819            * refers to the first result in the set. Setting both <code>start</code>
820            * and <code>end</code> to {@link
821            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
822            * result set.
823            * </p>
824            *
825            * @param companyId the primary key of the company
826            * @param name the role's name (optionally <code>null</code>)
827            * @param description the role's description (optionally <code>null</code>)
828            * @param types the role types (optionally <code>null</code>)
829            * @param params the finder's parameters. Can specify values for the
830            "usersRoles" key. For more information, see {@link
831            com.liferay.portal.service.persistence.RoleFinder}
832            * @param start the lower bound of the range of the roles to return
833            * @param end the upper bound of the range of the roles to return (not
834            inclusive)
835            * @param obc the comparator to order the roles (optionally
836            <code>null</code>)
837            * @return the ordered range of the matching roles, ordered by
838            <code>obc</code>
839            * @see com.liferay.portal.service.persistence.RoleFinder
840            */
841            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
842            public List<Role> search(long companyId, java.lang.String name,
843                    java.lang.String description, java.lang.Integer[] types,
844                    LinkedHashMap<java.lang.String, java.lang.Object> params, int start,
845                    int end, OrderByComparator<Role> obc);
846    
847            /**
848            * Returns an ordered range of all the roles that match the name,
849            * description, and types.
850            *
851            * <p>
852            * Useful when paginating results. Returns a maximum of <code>end -
853            * start</code> instances. <code>start</code> and <code>end</code> are not
854            * primary keys, they are indexes in the result set. Thus, <code>0</code>
855            * refers to the first result in the set. Setting both <code>start</code>
856            * and <code>end</code> to {@link
857            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
858            * result set.
859            * </p>
860            *
861            * @param companyId the primary key of the company
862            * @param name the role's name (optionally <code>null</code>)
863            * @param description the role's description (optionally <code>null</code>)
864            * @param types the role types (optionally <code>null</code>)
865            * @param start the lower bound of the range of the roles to return
866            * @param end the upper bound of the range of the roles to return (not
867            inclusive)
868            * @param obc the comparator to order the roles (optionally
869            <code>null</code>)
870            * @return the ordered range of the matching roles, ordered by
871            <code>obc</code>
872            * @see com.liferay.portal.service.persistence.RoleFinder
873            */
874            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
875            public List<Role> search(long companyId, java.lang.String name,
876                    java.lang.String description, java.lang.Integer[] types, int start,
877                    int end, OrderByComparator<Role> obc);
878    
879            /**
880            * Returns the number of roles that match the keywords and types.
881            *
882            * @param companyId the primary key of the company
883            * @param keywords the keywords (space separated), which may occur in the
884            role's name or description (optionally <code>null</code>)
885            * @param types the role types (optionally <code>null</code>)
886            * @return the number of matching roles
887            */
888            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
889            public int searchCount(long companyId, java.lang.String keywords,
890                    java.lang.Integer[] types);
891    
892            /**
893            * Returns the number of roles that match the keywords, types and params.
894            *
895            * @param companyId the primary key of the company
896            * @param keywords the keywords (space separated), which may occur in the
897            role's name or description (optionally <code>null</code>)
898            * @param types the role types (optionally <code>null</code>)
899            * @param params the finder parameters. For more information, see {@link
900            com.liferay.portal.service.persistence.RoleFinder}
901            * @return the number of matching roles
902            */
903            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
904            public int searchCount(long companyId, java.lang.String keywords,
905                    java.lang.Integer[] types,
906                    LinkedHashMap<java.lang.String, java.lang.Object> params);
907    
908            /**
909            * Returns the number of roles that match the name, description, and types.
910            *
911            * @param companyId the primary key of the company
912            * @param name the role's name (optionally <code>null</code>)
913            * @param description the role's description (optionally <code>null</code>)
914            * @param types the role types (optionally <code>null</code>)
915            * @return the number of matching roles
916            */
917            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
918            public int searchCount(long companyId, java.lang.String name,
919                    java.lang.String description, java.lang.Integer[] types);
920    
921            /**
922            * Returns the number of roles that match the name, description, types, and
923            * params.
924            *
925            * @param companyId the primary key of the company
926            * @param name the role's name (optionally <code>null</code>)
927            * @param description the role's description (optionally <code>null</code>)
928            * @param types the role types (optionally <code>null</code>)
929            * @param params the finder parameters. Can specify values for the
930            "usersRoles" key. For more information, see {@link
931            com.liferay.portal.service.persistence.RoleFinder}
932            * @return the number of matching roles
933            */
934            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
935            public int searchCount(long companyId, java.lang.String name,
936                    java.lang.String description, java.lang.Integer[] types,
937                    LinkedHashMap<java.lang.String, java.lang.Object> params);
938    
939            public void setGroupRoles(long groupId, long[] roleIds);
940    
941            /**
942            * @throws PortalException
943            */
944            public void setUserRoles(long userId, long[] roleIds)
945                    throws PortalException;
946    
947            /**
948            * Removes the matching roles associated with the user. The user is
949            * reindexed after the roles are removed.
950            *
951            * @param userId the primary key of the user
952            * @param roleIds the primary keys of the roles
953            */
954            public void unsetUserRoles(long userId, long[] roleIds)
955                    throws PortalException;
956    
957            /**
958            * Updates the role in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
959            *
960            * @param role the role
961            * @return the role that was updated
962            */
963            @Indexable(type = IndexableType.REINDEX)
964            public Role updateRole(Role role);
965    
966            /**
967            * Updates the role with the primary key.
968            *
969            * @param roleId the primary key of the role
970            * @param name the role's new name
971            * @param titleMap the new localized titles (optionally <code>null</code>)
972            to replace those existing for the role
973            * @param descriptionMap the new localized descriptions (optionally
974            <code>null</code>) to replace those existing for the role
975            * @param subtype the role's new subtype (optionally <code>null</code>)
976            * @param serviceContext the service context to be applied (optionally
977            <code>null</code>). Can set expando bridge attributes for the
978            role.
979            * @return the role with the primary key
980            */
981            public Role updateRole(long roleId, java.lang.String name,
982                    Map<Locale, java.lang.String> titleMap,
983                    Map<Locale, java.lang.String> descriptionMap, java.lang.String subtype,
984                    com.liferay.portal.service.ServiceContext serviceContext)
985                    throws PortalException;
986    }