How to Do Mass Update in Alfresco Using CMIS

前端 未结 2 1335
野的像风
野的像风 2021-01-07 12:44

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

2条回答
  •  情深已故
    2021-01-07 13:20

    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.

    Here is what the code looks like:

    ArrayList docList = new ArrayList();
    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 props = new HashMap();
    props.put("cmis:description", "description set in bulk");
    List 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.

    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.

提交回复
热议问题