How to declare a jdbc used by a vocabulary in Studio ?

In studio, it seems impossible to declare a custom vocabulary (not based on the single data source).

So I choose an arbitrary vocabulary and give in custom properties my directoryName (test)

The bundle is generated as expected

    <properties widgetMode="edit">
      <property name="directoryName">test</property>
    </properties>

and in studio i even have “Directory Name” positionned to “test” (as if it was a studio vocabulary).

That's a real dirty solution !

I also declared an XML extension in studio for my directory :

<extension point="directories" target="org.nuxeo.ecm.directory.sql.SQLDirectoryFactory">
    <directory name="test">
      <schema>vocabulary</schema>
      <dataSource>XXXXX</dataSource>
      <cacheTimeout>3600</cacheTimeout>
      <cacheMaxSize>1000</cacheMaxSize>
      <table>test</table>
      <idField>id</idField>
      <autoincrementIdField>false</autoincrementIdField>
      <createTablePolicy>never</createTablePolicy>
    </directory>
  </extension>

First question : what's the syntax of the datasource element :

a studio vocabulary would be defined as java:/test whereas, according to common contributions to the org.nuxeo.ecm.directory.sql.SQLDirectoryFactory directories extension point, it would be jdbc/test. What's the difference ?

Server side : I tried to declare the mentionned jdbc ressource.

I copied common-base to a custom template

it is deployed after common-base

in server.xml template, I declared a second ressource next to the common datasource :

<Resource name="jdbc/testDS" auth="Container" type="javax.sql.DataSource"
    maxActive="5" maxIdle="30" maxWait="10000" driverClassName="${nuxeo.test.driver}"
    url="${nuxeo.test.jdbc.url}" validationQuery=""
    username="${nuxeo.test.user}" password="${nuxeo.test.password}"
    accessToUnderlyingConnectionAllowed="true" />

In nuxeo.xml template, I delared the ressource link pointing to the global ressource

<ResourceLink name="jdbc/test" global="jdbc/testDS" type="javax.sql.DataSource" />

Finally, I excluded both ressource names from the common datasource in nuxeo.conf

singleDataSource.exclude=jdbc/testDS,jdbc/test

When using the widget, I get the following error :

Caused by: **org.postgresql.util.PSQLException**: ERREUR: la relation « test » n'existe pas

What would be the proper declaration(s) for my directory to work with the data source I declared ?

0 votes

1 answers

1438 views

ANSWER



The solution is to simply create a contribution extending the “datasources” extension point of “org.nuxeo.runtime.datasource”

0 votes