In CMIS, updating properties will overwrite existing values by default, and properties you don't send along with the updateProperties message are by default retained. That is to say that both your requirements are already guaranteed by the protocol semantic.
Code wise, have a look at the Updating properties
code sample for OpenCMIS, here's it applied to your case:
CmisObject cmisobject = ....
Map<String, Object> updateProperties = new HashMap<String, Object>();
updateProperties.put("acme:barcode", "new value"); // single-value property
cmisobject.updateProperties(updateProperties);
In case of DotCMIS, the samples page offer another useful snippet, here's the modified version to map your use case:
ICmisObject cmisObject = ...
IDictionary<string, object> properties = new Dictionary<string, object>();
properties["acme:barcode"] = "new value";
IObjectId newId = cmisObject.UpdateProperties(properties);
if (newId.Id == cmisObject.Id)
{
// the repository updated this object - refresh the object
cmisObject.Refresh();
}
else
{
// the repository created a new version - fetch the new version
cmisObject = session.GetObject(newId);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…