Search in sources :

Example 11 with OrgUnit

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

the class PsoUtil method getInherited.

/**
 * Return Set of {@link org.apache.directory.fortress.core.model.OrgUnit#name}s ascendants contained within {@link org.apache.directory.fortress.core.model.OrgUnit.Type#PERM}.
 *
 * @param ous       contains list of {@link org.apache.directory.fortress.core.model.OrgUnit}s.
 * @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
 * @return contains Set of all descendants.
 */
Set<String> getInherited(List<OrgUnit> ous, String contextId) {
    // create Set with case insensitive comparator:
    Set<String> iOUs = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    if (CollectionUtils.isNotEmpty(ous)) {
        for (OrgUnit ou : ous) {
            String name = ou.getName();
            iOUs.add(name);
            Set<String> parents = HierUtil.getAscendants(name, getGraph(contextId));
            if (CollectionUtils.isNotEmpty(parents)) {
                iOUs.addAll(parents);
            }
        }
    }
    return iOUs;
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) TreeSet(java.util.TreeSet)

Example 12 with OrgUnit

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

the class DelegatedMgrImplTest method addOrgUnit.

public static void addOrgUnit(String msg, String[] org) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
        OrgUnit ou = OrgUnitTestData.getOrgUnit(org);
        OrgUnit entity = dAdminMgr.add(ou);
        LOG.debug("addOrgUnit ou [{}] successful", entity.getName());
    } catch (SecurityException ex) {
        LOG.error("addOrgUnit caught SecurityException rc={}, msg={}", ex.getErrorId(), ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 13 with OrgUnit

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

the class DelegatedMgrImplTest method delOrgUnitDescendant.

/**
 * @param msg
 */
private void delOrgUnitDescendant(String msg, String[][] oArray, OrgUnit.Type type) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] ole : oArray) {
            OrgUnit orgUnit = OrgUnitTestData.getOrgUnit(ole);
            // use list because order is important for test structure:
            List<String> descs = new ArrayList<String>();
            OrgUnitTestData.getRelationship(descs, ole);
            if (OrgUnitTestData.isTree(ole)) {
                OrgUnit parent = orgUnit;
                for (String desc : descs) {
                    OrgUnit child = new OrgUnit(desc);
                    dAdminMgr.deleteInheritance(parent, new OrgUnit(desc, type));
                    LOG.debug("delOrgUnitDescendant asc orgUnit [" + orgUnit.getName() + "] desc orgUnit [" + desc + "] successful");
                    parent = child;
                }
            } else {
                for (String desc : descs) {
                    dAdminMgr.deleteInheritance(orgUnit, new OrgUnit(desc, type));
                    LOG.debug("delOrgUnitDescendant asc orgUnit [" + orgUnit.getName() + "] desc orgUnit [" + desc + "] successful");
                }
            }
            Set<String> inheritances = OrgUnitTestData.getInheritances(ole);
            if (inheritances != null) {
                for (String desc : inheritances) {
                    dAdminMgr.deleteInheritance(orgUnit, new OrgUnit(desc, type));
                    LOG.debug("delOrgUnitDescendant asc orgUnit [" + orgUnit.getName() + "] desc orgUnit [" + desc + "] successful");
                }
            }
            dAdminMgr.delete(orgUnit);
            LOG.debug("delOrgUnitDescendant remove asc orgUnit [" + orgUnit.getName() + "] successful");
        }
        // cleanup the last row of descendants from orgUnit data set.
        DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
        String orgUnitSrchVal = TestUtils.getSrchValue(OrgUnitTestData.getName(oArray[0]));
        List<OrgUnit> cleanup = dReviewMgr.search(type, orgUnitSrchVal);
        for (OrgUnit oe : cleanup) {
            dAdminMgr.delete(oe);
            LOG.debug("delOrgUnitDescendant cleanup orgUnit [" + oe.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("delOrgUnitDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) ArrayList(java.util.ArrayList) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Example 14 with OrgUnit

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

the class DelegatedMgrImplTest method addOrgUnitAscendant.

/**
 * @param msg
 * @param oArray
 * @param type
 */
public static void addOrgUnitAscendant(String msg, String[][] oArray, OrgUnit.Type type) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] ole : oArray) {
            OrgUnit orgUnit = OrgUnitTestData.getOrgUnit(ole);
            if (OrgUnitTestData.isCreate(ole)) {
                dAdminMgr.add(orgUnit);
                LOG.debug("addOrgUnitAscendant add orgUnit [" + orgUnit.getName() + "] successful");
            }
            Set<String> ascs = new HashSet<String>();
            OrgUnitTestData.getRelationship(ascs, ole);
            for (String asc : ascs) {
                dAdminMgr.addAscendant(orgUnit, new OrgUnit(asc, type));
                LOG.debug("addOrgUnitAscendant desc role [" + orgUnit.getName() + "] asc role [" + asc + "] successful");
            }
            Set<String> inheritances = OrgUnitTestData.getInheritances(ole);
            if (inheritances != null) {
                for (String asc : inheritances) {
                    dAdminMgr.addInheritance(new OrgUnit(asc, type), orgUnit);
                    LOG.debug("addOrgUnitAscendant desc role [" + orgUnit.getName() + "] asc role [" + asc + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addOrgUnitAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) HashSet(java.util.HashSet)

Example 15 with OrgUnit

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

the class DelegatedMgrImplTest method deleteInheritedOrgUnits.

/**
 * @param msg
 * @param oArray
 */
private void deleteInheritedOrgUnits(String msg, String[][] oArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] ole : oArray) {
            OrgUnit child = OrgUnitTestData.getOrgUnit(ole);
            Set<String> parents = new HashSet<String>();
            OrgUnitTestData.getRelationship(parents, ole);
            for (String pOrg : parents) {
                OrgUnit parent = new OrgUnit(pOrg);
                parent.setType(child.getType());
                // public void deleteInheritance(OrgUnit parent, OrgUnit child)
                dAdminMgr.deleteInheritance(parent, child);
                LOG.debug("deleteInheritedOrgUnits child org [" + child.getName() + "] parent org [" + pOrg + "] successful");
            }
        }
    } catch (SecurityException ex) {
        LOG.error("deleteInheritedOrgUnits caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) HashSet(java.util.HashSet)

Aggregations

OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)60 SecurityException (org.apache.directory.fortress.core.SecurityException)36 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)26 DelReviewMgr (org.apache.directory.fortress.core.DelReviewMgr)7 Relationship (org.apache.directory.fortress.core.model.Relationship)6 FinderException (org.apache.directory.fortress.core.FinderException)5 FortRequest (org.apache.directory.fortress.core.model.FortRequest)5 FortResponse (org.apache.directory.fortress.core.model.FortResponse)5 HashSet (java.util.HashSet)4 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)4 ArrayList (java.util.ArrayList)3 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)3 UserRole (org.apache.directory.fortress.core.model.UserRole)3 TreeSet (java.util.TreeSet)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 ValidationException (org.apache.directory.fortress.core.ValidationException)2 AdminRole (org.apache.directory.fortress.core.model.AdminRole)2 Graphable (org.apache.directory.fortress.core.model.Graphable)2 Hier (org.apache.directory.fortress.core.model.Hier)2 ObjectFactory (org.apache.directory.fortress.core.model.ObjectFactory)2