Alfresco CMIS ACL仅删除用户权限(露天)
当我想使用openCMIS方法Acl removeAcl(List removeAces,AclPropagation AclPropagation)从单个用户删除权限时,我遇到了麻烦 我有一个文档或文件夹,有多个用户具有权限,我只想删除对单个用户的权限 这是我用来删除用户的代码:Alfresco CMIS ACL仅删除用户权限(露天),alfresco,acl,cmis,Alfresco,Acl,Cmis,当我想使用openCMIS方法Acl removeAcl(List removeAces,AclPropagation AclPropagation)从单个用户删除权限时,我遇到了麻烦 我有一个文档或文件夹,有多个用户具有权限,我只想删除对单个用户的权限 这是我用来删除用户的代码: OperationContext operationContext = new OperationContextImpl(); operationContext.setIncludeAcls(true
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
OperationContext OperationContext=new OperationContextImpl();
operationContext.setIncludeAcls(true);
文件夹testFolder=(文件夹)session.getObject(“72deb421-3b8e-4268-9987-9c59a19f4a13”);
testFolder=(文件夹)session.getObject(testDoc,operationContext);
列表权限=新建ArrayList();
权限。添加(“{http://www.alfresco.org/model/content/1.0}文件夹(协调人);
String principal=“peter.sts”;
Ace aceIn=session.getObjectFactory().createAce(主体,权限);
List}文件夹协调器“
String principal=“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()));
}
}
您是否尝试获取ACL,从列表中删除ACE并将其设置回原位?我还测试了仅删除与用户对应的ACE,我想删除,但现在我发现我错在哪里。我只是删除了用户的ACE,没有设置新的ACE列表。感谢您的帮助,icrovett和Jeff。
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