May 22, 2017

How to create a CMIS session using Apache Chemistry OpenCMIS

CMIS is an OASIS open standard enabling information sharing between different Content Management Systems. The CMIS standard defines a domain model and set of bindings that include Web Services and ReSTful AtomPub that can be used by applications to work with one or more ECM repositories/systems like Sharepoint, Alfresco, Nuxeo, OpenText, Documentum, IBM FileNet and so on.

Apache Chemistry, a project of the Apache Software Foundation, provides open source implementations of the CMIS specification and it allows for building applications on CMIS repositories from both the client and the server sides using a set of API libraries in Java, Python, PHP, .NET and Objective-C. In this article I want to use the Apache Chemistry OpenCMIS Client API to access the Alfresco CMIS-compliant content repository from Java code. The class diagram below shows the high level structure of the OpenCMIS Client API.

giuseppe-urso-create-cimis-session-02

CHECK OUT THE SOURCE CODE

Project skeleton using Maven quickstart archetype

The OpenCMIS Client API dependency declaration in the pom.xml file

The following code snippet shows how to connect to the Alfresco repository using the AtomPub binding. The SessionFactory object, is responsible for creating of the CMIS session. I set up a parameter map that defines the credentials and connection settings for the target URL (user name, authentication, connection URL, binding type, etc.). It’s important to say that some CMIS endpoints, as such as for Alfresco, only provide one repository. In this case it is not necessary to provide its repository id. So it is sufficient get the list of all available repositories and connect to the first one invoking the method get(0).createSession(). In this example I retrieved some Alfresco Repository info over the CMIS session.

 

giuseppe-urso-create-cmis-session-01

Related posts

3 Comments

    1. Giuseppe Urso

      Thanks Jeff for your comment.

      This article is only a simply quick start to introduce the CMIS Session argument, the Alfresco version was indifferent for me. For practicality reasons I used the first Alfresco that I had in my hands…The next step for me is to use the ThreadLocal to hold a CMIS Session. My idea is to create an advanced CMIS Session and authentication manager for Alfresco using ThreadLocal+Spring HandlerInterceptor. The Apache Chemistry wiki reports that openCMIS Session is thread-safe. In this post I used a version of Alfresco 4.1 already installed and ready on my pc, so I used the old ATOMPUB_URL…As you rightly say the new request URL format for Alfresco 4.2 supports the atom binding for the CMIS 1.0 and CMIS 1.1 protocol. To avoid mistakes, I added a comment in the code snippet.
      Thanks for your note.
      Giuseppe

Leave a Reply

Your email address will not be published.