cancel
Showing results for 
Search instead for 
Did you mean: 

Contribute to "File" core DocumentType to add extra metadata

yayo_
Confirmed Champ
Confirmed Champ

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#H...

1 ACCEPTED ANSWER

bruce_Grant
Elite Collaborator
Elite Collaborator

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.

View answer in original post

13 REPLIES 13

bruce_Grant
Elite Collaborator
Elite Collaborator

Try adding a at the beginning of your contribution to ensure that system defined File is properly overridden... see below

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

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

Thanks for your answer...

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

change nxs to extra doesn't solve the problem

Same error with SDK 5.6

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...

bruce_Grant
Elite Collaborator
Elite Collaborator

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>
  -->

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

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.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.