001
014
015 package com.liferay.portlet.mobiledevicerules.service.permission;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.security.auth.PrincipalException;
020 import com.liferay.portal.security.permission.PermissionChecker;
021 import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroup;
022 import com.liferay.portlet.mobiledevicerules.service.MDRRuleGroupLocalServiceUtil;
023
024
027 public class MDRRuleGroupPermissionImpl implements MDRRuleGroupPermission {
028
029 @Override
030 public void check(
031 PermissionChecker permissionChecker, long ruleGroupId,
032 String actionId)
033 throws PortalException, SystemException {
034
035 if (!contains(permissionChecker, ruleGroupId, actionId)) {
036 throw new PrincipalException();
037 }
038 }
039
040 @Override
041 public void check(
042 PermissionChecker permissionChecker, MDRRuleGroup ruleGroup,
043 String actionId)
044 throws PortalException {
045
046 if (!contains(permissionChecker, ruleGroup, actionId)) {
047 throw new PrincipalException();
048 }
049 }
050
051 @Override
052 public boolean contains(
053 PermissionChecker permissionChecker, long ruleGroupId,
054 String actionId)
055 throws PortalException, SystemException {
056
057 MDRRuleGroup ruleGroup = MDRRuleGroupLocalServiceUtil.getMDRRuleGroup(
058 ruleGroupId);
059
060 return contains(permissionChecker, ruleGroup, actionId);
061 }
062
063 @Override
064 public boolean contains(
065 PermissionChecker permissionChecker, MDRRuleGroup ruleGroup,
066 String actionId) {
067
068 return permissionChecker.hasPermission(
069 ruleGroup.getGroupId(), MDRRuleGroup.class.getName(),
070 ruleGroup.getRuleGroupId(), actionId);
071 }
072
073 }