如何使用 CMIS 删除文档 [英] How to Delete Document Using CMIS

查看:26
本文介绍了如何使用 CMIS 删除文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用连接到 alfresco 存储库的 Servlet 创建了一个外部 Web 应用程序.

I have Created a External web application using Servlets which is connected to alfresco repository.

我还可以将文档上传到存储库,从存储库下载文档.

I am also able to upload document in to the repository, download document from repository.

现在我的要求是,我必须根据用户角色删除文档.意味着我只想将删除文档的访问权限授予站点管理员.

now my requirement is, i have to delete document based on user role. means i want to give delete document access to only site manager.

如果有,请提供示例代码.

Please provide sample code if you have.

提前致谢

推荐答案

要删除文档,首先需要查看用户是否具有删除角色,这就是为什么答案将分为两部分

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

第 1 部分:搜索权威

这部分你会看到用户是否有删除权限

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

第 2 部分:删除方法

对于一个文档,删除它很简单

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

注意一个文件夹是不同的,但是只有第2部分会改变(因为当你删除一个文件夹时,你需要删除他孩子的)

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)

要完成此答案,您只需要将第 1 部分与第 2 部分结合起来即可.

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

这篇关于如何使用 CMIS 删除文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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