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.kernel.mobile.device.rulegroup;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.mobile.device.rulegroup.action.ActionHandler;
020    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
021    import com.liferay.portlet.mobiledevicerules.model.MDRAction;
022    
023    import java.util.Collection;
024    import java.util.List;
025    
026    import javax.servlet.http.HttpServletRequest;
027    import javax.servlet.http.HttpServletResponse;
028    
029    /**
030     * @author Edward Han
031     */
032    public class ActionHandlerManagerUtil {
033    
034            public static void applyActions(
035                            List<MDRAction> mdrActions, HttpServletRequest request,
036                            HttpServletResponse response)
037                    throws PortalException, SystemException {
038    
039                    getActionHandlerManager().applyActions(mdrActions, request, response);
040            }
041    
042            public static ActionHandler getActionHandler(String actionType) {
043                    return getActionHandlerManager().getActionHandler(actionType);
044            }
045    
046            public static ActionHandlerManager getActionHandlerManager() {
047                    PortalRuntimePermission.checkGetBeanProperty(
048                            ActionHandlerManagerUtil.class);
049    
050                    return _actionHandlerManager;
051            }
052    
053            public static Collection<ActionHandler> getActionHandlers() {
054                    return getActionHandlerManager().getActionHandlers();
055            }
056    
057            public static Collection<String> getActionHandlerTypes() {
058                    return getActionHandlerManager().getActionHandlerTypes();
059            }
060    
061            public static void registerActionHandler(ActionHandler actionHandler) {
062                    getActionHandlerManager().registerActionHandler(actionHandler);
063            }
064    
065            public static ActionHandler unregisterActionHandler(String actionType) {
066                    return getActionHandlerManager().unregisterActionHandler(actionType);
067            }
068    
069            public void setActionHandlerManager(
070                    ActionHandlerManager actionHandlerManager) {
071    
072                    PortalRuntimePermission.checkSetBeanProperty(getClass());
073    
074                    _actionHandlerManager = actionHandlerManager;
075            }
076    
077            private static ActionHandlerManager _actionHandlerManager;
078    
079    }