use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class LdifSchemaLoader method loadDitContentRules.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadDitContentRules(Schema... schemas) throws LdapException, IOException {
List<Entry> ditContentRuleList = new ArrayList<>();
if (schemas == null) {
return ditContentRuleList;
}
for (Schema schema : schemas) {
File ditContentRulesDirectory = new File(getSchemaDirectory(schema), SchemaConstants.DIT_CONTENT_RULES_PATH);
if (!ditContentRulesDirectory.exists()) {
return ditContentRuleList;
}
File[] ditContentRuleFiles = ditContentRulesDirectory.listFiles(ldifFilter);
if (ditContentRuleFiles != null) {
for (File ldifFile : ditContentRuleFiles) {
LdifReader reader = new LdifReader(ldifFile);
LdifEntry entry = reader.next();
reader.close();
ditContentRuleList.add(entry.getEntry());
}
}
}
return ditContentRuleList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class LdifSchemaLoader method initializeSchemas.
/**
* Scans for LDIF files just describing the various schema contained in
* the schema repository.
*
* @throws LdapException
*/
private void initializeSchemas() throws LdapException, IOException {
if (IS_DEBUG) {
LOG.debug(I18n.msg(I18n.MSG_16006_INITIALIZING_SCHEMA));
}
File schemaDirectory = new File(baseDirectory, SchemaConstants.OU_SCHEMA);
String[] ldifFiles = schemaDirectory.list(ldifFilter);
if (ldifFiles != null) {
for (String ldifFile : ldifFiles) {
File file = new File(schemaDirectory, ldifFile);
try (LdifReader reader = new LdifReader(file)) {
LdifEntry entry = reader.next();
Schema schema = getSchema(entry.getEntry());
if (schema == null) {
// The entry was not a schema, skip it
continue;
}
schemaMap.put(schema.getSchemaName(), schema);
if (IS_DEBUG) {
LOG.debug(I18n.msg(I18n.MSG_16007_SCHEMA_INITIALIZED, schema));
}
} catch (LdapException e) {
LOG.error(I18n.err(I18n.ERR_16009_LDIF_LOAD_FAIL, ldifFile), e);
throw e;
}
}
}
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class LdifSchemaLoader method loadMatchingRuleUses.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadMatchingRuleUses(Schema... schemas) throws LdapException, IOException {
List<Entry> matchingRuleUseList = new ArrayList<>();
if (schemas == null) {
return matchingRuleUseList;
}
for (Schema schema : schemas) {
File matchingRuleUsesDirectory = new File(getSchemaDirectory(schema), SchemaConstants.MATCHING_RULE_USE_PATH);
if (!matchingRuleUsesDirectory.exists()) {
return matchingRuleUseList;
}
File[] matchingRuleUseFiles = matchingRuleUsesDirectory.listFiles(ldifFilter);
if (matchingRuleUseFiles != null) {
for (File ldifFile : matchingRuleUseFiles) {
LdifReader reader = new LdifReader(ldifFile);
LdifEntry entry = reader.next();
reader.close();
matchingRuleUseList.add(entry.getEntry());
}
}
}
return matchingRuleUseList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class LdifSchemaLoader method loadMatchingRules.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadMatchingRules(Schema... schemas) throws LdapException, IOException {
List<Entry> matchingRuleList = new ArrayList<>();
if (schemas == null) {
return matchingRuleList;
}
for (Schema schema : schemas) {
File matchingRulesDirectory = new File(getSchemaDirectory(schema), SchemaConstants.MATCHING_RULES_PATH);
if (!matchingRulesDirectory.exists()) {
return matchingRuleList;
}
File[] matchingRuleFiles = matchingRulesDirectory.listFiles(ldifFilter);
if (matchingRuleFiles != null) {
for (File ldifFile : matchingRuleFiles) {
LdifReader reader = new LdifReader(ldifFile);
LdifEntry entry = reader.next();
reader.close();
matchingRuleList.add(entry.getEntry());
}
}
}
return matchingRuleList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class LdifSchemaLoader method loadObjectClasses.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadObjectClasses(Schema... schemas) throws LdapException, IOException {
List<Entry> objectClassList = new ArrayList<>();
if (schemas == null) {
return objectClassList;
}
for (Schema schema : schemas) {
// get objectClasses directory, check if exists, return if not
File objectClassesDirectory = new File(getSchemaDirectory(schema), SchemaConstants.OBJECT_CLASSES_PATH);
if (!objectClassesDirectory.exists()) {
return objectClassList;
}
// get list of objectClass LDIF files from directory and load
File[] objectClassFiles = objectClassesDirectory.listFiles(ldifFilter);
if (objectClassFiles != null) {
for (File ldifFile : objectClassFiles) {
LdifReader reader = new LdifReader(ldifFile);
LdifEntry entry = reader.next();
reader.close();
objectClassList.add(entry.getEntry());
}
}
}
return objectClassList;
}
Aggregations