From 6773e2f1ce9c64ad2954b0360dead00447cc038c Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Wed, 11 Mar 2009 00:13:19 +0000 Subject: [PATCH] Compilation fix - Required by a merge that skipped a few revisions - Will merge fine when it eventually gets hit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13543 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web/ui/common/ReportedException.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source/java/org/alfresco/web/ui/common/ReportedException.java b/source/java/org/alfresco/web/ui/common/ReportedException.java index 8fb1488f5a..61dfaf3177 100644 --- a/source/java/org/alfresco/web/ui/common/ReportedException.java +++ b/source/java/org/alfresco/web/ui/common/ReportedException.java @@ -24,6 +24,10 @@ */ package org.alfresco.web.ui.common; +import javax.transaction.UserTransaction; + +import org.alfresco.repo.transaction.RetryingTransactionHelper; + /** * Unchecked exception wrapping an already-reported exception. The dialog code can use this to * detect whether or not to report further to the user. @@ -39,4 +43,24 @@ public class ReportedException extends RuntimeException { super(e); } + + /** + * Throws the given exception if we are still in an active transaction, + * this ensures that we cross the transaction boundary and thus cause + * the transaction to rollback. + * + * @param error The error to be thrown + * @throws Throwable + */ + public static void throwIfNecessary(Throwable error) + { + if (error != null) + { + UserTransaction txn = RetryingTransactionHelper.getActiveUserTransaction(); + if (txn != null) + { + throw new ReportedException(error); + } + } + } }