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