Search in sources :

Example 46 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelReviewMgrRestImpl method read.

/**
 * {@inheritDoc}
 */
@Override
public OrgUnit read(OrgUnit entity) throws SecurityException {
    VUtil.assertNotNull(entity, GlobalErrIds.ORG_NULL, CLS_NM + ".readOrgUnit");
    OrgUnit retOrg;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(entity);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_READ);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retOrg = (OrgUnit) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retOrg;
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 47 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelReviewMgrRestImpl method search.

/**
 * {@inheritDoc}
 */
@Override
public List<OrgUnit> search(OrgUnit.Type type, String searchVal) throws SecurityException {
    VUtil.assertNotNull(type, GlobalErrIds.ORG_TYPE_NULL, CLS_NM + ".search");
    List<OrgUnit> retOrgs;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    OrgUnit inOrg = new OrgUnit(searchVal, type);
    request.setEntity(inOrg);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_SEARCH);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retOrgs = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retOrgs;
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 48 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelegatedAdminMgrConsole method addAscendant.

/**
 */
private void addAscendant(OrgUnit.Type type) {
    try {
        OrgUnit cou = new OrgUnit();
        OrgUnit pou = new OrgUnit();
        cou.setType(type);
        pou.setType(type);
        ReaderUtil.clearScreen();
        System.out.println("Enter child orgunit name:");
        cou.setName(ReaderUtil.readLn());
        System.out.println("Enter parent orgunit name to add to repo:");
        pou.setName(ReaderUtil.readLn());
        System.out.println("Enter parent orgunit description:");
        pou.setDescription(ReaderUtil.readLn());
        dAmgr.addAscendant(cou, pou);
        System.out.println("child orgunit [" + cou.getName() + "]");
        System.out.println("parent orgunit [" + pou.getName() + "]");
        System.out.println("parent orgunit and inheritance relationship has been added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addAscendant caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

Example 49 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelegatedAdminMgrConsole method addDescendant.

/**
 */
private void addDescendant(OrgUnit.Type type) {
    try {
        OrgUnit cou = new OrgUnit();
        OrgUnit pou = new OrgUnit();
        cou.setType(type);
        pou.setType(type);
        ReaderUtil.clearScreen();
        System.out.println("Enter child orgunit name to add to repo:");
        cou.setName(ReaderUtil.readLn());
        System.out.println("Enter child orgunit description:");
        cou.setDescription(ReaderUtil.readLn());
        System.out.println("Enter parent orgunit name:");
        pou.setName(ReaderUtil.readLn());
        dAmgr.addDescendant(pou, cou);
        System.out.println("child orgunit [" + cou.getName() + "]");
        System.out.println("parent orgunit [" + pou.getName() + "]");
        System.out.println("child orgunit and inheritance relationship has been added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addDescendant caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

Example 50 with OrgUnit

use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.

the class DelegatedAdminMgrConsole method update.

private void update(OrgUnit.Type type) {
    OrgUnit ou = new OrgUnit();
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter orgunit name:");
        ou.setName(ReaderUtil.readLn());
        System.out.println("Enter description field");
        ou.setDescription(ReaderUtil.readLn());
        ou.setType(type);
        OrgUnit ou2 = dAmgr.update(ou);
        System.out.println("name [" + ou2.getName() + "]");
        System.out.println("internalId [" + ou2.getId() + "]");
        System.out.println("name description [" + ou2.getDescription() + "]");
        System.out.println("has been updated");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("update caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit)

Aggregations

OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)60 SecurityException (org.apache.directory.fortress.core.SecurityException)36 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)26 DelReviewMgr (org.apache.directory.fortress.core.DelReviewMgr)7 Relationship (org.apache.directory.fortress.core.model.Relationship)6 FinderException (org.apache.directory.fortress.core.FinderException)5 FortRequest (org.apache.directory.fortress.core.model.FortRequest)5 FortResponse (org.apache.directory.fortress.core.model.FortResponse)5 HashSet (java.util.HashSet)4 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)4 ArrayList (java.util.ArrayList)3 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)3 UserRole (org.apache.directory.fortress.core.model.UserRole)3 TreeSet (java.util.TreeSet)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 ValidationException (org.apache.directory.fortress.core.ValidationException)2 AdminRole (org.apache.directory.fortress.core.model.AdminRole)2 Graphable (org.apache.directory.fortress.core.model.Graphable)2 Hier (org.apache.directory.fortress.core.model.Hier)2 ObjectFactory (org.apache.directory.fortress.core.model.ObjectFactory)2