AnsweredAssumed Answered

ACL cmis:read

Question asked by mmaicas on Jun 29, 2014
Latest reply on Oct 30, 2014 by pasqualerizzi
Hi,

I'm having problems to assign permissions to a document using CMIS 1.1 Atom interface from Java
I have a workaround to the problem but the solution is specific to Alfresco ECM and I think it shouldn’t
<!–break–>
My first version was:

    public static void addReadAcl(CmisObject doc,
                                  String idUser)
            throws Exception {

        if (doc!=null) {
                System.out.println("Adding permissions to " + idUser + " over: " + doc.getId());

                // Make permissions object
                List<String> permissions = new ArrayList<String>();  
                permissions.add(BasicPermissions.READ);
                Ace aceIn = session.getObjectFactory().createAce(idUser, permissions);

                // Add permisions
                List<Ace> aceListAdd = new ArrayList<Ace>();
                aceListAdd.add(aceIn);
                doc.addAcl(aceListAdd, AclPropagation.OBJECTONLY);
        }
    }


Then I try to call several times to the function

addReadAcl(doc, "testUser1");
addReadAcl(doc, "testUser2");
addReadAcl(doc, "testUser3");

Only the first call was reflected over the document, testUser2 and testUser3 didn’t appear in the “admin permissions” of the document . If I changed the order of the users only the first seemed to have been taken into consideration.
After a debugging process I found a solution. I saw that when I assigned 'cmis:read' the system assigned 2 permissions [cmis:read, {http://www.alfresco.org/model/system/1.0}base.Read] so I changed the function



    public static void addReadAcl(CmisObject doc,
                                  String idUser)
            throws Exception {

        if (doc!=null) {
                System.out.println("Adding permissions to " + idUser + " over: " + doc.getId());

                // Make permissions object
                List<String> permissions = new ArrayList<String>();  
                permissions.add(BasicPermissions.READ);
                permissions.add("{http://www.alfresco.org/model/system/1.0}base.Read");
                Ace aceIn = session.getObjectFactory().createAce(idUser, permissions);

                // Add permisions
                List<Ace> aceListAdd = new ArrayList<Ace>();
                aceListAdd.add(aceIn);
                doc.addAcl(aceListAdd, AclPropagation.OBJECTONLY);
        }
    }


And then It works! I can call several times to the function an all users are added to document permissions.

The problem is that this solution is specific to Alfresco and we wanted a pure cmis solution.

Any idea or alternative?

Best regards,
Miguel A. Maicas

Outcomes