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);
}
}
Aggregations