use of org.apache.directory.api.ldap.model.schema.SchemaObject in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadComparators.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadComparators(Schema... schemas) throws LdapException, IOException {
List<Entry> comparatorEntries = new ArrayList<>();
if (schemas == null) {
return comparatorEntries;
}
for (Schema schema : schemas) {
Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
SchemaObject schemaObject = schemaObjectWrapper.get();
if (schemaObject instanceof LdapComparatorDescription) {
LdapComparatorDescription ldapComparatorDescription = (LdapComparatorDescription) schemaObject;
Entry lcEntry = getEntry(ldapComparatorDescription);
comparatorEntries.add(lcEntry);
}
}
}
return comparatorEntries;
}
use of org.apache.directory.api.ldap.model.schema.SchemaObject in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadSyntaxCheckers.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadSyntaxCheckers(Schema... schemas) throws LdapException, IOException {
List<Entry> syntaxCheckerEntries = new ArrayList<>();
if (schemas == null) {
return syntaxCheckerEntries;
}
for (Schema schema : schemas) {
Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
SchemaObject schemaObject = schemaObjectWrapper.get();
if (schemaObject instanceof SyntaxCheckerDescription) {
SyntaxCheckerDescription syntaxCheckerDescription = (SyntaxCheckerDescription) schemaObject;
Entry syntaxCheckerEntry = getEntry(syntaxCheckerDescription);
syntaxCheckerEntries.add(syntaxCheckerEntry);
}
}
}
return syntaxCheckerEntries;
}
use of org.apache.directory.api.ldap.model.schema.SchemaObject in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadDitContentRules.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadDitContentRules(Schema... schemas) throws LdapException, IOException {
List<Entry> ditContentRuleEntries = new ArrayList<>();
if (schemas == null) {
return ditContentRuleEntries;
}
AttributesFactory factory = new AttributesFactory();
for (Schema schema : schemas) {
Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
SchemaObject schemaObject = schemaObjectWrapper.get();
if (schemaObject instanceof DitContentRule) {
DitContentRule ditContentRule = (DitContentRule) schemaObject;
Entry ditContentRuleEntry = factory.convert(ditContentRule, schema, null);
ditContentRuleEntries.add(ditContentRuleEntry);
}
}
}
return ditContentRuleEntries;
}
use of org.apache.directory.api.ldap.model.schema.SchemaObject in project directory-ldap-api by apache.
the class DefaultSchemaManager method deleteSchemaObjects.
/**
* Delete all the schemaObjects for a given schema from the registries
*/
private void deleteSchemaObjects(Schema schema, Registries registries) throws LdapException {
Map<String, Set<SchemaObjectWrapper>> schemaObjects = registries.getObjectBySchemaName();
Set<SchemaObjectWrapper> content = schemaObjects.get(Strings.toLowerCaseAscii(schema.getSchemaName()));
List<SchemaObject> toBeDeleted = new ArrayList<>();
if (content != null) {
// Build an intermediate list to avoid concurrent modifications
for (SchemaObjectWrapper schemaObjectWrapper : content) {
toBeDeleted.add(schemaObjectWrapper.get());
}
for (SchemaObject schemaObject : toBeDeleted) {
registries.delete(errors, schemaObject);
}
}
}
use of org.apache.directory.api.ldap.model.schema.SchemaObject in project directory-ldap-api by apache.
the class DefaultSchemaManager method copy.
private SchemaObject copy(SchemaObject schemaObject) {
SchemaObject copy = null;
if (!(schemaObject instanceof LoadableSchemaObject)) {
copy = schemaObject.copy();
} else {
// Check the schemaObject here.
if (((LoadableSchemaObject) schemaObject).isValid()) {
copy = schemaObject;
} else {
// We have an invalid SchemaObject, no need to go any further
Throwable error = new LdapUnwillingToPerformException(ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err(I18n.ERR_11007, schemaObject.getOid()));
errors.add(error);
}
}
return copy;
}
Aggregations