Skip to content

Commit

Permalink
NXP-30244: Prevent transaction timeout during thumbnail listener
Browse files Browse the repository at this point in the history
  • Loading branch information
bdelbosc committed Mar 23, 2021
1 parent 10932ef commit 9a888e0
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.nuxeo.ecm.platform.ec.notification.NotificationConstants;
import org.nuxeo.ecm.platform.thumbnail.ThumbnailConstants;
import org.nuxeo.runtime.api.Framework;
import org.nuxeo.runtime.transaction.TransactionHelper;

/**
* Thumbnail listener handling creation and update of thumbnail preview on main blob update, for documents holding the
Expand Down Expand Up @@ -94,9 +95,17 @@ protected void processDoc(CoreSession session, DocumentModel doc) {
}
doc.putContextData(THUMBNAIL_UPDATED, true);
session.saveDocument(doc);
newTransaction();
}
}

protected void newTransaction() {
if (TransactionHelper.isTransactionActiveOrMarkedRollback()) {
TransactionHelper.commitOrRollbackTransaction();
}
TransactionHelper.startTransaction();
}

private Blob getManagedThumbnail(DocumentModel doc) {
BlobHolder bh = doc.getAdapter(BlobHolder.class);
if (bh == null) {
Expand Down

0 comments on commit 9a888e0

Please sign in to comment.