Search in sources :

Example 6 with Hier

use of org.apache.directory.fortress.core.model.Hier in project directory-fortress-core by apache.

the class HierUtil method loadHier.

/**
 * This method will retrieve the list of all parent-child relationships for a given node.  If the node was not found in
 * ldap this method will create a new node and store default data.
 * The following ldap nodes are currently storing hierarchical data:
 * <ol>
 * <li>RBAC Role relations are stored in {@code cn=Hierarchies,ou=Roles,ou=RBAC} ldap node and cached as singleton in {@link RoleUtil}</li>
 * <li>ARBAC Admin Role relations are stored in {@code cn=Hierarchies,ou=AdminRoles,ou=ARBAC} ldap node and cached as singleton in {@link AdminRoleUtil}</li>
 * <li>User Organizational Unit relations are stored in {@code cn=Hierarchies,ou=OS-U,ou=ARBAC} node and cached as {@link org.apache.directory.fortress.core.impl.UsoUtil}</li>
 * <li>Permission Organizational Unit relations are stored in {@code cn=Hierarchies,ou=OS-P,ou=ARBAC} node and cached as {@link org.apache.directory.fortress.core.impl.PsoUtil}</li>
 * </ol>
 *
 * @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
 * @return reference the the Hier result set retrieved from ldap.
 */
static Hier loadHier(String contextId, List<Graphable> descendants) {
    Hier hier = new Hier();
    if (CollectionUtils.isNotEmpty(descendants)) {
        hier.setContextId(contextId);
        for (Graphable descendant : descendants) {
            Set<String> parents = descendant.getParents();
            if (CollectionUtils.isNotEmpty(parents)) {
                for (String parent : parents) {
                    Relationship relationship = new Relationship();
                    relationship.setChild(descendant.getName().toUpperCase());
                    relationship.setParent(parent.toUpperCase());
                    hier.setRelationship(relationship);
                }
            }
        }
    }
    return hier;
}
Also used : Relationship(org.apache.directory.fortress.core.model.Relationship) Graphable(org.apache.directory.fortress.core.model.Graphable) Hier(org.apache.directory.fortress.core.model.Hier)

Aggregations

Hier (org.apache.directory.fortress.core.model.Hier)6 Relationship (org.apache.directory.fortress.core.model.Relationship)6 Graphable (org.apache.directory.fortress.core.model.Graphable)5 SecurityException (org.apache.directory.fortress.core.SecurityException)4 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)2