Search in sources :

Example 91 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class DefaultDitStructureRuleRegistry method getSchemaName.

/**
 * {@inheritDoc}
 */
@Override
public String getSchemaName(int ruleId) throws LdapException {
    DitStructureRule ditStructureRule = byRuleId.get(ruleId);
    if (ditStructureRule != null) {
        return ditStructureRule.getSchemaName();
    }
    String msg = I18n.err(I18n.ERR_13729_RULE_ID_NOT_FOUND, ruleId);
    LOG.warn(msg);
    throw new LdapException(msg);
}
Also used : DitStructureRule(org.apache.directory.api.ldap.model.schema.DitStructureRule) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 92 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class DefaultObjectClassRegistry method descendants.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public Iterator<ObjectClass> descendants(String ancestorId) throws LdapException {
    try {
        String oid = getOidByName(ancestorId);
        Set<ObjectClass> descendants = oidToDescendants.get(oid);
        if (descendants == null) {
            return Collections.EMPTY_SET.iterator();
        }
        return descendants.iterator();
    } catch (LdapException ne) {
        throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
    }
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 93 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class DefaultSchemaObjectRegistry method getSchemaName.

/**
 * {@inheritDoc}
 */
@Override
public String getSchemaName(String oid) throws LdapException {
    if (!Oid.isOid(oid)) {
        String msg = I18n.err(I18n.ERR_13733_ARG_NOT_NUMERIC_OID);
        LOG.warn(msg);
        throw new LdapException(msg);
    }
    SchemaObject schemaObject = byName.get(oid);
    if (schemaObject != null) {
        return schemaObject.getSchemaName();
    }
    String msg = I18n.err(I18n.ERR_13734_OID_NOT_FOUND, oid);
    LOG.warn(msg);
    throw new LdapException(msg);
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) LoadableSchemaObject(org.apache.directory.api.ldap.model.schema.LoadableSchemaObject) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 94 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class DnComparator method compare.

/**
 * {@inheritDoc}
 */
@Override
public int compare(Object obj0, Object obj1) {
    if ((obj0 instanceof String) && (obj1 instanceof String)) {
        return compare((String) obj0, (String) obj1);
    }
    Dn dn0 = null;
    Dn dn1 = null;
    try {
        dn0 = getDn(obj0);
        dn1 = getDn(obj1);
    } catch (LdapException e) {
        // -- what do we do here ?
        return -1;
    }
    int dn0Size = dn0.getRdns().size();
    int dn1Size = dn1.getRdns().size();
    // when both DNs are equal checking isAncestorOf() returns true
    if (dn0.equals(dn1)) {
        return 0;
    } else if (dn0Size > dn1Size) {
        return -1;
    } else if (dn1Size > dn0Size) {
        return 1;
    }
    for (int i = dn0Size - 1; i >= 0; i--) {
        int comp = dn0.getRdn(i).compareTo(dn1.getRdn(i));
        if (comp != 0) {
            return comp;
        }
    }
    return 0;
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 95 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class AddAttributeType method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchResultEntryDecorator> container) throws DecoderException {
    SearchResultEntryDecorator searchResultEntry = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the type
    if (tlv.getLength() == 0) {
        // The type can't be null
        String msg = I18n.err(I18n.ERR_04081);
        LOG.error(msg);
        throw new DecoderException(msg);
    } else {
        try {
            searchResultEntry.addAttribute(tlv.getValue().getData());
        } catch (LdapException ine) {
            String type = Strings.utf8ToString(tlv.getValue().getData());
            // This is for the client side. We will never decode LdapResult on the server
            String msg = "The Attribute type " + type + "is invalid : " + ine.getMessage();
            LOG.error("{} : {}", msg, ine.getMessage());
            throw new DecoderException(msg, ine);
        }
    }
    if (IS_DEBUG) {
        String type = Strings.utf8ToString(tlv.getValue().getData());
        LOG.debug("Attribute type : {}", type);
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) SearchResultEntryDecorator(org.apache.directory.api.ldap.codec.decorators.SearchResultEntryDecorator) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Aggregations

LdapException (org.apache.directory.api.ldap.model.exception.LdapException)361 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)161 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)111 ArrayList (java.util.ArrayList)94 FinderException (org.apache.directory.fortress.core.FinderException)73 Modification (org.apache.directory.api.ldap.model.entry.Modification)70 Entry (org.apache.directory.api.ldap.model.entry.Entry)68 IOException (java.io.IOException)57 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)57 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)53 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)51 UpdateException (org.apache.directory.fortress.core.UpdateException)41 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)35 Dn (org.apache.directory.api.ldap.model.name.Dn)34 SEPASecurityException (it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException)29 LdapAuthenticationException (org.apache.directory.api.ldap.model.exception.LdapAuthenticationException)25 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)25 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)23 DecoderException (org.apache.directory.api.asn1.DecoderException)22 LdapNoPermissionException (org.apache.directory.api.ldap.model.exception.LdapNoPermissionException)22