Search in sources :

Example 6 with Acl

use of org.apache.chemistry.opencmis.commons.data.Acl in project iaf by ibissource.

the class FilterCmisService method applyAcl.

@Override
public Acl applyAcl(String repositoryId, String objectId, Acl aces, AclPropagation aclPropagation) {
    Acl orgAcl = getAclService().getAcl(repositoryId, objectId, Boolean.FALSE, null);
    Acl removeAces = null;
    if (orgAcl != null && orgAcl.getAces() != null && !orgAcl.getAces().isEmpty()) {
        List<Ace> directAces = new ArrayList<Ace>();
        for (Ace ace : orgAcl.getAces()) {
            if (ace.isDirect()) {
                directAces.add(ace);
            }
        }
        if (!directAces.isEmpty()) {
            removeAces = new AccessControlListImpl(directAces);
        }
    }
    return getAclService().applyAcl(repositoryId, objectId, aces, removeAces, aclPropagation, null);
}
Also used : Ace(org.apache.chemistry.opencmis.commons.data.Ace) ArrayList(java.util.ArrayList) AccessControlListImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl) Acl(org.apache.chemistry.opencmis.commons.data.Acl)

Example 7 with Acl

use of org.apache.chemistry.opencmis.commons.data.Acl in project alfresco-remote-api by Alfresco.

the class TestRemovePermissions method testRemoveAllPermissions_WEBSERVICE_10.

/**
 * cmisws?wsdl is not available using jetty in automated test suite should
 * be runned using an external alfresco server
 */
// @Test
public void testRemoveAllPermissions_WEBSERVICE_10() {
    Folder testFolder = null;
    try {
        Session session = getWEBSERVICE_10_Session();
        if (session == null) {
            fail("WEBSERVICE 1.0 session cannot be null");
        }
        testFolder = createFolder(session, "testRemoveAllPermissions_WEBSERVICE_10");
        List<Ace> acl = create2TestACLs(session);
        // adding new ACE
        testFolder.addAcl(acl, AclPropagation.PROPAGATE);
        Acl allacl = session.getAcl(session.createObjectId(testFolder.getId()), false);
        int oldSize = allacl.getAces().size();
        // Removing ALL ACEs
        Acl newAcl = testFolder.removeAcl(allacl.getAces(), AclPropagation.PROPAGATE);
        int newsize = newAcl.getAces().size();
        System.out.println("Old ace size -->" + oldSize);
        System.out.println("New ace size --> " + newsize);
        assertTrue(newsize == oldSize - acl.size());
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        if (testFolder != null) {
            testFolder.delete();
        }
    }
}
Also used : Ace(org.apache.chemistry.opencmis.commons.data.Ace) Acl(org.apache.chemistry.opencmis.commons.data.Acl) Folder(org.apache.chemistry.opencmis.client.api.Folder) Session(org.apache.chemistry.opencmis.client.api.Session)

Example 8 with Acl

use of org.apache.chemistry.opencmis.commons.data.Acl in project alfresco-remote-api by Alfresco.

the class TestRemovePermissions method testRemoveAllPermissions_ATOMPUB_10.

@Test
public void testRemoveAllPermissions_ATOMPUB_10() {
    Folder testFolder = null;
    try {
        Session session = getATOMPUB_10_Session();
        if (session == null) {
            fail("ATOMPUB 1.0 session cannot be null");
        }
        testFolder = createFolder(session, "testRemoveAllPermissions_ATOMPUB_10");
        List<Ace> acl = create2TestACLs(session);
        // adding new ACE
        testFolder.addAcl(acl, AclPropagation.PROPAGATE);
        Acl allacl = session.getAcl(session.createObjectId(testFolder.getId()), false);
        int oldSize = allacl.getAces().size();
        // Removing ALL ACEs
        Acl newAcl = testFolder.removeAcl(allacl.getAces(), AclPropagation.PROPAGATE);
        int newsize = newAcl.getAces().size();
        System.out.println("Old ace size -->" + oldSize);
        System.out.println("New ace size --> " + newsize);
        assertTrue(newsize == oldSize - acl.size());
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        if (testFolder != null) {
            testFolder.delete();
        }
    }
}
Also used : Ace(org.apache.chemistry.opencmis.commons.data.Ace) Acl(org.apache.chemistry.opencmis.commons.data.Acl) Folder(org.apache.chemistry.opencmis.client.api.Folder) Session(org.apache.chemistry.opencmis.client.api.Session) Test(org.junit.Test)

Example 9 with Acl

use of org.apache.chemistry.opencmis.commons.data.Acl in project alfresco-remote-api by Alfresco.

the class TestRemovePermissions method testRemoveAllPermissions_BROWSER_11.

@Test
public void testRemoveAllPermissions_BROWSER_11() {
    Folder testFolder = null;
    try {
        Session session = getBROWSER_11_Session();
        if (session == null) {
            fail("ATOMPUB 1.1 session cannot be null");
        }
        testFolder = createFolder(session, "testRemoveAllPermissions_BROWSER_11");
        List<Ace> acl = create2TestACLs(session);
        // adding new ACE
        testFolder.addAcl(acl, AclPropagation.PROPAGATE);
        Acl allacl = session.getAcl(session.createObjectId(testFolder.getId()), false);
        int oldSize = allacl.getAces().size();
        // Removing ALL ACEs
        Acl newAcl = testFolder.removeAcl(allacl.getAces(), AclPropagation.PROPAGATE);
        int newsize = newAcl.getAces().size();
        System.out.println("Old ace size -->" + oldSize);
        System.out.println("New ace size --> " + newsize);
        assertTrue(newsize == oldSize - acl.size());
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        if (testFolder != null) {
            testFolder.delete();
        }
    }
}
Also used : Ace(org.apache.chemistry.opencmis.commons.data.Ace) Acl(org.apache.chemistry.opencmis.commons.data.Acl) Folder(org.apache.chemistry.opencmis.client.api.Folder) Session(org.apache.chemistry.opencmis.client.api.Session) Test(org.junit.Test)

Example 10 with Acl

use of org.apache.chemistry.opencmis.commons.data.Acl in project copper-cms by PogeyanOSS.

the class ObjectActor method createItem.

private JSONObject createItem(PostRequest request) throws CmisInvalidArgumentException, CmisObjectNotFoundException, IllegalArgumentException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    String principalId = request.getUserObject().getUserDN();
    IUserGroupObject[] groups = request.getUserObject().getGroups();
    if (!Helpers.getGroupPermission(permission, groups)) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String folderId = request.getObjectId() != null ? request.getObjectId() : null;
    boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    Properties prop = CmisPropertyConverter.Impl.createNewProperties(request.getPropertyData(), request.getRepositoryId());
    Acl aclImp = CmisUtils.Object.getAcl(request.getAddAcl(), principalId, permission);
    String newObjectId = CmisObjectService.Impl.createItem(request.getRepositoryId(), prop, folderId, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
    ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_ITEM);
    if (object == null) {
        throw new CmisRuntimeException("New folder is null!");
    }
    // return object
    JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
    return jsonObject;
}
Also used : IUserGroupObject(com.pogeyan.cmis.api.auth.IUserGroupObject) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) Acl(org.apache.chemistry.opencmis.commons.data.Acl) Properties(org.apache.chemistry.opencmis.commons.data.Properties) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Aggregations

Acl (org.apache.chemistry.opencmis.commons.data.Acl)14 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)8 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)8 IUserGroupObject (com.pogeyan.cmis.api.auth.IUserGroupObject)6 Ace (org.apache.chemistry.opencmis.commons.data.Ace)6 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)6 Properties (org.apache.chemistry.opencmis.commons.data.Properties)6 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)6 Folder (org.apache.chemistry.opencmis.client.api.Folder)5 Session (org.apache.chemistry.opencmis.client.api.Session)4 CapabilityAcl (org.apache.chemistry.opencmis.commons.enums.CapabilityAcl)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 VersioningState (org.apache.chemistry.opencmis.commons.enums.VersioningState)2 Document (org.apache.chemistry.opencmis.client.api.Document)1 AccessControlListImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl)1 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)1