use of io.jans.orm.reflect.property.PropertyAnnotation in project jans by JanssenProject.
the class BaseEntryManager method getAttributeDataFromAttribute.
private AttributeData getAttributeDataFromAttribute(Object entry, Annotation ldapAttribute, PropertyAnnotation propertiesAnnotation, String propertyName) {
Class<?> entryClass = entry.getClass();
String ldapAttributeName = ((AttributeName) 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);
}
Class<?> parameterType = getSetterPropertyType(entryClass, propertyName);
boolean multiValued = isMultiValued(parameterType);
Annotation ldapJsonObject = ReflectHelper.getAnnotationByType(propertiesAnnotation.getAnnotations(), JsonObject.class);
boolean jsonObject = ldapJsonObject != null;
AttributeData attribute = getAttributeData(propertyName, ldapAttributeName, getter, entry, multiValued, jsonObject);
return attribute;
}
use of io.jans.orm.reflect.property.PropertyAnnotation in project jans by JanssenProject.
the class BaseEntryManager method contains.
@Override
public boolean contains(Object entry) {
if (entry == null) {
throw new MappingException("Entry to persist is null");
}
// Check entry class
Class<?> entryClass = entry.getClass();
checkEntryClass(entryClass, false);
String[] objectClasses = getObjectClasses(entry, entryClass);
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
Object dnValue = getDNValue(entry, entryClass);
List<AttributeData> attributes = getAttributesListForPersist(entry, propertiesAnnotations);
String[] ldapReturnAttributes = getAttributes(null, propertiesAnnotations, false);
return contains(dnValue.toString(), entryClass, propertiesAnnotations, attributes, objectClasses, ldapReturnAttributes);
}
use of io.jans.orm.reflect.property.PropertyAnnotation in project jans by JanssenProject.
the class BaseEntryManager method convertToPropertyAnnotationList.
private List<PropertyAnnotation> convertToPropertyAnnotationList(Map<String, List<Annotation>> annotations) {
List<PropertyAnnotation> result = new ArrayList<PropertyAnnotation>(annotations.size());
for (Entry<String, List<Annotation>> entry : annotations.entrySet()) {
result.add(new PropertyAnnotation(entry.getKey(), entry.getValue()));
}
Collections.sort(result);
return result;
}
use of io.jans.orm.reflect.property.PropertyAnnotation in project jans by JanssenProject.
the class BaseEntryManager method setCustomObjectClasses.
protected void setCustomObjectClasses(Object entry, Class<?> entryClass, String[] objectClasses) {
List<PropertyAnnotation> customObjectAnnotations = getEntryCustomObjectClassAnnotations(entryClass);
for (PropertyAnnotation propertiesAnnotation : customObjectAnnotations) {
String propertyName = propertiesAnnotation.getPropertyName();
Setter setter = getSetter(entryClass, propertyName);
if (setter == null) {
throw new MappingException("Entry should has setter for property " + propertyName);
}
AttributeData attribute = new AttributeData(propertyName, objectClasses);
setPropertyValue(propertyName, setter, entry, attribute, false);
break;
}
}
use of io.jans.orm.reflect.property.PropertyAnnotation in project jans by JanssenProject.
the class BaseEntryManager method persist.
@Override
public void persist(Object entry) {
if (entry == null) {
throw new MappingException("Entry to persist is null");
}
// Check entry class
Class<?> entryClass = entry.getClass();
checkEntryClass(entryClass, false);
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
Object dnValue = getDNValue(entry, entryClass);
Integer expirationValue = getExpirationValue(entry, entryClass, false);
List<AttributeData> attributes = getAttributesListForPersist(entry, propertiesAnnotations);
// Add object classes
String[] objectClasses = getObjectClasses(entry, entryClass);
attributes.add(new AttributeData(OBJECT_CLASS, objectClasses, true));
LOG.debug(String.format("LDAP attributes for persist: %s", attributes));
persist(dnValue.toString(), objectClasses, attributes, expirationValue);
}
Aggregations