use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method delAdminRoleAscendant.
/**
* @param msg
* @param rArray
*/
private void delAdminRoleAscendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole adminRole = AdminRoleTestData.getRole(rle);
Set<String> ascs = RoleTestData.getRelationships(rle);
if (ascs != null) {
for (String asc : ascs) {
dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc adminRole [" + asc + "] successful");
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String asc : inheritances) {
dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc orgUnit [" + asc + "] successful");
}
}
dAdminMgr.deleteRole(adminRole);
LOG.debug("delAdminRoleAscendant remove desc adminRole [" + adminRole.getName() + "] successful");
}
// cleanup the top ascendant from orgUnit data set.
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
String adminRoleSrchVal = RoleTestData.getName(rArray[0]);
// stip off prefix and search:
adminRoleSrchVal = adminRoleSrchVal.substring(0, 3);
List<AdminRole> cleanup = dReviewMgr.findRoles(adminRoleSrchVal);
for (AdminRole re : cleanup) {
dAdminMgr.deleteRole(re);
LOG.debug("delAdminRoleAscendant cleanup adminRole [" + re.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delAdminRoleAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.AdminRole 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.model.AdminRole in project directory-fortress-core by apache.
the class DelAdminMgrRestImpl method updateRole.
/**
* {@inheritDoc}
*/
@Override
public AdminRole updateRole(AdminRole role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".updateRole");
AdminRole retRole;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(role);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRole = (AdminRole) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRole;
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedAdminMgrConsole method updateRole.
/**
*/
protected void updateRole() {
AdminRole re = new AdminRole();
try {
ReaderUtil.clearScreen();
System.out.println("Enter role name:");
re.setName(ReaderUtil.readLn());
System.out.println("Enter Role's description field");
re.setDescription(ReaderUtil.readLn());
System.out.println("Enter OSP name (or NULL to skip):");
String val = ReaderUtil.readLn();
for (int i = 0; val != null && val.length() > 0; i++) {
re.setOsP(val);
System.out.println("Enter next name (or NULL if done entering OSPs):");
val = ReaderUtil.readLn();
}
System.out.println("Enter OSU name (or NULL to skip):");
val = ReaderUtil.readLn();
for (int i = 0; val != null && val.length() > 0; i++) {
re.setOsU(val);
System.out.println("Enter next name (or NULL if done entering OSUs):");
val = ReaderUtil.readLn();
}
AdminRole re2 = dAmgr.updateRole(re);
System.out.println("name [" + re2.getName() + "]");
System.out.println("internalId [" + re2.getId() + "]");
System.out.println("name description [" + re2.getDescription() + "]");
System.out.println("has been updated");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("updateRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedAdminMgrConsole method addRole.
protected void addRole() {
AdminRole re = new AdminRole();
try {
ReaderUtil.clearScreen();
System.out.println("Enter role name:");
re.setName(ReaderUtil.readLn());
System.out.println("Enter Role's description field");
re.setDescription(ReaderUtil.readLn());
System.out.println("Enter OSP name (or NULL to skip):");
String val = ReaderUtil.readLn();
for (int i = 0; val != null && val.length() > 0; i++) {
re.setOsP(val);
System.out.println("Enter next name (or NULL if done entering OSPs):");
val = ReaderUtil.readLn();
}
System.out.println("Enter OSU name (or NULL to skip):");
val = ReaderUtil.readLn();
for (int i = 0; val != null && val.length() > 0; i++) {
re.setOsU(val);
System.out.println("Enter next name (or NULL if done entering OSUs):");
val = ReaderUtil.readLn();
}
AdminRole re2 = dAmgr.addRole(re);
System.out.println("name [" + re2.getName() + "]");
System.out.println("internalId [" + re2.getId() + "]");
System.out.println("name description [" + re2.getDescription() + "]");
System.out.println("has been updated");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("updateRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations