如何使用DotCMIS/OpenCMIS修改CMIS文档的属性

编程入门 行业动态 更新时间:2024-10-20 09:22:59
本文介绍了如何使用DotCMIS/OpenCMIS修改CMIS文档的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设我有一个文档doc,我想将其barcode元数据更新为"01234".

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

该文档可能具有其他现有属性,我不想丢失它们. 如果doc已经有一个barcode,它将被覆盖.

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.

如何使用DotCMIS/OpenCMIS做到这一点?

How to do this with DotCMIS/OpenCMIS?

推荐答案

在CMIS中,默认情况下,更新属性将覆盖现有值,并且默认情况下将保留不与updateProperties消息一起发送的属性.也就是说,协议语义已经保证了您的两个需求.

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.

在代码方面,请看Updating properties 代码示例对于OpenCMIS,适用于您的情况:

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

对于DotCMIS,示例页面提供了另一个有用的代码段,下面是修改后的版本以映射您的用例:

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

更多推荐

如何使用DotCMIS/OpenCMIS修改CMIS文档的属性

本文发布于:2023-11-28 10:05:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641960.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   属性   文档   OpenCMIS   DotCMIS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!