mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Added method to check that a read-only or read-write txn is present
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16326 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -172,6 +172,29 @@ public abstract class AlfrescoTransactionSupport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the state of the current transaction and throws an exception if a transaction
|
||||||
|
* is not present or if the transaction is not read-write, if required.
|
||||||
|
*
|
||||||
|
* @param requireReadWrite <tt>true</tt> if the transaction must be read-write
|
||||||
|
*
|
||||||
|
* @since 3.2
|
||||||
|
*/
|
||||||
|
public static void checkTransactionReadState(boolean requireReadWrite)
|
||||||
|
{
|
||||||
|
if (!TransactionSynchronizationManager.isSynchronizationActive())
|
||||||
|
{
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"The current operation requires an active " +
|
||||||
|
(requireReadWrite ? "read-write" : "") +
|
||||||
|
"transaction.");
|
||||||
|
}
|
||||||
|
if (TransactionSynchronizationManager.isCurrentTransactionReadOnly() && requireReadWrite)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("The current operation requires an active read-write transaction.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are there any pending changes which must be synchronized with the store?
|
* Are there any pending changes which must be synchronized with the store?
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user