March 18, 2018

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.



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.



Related posts


    1. Giuseppe Urso

      Thanks for your comment Jeff, I updated the code snippet.
      Version of Alfresco is irrelevant here, I had Alfresco 4.1 installed and ready-to-use on my computer, so I used the first environment I had in my hands.

      Anyway this article is only a quick start to introduce the CMIS Session topic, the next step is to try handling a CMIS Session. I would like to implement a CMIS authentication manager for Alfresco using Spring HandlerInterceptor. The offcial wiki of Apache Chemistry says that openCMIS Session is thread-safe. This given me a great deal to think about.

Leave a Reply

Your email address will not be published.