use of org.apache.directory.fortress.core.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method addOrgUnits.
/**
* @param msg
* @param oArray
*/
public static void addOrgUnits(String msg, String[][] oArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] ole : oArray) {
OrgUnit ou = OrgUnitTestData.getOrgUnit(ole);
OrgUnit entity = dAdminMgr.add(ou);
LOG.debug("addOrgUnits ou [" + entity.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("addOrgUnits caught SecurityException=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelAdminMgr 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.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method addInheritedOrgUnits.
/**
* @param msg
* @param oArray
*/
public static void addInheritedOrgUnits(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());
dAdminMgr.addInheritance(parent, child);
LOG.debug("addInheritedOrgUnits child org [" + child.getName() + "] parent org [" + pOrg + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("addInheritedOrgUnits caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelAdminMgr 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.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method assignAdminUserRole.
public static void assignAdminUserRole(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
}
int i = 0;
for (String[] usr : uArray) {
UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rArray[i]).getName());
dAdminMgr.assignUser(uAdminRole);
i++;
}
} catch (SecurityException ex) {
LOG.error("assignAdminUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations