Archive for the ‘Friday Q&A’ tag
Today we have a question from guian who asks how to remove the notification tab in the administration panel for each folder inside:
To answer that question, the first thing you need to know is that a tab is what we call an Action. An action can also be a link (a tab is basically a link styled as a tab) or a button, anything clickable in fact. And as stated in the documentation, you can filter theses actions. Take a look at the filter extension point in Nuxeo Explorer. As you can see there are several ways to filter actions.
Let’s say that the documents where we want to hide the notification tabs are all of a special document type. We could add a filter like this:
The action associated with this filter would not be displayed if the current document type was SpecialDocType. …
Today we have a question from carlosrg and vjoussot who ask how to use a document type defined in Studio when a file is dragged and dropped in Nuxeo. A classic approach would be to override the classic Document Type like File, Picture, Audio or Video. But what happens when you want to keep the original document type? Well, you have to modify the way files are imported on drag and drop.
And the cool thing about this answer is that it comes from brian, another active community member. Here’s what he has to say:
Say you have document types SampleCustomPicture, CustomVideo, and CustomAudio — under “Projects>Advanced Settings>XML Extensions” do “+New” and create an extension with this content:
Kudos to Brian for providing the answer. Now how does it work? Well, when you drag and drop a file in Nuxeo, the plugins extension point is used. It …
Today we have a question from regular Nuxeo Answers user Antoine. He asks how to get logger from within a MVEL script in Nuxeo Studio.
If you are not familiar with MVEL, it’s the script language that we use in Studio. It gives a lot of flexibility when writing operation chains.
When writing those scripts, you have access to certain variables:
- CurrentDate: wrapper for a Calendar instance
- Context: the operation context
- This: the operation input
- Session: the CoreSession
- CurrentUser: Principal wrapper around the user running the chain
- currentUser: CurrentUser alias
- Env: the Framework properties
- Fn: wrapper to the CoreFunctions class
- Document only if the input is a document, wrap the input in a DocumentWrapper
- CurrentDocument: alias to Document
- Documents: only if the input is a list of documents if, wrap them in a DocumentWrapper.
- WorkflowVariables: Available only in a workflow context
- NodeVariables: available only in a workflow
To do this you need to know a little bit about the theme engine:
The next step is to state where you want your resource to be loaded. You need to choose the fragment where you want to have it (a page is made of fragments). If you want it to be loaded in every page, I would suggest you put your resource …
Today we have a question from maumig who asks if there is a way to get a video storyboard through Client Automation or REST API. And as you know the focus on our latest release has been on the REST API. So I’m going to answer today’s question using some of the new features we’ve introduced in this release.
So the first thing I want to show you is how to get a document. We’ve added a bunch of endpoints for resources like document, group, user, operation, and directory, so if you want to retrieve a document, you can either use its ID or path:
This will return a JSON object looking like this:
As you can see we have no information concerning the storyboard. But we do have an empty contextParameters object. It can be filled with other objects using a new extension point:
Today’s question is raised by bledi who asks how to create a group on domain creation. That seems like a legitimate request. His first thought was to create an event handler that would run an operation chain each time a new domain document is created. This is a good solution, providing that you have an operation to allow group creation. Unfortunately, there is no operation that lets you create a group right now. So today I’m going to show you how to add one and use it in Nuxeo Studio.
Creating a new operation in Nuxeo is dead simple, especially using Nuxeo IDE. Just use the operation wizard and it will generate a nice operation skeleton. All you have left to do is fill it with the important business logic. If you have no idea what I m blabbering about, take some time to read the Nuxeo IDE documentation.…
Today’s question is raised by vjoussot: How can we change the default value of the
There is actually a broader topic that we can address here. How can we change the Dublin Core metadata values that are automatically assigned by Nuxeo? Because there are different metadata values that we have chosen to assign automatically and that might not be assigned with what you expect. The
contributors is an example, but it could also be the
creation date, the
modification date, etc. Now I would be careful about this. Some of the Dublin Core metadata are used by other services of Nuxeo. You might change more things than you originally intended. Anyway, “What’s Dublin Core?” you may ask. Here’s what Wikipedia has to say about it:
The Dublin Core metadata terms are a set of vocabulary terms which can be used to describe resources
Had an interesting question today from Raymond asking how to cast variable in Studio. He wants to add two double fields and put the result in another field using Content Automation. While writing your operation parameter, you might not know it but you are actually using the MVEL expression language.
MVEL is a powerful expression language for Java-based applications. It provides a plethora of features and is suited for everything from the smallest property binding and extraction, to full blown scripts. For more information, jump right to the Getting Started Guide.
Again, one of the difficulties while using Nuxeo Studio is to know which EL you can use and when. Bertrand recently wrote a very good explanation for this topic. You have to read this, seriously.
Back to the question now, Raymond was doing the following:
This will be evaluated as a String, resulting in something like “1.0+2.0″…
Today we have a common question asked by sk90:, How can I attach files to documents through REST API?.
In his example, he uses our old REST API based on restlets. This API is deprecated and we now use Content Automation. Following are some examples for doing this.
Java Automation Client
This is an example using nuxeo-automation-client in a unit test. The test deploys a basic Nuxeo in a Jetty. Thanks to the EmbeddedAutomationServerFeature test feature, everything we need is deployed (core doc types, content automation etc…).
The first thing to do is create a File document at the root. Then we create a Blob with the automation-client API. Then comes the Blob.Attach request. Finally we test that the blob has been attached to the document.
PHP Automation Client
Here’s a sample taken from the nuxeo-automation-php-client repository. It lists the available workspaces and lets you choose a file …
Here’s a question that comes back often, asked by bruce: How to add tag capability during drag’n’drop?. Since Thierry added HTML5 drag’n’drop to the Nuxeo Platform, it’s possible to fill in metadata right after the import, and apply them to all the imported documents. But I understand it can be frustrating not being able to add tags. And fortunately the drag’n’drop service for content capture is extensible. The full code sample is available on GitHub.
So here’s how it works. When dragging files in a content view for at least 2 seconds, you’ll be prompted with a Select import operation choice. Those select operations are actually actions. It means you can add as any as you want through the action extension point. These actions have a specific behavior.
The ID of the action must, for instance, be the ID of the operation or the operation chain that …