CMIS Checkin Conflicts with Nuxeo Event Listener Actions

I am using CMIS to connect to a Nuxeo 5.9.5 repository using the atompub binding.

I am experiencing a problem with the CMIS Checkin.

I found that when I remove an event listener that I've customized that checkin uploads work fine, but when the event listener is active, the checkin fails. I'm consistently seeing the following error on checkin from the CMIS client:

org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException:     org.nuxeo.ecm.core.api.ClientException: Failed to check in document c3da9f1e-ae3b-4b23-bf6f-cc06db254efd
    at org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService.checkIn(NuxeoCmisService.java:1871)
    ...
Caused by: org.nuxeo.ecm.core.api.DocumentException: org.nuxeo.ecm.core.storage.StorageException:     Already checked in
at org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession.checkIn(SQLSession.java:846)
at org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocumentLive.checkIn(SQLDocumentLive.java:366)

From what I can see, the REST atompub request for Checkin is routed to the method

NuxeoCMISService.checkIn()

Within that method there is a block of code:

    try {
        coreSession.saveDocument(doc);
        DocumentRef ver = doc.checkIn(option, checkinComment);
        doc.removeLock();
        save();
        objectIdHolder.setValue(getIdFromDocumentRef(ver));
    }

I seem to be having a problem because of the method:

coreSession.saveDocument(doc);

This is what I think is happening in the code: Shortly into the saveDocument() method there is the following call:

notifyEvent(DocumentEventTypes.BEFORE_DOC_UPDATE, docModel, options, null, null, true, true);

That event triggers my listener. I'm listening for the events:

aboutToCreate
beforeDocumentModification

My action then extracts data from the document and maps to properties on the document.

The problem seems to be that doing that will cause the 'dirty' flag to be set for the document since some of the properties have been updated. If the document is dirty, the saveDocument() method then attempts to do a checkin. This is before the actual CMIS checkin happens. After that, the document is no longer checked out and when the actual checkin attempt is tried, it fails because the document is no longer checked out.

When the listener is removed, the extraction action function isn't called, checkins goes through successfully.

I tried also using the documentCreated event instead, but I see the same behavior.

Any suggestions for how to work around this?

0 votes

0 answers

2248 views

ANSWER