Sharepoint 2010: REST Atom Service and JAVA

by | May 26, 2011 | Enterprise Content Management, Java, SharePoint | 4 comments


This is the first of two blogs where I demonstrate how to use the openCMIS library from a JAVA client to connect to a CMIS enabled SharePoint site through the REST Atom service of SharePoint. The “lessons learned” and tips I include come from examining MSDN and CMIS documentation, “how to” results from google searches, debugging, and the time honored “trial and error” development methodology!

Accessing SharePoint Site from JAVA Application

The following provides instructions and examples for connecting to and manipulating objects in a CMIS enabled SharePoint 2010 site from a JAVA Application using the Apache Chemistry OpenCMIS[2] API.

SharePoint 2010 Configuration

The OpenCMIS API uses the REST Atom Pub services provided by a CMIS enabled SharePoint site. So the first step is to ensure the SharePoint site of interest is CMIS enabled. MSDN provides guidance for enabling CMIS in a SharePoint site[3] which I also cover in a previous blog “SharePoint 2010 – Implementing CMIS.”

Two other things are needed to connect to the SharePoint site: Authorization Credentials and the GUID of the SharePoint library of interest. CMIS Repositories are mapped to SharePoint Lists and Libraries. Unfortunately a session is based on a particular repository, so you cannot operate in two separate lists or libraries in the same session.

You need to be aware of two additional configurations in the SharePoint 2010 site: User Authorization and Versioning.

Authorization in IIS for the web site needs to match that set for the site in the Central Administration application.

Versioning is set in the SharePoint library settings. Whatever version setting is made must be mirrored in the REST method when adding a new document to the site.

Connecting to SharePoint CMIS Provider

The following is an example of connecting to a SharePoint CMIS Repository and establishing a session with that repository.

import org.apache.chemistry.opencmis.client.api.Repository;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import java.util.HashMap;
import java.util.Map;public class CMISConnect {   public void fillParams()    {//define some values for the connection string
String rest_base = “https://armwssp:2333/_vti_bin/cmis/rest”;
String repository_id =”E8AE6B3A-BAC2-4B4C-B889-BAE76A8142E6?;
String atompub_url = rest_base + “/” + repository_id + “?getRepositoryInfo”;
String username =”username”;
String password = “userpassword”;
//put everything into a HashMap
Map<String, String> parameter = new HashMap<String,String>();
parameter.put(SessionParameter.PASSWORD, password);
parameter.put(SessionParameter.ATOMPUB_URL, atompub_url);
SessionFactory f = SessionFactoryImpl.newInstance();
Repository soleRepository = f.getRepositories(parameter).get(0);
Session session = soleRepository.createSession();




Key things to note:

1) The ATOMPUB_URL session parameter is exactly that prescribed in the MSDN library referenced on the first page.
2) You establish a session on a Repository.
3) Though you can really only see one repository at a time in SharePoint, you have to use the “getRepositories” method and the first item in the list to instantiate the Repository object.

Retrieving SharePoint Library Properties and Capabilities

Now that you have a session you can look at some of the Repository (SharePoint library) properties and capabilities.

RepositoryInfo info = session.getRepositoryInfo();
String myInfo = “CMIS version: ” + info.getCmisVersionSupported()+
“\n Repository ID: ” + info.getId() +
“\n Repository Name: ” + info.getName() +
“\n Product Name: ” + info.getProductName();
RepositoryCapabilities rc = soleRepository.getCapabilities();
String capabilities = twolines + “SUPPORTED CAPABILITIES:” + newline
+ tab + “isAllVersionsSearchableSupported: ” + rc.isAllVersionsSearchableSupported() + newline
+ tab + “isGetDescendantsSupported: ” + rc.isGetDescendantsSupported()+ newline
+ tab + “isGetFolderTreeSupported: ” + rc.isGetFolderTreeSupported()+ newline
+ tab + “isMultifilingSupported: ” + rc.isMultifilingSupported()+ newline
+ tab + “isPwcSearchableSupported: ” + rc.isPwcSearchableSupported()+ newline
+ tab + “isPwcUpdatableSupported: ” + rc.isPwcUpdatableSupported()+ newline
+ tab + “isUnfilingSupported: ” + rc.isUnfilingSupported()+ newline
+ tab + “isVersionSpecificFilingSupported: ” + rc.isVersionSpecificFilingSupported()+ newline
+ tab + “CapabilityContentStreamUpdates: ” + rc.getContentStreamUpdatesCapability() + newline
+ tab + “getChangesCapability: ” + rc.getChangesCapability() + newline
+ tab + “getRenditionsCapability: ” + rc.getRenditionsCapability() + newline
+ tab + “CapabilityQuery: ” + rc.getQueryCapability() + newline
+ tab + “CapabilityJoin: ” + rc.getJoinCapability() + newline
+ tab + “CapabilityAcl: ” + rc.getAclCapability();



CMIS version: 1.0Repository ID: e8ae6b3a-bac2-4b4c-b889-bae76a8142e6
Repository Name: Shared Documents
Product Name: Office SharePoint Server
isAllVersionsSearchableSupported: false
isGetDescendantsSupported: false
isGetFolderTreeSupported: true
isMultifilingSupported: false
isPwcSearchableSupported: true
isPwcUpdatableSupported: true
isUnfilingSupported: false
isVersionSpecificFilingSupported: false
CapabilityContentStreamUpdates: ANYTIME
getChangesCapability: OBJECTIDSONLY
getRenditionsCapability: NONE
CapabilityQuery: BOTHESEPARATE
CapabilityJoin: NONE
CapabilityAcl: MANAGE

Things to note:

1) Getting a RepositoryInfo object was not necessary – the same methods are available to the Repository object.
2) “twolines”, “newline”, and “tab” are public string variables I created for formatting purposes.
3) The “getCapabilities” method of the respository sets the RespositoryCapabilities object, but that object is not iterable, so you have to retrieve the capabilities you are interested in individually.

I hope that I have shown how you can use the Chemistry openCMIS library to connect to a CMIS enabled SharePoint 2010 site through the REST Atom Service and look at some of the SharePoint site’s capabilities.

In my next blog I will show how you how to use the openCMIS library and REST Atom Service to:

  1.  Access and Create Folders
  2. Iterate over SharePoint folders
  3. Add documents to a SharePoint folder.



  1. Tim Lisko


    I would verify the path to CMIS/REST exists and that the library guid invoked is accurate and that the guid is in the format illustrated above.

    That is pretty basic and you probably have already done this, but it is easy to misenter a character.


  2. Tim Lisko


    I would verify the path to CMIS/REST exists and that the library guid invoked is accurate and that the guid is in the format illustrated above.

    That is pretty basic and you probably have already done this, but it is easy to misenter a character.


  3. Brant Benedith

    Thanks for your post. My spouse and i have continually seen that a lot of people are needing to lose weight when they wish to appear slim plus attractive. Even so, they do not generally realize that there are additional benefits just for losing weight as well. Doctors state that over weight people have problems with a variety of health conditions that can be directly attributed to the excess weight. The great thing is that people who are overweight and also suffering from diverse diseases are able to reduce the severity of their own illnesses through losing weight. It is possible to see a gradual but identifiable improvement with health whenever even a negligible amount of weight-loss is accomplished.


Submit a Comment

Your email address will not be published. Required fields are marked *