use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class DefaultSchemaManager method loadAllEnabled.
/**
* {@inheritDoc}
*/
@Override
public boolean loadAllEnabled() throws LdapException {
Schema[] schemas = new Schema[schemaMap.size()];
int i = 0;
for (Schema schema : schemaMap.values()) {
if (schema.isEnabled()) {
schemas[i++] = schema;
}
}
Schema[] enabledSchemas = new Schema[i];
System.arraycopy(schemas, 0, enabledSchemas, 0, i);
return loadWithDeps(enabledSchemas);
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class JarLdifSchemaLoader method initializeSchemas.
/**
* Scans for LDIF files just describing the various schema contained in
* the schema repository.
*
* @throws LdapException
*/
private void initializeSchemas() throws IOException, LdapException {
if (IS_DEBUG) {
LOG.debug(I18n.msg(I18n.MSG_16006_INITIALIZING_SCHEMA));
}
Pattern pat = Pattern.compile("schema" + SEPARATOR_PATTERN + "ou=schema" + SEPARATOR_PATTERN + "cn=[a-z0-9-_]*\\." + LDIF_EXT);
for (String file : RESOURCE_MAP.keySet()) {
if (pat.matcher(file).matches()) {
URL resource = getResource(file, "schema LDIF file");
InputStream in = resource.openStream();
try {
LdifReader reader = new LdifReader(in);
LdifEntry entry = reader.next();
reader.close();
Schema schema = getSchema(entry.getEntry());
schemaMap.put(schema.getSchemaName(), schema);
if (IS_DEBUG) {
LOG.debug(I18n.msg(I18n.MSG_16007_SCHEMA_INITIALIZED, schema));
}
} catch (LdapException le) {
LOG.error(I18n.err(I18n.ERR_16009_LDIF_LOAD_FAIL, file), le);
throw le;
} finally {
in.close();
}
}
}
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class JarLdifSchemaLoader method loadComparators.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadComparators(Schema... schemas) throws LdapException, IOException {
List<Entry> comparatorList = new ArrayList<>();
if (schemas == null) {
return comparatorList;
}
for (Schema schema : schemas) {
String start = getSchemaDirectoryString(schema) + SchemaConstants.COMPARATORS_PATH + "/" + "m-oid=";
String end = "." + LDIF_EXT;
for (String resourcePath : RESOURCE_MAP.keySet()) {
if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
URL resource = getResource(resourcePath, "comparator LDIF file");
LdifReader reader = new LdifReader(resource.openStream());
LdifEntry entry = reader.next();
reader.close();
comparatorList.add(entry.getEntry());
}
}
}
return comparatorList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class JarLdifSchemaLoader method loadSyntaxCheckers.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadSyntaxCheckers(Schema... schemas) throws LdapException, IOException {
List<Entry> syntaxCheckerList = new ArrayList<>();
if (schemas == null) {
return syntaxCheckerList;
}
for (Schema schema : schemas) {
String start = getSchemaDirectoryString(schema) + SchemaConstants.SYNTAX_CHECKERS_PATH + "/" + "m-oid=";
String end = "." + LDIF_EXT;
for (String resourcePath : RESOURCE_MAP.keySet()) {
if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
URL resource = getResource(resourcePath, "syntaxChecker LDIF file");
LdifReader reader = new LdifReader(resource.openStream());
LdifEntry entry = reader.next();
reader.close();
syntaxCheckerList.add(entry.getEntry());
}
}
}
return syntaxCheckerList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class JarLdifSchemaLoader method loadAttributeTypes.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadAttributeTypes(Schema... schemas) throws LdapException, IOException {
List<Entry> attributeTypeList = new ArrayList<>();
if (schemas == null) {
return attributeTypeList;
}
for (Schema schema : schemas) {
// check that the attributeTypes directory exists for the schema
String start = getSchemaDirectoryString(schema) + SchemaConstants.ATTRIBUTE_TYPES_PATH + "/" + "m-oid=";
String end = "." + LDIF_EXT;
// get list of attributeType LDIF schema files in attributeTypes
for (String resourcePath : RESOURCE_MAP.keySet()) {
if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
URL resource = getResource(resourcePath, "attributeType LDIF file");
LdifReader reader = new LdifReader(resource.openStream());
LdifEntry entry = reader.next();
reader.close();
attributeTypeList.add(entry.getEntry());
}
}
}
return attributeTypeList;
}
Aggregations