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.transaction.Isolation; 023 import com.liferay.portal.kernel.transaction.Propagation; 024 import com.liferay.portal.kernel.transaction.Transactional; 025 import com.liferay.portal.security.ac.AccessControlled; 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 com.liferay.portal.kernel.exception.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 com.liferay.portal.kernel.exception.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 com.liferay.portal.kernel.exception.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) 126 throws com.liferay.portal.kernel.exception.PortalException; 127 128 /** 129 * Returns the Spring bean ID for this bean. 130 * 131 * @return the Spring bean ID for this bean 132 */ 133 public java.lang.String getBeanIdentifier(); 134 135 /** 136 * Returns all the roles associated with the group. 137 * 138 * @param groupId the primary key of the group 139 * @return the roles associated with the group 140 * @throws PortalException if a portal exception occurred 141 */ 142 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 143 public java.util.List<com.liferay.portal.model.Role> getGroupRoles( 144 long groupId) 145 throws com.liferay.portal.kernel.exception.PortalException; 146 147 /** 148 * Returns the role with the name in the company. 149 * 150 * <p> 151 * The method searches the system roles map first for default roles. If a 152 * role with the name is not found, then the method will query the database. 153 * </p> 154 * 155 * @param companyId the primary key of the company 156 * @param name the role's name 157 * @return the role with the name 158 * @throws PortalException if a role with the name could not be found in the 159 company or if the user did not have permission to view the role 160 */ 161 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 162 public com.liferay.portal.model.Role getRole(long companyId, 163 java.lang.String name) 164 throws com.liferay.portal.kernel.exception.PortalException; 165 166 /** 167 * Returns the role with the primary key. 168 * 169 * @param roleId the primary key of the role 170 * @return the role with the primary key 171 * @throws PortalException if a role with the primary key could not be found 172 or if the user did not have permission to view the role 173 */ 174 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 175 public com.liferay.portal.model.Role getRole(long roleId) 176 throws com.liferay.portal.kernel.exception.PortalException; 177 178 /** 179 * Returns all the user's roles within the user group. 180 * 181 * @param userId the primary key of the user 182 * @param groupId the primary key of the group 183 * @return the user's roles within the user group 184 * @throws PortalException if a portal exception occurred 185 */ 186 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 187 public java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles( 188 long userId, long groupId) 189 throws com.liferay.portal.kernel.exception.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 * @throws PortalException if a portal exception occurred 198 */ 199 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 200 public java.util.List<com.liferay.portal.model.Role> getUserGroupRoles( 201 long userId, long groupId) 202 throws com.liferay.portal.kernel.exception.PortalException; 203 204 /** 205 * Returns the union of all the user's roles within the groups. 206 * 207 * @param userId the primary key of the user 208 * @param groups the groups (optionally <code>null</code>) 209 * @return the union of all the user's roles within the groups 210 * @throws PortalException if a portal exception occurred 211 */ 212 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 213 public java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles( 214 long userId, java.util.List<com.liferay.portal.model.Group> groups) 215 throws com.liferay.portal.kernel.exception.PortalException; 216 217 /** 218 * Returns all the roles associated with the user. 219 * 220 * @param userId the primary key of the user 221 * @return the roles associated with the user 222 * @throws PortalException if a portal exception occurred 223 */ 224 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 225 public java.util.List<com.liferay.portal.model.Role> getUserRoles( 226 long userId) throws com.liferay.portal.kernel.exception.PortalException; 227 228 /** 229 * Returns <code>true</code> if the user is associated with the named 230 * regular role. 231 * 232 * @param userId the primary key of the user 233 * @param companyId the primary key of the company 234 * @param name the name of the role 235 * @param inherited whether to include the user's inherited roles in the 236 search 237 * @return <code>true</code> if the user is associated with the regular 238 role; <code>false</code> otherwise 239 * @throws PortalException if a role with the name could not be found in the 240 company or if a default user for the company could not be found 241 */ 242 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 243 public boolean hasUserRole(long userId, long companyId, 244 java.lang.String name, boolean inherited) 245 throws com.liferay.portal.kernel.exception.PortalException; 246 247 /** 248 * Returns <code>true</code> if the user has any one of the named regular 249 * roles. 250 * 251 * @param userId the primary key of the user 252 * @param companyId the primary key of the company 253 * @param names the names of the roles 254 * @param inherited whether to include the user's inherited roles in the 255 search 256 * @return <code>true</code> if the user has any one of the regular roles; 257 <code>false</code> otherwise 258 * @throws PortalException if any one of the roles with the names could not 259 be found in the company or if the default user for the company 260 could not be found 261 */ 262 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 263 public boolean hasUserRoles(long userId, long companyId, 264 java.lang.String[] names, boolean inherited) 265 throws com.liferay.portal.kernel.exception.PortalException; 266 267 /** 268 * Sets the Spring bean ID for this bean. 269 * 270 * @param beanIdentifier the Spring bean ID for this bean 271 */ 272 public void setBeanIdentifier(java.lang.String beanIdentifier); 273 274 /** 275 * Removes the matching roles associated with the user. The user is 276 * reindexed after the roles are removed. 277 * 278 * @param userId the primary key of the user 279 * @param roleIds the primary keys of the roles 280 * @throws PortalException if a user with the primary key could not be 281 found, if the user did not have permission to remove members from 282 a role, or if a role with any one of the primary keys could not 283 be found 284 */ 285 public void unsetUserRoles(long userId, long[] roleIds) 286 throws com.liferay.portal.kernel.exception.PortalException; 287 288 /** 289 * Updates the role with the primary key. 290 * 291 * @param roleId the primary key of the role 292 * @param name the role's new name 293 * @param titleMap the new localized titles (optionally <code>null</code>) 294 to replace those existing for the role 295 * @param descriptionMap the new localized descriptions (optionally 296 <code>null</code>) to replace those existing for the role 297 * @param subtype the role's new subtype (optionally <code>null</code>) 298 * @param serviceContext the service context to be applied (optionally 299 <code>null</code>). Can set the expando bridge attributes for the 300 role. 301 * @return the role with the primary key 302 * @throws PortalException if the user did not have permission to update the 303 role, if a role with the primary could not be found, or if the 304 role's name was invalid 305 */ 306 public com.liferay.portal.model.Role updateRole(long roleId, 307 java.lang.String name, 308 java.util.Map<java.util.Locale, java.lang.String> titleMap, 309 java.util.Map<java.util.Locale, java.lang.String> descriptionMap, 310 java.lang.String subtype, 311 com.liferay.portal.service.ServiceContext serviceContext) 312 throws com.liferay.portal.kernel.exception.PortalException; 313 }