Thursday, November 24, 2011

This post aims to be an short how-to for setting up a CMIS development environment based on Maven and Apache Chemistry, specifically the OpenCMIS Java API, part of the Chemistry project.

I won't cover Maven installation and configuration here, so I assume you have Maven 2 or 3 up and running. With Maven you'll be independent from any specific IDE, so that you can manage your development cycle from the command line only.

Glossary

CMIS (Content Management Interoperability Services) =>"is a specification for improving interoperability between Enterprise Content Management systems. OASIS, a web standards consortium, approved CMIS as an OASIS Specification on May 1, 2010. CMIS provides a common data model covering typed files, folders with generic properties that can be set or read. In addition there may be an access control system, and a checkout and version control facility, and the ability to define generic relations. There is a set of generic services for modifying and querying the data model, and several protocol bindings for these services, including SOAP and Representational State Transfer (REST), using the Atom convention. The model is based on common architectures of document management systems."

OpenCMIS => "Apache Chemistry OpenCMIS is a collection of Java libraries, frameworks and tools around the CMIS specification. The goal of OpenCMIS is to make CMIS simple for Java client and server developers. It hides the binding details and provides APIs and SPIs on different abstraction levels. It also includes test tools for content repository developers and client application developers."

Apache Maven => "Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information."

Ingredients

A simple text editor or any decent Java IDE

Maven 2 or 3

A CMIS server for real-world testing

In my case I'm using IntelliJ IDEA, which is excellent. I'm an old Netbeans guy and both IDEs offer superior Maven integration, but it happens that I'm just having a look at IntelliJ these days.

To cover point # 3 I have selected the reference CMIS server implementation so far, which is Alfresco. OpenCMIS offers a basic CMIS server implementation for your self-contained unit tests, but for end-to-end integration testing I prefer to link to a real ECM system.

You can download the latest Alfresco Community Edition for free from here. At present the brand new 4.0 is available.

Setup

Note: I won't cover Alfresco's installation and configuration here because it's not in the scope of this post. You can already find plenty of excellent online resources for that.

Just open a shell, place into a folder and run the following Maven command, to create a very basic Java project through the quickstart archetype:

The pom.xml file is the center of the Maven's universe. We need to edit it for adding a few lines of XML so that we can build with OpenCMIS libraries.
Here is the default pom.xml created by the archetype:

Now that your development environment is ready and you can build both from the shell and the IDE, you can start exploring some examples.

Issuing a mvn clean compile command in your shell will start the process.
If it's the first time you run Maven then it will try to download many dependencies, but don't worry and be patient, all successive runs will be very fast.