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