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.security.permission;
016    
017    import com.liferay.portal.kernel.exception.NoSuchResourceActionException;
018    import com.liferay.portal.kernel.model.Group;
019    import com.liferay.portal.kernel.model.Portlet;
020    import com.liferay.portal.kernel.model.Role;
021    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
022    
023    import java.io.InputStream;
024    
025    import java.util.List;
026    import java.util.Locale;
027    
028    import javax.servlet.http.HttpServletRequest;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     * @author Daeyoung Song
033     */
034    public class ResourceActionsUtil {
035    
036            public static void checkAction(String name, String actionId)
037                    throws NoSuchResourceActionException {
038    
039                    getResourceActions().checkAction(name, actionId);
040            }
041    
042            public static String getAction(HttpServletRequest request, String action) {
043                    return getResourceActions().getAction(request, action);
044            }
045    
046            public static String getAction(Locale locale, String action) {
047                    return getResourceActions().getAction(locale, action);
048            }
049    
050            public static String getActionNamePrefix() {
051                    return getResourceActions().getActionNamePrefix();
052            }
053    
054            /**
055             * @deprecated As of 7.0.0
056             */
057            @Deprecated
058            public static List<String> getActionsNames(
059                    HttpServletRequest request, List<String> actions) {
060    
061                    return getResourceActions().getActionsNames(request, actions);
062            }
063    
064            /**
065             * @deprecated As of 7.0.0
066             */
067            @Deprecated
068            public static List<String> getActionsNames(
069                    HttpServletRequest request, String name, long actionIds) {
070    
071                    return getResourceActions().getActionsNames(request, name, actionIds);
072            }
073    
074            public static String getCompositeModelNameSeparator() {
075                    return getResourceActions().getCompositeModelNameSeparator();
076            }
077    
078            public static List<String> getModelNames() {
079                    return getResourceActions().getModelNames();
080            }
081    
082            public static List<String> getModelPortletResources(String name) {
083                    return getResourceActions().getModelPortletResources(name);
084            }
085    
086            public static String getModelResource(
087                    HttpServletRequest request, String name) {
088    
089                    return getResourceActions().getModelResource(request, name);
090            }
091    
092            public static String getModelResource(Locale locale, String name) {
093                    return getResourceActions().getModelResource(locale, name);
094            }
095    
096            public static List<String> getModelResourceActions(String name) {
097                    return getResourceActions().getModelResourceActions(name);
098            }
099    
100            public static List<String> getModelResourceGroupDefaultActions(
101                    String name) {
102    
103                    return getResourceActions().getModelResourceGroupDefaultActions(name);
104            }
105    
106            public static List<String> getModelResourceGuestDefaultActions(
107                    String name) {
108    
109                    return getResourceActions().getModelResourceGuestDefaultActions(name);
110            }
111    
112            public static List<String> getModelResourceGuestUnsupportedActions(
113                    String name) {
114    
115                    return getResourceActions().getModelResourceGuestUnsupportedActions(
116                            name);
117            }
118    
119            public static String getModelResourceNamePrefix() {
120                    return getResourceActions().getModelResourceNamePrefix();
121            }
122    
123            public static List<String> getModelResourceOwnerDefaultActions(
124                    String name) {
125    
126                    return getResourceActions().getModelResourceOwnerDefaultActions(name);
127            }
128    
129            public static Double getModelResourceWeight(String name) {
130                    return getResourceActions().getModelResourceWeight(name);
131            }
132    
133            public static String[] getOrganizationModelResources() {
134                    return getResourceActions().getOrganizationModelResources();
135            }
136    
137            public static String[] getPortalModelResources() {
138                    return getResourceActions().getPortalModelResources();
139            }
140    
141            public static String getPortletBaseResource(String portletName) {
142                    return getResourceActions().getPortletBaseResource(portletName);
143            }
144    
145            public static List<String> getPortletModelResources(String portletName) {
146                    return getResourceActions().getPortletModelResources(portletName);
147            }
148    
149            public static List<String> getPortletNames() {
150                    return getResourceActions().getPortletNames();
151            }
152    
153            public static List<String> getPortletResourceActions(Portlet portlet) {
154                    return getResourceActions().getPortletResourceActions(portlet);
155            }
156    
157            public static List<String> getPortletResourceActions(String name) {
158                    return getResourceActions().getPortletResourceActions(name);
159            }
160    
161            public static List<String> getPortletResourceGroupDefaultActions(
162                    String name) {
163    
164                    return getResourceActions().getPortletResourceGroupDefaultActions(name);
165            }
166    
167            public static List<String> getPortletResourceGuestDefaultActions(
168                    String name) {
169    
170                    return getResourceActions().getPortletResourceGuestDefaultActions(name);
171            }
172    
173            public static List<String> getPortletResourceGuestUnsupportedActions(
174                    String name) {
175    
176                    return getResourceActions().getPortletResourceGuestUnsupportedActions(
177                            name);
178            }
179    
180            public static List<String> getPortletResourceLayoutManagerActions(
181                    String name) {
182    
183                    return getResourceActions().getPortletResourceLayoutManagerActions(
184                            name);
185            }
186    
187            public static String getPortletRootModelResource(String portletName) {
188                    return getResourceActions().getPortletRootModelResource(portletName);
189            }
190    
191            public static ResourceActions getResourceActions() {
192                    PortalRuntimePermission.checkGetBeanProperty(ResourceActionsUtil.class);
193    
194                    return _resourceActions;
195            }
196    
197            public static List<String> getResourceActions(String name) {
198                    return getResourceActions().getResourceActions(name);
199            }
200    
201            public static List<String> getResourceActions(
202                    String portletResource, String modelResource) {
203    
204                    return getResourceActions().getResourceActions(
205                            portletResource, modelResource);
206            }
207    
208            public static List<String> getResourceGroupDefaultActions(String name) {
209                    return getResourceActions().getResourceGroupDefaultActions(name);
210            }
211    
212            public static List<String> getResourceGuestUnsupportedActions(
213                    String portletResource, String modelResource) {
214    
215                    return getResourceActions().getResourceGuestUnsupportedActions(
216                            portletResource, modelResource);
217            }
218    
219            public static List<Role> getRoles(
220                    long companyId, Group group, String modelResource, int[] roleTypes) {
221    
222                    return getResourceActions().getRoles(
223                            companyId, group, modelResource, roleTypes);
224            }
225    
226            public static String[] getRootModelResources() {
227                    return getResourceActions().getRootModelResources();
228            }
229    
230            public static boolean hasModelResourceActions(String name) {
231                    return getResourceActions().hasModelResourceActions(name);
232            }
233    
234            public static boolean isOrganizationModelResource(String modelResource) {
235                    return getResourceActions().isOrganizationModelResource(modelResource);
236            }
237    
238            public static boolean isPortalModelResource(String modelResource) {
239                    return getResourceActions().isPortalModelResource(modelResource);
240            }
241    
242            public static boolean isRootModelResource(String modelResource) {
243                    return getResourceActions().isRootModelResource(modelResource);
244            }
245    
246            public static void read(
247                            String servletContextName, ClassLoader classLoader, String source)
248                    throws Exception {
249    
250                    getResourceActions().read(servletContextName, classLoader, source);
251            }
252    
253            /**
254             * @deprecated As of 7.0.0
255             */
256            @Deprecated
257            public static void read(String servletContextName, InputStream inputStream)
258                    throws Exception {
259    
260                    getResourceActions().read(servletContextName, inputStream);
261            }
262    
263            public void setResourceActions(ResourceActions resourceActions) {
264                    PortalRuntimePermission.checkSetBeanProperty(getClass());
265    
266                    _resourceActions = resourceActions;
267            }
268    
269            private static ResourceActions _resourceActions;
270    
271    }