Search in sources :

Example 16 with RemoveException

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

the class OrgUnitDAO method remove.

/**
 * @param entity
 * @return
 * @throws org.apache.directory.fortress.core.RemoveException
 */
OrgUnit remove(OrgUnit entity) throws RemoveException {
    LdapConnection ld = null;
    Dn dn = getDn(entity);
    try {
        ld = getAdminConnection();
        delete(ld, dn, entity);
    } catch (LdapException e) {
        String error = "remove orgUnit name [" + entity.getName() + "] type [" + entity.getType() + "] root [" + dn + "] caught LdapException=" + e;
        int errCode;
        if (entity.getType() == OrgUnit.Type.PERM) {
            errCode = GlobalErrIds.ORG_DELETE_FAILED_PERM;
        } else {
            errCode = GlobalErrIds.ORG_DELETE_FAILED_USER;
        }
        throw new RemoveException(errCode, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return entity;
}
Also used : RemoveException(org.apache.directory.fortress.core.RemoveException) Dn(org.apache.directory.api.ldap.model.name.Dn) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Aggregations

LdapException (org.apache.directory.api.ldap.model.exception.LdapException)16 RemoveException (org.apache.directory.fortress.core.RemoveException)16 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)16 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)5 ArrayList (java.util.ArrayList)1 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)1 Modification (org.apache.directory.api.ldap.model.entry.Modification)1 Dn (org.apache.directory.api.ldap.model.name.Dn)1