use of org.gluu.persist.reflect.property.Getter in project oxCore by GluuFederation.
the class BaseEntryManager method getAttributeFromLdapAttribute.
private AttributeData getAttributeFromLdapAttribute(Object entry, Annotation ldapAttribute, PropertyAnnotation propertiesAnnotation, String propertyName) {
Class<?> entryClass = entry.getClass();
String ldapAttributeName = ((LdapAttribute) ldapAttribute).name();
if (StringHelper.isEmpty(ldapAttributeName)) {
ldapAttributeName = propertyName;
}
Getter getter = getGetter(entryClass, propertyName);
if (getter == null) {
throw new MappingException("Entry should has getter for property " + propertyName);
}
Annotation ldapJsonObject = ReflectHelper.getAnnotationByType(propertiesAnnotation.getAnnotations(), LdapJsonObject.class);
boolean jsonObject = ldapJsonObject != null;
AttributeData attribute = getAttribute(propertyName, ldapAttributeName, getter, entry, jsonObject);
return attribute;
}
use of org.gluu.persist.reflect.property.Getter in project oxCore by GluuFederation.
the class BaseEntryManager method getCustomObjectClasses.
protected String[] getCustomObjectClasses(Object entry, Class<?> entryClass) {
List<String> result = new ArrayList<String>();
List<PropertyAnnotation> customObjectAnnotations = getEntryCustomObjectClassAnnotations(entryClass);
for (PropertyAnnotation propertiesAnnotation : customObjectAnnotations) {
String propertyName = propertiesAnnotation.getPropertyName();
Getter getter = getGetter(entryClass, propertyName);
if (getter == null) {
throw new MappingException("Entry should has getter for property " + propertyName);
}
AttributeData attribute = getAttribute(propertyName, propertyName, getter, entry, false);
if (attribute != null) {
for (String objectClass : attribute.getValues()) {
if (objectClass != null) {
result.add(objectClass);
}
}
}
break;
}
return result.toArray(new String[0]);
}
use of org.gluu.persist.reflect.property.Getter in project oxCore by GluuFederation.
the class BaseEntryManager method getAttributesFromLdapAttributesList.
private List<AttributeData> getAttributesFromLdapAttributesList(Object entry, Annotation ldapAttribute, String propertyName) {
Class<?> entryClass = entry.getClass();
List<AttributeData> listAttributes = new ArrayList<AttributeData>();
Getter getter = getGetter(entryClass, propertyName);
if (getter == null) {
throw new MappingException("Entry should has getter for property " + propertyName);
}
Object propertyValue = getter.get(entry);
if (propertyValue == null) {
return null;
}
if (!(propertyValue instanceof List<?>)) {
throw new MappingException("Entry property should has List base type");
}
Class<?> elementType = ReflectHelper.getListType(getter);
String entryPropertyName = ((LdapAttributesList) ldapAttribute).name();
Getter entryPropertyNameGetter = getGetter(elementType, entryPropertyName);
if (entryPropertyNameGetter == null) {
throw new MappingException("Entry should has getter for property " + propertyName + "." + entryPropertyName);
}
String entryPropertyValue = ((LdapAttributesList) ldapAttribute).value();
Getter entryPropertyValueGetter = getGetter(elementType, entryPropertyValue);
if (entryPropertyValueGetter == null) {
throw new MappingException("Entry should has getter for property " + propertyName + "." + entryPropertyValue);
}
for (Object entryAttribute : (List<?>) propertyValue) {
AttributeData attribute = getAttribute(propertyName, entryPropertyNameGetter, entryPropertyValueGetter, entryAttribute, false);
if (attribute != null) {
listAttributes.add(attribute);
}
}
return listAttributes;
}
use of org.gluu.persist.reflect.property.Getter in project oxCore by GluuFederation.
the class BaseEntryManager method getDNValue.
protected <T> Object getDNValue(Object entry, Class<T> entryClass) {
// Check if entry has DN property
String dnProperty = getDNPropertyName(entryClass);
// Get DN value
Getter dnGetter = getGetter(entryClass, dnProperty);
if (dnGetter == null) {
throw new MappingException("Entry should has getter for property " + dnProperty);
}
Object dnValue = dnGetter.get(entry);
if (StringHelper.isEmptyString(dnValue)) {
throw new MappingException("Entry should has not null base DN property value");
}
return dnValue;
}
use of org.gluu.persist.reflect.property.Getter in project oxCore by GluuFederation.
the class BaseEntryManager method getGetter.
protected <T> Getter getGetter(Class<T> entryClass, String propertyName) {
String key = entryClass.getName() + "." + propertyName;
Getter getter = classGetters.get(key);
if (getter == null) {
synchronized (CLASS_GETTERS_LOCK) {
getter = classGetters.get(key);
if (getter == null) {
getter = ReflectHelper.getGetter(entryClass, propertyName);
classGetters.put(key, getter);
}
}
}
return getter;
}
Aggregations