From ac69d90741fc8e02e1b8114025a9dc925b837d0d Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Wed, 12 Feb 2014 08:12:15 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud) 59882: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (Cloud/4.3) 59607: Merged DEV to V4.2-BUG-FIX 58111: Ensure a transaction is present while initialising the DictionaryRepositoryBootstrap (Repo-based dictionary) (MNT-9806) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62198 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../DictionaryRepositoryBootstrap.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java index 95e899c1f0..36607cc6cf 100644 --- a/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java +++ b/source/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrap.java @@ -36,6 +36,8 @@ import org.alfresco.repo.i18n.MessageService; import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.repo.tenant.TenantDeployer; import org.alfresco.repo.tenant.TenantService; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; @@ -207,12 +209,34 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme // NOOP - will be destroyed directly via DictionaryComponent } - /* - * (non-Javadoc) - * @see org.alfresco.repo.dictionary.DictionaryListener#onInit() + /** + * Initialise the dictionary, ensuring that a transaction is available */ + @Override public void onDictionaryInit() { + RetryingTransactionCallback initCallback = new RetryingTransactionCallback() + { + @Override + public Void execute() throws Throwable + { + onDictionaryInitInTxn(); + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(initCallback, true, false); + } + + /** + * Perform the actual repository access, checking for the existence of a valid transaction + */ + private void onDictionaryInitInTxn() + { + if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_NONE) + { + throw new IllegalStateException("The Repository-based dictionary initialization has to be done in the context of a transaction."); + } + long startTime = System.currentTimeMillis(); if (logger.isTraceEnabled())