我可以使用露天仪表板设置权限,但我想用Java代码做同样的事情但是没有任何想法......如果任何人有示例请上传,直到现在我能够做以下事情。
我可以创建文件夹,存储内容和更改内容版本,但无法知道如何设置权限,所以请帮助我..
答案 0 :(得分:2)
以下是一些示例java代码:
String userName = "myusername;"
PermissionService permissionservice = serviceRegistry.getPermissionService();
permissionService.setPermission(nodeRef, userName, PermissionService.CONSUMER, true);
NodeRef dir = fileFolderService.searchSimple(nodeRef, userName);
if (dir == null){
dir = fileFolderService.create(nodeRef, userName, ContentModel.TYPE_FOLDER).getNodeRef();
permissionService.setInheritParentPermissions(dir, false);//should not be visible to others
permissionService.setPermission(dir, "GROUP_managers", PermissionService.COORDINATOR, true);
permissionService.setPermission(dir, "GROUP_basicusers", PermissionService.CONSUMER, true);
}
permissionService.setPermission(dir, userName, PermissionService.CONTRIBUTOR, true);