Search in sources :

Example 21 with LdapUnwillingToPerformException

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

the class SchemaEntityFactory method getSyntaxChecker.

/**
 * {@inheritDoc}
 */
@Override
public SyntaxChecker getSyntaxChecker(SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName) throws LdapException {
    checkEntry(entry, SchemaConstants.SYNTAX_CHECKER);
    // The SyntaxChecker OID
    String oid = getOid(entry, SchemaConstants.SYNTAX_CHECKER, schemaManager.isStrict());
    // Get the schema
    if (!schemaManager.isSchemaLoaded(schemaName)) {
        // The schema is not loaded. We can't create the requested Normalizer
        String msg = I18n.err(I18n.ERR_16019_CANNOT_ADD_SC, entry.getDn().getName(), schemaName);
        LOG.warn(msg);
        throw new LdapUnwillingToPerformException(ResultCodeEnum.UNWILLING_TO_PERFORM, msg);
    }
    Schema schema = getSchema(schemaName, targetRegistries);
    if (schema == null) {
        // The schema is disabled. We still have to update the backend
        String msg = I18n.err(I18n.ERR_16020_CANNOT_ADD_SC_IN_REGISTRY, entry.getDn().getName(), schemaName);
        LOG.info(msg);
        schema = schemaManager.getLoadedSchema(schemaName);
    }
    // The FQCN
    String className = getFqcn(entry, SchemaConstants.SYNTAX_CHECKER);
    // The ByteCode
    Attribute byteCode = entry.get(MetaSchemaConstants.M_BYTECODE_AT);
    try {
        // Class load the syntaxChecker
        SyntaxChecker syntaxChecker = classLoadSyntaxChecker(schemaManager, oid, className, byteCode);
        // Update the common fields
        setSchemaObjectProperties(syntaxChecker, entry, schema);
        // return the resulting syntaxChecker
        return syntaxChecker;
    } catch (Exception e) {
        throw new LdapUnwillingToPerformException(ResultCodeEnum.UNWILLING_TO_PERFORM, e.getMessage(), e);
    }
}
Also used : SyntaxChecker(org.apache.directory.api.ldap.model.schema.SyntaxChecker) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) Attribute(org.apache.directory.api.ldap.model.entry.Attribute) LdapUnwillingToPerformException(org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException) DefaultSchema(org.apache.directory.api.ldap.model.schema.registries.DefaultSchema) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) LdapInvalidAttributeValueException(org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException) InvocationTargetException(java.lang.reflect.InvocationTargetException) LdapUnwillingToPerformException(org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException) LdapSchemaException(org.apache.directory.api.ldap.model.exception.LdapSchemaException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Aggregations

LdapUnwillingToPerformException (org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException)21 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)11 DefaultSchema (org.apache.directory.api.ldap.model.schema.registries.DefaultSchema)10 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)9 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)9 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)5 LdapInvalidAttributeValueException (org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException)4 LoadableSchemaObject (org.apache.directory.api.ldap.model.schema.LoadableSchemaObject)4 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)4 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)4 Test (org.junit.Test)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 LdapSchemaException (org.apache.directory.api.ldap.model.exception.LdapSchemaException)3 Normalizer (org.apache.directory.api.ldap.model.schema.Normalizer)3 SyntaxChecker (org.apache.directory.api.ldap.model.schema.SyntaxChecker)3 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)2 MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)2 AuthenticationException (javax.naming.AuthenticationException)1 AuthenticationNotSupportedException (javax.naming.AuthenticationNotSupportedException)1 CommunicationException (javax.naming.CommunicationException)1