Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Let's say I have a document doc and I want to update its barcode metadata to "01234".

The document might have existing other properties, I don't want to lose them.
In case doc already has a barcode, it will be overwritten.

How to do this with DotCMIS/OpenCMIS?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
210 views
Welcome To Ask or Share your Answers For Others

1 Answer

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);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...