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

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

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:

[java]
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)
.setInput(doc)
.setHeader(Constants.HEADER_NX_SCHEMAS, "*").execute();
[/java]

img
img
img
img

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>