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

CMIS Connector

Community

Introduction

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.

Prerequisites

This document assumes you are familiar with Mule, Anypoint Connectors, and 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 Elements in a Mule Flow and Mule Global Elements.

This document describes implementation examples within the context of Anypoint Studio, Mule ESB’s graphical user interface, and, in parallel, includes configuration details for doing the same in the XML Editor.

Dependencies

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

Compatibility Matrix

Application/Service Version

Mule Runtime

3.5.0 or higher

Apache Chemistry

0.13.0

Alfresco OpenCMIS Extension

1.0

Installing and Configuring

Installing

You can install a connector in Anypoint Studio using the instructions in Installing a Connector from Anypoint Exchange.

Updating From an Older Version

Every time an updated version of a connector is released, Anypoint studio displays a popup in the bottom right corner of your screen with the following message: "Updates Available". To upgrade to the newer version of the Anypoint CMIS connector:

  1. Click the popup and check for available updates.

  2. Select the Anypoint CMIS connector version 2.1.0 checkbox and click Next.

  3. Follow the instructions provided by the user interface.

  4. Restart Studio when prompted. After restarting, if you have several versions of the connector installed, Mule asks you for the version of the connector you would like to use.

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.

    global_config
    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 above CMIS username.

    Base Url

    Enter the URL of the CMIS sandbox instance

    Repository Id

    Enter the Repository Identity that this connector can access. If not provided, the connector will automatically set it to the first if multiple repositories are available

    Endpoint

    Enter the type of the endpoint: SOAP or ATOMPUB.

    ATOM

    Connection Timeout

    Specify the values for the connection time out.

    10000

    Authentication

    Specify authentication provider, supports HTTP basic authentication (STANDARD) and NTLM.

    STANDARD

    Use Alfresco Extension

    Specify whether the Alfresco Object Factory implementation should be utilized. Leave this checkbox deselected 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

    Set this option to 'true' if you want to enable cookie support.

    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.

Connector Operations

The Anypoint CMIS connector is an operation-based connector, which means that when you add the connector to your flow, you need to configure a specific operation the connector is intended to perform. The connector supports 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

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.

     — 

  3. Save your configurations.

Example Use Case

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

Use Case Flow

  1. Drag an HTTP endpoint into a new flow, and add a new HTTP Listener Configuration as follows:

    Field Value

    Display Name

    HTTP

    Host

    localhost

    Port

    8081

    Base Path

    cmis

  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:

  4. Configure the CMIS global element with placeholders defined in mule-app.properties.

    CMIS Global Element Properties

    Field Value Default Value

    Name

    CMIS (or any other name you prefer)

    Base Url

    Enter the URL of the SOAP connector.

    Username

    Enter the username for your content repository.

    Password

    Enter the password for the CMIS username.

    Repository Id

    Enter the ID 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.

    ATOM

    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 checkbox deselected 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:

    CMIS operation parameters

    Field Value

    Display Name

    Create Folder

    Connector Configuration

    CMIS

    Operation

    Get or create folder by path

    Folder Path

    /mule-sample (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 Script

    Field Value

    Display Name

    Load File

    Script Text

    import java.io.FileInputStream;
    return new FileInputStream("../src/test/resources/mule_logo.png");

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

    Create Document By Path Properties

    Field Value

    Display Name

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

    Connector Configuration

    <Select the global element you have created>

    Operation

    Create document by path

    Filename

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

    Folder Path

    <Specify the path to the above-created folder>

    Content Reference

    #[payload]

    Mime Type

    image/png (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

    Deselected (If you check this box, the application will create any missing intermediate folders in the folder path. By default, the checkbox is deselected.)

    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.

    Field Value

    Display Name

    Object to Json

    This completes the use case.

Example Code

For this code to work in Anypoint Studio, you must provide the credentials for the CMIS account. You can either replace the variables with their values in the code, or you can add details to the file named mule-app.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
23
24
25
26
27
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:json="http://www.mulesoft.org/schema/mule/json" 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.6.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/cmis http://www.mulesoft.org/schema/mule/cmis/current/mule-cmis.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <cmis:config name="CMIS" baseUrl="${cmis.baseUrl}" username="${cmis.username}" password="${cmis.password}" endpoint="${cmis.endpoint}" useAlfrescoExtension="true" doc:name="CMIS" />
    <flow name="cmis-exampleFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/cmis" doc:name="HTTP"/>
        <cmis:get-or-create-folder-by-path config-ref="CMIS" doc:name="Get or Create Folder" folderPath="/mule-sample">
        </cmis:get-or-create-folder-by-path>
        <scripting:component doc:name="Load File">
            <scripting:script engine="Groovy"><![CDATA[import java.io.FileInputStream;

return new FileInputStream("../src/test/resources/mule_logo.png");]]></scripting:script> </scripting:component>
        <cmis:create-document-by-path config-ref="CMIS" filename="mule_logo.png" folderPath="/mule-sample" mimeType="image/png" objectType="cmis:document" versioningState="MAJOR" doc:name="Create Document by Path"/>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
    </flow> </mule>

Test the Flow

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

Navigate to http://localhost:8081/cmis to upload a file to your CMIS repository. Once successful, you should be able to view the folder along with the image in your repository.

In the browser you should see JSON text with the ID of the image, for example: {"id":"0ee92f24-2b77-4d83-b0ff-4c86946c81f2;1.0"}

See Also