Search in sources :

Example 1 with RemoveException

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

the class AdminRoleDAO method remove.

/**
 * This method will completely remove the AdminRole from the directory.  It will use {@link AdminRole#name} as key.
 * This operation is performed on the {@link GlobalIds#ADMIN_ROLE_ROOT} container.
 *
 * @param role record contains {@link AdminRole#name}.
 * @throws RemoveException in the event LDAP errors occur.
 */
void remove(AdminRole role) throws RemoveException {
    LdapConnection ld = null;
    String dn = getDn(role);
    try {
        ld = getAdminConnection();
        delete(ld, dn, role);
    } catch (LdapException e) {
        String error = "remove role name=" + role.getName() + " LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.ARLE_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 2 with RemoveException

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

the class PermDAO method deleteAttributeSet.

/**
 * @param entity
 * @throws RemoveException
 */
void deleteAttributeSet(PermissionAttributeSet entity) throws RemoveException {
    LdapConnection ld = null;
    String dn = getDn(entity, entity.getContextId());
    try {
        ld = getAdminConnection();
        deleteRecursive(ld, dn, entity);
    } catch (LdapException e) {
        String error = "deleteAttributeSet name [" + entity.getName() + "]" + " caught LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.PERM_ATTRIBUTE_SET_DELETE_FAILED, error, e);
    } catch (CursorException e) {
        String error = "deleteAttributeSet name [" + entity.getName() + "] " + " caught LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.PERM_ATTRIBUTE_SET_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)

Example 3 with RemoveException

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

the class ConfigDAO method remove.

/**
 * @param name
 * @throws org.apache.directory.fortress.core.RemoveException
 */
void remove(String name) throws RemoveException {
    LdapConnection ld = null;
    String dn = getDn(name);
    LOG.info("remove dn [{}]", dn);
    try {
        ld = getAdminConnection();
        delete(ld, dn);
    } catch (LdapException e) {
        String error = "remove dn [" + dn + "] LDAPException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.FT_CONFIG_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 4 with RemoveException

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

the class GroupDAO method remove.

/**
 * This method will remove group node from diretory.
 *
 * @param group
 * @throws org.apache.directory.fortress.core.RemoveException
 */
Group remove(Group group) throws RemoveException {
    LdapConnection ld = null;
    String nodeDn = getDn(group.getName(), group.getContextId());
    LOG.debug("remove group dn [{}]", nodeDn);
    try {
        ld = getAdminConnection();
        delete(ld, nodeDn, group);
    } catch (LdapException e) {
        String error = "remove group node dn [" + nodeDn + "] caught LDAPException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.GROUP_DELETE_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return group;
}
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 5 with RemoveException

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

the class OrganizationalUnitDAO method remove.

/**
 * @param oe
 * @throws org.apache.directory.fortress.core.RemoveException
 */
void remove(OrganizationalUnit oe) throws RemoveException {
    LdapConnection ld = null;
    String nodeDn = SchemaConstants.OU_AT + "=" + oe.getName() + ",";
    if (StringUtils.isNotEmpty(oe.getParent())) {
        nodeDn += SchemaConstants.OU_AT + "=" + oe.getParent() + ",";
    }
    nodeDn += getRootDn(oe.getContextId(), GlobalIds.SUFFIX);
    LOG.info("remove container dn [{}]", nodeDn);
    try {
        ld = getAdminConnection();
        deleteRecursive(ld, nodeDn);
    } catch (CursorException e) {
        String error = "remove container node dn [" + nodeDn + "] caught CursorException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.CNTR_DELETE_FAILED, error, e);
    } catch (LdapException e) {
        String error = "remove container node dn [" + nodeDn + "] caught LDAPException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.CNTR_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