use of org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper in project directory-ldap-api by apache.
the class Registries method contains.
/**
* Tells if the given SchemaObject is present in one schema. The schema
* may be disabled.
*
* @param schemaObject The schemaObject we are looking for
* @return true if the schemaObject is present in a schema
*/
public boolean contains(SchemaObject schemaObject) {
String schemaName = schemaObject.getSchemaName();
Set<SchemaObjectWrapper> setSchemaObjects = schemaObjects.get(schemaName);
if ((setSchemaObjects == null) || setSchemaObjects.isEmpty()) {
return false;
}
SchemaObjectWrapper wrapper = new SchemaObjectWrapper(schemaObject);
return setSchemaObjects.contains(wrapper);
}
use of org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper in project directory-ldap-api by apache.
the class Registries method addUsedBy.
/**
* Add an association between a SchemaObject an the SchemaObject that refers it
*
* @param reference The base SchemaObject
* @param referee The SchemaObject pointing on the reference
*/
private void addUsedBy(SchemaObject referee, SchemaObject reference) {
if ((reference == null) || (referee == null)) {
return;
}
SchemaObjectWrapper wrapper = new SchemaObjectWrapper(referee);
Set<SchemaObjectWrapper> uses = getUsedBy(referee);
if (uses == null) {
uses = new HashSet<>();
}
uses.add(new SchemaObjectWrapper(reference));
// Put back the set (this is a concurrentHashMap, it won't be replaced implicitly
usedBy.put(wrapper, uses);
}
use of org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper in project directory-ldap-api by apache.
the class Registries method dissociateFromSchema.
/**
* Remove the given SchemaObject from the Map associating SchemaObjetcs to their
* related Schema.
*
* @param schemaObject The schemaObject to remove
* @throws LdapException If there is a problem
*/
public void dissociateFromSchema(SchemaObject schemaObject) throws LdapException {
// And unregister the schemaObject within its schema
Set<SchemaObjectWrapper> content = schemaObjects.get(Strings.toLowerCaseAscii(schemaObject.getSchemaName()));
if (content != null) {
SchemaObjectWrapper schemaObjectWrapper = new SchemaObjectWrapper(schemaObject);
if (content.contains(schemaObjectWrapper)) {
// remove the schemaObject
content.remove(schemaObjectWrapper);
// an instance of LoadableSchemaObject
if (!(schemaObject instanceof LoadableSchemaObject)) {
globalOidRegistry.unregister(schemaObject.getOid());
}
LOG.debug("Unregistered {}:{}", schemaObject.getObjectType(), schemaObject.getOid());
} else {
// Not present !!
// What should we do ?
LOG.debug("Unregistering of {}:{} failed, not found in Registries", schemaObject.getObjectType(), schemaObject.getOid());
}
}
}
use of org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper in project directory-ldap-api by apache.
the class Registries method dumpUsing.
/**
* Dump the Using data structure as a String
*
* @return The Using data structure
*/
public String dumpUsing() {
StringBuilder sb = new StringBuilder();
sb.append("USING :\n");
try {
for (Map.Entry<SchemaObjectWrapper, Set<SchemaObjectWrapper>> entry : using.entrySet()) {
SchemaObjectWrapper wrapper = entry.getKey();
sb.append(wrapper.get().getObjectType()).append('[').append(wrapper.get().getOid()).append("] : {");
boolean isFirst = true;
for (SchemaObjectWrapper uses : entry.getValue()) {
if (isFirst) {
isFirst = false;
} else {
sb.append(", ");
}
sb.append(uses.get().getObjectType()).append('[').append(wrapper.get().getOid()).append("]");
}
sb.append("}\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
use of org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadDitStructureRules.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadDitStructureRules(Schema... schemas) throws LdapException, IOException {
List<Entry> ditStructureRuleEntries = new ArrayList<>();
if (schemas == null) {
return ditStructureRuleEntries;
}
AttributesFactory factory = new AttributesFactory();
for (Schema schema : schemas) {
Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
SchemaObject schemaObject = schemaObjectWrapper.get();
if (schemaObject instanceof DitStructureRule) {
DitStructureRule ditStructureRule = (DitStructureRule) schemaObject;
Entry ditStructureRuleEntry = factory.convert(ditStructureRule, schema, null);
ditStructureRuleEntries.add(ditStructureRuleEntry);
}
}
}
return ditStructureRuleEntries;
}
Aggregations