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.SystemException;
018    import com.liferay.portal.kernel.mobile.device.rulegroup.rule.RuleHandler;
019    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020    import com.liferay.portal.theme.ThemeDisplay;
021    import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance;
022    
023    import java.util.Collection;
024    
025    /**
026     * @author Edward Han
027     */
028    public class RuleGroupProcessorUtil {
029    
030            public static MDRRuleGroupInstance evaluateRuleGroups(
031                            ThemeDisplay themeDisplay)
032                    throws SystemException {
033    
034                    return getRuleGroupProcessor().evaluateRuleGroups(themeDisplay);
035            }
036    
037            public static RuleGroupProcessor getRuleGroupProcessor() {
038                    PortalRuntimePermission.checkGetBeanProperty(
039                            RuleGroupProcessorUtil.class);
040    
041                    return _ruleGroupProcessor;
042            }
043    
044            public static RuleHandler getRuleHandler(String ruleType) {
045                    return getRuleGroupProcessor().getRuleHandler(ruleType);
046            }
047    
048            public static Collection<RuleHandler> getRuleHandlers() {
049                    return getRuleGroupProcessor().getRuleHandlers();
050            }
051    
052            public static Collection<String> getRuleHandlerTypes() {
053                    return getRuleGroupProcessor().getRuleHandlerTypes();
054            }
055    
056            public static void registerRuleHandler(RuleHandler ruleHandler) {
057                    getRuleGroupProcessor().registerRuleHandler(ruleHandler);
058            }
059    
060            public static RuleHandler unregisterRuleHandler(String ruleType) {
061                    return getRuleGroupProcessor().unregisterRuleHandler(ruleType);
062            }
063    
064            public void setRuleGroupProcessor(RuleGroupProcessor ruleGroupProcessor) {
065                    PortalRuntimePermission.checkSetBeanProperty(getClass());
066    
067                    _ruleGroupProcessor = ruleGroupProcessor;
068            }
069    
070            private static RuleGroupProcessor _ruleGroupProcessor;
071    
072    }