Contribute to "File" core DocumentType to add extra metadata

hi @ all,

I'm tring to add extra data to “File” core DocumentType. To achive this i have created a schema with extra informations. like:

<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://nuxeo.com/schemas/com/nuxeo/myproject/metadata/extra/"
  xmlns:nxs="http://nuxeo.com/schemas/com/nuxeo/myproject/metadata/extra/"
  >

    <xs:element name="test1" type="xs:string"/>
    <xs:element name="test2" type="xs:string"/>   
</xs:schema>

And added a contrib xml file for extend “schema” and “doctype”:

<extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
    <schema name="extra" src="schemas/extra.xsd" prefix="extra" />
  </extension>

  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
    <doctype name="File" extends="Document">
      <schema name="common"/>
      <schema name="uid"/>
      <schema name="dublincore"/>
      <schema name="file"/>
      <schema name="file_schema"/>
      <schema name="files"/>
      <schema name="extra"/>
      <facet name="Versionable"/>
    </doctype>
  </extension>

Also, i have created a new table to add extra metadata and i have added the contrib in the xml file:

  <extension target="org.nuxeo.ecm.directory.sql.SQLDirectoryFactory" point="directories">
    <directory name="myextrametadata">
      <schema>vocabulary</schema>
      <dataSource>java:/nxsqldirectory</dataSource>
      <cacheTimeout>3600</cacheTimeout>
      <cacheMaxSize>1000</cacheMaxSize>
      <table>my_extrametadata</table>
      <idField>id</idField>
      <autoincrementIdField>true</autoincrementIdField>
      <dataFile>directories/myextrametadata-def.csv</dataFile>
      <createTablePolicy>on_missing_columns</createTablePolicy>
    </directory>
  </extension>

I want to add extra metadata that no one (using webinterface) can use, but that can be usable by me via nuxeo automation client. Using a call like:

PropertyMap props = new PropertyMap();
props.set("dc:title","MyTest");
props.set("dc:description", "Descr of my Test");
props.set("extra:test1", "myextrainfo");

nuxeosession.newRequest("Document.Create").setInput(new PathRef(workspacepath)).set("type", "File").set("name", "MyTest").set("properties", props).execute();

But when i try to create a “File” into workspace via Web user interface i have a runtime error with this full stacktrace:

To make more readable the post i have pasted the stacktrace here: http://pastebin.com/7pCzE26Z

Can you help me? There is a way to “extend” metadata for Document Type “File” ? What's my fault?

Thank you!!!

I have followed this nuxeo official howto: http://doc.nuxeo.com/display/NXDOC/How-to+configure+document+types%2C+actions+and+operation+chains#How-toconfiguredocumenttypes,actionsandoperationchains-Extensionofmetadata

2 votes

4 answers

2849 views

ANSWER



Ok, I tried your base schema and doc contribs on a test 5.6 system and they worked.

schema file:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           targetNamespace="http://nuxeo.com/schemas/com/nuxeo/myproject/metadata/extra/"
           xmlns:extra="http://nuxeo.com/schemas/com/nuxeo/myproject/metadata/extra/">

    <xs:element name="test1" type="xs:string" />
    <xs:element name="test2" type="xs:string" />
</xs:schema>

And the schema/doc contrib:

<?xml version="1.0" encoding="UTF-8"?>
<component name="test">

    <require>org.nuxeo.ecm.directory.types</require>
    <require>org.nuxeo.runtime.started</require>

    <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
        <schema name="extra" src="data/schemas/extra.xsd" prefix="extra" />
    </extension>

    <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
        <doctype name="File" extends="Document">
            <schema name="common" />
            <schema name="uid" />
            <schema name="dublincore" />
            <schema name="file" />
            <schema name="files" />
            <schema name="extra" />
            <facet name="Versionable" />
        </doctype>
    </extension>

</component>

I had to remove the “file_schema” schema because I dont have that defined. I created a new File doc and confirmed in Postgres that the extra table is created. So if your contribs look like those above then they are not the issue.

1 votes



I haven't followed either of these examples but I customize File on almost every Nuxeo project so I know that customizing File does work. Do you see any useful errors in the server startup log? Have you turned on additional startup logging (in Nuxeo server in the lib/log4j.xml file uncomment the following… [had to create this as an answer because the XML wouldn't show up in Comment]

  <!-- Uncomment for fragments pre-processing -->
  <!--
  <category name="org.nuxeo.runtime.deployment.preprocessor">
    <priority value="INFO" />
  </category>
  -->

and

  <!-- Uncomment for components registration info -->
  <!--
  <category name="org.nuxeo.runtime.model.impl">
    <priority value="INFO" />
  </category>
  -->
1 votes



have u seen my config file to contrib to "File" DocType and think that all is right? I have enabled the extra logging (thank for info) but i don't have any error or extra info to resolve my issue. same error and, with sdk 5.6, i have this log when i try to reload my bundle:

=== Reloaded Projects on Target Server ===

= Project: test-doc-definition

2012-10-19 17:35:47,539 INFO [org.nuxeo.runtime.reload.ReloadComponent] Before undeploy bundle with name 'com.test.docdefinition'.

= Component Loading Status: Pending: 0 / Unstarted: 0 / Total: 372

2012-10-19 17:35:47,541 INFO [org.nuxeo.runtime.model.impl.ComponentManagerImpl] Unregistering component: service:com.test.docdefinition

2012-10-19 17:35:47,544 INFO [org.nuxeo.runtime.reload.ReloadComponent] Undeploy done.

= Component Loading Status: Pending: 0 / Unstarted: 0 / Total: 371

2012-10-19 17:35:47,545 INFO [org.nuxeo.runtime.reload.ReloadComponent] Flush the JAAS cache

2012-10-19 17:35:48,585 INFO [org.nuxeo.runtime.reload.ReloadComponent] Before deploy bundle for file at '/home/yayo/Documents/proj/test-doc-definition/bin/main'

= Component Loading Status: Pending: 0 / Unstarted: 0 / Total: 371

2012-10-19 17:35:48,591 INFO [org.nuxeo.runtime.model.impl.ComponentManagerImpl] Registering component: service:com.test.docdefinition 2012-10-19 17:35:48,592 INFO [org.nuxeo.runtime.model.impl.ComponentRegistry] Registering component: service:com.test.docdefinition 2012-10-19 17:35:48,592 INFO [org.nuxeo.runtime.model.impl.RegistrationInfoImpl] Component activated: service:com.test.docdefinition

2012-10-19 17:35:48,606 INFO [org.nuxeo.runtime.reload.ReloadComponent] Deploy done for bundle with name 'com.test.docdefinition'.

= Component Loading Status: Pending: 0 / Unstarted: 0 / Total: 372

2012-10-19 17:35:48,607 INFO [org.nuxeo.runtime.reload.ReloadComponent] Install web resources 2012-10-19 17:35:48,607 INFO [org.nuxeo.runtime.reload.ReloadComponent] Reload runtime properties

10/19/2012

I have tried to change config files, redefing the environment, start from new IDE and from new Nuxeo installation. I have double check every config file but, only differences between the example and my component is that my component add extra metadata "hidden" (so can be used only via nuxeo automation not via we user interface) so i don't implemented the new widget and the new layout.

Same error and same problem every time.

10/22/2012

can you share or just send me your config files (bruce@concena.com) and I will have a look later today
10/22/2012

what kind of config file? Every config file i have created are added to the first answer. Are you think that i missed some config file or other stuff to create my contrib bundle? I have followed all the steps from official howto, only the widget creation and user interface is (intentionally) not added because i want access this extra information only via automation client (more general via CMIS)

Thanks

10/23/2012


Try adding a

<?xml version="1.0"?>
<component name="com.concena.test.doctypes.contrib">

    <require>org.nuxeo.runtime.started</require>
    <extension target="....
1 votes



Thanks for your answer…

I have added:

<require>org.nuxeo.runtime.started</require>

with same error.

So i have tried to add:

<require>org.nuxeo.runtime.started</require> <require>org.nuxeo.ecm.core.schema.TypeService</require> <require>org.nuxeo.ecm.directory.sql.SQLDirectoryFactory</require>

But Same error… (also with hot deploy in Nuxeo IDE, stop/start sdk, export jar and deploy to test environment)

I don't know where to look for errors in my code because i have followed all the steps in the official nuxeo howto link added to my question

P.s. Extra info: Version used is 5.5

10/19/2012

Not sure this is it but I would change the namespace in the schema definition

&lt;xs:schema
  xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
  targetNamespace=&quot;http://nuxeo.com/schemas/com/nuxeo/myproject/metadata/extra/&quot;
  xmlns:nxs=&quot;http://nuxeo.com/schemas/com/nuxeo/myproject/metadata/extra/&quot;

xmlns:nxs >> xmlns:extra

10/19/2012

change nxs to extra doesn't solve the problem :(

I think there is an error in the official nuxeo howto

also here (another official doc but about DAM): http://doc.nuxeo.com/display/DAMDOC55/Metadata+Customization the steps are the same and here the "extension" is about the "File" DocType (exactly what i want) but, following this howto i have the same error

10/19/2012

Same error with SDK 5.6
10/19/2012

I haven't followed either of these examples but I customize File on almost every Nuxeo project so I know that customizing File does work. Do you see any useful errors in the server startup log? Have you turned on additional startup logging (in Nuxeo server in the lib/log4j.xml file uncomment the following…

<!– Uncomment for fragments pre-processing –> <!– <category name="org.nuxeo.runtime.deployment.preprocessor">

&lt;priority value=&quot;INFO&quot; /&gt;

</category> –>

and

<!– Uncomment for components registration info –> <!– <category name="org.nuxeo.runtime.model.impl">

&lt;priority value=&quot;INFO&quot; /&gt;

</category> –>

10/19/2012


Ok, confirm that now works for me! So thank you for your time, you are my guru now! :)

I don't know why but i think that in the last part of my test i have missed the “files” schema and all other works broke against this problem. In the meanwhile i have decided to create another File Type but, in my latest test, i have tried to extend “File” (based on my first question) and all works fine :) So:

  1. Duble check every time that all core schema are imported
  2. Enable extra logging
  3. Enable
  4. When you have an exception like this, you miss something [1]
  5. Bruce is always right :)

Thank you!

[1]

Caused by: org.nuxeo.ecm.core.api.WrappedException: Exception: java.lang.NullPointerException. message: null
            at org.nuxeo.ecm.core.api.impl.DataModelImpl.getSchema(DataModelImpl.java:86)
            at org.nuxeo.ecm.core.api.impl.DocumentModelImpl.addDataModel(DocumentModelImpl.java:569)
0 votes