[Q&A Friday] How to Retrieve Custom Metadata with Content Automation

Fri 15 March 2013 By Laurent Doguin

How to retrieve custom metadata with Content Automation 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. If you don't use the header, only the minimum amount of required document properties are returned. To have more properties in the returned document, you can specify a list of document schema names:

X-NXDocumentProperties: dublincore, file

or to have all the document content, you can use the '*' character as the filter value:

X-NXDocumentProperties: *

If you are not familiar with Nuxeo, schemas are used to define lists of metadata.

This is intended for developers who build their own requests. If you're using a content automation client, there's a good chance this is already part of the client API. Here's an example with the Java client:

 import org.nuxeo.ecm.automation.client.Constants;
 import org.nuxeo.ecm.automation.client.adapters.DocumentService;
 import org.nuxeo.ecm.automation.client.model.Documents;
 Documents docs = (Documents) session.newRequest(DocumentService.GetDocumentChildren)
 .setHeader(Constants.HEADER_NX_SCHEMAS, "*").execute();

Category: Product & Development
Tagged: Nuxeo Automation, Q&A