use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class SchemaEntityFactory method getLdapComparator.
/**
* {@inheritDoc}
*/
@Override
public LdapComparator<?> getLdapComparator(SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName) throws LdapException {
checkEntry(entry, SchemaConstants.COMPARATOR);
// The Comparator OID
String oid = getOid(entry, SchemaConstants.COMPARATOR, schemaManager.isStrict());
// Get the schema
if (!schemaManager.isSchemaLoaded(schemaName)) {
// The schema is not loaded. We can't create the requested Comparator
String msg = I18n.err(I18n.ERR_16022_CANNOT_ADD_CMP, 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_16023_CANNOT_ADD_CMP_IN_REGISTRY, entry.getDn().getName(), schemaName);
LOG.info(msg);
schema = schemaManager.getLoadedSchema(schemaName);
}
// The FQCN
String fqcn = getFqcn(entry, SchemaConstants.COMPARATOR);
// The ByteCode
Attribute byteCode = entry.get(MetaSchemaConstants.M_BYTECODE_AT);
try {
// Class load the comparator
LdapComparator<?> comparator = classLoadComparator(schemaManager, oid, fqcn, byteCode);
// Update the common fields
setSchemaObjectProperties(comparator, entry, schema);
// return the resulting comparator
return comparator;
} catch (Exception e) {
throw new LdapUnwillingToPerformException(ResultCodeEnum.UNWILLING_TO_PERFORM, e.getMessage(), e);
}
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class SchemaEntityFactory method getNormalizer.
/**
* {@inheritDoc}
*/
@Override
public Normalizer getNormalizer(SchemaManager schemaManager, NormalizerDescription normalizerDescription, Registries targetRegistries, String schemaName) throws LdapException {
checkDescription(normalizerDescription, SchemaConstants.NORMALIZER);
// The Comparator OID
String oid = getOid(normalizerDescription, SchemaConstants.NORMALIZER);
// Get the schema
Schema schema = getSchema(schemaName, targetRegistries);
if (schema == null) {
// The schema is not loaded. We can't create the requested Normalizer
String msg = I18n.err(I18n.ERR_16024_CANNOT_ADD_NORMALIZER, normalizerDescription.getName(), schemaName);
LOG.warn(msg);
throw new LdapUnwillingToPerformException(ResultCodeEnum.UNWILLING_TO_PERFORM, msg);
}
// The FQCN
String fqcn = getFqcn(normalizerDescription, SchemaConstants.NORMALIZER);
// get the byteCode
Attribute byteCode = getByteCode(normalizerDescription, SchemaConstants.NORMALIZER);
// Class load the normalizer
Normalizer normalizer = classLoadNormalizer(schemaManager, oid, fqcn, byteCode);
// Update the common fields
setSchemaObjectProperties(normalizer, normalizerDescription, schema);
return normalizer;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class SchemaEntityFactory method getSyntax.
/**
* {@inheritDoc}
* @throws LdapInvalidAttributeValueException If the Syntax does not exist
* @throws LdapUnwillingToPerformException If the schema is not loaded
*/
@Override
public LdapSyntax getSyntax(SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName) throws LdapInvalidAttributeValueException, LdapUnwillingToPerformException {
checkEntry(entry, SchemaConstants.SYNTAX);
// The Syntax OID
String oid = getOid(entry, SchemaConstants.SYNTAX, schemaManager.isStrict());
// Get the schema
if (!schemaManager.isSchemaLoaded(schemaName)) {
// The schema is not loaded. We can't create the requested Syntax
String msg = I18n.err(I18n.ERR_16026_CANNOT_ADD_SYNTAX, 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_16027_CANNOT_ADD_SYNTAX_IN_REGISTRY, entry.getDn().getName(), schemaName);
LOG.info(msg);
schema = schemaManager.getLoadedSchema(schemaName);
}
// Create the new LdapSyntax instance
LdapSyntax syntax = new LdapSyntax(oid);
// Common properties
setSchemaObjectProperties(syntax, entry, schema);
return syntax;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class SchemaEntityFactory method getNormalizer.
/**
* {@inheritDoc}
*/
@Override
public Normalizer getNormalizer(SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName) throws LdapException {
checkEntry(entry, SchemaConstants.NORMALIZER);
// The Normalizer OID
String oid = getOid(entry, SchemaConstants.NORMALIZER, 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_16024_CANNOT_ADD_NORMALIZER, 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_16025_CANNOT_ADD_NORMALIZER_IN_REGISTRY, entry.getDn().getName(), schemaName);
LOG.info(msg);
schema = schemaManager.getLoadedSchema(schemaName);
}
// The FQCN
String className = getFqcn(entry, SchemaConstants.NORMALIZER);
// The ByteCode
Attribute byteCode = entry.get(MetaSchemaConstants.M_BYTECODE_AT);
try {
// Class load the Normalizer
Normalizer normalizer = classLoadNormalizer(schemaManager, oid, className, byteCode);
// Update the common fields
setSchemaObjectProperties(normalizer, entry, schema);
// return the resulting Normalizer
return normalizer;
} catch (Exception e) {
throw new LdapUnwillingToPerformException(ResultCodeEnum.UNWILLING_TO_PERFORM, e.getMessage(), e);
}
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class SchemaEntityFactory method getLdapComparator.
/**
* {@inheritDoc}
*/
@Override
public LdapComparator<?> getLdapComparator(SchemaManager schemaManager, LdapComparatorDescription comparatorDescription, Registries targetRegistries, String schemaName) throws LdapException {
checkDescription(comparatorDescription, SchemaConstants.COMPARATOR);
// The Comparator OID
String oid = getOid(comparatorDescription, SchemaConstants.COMPARATOR);
// Get the schema
Schema schema = getSchema(schemaName, targetRegistries);
if (schema == null) {
// The schema is not loaded. We can't create the requested Comparator
String msg = I18n.err(I18n.ERR_16022_CANNOT_ADD_CMP, comparatorDescription.getName(), schemaName);
LOG.warn(msg);
throw new LdapUnwillingToPerformException(ResultCodeEnum.UNWILLING_TO_PERFORM, msg);
}
// The FQCN
String fqcn = getFqcn(comparatorDescription, SchemaConstants.COMPARATOR);
// get the byteCode
Attribute byteCode = getByteCode(comparatorDescription, SchemaConstants.COMPARATOR);
// Class load the comparator
LdapComparator<?> comparator = classLoadComparator(schemaManager, oid, fqcn, byteCode);
// Update the common fields
setSchemaObjectProperties(comparator, comparatorDescription, schema);
return comparator;
}
Aggregations