001 /** 002 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.kernel.service; 016 017 import aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.portal.kernel.exception.PortalException; 020 import com.liferay.portal.kernel.exception.SystemException; 021 import com.liferay.portal.kernel.jsonwebservice.JSONWebService; 022 import com.liferay.portal.kernel.model.Group; 023 import com.liferay.portal.kernel.model.Role; 024 import com.liferay.portal.kernel.security.access.control.AccessControlled; 025 import com.liferay.portal.kernel.transaction.Isolation; 026 import com.liferay.portal.kernel.transaction.Propagation; 027 import com.liferay.portal.kernel.transaction.Transactional; 028 import com.liferay.portal.kernel.util.OrderByComparator; 029 030 import java.util.LinkedHashMap; 031 import java.util.List; 032 import java.util.Locale; 033 import java.util.Map; 034 035 /** 036 * Provides the remote service interface for Role. Methods of this 037 * service are expected to have security checks based on the propagated JAAS 038 * credentials because this service can be accessed remotely. 039 * 040 * @author Brian Wing Shun Chan 041 * @see RoleServiceUtil 042 * @see com.liferay.portal.service.base.RoleServiceBaseImpl 043 * @see com.liferay.portal.service.impl.RoleServiceImpl 044 * @generated 045 */ 046 @AccessControlled 047 @JSONWebService 048 @ProviderType 049 @Transactional(isolation = Isolation.PORTAL, rollbackFor = { 050 PortalException.class, SystemException.class}) 051 public interface RoleService extends BaseService { 052 /* 053 * NOTE FOR DEVELOPERS: 054 * 055 * 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. 056 */ 057 058 /** 059 * Returns <code>true</code> if the user is associated with the named 060 * regular role. 061 * 062 * @param userId the primary key of the user 063 * @param companyId the primary key of the company 064 * @param name the name of the role 065 * @param inherited whether to include the user's inherited roles in the 066 search 067 * @return <code>true</code> if the user is associated with the regular 068 role; <code>false</code> otherwise 069 */ 070 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 071 public boolean hasUserRole(long userId, long companyId, 072 java.lang.String name, boolean inherited) throws PortalException; 073 074 /** 075 * Returns <code>true</code> if the user has any one of the named regular 076 * roles. 077 * 078 * @param userId the primary key of the user 079 * @param companyId the primary key of the company 080 * @param names the names of the roles 081 * @param inherited whether to include the user's inherited roles in the 082 search 083 * @return <code>true</code> if the user has any one of the regular roles; 084 <code>false</code> otherwise 085 */ 086 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 087 public boolean hasUserRoles(long userId, long companyId, 088 java.lang.String[] names, boolean inherited) throws PortalException; 089 090 /** 091 * Adds a role. The user is reindexed after role is added. 092 * 093 * @param className the name of the class for which the role is created 094 * @param classPK the primary key of the class for which the role is 095 created (optionally <code>0</code>) 096 * @param name the role's name 097 * @param titleMap the role's localized titles (optionally 098 <code>null</code>) 099 * @param descriptionMap the role's localized descriptions (optionally 100 <code>null</code>) 101 * @param type the role's type (optionally <code>0</code>) 102 * @param subtype the role's subtype (optionally <code>null</code>) 103 * @param serviceContext the service context to be applied (optionally 104 <code>null</code>). Can set the expando bridge attributes for the 105 role. 106 * @return the role 107 */ 108 public Role addRole(java.lang.String className, long classPK, 109 java.lang.String name, Map<Locale, java.lang.String> titleMap, 110 Map<Locale, java.lang.String> descriptionMap, int type, 111 java.lang.String subtype, ServiceContext serviceContext) 112 throws PortalException; 113 114 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 115 public Role fetchRole(long roleId) throws PortalException; 116 117 /** 118 * Returns the role with the name in the company. 119 * 120 * <p> 121 * The method searches the system roles map first for default roles. If a 122 * role with the name is not found, then the method will query the database. 123 * </p> 124 * 125 * @param companyId the primary key of the company 126 * @param name the role's name 127 * @return the role with the name 128 */ 129 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 130 public Role getRole(long companyId, java.lang.String name) 131 throws PortalException; 132 133 /** 134 * Returns the role with the primary key. 135 * 136 * @param roleId the primary key of the role 137 * @return the role with the primary key 138 */ 139 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 140 public Role getRole(long roleId) throws PortalException; 141 142 /** 143 * Updates the role with the primary key. 144 * 145 * @param roleId the primary key of the role 146 * @param name the role's new name 147 * @param titleMap the new localized titles (optionally <code>null</code>) 148 to replace those existing for the role 149 * @param descriptionMap the new localized descriptions (optionally 150 <code>null</code>) to replace those existing for the role 151 * @param subtype the role's new subtype (optionally <code>null</code>) 152 * @param serviceContext the service context to be applied (optionally 153 <code>null</code>). Can set the expando bridge attributes for the 154 role. 155 * @return the role with the primary key 156 */ 157 public Role updateRole(long roleId, java.lang.String name, 158 Map<Locale, java.lang.String> titleMap, 159 Map<Locale, java.lang.String> descriptionMap, java.lang.String subtype, 160 ServiceContext serviceContext) throws PortalException; 161 162 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 163 public int searchCount(long companyId, java.lang.String keywords, 164 java.lang.Integer[] types, 165 LinkedHashMap<java.lang.String, java.lang.Object> params); 166 167 /** 168 * Returns the OSGi service identifier. 169 * 170 * @return the OSGi service identifier 171 */ 172 public java.lang.String getOSGiServiceIdentifier(); 173 174 /** 175 * Returns all the roles associated with the group. 176 * 177 * @param groupId the primary key of the group 178 * @return the roles associated with the group 179 */ 180 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 181 public List<Role> getGroupRoles(long groupId) throws PortalException; 182 183 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 184 public List<Role> getRoles(int type, java.lang.String subtype) 185 throws PortalException; 186 187 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 188 public List<Role> getRoles(long companyId, int[] types) 189 throws PortalException; 190 191 /** 192 * Returns all the user's roles within the user group. 193 * 194 * @param userId the primary key of the user 195 * @param groupId the primary key of the group 196 * @return the user's roles within the user group 197 */ 198 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 199 public List<Role> getUserGroupGroupRoles(long userId, long groupId) 200 throws PortalException; 201 202 /** 203 * Returns all the user's roles within the user group. 204 * 205 * @param userId the primary key of the user 206 * @param groupId the primary key of the group 207 * @return the user's roles within the user group 208 */ 209 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 210 public List<Role> getUserGroupRoles(long userId, long groupId) 211 throws PortalException; 212 213 /** 214 * Returns the union of all the user's roles within the groups. 215 * 216 * @param userId the primary key of the user 217 * @param groups the groups (optionally <code>null</code>) 218 * @return the union of all the user's roles within the groups 219 */ 220 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 221 public List<Role> getUserRelatedRoles(long userId, List<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 */ 230 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 231 public List<Role> getUserRoles(long userId) throws PortalException; 232 233 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 234 public List<Role> search(long companyId, java.lang.String keywords, 235 java.lang.Integer[] types, 236 LinkedHashMap<java.lang.String, java.lang.Object> params, int start, 237 int end, OrderByComparator<Role> obc); 238 239 /** 240 * Adds the roles to the user. The user is reindexed after the roles are 241 * added. 242 * 243 * @param userId the primary key of the user 244 * @param roleIds the primary keys of the roles 245 */ 246 public void addUserRoles(long userId, long[] roleIds) 247 throws PortalException; 248 249 /** 250 * Deletes the role with the primary key and its associated permissions. 251 * 252 * @param roleId the primary key of the role 253 */ 254 public void deleteRole(long roleId) throws PortalException; 255 256 /** 257 * Removes the matching roles associated with the user. The user is 258 * reindexed after the roles are removed. 259 * 260 * @param userId the primary key of the user 261 * @param roleIds the primary keys of the roles 262 */ 263 public void unsetUserRoles(long userId, long[] roleIds) 264 throws PortalException; 265 }