Search in sources :

Example 1 with AccessControlPrincipalDataImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl in project copper-cms by PogeyanOSS.

the class CmisRequestParameter method createAddAcl.

public Acl createAddAcl(ControlParser controlParser, PostRequest request) {
    List<String> principals = controlParser.getValues(QueryGetRequest.CONTROL_ADD_ACE_PRINCIPAL);
    if (principals == null) {
        return null;
    }
    List<Ace> aces = new ArrayList<Ace>();
    int i = 0;
    for (String principalId : principals) {
        aces.add(new AccessControlEntryImpl(new AccessControlPrincipalDataImpl(principalId), controlParser.getValues(QueryGetRequest.CONTROL_ADD_ACE_PERMISSION, i)));
        i++;
    }
    return new AccessControlListImpl(aces);
}
Also used : AccessControlEntryImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl) Ace(org.apache.chemistry.opencmis.commons.data.Ace) ArrayList(java.util.ArrayList) AccessControlListImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl) AccessControlPrincipalDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl)

Example 2 with AccessControlPrincipalDataImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl in project copper-cms by PogeyanOSS.

the class CmisRequestParameter method createRemoveAcl.

public Acl createRemoveAcl(ControlParser controlParser, PostRequest request) {
    List<String> principals = controlParser.getValues(QueryGetRequest.CONTROL_REMOVE_ACE_PRINCIPAL);
    if (principals == null) {
        return null;
    }
    List<Ace> aces = new ArrayList<Ace>();
    int i = 0;
    for (String principalId : principals) {
        aces.add(new AccessControlEntryImpl(new AccessControlPrincipalDataImpl(principalId), controlParser.getValues(QueryGetRequest.CONTROL_REMOVE_ACE_PERMISSION, i)));
        i++;
    }
    return new AccessControlListImpl(aces);
}
Also used : AccessControlEntryImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl) Ace(org.apache.chemistry.opencmis.commons.data.Ace) ArrayList(java.util.ArrayList) AccessControlListImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl) AccessControlPrincipalDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl)

Example 3 with AccessControlPrincipalDataImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl in project SearchServices by Alfresco.

the class CMISDataCreatorTest method testCreateLots.

public void testCreateLots() throws Exception {
    Session session = getSession("admin", "admin");
    Folder root = session.getRootFolder();
    String folderNameBase = getRootFolderName();
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    properties.put(PropertyIds.NAME, folderNameBase);
    Folder base = root.createFolder(properties);
    for (int i = 0; i < 10; i++) {
        AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl("" + i + i + i);
        List<String> permissions = new ArrayList<String>(1);
        permissions.add(BasicPermissions.ALL);
        List<Ace> addAces = new ArrayList<Ace>(1);
        addAces.add(new AccessControlEntryImpl(principal, permissions));
        base.addAcl(addAces, AclPropagation.PROPAGATE);
    }
    Thread last = null;
    for (int i = 0; i < 10; i++) {
        Creator creator = new Creator(base.getPath(), i);
        Thread thread = new Thread(creator);
        thread.start();
        last = thread;
    }
    if (last != null) {
        last.join();
    }
    ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
    assertTrue(result.getTotalNumItems() > 0);
// result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
// assertTrue(result.getTotalNumItems() > 0);
}
Also used : AccessControlEntryImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl) Ace(org.apache.chemistry.opencmis.commons.data.Ace) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Folder(org.apache.chemistry.opencmis.client.api.Folder) QueryResult(org.apache.chemistry.opencmis.client.api.QueryResult) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) AccessControlPrincipalDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl) Session(org.apache.chemistry.opencmis.client.api.Session)

Example 4 with AccessControlPrincipalDataImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl in project SearchServices by Alfresco.

the class CMISDataCreatorTest method testCreate.

public void testCreate() {
    Session session = getSession("admin", "admin");
    String folderName = getRootFolderName();
    Folder root = session.getRootFolder();
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    properties.put(PropertyIds.NAME, folderName);
    // create the folder
    Folder newFolder = root.createFolder(properties);
    for (int i = 0; i < 50; i++) {
        AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl("user" + i);
        List<String> permissions = new ArrayList<String>(1);
        permissions.add(BasicPermissions.READ);
        List<Ace> addAces = new ArrayList<Ace>(1);
        addAces.add(new AccessControlEntryImpl(principal, permissions));
        newFolder.addAcl(addAces, AclPropagation.PROPAGATE);
        Map<String, Object> updateProperties = new HashMap<String, Object>();
        updateProperties.put("cm:title", "Update title " + i);
        newFolder.updateProperties(properties);
        if (i % 10 == 0) {
            System.out.println("@ " + i);
        }
    }
    ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
    assertTrue(result.getTotalNumItems() > 0);
    result = session.query("select * from cmis:folder where cmis:name = '" + folderName + "'", false);
    assertTrue(result.getTotalNumItems() > 0);
}
Also used : AccessControlEntryImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl) Ace(org.apache.chemistry.opencmis.commons.data.Ace) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Folder(org.apache.chemistry.opencmis.client.api.Folder) QueryResult(org.apache.chemistry.opencmis.client.api.QueryResult) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) AccessControlPrincipalDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl) Session(org.apache.chemistry.opencmis.client.api.Session)

Aggregations

ArrayList (java.util.ArrayList)4 Ace (org.apache.chemistry.opencmis.commons.data.Ace)4 AccessControlEntryImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl)4 AccessControlPrincipalDataImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl)4 HashMap (java.util.HashMap)2 CmisObject (org.apache.chemistry.opencmis.client.api.CmisObject)2 Folder (org.apache.chemistry.opencmis.client.api.Folder)2 QueryResult (org.apache.chemistry.opencmis.client.api.QueryResult)2 Session (org.apache.chemistry.opencmis.client.api.Session)2 AccessControlListImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl)2