How to get Acls of a document?

2020-05-05 17:56发布

问题:

I am have created document in repository...

and I have set Acls Like below...

public void setPermissionsToDocument(Session session, List<String> users, String documentPath) {
    List<String> permissions = new LinkedList<String>();
    List<Ace> addAces = new LinkedList<Ace>();
    // permissions.add(BasicPermissions.WRITE);
    permissions.add(PermissionService.TAKE_OWNERSHIP);
    for (String user : users) {
        Ace addAce = session.getObjectFactory().createAce(user, permissions);
        addAces.add(addAce);
    }
    Document document = (Document) session.getObjectByPath(documentPath);
    // CmisObjectNotFoundException(String message)
    // document.addAcl(addAces, AclPropagation.REPOSITORYDETERMINED);
    document.setAcl(addAces);
    System.out.println("permissions are setted");

}

Now I am not getting Acls of paricular document like as shown below. and return null.

    Document document = dmsService.getDocument(session, "/Manohar/Manohar1/Manohar2/app-logo-48.png");
    document.getAcl();

Any body please help me...

回答1:

Try this :

System.out.println("getting ACL capabilities");
       AclCapabilities aclCapabilities =  session.getRepositoryInfo().getAclCapabilities();

System.out.println("Propogation for this repository is " + aclCapabilities.getAclPropagation().toString());

System.out.println("permissions for this repository are: ");
for (PermissionDefinition definition : aclCapabilities.getPermissions()) {
System.out.println(definition.toString());                
}

System.out.println("\npermission mappings for this repository are: ");
Map<String, PermissionMapping> repoMapping =  aclCapabilities.getPermissionMapping();
for (String key: repoMapping.keySet()) {
System.out.println(key + " maps to " + repoMapping.get(key).getPermissions());                
}