(Nuxeo 5.8) Document ID generation - why cannot provide a custom ID instead of using additional schema like UID?

The documentation suggests using uid:uid attribute to store custom doc ids.

I wonder why it is not possible to provide the main ID attribute value on document creation?

Let's say I have an document created in an external system and that needs to be synchronized with its' projection in nuxeo.

0 votes

1 answers

1742 views

ANSWER



The only way to have a Nuxeo document whose main id (uuid) is user-defined is to use the CoreSession.importDocuments API.

Note that for some Nuxeo configuration (see Id Column Type in the VCS Configuration doc), the id needs to be an integer and database-generated to ensure unicity.

0 votes



thank you!
07/29/2014

I try this function before and after creating document but it doesn't work. So I use the function putContextData of class DocumentModel to specified my ID with the constant IMPORT_BASE_VERSION_ID.

Maybe I forgot parameters to send? What is the correct way to use this function?

07/30/2014

It doesn't seem to work for me either, I'm testing on Nuxeo 5.8 (added the version in the question title).
07/31/2014

@Florent is it up-to-date for nuxeo 5.8? A code sample of calling importDocuments() API? I could not find an example to set Id. Thanks in advance.
08/01/2014

You must create a DocumentModelImpl with the proper id. You have to use the constructor with many args for that. Note that CoreSession.createDocumentModel has a 3-arg signature where the second arg is named "id" but it's a mislabeling, it's actually the "name" here (NXP-14913).
08/05/2014