Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • IBM Connections wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 1.0
  • 1.0.x
  • 2.0
  • 2.0.1
  • 2.0.1.1
  • 2.0_media
  • 2.5
  • 2.5_deployment
  • 2.5_media
  • 2.5_performance
  • 3
  • 3.0
  • 3.0.1
  • 3.0.1_media
  • 3.0_media
  • 3_deployment
  • 8.1.1
  • 8.2
  • activities
  • administrators
  • api
  • best_practices
  • blogs
  • bookmarks
  • business_card
  • cluster
  • communities
  • community
  • community_manager
  • connections
  • connections_3
  • connections_301
  • customization
  • customize
  • customizing
  • demos
  • deploying
  • deployment
  • deployments
  • developers
  • dogear
  • Domino
  • Edge server
  • education
  • error messages
  • files
  • forums
  • getting_started
  • Help
  • home
  • home_page
  • homepage
  • how-to
  • HTTP server
  • ibm
  • index
  • installation
  • integration
  • iOS
  • ipad
  • iWidget
  • J2EE
  • javadoc
  • lc3.0
  • learning
  • lotus-connections
  • mml
  • mobile
  • Notes
  • performance
  • person_card
  • Portal
  • portlet
  • portlet_factory
  • profiles
  • proxy server
  • quickr
  • Redbooks
  • rest
  • reverse proxy server
  • Sametime
  • scenarios
  • search
  • security
  • self-paced
  • SSO
  • tags
  • test_infrastructure
  • troubleshooting
  • tuning
  • video
  • VideoFest
  • videos
  • WAI
  • WAS
  • web_seminar
  • WebAppIntegrator
  • WebSphere
  • widgets
  • wikis
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > IBM Redbooks: Customizing IBM Connections 3.0.1 > 9.6 Using the Files CMIS APIs
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

9.6 Using the Files CMIS APIs 

expanded Abstract
collapsed Abstract
No abstract provided.
Previous | Next

The Files CMIS API exposes the Files application data using the Content Management Interoperability Services (CMIS) standard. CMIS is a standard created with the goal of making application code more portable across various Enterprise Content Management (ECM) systems. In fact, any CMIS-compatible application should work with IBM Connections. This page has a list of existing CMIS client applications.

The details of the CMIS standard are outside the scope of this article. For more detailed documentation about the CMIS standard visit the  OASIS CMIS web site.

To use the Files CMIS API, an application first must retrieve the API service document. This document is available at the following location: https://server/files/basic/cmis/my/servicedoc. The following is a sample of the beginning of the service document:
 
<?xml version="1.0" encoding="UTF-8"?>
<app:service xmlns:snx="http://www.ibm.com/xmlns/prod/sn" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" 
        xmlns:cmism="http://docs.oasis-open.org/ns/cmis/messaging/200908/" xmlns:lcmis="http://www.ibm.com/xmlns/prod/sn/cmis" 
        xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app">
    <app:workspace>
        <atom:title type="text">Frank Adams</atom:title>
        <atom:link href="https://server:443/files/basic/opensocial/container" rel="http://www.ibm.com/xmlns/prod/sn/opensocial" type="application/xrds+xml"/>
        <app:collection href="https://server/files/basic/cmis/repository/p%21E514AA26290C91108525688600530CAC/folderc/snx%3Aroot">
            <cmisra:collectionType>root</cmisra:collectionType>
            <atom:title type="text">Root Children Collection</atom:title>
        </app:collection>
        <app:collection href="https://server/files/basic/cmis/repository/p%21E514AA26290C91108525688600530CAC/typesc">
            <cmisra:collectionType>types</cmisra:collectionType>
            <atom:title type="text">Types Children Collection</atom:title>
        </app:collection>
        <app:collection href="https://server/files/basic/cmis/repository/p%21E514AA26290C91108525688600530CAC/checkedout">
            <cmisra:collectionType>checkedout</cmisra:collectionType>
            <atom:title type="text">Checkedout Collection</atom:title>
            <app:accept>application/atom+xml;type=entry</app:accept>
        </app:collection>
        <app:collection href="https://server/files/basic/cmis/repository/p%21E514AA26290C91108525688600530CAC/query">
            <cmisra:collectionType>query</cmisra:collectionType>
            <atom:title type="text">Query Collection</atom:title>
            <app:accept>application/cmisquery+xml</app:accept>
        </app:collection>
        <app:collection href="https://server/files/basic/cmis/repository/p%21E514AA26290C91108525688600530CAC/unfiled">
            <cmisra:collectionType>unfiled</cmisra:collectionType>
            <atom:title type="text">Unfiled Collection</atom:title>
        </app:collection>
        <atom:link href="https://server/files/basic/cmis/repository/p%21E514AA26290C91108525688600530CAC/typesd" 
            rel="http://docs.oasis-open.org/ns/cmis/link/200908/typedescendants" type="application/atom+xml;type=feed"/>
        <atom:link href="https://server/files/basic/cmis/nonce" rel="http://www.ibm.com/xmlns/prod/sn/cmis/nonce" type="text/plain"/>
        
        ....  


Using the service document, an application will then follow the links provided to access the document repository.

The following example uses Apache Abdera to retrieve a list of documents in the My Files collections for a specific user:

 Abdera abdera = new Abdera();
Parser parser = abdera.getParser();

AbderaClient client = new AbderaClient(abdera);
AbderaClient.registerTrustManager();
        
client.addCredentials("https://server", null, null, new UsernamePasswordCredentials("user","password"));
            
ClientResponse resp = client.get("https://server/files/basic/cmis/my/servicedoc");

Document<Service> service_doc = resp.getDocument();
Service service = service_doc.getRoot();
Collection collection = service.getCollection("Frank Adams","Root Children Collection");

URL myFilesUrl = new URL(collection.getResolvedHref().toASCIIString());
resp = client.get(collection.getResolvedHref().toASCIIString());

Document<Element> document = parser.parse(resp.getInputStream());
Feed feed = (Feed)document.getRoot();

List<Entry> entries = feed.getEntries();
resp = client.get(entries.get(0).getLink("down").getHref().toASCIIString());

document = parser.parse(resp.getInputStream());
feed = (Feed)document.getRoot();
entries = feed.getEntries();

for (Entry entry: entries) {
    
    // Using XPath functions to get file information
    XPath xpath = abdera.getXPath();
                
    Map<String,String> ns = new HashMap<String,String>();
    ns.put("atom", "http://www.w3.org/2005/Atom");
    ns.put("app", "http://www.ibm.com/xmlns/prod/sn");
    ns.put("cmisra", "http://docs.oasis-open.org/ns/cmis/restatom/200908/"); 
    ns.put("cmis", "http://docs.oasis-open.org/ns/cmis/core/200908/");
                 
    System.out.println("File name: " + xpath.valueOf("cmisra:object/cmis:properties/cmis:propertyString[@queryName='cmis:name']", entry, ns));
    System.out.println("File size: " + xpath.valueOf("cmisra:object/cmis:properties/cmis:propertyInteger[@queryName='cmis:contentStreamLength']", entry, ns));
} 


When using the Files CMIS API to create or update information in the document repository, the application must first retrieve a nonce token. The nonce token is used to protect against Cross Site RF (CSRF) attacks. The following code example can be used to retrieve the nonce token.
 
 Abdera abdera = new Abdera();

AbderaClient client = new AbderaClient(abdera);
AbderaClient.registerTrustManager();

client.addCredentials("https://server", null, null, new UsernamePasswordCredentials("user","pass"));

String nonceUrl = "https://server/files/basic/cmis/nonce";

resp = client.get(nonceUrl);

StringWriter writer = new StringWriter();
IOUtils.copy(resp.getInputStream(), writer);
String nonce = writer.toString();

// Add the nonce to the request

RequestOptions options = new RequestOptions();
options.addHeader("X-Update-Nonce", nonce);

 
The code examples in this article and other articles in this wiki used the Apache Abdera libraries when working with the API Atom feeds using Java. If you plan to work heavily in the CMIS API, other libraries such as Apache Chemistry may better serve your needs. For more information about Apache Chemistry, visit the project website.
 
Parent topic: 9.0 Using the API

expanded Article information
collapsed Article information
Category:
IBM Redbooks: Customizing IBM Connections 3.0.1
Tags:
Redbooks

This Version: Version 2 November 22, 2011 12:04:45 PM by Amanda J Bauman  IBMer

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (2)
collapsed Versions (2)
Version Comparison     
Version Date Changed by               Summary of changes
This version (2) Nov 22, 2011 12:04:45 PM Amanda J Bauman  
1 Nov 21, 2011 1:14:35 PM Amanda J Bauman  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use