use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class LdifSchemaLoader method loadNameForms.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadNameForms(Schema... schemas) throws LdapException, IOException {
List<Entry> nameFormList = new ArrayList<>();
if (schemas == null) {
return nameFormList;
}
for (Schema schema : schemas) {
File nameFormsDirectory = new File(getSchemaDirectory(schema), SchemaConstants.NAME_FORMS_PATH);
if (!nameFormsDirectory.exists()) {
return nameFormList;
}
File[] nameFormFiles = nameFormsDirectory.listFiles(ldifFilter);
if (nameFormFiles != null) {
for (File ldifFile : nameFormFiles) {
LdifReader reader = new LdifReader(ldifFile);
LdifEntry entry = reader.next();
reader.close();
nameFormList.add(entry.getEntry());
}
}
}
return nameFormList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class LdifSchemaLoader method loadSyntaxes.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadSyntaxes(Schema... schemas) throws LdapException, IOException {
List<Entry> syntaxList = new ArrayList<>();
if (schemas == null) {
return syntaxList;
}
for (Schema schema : schemas) {
File syntaxesDirectory = new File(getSchemaDirectory(schema), SchemaConstants.SYNTAXES_PATH);
if (!syntaxesDirectory.exists()) {
return syntaxList;
}
File[] syntaxFiles = syntaxesDirectory.listFiles(ldifFilter);
if (syntaxFiles != null) {
for (File ldifFile : syntaxFiles) {
LdifReader reader = new LdifReader(ldifFile);
LdifEntry entry = reader.next();
reader.close();
syntaxList.add(entry.getEntry());
}
}
}
return syntaxList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class SchemaEntityFactory method getObjectClass.
/**
* {@inheritDoc}
*/
@Override
public ObjectClass getObjectClass(SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName) throws LdapException {
checkEntry(entry, SchemaConstants.OBJECT_CLASS);
// The ObjectClass OID
String oid = getOid(entry, SchemaConstants.OBJECT_CLASS, schemaManager.isStrict());
// Get the schema
if (!schemaManager.isSchemaLoaded(schemaName)) {
// The schema is not loaded. We can't create the requested ObjectClass
String msg = I18n.err(I18n.ERR_16030_CANNOT_ADD_OC, 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_16031_CANNOT_ADD_OC_IN_REGISTRY, entry.getDn().getName(), schemaName);
LOG.info(msg);
schema = schemaManager.getLoadedSchema(schemaName);
}
// Create the ObjectClass instance
MutableObjectClass oc = new MutableObjectClass(oid);
// The Sup field
Attribute mSuperiors = entry.get(MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT);
if (mSuperiors != null) {
oc.setSuperiorOids(getStrings(mSuperiors));
}
// The May field
Attribute mMay = entry.get(MetaSchemaConstants.M_MAY_AT);
if (mMay != null) {
oc.setMayAttributeTypeOids(getStrings(mMay));
}
// The Must field
Attribute mMust = entry.get(MetaSchemaConstants.M_MUST_AT);
if (mMust != null) {
oc.setMustAttributeTypeOids(getStrings(mMust));
}
// The objectClassType field
Attribute mTypeObjectClass = entry.get(MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT);
if (mTypeObjectClass != null) {
String type = mTypeObjectClass.getString();
oc.setType(ObjectClassTypeEnum.getClassType(type));
}
// Common properties
setSchemaObjectProperties(oc, entry, schema);
return oc;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadNameForms.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadNameForms(Schema... schemas) throws LdapException, IOException {
List<Entry> nameFormEntries = new ArrayList<>();
if (schemas == null) {
return nameFormEntries;
}
AttributesFactory factory = new AttributesFactory();
for (Schema schema : schemas) {
Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
SchemaObject schemaObject = schemaObjectWrapper.get();
if (schemaObject instanceof NameForm) {
NameForm nameForm = (NameForm) schemaObject;
Entry nameFormEntry = factory.convert(nameForm, schema, null);
nameFormEntries.add(nameFormEntry);
}
}
}
return nameFormEntries;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadMatchingRules.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadMatchingRules(Schema... schemas) throws LdapException, IOException {
List<Entry> matchingRuleEntries = new ArrayList<>();
if (schemas == null) {
return matchingRuleEntries;
}
AttributesFactory factory = new AttributesFactory();
for (Schema schema : schemas) {
Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
SchemaObject schemaObject = schemaObjectWrapper.get();
if (schemaObject instanceof MatchingRule) {
MatchingRule matchingRule = (MatchingRule) schemaObject;
Entry matchingRuleEntry = factory.convert(matchingRule, schema, null);
matchingRuleEntries.add(matchingRuleEntry);
}
}
}
return matchingRuleEntries;
}
Aggregations