use of io.jans.orm.model.AttributeData in project jans by JanssenProject.
the class BaseEntryManager method dumpAttributeDataModifications.
protected void dumpAttributeDataModifications(String variableName, List<AttributeDataModification> attributeDataModifications) {
System.out.println("\n" + variableName + ": START");
for (AttributeDataModification modification : attributeDataModifications) {
String newValues = "[]";
String oldValues = "[]";
if ((modification.getAttribute() != null) && (modification.getAttribute().getValues() != null)) {
newValues = Arrays.toString(modification.getAttribute().getValues());
}
if ((modification.getOldAttribute() != null) && (modification.getOldAttribute().getValues() != null)) {
oldValues = Arrays.toString(modification.getOldAttribute().getValues());
}
AttributeData attribute = modification.getAttribute();
if (attribute == null) {
attribute = modification.getOldAttribute();
}
System.out.println(String.format("%s\t\t%s\t%b\t\t%s\t->\t%s", attribute.getName(), modification.getModificationType().name(), attribute.getMultiValued(), oldValues, newValues));
}
System.out.println(variableName + ": END");
}
use of io.jans.orm.model.AttributeData 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.model.AttributeData 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.model.AttributeData 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.model.AttributeData 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