...
If an entity is going to be disabled from permissions, send an email to the employee and an admin
Assign this rule to the permission definition of the permission that is disabled.
Java example
Code Block |
---|
//add a rule on the permission definition saying if you are about to lose a permission by all paths (flattened), then send an email AttributeAssign attributeAssign = permissionDef .getAttributeDelegate().addAttribute(RuleUtils.ruleAttributeDefName()).getAttributeAssign(); attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleActAsSubjectSourceIdName(), actAsSubject.getSourceId()); attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleActAsSubjectIdName(), actAsSubject.getId()); attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleCheckTypeName(), RuleCheckType.permissionDisabledDate.name()); //will find memberships with a disabled date at least 6 days from now. blank means no min attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleCheckArg0Name(), daysInFutureDisabledDateMin == null ? null : daysInFutureDisabledDateMin.toString()); //will find memberships with a disabled date at most 8 days from now. blank means no max attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleCheckArg1Name(), daysInFutureDisabledDateMax == null ? null : daysInFutureDisabledDateMax.toString()); attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleThenEnumName(), RuleThenEnum.sendEmail.name()); attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleThenEnumArg0Name(), emailToValue); attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleThenEnumArg1Name(), emailSubjectValue); //the to, subject, or body could be text with EL variables, or could be a template. If template, it is //read from the classpath from package: grouperRulesEmailTemplates/theTemplateName.txt //or you could configure grouper.properties to keep them in an external folder, not in the classpath attributeAssign.getAttributeValueDelegate().assignValue( RuleUtils.ruleThenEnumArg2Name(), emailBodyValue); //should be valid String isValidString = attributeAssign.getAttributeValueDelegate().retrieveValueString( RuleUtils.ruleValidName()); if (!StringUtils.equals("T", isValidString)) { throw new RuntimeException(isValidString); } |
...