Nuxeo/Blogs

Industry Insight, Product & Development, Updates.

Archive for the ‘Java’ tag

Next Nuxeo Bug Day: Monday, March 18

without comments

Today is Bug Day!

Our next bug day is coming up next Monday, March 18. If you want to contribute, there are many ways to do so!
For instance, if you have found a bug, and did not find a Jira ticket mentioning it, feel free to open one. The bugs related to Nuxeo Platform are to be filed under NXP, and the bugs related to Nuxeo Studio, NXS. All of the bugs we’ll be working on are tagged with ‘bugday‘.

The tickets that we want to include in the bugday backlog must be:
- Bugs (obviously)
- Quite short to fix (3 hours estimate max)
- User-visible

Now, if you’re a developer and you want to help, this is a nice opportunity to give back to the Nuxeo community. You can take tickets tagged with ‘bugday’ and then submit the fix using GitHub’s pull request. If you’re experiencing difficulties while fixing …

Written by

March 14th, 2013 at 10:30 am

Posted in Product & Development

Tagged with , ,

Using HttpClient properly to avoid CLOSE_WAIT TCP connections

with 4 comments

As I discovered when debugging TCP connections stuck in the CLOSE_WAIT state for one of our customers, we were using HttpClient incorrectly. We’re not alone in this case, as you’ll find out if you google HttpClient CLOSE_WAIT, but it’s very non-intuitive. Even the official tutorial is wrong, so I’m describing the issue here.

Apache HttpClient is usually used like this in basic mode:

But this is not enough.

The issue is that releasing the connection makes it available again to the HttpClient instance, but does not close it, because HTTP 1.1 is used and it can pipeline further requests to the same host:port in the same connection.

Even though the server may have decided to close its end of the connection, on our client side the connection is still open and will stay that way until an attempt to read from it is made (at which point the client will detect that …

Written by

February 26th, 2013 at 6:49 am

[Q&A Friday] How to deploy a contribution on a per method basis?

without comments

Today we have a question from Edgar who asks if it’s possible to deploy a contribution on per method basis? I like this question because the use of the Deploy annotation can be misleading. Here’s why: You can put this annotation on a method and it won’t do anything, which is deeply disturbing to me. That’s because method annotations are never looked for in our JUnit runner (One day I’ll have to fix the target of those annotations).

So if you cannot use the Deploy and LocalDeploy annotations on your method, the question is: How do you deploy bundles or contributions inside them? Well, the proper way to do this is to use the test harness you can inject in your test using the @Inject annotation.

Injection is one of the most important part of our test framework. But, it’s not easy to know what you can/cannot inject. To …

Written by

February 8th, 2013 at 11:55 am

[Monday Dev Heaven] Creating DeckJS Slides in Markdown

without comments

Today we’re going to play with the templating module. It lets you render a document using a template. You can easily install it through our Marketplace. It comes with a bunch of examples to give you an idea of what’s doable. You will also find information in our user guide.

A live example is the last Webinar slide deck. It was written in a Markdown Note document and rendered using a DeckJS based template.

If you want to try it now it’s available in the nuxeo-template-rendering-deckjs bundle. Just copy the jar in the plugins folder and the template and its example should be automatically loaded. Be aware that the pdf conversion will only work if you have PhantomJS (version >= 1.8) installed on your server.

The template document is a regular WebTemplate. You need to import JavaScripts, StyleSheets, images, etc. as document attachments. Then where you usually …

Written by

January 22nd, 2013 at 10:30 am

[Q&A Friday] Document Expiration Notification

with 3 comments

Here’s a very practical question from blaszta:

How can I set an email notification about the impending expiration of a document (let’s say a 3 year contract leased document), 1 month before it expires?

Let’s break this in two parts. First, get the contract that expires in 1 month. Then send the email.

Query the contracts

If you’re looking for specific document like a contract, there’s a good chance you have an easy way to identify one using its type or some metadata. Let’s say all contract documents are of type Contract. If I want all of them I can do the following query:

This gets me all the contract documents, even the deleted ones or different versions of the same document. To avoid this we can add the following parameters:

Now you want to add something that gets you only Contracts that expire in 30 days, no more, …

Written by

January 18th, 2013 at 11:37 am

[Monday Dev Heaven] Extract Metadata from Content File Attachments #2

without comments

Welcome to the second part of the file metadata blog post. Last time I explained the issues I wanted to address and started to code a service for that. Today I’ll try to show you when and how to do the actual mapping.

First comes the “When.” We need to update metadata each time the document is about to be modified or created. So I need a Listener with the following configuration:

I’ve chosen to listen to aboutToCreate and beforeDocumentModification instead of the common documentModified or documentCreated. This way we don’t have to save document again, which could trigger another documentModified hence a loop.

The listener itself is simple. It just calls the mapping service. This is where all the logic is. This way you can call it from somewhere else like an importer or from an operation.

Now that we took care of the “When,” we can handle …

Written by

January 14th, 2013 at 3:26 pm

Next Nuxeo Bug day scheduled Monday, January 7

without comments

Today is Bug Day!

Hi guys, we have a bug day coming up next Monday, January 7. If you want to contribute, there are many ways to do so!
For instance, if you have found a bug, and did not find a Jira ticket mentioning it, feel free to open one. The bugs related to Nuxeo Platform are to be filed under NXP, and the bugs related to Nuxeo Studio, NXS. All of the bugs we’ll be working on are tagged with ‘bugday‘.

Now, if you’re a developer and you want to help, this is a nice opportunity to give back to the Nuxeo community. You can take tickets tagged with bugday and then submit the fix using GitHub’s pull request. If you’re experiencing difficulties while fixing bugs, you can ping us on our IRC channel (#nuxeo on Freenode).

And, if you are in Paris, you can join us at the office …

Written by

January 3rd, 2013 at 3:46 pm

Posted in Product & Development

Tagged with , ,

[Monday Dev Heaven] Extract Metadata from Content File Attachments

with one comment

Today I’m digging out an old question about XMP support in Nuxeo. I’m actually going to widen this a bit and talk about metadata in Nuxeo. A limitation we have these days is the fact that you can only read metadata from a file, not write them. So let’s think about what this means.

A few questions first: do you write back metadata to files when you edit them in Nuxeo? Do you sync everything you can extract from the file? How do you map this to existing document properties? When should you do all of this?

What we need to know is which metadata from which type of file should we extract and/or write back to the file?

So we can define a specific mapping between document properties and file metadata. It will be differentiated by the file mime type, the type of the document and the file’s xPath. …

Written by

December 3rd, 2012 at 10:28 pm

[Q&A Friday] How to view emails stored in Nuxeo via WebDAV

with 2 comments

Today’s question from Karl is about WebDAV. He’s asking about viewing emails stored in Nuxeo via WebDAV. There’s actually two questions here. First one is how do you get the content of an msg file and second one is how do you take control of Document creation via WebDAV.

When you map a drive to Nuxeo using WebDAV, each new file you create there will be created as a File Document in Nuxeo. If you want complete control on how the document is created, you need to implement your own backend. Or at least extend the existing one and override the create file method. Here’s how you do it:

There are some constraints due to the WebDAV model that you have to take into account. The major one is the naming of your document. It must be exactly the same as the hard drive file. It makes the usual FileManager

Written by

November 30th, 2012 at 2:23 pm

[Q&A Friday] How can you know which document properties have been modified?

without comments

A question that’s coming now and then is how do you know which document properties have been changed? I remember someone asking that on Nuxeo Answers but I can’t find the question anymore.

Anyway this can be useful for many things. First example would be thumbnail generation. The thumb is computed from the main document file. If this file changes, we want to update the thumb. To be aware of that change, you need to listen to the right event.

When you save modifications on a doc, several events occur. Some of the most interesting for us are beforeDocumentModification and aboutToCreate. It’s the perfect time to know what properties are going to be modified. These events context are instances of DocumentEventContext, which means we can retrieve the source document where the event occurred. All you have to do next is introspect the document properties to know which one …

Written by

November 23rd, 2012 at 10:33 am