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.security.permission.ActionKeys;
020 import com.liferay.portal.security.permission.PermissionChecker;
021 import com.liferay.portal.service.ServiceContext;
022 import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroup;
023 import com.liferay.portlet.mobiledevicerules.service.base.MDRRuleGroupServiceBaseImpl;
024 import com.liferay.portlet.mobiledevicerules.service.permission.MDRPermissionUtil;
025 import com.liferay.portlet.mobiledevicerules.service.permission.MDRRuleGroupPermissionUtil;
026
027 import java.util.Locale;
028 import java.util.Map;
029
030
033 public class MDRRuleGroupServiceImpl extends MDRRuleGroupServiceBaseImpl {
034
035 @Override
036 public MDRRuleGroup addRuleGroup(
037 long groupId, Map<Locale, String> nameMap,
038 Map<Locale, String> descriptionMap, ServiceContext serviceContext)
039 throws PortalException, SystemException {
040
041 MDRPermissionUtil.check(
042 getPermissionChecker(), groupId, ActionKeys.ADD_RULE_GROUP);
043
044 return mdrRuleGroupLocalService.addRuleGroup(
045 groupId, nameMap, descriptionMap, serviceContext);
046 }
047
048 @Override
049 public MDRRuleGroup copyRuleGroup(
050 long ruleGroupId, long groupId, ServiceContext serviceContext)
051 throws PortalException, SystemException {
052
053 PermissionChecker permissionChecker = getPermissionChecker();
054
055 MDRRuleGroup ruleGroup = getRuleGroup(ruleGroupId);
056
057 MDRRuleGroupPermissionUtil.check(
058 permissionChecker, ruleGroup, ActionKeys.VIEW);
059
060 MDRPermissionUtil.check(
061 permissionChecker, groupId, ActionKeys.ADD_RULE_GROUP);
062
063 return mdrRuleGroupLocalService.copyRuleGroup(
064 ruleGroup, groupId, serviceContext);
065 }
066
067 @Override
068 public void deleteRuleGroup(long ruleGroupId)
069 throws PortalException, SystemException {
070
071 MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.findByPrimaryKey(
072 ruleGroupId);
073
074 MDRRuleGroupPermissionUtil.check(
075 getPermissionChecker(), ruleGroup, ActionKeys.DELETE);
076
077 mdrRuleGroupLocalService.deleteRuleGroup(ruleGroup);
078 }
079
080 @Override
081 public MDRRuleGroup fetchRuleGroup(long ruleGroupId)
082 throws PortalException, SystemException {
083
084 MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.fetchByPrimaryKey(
085 ruleGroupId);
086
087 if (ruleGroup != null) {
088 MDRRuleGroupPermissionUtil.check(
089 getPermissionChecker(), ruleGroup, ActionKeys.VIEW);
090 }
091
092 return ruleGroup;
093 }
094
095 @Override
096 public MDRRuleGroup getRuleGroup(long ruleGroupId)
097 throws PortalException, SystemException {
098
099 MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.findByPrimaryKey(
100 ruleGroupId);
101
102 MDRRuleGroupPermissionUtil.check(
103 getPermissionChecker(), ruleGroup, ActionKeys.VIEW);
104
105 return ruleGroup;
106 }
107
108 @Override
109 public MDRRuleGroup updateRuleGroup(
110 long ruleGroupId, Map<Locale, String> nameMap,
111 Map<Locale, String> descriptionMap, ServiceContext serviceContext)
112 throws PortalException, SystemException {
113
114 MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.findByPrimaryKey(
115 ruleGroupId);
116
117 MDRRuleGroupPermissionUtil.check(
118 getPermissionChecker(), ruleGroup, ActionKeys.UPDATE);
119
120 return mdrRuleGroupLocalService.updateRuleGroup(
121 ruleGroupId, nameMap, descriptionMap, serviceContext);
122 }
123
124 }