@Override
  public MDRRuleGroup getRuleGroup(long ruleGroupId) throws PortalException {
    MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.findByPrimaryKey(ruleGroupId);

    MDRRuleGroupPermissionUtil.check(getPermissionChecker(), ruleGroup, ActionKeys.VIEW);

    return ruleGroup;
  }
  @Override
  public void deleteRuleGroup(long ruleGroupId) throws PortalException {
    MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.findByPrimaryKey(ruleGroupId);

    MDRRuleGroupPermissionUtil.check(getPermissionChecker(), ruleGroup, ActionKeys.DELETE);

    mdrRuleGroupLocalService.deleteRuleGroup(ruleGroup);
  }
  @Override
  public MDRRuleGroup fetchRuleGroup(long ruleGroupId) throws PortalException {

    MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.fetchByPrimaryKey(ruleGroupId);

    if (ruleGroup != null) {
      MDRRuleGroupPermissionUtil.check(getPermissionChecker(), ruleGroup, ActionKeys.VIEW);
    }

    return ruleGroup;
  }
  @Override
  public MDRRuleGroup copyRuleGroup(long ruleGroupId, long groupId, ServiceContext serviceContext)
      throws PortalException {

    PermissionChecker permissionChecker = getPermissionChecker();

    MDRRuleGroup ruleGroup = getRuleGroup(ruleGroupId);

    MDRRuleGroupPermissionUtil.check(permissionChecker, ruleGroup, ActionKeys.VIEW);

    MDRPermissionUtil.check(permissionChecker, groupId, ActionKeys.ADD_RULE_GROUP);

    return mdrRuleGroupLocalService.copyRuleGroup(ruleGroup, groupId, serviceContext);
  }
  @Override
  public MDRRuleGroup updateRuleGroup(
      long ruleGroupId,
      Map<Locale, String> nameMap,
      Map<Locale, String> descriptionMap,
      ServiceContext serviceContext)
      throws PortalException {

    MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.findByPrimaryKey(ruleGroupId);

    MDRRuleGroupPermissionUtil.check(getPermissionChecker(), ruleGroup, ActionKeys.UPDATE);

    return mdrRuleGroupLocalService.updateRuleGroup(
        ruleGroupId, nameMap, descriptionMap, serviceContext);
  }