Search in sources :

Example 1 with OperationContextImpl

use of org.apache.chemistry.opencmis.client.runtime.OperationContextImpl in project alfresco-remote-api by Alfresco.

the class TestCMIS method testPublicApi110.

@Test
public void testPublicApi110() throws Exception {
    Iterator<TestNetwork> networksIt = getTestFixture().networksIterator();
    final TestNetwork network1 = networksIt.next();
    Iterator<String> personIt = network1.getPersonIds().iterator();
    final String person1Id = personIt.next();
    final String person2Id = personIt.next();
    final List<NodeRef> nodes = new ArrayList<NodeRef>(5);
    // Create some favourite targets, sites, files and folders
    TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() {

        @Override
        public Void doWork() throws Exception {
            String siteName1 = "site" + GUID.generate();
            SiteInformation siteInfo1 = new SiteInformation(siteName1, siteName1, siteName1, SiteVisibility.PUBLIC);
            TestSite site1 = network1.createSite(siteInfo1);
            String siteName2 = "site" + GUID.generate();
            SiteInformation siteInfo2 = new SiteInformation(siteName2, siteName2, siteName2, SiteVisibility.PRIVATE);
            TestSite site2 = network1.createSite(siteInfo2);
            NodeRef nodeRef1 = repoService.createDocument(site1.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), "Test Doc1", "Test Doc1 Title", "Test Doc1 Description", "Test Content");
            nodes.add(nodeRef1);
            NodeRef nodeRef2 = repoService.createDocument(site1.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), "Test Doc2", "Test Doc2 Title", "Test Doc2 Description", "Test Content");
            nodes.add(nodeRef2);
            NodeRef nodeRef3 = repoService.createDocument(site2.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), "Test Doc2", "Test Doc2 Title", "Test Doc2 Description", "Test Content");
            nodes.add(nodeRef3);
            repoService.createAssociation(nodeRef2, nodeRef1, ASSOC_ORIGINAL);
            repoService.createAssociation(nodeRef3, nodeRef1, ASSOC_ORIGINAL);
            site1.inviteToSite(person2Id, SiteRole.SiteCollaborator);
            return null;
        }
    }, person1Id, network1.getId());
    {
        OperationContext cmisOperationCtxOverride = new OperationContextImpl();
        cmisOperationCtxOverride.setIncludeRelationships(IncludeRelationships.BOTH);
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2Id, cmisOperationCtxOverride));
        CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_10, AlfrescoObjectFactoryImpl.class.getName());
        CmisObject o1 = cmisSession.getObject(nodes.get(0).getId());
        List<Relationship> relationships = o1.getRelationships();
        assertEquals(1, relationships.size());
        Relationship r = relationships.get(0);
        CmisObject source = r.getSource();
        CmisObject target = r.getTarget();
        String sourceVersionSeriesId = (String) source.getProperty(PropertyIds.VERSION_SERIES_ID).getFirstValue();
        String targetVersionSeriesId = (String) target.getProperty(PropertyIds.VERSION_SERIES_ID).getFirstValue();
        assertEquals(nodes.get(1).getId(), sourceVersionSeriesId);
        assertEquals(nodes.get(0).getId(), targetVersionSeriesId);
    }
}
Also used : OperationContext(org.apache.chemistry.opencmis.client.api.OperationContext) CmisSession(org.alfresco.rest.api.tests.client.PublicApiClient.CmisSession) TestSite(org.alfresco.rest.api.tests.RepoService.TestSite) ArrayList(java.util.ArrayList) OperationContextImpl(org.apache.chemistry.opencmis.client.runtime.OperationContextImpl) CmisUpdateConflictException(org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException) CmisConstraintException(org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException) CmisPermissionDeniedException(org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException) CmisInvalidArgumentException(org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException) PublicApiException(org.alfresco.rest.api.tests.client.PublicApiException) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInformation(org.alfresco.rest.api.tests.RepoService.SiteInformation) Relationship(org.apache.chemistry.opencmis.client.api.Relationship) TestNetwork(org.alfresco.rest.api.tests.RepoService.TestNetwork) FileableCmisObject(org.apache.chemistry.opencmis.client.api.FileableCmisObject) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) ArrayList(java.util.ArrayList) AbstractList(java.util.AbstractList) List(java.util.List) RequestContext(org.alfresco.rest.api.tests.client.RequestContext) VersionableAspectTest(org.alfresco.repo.version.VersionableAspectTest) Test(org.junit.Test)

Aggregations

AbstractList (java.util.AbstractList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 VersionableAspectTest (org.alfresco.repo.version.VersionableAspectTest)1 SiteInformation (org.alfresco.rest.api.tests.RepoService.SiteInformation)1 TestNetwork (org.alfresco.rest.api.tests.RepoService.TestNetwork)1 TestSite (org.alfresco.rest.api.tests.RepoService.TestSite)1 CmisSession (org.alfresco.rest.api.tests.client.PublicApiClient.CmisSession)1 PublicApiException (org.alfresco.rest.api.tests.client.PublicApiException)1 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 CmisObject (org.apache.chemistry.opencmis.client.api.CmisObject)1 FileableCmisObject (org.apache.chemistry.opencmis.client.api.FileableCmisObject)1 OperationContext (org.apache.chemistry.opencmis.client.api.OperationContext)1 Relationship (org.apache.chemistry.opencmis.client.api.Relationship)1 OperationContextImpl (org.apache.chemistry.opencmis.client.runtime.OperationContextImpl)1 CmisConstraintException (org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException)1 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)1 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)1 CmisPermissionDeniedException (org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException)1