05-14-2012 05:03 PM
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
05-15-2012 04:07 AM
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
05-15-2012 10:33 AM
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?
10-08-2012 05:43 PM
After i tried this solution on Nuxeo-dm5.6 i get a HTTP internal 500 error...
05-16-2012 12:22 PM
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.
05-16-2012 06:04 PM
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.
05-17-2012 01:31 PM
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.
05-21-2012 10:18 AM
The Document
object that doPostCreate
receives has APIs like getPropertyValue
that you can use to get values from the document.
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.