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 * Adds a role. The user is reindexed after role is added. 060 * 061 * @param className the name of the class for which the role is created 062 * @param classPK the primary key of the class for which the role is 063 created (optionally <code>0</code>) 064 * @param name the role's name 065 * @param titleMap the role's localized titles (optionally 066 <code>null</code>) 067 * @param descriptionMap the role's localized descriptions (optionally 068 <code>null</code>) 069 * @param type the role's type (optionally <code>0</code>) 070 * @param subtype the role's subtype (optionally <code>null</code>) 071 * @param serviceContext the service context to be applied (optionally 072 <code>null</code>). Can set the expando bridge attributes for the 073 role. 074 * @return the role 075 */ 076 public Role addRole(java.lang.String className, long classPK, 077 java.lang.String name, Map<Locale, java.lang.String> titleMap, 078 Map<Locale, java.lang.String> descriptionMap, int type, 079 java.lang.String subtype, 080 com.liferay.portal.kernel.service.ServiceContext serviceContext) 081 throws PortalException; 082 083 /** 084 * Adds the roles to the user. The user is reindexed after the roles are 085 * added. 086 * 087 * @param userId the primary key of the user 088 * @param roleIds the primary keys of the roles 089 */ 090 public void addUserRoles(long userId, long[] roleIds) 091 throws PortalException; 092 093 /** 094 * Deletes the role with the primary key and its associated permissions. 095 * 096 * @param roleId the primary key of the role 097 */ 098 public void deleteRole(long roleId) throws PortalException; 099 100 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 101 public Role fetchRole(long roleId) throws PortalException; 102 103 /** 104 * Returns all the roles associated with the group. 105 * 106 * @param groupId the primary key of the group 107 * @return the roles associated with the group 108 */ 109 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 110 public List<Role> getGroupRoles(long groupId) throws PortalException; 111 112 /** 113 * Returns the OSGi service identifier. 114 * 115 * @return the OSGi service identifier 116 */ 117 public java.lang.String getOSGiServiceIdentifier(); 118 119 /** 120 * Returns the role with the name in the company. 121 * 122 * <p> 123 * The method searches the system roles map first for default roles. If a 124 * role with the name is not found, then the method will query the database. 125 * </p> 126 * 127 * @param companyId the primary key of the company 128 * @param name the role's name 129 * @return the role with the name 130 */ 131 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 132 public Role getRole(long companyId, java.lang.String name) 133 throws PortalException; 134 135 /** 136 * Returns the role with the primary key. 137 * 138 * @param roleId the primary key of the role 139 * @return the role with the primary key 140 */ 141 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 142 public Role getRole(long roleId) throws PortalException; 143 144 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 145 public List<Role> getRoles(long companyId, int[] types) 146 throws PortalException; 147 148 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 149 public List<Role> getRoles(int type, java.lang.String subtype) 150 throws PortalException; 151 152 /** 153 * Returns all the user's roles within the user group. 154 * 155 * @param userId the primary key of the user 156 * @param groupId the primary key of the group 157 * @return the user's roles within the user group 158 */ 159 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 160 public List<Role> getUserGroupGroupRoles(long userId, long groupId) 161 throws PortalException; 162 163 /** 164 * Returns all the user's roles within the user group. 165 * 166 * @param userId the primary key of the user 167 * @param groupId the primary key of the group 168 * @return the user's roles within the user group 169 */ 170 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 171 public List<Role> getUserGroupRoles(long userId, long groupId) 172 throws PortalException; 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 */ 181 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 182 public List<Role> getUserRelatedRoles(long userId, List<Group> groups) 183 throws PortalException; 184 185 /** 186 * Returns all the roles associated with the user. 187 * 188 * @param userId the primary key of the user 189 * @return the roles associated with the user 190 */ 191 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 192 public List<Role> getUserRoles(long userId) throws PortalException; 193 194 /** 195 * Returns <code>true</code> if the user is associated with the named 196 * regular role. 197 * 198 * @param userId the primary key of the user 199 * @param companyId the primary key of the company 200 * @param name the name of the role 201 * @param inherited whether to include the user's inherited roles in the 202 search 203 * @return <code>true</code> if the user is associated with the regular 204 role; <code>false</code> otherwise 205 */ 206 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 207 public boolean hasUserRole(long userId, long companyId, 208 java.lang.String name, boolean inherited) throws PortalException; 209 210 /** 211 * Returns <code>true</code> if the user has any one of the named regular 212 * roles. 213 * 214 * @param userId the primary key of the user 215 * @param companyId the primary key of the company 216 * @param names the names of the roles 217 * @param inherited whether to include the user's inherited roles in the 218 search 219 * @return <code>true</code> if the user has any one of the regular roles; 220 <code>false</code> otherwise 221 */ 222 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 223 public boolean hasUserRoles(long userId, long companyId, 224 java.lang.String[] names, boolean inherited) throws PortalException; 225 226 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 227 public List<Role> search(long companyId, java.lang.String keywords, 228 java.lang.Integer[] types, 229 LinkedHashMap<java.lang.String, java.lang.Object> params, int start, 230 int end, OrderByComparator<Role> obc); 231 232 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 233 public int searchCount(long companyId, java.lang.String keywords, 234 java.lang.Integer[] types, 235 LinkedHashMap<java.lang.String, java.lang.Object> params); 236 237 /** 238 * Removes the matching roles associated with the user. The user is 239 * reindexed after the roles are removed. 240 * 241 * @param userId the primary key of the user 242 * @param roleIds the primary keys of the roles 243 */ 244 public void unsetUserRoles(long userId, long[] roleIds) 245 throws PortalException; 246 247 /** 248 * Updates the role with the primary key. 249 * 250 * @param roleId the primary key of the role 251 * @param name the role's new name 252 * @param titleMap the new localized titles (optionally <code>null</code>) 253 to replace those existing for the role 254 * @param descriptionMap the new localized descriptions (optionally 255 <code>null</code>) to replace those existing for the role 256 * @param subtype the role's new subtype (optionally <code>null</code>) 257 * @param serviceContext the service context to be applied (optionally 258 <code>null</code>). Can set the expando bridge attributes for the 259 role. 260 * @return the role with the primary key 261 */ 262 public Role updateRole(long roleId, java.lang.String name, 263 Map<Locale, java.lang.String> titleMap, 264 Map<Locale, java.lang.String> descriptionMap, java.lang.String subtype, 265 com.liferay.portal.kernel.service.ServiceContext serviceContext) 266 throws PortalException; 267 }