如何使用CMIS在Alfresco中进行批量更新 [英] How to Do Mass Update in Alfresco Using CMIS

查看:172
本文介绍了如何使用CMIS在Alfresco中进行批量更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在露天使用CMIS进行批量更新。

Is it possible to do mass update using CMIS in alfresco.

我有不同的文件类型,每种文件类型在露天存储库中都有多个文件。

I have Different Documents Types and Every Document type is having multiple documents in alfresco repository.

现在我的要求是,如果我将更新任何文件的任何单一财产,那么它应该反映所有相同类型的文件。

Now my requirement is, If i will Update any single property of any document, then it should reflect with all the documents of same type.

我可以使用CMIS吗?

Can i do this USING CMIS?

如果是,请提供步骤和示例代码来执行此操作。

If yes, please provide the steps and sample code to do this.

提前致谢

推荐答案

艰难的方式(和喋喋不休的方式)是查询你的文件然后设置每个属性。但CMIS规范实际上提供了一种更好的方式:批量更新。

The hard way (and chatty way) is to query for your documents and then set the properties on each one. But the CMIS spec actually provides a better way: Bulk updates.

这是代码的样子:

ArrayList<CmisObject> docList = new ArrayList<CmisObject>();
Document doc1 = (Document) getSession().getObjectByPath("/bulk/bulktest1.txt");
docList.add(doc1);
Document doc2 = (Document) getSession().getObjectByPath("/bulk/bulktest2.txt");
docList.add(doc2);
Document doc3 = (Document) getSession().getObjectByPath("/bulk/bulktest3.txt");
docList.add(doc3);

HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cmis:description", "description set in bulk");
List<BulkUpdateObjectIdAndChangeToken> updatedIds = getSession().bulkUpdateProperties(docList, props, null, null);

System.out.println("Updated " + updatedIds.size() + " docs.");

在我的例子中,我按路径抓取每个文档,但当然你可以运行查询和构建你的列表也是如此。

In my example I am grabbing each document by path, but of course you could run a query and build your list that way as well.

要在Alfresco中使用它,你必须使用CMIS 1.1和浏览器绑定,所以要确保你的服务URL是 HTTP://本地主机:8080 /露天/ API / - 默认/公共/ CMIS /版本/ 1.1 /浏览器

To use this with Alfresco you must use CMIS 1.1 and the browser binding so make sure your service URL is http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser.

这篇关于如何使用CMIS在Alfresco中进行批量更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆