Archive for the ‘beginner’ tag
Extend Nuxeo Drive Series #2 – Override existing adapter parameters
Last week I started a series of blog post on how to extend Nuxeo Drive. Today I’ll write about factories and adapters. Every file or folder on the client file system is represented on the server side using adapters. Those adapters are associated to a particular document through a factory.
We can take the default configuration as an example to better understand this.
A look at the default configuration
Using Drive on the client side, the first entry point is the Nuxeo Drive folder. It contains all the documents you have synchronized. This folder is represented on the server side through the DefaultTopLevelFolderItem adapter, and returned by the DefaultTopLevelFolderItemFactory factory. This configuration is declared in the org.nuxeo.drive.service.FileSystemItemAdapterService#topLevelFolderItemFactory extension point:
As you can see, you can change the folderName parameter to something else. Some might prefer ‘My Drive’ or ‘My Nuxeo Files’ as name for your sync documents. The default implementation …
Extend Nuxeo Drive Series #1 – Override Operations
Like most parts of the Nuxeo Platform, we designed Nuxeo Drive as something extensible. And there are indeed different ways you can customize it to fit your needs. I’ll be writing more posts about how to extend Nuxeo Drive in the coming weeks. Today we’ll take a look at what you can do by simply overriding the different operations used by Nuxeo Drive.
Let’s take a very simple example. When Drive detects a conflict, the file is renamed a certain way. This is done using the NuxeoDrive.GenerateConflictedItemName operation. So what we can do is override this operation to specify our own way of renaming a file. Right now what it does is split the name of the file and the extension. Then we generate the contextSection. It’s the user’s first and last name concatenated with the current date formatted as “yyyy-MM-dd hh-mm”. Then it puts them back together.
To …
[Monday Dev Heaven] Nuxeo and Atlassian HipChat Integration
Being big Atlassian fans here at Nuxeo, we recently started using HipChat. It’s an enterprise chat room. One of the cool things about HipChat is its very simple web API. It makes it really easy to send notifications to a chat room.
To show you how dead easy it is, I did a project showing how to send Nuxeo events to a Hipchat room using their web API. I did it using Nuxeo IDE to generate my plugin structure, using the Nuxeo Plugin Project and Nuxeo Listener wizards. My listener only listens to documentCreated and documentModified events. Each time they occur, we send a small message to a HipChat room, containing the URL of the document, its title, date and creator. The code is really simple (especially because most of it is generated by Nuxeo IDE):
What it does is simply relay the modify or create events to a room. …
[Q&A Friday] How to Access a Resource Bundle with MVEL in Content Automation
There’s an interesting question today from milonette, asking how to access labels with MVEL. Sometimes the Content Automation API doesn’t provide everything you need out of the box, hence the question. But the good news is this API is extensible.
While some functions are already available in the automation context, there is currently nothing to access the resource bundles. We’ll need to add our own function into it. This is quite easy to do. First we need to write the new function we need, then we’ll write an operation that adds this function to the content automation context.
Our localized function needs different parameters. We want the locale, the name of the resource bundle, the key of our message and some optional parameters. Here’s a simple implementation:
Now that I have my function, I need to create an operation that will make this available within the automation context:…
[Q&A Friday] Remotely Searching for a Document Using Tags
Today dedacosta asks if it’s possible to search documents remotely using tags. First let’s talk about tags.
The tag service uses two important concepts: a tag object, and a tagging action. Both are represented as Nuxeo documents.
A tag is a document type representing the tag itself (but not its association to specific documents). It contains the usual dublincore schema, and in addition has a specific tag schema containing a tag:label string field.
A tagging is a relation type representing the action of tagging a given document with a tag. (A relation type is a document type extending the default relation document type; it works like a normal document type except that it’s not found by NXQL queries on document). The important fields of a tagging document are relation:source which is the document ID, relation:target which is the tag ID, and dc:creator which is the user doing the
…
[Q&A Friday] How to Retrieve the List of All Possible Subject Values Using Content Automation
Today we have a question from thexman who asks how he can retrieve the list of all possible subject values with content automation. His first thought was to use NXQL, Nuxeo’s query language, which makes perfect sense when you are searching for something. Unfortunately, NXQL is used to search the content of documents, and all the subject values are not stored as documents. The values proposed by Nuxeo when choosing a subject are all stored on what we call a directory. Here’s a definition taken straight from our documentation:
In Nuxeo EP, a directory is a source of (mostly) table-like data that lives outside of the VCS document storage database. A directory is typically a connection to an external data source that is also accessed by processes other than Nuxeo EP itself (therefore allowing shared management and usage).
A vocabulary is a specialized directory with only a few
…
[Q&A Friday] How to Retrieve Custom Metadata with Content Automation
Here’s a question that comes up often: When you retrieve a document using content automation, how do you retrieve custom metadata? This question comes up often mostly because content automation is the preferred way of interacting with Nuxeo from another application. People use it on mobile, directly from Javascript, from another Java app, the PHP client, the python client (Nuxeo Drive is a good example of that), etc.
Now back to the question, how do you retrieve other metadata? The question was about the Android connector but it applies to content automation. The short answer: We have special headers. Here’s the definition straight from the documentation:
This header can be used whenever a document will be returned by the server. The header is forcing the server to fill the returned document up with data from schemas that match the X-NXDocumentProperties filter. So, X-NXDocumentProperties is a filter of schemas.
…
[Q&A Friday] Relative date usage in Nuxeo Studio
Here’s a question about relative date usage in Nuxeo Studio: How do I pass a date, relative to the current date, into a Query Filter?
This is interesting as sometimes you might want to retrieve all documents with an expiration date before today plus 30 days. Or maybe you want to retrieve every document created thirty days ago. You obviously can’t hardcode the date so you have to use something like a @{CurrentDate} object.
Content Automation
If you’re in the content automation context, it’s really straight forward. Most of the operation parameters support the MVEl scripting language. So you have access to any objects like @{CurrentDate}.
Here’s a query that returns the documents that will expire in the next 10 days:
While this retrieves all the documents that have been expired at least 10 days:
Content Views
Unfortunately, this won’t work in a content view. The problem …
[Monday Dev Heaven] Trying IntelliJ IDEA and Nuxeo Platform
Today I’ll write a post a little differently than usual. I won’t write about code per say but about my experience with IntelliJ IDEA. Some of you might be aware that one of our developers has developed an IDEA plugin for Nuxeo, so I decided to give it a try.
First thing I did was import Nuxeo Platform source code using maven. All I had to do was tell IDEA where the root pom and the addon parent pom were. As you know we have many modules so I was expecting this step to take forever. I’m happy to say I was wrong. It went really fast. And I didn’t have to specify my maven repo as an environment variable. What surprised me though is that there is no default JDK, hence there are errors everywher — something fixed quickly using the contextual help. Anyway, it feels great just to …
[Q&A Friday] How to add extra files to a document using Content Automation
Today we have someone asking how to attach extra files to a document using Content Automation. So I’m going to do this using nuxeo-automation-client. This is a jar that you can add as a dependency to your Java application and that gives you a nice API to make content automation call to a Nuxeo server.
I’ve written a small example that opens a Content Automation HTTP session to a local Nuxeo server as Administrator and execute an operation that adds a file to an existing document. Those operations are wrapped in the DocumentService. This class hides part of the complexity to make an operation request. You can take a look at our documentation for the complete details. Now here’s the code sample, most of it is explained in the comments:…