use of org.apache.directory.fortress.core.DelReviewMgr 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());
}
}
use of org.apache.directory.fortress.core.DelReviewMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method readAdminRoles.
/**
* @param msg
* @param rArray
*/
public static void readAdminRoles(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
for (String[] rle : rArray) {
AdminRole entity = dReviewMgr.readRole(AdminRoleTestData.getRole(rle));
AdminRoleTestData.assertEquals(entity, rle);
LOG.debug("readAdminRoles [" + entity.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("readAdminRoles caught SecurityException=" + 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 loadAdminRequired.
private static boolean loadAdminRequired(String msg, String[][] rArray) {
// default return is 'true':
boolean loadAdmin = true;
String methodName = ".loadAdminRequired";
LogUtil.logIt(msg);
try {
DelReviewMgr dReviewMgr = getDelegatedReviewMgr();
for (String[] rle : rArray) {
AdminRole entity = dReviewMgr.readRole(new AdminRole(RoleTestData.getName(rle)));
if (entity == null) {
break;
}
// AdminRoleTestData.assertEquals( entity, rle );
}
// if we get to here it means that admin role has already been loaded
loadAdmin = false;
} catch (SecurityException ex) {
// This is the expected when teardown is not required:
if (ex.getErrorId() == GlobalErrIds.ROLE_NOT_FOUND) {
// did not find so need to load admin roles
} else {
// Something unexpected occurred here, Report as warning to the logger:
String warning = methodName + " caught SecurityException=" + ex.getMessage();
LOG.warn(warning);
// TODO: Determine if it would be better to throw a SecurityException here.
}
}
LOG.info(methodName + ":" + loadAdmin);
return loadAdmin;
}
use of org.apache.directory.fortress.core.DelReviewMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method assignAdminUsers.
/**
* @param msg
* @param uArray
* @param rArray
*/
public static void assignAdminUsers(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
DelReviewMgr dReviewMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
dReviewMgr = getManagedDelegatedReviewMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
dReviewMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
}
int i = 0;
for (String[] usr : uArray) {
i++;
for (String[] rle : rArray) {
UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rle).getName());
dAdminMgr.assignUser(uAdminRole);
LOG.debug("assignAdminUsers user [" + uAdminRole.getUserId() + "] role [" + uAdminRole.getName() + "] successful");
// Let's double check the number of users not associated with role:
// This one retrieves the collection of all "roleOccupant" attributes associated with the role node:
List<User> users = dReviewMgr.assignedUsers(AdminRoleTestData.getRole(rle));
assertNotNull(users);
assertTrue(CLS_NM + "assignAdminUsers list size check", i == users.size());
}
}
} catch (SecurityException ex) {
LOG.error("assignAdminUsers 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 getManagedDelegatedReviewMgr.
/**
* @return
* @throws SecurityException
*/
private static DelReviewMgr getManagedDelegatedReviewMgr() throws SecurityException {
DelReviewMgr dReviewMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
if (FortressJUnitTest.isAdminEnabled() && adminSess == null) {
adminSess = DelegatedMgrImplTest.createAdminSession();
}
dReviewMgr.setAdmin(adminSess);
return dReviewMgr;
}
Aggregations