CMIS ACL 仅删除用户权限(在 Alfresco 上)
CMIS ACL remove permission only a user (on Alfresco)
我在使用 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");
字符串主体 = "peter.sts";
当我 运行 方法时,所有具有与该文件夹关联的权限的用户都将被删除。
我做错了什么?
如果您只需要删除一个条目,则无需创建 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 的文件夹,每个用户都具有协作者访问权限 returns:
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
我在使用 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");
字符串主体 = "peter.sts";
当我 运行 方法时,所有具有与该文件夹关联的权限的用户都将被删除。
我做错了什么?
如果您只需要删除一个条目,则无需创建 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 的文件夹,每个用户都具有协作者访问权限 returns:
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