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 ServiceContext#setAddGroupPermissions(
054            * boolean)} and {@link
055            * 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            * ServiceContext#setDeriveDefaultPermissions(
066            * boolean)}.
067            * </li>
068            * <li>
069            * Lastly group and guest permissions from the service
070            * context are applied. See {@link
071            * ServiceContext#setGroupPermissions(String[])}
072            * and {@link
073            * 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            public static void addModelResources(long companyId, long groupId,
148                    long userId, java.lang.String name, long primKey,
149                    com.liferay.portal.service.permission.ModelPermissions modelPermissions)
150                    throws com.liferay.portal.kernel.exception.PortalException {
151                    getService()
152                            .addModelResources(companyId, groupId, userId, name, primKey,
153                            modelPermissions);
154            }
155    
156            public static void addModelResources(long companyId, long groupId,
157                    long userId, java.lang.String name, java.lang.String primKey,
158                    com.liferay.portal.service.permission.ModelPermissions modelPermissions)
159                    throws com.liferay.portal.kernel.exception.PortalException {
160                    getService()
161                            .addModelResources(companyId, groupId, userId, name, primKey,
162                            modelPermissions);
163            }
164    
165            /**
166            * Adds resources for the entity with the name. Use this method if the user
167            * is unknown or irrelevant and there is no current entity instance.
168            *
169            * @param companyId the primary key of the portal instance
170            * @param groupId the primary key of the group
171            * @param name a name for the resource, which should be a portlet ID if the
172            resource is a portlet or the resource's class name otherwise
173            * @param portletActions whether to associate portlet actions with the
174            resource
175            * @throws PortalException if no portal actions could be found associated
176            with the resource or if a portal exception occurred
177            */
178            public static void addResources(long companyId, long groupId,
179                    java.lang.String name, boolean portletActions)
180                    throws com.liferay.portal.kernel.exception.PortalException {
181                    getService().addResources(companyId, groupId, name, portletActions);
182            }
183    
184            /**
185            * Adds resources for the entity with the name and primary key string,
186            * always creating a resource at the individual scope and only creating
187            * resources at the group, group template, and company scope if such
188            * resources don't 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 string of the resource instance,
196            optionally an empty string 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            * @throws PortalException if no portal actions could be found associated
202            with the resource or if a portal exception occurred
203            */
204            public static void addResources(long companyId, long groupId, long userId,
205                    java.lang.String name, java.lang.String primKey,
206                    boolean portletActions, boolean addGroupPermissions,
207                    boolean addGuestPermissions)
208                    throws com.liferay.portal.kernel.exception.PortalException {
209                    getService()
210                            .addResources(companyId, groupId, userId, name, primKey,
211                            portletActions, addGroupPermissions, addGuestPermissions);
212            }
213    
214            /**
215            * Adds resources for the entity with the name and primary key, always
216            * creating a resource at the individual scope and only creating resources
217            * at the group, group template, and company scope if such resources don't
218            * already exist.
219            *
220            * @param companyId the primary key of the portal instance
221            * @param groupId the primary key of the group
222            * @param userId the primary key of the user adding the resources
223            * @param name a name for the resource, which should be a portlet ID if the
224            resource is a portlet or the resource's class name otherwise
225            * @param primKey the primary key of the resource instance, optionally
226            <code>0</code> if no instance exists
227            * @param portletActions whether to associate portlet actions with the
228            resource
229            * @param addGroupPermissions whether to add group permissions
230            * @param addGuestPermissions whether to add guest permissions
231            * @throws PortalException if no portal actions could be found associated
232            with the resource or if a portal exception occurred
233            */
234            public static void addResources(long companyId, long groupId, long userId,
235                    java.lang.String name, long primKey, boolean portletActions,
236                    boolean addGroupPermissions, boolean addGuestPermissions)
237                    throws com.liferay.portal.kernel.exception.PortalException {
238                    getService()
239                            .addResources(companyId, groupId, userId, name, primKey,
240                            portletActions, addGroupPermissions, addGuestPermissions);
241            }
242    
243            /**
244            * Deletes the resource associated with the model at the scope.
245            *
246            * @param auditedModel the model associated with the resource
247            * @param scope the scope of the resource. For more information see {@link
248            ResourceConstants}.
249            * @throws PortalException if a portal exception occurred
250            */
251            public static void deleteResource(
252                    com.liferay.portal.model.AuditedModel auditedModel, int scope)
253                    throws com.liferay.portal.kernel.exception.PortalException {
254                    getService().deleteResource(auditedModel, scope);
255            }
256    
257            /**
258            * Deletes the resource matching the primary key at the scope.
259            *
260            * @param companyId the primary key of the portal instance
261            * @param name the resource's name, which should be a portlet ID if the
262            resource is a portlet or the resource's class name otherwise
263            * @param scope the scope of the resource. For more information see {@link
264            ResourceConstants}.
265            * @param primKey the primary key of the resource instance
266            * @throws PortalException if a portal exception occurred
267            */
268            public static void deleteResource(long companyId, java.lang.String name,
269                    int scope, long primKey)
270                    throws com.liferay.portal.kernel.exception.PortalException {
271                    getService().deleteResource(companyId, name, scope, primKey);
272            }
273    
274            /**
275            * Deletes the resource matching the primary key at the scope.
276            *
277            * @param companyId the primary key of the portal instance
278            * @param name the resource's name, which should be a portlet ID if the
279            resource is a portlet or the resource's class name otherwise
280            * @param scope the scope of the resource. For more information see {@link
281            ResourceConstants}.
282            * @param primKey the primary key string of the resource instance
283            * @throws PortalException if a portal exception occurred
284            */
285            public static void deleteResource(long companyId, java.lang.String name,
286                    int scope, java.lang.String primKey)
287                    throws com.liferay.portal.kernel.exception.PortalException {
288                    getService().deleteResource(companyId, name, scope, primKey);
289            }
290    
291            /**
292            * Returns the Spring bean ID for this bean.
293            *
294            * @return the Spring bean ID for this bean
295            */
296            public static java.lang.String getBeanIdentifier() {
297                    return getService().getBeanIdentifier();
298            }
299    
300            /**
301            * Returns a new resource with the name and primary key at the scope.
302            *
303            * @param companyId the primary key of the portal instance
304            * @param name a name for the resource, which should be a portlet ID if the
305            resource is a portlet or the resource's class name otherwise
306            * @param scope the scope of the resource. For more information see {@link
307            ResourceConstants}.
308            * @param primKey the primary key string of the resource
309            * @return the new resource
310            */
311            public static com.liferay.portal.model.Resource getResource(
312                    long companyId, java.lang.String name, int scope,
313                    java.lang.String primKey) {
314                    return getService().getResource(companyId, name, scope, primKey);
315            }
316    
317            /**
318            * Returns <code>true</code> if the roles have permission to perform the
319            * action on the resources.
320            *
321            * @param userId the primary key of the user performing the permission
322            check
323            * @param resourceId the primary key of the resource, typically the scope
324            group ID representing the scope in which the permission check is
325            being performed
326            * @param resources the resources for which permissions are to be checked
327            * @param actionId the primary key of the action to be performed on the
328            resources
329            * @param roleIds the primary keys of the roles
330            * @return <code>true</code> if the roles have permission to perform the
331            action on the resources;<code>false</code> otherwise
332            * @throws PortalException if any one of the roles with the primary keys
333            could not be found or if a resource action with the action ID
334            could not be found
335            */
336            public static boolean hasUserPermissions(long userId, long resourceId,
337                    java.util.List<com.liferay.portal.model.Resource> resources,
338                    java.lang.String actionId, long[] roleIds)
339                    throws com.liferay.portal.kernel.exception.PortalException {
340                    return getService()
341                                       .hasUserPermissions(userId, resourceId, resources, actionId,
342                            roleIds);
343            }
344    
345            /**
346            * Sets the Spring bean ID for this bean.
347            *
348            * @param beanIdentifier the Spring bean ID for this bean
349            */
350            public static void setBeanIdentifier(java.lang.String beanIdentifier) {
351                    getService().setBeanIdentifier(beanIdentifier);
352            }
353    
354            /**
355            * Updates the resources for the model, replacing their group and guest
356            * permissions with new ones from the service context.
357            *
358            * @param auditedModel the model associated with the resources
359            * @param serviceContext the service context to be applied. Can set group
360            and guest permissions.
361            * @throws PortalException if a portal exception occurred
362            */
363            public static void updateModelResources(
364                    com.liferay.portal.model.AuditedModel auditedModel,
365                    com.liferay.portal.service.ServiceContext serviceContext)
366                    throws com.liferay.portal.kernel.exception.PortalException {
367                    getService().updateModelResources(auditedModel, serviceContext);
368            }
369    
370            /**
371            * Updates resources matching the group, name, and primary key string at the
372            * individual scope, setting new group and guest permissions.
373            *
374            * @param companyId the primary key of the portal instance
375            * @param groupId the primary key of the group
376            * @param name the resource's name, which should be a portlet ID if the
377            resource is a portlet or the resource's class name otherwise
378            * @param primKey the primary key string of the resource instance
379            * @param groupPermissions the group permissions to be applied
380            * @param guestPermissions the guest permissions to be applied
381            * @throws PortalException if a portal exception occurred
382            */
383            public static void updateResources(long companyId, long groupId,
384                    java.lang.String name, java.lang.String primKey,
385                    java.lang.String[] groupPermissions, java.lang.String[] guestPermissions)
386                    throws com.liferay.portal.kernel.exception.PortalException {
387                    getService()
388                            .updateResources(companyId, groupId, name, primKey,
389                            groupPermissions, guestPermissions);
390            }
391    
392            /**
393            * Updates resources matching the group, name, and primary key at the
394            * individual scope, setting new group and guest permissions.
395            *
396            * @param companyId the primary key of the portal instance
397            * @param groupId the primary key of the group
398            * @param name the resource's name, which should be a portlet ID if the
399            resource is a portlet or the resource's class name otherwise
400            * @param primKey the primary key of the resource instance
401            * @param groupPermissions the group permissions to be applied
402            * @param guestPermissions the guest permissions to be applied
403            * @throws PortalException if a portal exception occurred
404            */
405            public static void updateResources(long companyId, long groupId,
406                    java.lang.String name, long primKey,
407                    java.lang.String[] groupPermissions, java.lang.String[] guestPermissions)
408                    throws com.liferay.portal.kernel.exception.PortalException {
409                    getService()
410                            .updateResources(companyId, groupId, name, primKey,
411                            groupPermissions, guestPermissions);
412            }
413    
414            /**
415            * Updates resources matching the group, name, and primary key at the
416            * individual scope, setting new permissions.
417            *
418            * @param companyId the primary key of the portal instance
419            * @param groupId the primary key of the group
420            * @param name the resource's name, which should be a portlet ID if the
421            resource is a portlet or the resource's class name otherwise
422            * @param primKey the primary key of the resource instance
423            * @param modelPermissions the model permissions to be applied
424            * @throws PortalException if a portal exception occurred
425            */
426            public static void updateResources(long companyId, long groupId,
427                    java.lang.String name, long primKey,
428                    com.liferay.portal.service.permission.ModelPermissions modelPermissions)
429                    throws com.liferay.portal.kernel.exception.PortalException {
430                    getService()
431                            .updateResources(companyId, groupId, name, primKey, modelPermissions);
432            }
433    
434            /**
435            * Updates resources matching the group, name, and primary key string at the
436            * individual scope, setting new permissions.
437            *
438            * @param companyId the primary key of the portal instance
439            * @param groupId the primary key of the group
440            * @param name the resource's name, which should be a portlet ID if the
441            resource is a portlet or the resource's class name otherwise
442            * @param primKey the primary key string of the resource instance
443            * @param modelPermissions the model permissions to be applied
444            * @throws PortalException if a portal exception occurred
445            */
446            public static void updateResources(long companyId, long groupId,
447                    java.lang.String name, java.lang.String primKey,
448                    com.liferay.portal.service.permission.ModelPermissions modelPermissions)
449                    throws com.liferay.portal.kernel.exception.PortalException {
450                    getService()
451                            .updateResources(companyId, groupId, name, primKey, modelPermissions);
452            }
453    
454            /**
455            * Updates resources matching the name, primary key string and scope,
456            * replacing the primary key of their resource permissions with the new
457            * primary key.
458            *
459            * @param companyId the primary key of the portal instance
460            * @param name the resource's name, which should be a portlet ID if the
461            resource is a portlet or the resource's class name otherwise
462            * @param scope the scope of the resource. For more information see {@link
463            ResourceConstants}.
464            * @param primKey the primary key string of the resource instance
465            * @param newPrimKey the new primary key string of the resource
466            */
467            public static void updateResources(long companyId, java.lang.String name,
468                    int scope, java.lang.String primKey, java.lang.String newPrimKey) {
469                    getService().updateResources(companyId, name, scope, primKey, newPrimKey);
470            }
471    
472            public static ResourceLocalService getService() {
473                    if (_service == null) {
474                            _service = (ResourceLocalService)PortalBeanLocatorUtil.locate(ResourceLocalService.class.getName());
475    
476                            ReferenceRegistry.registerReference(ResourceLocalServiceUtil.class,
477                                    "_service");
478                    }
479    
480                    return _service;
481            }
482    
483            /**
484             * @deprecated As of 6.2.0
485             */
486            @Deprecated
487            public void setService(ResourceLocalService service) {
488            }
489    
490            private static ResourceLocalService _service;
491    }