As we know, Alfresco implements Content Management Interoperability Services (CMIS) standard which allows our application to manage content and its metadata in Alfresco repository or in Alfresco cloud.
Here, we will see how we can use Mule to integrate Alfresco into Enterprise Architecture using CMIS.
And mule provides developer tooling RESTful API Modeling Language (RAML) which enables us to build the design-first approach to REST APIs.
We will implement simple HTTP service which gets content metadata from Alfresco as following
- Design and write our API definition in RAML
- Use this RAML file to create simple REST API using Anypoint studio
- Use CMIS connector to connect to Alfresco repository
- Get metadata of given node and display it in JSON format.
Assumption: You
have already installed Alfresco and AnypointStudio.
I have executed this example with Alfresco 4.2.1EE, Mule server 3.5.1 EE
Our URL and Response will look like:
Script URL: http://localhost:8080/mule/test/content/props?nodeRef=c76fe91c-c1f1-45cb-9b75-6742398482a6
Response:
{
"title" : "test
content",
"name" :
"test.ppt",
"creator" :
"admin",
"description" : "My first RAML
file"
}
Write API Definition in RAML:
We will use API web designer to write our RAML file
- Please create API Portal account -http://www.mulesoft.org/documentation/display/current/Setting+Up+Your+API+Portal
- Login in to designer on API Portal - http://api-portal.anypoint.mulesoft.com/raml/api-designer
- Click on New File and give any name to your new raml file. Ex: alfrescoContentMetaData.raml
- Our RAML file contains mainly title, URI, HTTP method – get/post etc… query parameter and response.
- Below is RAML file for our example.
- Once your RAML file is ready you can test it.
- Click on Get which will show Request, Response and Try it tab
- Request shows description and query parameter detail that we have provided in our RAML file
- Response is static response that we have provided as example in RAML file with proper HTTP status code 200 and if any error occurs then 500
- Try it – You can try your script and check its response. Click on GET which will show you Response.
- Once your RAML file is ready then save it on your local drive.
- We are done with RAML file.
Create Mule Project:
We will create a mule project and will import this RAML file which will automatically generate the flow.
- Click on File - New – Mule Project
- Provide name of your project
- Check Add APIkit Component and select From RAML file or URL
- Select RAML file that you have saved in your local drive.
- Click Finish.
- Studio creates new project and it automatically generates Main flow from RAML file and you can check your RAML file under – src/main/api
- In Flows you can see:
- Main Flow with HTTP end point and API Kir Router
- Global exception strategy mappings
- Backend flow for each resource-action pairing
- In backend flow, it initially sets up hard coded parameter and response in payload.
- In Main flow, click on HTTP connector which will open its properties. Click on Advanced tab.
- Check studio has not populated address as per baseUri of our RAML file. Change its values as per RAML file - http://localhost:8080/mule/test/content and save it.
- Let’s first run this project and test in console
- Right click on Project- Run as – Mule Application.
- On startup of server, it will launch APIkit Console.
- You can verify your script same as we did before.
- We are done with importing RAML file and creating flow.
CMIS Connector:
Now, we will implement actual logic for our flow to connect Alfresco using CMIS connector and to get metadata of given content.
Now, we will implement actual logic for our flow to connect Alfresco using CMIS connector and to get metadata of given content.
- In your flow get:/props:alfrescoContentMetaData-config add CMIS connector.
- Open CMIS connector properties window
- In General tab, in Connector Configurations click on plus sign to add Alfresco cmis repository and add properties as following. Here we will use alfresco cmis 1.1
- Name: CMIS [Provide any name]
- UserName: admin
- Password : admin
- BaseURL: http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom
- Repository id: -default-
- Use Alfresco Extension: true [Default value is false. You need to make it true if you need to access alfresco open cmis extension API. Our example will work with true/false both value.]
- Once done Test connection
- If everything is OK then Click on OK
- In Basic Settings, Select Operation – Here we want to get CMIS node object from given nodeId so Select “Get object by Id”
- In General: In object id, we need to provide noderef. You can test it by giving any hard coded noderef of your alfresco’s content . But we want to access it from parameter so give it as below- #groovy:message.getProperty('nodeRef',org.mule.api.transport.PropertyScope.INBOUND)]
- We are done with CMIS connector configurations.
- For testing run your project and hit URL - http://localhost:8080/mule/test/content/props?nodeRef=c76fe91c-c1f1-45cb-9b75-6742398482a6 with actual noderef this will give hard coded JSON response that we have provided in RAML file as I mentioned earlier when we import RAML file, in payload it sets this hardcoded message.
Process CMIS object:
Now we need to Process CMIS object to get required properties as per our JSON response
- CMIS connector and its operation Get object by Id gives us CMIS object
- You can process it with either js like groovy or java. Here I will show you with JAVA
- Add java component as shown in image and add class com.test.mule.alfresco.cmis.content.GetContentProps
- In src/main/java add GetContentProps class and also add ContentPropsBean. Below is source code for both classes.
- GetContentProps class will process CMIS object to get required properties and it will set to instance of ContentPropsBean
- Now add Object to Json transformer as shown in image to get our response in JSON format.
- And also remove/comment payload.
- We are done with our coding. Below is our main Flow.
- Run your mule project.
- Hit mule service with actual noderef. Make sure Alfresco is Up and running : http://localhost:8080/mule/test/content/props?nodeRef=c76fe91c-c1f1-45cb-9b75-6742398482a6
- Verify your JSON response.
You can download source code of this example from GitHub
ReplyDeleteExcellent website. Lots of useful information here, thanks in your effort! . For more information please visit
Mulesoft online training
Merhaba,
DeleteAmaze! I have been looking bing for hours because of this and i also in the end think it is in this article! Maybe I recommend you something helps me all the time?
In my role at MuleSoft, I advise federal agencies and commercial businesses in connecting their applications, data, and devices. Those conversations center around building modern Application Programming Interfaces (APIs) to create new capabilities. A modern API is one that enables systems to exchange information securely using broadly adopted standards like REST and JSON.
These days there are APIs for nearly everything, like an API for your thermostat. I can change the temperature in my house from my phone or my smartwatch using an application that interacts with my thermostat’s API.
By the way do you have any YouTube videos, would love to watch it. I would like to connect you on LinkedIn, great to have experts like you in my connection (In case, if you don’t have any issues).
Please keep providing such valuable information.
Ciao,
Hi Bru,
ReplyDeleteI love all the posts, I really enjoyed.I would like more information about this, because it is very nice., Thanks for sharing.
I wrote about Kerberos support in MuleSoft, so it seems only natural to discuss the other place where Kerberos fits into the API ecosystem. Not only can Kerberos be used to secure APIs hosted or proxied by MuleSoft, but certain third-party systems can use or even require Kerberos for their security.
By the way do you have any YouTube videos, would love to watch it. I would like to connect you on LinkedIn, great to have experts like you in my connection (In case, if you don’t have any issues).
Please keep providing such valuable information.
Merci Beaucoup,
Morgan
the blog is good and Interactive it is about Mulesoft Anypoint Studio it is useful for students and Mulesoft Developers for more updates on Mulesoft mulesoft Online course bangalore
ReplyDeletehi There,
ReplyDeleteNice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long.
I am excited to announce a new version of our open source API console. The 4.0 release comes with a completely new and responsive UI, improved capabilities for trying out your API, and additional tools to integrate automated builds into your CI/CD pipeline.
The API console can be run as a standalone web application or easily integrated into your own website, making it easy to incorporate into an existing developer portal with a fully branded layout.
Awesome! Thanks for putting this all in one place. Very useful!
Shukran,
Irene Hynes
Hello There,
ReplyDeleteGratitude for putting up this prolific article! You truly make everything a cake walk. Genuinely good stuff, saving time and energy.
In the previous blog post of this series on C4E, I discussed using an API-led approach to build software applications. The C4E practice encourages reuse of resources, collaboration with third-party developers and frequent direct interaction with business owners.
During the initial discovery phase, the team recognizes the opportunity to develop a System API that provides an endpoint for retrieving data from a lookup list. The System API also allows for the list to be replaced and updated.
By the way do you have any YouTube videos, would love to watch it. I would like to connect you on LinkedIn, great to have experts like you in my connection (In case, if you don’t have any issues).
Please keep providing such valuable information.
Thank you,
Abhiram
ReplyDeletethe blog is good and Interactive it is about Mulesoft API Developer it is useful for students and Mulesoft Developers for more updates on Mulesoft mulesoft Online training
Really Thanks For Posting Such a Useful Content. Really Thanks For Sharing Such an Informative Post.
ReplyDeleteMulesoft Certification Training
This comment has been removed by the author.
ReplyDeleteThanks for sharing such an awesome blog.
ReplyDeleteMulesoft Online Training
Mulesoft Training in Hyderabad
Good information for mule guys..
ReplyDeleteyou can also visit on https://www.goformule.com for mulesoft examples
ReplyDeleteIt is so nice article thank you for sharing this valuable content
Mulesoft Training in Hyderabad
Mulesoft Online Training
wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
ReplyDeleteoracle training in chennai
oracle training institute in chennai
oracle training in bangalore
oracle training in hyderabad
oracle training
hadoop training in chennai
hadoop training in bangalore
Thanks for sharing valuable information and very well explained. keep posting.
ReplyDeletemulesoft online training in Hyderabad
mulesoft online training in India
An awesome blog for the freshers. Thanks for posting this information.
ReplyDeleteMulesoft Online Training
Mulesoft Online Training in Hyderabad
Great post thanks for posting
ReplyDeletemulesoft training in hyderabad
mulesoft training
Good content. You write beautiful things.
ReplyDeletevbet
hacklink
mrbahis
sportsbet
vbet
sportsbet
mrbahis
hacklink
taksi
Good text Write good content success. Thank you
ReplyDeletekralbet
kibris bahis siteleri
poker siteleri
betpark
slot siteleri
mobil ödeme bahis
bonus veren siteler
betmatik
van
ReplyDeleteyalova
diyarbakır
düzce
gümüşhane
13M
maraş
ReplyDeletebursa
tokat
uşak
samsun
S4OS
manisa
ReplyDeletetunceli
amasya
balıkesir
şırnak
YW5T67
شركة مكافحة القوارض
ReplyDeleteشركة رش مبيدات
çeşme transfer
ReplyDeletesoulmate ajans
bor yağı filtre kağıdı
yağ süzme filtre kağıdı
GL8J
افضل شركة دهانات في ليبيا
ReplyDeleteشركة رش حشرات بالاحساء vt6y7SxVoN
ReplyDelete