Search in sources :

Example 11 with RemoveException

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

the class PermDAO method deletePermissionAttribute.

/**
 * @param entity
 * @throws RemoveException
 */
void deletePermissionAttribute(PermissionAttribute entity, String attributeSetName) throws RemoveException {
    LdapConnection ld = null;
    String dn = getDn(entity, attributeSetName, entity.getContextId());
    try {
        ld = getAdminConnection();
        delete(ld, dn);
    } catch (LdapException e) {
        String error = "deletePermission name [" + entity.getAttributeName() + "] set [" + attributeSetName + "] caught LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.PERM_ATTRIBUTE_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 12 with RemoveException

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

the class PermDAO method deleteObj.

/**
 * @param entity
 * @throws org.apache.directory.fortress.core.RemoveException
 */
void deleteObj(PermObj entity) throws RemoveException {
    LdapConnection ld = null;
    String dn = getDn(entity, entity.getContextId());
    try {
        ld = getAdminConnection();
        deleteRecursive(ld, dn, entity);
    } catch (LdapException e) {
        String error = "deleteObj objName [" + entity.getObjName() + "] caught LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.PERM_DELETE_FAILED, error, e);
    } catch (CursorException e) {
        String error = "deleteObj objName [" + entity.getObjName() + "] caught LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.PERM_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 13 with RemoveException

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

the class PermDAO method deleteOperation.

/**
 * @param entity
 * @throws org.apache.directory.fortress.core.RemoveException
 */
void deleteOperation(Permission entity) throws RemoveException {
    LdapConnection ld = null;
    String dn = getOpRdn(entity.getOpName(), entity.getObjId()) + "," + GlobalIds.POBJ_NAME + "=" + entity.getObjName() + "," + getRootDn(entity.isAdmin(), entity.getContextId());
    try {
        ld = getAdminConnection();
        deleteRecursive(ld, dn, entity);
    } catch (LdapException e) {
        String error = "deleteOperation objName [" + entity.getObjName() + "] opName [" + entity.getOpName() + "] caught LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.PERM_DELETE_FAILED, error, e);
    } catch (CursorException e) {
        String error = "deleteOperation objName [" + entity.getObjName() + "] opName [" + entity.getOpName() + "] caught LdapException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.PERM_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 14 with RemoveException

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

the class PolicyDAO method remove.

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

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

the class GroupDAO method delete.

Group delete(Group group, String key, String value) throws FinderException, RemoveException {
    LdapConnection ld = null;
    String nodeDn = getDn(group.getName(), group.getContextId());
    try {
        LOG.debug("delete group property dn [{}], key [{}], value [{}]", nodeDn, key, value);
        List<Modification> mods = new ArrayList<Modification>();
        mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, GROUP_PROPERTY_ATTR_IMPL, key + "=" + value));
        ld = getAdminConnection();
        modify(ld, nodeDn, mods, group);
    } catch (LdapException e) {
        String error = "delete group property node dn [" + nodeDn + "] caught LDAPException=" + e.getMessage();
        throw new RemoveException(GlobalErrIds.GROUP_DELETE_PROPERTY_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return get(group);
}
Also used : DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) Modification(org.apache.directory.api.ldap.model.entry.Modification) RemoveException(org.apache.directory.fortress.core.RemoveException) DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) ArrayList(java.util.ArrayList) 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