001
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.jsonwebservice.JSONWebService;
020 import com.liferay.portal.kernel.jsonwebservice.JSONWebServiceMode;
021 import com.liferay.portal.kernel.util.UnicodeProperties;
022 import com.liferay.portal.security.permission.ActionKeys;
023 import com.liferay.portal.service.ServiceContext;
024 import com.liferay.portlet.mobiledevicerules.model.MDRRule;
025 import com.liferay.portlet.mobiledevicerules.service.base.MDRRuleServiceBaseImpl;
026 import com.liferay.portlet.mobiledevicerules.service.permission.MDRRuleGroupPermissionUtil;
027
028 import java.util.Locale;
029 import java.util.Map;
030
031
034 public class MDRRuleServiceImpl extends MDRRuleServiceBaseImpl {
035
036 @Override
037 public MDRRule addRule(
038 long ruleGroupId, Map<Locale, String> nameMap,
039 Map<Locale, String> descriptionMap, String type,
040 String typeSettings, ServiceContext serviceContext)
041 throws PortalException, SystemException {
042
043 MDRRuleGroupPermissionUtil.check(
044 getPermissionChecker(), ruleGroupId, ActionKeys.UPDATE);
045
046 return mdrRuleLocalService.addRule(
047 ruleGroupId, nameMap, descriptionMap, type, typeSettings,
048 serviceContext);
049 }
050
051 @JSONWebService(mode = JSONWebServiceMode.IGNORE)
052 @Override
053 public MDRRule addRule(
054 long ruleGroupId, Map<Locale, String> nameMap,
055 Map<Locale, String> descriptionMap, String type,
056 UnicodeProperties typeSettings, ServiceContext serviceContext)
057 throws PortalException, SystemException {
058
059 MDRRuleGroupPermissionUtil.check(
060 getPermissionChecker(), ruleGroupId, ActionKeys.UPDATE);
061
062 return mdrRuleLocalService.addRule(
063 ruleGroupId, nameMap, descriptionMap, type, typeSettings,
064 serviceContext);
065 }
066
067 @Override
068 public void deleteRule(long ruleId)
069 throws PortalException, SystemException {
070
071 MDRRule rule = mdrRulePersistence.findByPrimaryKey(ruleId);
072
073 MDRRuleGroupPermissionUtil.check(
074 getPermissionChecker(), rule.getRuleGroupId(), ActionKeys.UPDATE);
075
076 mdrRuleLocalService.deleteRule(rule);
077 }
078
079 @Override
080 public MDRRule fetchRule(long ruleId)
081 throws PortalException, SystemException {
082
083 MDRRule rule = mdrRuleLocalService.fetchRule(ruleId);
084
085 if (rule != null) {
086 MDRRuleGroupPermissionUtil.check(
087 getPermissionChecker(), rule.getRuleGroupId(), ActionKeys.VIEW);
088 }
089
090 return rule;
091 }
092
093 @Override
094 public MDRRule getRule(long ruleId)
095 throws PortalException, SystemException {
096
097 MDRRule rule = mdrRulePersistence.findByPrimaryKey(ruleId);
098
099 MDRRuleGroupPermissionUtil.check(
100 getPermissionChecker(), rule.getRuleGroupId(), ActionKeys.VIEW);
101
102 return rule;
103 }
104
105 @Override
106 public MDRRule updateRule(
107 long ruleId, Map<Locale, String> nameMap,
108 Map<Locale, String> descriptionMap, String type,
109 String typeSettings, ServiceContext serviceContext)
110 throws PortalException, SystemException {
111
112 MDRRule rule = mdrRulePersistence.findByPrimaryKey(ruleId);
113
114 MDRRuleGroupPermissionUtil.check(
115 getPermissionChecker(), rule.getRuleGroupId(), ActionKeys.UPDATE);
116
117 return mdrRuleLocalService.updateRule(
118 ruleId, nameMap, descriptionMap, type, typeSettings,
119 serviceContext);
120 }
121
122 @Override
123 public MDRRule updateRule(
124 long ruleId, Map<Locale, String> nameMap,
125 Map<Locale, String> descriptionMap, String type,
126 UnicodeProperties typeSettingsProperties,
127 ServiceContext serviceContext)
128 throws PortalException, SystemException {
129
130 MDRRule rule = mdrRulePersistence.findByPrimaryKey(ruleId);
131
132 MDRRuleGroupPermissionUtil.check(
133 getPermissionChecker(), rule.getRuleGroupId(), ActionKeys.UPDATE);
134
135 return mdrRuleLocalService.updateRule(
136 ruleId, nameMap, descriptionMap, type, typeSettingsProperties,
137 serviceContext);
138 }
139
140 }