001    /**
002     * Copyright (c) 2000-2012 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.portlet.mobiledevicerules.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.UnicodeProperties;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.ServiceContext;
022    import com.liferay.portlet.mobiledevicerules.model.MDRAction;
023    import com.liferay.portlet.mobiledevicerules.service.base.MDRActionServiceBaseImpl;
024    import com.liferay.portlet.mobiledevicerules.service.permission.MDRRuleGroupInstancePermissionUtil;
025    
026    import java.util.Locale;
027    import java.util.Map;
028    
029    /**
030     * @author Edward C. Han
031     */
032    public class MDRActionServiceImpl extends MDRActionServiceBaseImpl {
033    
034            public MDRAction addAction(
035                            long ruleGroupInstanceId, Map<Locale, String> nameMap,
036                            Map<Locale, String> descriptionMap, String type,
037                            String typeSettings, ServiceContext serviceContext)
038                    throws PortalException, SystemException {
039    
040                    MDRRuleGroupInstancePermissionUtil.check(
041                            getPermissionChecker(), ruleGroupInstanceId, ActionKeys.UPDATE);
042    
043                    return mdrActionLocalService.addAction(
044                            ruleGroupInstanceId, nameMap, descriptionMap, type, typeSettings,
045                            serviceContext);
046            }
047    
048            public MDRAction addAction(
049                            long ruleGroupInstanceId, Map<Locale, String> nameMap,
050                            Map<Locale, String> descriptionMap, String type,
051                            UnicodeProperties typeSettingsProperties,
052                            ServiceContext serviceContext)
053                    throws PortalException, SystemException {
054    
055                    MDRRuleGroupInstancePermissionUtil.check(
056                            getPermissionChecker(), ruleGroupInstanceId, ActionKeys.UPDATE);
057    
058                    return mdrActionLocalService.addAction(
059                            ruleGroupInstanceId, nameMap, descriptionMap, type,
060                            typeSettingsProperties, serviceContext);
061            }
062    
063            public void deleteAction(long actionId)
064                    throws PortalException, SystemException {
065    
066                    MDRAction action = mdrActionPersistence.findByPrimaryKey(actionId);
067    
068                    MDRRuleGroupInstancePermissionUtil.check(
069                            getPermissionChecker(), action.getRuleGroupInstanceId(),
070                            ActionKeys.UPDATE);
071    
072                    mdrActionLocalService.deleteAction(action);
073            }
074    
075            public MDRAction fetchAction(long actionId)
076                    throws PortalException, SystemException {
077    
078                    MDRAction action = mdrActionLocalService.fetchAction(actionId);
079    
080                    if (action != null) {
081                            MDRRuleGroupInstancePermissionUtil.check(
082                                    getPermissionChecker(), action.getRuleGroupInstanceId(),
083                                    ActionKeys.VIEW);
084                    }
085    
086                    return action;
087            }
088    
089            public MDRAction getAction(long actionId)
090                    throws PortalException, SystemException {
091    
092                    MDRAction action = mdrActionPersistence.findByPrimaryKey(actionId);
093    
094                    MDRRuleGroupInstancePermissionUtil.check(
095                            getPermissionChecker(), action.getRuleGroupInstanceId(),
096                            ActionKeys.VIEW);
097    
098                    return action;
099            }
100    
101            public MDRAction updateAction(
102                            long actionId, Map<Locale, String> nameMap,
103                            Map<Locale, String> descriptionMap, String type,
104                            String typeSettings, ServiceContext serviceContext)
105                    throws PortalException, SystemException {
106    
107                    MDRAction action = mdrActionPersistence.findByPrimaryKey(actionId);
108    
109                    MDRRuleGroupInstancePermissionUtil.check(
110                            getPermissionChecker(), action.getRuleGroupInstanceId(),
111                            ActionKeys.UPDATE);
112    
113                    return mdrActionLocalService.updateAction(
114                            actionId, nameMap, descriptionMap, type, typeSettings,
115                            serviceContext);
116            }
117    
118            public MDRAction updateAction(
119                            long actionId, Map<Locale, String> nameMap,
120                            Map<Locale, String> descriptionMap, String type,
121                            UnicodeProperties typeSettingsProperties,
122                            ServiceContext serviceContext)
123                    throws PortalException, SystemException {
124    
125                    MDRAction action = mdrActionPersistence.findByPrimaryKey(actionId);
126    
127                    MDRRuleGroupInstancePermissionUtil.check(
128                            getPermissionChecker(), action.getRuleGroupInstanceId(),
129                            ActionKeys.UPDATE);
130    
131                    return mdrActionLocalService.updateAction(
132                            actionId, nameMap, descriptionMap, type, typeSettingsProperties,
133                            serviceContext);
134            }
135    
136    }