我使用连接到露天存储库的Servlets创建了一个外部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部分:搜索权限
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 "); }第2部分:删除方法
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);请注意,文件夹不同,但只会更改第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删除文档
发布评论