Replacing the topic & subtopic vocabularies in Nuxeo

Hi,

I need to replace the subject field vocabularies by other domain specific tags. I want to do it in a plugin contribution so that it is easier for us to keep several environments in sync.

I have found how to contribute new vocabularies, but I don't know what do I need to override to replace the vanilla topic/subtopic with a custom vocabulary (it will also have 2 level hierarchy).

Anyone may point me in the right direction?

Edit: We are using Nuxeo CAP with DAM (5.6)

Thanks. Jose

0 votes

1 answers

3588 views

ANSWER



Ok. This is what I have done in case it can be useful to someone:

I have overriden the topic and subtopic directories defined in nuxeo-platform-default-config. Like this:

In my plugin, I have created the csv files for topics and subtopics, with the same schemas than the originals (check the source!):

src/main/resources/directories/my-subtopic.csv
src/main/resources/directories/my-topic.csv

Then I have created the contribution file:

OSGI-INF/my-directories-contrib.xml

With this:

<?xml version="1.0"?>
<component name="org.my.ecm.directories"> 
  <require>org.nuxeo.ecm.directories</require>

  <extension target="org.nuxeo.ecm.directory.sql.SQLDirectoryFactory"
    point="directories">

    <directory name="subtopic">
      <schema>xvocabulary</schema>
      <parentDirectory>topic</parentDirectory>
      <dataSource>java:/nxsqldirectory</dataSource>
      <cacheTimeout>3600</cacheTimeout>
      <cacheMaxSize>1000</cacheMaxSize>
      <table>my_subtopic</table>
      <idField>id</idField>
      <autoincrementIdField>false</autoincrementIdField>
      <dataFile>directories/my-subtopic.csv</dataFile>
      <createTablePolicy>on_missing_columns</createTablePolicy>
    </directory>

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

  </extension>

</component>

The table names must be different than the original ones.

Then, in META-INF/MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: my-plugin
Bundle-SymbolicName: org.my.video;singleton:=true
Bundle-Version: 1.0.0
Bundle-Vendor: Me
Bundle-Category: web
Bundle-Localization: plugin
Nuxeo-Component: OSGI-INF/my-directories-contrib.xml
Require-Bundle: org.nuxeo.ecm.default.config

In OSGI-INF/l10n/ I have created the desired l10n properties for the topics and subtopics (must match the keys defined in the csv files), for instance:

OSGI-INF/l10n/messages.properties
OSGI-INF/l10n/messages_en.properties
OSGI-INF/l10n/messages_fr.properties

And finally in OSGI-INF/deployment-fragment.xml:

<?xml version="1.0"?>
<fragment version="1">
    <require>all</require>  
    <install>\
        <unzip from="${bundle.fileName}" to="/" prefix="web">
            <include>/web/nuxeo.war/**</include>
        </unzip>
        <delete path="${bundle.fileName}.tmp" />
        <mkdir path="${bundle.fileName}.tmp" />
        <unzip from="${bundle.fileName}" to="${bundle.fileName}.tmp" />

        <append from="${bundle.fileName}.tmp/OSGI-INF/l10n/messages.properties"
          to="nuxeo.war/WEB-INF/classes/messages.properties" addNewLine="true" />
        <append from="${bundle.fileName}.tmp/OSGI-INF/l10n/messages_en.properties"
          to="nuxeo.war/WEB-INF/classes/messages_en.properties" addNewLine="true" />
        <append from="${bundle.fileName}.tmp/OSGI-INF/l10n/messages_fr.properties"
          to="nuxeo.war/WEB-INF/classes/messages_fr.properties" addNewLine="true" />
        <delete path="${bundle.fileName}.tmp" />
    </install>
</fragment>

Cheers.

1 votes