use of org.gluu.persist.model.AttributeData in project oxCore by GluuFederation.
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 org.gluu.persist.model.AttributeData in project oxTrust by GluuFederation.
the class LdifService method performImport.
@SuppressWarnings("resource")
public void performImport(Class entryClass, InputStream inputStream) {
final ArrayList<Entry> entryList = new ArrayList<Entry>();
final LDIFReader reader = new LDIFReader(inputStream);
while (true) {
try {
final Entry entry = reader.readEntry();
if (entry == null) {
break;
} else {
entryList.add(entry);
}
} catch (final Exception e) {
log.error("", e);
}
}
entryList.stream().forEach(e -> {
Collection<Attribute> attributes = e.getAttributes();
List<Attribute> values = new ArrayList<>();
values.addAll(attributes);
ArrayList<AttributeData> datas = new ArrayList<>();
values.stream().forEach(value -> {
datas.add(new AttributeData(value.getName(), value.getValues(), (value.getValues().length > 1) ? true : false));
});
try {
persistenceManager.importEntry(e.getDN(), entryClass, datas);
} catch (Exception ex) {
log.info("=========", ex);
}
});
}
Aggregations