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.model.AuditedModel; 022 import com.liferay.portal.kernel.model.Resource; 023 import com.liferay.portal.kernel.service.permission.ModelPermissions; 024 import com.liferay.portal.kernel.transaction.Isolation; 025 import com.liferay.portal.kernel.transaction.Propagation; 026 import com.liferay.portal.kernel.transaction.Transactional; 027 028 import java.util.List; 029 030 /** 031 * Provides the local service interface for Resource. Methods of this 032 * service will not have security checks based on the propagated JAAS 033 * credentials because this service can only be accessed from within the same 034 * VM. 035 * 036 * @author Brian Wing Shun Chan 037 * @see ResourceLocalServiceUtil 038 * @see com.liferay.portal.service.base.ResourceLocalServiceBaseImpl 039 * @see com.liferay.portal.service.impl.ResourceLocalServiceImpl 040 * @generated 041 */ 042 @ProviderType 043 @Transactional(isolation = Isolation.PORTAL, rollbackFor = { 044 PortalException.class, SystemException.class}) 045 public interface ResourceLocalService extends BaseLocalService { 046 /* 047 * NOTE FOR DEVELOPERS: 048 * 049 * Never modify or reference this interface directly. Always use {@link ResourceLocalServiceUtil} to access the resource local service. Add custom service methods to {@link com.liferay.portal.service.impl.ResourceLocalServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface. 050 */ 051 052 /** 053 * Adds resources for the model, always creating a resource at the 054 * individual scope and only creating resources at the group, group 055 * template, and company scope if such resources don't already exist. 056 * 057 * <ol> 058 * <li> 059 * If the service context specifies that default group or default guest 060 * permissions are to be added, then only default permissions are added. See 061 * {@link ServiceContext#setAddGroupPermissions( 062 * boolean)} and {@link 063 * ServiceContext#setAddGuestPermissions( 064 * boolean)}. 065 * </li> 066 * <li> 067 * Else ... 068 * <ol> 069 * <li> 070 * If the service context specifies to derive default permissions, then 071 * default group and guest permissions are derived from the model and 072 * added. See {@link 073 * ServiceContext#setDeriveDefaultPermissions( 074 * boolean)}. 075 * </li> 076 * <li> 077 * Lastly group and guest permissions from the service 078 * context are applied. See {@link 079 * ServiceContext#setGroupPermissions(String[])} 080 * and {@link 081 * ServiceContext#setGuestPermissions(String[])}. 082 * </li> 083 * </ol> 084 * 085 * </li> 086 * </ol> 087 * 088 * @param auditedModel the model to associate with the resources 089 * @param serviceContext the service context to apply. Can set whether to 090 add the model's default group and guest permissions, set whether 091 to derive default group and guest permissions from the model, set 092 group permissions to apply, and set guest permissions to apply. 093 */ 094 public void addModelResources(AuditedModel auditedModel, 095 com.liferay.portal.kernel.service.ServiceContext serviceContext) 096 throws PortalException; 097 098 /** 099 * Adds resources for the model with the name and primary key, always 100 * creating a resource at the individual scope and only creating resources 101 * at the group, group template, and company scope if such resources don't 102 * already exist. 103 * 104 * @param companyId the primary key of the portal instance 105 * @param groupId the primary key of the group 106 * @param userId the primary key of the user adding the resources 107 * @param name a name for the resource, typically the model's class name 108 * @param primKey the primary key of the model instance, optionally 109 <code>0</code> if no instance exists 110 * @param groupPermissions the group permissions to be applied 111 * @param guestPermissions the guest permissions to be applied 112 */ 113 public void addModelResources(long companyId, long groupId, long userId, 114 java.lang.String name, long primKey, 115 java.lang.String[] groupPermissions, java.lang.String[] guestPermissions) 116 throws PortalException; 117 118 /** 119 * Adds resources for the model with the name and primary key string, always 120 * creating a resource at the individual scope and only creating resources 121 * at the group, group template, and company scope if such resources don't 122 * already exist. 123 * 124 * @param companyId the primary key of the portal instance 125 * @param groupId the primary key of the group 126 * @param userId the primary key of the user adding the resources 127 * @param name a name for the resource, typically the model's class name 128 * @param primKey the primary key string of the model instance, optionally 129 an empty string if no instance exists 130 * @param groupPermissions the group permissions to be applied 131 * @param guestPermissions the guest permissions to be applied 132 */ 133 public void addModelResources(long companyId, long groupId, long userId, 134 java.lang.String name, java.lang.String primKey, 135 java.lang.String[] groupPermissions, java.lang.String[] guestPermissions) 136 throws PortalException; 137 138 public void addModelResources(long companyId, long groupId, long userId, 139 java.lang.String name, long primKey, ModelPermissions modelPermissions) 140 throws PortalException; 141 142 public void addModelResources(long companyId, long groupId, long userId, 143 java.lang.String name, java.lang.String primKey, 144 ModelPermissions modelPermissions) throws PortalException; 145 146 /** 147 * Adds resources for the entity with the name. Use this method if the user 148 * is unknown or irrelevant and there is no current entity instance. 149 * 150 * @param companyId the primary key of the portal instance 151 * @param groupId the primary key of the group 152 * @param name a name for the resource, which should be a portlet ID if the 153 resource is a portlet or the resource's class name otherwise 154 * @param portletActions whether to associate portlet actions with the 155 resource 156 */ 157 public void addResources(long companyId, long groupId, 158 java.lang.String name, boolean portletActions) 159 throws PortalException; 160 161 /** 162 * Adds resources for the entity with the name and primary key string, 163 * always creating a resource at the individual scope and only creating 164 * resources at the group, group template, and company scope if such 165 * resources don't already exist. 166 * 167 * @param companyId the primary key of the portal instance 168 * @param groupId the primary key of the group 169 * @param userId the primary key of the user adding the resources 170 * @param name a name for the resource, which should be a portlet ID if the 171 resource is a portlet or the resource's class name otherwise 172 * @param primKey the primary key string of the resource instance, 173 optionally an empty string if no instance exists 174 * @param portletActions whether to associate portlet actions with the 175 resource 176 * @param addGroupPermissions whether to add group permissions 177 * @param addGuestPermissions whether to add guest permissions 178 */ 179 public void addResources(long companyId, long groupId, long userId, 180 java.lang.String name, java.lang.String primKey, 181 boolean portletActions, boolean addGroupPermissions, 182 boolean addGuestPermissions) throws PortalException; 183 184 /** 185 * Adds resources for the entity with the name and primary key, always 186 * creating a resource at the individual scope and only creating resources 187 * at the group, group template, and company scope if such resources don't 188 * already exist. 189 * 190 * @param companyId the primary key of the portal instance 191 * @param groupId the primary key of the group 192 * @param userId the primary key of the user adding the resources 193 * @param name a name for the resource, which should be a portlet ID if the 194 resource is a portlet or the resource's class name otherwise 195 * @param primKey the primary key of the resource instance, optionally 196 <code>0</code> if no instance exists 197 * @param portletActions whether to associate portlet actions with the 198 resource 199 * @param addGroupPermissions whether to add group permissions 200 * @param addGuestPermissions whether to add guest permissions 201 */ 202 public void addResources(long companyId, long groupId, long userId, 203 java.lang.String name, long primKey, boolean portletActions, 204 boolean addGroupPermissions, boolean addGuestPermissions) 205 throws PortalException; 206 207 /** 208 * Deletes the resource associated with the model at the scope. 209 * 210 * @param auditedModel the model associated with the resource 211 * @param scope the scope of the resource. For more information see {@link 212 ResourceConstants}. 213 */ 214 public void deleteResource(AuditedModel auditedModel, int scope) 215 throws PortalException; 216 217 /** 218 * Deletes the resource matching the primary key at the scope. 219 * 220 * @param companyId the primary key of the portal instance 221 * @param name the resource's name, which should be a portlet ID if the 222 resource is a portlet or the resource's class name otherwise 223 * @param scope the scope of the resource. For more information see {@link 224 ResourceConstants}. 225 * @param primKey the primary key of the resource instance 226 */ 227 public void deleteResource(long companyId, java.lang.String name, 228 int scope, long primKey) throws PortalException; 229 230 /** 231 * Deletes the resource matching the primary key at the scope. 232 * 233 * @param companyId the primary key of the portal instance 234 * @param name the resource's name, which should be a portlet ID if the 235 resource is a portlet or the resource's class name otherwise 236 * @param scope the scope of the resource. For more information see {@link 237 ResourceConstants}. 238 * @param primKey the primary key string of the resource instance 239 */ 240 public void deleteResource(long companyId, java.lang.String name, 241 int scope, java.lang.String primKey) throws PortalException; 242 243 /** 244 * Returns the OSGi service identifier. 245 * 246 * @return the OSGi service identifier 247 */ 248 public java.lang.String getOSGiServiceIdentifier(); 249 250 /** 251 * Returns a new resource with the name and primary key at the scope. 252 * 253 * @param companyId the primary key of the portal instance 254 * @param name a name for the resource, which should be a portlet ID if the 255 resource is a portlet or the resource's class name otherwise 256 * @param scope the scope of the resource. For more information see {@link 257 ResourceConstants}. 258 * @param primKey the primary key string of the resource 259 * @return the new resource 260 */ 261 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 262 public Resource getResource(long companyId, java.lang.String name, 263 int scope, java.lang.String primKey); 264 265 /** 266 * Returns <code>true</code> if the roles have permission to perform the 267 * action on the resources. 268 * 269 * @param userId the primary key of the user performing the permission 270 check 271 * @param resourceId the primary key of the resource, typically the scope 272 group ID representing the scope in which the permission check is 273 being performed 274 * @param resources the resources for which permissions are to be checked 275 * @param actionId the primary key of the action to be performed on the 276 resources 277 * @param roleIds the primary keys of the roles 278 * @return <code>true</code> if the roles have permission to perform the 279 action on the resources;<code>false</code> otherwise 280 */ 281 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) 282 public boolean hasUserPermissions(long userId, long resourceId, 283 List<Resource> resources, java.lang.String actionId, long[] roleIds) 284 throws PortalException; 285 286 /** 287 * Updates the resources for the model, replacing their group and guest 288 * permissions with new ones from the service context. 289 * 290 * @param auditedModel the model associated with the resources 291 * @param serviceContext the service context to be applied. Can set group 292 and guest permissions. 293 */ 294 public void updateModelResources(AuditedModel auditedModel, 295 com.liferay.portal.kernel.service.ServiceContext serviceContext) 296 throws PortalException; 297 298 /** 299 * Updates resources matching the group, name, and primary key string at the 300 * individual scope, setting new group and guest permissions. 301 * 302 * @param companyId the primary key of the portal instance 303 * @param groupId the primary key of the group 304 * @param name the resource's name, which should be a portlet ID if the 305 resource is a portlet or the resource's class name otherwise 306 * @param primKey the primary key string of the resource instance 307 * @param groupPermissions the group permissions to be applied 308 * @param guestPermissions the guest permissions to be applied 309 */ 310 public void updateResources(long companyId, long groupId, 311 java.lang.String name, java.lang.String primKey, 312 java.lang.String[] groupPermissions, java.lang.String[] guestPermissions) 313 throws PortalException; 314 315 /** 316 * Updates resources matching the group, name, and primary key at the 317 * individual scope, setting new group and guest permissions. 318 * 319 * @param companyId the primary key of the portal instance 320 * @param groupId the primary key of the group 321 * @param name the resource's name, which should be a portlet ID if the 322 resource is a portlet or the resource's class name otherwise 323 * @param primKey the primary key of the resource instance 324 * @param groupPermissions the group permissions to be applied 325 * @param guestPermissions the guest permissions to be applied 326 */ 327 public void updateResources(long companyId, long groupId, 328 java.lang.String name, long primKey, 329 java.lang.String[] groupPermissions, java.lang.String[] guestPermissions) 330 throws PortalException; 331 332 /** 333 * Updates resources matching the group, name, and primary key string at the 334 * individual scope, setting new permissions. 335 * 336 * @param companyId the primary key of the portal instance 337 * @param groupId the primary key of the group 338 * @param name the resource's name, which should be a portlet ID if the 339 resource is a portlet or the resource's class name otherwise 340 * @param primKey the primary key string of the resource instance 341 * @param modelPermissions the model permissions to be applied 342 */ 343 public void updateResources(long companyId, long groupId, 344 java.lang.String name, java.lang.String primKey, 345 ModelPermissions modelPermissions) throws PortalException; 346 347 /** 348 * Updates resources matching the group, name, and primary key at the 349 * individual scope, setting new permissions. 350 * 351 * @param companyId the primary key of the portal instance 352 * @param groupId the primary key of the group 353 * @param name the resource's name, which should be a portlet ID if the 354 resource is a portlet or the resource's class name otherwise 355 * @param primKey the primary key of the resource instance 356 * @param modelPermissions the model permissions to be applied 357 */ 358 public void updateResources(long companyId, long groupId, 359 java.lang.String name, long primKey, ModelPermissions modelPermissions) 360 throws PortalException; 361 362 /** 363 * Updates resources matching the name, primary key string and scope, 364 * replacing the primary key of their resource permissions with the new 365 * primary key. 366 * 367 * @param companyId the primary key of the portal instance 368 * @param name the resource's name, which should be a portlet ID if the 369 resource is a portlet or the resource's class name otherwise 370 * @param scope the scope of the resource. For more information see {@link 371 ResourceConstants}. 372 * @param primKey the primary key string of the resource instance 373 * @param newPrimKey the new primary key string of the resource 374 */ 375 public void updateResources(long companyId, java.lang.String name, 376 int scope, java.lang.String primKey, java.lang.String newPrimKey); 377 }