Search in sources :

Example 86 with LdapException

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

the class LdapSyntaxHelper method addToRegistries.

/**
 * Inject the LdapSyntax into the registries, updating the references to
 * other SchemaObject
 *
 * @param ldapSyntax The LdapSyntax to add to the Registries
 * @param errors The errors we got while adding the LdapSyntax to the Registries
 * @param registries The Registries
 * @throws LdapException If the addition failed
 */
public static void addToRegistries(LdapSyntax ldapSyntax, List<Throwable> errors, Registries registries) throws LdapException {
    if (registries != null) {
        try {
            ldapSyntax.unlock();
            SyntaxChecker syntaxChecker = null;
            try {
                // Gets the associated SyntaxChecker
                syntaxChecker = registries.getSyntaxCheckerRegistry().lookup(ldapSyntax.getOid());
            } catch (LdapException ne) {
                // No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker
                syntaxChecker = OctetStringSyntaxChecker.builder().setOid(ldapSyntax.getOid()).build();
            }
            // S -> SC
            if (syntaxChecker != null) {
                registries.addReference(ldapSyntax, syntaxChecker);
                ldapSyntax.setSyntaxChecker(syntaxChecker);
            }
        } finally {
            ldapSyntax.lock();
        }
    }
}
Also used : SyntaxChecker(org.apache.directory.api.ldap.model.schema.SyntaxChecker) OctetStringSyntaxChecker(org.apache.directory.api.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 87 with LdapException

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

the class MatchingRuleHelper method addToRegistries.

/**
 * Inject the MatchingRule into the Registries, updating the references to
 * other SchemaObject
 *
 * @param matchingRule The MatchingRule to add to the Registries
 * @param errors The errors we got while adding the MatchingRule to the registries
 * @param registries The Registries
 * @throws LdapException If the addition failed
 */
@SuppressWarnings("rawtypes")
public static void addToRegistries(MutableMatchingRule matchingRule, List<Throwable> errors, Registries registries) throws LdapException {
    if (registries != null) {
        try {
            matchingRule.unlock();
            LdapComparator<?> ldapComparator = null;
            Normalizer normalizer = null;
            LdapSyntax ldapSyntax = null;
            try {
                // Gets the associated Comparator
                ldapComparator = registries.getComparatorRegistry().lookup(matchingRule.getOid());
            } catch (LdapException ne) {
                // Default to a catch all comparator
                ldapComparator = new ComparableComparator(matchingRule.getOid());
            }
            try {
                // Gets the associated Normalizer
                normalizer = registries.getNormalizerRegistry().lookup(matchingRule.getOid());
            } catch (LdapException ne) {
                // Default to the NoOp normalizer
                normalizer = new NoOpNormalizer(matchingRule.getOid());
            }
            try {
                // Get the associated LdapSyntax
                ldapSyntax = registries.getLdapSyntaxRegistry().lookup(matchingRule.getSyntaxOid());
            } catch (LdapException ne) {
                // The Syntax is a mandatory element, it must exist.
                String msg = I18n.err(I18n.ERR_13765_MR_MUST_REFER_EXISTING_SYNTAX);
                LdapSchemaException ldapSchemaException = new LdapSchemaException(LdapSchemaExceptionCodes.MR_NONEXISTENT_SYNTAX, msg, ne);
                ldapSchemaException.setSourceObject(matchingRule);
                ldapSchemaException.setRelatedId(matchingRule.getSyntaxOid());
                errors.add(ldapSchemaException);
                LOG.info(msg);
            }
            /**
             * Add the MR references (using and usedBy) :
             * MR -> C
             * MR -> N
             * MR -> S
             */
            if (ldapComparator != null) {
                registries.addReference(matchingRule, ldapComparator);
                matchingRule.setLdapComparator(ldapComparator);
            }
            if (normalizer != null) {
                registries.addReference(matchingRule, normalizer);
                matchingRule.setNormalizer(normalizer);
            }
            if (ldapSyntax != null) {
                registries.addReference(matchingRule, ldapSyntax);
                matchingRule.setSyntax(ldapSyntax);
            }
        } finally {
            matchingRule.lock();
        }
    }
}
Also used : NoOpNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.NoOpNormalizer) NoOpNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.NoOpNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) LdapSyntax(org.apache.directory.api.ldap.model.schema.LdapSyntax) LdapSchemaException(org.apache.directory.api.ldap.model.exception.LdapSchemaException) ComparableComparator(org.apache.directory.api.ldap.model.schema.comparators.ComparableComparator) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 88 with LdapException

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

the class DefaultAttributeTypeRegistry method hasDescendants.

/**
 * {@inheritDoc}
 */
@Override
public boolean hasDescendants(String ancestorId) throws LdapException {
    try {
        String oid = getOidByName(ancestorId);
        Set<AttributeType> descendants = oidToDescendantSet.get(oid);
        return (descendants != null) && !descendants.isEmpty();
    } catch (LdapException ne) {
        throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
    }
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 89 with LdapException

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

the class DefaultAttributeTypeRegistry method unregister.

/**
 * {@inheritDoc}
 */
@Override
public AttributeType unregister(String numericOid) throws LdapException {
    try {
        AttributeType removed = super.unregister(numericOid);
        removeMappingFor(removed);
        // Deleting an AT which might be used as a superior means we have
        // to recursively update the descendant map. We also have to remove
        // the at.oid -> descendant relation
        oidToDescendantSet.remove(numericOid);
        // Now recurse if needed
        unregisterDescendants(removed, removed.getSuperior());
        return removed;
    } catch (LdapException ne) {
        throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
    }
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 90 with LdapException

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

the class DefaultDitStructureRuleRegistry method lookup.

/**
 * {@inheritDoc}
 */
@Override
public DitStructureRule lookup(int ruleId) throws LdapException {
    DitStructureRule ditStructureRule = byRuleId.get(ruleId);
    if (ditStructureRule == null) {
        String msg = I18n.err(I18n.ERR_13731_DIT_STRUCTURE_RULE_DOES_NOT_EXIST, ruleId);
        LOG.debug(msg);
        throw new LdapException(msg);
    }
    if (DEBUG) {
        LOG.debug("Found {} with ruleId: {}", ditStructureRule, ruleId);
    }
    return ditStructureRule;
}
Also used : DitStructureRule(org.apache.directory.api.ldap.model.schema.DitStructureRule) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

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