Search in sources :

Example 6 with RemoveException

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

the class UserDAO method remove.

/**
 * @param user
 * @throws RemoveException
 */
String remove(User user) throws RemoveException {
    LdapConnection ld = null;
    String userDn = getDn(user.getUserId(), user.getContextId());
    try {
        ld = getAdminConnection();
        delete(ld, userDn, user);
    } catch (LdapException e) {
        String error = "remove userId [" + user.getUserId() + "] caught LDAPException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.USER_DELETE_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return userDn;
}
Also used : RemoveException(org.apache.directory.fortress.core.RemoveException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 7 with RemoveException

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

the class RoleDAO method remove.

/**
 * @param role
 * @throws RemoveException
 */
void remove(Role role) throws RemoveException {
    LdapConnection ld = null;
    String dn = getDn(role.getName(), role.getContextId());
    try {
        ld = getAdminConnection();
        delete(ld, dn, role);
    } catch (LdapException e) {
        String error = "remove role name=" + role.getName() + " LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.ROLE_DELETE_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
}
Also used : RemoveException(org.apache.directory.fortress.core.RemoveException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 8 with RemoveException

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

the class ExampleDAO method remove.

/**
 * @param name
 * @throws org.apache.directory.fortress.core.RemoveException
 */
public void remove(String name) throws RemoveException {
    LdapConnection ld = null;
    String dn = SchemaConstants.CN_AT + "=" + name + "," + Config.getInstance().getProperty(EIds.EXAMPLE_ROOT);
    if (LOG.isDebugEnabled()) {
        LOG.debug("remove dn [" + dn + "]");
    }
    try {
        ld = getAdminConnection();
        delete(ld, dn);
    } catch (LdapException e) {
        String error = "remove [" + name + "] caught LDAPException=" + e;
        LOG.error(error);
        throw new RemoveException(EErrIds.EXAMPLE_DELETE_FAILED, error);
    } finally {
        closeAdminConnection(ld);
    }
}
Also used : RemoveException(org.apache.directory.fortress.core.RemoveException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 9 with RemoveException

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

the class SdDAO method remove.

/**
 * @param entity
 * @throws org.apache.directory.fortress.core.RemoveException
 */
SDSet remove(SDSet entity) throws RemoveException {
    LdapConnection ld = null;
    String dn = getDn(entity.getName(), entity.getContextId());
    try {
        ld = getAdminConnection();
        delete(ld, dn, entity);
    } catch (LdapException e) {
        String error = "remove SD name=" + entity.getName() + " type [" + entity.getType() + "] LdapException=" + e.getMessage();
        int errCode;
        if (entity.getType() == SDSet.SDType.DYNAMIC) {
            errCode = GlobalErrIds.DSD_DELETE_FAILED;
        } else {
            errCode = GlobalErrIds.SSD_DELETE_FAILED;
        }
        throw new RemoveException(errCode, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return entity;
}
Also used : RemoveException(org.apache.directory.fortress.core.RemoveException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 10 with RemoveException

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

the class SuffixDAO method remove.

/**
 * <p>
 * <font size="4" color="red">
 * This method is destructive as it will remove all nodes below the suffix using recursive delete function.<BR>
 * Extreme care should be taken during execution to ensure target directory is correct and permanent removal of data is intended.  There is no
 * 'undo' for this operation.
 * </font>
 *
 * @param se
 * @throws org.apache.directory.fortress.core.RemoveException
 */
void remove(Suffix se) throws RemoveException {
    LdapConnection ld = null;
    String nodeDn = getDn(se);
    LOG.info("remove suffix dn [{}]", nodeDn);
    try {
        ld = getAdminConnection();
        deleteRecursive(ld, nodeDn);
    } catch (CursorException e) {
        String error = "remove suffix node dn [" + nodeDn + "] caught CursorException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.SUFX_DELETE_FAILED, error, e);
    } catch (LdapException e) {
        String error = "remove suffix node dn [" + nodeDn + "] caught LDAPException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.SUFX_DELETE_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
}
Also used : RemoveException(org.apache.directory.fortress.core.RemoveException) CursorException(org.apache.directory.api.ldap.model.cursor.CursorException) 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