IBM Support

HelloCMIS: Developing Content Navigator on Cloud solutions

Technical Blog Post


Abstract

HelloCMIS: Developing Content Navigator on Cloud solutions

Body

With the release of IBM Content Navigator on Cloud, customers are embracing the concept of cloud for managing their documents.  With IBM, they know the documents will be secured and hosted in an enterprise class data center.  As customers increasingly move to cloud, it is increasingly important to move custom solutions to leverage this technology.  IBM Content Navigator on Cloud provides the ECM standard Content Management Interoperability Services (CMIS) API to enable the creation of powerful content management applications.


Connecting a client application
As an industry standard, CMIS offers multiple options for both server and client development. 

Connecting with OpenCMIS:  The Apache Chemistry project (http://chemistry.apache.org/) leverages the CMIS standard and provides client libraries for Java, PHP, Python, and others.  The OpenCMIS client libraries from the Apache project manage the bindings to the server and provide a language specific implementation of the standard.  

Connecting with REST/SOAP:  The Navigator on Cloud offering provides both a CMIS REST and a SOAP interface.  Client developers can use the tools of their choice and manage the connection specifics as an alternative to the OpenCMIS libraries.
 

image

 

The following sample connects to Navigator on Cloud with the Apache OpenCMIS java library.

import java.util.*;
import org.apache.chemistry.opencmis.client.api.*;
import org.apache.chemistry.opencmis.client.runtime.*;
import org.apache.chemistry.opencmis.commons.*;
import org.apache.chemistry.opencmis.commons.data.*;
import org.apache.chemistry.opencmis.commons.enums.*;

public class HelloCMIS {
   public static void main(String args[]){
          // default factory implementation
    SessionFactory factory = SessionFactoryImpl.newInstance();
                
    Map<String, String> parameter = new HashMap<String, String>();
    // user credentials
    parameter.put(SessionParameter.USER, "myAdmin");
    parameter.put(SessionParameter.PASSWORD, "myPassword");
    
       // connection settings
       parameter.put(SessionParameter.ATOMPUB_URL, "http://myServer:9080/fncmis/resources/Service&quot;);
       parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
        
    //list the available repositories
    List repositories = factory.getRepositories(parameter);
    for (int j=0; j<repositories.size(); j++) {
        RepositoryInfo info = (RepositoryInfo) repositories.get(j);
        System.out.println(info.getName());
    }
        
    parameter.put(SessionParameter.REPOSITORY_ID, "ECM");
    // create session
    Session session = factory.createSession(parameter);

 

Once connected, interacting with Navigator on Cloud is straight forward and follows standard ECM patterns.  The Apache Chemistry project contains examples and documentation as well as a set of tools for helping test CMIS-based solutions.  The following small samples show some basic operations.

Read the root folder and list all subfolders:

Folder rootFolder = session.getRootFolder();
listFolderContents(rootFolder);

private void listFolderContents(Folder, folder) {    
   ItemIterable<CmisObject> folderContent = folder.getChildren();
   ItemIterable<CmisObject> page = folderContent.getPage();
        
   Iterator<CmisObject> pageItems = page.iterator();
   while(pageItems.hasNext()) {
      CmisObject item = pageItems.next();
      System.out.println(item.getName() + " (" + item.getId() + ")");
      if ( item instanceof Folder) {
            listFolderContents((Folder) item);
      }
   }        
}

 

Get a specific folder:

//get a specific folder
Folder myFolder = (Folder) session.getObject("idf_134972D5-C571-4161-A61C-00823B095306");

 

The following query will search for folders (from cmis:folder).  To search for documents, search against the cmis:document class.  It is also possible to search against a specific document or folder class.

Execute a Query:

//Search for folders for a specific customer
String queryStmt = "select id, name from ‘CustomerDossier’ where Customer = ‘CNN’";
String queryStmt = "select id, name from cmis:folder where name LIKE 'C%'";
String queryStmt = "select id, name from cmis:document where Customer = ‘CNN’";
ItemIterable<QueryResult> results = session.query(queryStmt, false);
listQueryContents(results);

 

Helpful Resources:

Apache Chemistry openCMIS documentation and libraries

Oasis CMIS Content Management Interoperability Services

CMIS Development Forum - ask questions, get answers.

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSCTJ4","label":"IBM Case Manager"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

UID

ibm11281322