简体   繁体   English

Alfresco禁止所有用户删除内容

[英]Alfresco Prohibit all users to delete a content

I have next task - prohibit all users(except admin) to delete a content in Alfresco. 我有下一个任务 - 禁止所有用户(管理员除外)删除Alfresco中的内容。 I'm use a permission service for that, but it doesn't work: 我正在使用权限服务,但它不起作用:

private void setReadOnly(ScriptNode node) {
        permissionService.deletePermissions(node.getNodeRef());
        permissionService.setPermission(node.getNodeRef(),
PermissionService.ALL_AUTHORITIES, PermissionService.CONSUMER, true);
}

But if i'm add my user if other group(for example - Template designer) and than add new permission for blocking content from Alfresco Share(for example group-"TEMPLATE_DESIGNER" role-"COORDINATOR") - after that my user must delete content, add new content(if it folder) and other... Another way to solve my problem - 但是,如果我添加我的用户,如果其他组(例如 - 模板设计师),而不是添加新的权限来阻止来自Alfresco Share的内容(例如group-“TEMPLATE_DESIGNER”角色 - “COORDINATOR”) - 之后我的用户必须删除内容,添加新内容(如果它文件夹)和其他...另一种解决我的问题的方法 -

private void setReadOnly(ScriptNode node) {
        permissionService.deletePermissions(node.getNodeRef());
        permissionService.setInheritParentPermissions(node.getNodeRef(), false);
}

but it is not suitable for some reason. 但由于某种原因它不适合。 Please, answer - how to prohibit delete a content for all users(except admin)? 请回答 - 如何禁止删除所有用户的内容(管理员除外)? Thank you. 谢谢。

Can't you just change the permissionDefinitions.xml and remove the delete permission for every role? 你不能只是更改permissionDefinitions.xml并删除每个角色的删除权限吗?

There is a separate role for admin, just leave that as it is. 管理员有一个单独的角色,只需保留原样即可。

UPDATE: If you just want to do it for just one folder, then you can set the permissions manually. 更新:如果您只想为一个文件夹执行此操作,则可以手动设置权限。 Un-check inherit permission and set the the groups & user to editor rights. 取消选中继承权限并将组和用户设置为编辑者权限。 Only coordinator has delete rights, see page Docs 只有协调员具有删除权限,请参阅页面文档

In case you want to remove the permission of the owner, which still has delete rights. 如果您要删除拥有删除权限的所有者的权限。 just create a Javascript which removes the owner. 只需创建一个删除所有者的Javascript。

OK Second Answer: 好的第二个答案:

Create a behavior which implements NodeServicePolicies.BeforeDeleteNodePolicy. 创建实现NodeServicePolicies.BeforeDeleteNodePolicy的行为。

This behavior will get triggered every time before a user tries to delete an item. 每次用户尝试删除项目之前都会触发此行为。 So Then you'll have a NodeRef, from there you can check which node it is and if you want to make it deletable or not. 那么你将拥有一个NodeRef,从那里你可以检查它是哪个节点,以及你是否想要删除它。

The best way to do this is to: 最好的方法是:

  • Ad a custom aspect and evaluate it with the behavior 广告自定义方面并根据行为进行评估
  • Or define a custom node type, which has a custom metadata boolean or something which is set by a javascript or a rule which triggers the javascript. 或者定义一个自定义节点类型,它具有自定义元数据布尔值或由javascript或触发javascript的规则设置的东西。 And make that field hidden, so no user can check/uncheck it 并使该字段隐藏,因此没有用户可以检查/取消选中它

Btw check this PDF by Jeff Pots on creating behaviors :) 顺便看看Jeff Pots撰写的关于创建行为的PDF文件 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM