How to Delete Document Using CMIS

隐身守侯 提交于 2019-12-03 23:15:57

In order to delete a document you first need to see if the user have the role to delete this is why the answer will be split in two part

Part 1 : search for authority

in this part you will see if the user have the authority to delete

Session session = getSession(serverUrl, username, password); // Get the session 

object = session.getObjectByPath(idObject); // get the object 

if (object.getAllowableActions().getAllowableActions().contains(Action.CAN_DELETE_OBJECT)) { //// You can delete 

   } else {  //// You can't delete 
       System.out.println("I can't ");            
   }

Part 2 : delete method

for a document it is simple to delete it

Session session = getSession(serverUrl, username, password);
CmisObject object = session.getObject(path);
Document suppDoc = (Document) object;
suppDoc.delete(true);

Note that it's different for a folder , but only the part 2 will be changed ( because when you delete a folder you need to delete his child's)

to complete this answer you only need to combine part 1 with part 2.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!