[Q&A Friday] How to Retrieve the List of All Possible Subject Values Using Content Automation


Fri 22 March 2013 By Laurent Doguin


Retrieve the list of all possible subjects values using Content Automation Retrieve the list of all possible subjects 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 important columns that are used by Nuxeo EP to display things like menus and selection lists.


There is a specific operation to retrieve the entries of a vocabulary called Directory.Entries.

Get the entries of a directory. This returns a blob containing a serialized JSON array. The input document, if specified, is used as a context for a potential local configuration of the directory.

Here's a call example using cURL:

curl -H 'Content-Type:application/json+nxrequest' -X POST
-d '{"params":{"directoryName":"topic"}}'
-u Administrator:Administrator http://localhost:8080/nuxeo/site/automation/Directory.Entries
This automation call returns the following JSON array on a default Nuxeo instance:
[ { "id" : "art",
"label" : "label.directories.topic.art",
"obsolete" : 0,
"ordering" : 10000000
},
{ "id" : "human sciences",
"label" : "label.directories.topic.humanscience",
"obsolete" : 0,
"ordering" : 10000000
},
{ "id" : "society",
"label" : "label.directories.topic.society",
"obsolete" : 0,
"ordering" : 10000000
},
{ "id" : "daily life",
"label" : "label.directories.topic.dailylife",
"obsolete" : 0,
"ordering" : 10000000
},
{ "id" : "technology",
"label" : "label.directories.topic.technology",
"obsolete" : 0,
"ordering" : 10000000
}
]

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