<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Access vocabulary from Java in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/access-vocabulary-from-java/m-p/315216#M2217</link>
    <description>&lt;P&gt;Is there any way of accessing a vocabulary via Java code?&lt;/P&gt;</description>
    <pubDate>Thu, 10 Nov 2011 17:57:20 GMT</pubDate>
    <dc:creator>hgonzalez_</dc:creator>
    <dc:date>2011-11-10T17:57:20Z</dc:date>
    <item>
      <title>Access vocabulary from Java</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/access-vocabulary-from-java/m-p/315216#M2217</link>
      <description>&lt;P&gt;Is there any way of accessing a vocabulary via Java code?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2011 17:57:20 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/access-vocabulary-from-java/m-p/315216#M2217</guid>
      <dc:creator>hgonzalez_</dc:creator>
      <dc:date>2011-11-10T17:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Access vocabulary from Java</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/access-vocabulary-from-java/m-p/315217#M2218</link>
      <description>&lt;P&gt;You need to use a &lt;STRONG&gt;Session&lt;/STRONG&gt; (&lt;EM&gt;org.nuxeo.ecm.directory.Session&lt;/EM&gt;) connected to the SQL repository which contains all directories and the &lt;STRONG&gt;DirectoryService&lt;/STRONG&gt; (&lt;EM&gt;org.nuxeo.ecm.directory.api.DirectoryService&lt;/EM&gt;).&lt;/P&gt;
&lt;P&gt;This is a &lt;STRONG&gt;snippet of my code&lt;/STRONG&gt; to create a new directory entry :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    DirectoryService dirService = DirectoryHelper.getDirectoryService();
    if (dirService == null) {
        return;
    }

    DocumentModel entry = null;
    Session dirSession = null;
    int id;
    try {
        dirSession = dirService.open(&amp;lt;VOCABULARY_ID&amp;gt;);
        Map&amp;lt;String, Object&amp;gt; map = new HashMap&amp;lt;String, Object&amp;gt;();
        map.put("id", "1");
        map.put("label", "label.country.france");
        map.put("obsolete", "0");
        map.put("ordering", "0");
        entry = dirSession.createEntry(map);
    } finally {
        if (entry == null) {
            dirSession.close();
            throw new ApplicationException("Can't add reference to the directory &amp;lt;VOCABULARY_ID&amp;gt;");
        } else {
            dirSession.commit();
            dirSession.close();
        }
    }
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just take care to close (or commit) the Session correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2011 18:16:08 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/access-vocabulary-from-java/m-p/315217#M2218</guid>
      <dc:creator>Clément_Lardeur</dc:creator>
      <dc:date>2011-11-10T18:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Access vocabulary from Java</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/access-vocabulary-from-java/m-p/315218#M2219</link>
      <description>&lt;P&gt;Merci, that's it .&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2011 18:21:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/access-vocabulary-from-java/m-p/315218#M2219</guid>
      <dc:creator>hgonzalez_</dc:creator>
      <dc:date>2011-11-10T18:21:02Z</dc:date>
    </item>
  </channel>
</rss>

