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