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.MDRRuleGroupInstance;
022 import com.liferay.portlet.mobiledevicerules.service.MDRRuleGroupInstanceLocalServiceUtil;
023
024
027 public class MDRRuleGroupInstancePermissionImpl
028 implements MDRRuleGroupInstancePermission {
029
030 @Override
031 public void check(
032 PermissionChecker permissionChecker, long ruleGroupInstanceId,
033 String actionId)
034 throws PortalException, SystemException {
035
036 if (!contains(permissionChecker, ruleGroupInstanceId, actionId)) {
037 throw new PrincipalException();
038 }
039 }
040
041 @Override
042 public void check(
043 PermissionChecker permissionChecker,
044 MDRRuleGroupInstance ruleGroupInstance, String actionId)
045 throws PortalException {
046
047 if (!contains(permissionChecker, ruleGroupInstance, actionId)) {
048 throw new PrincipalException();
049 }
050 }
051
052 @Override
053 public boolean contains(
054 PermissionChecker permissionChecker, long ruleGroupInstanceId,
055 String actionId)
056 throws PortalException, SystemException {
057
058 MDRRuleGroupInstance ruleGroupInstance =
059 MDRRuleGroupInstanceLocalServiceUtil.getMDRRuleGroupInstance(
060 ruleGroupInstanceId);
061
062 return contains(permissionChecker, ruleGroupInstance, actionId);
063 }
064
065 @Override
066 public boolean contains(
067 PermissionChecker permissionChecker,
068 MDRRuleGroupInstance ruleGroupInstance, String actionId) {
069
070 return permissionChecker.hasPermission(
071 ruleGroupInstance.getGroupId(),
072 MDRRuleGroupInstance.class.getName(),
073 ruleGroupInstance.getRuleGroupInstanceId(), actionId);
074 }
075
076 }