use of org.apache.directory.fortress.core.DelReviewMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method delAdminRoleDescendant.
private void delAdminRoleDescendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole adminRole = AdminRoleTestData.getRole(rle);
// use list because order is important for test structure:
List<String> descs = RoleTestData.getRelationshipList(rle);
if (descs != null) {
if (RoleTestData.isTree(rle)) {
AdminRole parent = adminRole;
for (String desc : descs) {
AdminRole child = new AdminRole(desc);
dAdminMgr.deleteInheritance(parent, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
parent = child;
}
} else {
for (String desc : descs) {
dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
}
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String desc : inheritances) {
dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
}
}
dAdminMgr.deleteRole(adminRole);
LOG.debug("delAdminRoleDescendant remove asc adminRole [" + adminRole.getName() + "] successful");
}
// cleanup the last row of descendants from orgUnit data set.
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
String srchVal = TestUtils.getSrchValue(RoleTestData.getName(rArray[0]));
List<AdminRole> cleanup = dReviewMgr.findRoles(srchVal);
for (Role re : cleanup) {
dAdminMgr.deleteRole((AdminRole) re);
LOG.debug("delAdminRoleDescendant cleanup adminRole [" + re.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delOrgUnitDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelReviewMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method delOrgUnitAscendant.
/**
* @param msg
* @param oArray
*/
private void delOrgUnitAscendant(String msg, String[][] oArray, OrgUnit.Type type) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] ole : oArray) {
OrgUnit orgUnit = OrgUnitTestData.getOrgUnit(ole);
Set<String> ascs = new HashSet<String>();
OrgUnitTestData.getRelationship(ascs, ole);
for (String asc : ascs) {
dAdminMgr.deleteInheritance(new OrgUnit(asc, type), orgUnit);
LOG.debug("delOrgUnitAscendant desc orgUnit [" + orgUnit.getName() + "] asc orgUnit [" + asc + "] successful");
}
Set<String> inheritances = OrgUnitTestData.getInheritances(ole);
if (inheritances != null) {
for (String asc : inheritances) {
dAdminMgr.deleteInheritance(new OrgUnit(asc, type), orgUnit);
LOG.debug("delOrgUnitAscendant desc orgUnit [" + orgUnit.getName() + "] asc orgUnit [" + asc + "] successful");
}
}
dAdminMgr.delete(orgUnit);
LOG.debug("delOrgUnitAscendant remove desc orgUnit [" + orgUnit.getName() + "] successful");
}
// cleanup the top ascendant from orgUnit data set.
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
String orgUnitSrchVal = OrgUnitTestData.getName(oArray[0]);
// stip off prefix and search:
orgUnitSrchVal = orgUnitSrchVal.substring(0, 3);
List<OrgUnit> cleanup = dReviewMgr.search(type, orgUnitSrchVal);
for (OrgUnit oe : cleanup) {
dAdminMgr.delete(oe);
LOG.debug("delOrgUnitAscendant cleanup orgUnit [" + oe.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delOrgUnitAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelReviewMgr 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.DelReviewMgr 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.DelReviewMgr in project directory-fortress-core by apache.
the class CreatePermOrgSample method testCreatePermOrg2.
/**
*/
public static void testCreatePermOrg2() {
String szLocation = ".testCreatePermOrg2";
try {
DelReviewMgr dRevAdminMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
// The OrgUnit requires name and type to be set before use.
OrgUnit inOU = new OrgUnit(TEST_PERM_OU_NM2, OrgUnit.Type.PERM);
try {
dRevAdminMgr.read(inOU);
// if org is found, return.
return;
} catch (FinderException fe) {
assertTrue(szLocation + " excep id check", fe.getErrorId() == GlobalErrIds.ORG_NOT_FOUND_PERM);
// pass
}
// Instantiate the Delegated AdminMgr implementation object which provisions OrgUnits and AdminRoles to the system.
DelAdminMgr dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
// Add the OrgUnit to the directory.
dAdminMgr.add(inOU);
// Instantiate the Delegated RevewMgr implementation which interrogates the OrgUnit and AdminRole data.
DelReviewMgr dReviewMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
// Now read the OrgUnit back to make sure it got added OK.
OrgUnit outOU = dReviewMgr.read(inOU);
assertTrue(szLocation + " failed read", inOU.equals(outOU));
LOG.info(szLocation + " [" + outOU.getName() + "] success");
} catch (SecurityException ex) {
LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations