更新时间:2023-11-25 22:00:16
艰难的方式(和喋喋不休的方式)是查询你的文件然后设置每个属性。但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.