Search in sources :

Example 6 with LdapProtocolErrorException

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

the class SchemaManagerDelTest method testDeleteExistingNormalizerUsedByMatchingRule.

@Test
public void testDeleteExistingNormalizerUsedByMatchingRule() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int nrSize = schemaManager.getNormalizerRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    Normalizer nr = schemaManager.lookupNormalizerRegistry("2.5.13.0");
    // shouldn't be deleted cause there is a MR associated with it
    assertFalse(schemaManager.delete(nr));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    assertNotNull(schemaManager.lookupNormalizerRegistry("2.5.13.0"));
    assertEquals(nrSize, schemaManager.getNormalizerRegistry().size());
    assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Also used : LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) BooleanNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.BooleanNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 7 with LdapProtocolErrorException

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

the class SchemaManagerDelTest method testDeleteExistingNormalizerUsedByRemovedMatchingRule.

/**
 * Check that a Normalizer which has been used by a deleted MatchingRule
 * can be removed
 */
@Test
public void testDeleteExistingNormalizerUsedByRemovedMatchingRule() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int nrSize = schemaManager.getNormalizerRegistry().size();
    int mrrSize = schemaManager.getMatchingRuleRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    String OID = "2.5.13.33";
    // Check that the MR and N are present
    assertTrue(isMatchingRulePresent(schemaManager, OID));
    assertTrue(isNormalizerPresent(schemaManager, OID));
    // Now try to remove the N
    Normalizer normalizer = schemaManager.lookupNormalizerRegistry(OID);
    // shouldn't be deleted cause there is a MR associated with it
    assertFalse(schemaManager.delete(normalizer));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    // Now delete the using MR : it should be OK
    MatchingRule mr = new MatchingRule(OID);
    assertTrue(schemaManager.delete(mr));
    assertEquals(mrrSize - 1, schemaManager.getMatchingRuleRegistry().size());
    assertEquals(goidSize - 1, schemaManager.getGlobalOidRegistry().size());
    assertFalse(isMatchingRulePresent(schemaManager, OID));
    // and try to delete the normalizer again
    assertTrue(schemaManager.delete(normalizer));
    assertFalse(isNormalizerPresent(schemaManager, OID));
    assertEquals(nrSize - 1, schemaManager.getNormalizerRegistry().size());
    assertEquals(goidSize - 1, schemaManager.getGlobalOidRegistry().size());
}
Also used : LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) BooleanNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.BooleanNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) MatchingRule(org.apache.directory.api.ldap.model.schema.MatchingRule) Test(org.junit.Test)

Example 8 with LdapProtocolErrorException

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

the class WrappedPartialResultException method wrap.

/**
 * Wraps a LDAP exception into a NaingException
 *
 * @param t The original exception
 * @throws NamingException The wrapping JNDI exception
 */
public static void wrap(Throwable t) throws NamingException {
    if (t instanceof NamingException) {
        throw (NamingException) t;
    }
    NamingException ne;
    if ((t instanceof LdapAffectMultipleDsaException) || (t instanceof LdapAliasDereferencingException) || (t instanceof LdapLoopDetectedException) || (t instanceof LdapAliasException) || (t instanceof LdapOperationErrorException) || (t instanceof LdapOtherException)) {
        ne = new NamingException(t.getLocalizedMessage());
    } else if (t instanceof LdapAttributeInUseException) {
        ne = new AttributeInUseException(t.getLocalizedMessage());
    } else if (t instanceof LdapAuthenticationException) {
        ne = new AuthenticationException(t.getLocalizedMessage());
    } else if (t instanceof LdapAuthenticationNotSupportedException) {
        ne = new AuthenticationNotSupportedException(t.getLocalizedMessage());
    } else if (t instanceof LdapContextNotEmptyException) {
        ne = new ContextNotEmptyException(t.getLocalizedMessage());
    } else if (t instanceof LdapEntryAlreadyExistsException) {
        ne = new NameAlreadyBoundException(t.getLocalizedMessage());
    } else if (t instanceof LdapInvalidAttributeTypeException) {
        ne = new InvalidAttributeIdentifierException(t.getLocalizedMessage());
    } else if (t instanceof LdapInvalidAttributeValueException) {
        ne = new InvalidAttributeValueException(t.getLocalizedMessage());
    } else if (t instanceof LdapInvalidDnException) {
        ne = new InvalidNameException(t.getLocalizedMessage());
    } else if (t instanceof LdapInvalidSearchFilterException) {
        ne = new InvalidSearchFilterException(t.getLocalizedMessage());
    } else if (t instanceof LdapNoPermissionException) {
        ne = new NoPermissionException(t.getLocalizedMessage());
    } else if (t instanceof LdapNoSuchAttributeException) {
        ne = new NoSuchAttributeException(t.getLocalizedMessage());
    } else if (t instanceof LdapNoSuchObjectException) {
        ne = new NameNotFoundException(t.getLocalizedMessage());
    } else if (t instanceof LdapProtocolErrorException) {
        ne = new CommunicationException(t.getLocalizedMessage());
    } else if (t instanceof LdapReferralException) {
        ne = new WrappedReferralException((LdapReferralException) t);
    } else if (t instanceof LdapPartialResultException) {
        ne = new WrappedPartialResultException((LdapPartialResultException) t);
    } else if (t instanceof LdapSchemaViolationException) {
        ne = new SchemaViolationException(t.getLocalizedMessage());
    } else if (t instanceof LdapServiceUnavailableException) {
        ne = new ServiceUnavailableException(t.getLocalizedMessage());
    } else if (t instanceof LdapTimeLimitExceededException) {
        ne = new TimeLimitExceededException(t.getLocalizedMessage());
    } else if (t instanceof LdapUnwillingToPerformException) {
        ne = new OperationNotSupportedException(t.getLocalizedMessage());
    } else {
        ne = new NamingException(t.getLocalizedMessage());
    }
    ne.setRootCause(t);
    throw ne;
}
Also used : LdapEntryAlreadyExistsException(org.apache.directory.api.ldap.model.exception.LdapEntryAlreadyExistsException) LdapOperationErrorException(org.apache.directory.api.ldap.model.exception.LdapOperationErrorException) LdapAttributeInUseException(org.apache.directory.api.ldap.model.exception.LdapAttributeInUseException) AuthenticationException(javax.naming.AuthenticationException) LdapAuthenticationException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationException) LdapAuthenticationNotSupportedException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationNotSupportedException) AuthenticationNotSupportedException(javax.naming.AuthenticationNotSupportedException) LdapServiceUnavailableException(org.apache.directory.api.ldap.model.exception.LdapServiceUnavailableException) LdapInvalidAttributeTypeException(org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException) LdapInvalidAttributeValueException(org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException) LdapServiceUnavailableException(org.apache.directory.api.ldap.model.exception.LdapServiceUnavailableException) ServiceUnavailableException(javax.naming.ServiceUnavailableException) LdapTimeLimitExceededException(org.apache.directory.api.ldap.model.exception.LdapTimeLimitExceededException) LdapAliasException(org.apache.directory.api.ldap.model.exception.LdapAliasException) LdapNoSuchObjectException(org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException) LdapPartialResultException(org.apache.directory.api.ldap.model.exception.LdapPartialResultException) LdapSchemaViolationException(org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException) LdapAuthenticationNotSupportedException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationNotSupportedException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) LdapLoopDetectedException(org.apache.directory.api.ldap.model.exception.LdapLoopDetectedException) InvalidNameException(javax.naming.InvalidNameException) LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) LdapReferralException(org.apache.directory.api.ldap.model.exception.LdapReferralException) NamingException(javax.naming.NamingException) SchemaViolationException(javax.naming.directory.SchemaViolationException) LdapSchemaViolationException(org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException) LdapNoPermissionException(org.apache.directory.api.ldap.model.exception.LdapNoPermissionException) LdapOtherException(org.apache.directory.api.ldap.model.exception.LdapOtherException) LdapInvalidDnException(org.apache.directory.api.ldap.model.exception.LdapInvalidDnException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) LdapAliasDereferencingException(org.apache.directory.api.ldap.model.exception.LdapAliasDereferencingException) InvalidAttributeIdentifierException(javax.naming.directory.InvalidAttributeIdentifierException) CommunicationException(javax.naming.CommunicationException) InvalidSearchFilterException(javax.naming.directory.InvalidSearchFilterException) LdapInvalidSearchFilterException(org.apache.directory.api.ldap.model.exception.LdapInvalidSearchFilterException) NameNotFoundException(javax.naming.NameNotFoundException) LdapUnwillingToPerformException(org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException) LdapAffectMultipleDsaException(org.apache.directory.api.ldap.model.exception.LdapAffectMultipleDsaException) LdapInvalidAttributeValueException(org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException) InvalidAttributeValueException(javax.naming.directory.InvalidAttributeValueException) LdapContextNotEmptyException(org.apache.directory.api.ldap.model.exception.LdapContextNotEmptyException) NoSuchAttributeException(javax.naming.directory.NoSuchAttributeException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException) LdapAuthenticationException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationException) ContextNotEmptyException(javax.naming.ContextNotEmptyException) LdapContextNotEmptyException(org.apache.directory.api.ldap.model.exception.LdapContextNotEmptyException) NoPermissionException(javax.naming.NoPermissionException) LdapNoPermissionException(org.apache.directory.api.ldap.model.exception.LdapNoPermissionException) LdapTimeLimitExceededException(org.apache.directory.api.ldap.model.exception.LdapTimeLimitExceededException) TimeLimitExceededException(javax.naming.TimeLimitExceededException) AttributeInUseException(javax.naming.directory.AttributeInUseException) LdapAttributeInUseException(org.apache.directory.api.ldap.model.exception.LdapAttributeInUseException) LdapInvalidSearchFilterException(org.apache.directory.api.ldap.model.exception.LdapInvalidSearchFilterException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 9 with LdapProtocolErrorException

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

the class SchemaManagerDelTest method testDeleteExistingSyntaxCheckerUsedByRemovedSyntax.

/**
 * Check that a SyntaxChecker which has been used by a deleted Syntax
 * can be removed
 */
@Test
public void testDeleteExistingSyntaxCheckerUsedByRemovedSyntax() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int scrSize = schemaManager.getSyntaxCheckerRegistry().size();
    int srSize = schemaManager.getLdapSyntaxRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    String OID = "1.3.6.1.4.1.1466.115.121.1.33";
    // Check that the S and SC are present
    assertTrue(isSyntaxCheckerPresent(schemaManager, OID));
    assertTrue(isSyntaxPresent(schemaManager, OID));
    // Now try to remove the SC
    SyntaxChecker sc = schemaManager.lookupSyntaxCheckerRegistry(OID);
    // shouldn't be deleted cause there is a S associated with it
    assertFalse(schemaManager.delete(sc));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    // Now delete the using S : it should be OK
    LdapSyntax syntax = new LdapSyntax(OID);
    assertTrue(schemaManager.delete(syntax));
    assertEquals(srSize - 1, schemaManager.getLdapSyntaxRegistry().size());
    assertEquals(goidSize - 1, schemaManager.getGlobalOidRegistry().size());
    assertFalse(isSyntaxPresent(schemaManager, OID));
    // and try to delete the SC again
    assertTrue(schemaManager.delete(sc));
    assertFalse(isSyntaxCheckerPresent(schemaManager, OID));
    assertEquals(scrSize - 1, schemaManager.getSyntaxCheckerRegistry().size());
    assertEquals(goidSize - 1, schemaManager.getGlobalOidRegistry().size());
}
Also used : BooleanSyntaxChecker(org.apache.directory.api.ldap.model.schema.syntaxCheckers.BooleanSyntaxChecker) SyntaxChecker(org.apache.directory.api.ldap.model.schema.SyntaxChecker) LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) LdapSyntax(org.apache.directory.api.ldap.model.schema.LdapSyntax) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 10 with LdapProtocolErrorException

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

the class SchemaManagerDelTest method testDeleteExistingSyntaxCheckerUsedBySyntax.

@Test
public void testDeleteExistingSyntaxCheckerUsedBySyntax() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int scrSize = schemaManager.getSyntaxCheckerRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    SyntaxChecker sc = schemaManager.lookupSyntaxCheckerRegistry("1.3.6.1.4.1.1466.115.121.1.1");
    // FIXME should return false but is returning true
    assertFalse(schemaManager.delete(sc));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    assertEquals(scrSize, schemaManager.getSyntaxCheckerRegistry().size());
    assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Also used : BooleanSyntaxChecker(org.apache.directory.api.ldap.model.schema.syntaxCheckers.BooleanSyntaxChecker) SyntaxChecker(org.apache.directory.api.ldap.model.schema.SyntaxChecker) LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Aggregations

LdapProtocolErrorException (org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException)14 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)10 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)10 Test (org.junit.Test)10 MatchingRule (org.apache.directory.api.ldap.model.schema.MatchingRule)4 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)3 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)3 LdapOtherException (org.apache.directory.api.ldap.model.exception.LdapOtherException)2 LoadableSchemaObject (org.apache.directory.api.ldap.model.schema.LoadableSchemaObject)2 MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)2 Normalizer (org.apache.directory.api.ldap.model.schema.Normalizer)2 SchemaObject (org.apache.directory.api.ldap.model.schema.SchemaObject)2 SyntaxChecker (org.apache.directory.api.ldap.model.schema.SyntaxChecker)2 BooleanNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.BooleanNormalizer)2 Registries (org.apache.directory.api.ldap.model.schema.registries.Registries)2 BooleanSyntaxChecker (org.apache.directory.api.ldap.model.schema.syntaxCheckers.BooleanSyntaxChecker)2 AuthenticationException (javax.naming.AuthenticationException)1 AuthenticationNotSupportedException (javax.naming.AuthenticationNotSupportedException)1 CommunicationException (javax.naming.CommunicationException)1 ContextNotEmptyException (javax.naming.ContextNotEmptyException)1