Search in sources :

Example 1 with Binding

use of org.alfresco.opencmis.CMISDispatcherRegistry.Binding in project alfresco-remote-api by Alfresco.

the class TestCMIS method testACE3433.

@Test
public void testACE3433() throws Exception {
    final TestNetwork network = getTestFixture().getRandomNetwork();
    NodeRef rootNodeRef = TenantUtil.runAsSystemTenant(new TenantRunAsWork<NodeRef>() {

        @Override
        public NodeRef doWork() throws Exception {
            NodeRef rootNodeRef = repoService.getNodeService().getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
            List<ChildAssociationRef> childAssocs = repoService.getNodeService().getChildAssocsByPropertyValue(rootNodeRef, ContentModel.PROP_TITLE, "Company Home");
            assertEquals(1, childAssocs.size());
            NodeRef companyHomeNodeRef = childAssocs.get(0).getChildRef();
            return companyHomeNodeRef;
        }
    }, network.getId());
    assertNotNull(rootNodeRef);
    // atom
    {
        Binding binding = Binding.atom;
        String url = httpClient.getPublicApiCmisUrl(TenantUtil.DEFAULT_TENANT, binding, "1.1", null);
        Map<String, String> parameters = new HashMap<String, String>();
        // user credentials
        parameters.put(SessionParameter.USER, "admin@" + network.getId());
        parameters.put(SessionParameter.PASSWORD, "admin");
        parameters.put(SessionParameter.ATOMPUB_URL, url);
        parameters.put(SessionParameter.BINDING_TYPE, binding.getOpenCmisBinding().value());
        SessionFactory factory = SessionFactoryImpl.newInstance();
        Repository repository = factory.getRepositories(parameters).get(0);
        String rootFolderId = repository.getRootFolderId();
        assertEquals(rootNodeRef.getId(), rootFolderId);
    }
    {
        Binding binding = Binding.browser;
        String url = httpClient.getPublicApiCmisUrl(TenantUtil.DEFAULT_TENANT, binding, "1.1", null);
        Map<String, String> parameters = new HashMap<String, String>();
        // user credentials
        parameters.put(SessionParameter.USER, "admin@" + network.getId());
        parameters.put(SessionParameter.PASSWORD, "admin");
        parameters.put(SessionParameter.BROWSER_URL, url);
        parameters.put(SessionParameter.BINDING_TYPE, binding.getOpenCmisBinding().value());
        SessionFactory factory = SessionFactoryImpl.newInstance();
        Repository repository = factory.getRepositories(parameters).get(0);
        String rootFolderId = repository.getRootFolderId();
        assertEquals(rootNodeRef.getId(), rootFolderId);
    }
}
Also used : Binding(org.alfresco.opencmis.CMISDispatcherRegistry.Binding) SessionFactory(org.apache.chemistry.opencmis.client.api.SessionFactory) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Repository(org.apache.chemistry.opencmis.client.api.Repository) TestNetwork(org.alfresco.rest.api.tests.RepoService.TestNetwork) ArrayList(java.util.ArrayList) AbstractList(java.util.AbstractList) List(java.util.List) Map(java.util.Map) MimetypeMap(org.alfresco.repo.content.MimetypeMap) HashMap(java.util.HashMap) 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) VersionableAspectTest(org.alfresco.repo.version.VersionableAspectTest) Test(org.junit.Test)

Aggregations

AbstractList (java.util.AbstractList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Binding (org.alfresco.opencmis.CMISDispatcherRegistry.Binding)1 MimetypeMap (org.alfresco.repo.content.MimetypeMap)1 VersionableAspectTest (org.alfresco.repo.version.VersionableAspectTest)1 TestNetwork (org.alfresco.rest.api.tests.RepoService.TestNetwork)1 PublicApiException (org.alfresco.rest.api.tests.client.PublicApiException)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 Repository (org.apache.chemistry.opencmis.client.api.Repository)1 SessionFactory (org.apache.chemistry.opencmis.client.api.SessionFactory)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 CmisUpdateConflictException (org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException)1 Test (org.junit.Test)1