// object does not exist. propably was deleted by from cmis domain
// we don't know how to handle such case yet, thus TODO
return;
}
PropertyChanges changes = delta.getPropertyChanges();
// for this case we have only one property jcr:data
// what we need to understant it is what kind of action
if (!changes.getRemoved().isEmpty()) {
// we need to remove
((org.apache.chemistry.opencmis.client.api.Document)cmisObject).deleteContentStream();
} else {
ContentStream stream = jcrBinaryContent(delta.getDocument());
if (stream != null) {
((org.apache.chemistry.opencmis.client.api.Document)cmisObject).setContentStream(stream, true);
}
}
break;
case OBJECT:
// modifing cmis:folders and cmis:documents
cmisObject = session.getObject(objectId.getIdentifier());
changes = delta.getPropertyChanges();
Document props = delta.getDocument().getDocument("properties");
// checking that object exists
if (cmisObject == null) {
// unknown object
return;
}
// Prepare store for the cmis properties
Map<String, Object> updateProperties = new HashMap<String, Object>();
// ask cmis repository to get property definitions
// we will use these definitions for correct conversation
Map<String, PropertyDefinition<?>> propDefs = cmisObject.getBaseType().getPropertyDefinitions();
// group added and modified properties
ArrayList<Name> modifications = new ArrayList<Name>();
modifications.addAll(changes.getAdded());
modifications.addAll(changes.getChanged());
// convert names and values
for (Name name : modifications) {
String prefix = prefixes.value(name.getNamespaceUri());
// prefixed name of the property in jcr domain is
String jcrPropertyName = prefix != null ? prefix + ":" + name.getLocalName() : name.getLocalName();
// the name of this property in cmis domain is
String cmisPropertyName = properties.findCmisName(jcrPropertyName);
// in cmis domain this property is defined as
PropertyDefinition<?> pdef = propDefs.get(cmisPropertyName);
// unknown property?
if (pdef == null) {
// ignore
continue;
}
// convert value and store
Document jcrValues = props.getDocument(name.getNamespaceUri());
updateProperties.put(cmisPropertyName, properties.cmisValue(pdef, name.getLocalName(), jcrValues));
}
// step #2: nullify removed properties
for (Name name : changes.getRemoved()) {
String prefix = prefixes.value(name.getNamespaceUri());
// prefixed name of the property in jcr domain is
String jcrPropertyName = prefix != null ? prefix + ":" + name.getLocalName() : name.getLocalName();
// the name of this property in cmis domain is