Archive for the ‘Monday Dev Heaven’ Category
[Monday Dev Heaven] Add a Forgotten Password Functionality to Nuxeo, Part 1/2
This question is sometimes asked on answers or in the forum. It’s a method to handle password reset for users. So I’m going to show you how I would do it. This is going to be a two part blog. Today I’ll write mostly about the WebEngine module handling the password reset functionality. Next week I’ll show you how to package it for Nuxeo’s Marketplace.
How does it work?
Starting with something simple, we’ll add a ‘forgotten password’ link on Nuxeo’s home page. It will redirect the user to an open (i.e. no authentication needed) page asking for an email address. Once the user submits the form, we’ll look in the user directory to see if the email has a corresponding user. If there’s no user, we’ll simply render the page again with an error message saying there’s no user associated with that email address. If we … Read more
[Monday Dev Heaven] Create Your Own Documents on File Drag and Drop
If you follow this blog you’ll remember I’ve been writing a lot about file import recently. And I have a new trick for you on this matter. When I created the import factory, I took an existing Nuxeo XML export as example. But this could also work with single files. In this case, the importer uses the FileMangerService plugin. The role of this plugin is to create Documents in Nuxeo using a given file.
When the file is imported, Nuxeo goes through each plugin following their processes. If the mime type matches, then it tries to create the document. If it returns null instead of a DocumentModel, the next plugin with a matching mime type is used, and so on. Here is a simple plugin contribution as an example:
<extension
target="org.nuxeo.ecm.platform.filemanager.service.FileManagerService"
point="plugins">
<plugin name="ExportedArchivePlugin"
class="org.nuxeo.ecm.platform.filemanager.service.extension.ExportedZipImporter"
order="10">
<filter>application/zip</filter>
</plugin>
<plugin name="CSVArchivePlugin"
class="org.nuxeo.ecm.platform.filemanager.service.extension.CSVZipImporter"
order="11">
<filter>application/zip</filter>
</plugin>
<plugin name="DefaultFileImporter"
class="org.nuxeo.ecm.platform.filemanager.service.extension.DefaultFileImporter"
order="100">
… Read more
[Monday Dev Heaven] Nuxeo @ First Devoxx France – 2012 Edition
Part of the Nuxeo team attended Devoxx France last week. If you don’t know about Devoxx, It’s an independent Java developer conference. This was the first French edition and I must say it went amazingly well for a first try, so kudos to the 20-person organizing team for pulling this off so smoothly.
We attended many, many different and interesting sessions. There’s a lot to say so I’ll try to be short. And all the sessions will be available on Parleys anyway :)
I’ll start with a very inspiring talk given by Alexandre Bertails: Linked Data – Big Data at Web scale. The web of data is here, and vendors have to step up. Nuxeo is already engaged in it through the Apache Stanbol project. This talk made me want to look more into RDFa, WebID and WebACLs.
There was a lot of interests in new languages. This is … Read more
[Monday Dev Heaven] How to add an HTML preview for iWork Pages files
Last week I got slightly frustrated when I received a .pages file that I could not open with any software on my Ubuntu system. And I could not see a preview on Nuxeo because this format is currently not supported. For those who have never heard about “.pages” files, they are documents made using the Apple iWork Pages application, which has its own format. With the growing population of MacOS users, this will surely happen again. But fear not, because today I will show you how to create your own file converters on a Nuxeo application so that you can, for instance, add an HTML preview for the iWork files without having to install anything on your laptop.
What’s your file’s mime-type?
A first and mandatory step to deal with files in Nuxeo is to be sure you’ll get the right mime-type. I’ve first tried to upload a Pages file into … Read more
[Monday Dev Heaven] Automatic document creation in Nuxeo, Part 2
As I was working on the content template service for my last blog, I saw some things that neeeded to be done. There is an ImportBasedFactory hanging around since basically the beginning of the ContentTemplateService. It has never been implemented. Here’s how we’re gonna do it.
The ImportFactory
The goal of this factory will be to import some content from a file or a folder instead of a templateItem like we saw last week.
To create a new factory, I need a new class that implements the ContentFactory interface. A good thing to know is that there is an abstract class BaseContentFactory that implements the interface and gives a method to handle the CoreSession. So right now the ImportBasedFactory looks like this:
public class ImportBasedFactory extends BaseContentFactory {
public void createContentStructure(DocumentModel eventDoc)
throws ClientException {
throw new UnsupportedOperationException();
}
public boolean initFactory(Map<String, String> options,
List<ACEDescriptor> rootAcl, List<TemplateItemDescriptor> … Read more
[Monday Dev Heaven] Automatic document creation in Nuxeo
Many times you’ll face the need to automatically create a set of documents from different document types. For instance if I create a contract document type, I know this contract will have different child documents like general terms & conditions, specific terms & conditions, purchase order, appendix, etc. Of course, I could let the user create every child document, but that would be inefficient (and not much fun for a tech blog). So let’s see how to create those documents automatically in the Nuxeo Platform.
Introducing the content template service
The content template service documentation that can be found in the Nuxeo Explorer says:
The content template manager service provides factories to automatically create Documents. The factories are used whenever a document is created using EventListener.
It looks like this is what we need for our Contract document structure. This service defines a factoryBinding extension point that lets us specify … Read more
[Monday Dev Heaven] Use Your Nuxeo OpenSocial Gadgets in a Liferay Portal
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 … Read more
[Monday Dev Heaven] How to unit test Nuxeo WebEngine modules
I’ve already written about WebEngine, and I’ve written about unit testing, but I haven’t written about WebEngine AND unit testing. Let’s fix this with a little example. If you don’t already know our testing framework I suggest that you read a previous post on how to test operations or our test framework documentation.
Hello WebEngine
So this is a very simple WebEngine module that returns a String “Hello WebEngine.” And we want to make sure that when we hit the /hello/ url, we get that hello.
@Path("/hello")
@Produces("text/html;charset=UTF-8")
@WebObject(type = "MyRoot")
public class MyRoot extends ModuleRoot {
@GET
public Object doGet() {
return "Hello WebEngine";
}
To make sure this happens, we can set up a unit test that deploys our WebEngine module in a Jetty test server. It’s really easy to do thanks to JUnit4 runners. We’ve written our own that starts Jetty and deploys the necessary … Read more
[Monday Dev Heaven] Multi-threaded, transactional bulk import with Nuxeo
Most Nuxeo developers like toying around with new ideas or concepts. Sometimes the result ends up in a sandbox, sometimes in a new addon, sometimes in the platform. Unfortunately some wicked cool stuff can be left in their sandbox. This doesn’t necessarily mean they lack something or have no value, but more that we had no time to take them to the next step, for instance making a supported package on the Marketplace. Some of these projects have indeed a lot to offer, and are totally compliant with 5.5. So today I’ve decided to exhume nuxeo-importer-scan. I remember using it for a project and found that it was really easy to configure and set up. It’s a bulk import plugin made by our mighty CTO Thierry Delprat. Technically it’s based on nuxeo-platform-importer-core. The way it works is quite simple. When the scanImporter event is fired, it looks into … Read more
[Monday dev heaven] Sharing with the outside world #2: getting your readers’ feedback
The real life example I had in mind last time was about writing and publishing job offers. Staying on the sharing/collaborating trend, we’re going to give the opportunity to users to not only read the job offer but to send feedback to the application. It’s a common need for such a thing. We could easily imagine an application form at the bottom of the page that would collect applications, enter them in Nuxeo with an adhoc document type including resume and cover letter, adhoc content lifecycle including all the required steps (filtering, review, notifications…) up to selections of candidates. But this is a whole HR application and I don’t want to lose you. We will just make a simple thing here for now. We will allow users to simply comment on job offers to illustrate the idea of collecting user-generated feedback, content or … Read more



