use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelAdminMgrImpl method addAscendant.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public void addAscendant(AdminRole childRole, AdminRole parentRole) throws SecurityException {
String methodName = "addAscendantRole";
assertContext(CLS_NM, methodName, parentRole, GlobalErrIds.ARLE_PARENT_NULL);
setEntitySession(CLS_NM, methodName, parentRole);
assertContext(CLS_NM, methodName, childRole, GlobalErrIds.ARLE_CHILD_NULL);
// ensure the child AdminRole exists:
AdminRole newChild = admRP.read(childRole);
AdminRoleUtil.validateRelationship(childRole, parentRole, false);
admRP.add(parentRole);
// Use cRole2 to update ONLY the parents attribute on the child role and nothing else:
AdminRole cRole2 = new AdminRole(childRole.getName());
cRole2.setParents(newChild.getParents());
cRole2.setParent(parentRole.getName());
cRole2.setContextId(this.contextId);
setAdminData(CLS_NM, methodName, cRole2);
admRP.update(cRole2);
AdminRoleUtil.updateHier(this.contextId, new Relationship(childRole.getName().toUpperCase(), parentRole.getName().toUpperCase()), Hier.Op.ADD);
}
Aggregations