【问题标题】:CMIS ACL remove permission only a user (on Alfresco)CMIS ACL 仅删除用户权限(在 Alfresco 上)
【发布时间】:2018-10-01 09:46:29
【问题描述】:

当我想使用 openCMIS 方法 Acl removeAcl(List removeAces, AclPropagation aclPropagation) 删除单个用户的权限时遇到问题。

我有一个文档或文件夹有多个用户的权限,我只想删除单个用户的权限。

这是我用来删除用户的代码:

    OperationContext operationContext = new OperationContextImpl();
    operationContext.setIncludeAcls(true);
    Folder testFolder = (Folder) session.getObject("72deb421-3b8e-4268-9987-9c59a19f4a13");
    testFolder = (Folder) session.getObject(testDoc, operationContext);
    List<String> permissions = new ArrayList<String>();
    permissions.add("{http://www.alfresco.org/model/content/1.0}folder.Coordinator");
    String principal = "peter.sts";
    Ace aceIn = session.getObjectFactory().createAce(principal, permissions);
    List<Ace> aceListIn = new ArrayList<Ace>();
    aceListIn.add(aceIn);
    testDoc.removeAcl(aceListIn, AclPropagation.REPOSITORYDETERMINED);
    testDoc = (Folder) session.getObject(testDoc, operationContext);here

我让这个用户拥有与文件夹相关联的此权限并想要删除,但只有这个用户。

permissions.add("{http://www.alfresco.org/model/content/1.0}folder.Coordinator");

String principal = "peter.sts";

当我运行该方法时,所有与该文件夹相关的权限的用户都将被删除。

我做错了什么?

【问题讨论】:

  • 您是否尝试过获取 ACL、从列表中删除 ACE 并将其重新设置?
  • 我也做了测试,只删除与用户对应的 Ace,我想删除,但现在我知道我错了。我只是删除了用户的 Ace,并没有设置新的 Aces 列表。感谢 icrovett 和 Jeff 的帮助。

标签: alfresco acl cmis


【解决方案1】:

如果您只需要删除一个条目,则不需要创建 ACE 的实例。示例:

public void doExample() {
    OperationContext oc = new OperationContextImpl();
    oc.setIncludeAcls(true);
    Folder folder = (Folder) getSession().getObject("workspace://SpacesStore/5c8251c3-d309-4c88-a397-c408f4b34ed3", oc);

    // grab the ACL
    Acl acl = folder.getAcl();

    // dump the entries to sysout
    dumpAcl(acl);

    // iterate over the ACL Entries, removing the one that matches the id we want to remove
    List<Ace> aces = acl.getAces();
    for (Ace ace : aces) {
        if (ace.getPrincipalId().equals("tuser2")) {
            aces.remove(ace);
        }
    }

    // update the object ACL with the new list of ACL Entries
    folder.setAcl(aces);

    // refresh the object
    folder.refresh();

    // dump the acl to show the update
    acl = folder.getAcl();
    dumpAcl(acl);
}

public void dumpAcl(Acl acl) {
    List<Ace> aces = acl.getAces();
    for (Ace ace : aces) {
        System.out.println(String.format("%s has %s access", ace.getPrincipalId(), ace.getPermissions()));
    }
}

对包含三个用户 tuser1/2/3 的文件夹运行此命令,每个用户都具有协作者访问权限:

GROUP_EVERYONE has [{http://www.alfresco.org/model/content/1.0}cmobject.Consumer] access
tuser1 has [{http://www.alfresco.org/model/content/1.0}cmobject.Collaborator] access
tuser2 has [{http://www.alfresco.org/model/content/1.0}cmobject.Collaborator] access
tuser3 has [{http://www.alfresco.org/model/content/1.0}cmobject.Collaborator] access
GROUP_EVERYONE has [{http://www.alfresco.org/model/content/1.0}cmobject.Consumer] access
tuser1 has [{http://www.alfresco.org/model/content/1.0}cmobject.Collaborator] access
tuser3 has [{http://www.alfresco.org/model/content/1.0}cmobject.Collaborator] access

【讨论】:

    猜你喜欢
    • 2016-06-04
    • 2015-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-27
    • 1970-01-01
    • 2015-11-06
    相关资源
    最近更新 更多