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