use of com.unboundid.ldap.sdk.schema.ObjectClassDefinition in project zm-mailbox by Zimbra.
the class UBIDLdapSchema method getObjectClasses.
@Override
public List<ZObjectClassDefinition> getObjectClasses() throws LdapException {
List<ZObjectClassDefinition> ocList = new ArrayList<ZObjectClassDefinition>();
Set<ObjectClassDefinition> ocs = schema.getObjectClasses();
for (ObjectClassDefinition oc : ocs) {
UBIDObjectClassDefinition ubidOC = new UBIDObjectClassDefinition(oc);
ocList.add(ubidOC);
}
Comparator comparator = new Comparator<UBIDObjectClassDefinition>() {
public int compare(UBIDObjectClassDefinition first, UBIDObjectClassDefinition second) {
return first.getName().compareTo(second.getName());
}
};
Collections.sort(ocList, comparator);
return ocList;
}
use of com.unboundid.ldap.sdk.schema.ObjectClassDefinition in project oxCore by GluuFederation.
the class SchemaService method getObjectClassesByAttribute.
/**
* Determine object classes by attribute name
*
* @param schemaEntry
* Schema
* @param OBJECT_CLASS
* Object class name
* @return List of object classes
*/
public Set<String> getObjectClassesByAttribute(SchemaEntry schemaEntry, String attributeType) {
if ((schemaEntry == null) || StringHelper.isEmpty(attributeType)) {
return null;
}
String lowerCaseAttributeType = StringHelper.toLowerCase(attributeType);
Set<String> resultObjectClasses = new HashSet<String>();
for (String objectClassDefinition : schemaEntry.getObjectClasses()) {
ObjectClassDefinition definition;
try {
definition = new ObjectClassDefinition(objectClassDefinition);
Set<String> objectClassAttributeTypes = new HashSet<String>();
for (String name : definition.getOptionalAttributes()) {
objectClassAttributeTypes.add(StringHelper.toLowerCase(name));
}
for (String name : definition.getRequiredAttributes()) {
objectClassAttributeTypes.add(StringHelper.toLowerCase(name));
}
if (objectClassAttributeTypes.contains(lowerCaseAttributeType)) {
String objectClassType = definition.getNameOrOID();
resultObjectClasses.add(objectClassType);
}
} catch (Exception ex) {
log.error("Failed to parse LDAP object class definition: '{}'", ex, objectClassDefinition);
}
}
return resultObjectClasses;
}
use of com.unboundid.ldap.sdk.schema.ObjectClassDefinition in project oxCore by GluuFederation.
the class SchemaService method getObjectClassesAttributes.
/**
* Get all attribute names by specified object classes
*
* @param schemaEntry
* Schema
* @param OBJECT_CLASS
* Object class name
* @return Object class schema definition string
*/
public Set<String> getObjectClassesAttributes(SchemaEntry schemaEntry, String[] objectClasses) {
if ((schemaEntry == null) || (objectClasses == null)) {
return null;
}
Map<String, ObjectClassDefinition> objectClassDefinitions = new HashMap<String, ObjectClassDefinition>();
for (String objectClassDefinition : schemaEntry.getObjectClasses()) {
ObjectClassDefinition definition;
try {
definition = new ObjectClassDefinition(objectClassDefinition);
for (String name : definition.getNames()) {
objectClassDefinitions.put(StringHelper.toLowerCase(name), definition);
}
} catch (Exception ex) {
log.error("Failed to parse LDAP object class definition: '{}'", ex, objectClassDefinition);
}
}
Set<ObjectClassDefinition> resultObjectClassDefinitions = getSuperiorClasses(objectClassDefinitions, objectClasses, true);
Set<String> resultAttributes = getAttributes(resultObjectClassDefinitions, true, true);
return resultAttributes;
}
use of com.unboundid.ldap.sdk.schema.ObjectClassDefinition in project oxCore by GluuFederation.
the class SchemaService method getSuperiorClasses.
private static void getSuperiorClasses(final Map<String, ObjectClassDefinition> objectClassDefinitions, final ObjectClassDefinition objectClassDefinition, final Set<ObjectClassDefinition> resultObjectClassDefinitions) {
for (final String superiorClass : objectClassDefinition.getSuperiorClasses()) {
final ObjectClassDefinition superiorObjectClassDefinition = objectClassDefinitions.get(StringHelper.toLowerCase(superiorClass));
if (superiorObjectClassDefinition != null) {
resultObjectClassDefinitions.add(superiorObjectClassDefinition);
getSuperiorClasses(objectClassDefinitions, superiorObjectClassDefinition, resultObjectClassDefinitions);
}
}
}
Aggregations