cancel
Showing results for 
Search instead for 
Did you mean: 

How to import a document and put it in Nuxeo in version 12 as initial version?

maxr_
Champ on-the-rise
Champ on-the-rise

As part of the migration of existing documents in Nuxeo, we have to manage documents that already have an existing version.

How to import a document and put it in Nuxeo in version 12? Is it possible without having to click 12 times on "Increment major version"?

Do you have some hints to help us to developing this feature?

Thanks a lot

7 REPLIES 7

Wojciech_Sulejm
Star Contributor
Star Contributor

You can use Nuxeo's extension system to do that just that. For instance you could create a file called

versioning-override-config.xml

in the following location:

<NUXEO_HOME>/nxserver/config

Then fill it with the following contents:

  <?xml version="1.0"?>
   <component name="org.nuxeo.ecm.platform.versionoverride" version="1.0">
     <extension target="org.nuxeo.ecm.core.versioning.VersioningService" point="versioningRules">
       <defaultVersioningRule>
         <initialState major="12" minor="0" />
        </defaultVersioningRule>
      </extension>
   </component>

and restart your server.

You can find more documentation and other possible applications of the versioning service: here

This solution will put each new documents in version 12. We need to be able to choose the initial version when we import the documents. Do you have other ideas?

After i tried this solution on Nuxeo-dm5.6 i get a HTTP internal 500 error...

Laurent_Doguin
Star Collaborator
Star Collaborator

So you have two possible solution here.

You can filter the versioning rule per document if that's enough for you. Every document of this type will start with version defined in the versioning rule.

    <versioningRule typeName="File" enabled="true">
     <initialState major="12" minor="0" />
    </versioningRule>

This way every File document start with version 12.0 . You can always remove this contribution after the import.

Another solution would be to define your own versioningService. This way you can override the doPostCreate called every time a document is created by the method CoreSession#createDocument(DocumentModel) . The option Map it takes as parameter is the one from DocumentModel#getContextData . You can define your own versioningService with a contribution like this:

<extension target="org.nuxeo.ecm.core.versioning.VersioningService" point="versioningService">
    <service class="yourVersioningservice" />
</extension>

Hope it helps.

I overwrite doPostCreate method from VersioningService class. I am able to change the version of the document with a hard coded value. I want to retrieve a value from a field in create_document view. Options parameters doesn't contains anything about context data. Thanks a lot. I am new to nuxeo development.

Just to be clear, each document that I import doesn't have the same version number. I need to have a way to chose the version number when I import it. I don't want to click X times on "Increment major version" to go to version X. Thanks.

The Document object that doPostCreate receives has APIs like getPropertyValue that you can use to get values from the document.

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.