Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

CMIS Connector

Community

The Anypoint™ Connector for Content Management Interoperability Services (CMIS) provides connectivity to CMIS repositories, such as Alfresco and SharePoint. It enables synchronizing data and automating business processes across applications and systems.

Assumptions

This document assumes that you are familiar with Mule, Anypoint™ Connectors, and the Anypoint Studio Essentials. To increase your familiarity with Studio, consider completing one or more Anypoint Studio Tutorials. Further, this page assumes that you have a basic understanding of Mule flows and Mule Global Elements

Prerequisites

For the CMIS connector to work properly in your Mule application, you need the following: 

  • Access to a CMIS repository

  • A community edition of Anypoint™ Studio

Installing the Connector

 You can "test drive" the CMIS connector by installing it in Anypoint Studio. Follow the instructions to link:/anypoint-studio/v/6/[download and launch Anypoint Studio], then follow the steps below to install the connector:  
  1. Open Anypoint Studio, and under the Help menu, select Install New Software.

  2. In the Install menu, click Work with, and click the Anypoint Connectors Update Site.

  3. In the table below the Filter field, click the right arrow next to the Community folder, and select the MuleSoft CMIS Connector Mule Studio Extension check box. Click Next.

  4. Review the details of the item you selected, then click Next.

  5. Select I accept the terms of license agreement, then click Finish.

  6. Click Restart Now to complete the installation.  

Configuring the CMIS Connector

 To use the CMIS connector in your Mule application, you must configure:  
  • A global element for CMIS for use by all the CMIS connectors in your Mule application. For more information, see Mule Global Elements.

  • Parameters of each CMIS connector instance in the application.  

Follow these steps to configure CMIS connector in a Mule application:

  1. Click the Global Elements tab at the base of the canvas, then click Create.

  2. In the Choose Global Type menu, use the filter to locate and select CMIS, then click OK.

  3. Configure the parameters according to the table below.

    config-1

    Parameter Description Default Value

    Name

    Enter a name for the configuration so it can be referenced later by the config-ref parameter in the flow.

     

    Username

    Enter the username for your content repository.

     

    Password

    Enter the password for the CMIS username.

     

    Base Url

    Enter the URL of the SOAP connector.

     

    Repository Id

    Enter the Repository Identity that this connector can access.

     

    Endpoint

    Enter the type of the endpoint: SOAP or ATOMPUB.

    ATOM

    Connection Timeout

    Specify the values for the connection time out.

    10000

    Use Alfresco Extension

    Specify whether the Alfresco Object Factory implementation should be utilized.

    The Aflresco CMIS extension JAR must be included in your Mule application for this configuration to work.

    False

    Cxf Port Provider

    Specify the name of the CXF port provider here. The CMIS connector includes a default implementation.

    org.apache.chemistry.  opencmis.client. bindings.spi.  webservices. CXFPortProvider

    Use Cookies

    Set this option to 'true' if you want to enable cookie support. If you want to implement a custom cookie setting, click the # button to add an expression.

    False

  4. Access the Pooling Profile tab to configure any settings relevant to managing multiple connections using a connection pool.

  5. Access the Reconnection tab to configure any settings relevant to reconnection strategies that Mule should execute if it loses its connection to CMIS.

  6. Click OK to save the global connector configurations.

  7. Return to the Message Flow tab in Studio. 

Configuring the connector in a flow:

Follow these steps to configure the parameters of the CMIS connector in a flow:  

  1. Drag the CMIS connector onto the canvas, then select it to open the Properties Editor console.

  2. Configure these connector parameters:  

    Field Description Default

    Display Name

    Enter a unique label for the connector in your application.

    CMIS

    Connector Configuration

    Select the global CMIS connector element that you just created.

     — 

    Operation

    Select the action this component must perform.

     — 

    Refer to the list of supported operations and their descriptions on the XML Editor tab.
  3. Save your configurations.

Include the CMIS namespaces in your configuration file:


    
            
         
1
2
3
4
5
6
7
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:cmis="http://www.mulesoft.org/schema/mule/cmis"
      xsi:schemaLocation="
               http://www.mulesoft.org/schema/mule/core
               http://www.mulesoft.org/schema/mule/core/current/mule.xsd
               http://www.mulesoft.org/schema/mule/cmis
               http://www.mulesoft.org/schema/mule/cmis/current/mule-cmis.xsd">

Follow these steps to configure a CMIS connector in your application:

  1. Create a global CMIS element outside and above your flows, using a global configuration code similar to the following: 

    
           
                   
                
    1
    
    <cmis:config name="CMIS" doc:name="CMIS" baseUrl="Enter the Base URL of your CMIS endpoint here" password="Enter the passowrd" repositoryId="Enter the CMIS repository ID which the connector needs to connect with" username="Enter CMIS username"/>

Build your application flow, then add a CMIS connector to execute one of the following operations:   

Operation Description

<cmis:apply-acl>

Set the permissions associated with an object

<cmis:apply-aspect>

Apply and aspect to an object and set some properties of that aspect

<cmis:apply-policy>

Apply policies to an object

<cmis:cancel-check-out>

If applied to a private working copy of a document, the check out will be reversed

<cmis:changelog>

Get repository changes

<cmis:check-in>

If applied to a private working copy, it performs a check in

<cmis:check-out>

Check out the document and return the object id of the private working copy

<cmis:create-document-by-id>

Create a new document in the repository where the content comes directly from the payload and the target folder node is specified by an object ID

<cmis:create-document-by-id-from-content>

Create a new document in the repository where the content comes directly from the payload and the target folder node is specified by an object ID

<cmis:create-document-by-path>

Create a new document in the repository where the content comes directly from the payload and the target folder node is specified by a repository path

<cmis:create-document-by-path-from-content>

Create a new document in the repository where the content is specified as the value of the "content" parameter and the target folder node is specified by a repository path.

<cmis:create-folder>

Create a folder

<cmis:create-relationship>

Creates a parent/child relationship between two nodes in the repository of the specified relationship object type

<cmis:delete>

Remove an object

<cmis:delete-tree>

Delete a folder and all sub-folders

<cmis:folder>

Navigates the folder structure

<cmis:get-acl>

Get the permissions associated with an object

<cmis:get-all-versions>

Retrieve an object’s version history

<cmis:get-applied-policies>

Get the policies that are applied to an object

<cmis:get-checkout-docs>

Retrieve list of checked out documents

<cmis:get-content-stream>

Retrieves the content stream of a document

<cmis:get-object-by-id>

Get a CMIS object from the repository and put it into the cache

<cmis:get-object-by-path>

Get a CMIS object from the repository and puts it into the cache

<cmis:get-object-relationships>

Get the relationships if they have been fetched for an object

<cmis:get-or-create-folder-by-path>

Create a new folder in the repository if it doesn’t already exist

<cmis:get-parent-folders>

Get the parent folders of a Fileable CMIS object

<cmis:get-type-definition>

Get the type definition of the given type id.

<cmis:move-object>

Move a Fileable CMIS object from one location to another.

<cmis:query>

Send a query to the repository

<cmis:repositories>

Get all repositories that are available at the endpoint

<cmis:repository-info>

Get information about the CMIS repository, the optional capabilities it supports, and its Access Control information, if applicable

<cmis:update-object-properties>

Update an object’s properties

Example Use Case

Use the CMIS connector to access an CMIS repository and upload a file to it. 

image017

  1. Drag an HTTP endpoint into a new flow, and configure it as follows: 

    http

    Field Value

    Display Name

    HTTP

    Exchange Pattern

    request-response (Default)

    Enable HTTPS

    Leave this option disabled. (If you select this check box, the HTTP over SSL or HTTPS protocol is enabled)

    Host

    localhost

    Port

    8081

    Path

    cmis

    Connector Configuration

    Leave this option empty. (You can use the drop-down list to select a previously created connector configuration for this endpoint, if any.)

  2. Drag the CMIS connector onto the canvas, then select it to open the properties editor console.

  3. Click the sign next to the Connector Configuration field to add a new global connector configuration:

    global+element

  4. Configure the CMIS global element.

    image

    Field Value Default Value

    Name

    CMIS (or any other name you prefer)

     

    Username

    Enter the username for your content repository.

     

    Password

    Enter the password for the CMIS username.

     

    Base Url

    Enter the URL of the SOAP connector.

     

    Repository Id

    Enter the identify of the repository that this connector should access.

     

    Endpoint

    Enter the type of the endpoint. You can leave this field blank for the application to use the default value.

    ATOMPUB

    Connection Timeout

    Specify the values for the connection time out. You can leave this field blank for the application to use the default value.

    10000

    Use Alfresco Extension

    Specify whether the Alfresco Object Factory implementation should be utilized. Leave this field blank for the application to use the default value.

    False

    Cxf Port Provider

    Specify the name of the CXF port provider here. The CMIS connector includes a default implementation.

    org.apache.chemistry. opencmis.client.bindings.spi. webservices.CXFPortProvider

    Use Cookies

    Leave the checkbox deselected to disable the cookie support in the application. Use Cookies field can be used to enable/disable cookie support, and also implement custom cookie settings.

    False

  5. In the properties editor of the CMIS connector, use the Get or create folder by path operation to create a folder in the CMIS repository:

    connector+parameters

    Field Value

    Display Name

    Create Folder

    Connector Configuration

    CMIS

    Operation

    Get or create folder by path

    Folder Path

    /mule-demo (or any other path your prefer)

  6. Add a Groovy component to the flow and add the following script text to process the message payload:

    groovy

    Field Value

    Display Name

    Load File

    Script Text

    import java.io.FileInputStream;

    return new FileInputStream("/Users/../../image.gif");

    Note: This file path specified in the script text need to be changed to point  point to the .gif  file on your local system.
  7. Add another CMIS connector after the Groovy transformer, and use the Create document by path from content operation to create a document with the content in the payload.

    second+cmis

    Field Value

    Display Name

    Create document by path from content (or any other name you prefer).

    Connector Configuration

    <select the global element you create>

    Operation

    Create document by path from content

    Filename

    <Specify the name of the file you want to use>

    Folder Path

    <Specify the path to the file>

    Content Reference

    #[payload]

    Mime Type

    image.gif (Specifies the stream content type)

    Object Type

    cmis:document

    Versioning State

    MAJOR (Specifies the versioning state of the newly created object. Major denotes that the document must be created as a major version)

    Force

    _de-select (_If you select this checkbox, the application will create any missing intermediate folders in the folder path. By default, the checkbox is de-selected.)

    Properties

    none

  8. Add a Object to Json transformer onto the flow to capture the response from the CMIS connector and display it as a HTTP response. 

    ObjecttoJson

    Field Value

    Display Name

    Object to Json

  9. Run the project as a Mule Application (right-click project name, then select Run As > Mule Application).

  10. Navigate to http://localhost:8081/cmis to upload a file to your CMIS repository.

image017

  1. Add a cmis:config element to your project, then configure its attributes as follows:

    
           
                   
                
    1
    
    &lt;cmis:config name="CMIS" doc:name="CMIS" baseUrl="Enter the Base URL of your CMIS endpoint here" password="Enter the passowrd" repositoryId="Enter the CMIS repository ID which the connector needs to connect with" username="Enter CMIS username"/&gt;
    Attribute Value

    name

    CMIS (or any other name you prefer)

    doc:name

    CMIS

    baseUrl

    Enter the Base URL of your CMIS endpoint here

    password

    Enter a CMIS password

    repositoryId

    Enter the CMIS repository ID which the connector needs to connect with

    username

    Enter a CMIS username

  2. Create a Mule flow with an HTTP endpoint, configuring the endpoint as follows:   

    
           
                   
                
    1
    
    &lt;http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="cmis" doc:name="HTTP"/&gt;
    Attribute Value

    exchange-pattern

    request-response

    host

    localhost

    port

    8081

    path

    cmis

    doc:name

    HTTP

  3. Configure a cmis:get-or-create-folder-by-path element to create a folder in the CMIS repository.

    
           
                   
                
    1
    
    &lt;cmis:get-or-create-folder-by-path config-ref="CMIS" folderPath="/mule-demo" doc:name="Create Folder"/&gt;
    Attribute Value

    config-ref

    CMIS

    folderPath

    /mule-demo

    doc:name

    Create Folder

  4. Add a scripting:component element

    
           
                   
                
    1
    2
    3
    4
    
    &lt;scripting:component doc:name="Groovy"&gt;
                &lt;scripting:script engine="Groovy"&gt;&lt;![CDATA[import java.io.FileInputStream;
    return new FileInputStream("/Users/../../image.gif");]]&gt;&lt;/scripting:script&gt;
            &lt;/scripting:component&gt;
  5. Add a cmis:create-document-by-path-from-content element to create a document with the content in the payload.:

    
           
                   
                
    1
    
    &lt;cmis:create-document-by-path-from-content config-ref="CMIS" filename="image.gif" folderPath="/mule-cloud-connector/video-demo" mimeType="image/gif" objectType="cmis:document" versioningState="MAJOR" doc:name="Create document by path from content"/&gt;
    Attribute Value

    config-ref

    CMIS

    filename

    image.gif (or any other filename you like to use)

    folderPath

    Enter the path to the file you specify

    mimeType

    image/gif

    objectType

    cmis:document

    versioningState

    Major

    doc:name

    Create document by path from content (or any other name you prefer)`

  6. Add a json:object-to-json-transformer element to the flow to capture the response from the CMIS connector and display it as an HTTP response. 

    
           
                   
                
    1
    
    &lt;json:object-to-json-transformer doc:name="Object to JSON"/&gt;
    Attribute Value

    doc:name

    Object to JSON (or any other name you prefer)

  7. Run the project as a Mule Application (right-click project name, then select Run As > Mule Application).

  8. Navigate to http://localhost:8081/cmis to upload a file to your CMIS repository.

Example Code

For this code to work in Anypoint Studio, you must provide the credentials for CMIS account. You can either replace the variables with their values in the code, or you can add a file named  mule.properties  in the folder src/main/properties  to provide values for each variable.

         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cmis="http://www.mulesoft.org/schema/mule/cmis" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cmis http://www.mulesoft.org/schema/mule/cmis/current/mule-cmis.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
    <cmis:config name="CMIS" doc:name="CMIS" baseUrl="http://cmis.examplecode.com/service/cmis" password="examplepassword" repositoryId="examplerepositoryId" username="exampleusername"/>
    <flow name="checkFlow1" doc:name="checkFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="cmis" doc:name="HTTP"/>
        <cmis:get-or-create-folder-by-path config-ref="CMIS" folderPath="/mule-demo" doc:name="Create Folder"/>
        <scripting:component doc:name="Groovy">
            <scripting:script engine="Groovy"><![CDATA[import java.io.FileInputStream;
return new FileInputStream("/Users/../../image.gif");]]></scripting:script>         </scripting:component>
        <cmis:create-document-by-path-from-content config-ref="CMIS" filename="image.gif" folderPath="/mule-cloud-connector/video-demo" mimeType="image/gif" objectType="cmis:document" versioningState="MAJOR" doc:name="Create document by path from content"/>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
    </flow> </mule>

See Also

  • Learn more about working with Anypoint Connectors 

  • Learn about http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+MEL[Mule Expression Language] 

  • Learn about Configuring Endpoints 

  • Learn  about http://www.mulesoft.org/documentation/display/current/Studio+Transformers[Studio transformers] 

  • Access http://www.alfresco.com/cmis[Public Alfresco CMIS Test Server] documentation