Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

!!! DRAFT !!!

OpenCMIS Client API

Info
titleTable of Content
Table of Contents

The OpenCMIS client layer provides an object oriented interface for easy consumption of the underlying CMIS related layers. In addition to the CMIS specification the OpenCMIS client layer introduces a session concept which easily enables applications to get control on the client side cache behavior.

The client layer consists of a client interface, common interfaces and a runtime implementation. The runtime maps the client interface to the provider bindings layer and implements the session cache. All parts are exposed by following packages:

Package

Artifact

Description

org.apache.chemistry.opencmis.client.api

chemistry-opencmis-client-api

Main classes interfaces of the client API

org.apache.chemistry.opencmis.commons.api

chemistry-opencmis-commons-api

Interfaces and classes shared by client and provider client bindings API

org.apache.chemistry.opencmis.client.runtime

chemistry-opencmis-client-impl

Implementation classes of client API including a default implementation of the SessionFactory

The following UML diagram illustrates the main classes of the client API:

Image Modified

  • SessionFactory This interface provides the entry point into the client API and is responsible to create a session object. Additionally it gives access to all repository info exposed by a CMIS providerclient binding. The runtime provides a default implementation for the SessionFactory interface.
  • Session This is the main interfahce interface an application has to work with. A session object is related to a CMIS service provider client binding and is attached to exact one repository. All data that is received through the session interface can be cached in the session object in dependency of the concrete implementation which is behind.
  • Repository Wrapper interface for the CMIS RepositoryInfo service.
  • CmisObject The CmisObject interface represents the CMIS domain object.
  • ObjectType This interface is base for all CMIS domain types like FolderType, DocumentType, PolicyType and RelationTypeRelationshipType. The derived interfaces are not shown in the diagram.
  • Folder This interface represents the CMIS folder object.
  • Document This interface represents the CMIS document object.
  • ContentStream this interface wraps the content stream of a CMIS document.
  • Policy This interface represents the CMIS policy object.
  • Relation Relationship This interface represents the CMIS relation relationship object.

Session and Cache Concepts

The concrete cache strategy depends on the implementation of the session in the client runtime. There are currently two session implementations in consideration:

  1. Persistent Session
  2. Transient Session

A Persistent Session implements a read cache only. That means whenever it makes sense the session will avoid secondary calls to the provider and returns cached data instead. An application can control this behavior at different granularity. A refresh of the session will release all data kept by the session and ensures most actuality of the read data afterwards. On the granularity of a method call an application can bypass the cache or avoid caching by parameterizing an optional operation context. The lifetime of the session can be bound to the application. A stateless application can create a new session for each request. The persistent session strategy enables a very performing access to a CMIS enabled DMS infrastructure.

Sessions

OpenCMIS' central entry point to a CMIS repository is a session. A session controls settings and caches that used across multiple calls and provides access to all CMIS operations and objects.
In order to create a session, the SessionFactory needs a set parameters (see OpenCMIS Session Parameters)A Transient Session extends the persistent session and implements a buffer for all write operations. With that all single write operations are executed lazy during an explicit session save call. Write operations can be reverted by calling the cancel method on the session object. This strategy is not implemented yet.

Example Code

Session Creation - AtomPub

...

Binding

Code Block
titleOpening a Atom Pub Connection
// default factory implementation of client runtime
SessionFactory f = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
		
// user credentials
parameter.put(SessionParameter.USER, "Otto");
parameter.put(SessionParameter.PASSWORD, "****");

// connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://<host>:<port>/cmis/atom");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
parameter.put(SessionParameter.REPOSITORY_ID, "myRepository");
		
// session locale
parameter.put(SessionParameter.LOCALE_ISO3166_COUNTRY, "");
parameter.put(SessionParameter.LOCALE_ISO639_LANGUAGE, "de");
parameter.put(SessionParameter.LOCALE_VARIANT, "");

// create session
Session s = f.createSession(parameter);

Session Creation - Web Services

...

Binding

Code Block
titleOpening a Web Services Connection
// default factory implementation of client runtime
SessionFactory f = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
		
// user credentials
parameter.put(SessionParameter.USER, "Otto");
parameter.put(SessionParameter.PASSWORD, "****");

// connection settings
parameter.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());
parameter.put(SessionParameter.REPOSITORY_ID, "myRepository");
parameter.put(SessionParameter.WEBSERVICES_ACL_SERVICE, "http://<host>:<port>/cmis/services/ACLService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, "http://<host>:<port>/cmis/services/DiscoveryService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, "http://<host>:<port>/cmis/services/MultiFilingService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, "http://<host>:<port>/cmis/services/NavigationService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, "http://<host>:<port>/cmis/services/ObjectService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, "http://<host>:<port>/cmis/services/PolicyService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, "http://<host>:<port>/cmis/services/RelationshipService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, "http://<host>:<port>/cmis/services/RepositoryService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, "http://<host>:<port>/cmis/services/VersioningService?wsdl");
		
// session locale
parameter.put(SessionParameter.LOCALE_ISO3166_COUNTRY, "");
parameter.put(SessionParameter.LOCALE_ISO639_LANGUAGE, "de");
parameter.put(SessionParameter.LOCALE_VARIANT, "");

// create session
Session s = f.createSession(parameter);

Reading Objects - Root Collection

Code Block
titleReading the Root Collection
Folder root = this.session.getRootFolder();

PagingList<CmisObject>ItemIterable<CmisObject> pl = root.getChildren(1);

for (List<CmisObject> cl : pl) {
  for (CmisObject o : clpl) {
    System.out.println(o.getName());
  }
}

Reading Properties - Single Property

Code Block
titleReading a Single Property
ObjectId id = this.session.createObjectId("4711");
Document document = (Document) this.session.getObject(id);
Property<String> p = document.getProperty(CmisPropertiesPropertyIds.OBJECT_ID.value());

String s = p.getValue();

Reading Properties - All Properties

Code Block
titleReading all Properties
ObjectId id = this.session.createObjectId("4711");
Document document = (Document) this.session.getObject(id);
List<Property<?>> l = document.getProperties();
Iterator<Property<?>> i = l.iterator();
while (i.hasNext()) {
  Property<?> p = i.next();
  Object value = p.getValue();
  PropertyType t = p.getType();

  switch (t) {
    case INTEGER:
      Integer n = (Integer) value;
      System.out.println(p.getName() + " = " + n);
      break;
    case STRING:
    [...]
}