use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method addOrgUnitDescendant.
/**
* @param msg
* @param oArray
*/
public static void addOrgUnitDescendant(String msg, String[][] oArray, OrgUnit.Type type) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
int ctr = 0;
for (String[] ole : oArray) {
OrgUnit orgUnit = OrgUnitTestData.getOrgUnit(ole);
if (ctr++ == 0 || OrgUnitTestData.isTree(ole)) {
dAdminMgr.add(orgUnit);
LOG.debug("addOrgUnitDescendant add orgUnit [" + orgUnit.getName() + "] successful");
}
// 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, type);
dAdminMgr.addDescendant(parent, new OrgUnit(desc, type));
LOG.debug("addOrgUnitDescendant asc orgUnit [" + orgUnit.getName() + "] desc orgUnit [" + desc + "] successful");
parent = child;
}
} else {
for (String desc : descs) {
dAdminMgr.addDescendant(orgUnit, new OrgUnit(desc, type));
LOG.debug("addOrgUnitDescendant asc orgUnit [" + orgUnit.getName() + "] desc orgUnit [" + desc + "] successful");
}
}
Set<String> inheritances = OrgUnitTestData.getInheritances(ole);
if (inheritances != null) {
for (String desc : inheritances) {
dAdminMgr.addInheritance(orgUnit, new OrgUnit(desc, type));
LOG.debug("addOrgUnitDescendant asc orgUnit [" + orgUnit.getName() + "] desc orgUnit [" + desc + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("addOrgUnitDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method readOrgUnits.
/**
* @param msg
* @param oArray
*/
public static void readOrgUnits(String msg, String[][] oArray) {
LogUtil.logIt(msg);
try {
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
for (String[] ole : oArray) {
OrgUnit ou = OrgUnitTestData.getOrgUnit(ole);
OrgUnit entity = dReviewMgr.read(ou);
OrgUnitTestData.assertEquals(entity, ole);
LOG.debug("readOrgUnits [" + entity.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("readOrgUnits caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method searchOrgUnits.
/**
* @param msg
* @param srchValue
* @param oArray
*/
public static void searchOrgUnits(String msg, String srchValue, String[][] oArray) {
LogUtil.logIt(msg);
try {
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
// grab the type from the first entry in the test org list:
OrgUnit.Type type = OrgUnitTestData.getType(oArray[0]);
List<OrgUnit> ous = dReviewMgr.search(type, srchValue);
assertNotNull(ous);
assertTrue("searchOrgUnits list size check", oArray.length == ous.size());
for (String[] ole : oArray) {
int indx = ous.indexOf(new OrgUnit(OrgUnitTestData.getName(ole)));
if (indx != -1) {
OrgUnit entity = ous.get(indx);
assertNotNull(entity);
OrgUnitTestData.assertEquals(entity, ole);
LOG.debug("searchOrgUnits [" + entity.getName() + "] successful");
} else {
msg = "searchOrgUnits srchValue [" + srchValue + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
} catch (SecurityException ex) {
LOG.error("searchOrgUnits srchValue [" + srchValue + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class OrgUnitTestData method getOrgUnit.
public static OrgUnit getOrgUnit(String[] ole) {
OrgUnit ou = new OrgUnit();
ou.setName(getName(ole));
ou.setDescription(getDescription(ole));
ou.setType(getType(ole));
return ou;
}
use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class CreateUserOrgHierarchySample method testCreateHierUserOrgs.
/**
* Add a simple OrgUnit hierarchy to ldap. The OrgUnits will named to include a name,'sampleHierUserOrg', appended with the
* sequence of 1 - 6. 'sampleHierUserOrg1' is the root or highest level OrgUnit in the structure while sampleHierUserOrg6 is the lowest
* most child. Fortress OrgUnits may have multiple parents which is demonstrated in testCreateAscendantUserOrgs sample.
* <p>
* <img src="./doc-files/HierUserOrgSimple.png" alt="">
*/
public static void testCreateHierUserOrgs() {
String szLocation = ".testCreateHierUserOrgs";
try {
// Instantiate the DelAdminMgr implementation which is used to provision ARBAC policies.
DelAdminMgr delAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
// Instantiate the root OrgUnit entity. OrgUnit requires name and type before addition.
OrgUnit baseOrgUnit = new OrgUnit(TEST_HIER_BASE_USERORG, OrgUnit.Type.USER);
// Add the root OrgUnit entity to the directory.
delAdminMgr.add(baseOrgUnit);
// Create User OrgUnits, 'sampleHierUserOrg2' - 'sampleHierUserOrg6'.
for (int i = 2; i < TEST_NUMBER + 1; i++) {
// Instantiate the OrgUnit entity.
OrgUnit childOrgUnit = new OrgUnit(TEST_HIER_USERORG_PREFIX + i, OrgUnit.Type.USER);
// Add the OrgUnit entity to the directory.
delAdminMgr.add(childOrgUnit);
// Instantiate the parent OrgUnit. The key is the name and type.
OrgUnit parentOrgUnit = new OrgUnit(TEST_HIER_USERORG_PREFIX + (i - 1), OrgUnit.Type.USER);
// Add a relationship between the parent and child OrgUnits:
delAdminMgr.addInheritance(parentOrgUnit, childOrgUnit);
}
LOG.info(szLocation + " success");
} catch (SecurityException ex) {
LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations