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.jsonwebservice;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import java.lang.reflect.Method;
020    
021    import java.util.List;
022    import java.util.Map;
023    import java.util.Set;
024    
025    import javax.servlet.ServletContext;
026    import javax.servlet.http.HttpServletRequest;
027    
028    /**
029     * @author Igor Spasic
030     */
031    public class JSONWebServiceActionsManagerUtil {
032    
033            public static Set<String> getContextNames() {
034                    return _jsonWebServiceActionsManager.getContextNames();
035            }
036    
037            public static JSONWebServiceAction getJSONWebServiceAction(
038                            HttpServletRequest request)
039                    throws NoSuchJSONWebServiceException {
040    
041                    return getJSONWebServiceActionsManager().getJSONWebServiceAction(
042                            request);
043            }
044    
045            public static JSONWebServiceAction getJSONWebServiceAction(
046                            HttpServletRequest request, String path, String method,
047                            Map<String, Object> parameterMap)
048                    throws NoSuchJSONWebServiceException {
049    
050                    return getJSONWebServiceActionsManager().getJSONWebServiceAction(
051                            request, path, method, parameterMap);
052            }
053    
054            public static JSONWebServiceActionMapping getJSONWebServiceActionMapping(
055                    String signature) {
056    
057                    return getJSONWebServiceActionsManager().getJSONWebServiceActionMapping(
058                            signature);
059            }
060    
061            public static List<JSONWebServiceActionMapping>
062                    getJSONWebServiceActionMappings(String contextName) {
063    
064                    PortalRuntimePermission.checkGetBeanProperty(
065                            JSONWebServiceActionsManagerUtil.class);
066    
067                    return _jsonWebServiceActionsManager.getJSONWebServiceActionMappings(
068                            contextName);
069            }
070    
071            public static int getJSONWebServiceActionsCount(String contextName) {
072                    return getJSONWebServiceActionsManager().getJSONWebServiceActionsCount(
073                            contextName);
074            }
075    
076            public static JSONWebServiceActionsManager
077                    getJSONWebServiceActionsManager() {
078    
079                    return _jsonWebServiceActionsManager;
080            }
081    
082            public static JSONWebServiceNaming getJSONWebServiceNaming() {
083                    return getJSONWebServiceActionsManager().getJSONWebServiceNaming();
084            }
085    
086            public static void registerJSONWebServiceAction(
087                    String contextName, String contextPath, Class<?> actionClass,
088                    Method actionMethod, String path, String method) {
089    
090                    getJSONWebServiceActionsManager().registerJSONWebServiceAction(
091                            contextName, contextPath, actionClass, actionMethod, path, method);
092            }
093    
094            public static void registerJSONWebServiceAction(
095                    String contextName, String contextPath, Object actionObject,
096                    Class<?> actionClass, Method actionMethod, String path, String method) {
097    
098                    getJSONWebServiceActionsManager().registerJSONWebServiceAction(
099                            contextName, contextPath, actionObject, actionClass, actionMethod,
100                            path, method);
101            }
102    
103            public static int registerServletContext(ServletContext servletContext) {
104                    return getJSONWebServiceActionsManager().registerServletContext(
105                            servletContext);
106            }
107    
108            public static int unregisterJSONWebServiceActions(Object actionObject) {
109                    return getJSONWebServiceActionsManager().
110                            unregisterJSONWebServiceActions(actionObject);
111            }
112    
113            public static int unregisterJSONWebServiceActions(String contextPath) {
114                    return getJSONWebServiceActionsManager().
115                            unregisterJSONWebServiceActions(contextPath);
116            }
117    
118            public static int unregisterServletContext(ServletContext servletContext) {
119                    return getJSONWebServiceActionsManager().unregisterServletContext(
120                            servletContext);
121            }
122    
123            public void setJSONWebServiceActionsManager(
124                    JSONWebServiceActionsManager jsonWebServiceActionsManager) {
125    
126                    PortalRuntimePermission.checkSetBeanProperty(getClass());
127    
128                    _jsonWebServiceActionsManager = jsonWebServiceActionsManager;
129            }
130    
131            private static JSONWebServiceActionsManager _jsonWebServiceActionsManager;
132    
133    }