New Local Configuration: Directory Service - First step


Wed 08 June 2011 By nuxeo

As you can see from this blog, we're continually improving the Nuxeo Enterprise Platform to allow our users to configure some behaviors locally. Thanks to the new Local Configuration service (formerly known as Placeful Service, RIP), you can now locally set:



  • the theme

  • the document types that can be created into children containers

  • content view

  • advanced search


Today we'll cover how the directory service is evolving: users now have the option to specify locally a suffix that will be used in the context of the container, and its children, that will apply the specific directory desired for these documents.


Let's imagine, I want to change the default "topics" vocabulary for one of my domains. This domain is dedicated to the marketing department and their topics include these categories:



  • Website

  • Campaign

  • Newsletter


So I will create this specific vocabulary and add a suffix, for this example I'll add: "topic_marketing". To contribute this new vocabulary, I follow the normal process of creating a vocabulary:



 <directory name="topic_marketing">
<schema>vocabulary</schema>
<dataSource>java:/nxsqldirectory</dataSource>
<cacheTimeout>3600</cacheTimeout>
<cacheMaxSize>1000</cacheMaxSize>
<table>topic</table>
<idField>id</idField>
<autoincrementIdField>false</autoincrementIdField>
<dataFile>directories/topic_marketing.csv</dataFile>
<createTablePolicy>on_missing_columns</createTablePolicy>
</directory>


I select a document that will support the local directory configuration and choose the domain that will contain all marketing documents:
doc = session.getDocument(new PathRef("/marketing-domain"));
doc.setFacet("SuperSpace");
doc.setFacet("DirectoryLocalConfiguration");
session.saveDocument(doc);
session.save();
Here, these two facets are added dynamically but can be added manually as well into the core type definition :


<doctype name="myDocumentTypeWithConfiguration">
<schema name="hisSchema" />
<facet name="SuperSpace" />
<facet name="DirectoryLocalConfiguration" />
</doctype>


Each child, grandchild, etc. will inherit the configuration I assign to these documents when I attach the "_marketing" suffix to the dedicated domain for the marketing team:


doc = session.getDocument(new PathRef("/marketing-domain"));
doc.setPropertyValue("dirconf:suffix", "marketing");
session.saveDocument(doc);
session.save();

This code tells the Nuxeo application that if a directory exists or is created within the Marketing Domain context, always suffix the directory with "_marketing" (the underscore is automatically added by the service).
What does that means in term of java code :


DirectoryService ds = Framework.getService(DirectoryService.class);
Session session = ds.openSession("topic", currentDocument);
// this will return the "topic_marketing" directory if the currentdocument is child of "/marketing-domain"
// if not, this will return simply the "topic" directory
Session session = ds.openSession("continent", currentDocument);
// this will always return the "continent" directory, even if the currentDocument is a
// child of "/marketing-domain" as I didn't create a "continent_marketing" directory

This improvement is not yet end-user visible, but is viewable by developers through the Java code. This is something we will remedy in a future enhancement, so that users will see from the topic drop down list their locally configured directory. When it's ready, we'll blog about it here...so stay-tuned!


Category: Product & Development