use of org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl in project iaf by ibissource.
the class ObjectServiceImpl method processProperties.
private Properties processProperties(Element cmisElement) throws SenderException {
PropertiesImpl properties = new PropertiesImpl();
Element propertiesElement = XmlUtils.getFirstChildTag(cmisElement, "properties");
Iterator<Node> propertyIterator = XmlUtils.getChildTags(propertiesElement, "property").iterator();
while (propertyIterator.hasNext()) {
Element propertyElement = (Element) propertyIterator.next();
String property = XmlUtils.getStringValue(propertyElement);
String nameAttr = propertyElement.getAttribute("name");
String typeAttr = propertyElement.getAttribute("type");
if (StringUtils.isEmpty(typeAttr) || typeAttr.equalsIgnoreCase("string")) {
if (nameAttr.startsWith("cmis:")) {
properties.addProperty(new PropertyIdImpl(nameAttr, property));
} else {
properties.addProperty(new PropertyStringImpl(nameAttr, property));
}
} else if (typeAttr.equalsIgnoreCase("integer")) {
properties.addProperty(new PropertyIntegerImpl(nameAttr, new BigInteger(property)));
} else if (typeAttr.equalsIgnoreCase("boolean")) {
properties.addProperty(new PropertyBooleanImpl(nameAttr, Boolean.parseBoolean(property)));
} else if (typeAttr.equalsIgnoreCase("datetime")) {
String formatStringAttr = propertyElement.getAttribute("formatString");
if (StringUtils.isEmpty(formatStringAttr)) {
formatStringAttr = CmisSender.FORMATSTRING_BY_DEFAULT;
}
DateFormat df = new SimpleDateFormat(formatStringAttr);
Date date;
try {
date = df.parse(property);
} catch (ParseException e) {
throw new SenderException("exception parsing date [" + property + "] using formatString [" + formatStringAttr + "]", e);
}
GregorianCalendar gregorian = new GregorianCalendar();
gregorian.setTime(date);
properties.addProperty(new PropertyDateTimeImpl(nameAttr, gregorian));
} else {
log.warn("unparsable type [" + typeAttr + "] for property [" + property + "]");
}
log.debug("set property name [" + nameAttr + "] value [" + property + "]");
}
return properties;
}
Aggregations