But like every new software release, one or two things may not behave quite like you expected them to.
As an example, the rule embedded within the USER_MOVE Rule Flow suggests that the moveUser method will move a user to a new Organisational Unit and automatically assign all default entitlements assigned to that OU. At least, the comments explicitly state that this is to be expected:
// Move the user assigning the default entitlements of the new OU
UtilAction.moveUser(sql, userBean, orgUnitBean);
// Assign default entitlements of OU
EntitlementBean entBeanDefault = new EntitlementBean();
entBeanDefault.setDefaultOption(true);
BeanList entsDefault = _OrgUnitAction.findEntitlementByOU(sql, false, entBeanDefault, null, orgUnitBean, null);
if (!entsDefault.isEmpty()) {
for (int k = 0; k < entsDefault.size(); k++) {
EntitlementBean role = (EntitlementBean) entsDefault.get(k);
BeanList roles = JobRoleAction.find(sql, role);
if(roles==null || roles.isEmpty() ) {
throw new Exception("Role : " + role.getName() + " not found!");
}
UserAction.addRole(sql, userBean , orgUnitBean , roles , null, null, false, false);
}
}
NOTE: The following will need adding to the Package Imports:
import com.engiweb.profilemanager.common.ruleengine.action.reorganize._OrgUnitAction
import com.engiweb.profilemanager.common.ruleengine.action.JobRoleAction
UtilAction.moveUser(sql, userBean, orgUnitBean);
Unfortunately, the result of this operation is somewhat disappointing. The user does indeed move... but new default entitlements are not assigned.
Checking a v5.2.1 demo image that I have, though, reveals the following additional code which does actually meet our expectations:
EntitlementBean entBeanDefault = new EntitlementBean();
entBeanDefault.setDefaultOption(true);
BeanList entsDefault = _OrgUnitAction.findEntitlementByOU(sql, false, entBeanDefault, null, orgUnitBean, null);
if (!entsDefault.isEmpty()) {
for (int k = 0; k < entsDefault.size(); k++) {
EntitlementBean role = (EntitlementBean) entsDefault.get(k);
BeanList roles = JobRoleAction.find(sql, role);
if(roles==null || roles.isEmpty() ) {
throw new Exception("Role : " + role.getName() + " not found!");
}
UserAction.addRole(sql, userBean , orgUnitBean , roles , null, null, false, false);
}
}
NOTE: The following will need adding to the Package Imports:
import com.engiweb.profilemanager.common.ruleengine.action.reorganize._OrgUnitAction
import com.engiweb.profilemanager.common.ruleengine.action.JobRoleAction
No comments:
Post a Comment