I don’t know if you have seen the latest news, but Nuxeo is now a certified content source for Liferay. We usually talk a lot about CMIS in the ECM world, but there is also the OpenSocial alternative. It’s not doing the same thing at all, but it is definitely another nice way to integrate the two applications. Usually more widespread in the portal world, it’s available both in Liferay and Nuxeo. So today I’m going to show you how to create and share an OpenSocial gadget from Nuxeo into a Liferay portlet. Follow the guide below and/or just check out the video recording I did.
Creating the Gadget
If you are used to creating OpenSocial gadgets, this is a piece of cake. If not, we have a nice wizard for you in Nuxeo IDE. Let’s run the Automation Gadget Wizard. It gives you all the necessary code to add an OpenSocial gadget that will use the Content Automation API to communicate with Nuxeo.
In that case all we need to do is to replace Document by Contract in the query parameter like this:
java "select * from Contract where ecm:mixinType != 'HiddenInNavigation'"
And modify the displayColumn:
[xhtml] <#include “default-documentlist-layout.ftl”/> [/xhtml]
This is because inside Nuxeo, we use a FreeMarker template with WebEngine to generate the content of the gadget. And why would we do that? There’s a bunch of reasons that you can find on the documentation, but to summarize, it brings better reusability, so you can easily share resources between gadgets. You also have access to a lot of useful variables, like the client and server URLs and the context path of Nuxeo Webapp.
Now the good thing about OpenSocial is that, if developed properly with no local dependencies, your gadgets don’t have to stay in your application. They can go in other OpenSocial containers, like the Liferay Portal.
Sharing the Gadget with Liferay
Sharing a gadget from one app to another is a common requirement when dealing with OpenSocial stuff. Depending on which app you are working with, it can get fairly complicated. The good news is that it’s not so hard to share a gadget from Nuxeo to Liferay. We’ve already dealt with most of the OAuth part in Nuxeo. You just need to create a new consumer in the Admin center. The goal of this consumer is to share a secret between Liferay and Nuxeo so that one user can authenticate to Nuxeo from Liferay using a special key. Take a look at the screencast to get an idea on how to do it.
Notice that you don’t have to take care of the users. Everything is managed via OAuth. That makes it a bit simpler to use than CMIS, where you have to have the exact same users on both Liferay and Nuxeo. This is, of course, a no-brainer when you use a directory for your users and groups.
Going Deeper into the Gadget Code
What we did here was really simple. There are many other things you could do since you can call operation chains or simple operations from a gadget. And you should know that with the Nuxeo IDE, it’s dead easy to create new operations.