How to directly change lifecycle state

Hello

Before our customers can work with Nuxeo DM we must import all the xml files and set them to a lifecycle state which is not the initial state. How can we do it ?

We tried setting the property ecm:currentLifeCycleState and using followTransition method but without any success (exceptions encountered).

Thanks

0 votes

2 answers

5835 views

ANSWER



When creating a document through the CoreSession.createDocument(DocumentModel) method, you can set in the DocumentModel context data an indication of which initial lifecycle state it should be in instead of the default.

doc.putContextData(LifeCycleConstants.INITIAL_LIFECYCLE_STATE_OPTION_NAME, "yourInitialState")

BUT note that this is only possible for lifecycle states that have been marked as initial="true" in the lifecycle state definition.

2 votes



Thanks a lot ! That's exactly what I was asking for.
09/28/2012


CoreSession expose the following method: reinitLifeCycleState that move the document to the initial state. Lifecycle is specifically design to manage it through available transitions.

But for mass import I suggest you to use our framework for import explain here. The github repository is here and you can look the project that is well explained.

You can create importer with the number of thread and the frequency for committing , etc…

Hope this will help.

0 votes