
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.
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" a connector in Anypoint Studio using the instructions in To Install a Connector from Anypoint Exchange.
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:
Studio Visual Editor
-
Click the Global Elements tab at the base of the canvas, then click Create.
-
In the Choose Global Type menu, use the filter to locate and select CMIS, then click OK.
-
Configure the parameters according to the table below.
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
-
Access the Pooling Profile tab to configure any settings relevant to managing multiple connections using a connection pool.
-
Access the Reconnection tab to configure any settings relevant to reconnection strategies that Mule should execute if it loses its connection to CMIS.
-
Click OK to save the global connector configurations.
-
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:
-
Drag the CMIS connector onto the canvas, then select it to open the Properties Editor console.
-
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. -
Save your configurations.
XML Editor
Include the CMIS namespaces in your configuration file:
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:
-
Create a global CMIS element outside and above your flows, using a global configuration code similar to the following:
<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 Set the permissions associated with an object
Apply and aspect to an object and set some properties of that aspect
Apply policies to an object
If applied to a private working copy of a document, the check out will be reversed
Get repository changes
If applied to a private working copy, it performs a check in
Check out the document and return the object ID of the private working copy
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
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
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
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.
Create a folder
Creates a parent/child relationship between two nodes in the repository of the specified relationship object type
Remove an object
Delete a folder and all sub-folders
Navigates the folder structure
Get the permissions associated with an object
Retrieve an object’s version history
Get the policies that are applied to an object
Retrieve list of checked out documents
Retrieves the content stream of a document
Get a CMIS object from the repository and put it into the cache.
Get a CMIS object from the repository and puts it into the cache.
Get the relationships if they have been fetched for an object.
Create a new folder in the repository if it doesn’t already exist.
Get the parent folders of a Fileable CMIS object.
Get the type definition of the given type ID.
Move a Fileable CMIS object from one location to another.
Send a query to the repository.
Get all repositories that are available at the endpoint.
Get information about the CMIS repository, the optional capabilities it supports, and its Access Control information, if applicable.
Update an object’s properties.
Example Use Case
Use the CMIS connector to access an CMIS repository and upload a file to it.

-
Drag an HTTP endpoint into a new flow, and configure it as follows:
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.)
-
Drag the CMIS connector onto the canvas, then select it to open the properties editor console.
-
Click the plus sign next to the Connector Configuration field to add a new global connector configuration:
-
Configure the CMIS global element.
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
-
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:
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)
-
Add a Groovy component to the flow and add the following script text to process the message payload:
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.
-
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.
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 creates any missing intermediate folders in the folder path. By default, the checkbox is de-selected.)
Properties
none
-
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
-
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.
XML Editor
-
Add a
cmis:config
element to your project, then configure its attributes as follows:<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"/>
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
-
Create a Mule flow with an HTTP endpoint, configuring the endpoint as follows:
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="cmis" doc:name="HTTP"/>
Attribute Value exchange-pattern
request-response
host
localhost
port
8081
path
cmis
doc:name
HTTP
-
Configure a cmis:get-or-create-folder-by-path element to create a folder in the CMIS repository.
<cmis:get-or-create-folder-by-path config-ref="CMIS" folderPath="/mule-demo" doc:name="Create Folder"/>
Attribute Value config-ref
CMIS
folderPath
/mule-demo
doc:name
Create Folder
-
Add a scripting:component element
<scripting:component doc:name="Groovy"> <scripting:script engine="Groovy"><![CDATA[import java.io.FileInputStream; return new FileInputStream("/Users/../../image.gif");]]></scripting:script> </scripting:component>
-
Add a cmis:create-document-by-path-from-content element to create a document with the content in the payload:
<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"/>
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)
-
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.
<json:object-to-json-transformer doc:name="Object to JSON"/>
Attribute Value doc:name
Object to JSON (or any other name you prefer)
-
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.
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. |
<?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"
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 Mule Expression Language
-
Learn about Configuring Endpoints
-
Access Public Alfresco CMIS Test Server documentation