From 6cf3584770d309d4116103d0ea83dfbadcf84b28 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Wed, 2 Apr 2014 20:08:56 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud) 64841: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (4.3/Cloud) 64800: Skeleton fix for MT upgrade running while default tenant holds open a transaction (MNT-10881) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@66202 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/admin/patch/AbstractPatch.java | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java index 7c536ee7b9..792c3cc412 100644 --- a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java @@ -430,16 +430,34 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher } } - private String applyImpl() throws Exception + private String applyWithTxns() throws Exception { - // downgrade integrity checking - IntegrityChecker.setWarnInTransaction(); - if(logger.isDebugEnabled()) { logger.debug("call applyInternal for main context id:" + id); } - String report = applyInternal(); + RetryingTransactionCallback patchWork = new RetryingTransactionCallback() + { + public String execute() throws Exception + { + // downgrade integrity checking + IntegrityChecker.setWarnInTransaction(); + + return applyInternal(); + } + }; + StringBuilder sb = new StringBuilder(128); + if (requiresTransaction()) + { + // execute in a transaction + String temp = transactionService.getRetryingTransactionHelper().doInTransaction(patchWork, false, true); + sb.append(temp); + } + else + { + String temp = applyInternal(); + sb.append(temp); + } if ((tenantAdminService != null) && tenantAdminService.isEnabled() && applyToTenants) { @@ -483,7 +501,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher logger, 1000); - BatchProcessWorker worker = new BatchProcessWorker() + BatchProcessWorker worker = new BatchProcessWorker() { @Override public String getIdentifier(Tenant entry) @@ -501,6 +519,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher public void process(Tenant entry) throws Throwable { String tenantDomain = entry.getTenantDomain(); + @SuppressWarnings("unused") String tenantReport = AuthenticationUtil.runAs(new RunAsWork() { public String doWork() throws Exception @@ -518,6 +537,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher }; // Now do the work + @SuppressWarnings("unused") int numberOfInvocations = batchProcessor.process(worker, true); if (logger.isDebugEnabled()) @@ -527,16 +547,16 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher if (batchProcessor.getTotalErrors() > 0) { - report = report + "\n" + " and failure during update of tennants total success: " + batchProcessor.getSuccessfullyProcessedEntries() + " number of errors: " +batchProcessor.getTotalErrors() + " lastError" + batchProcessor.getLastError(); + sb.append("\n" + " and failure during update of tennants total success: " + batchProcessor.getSuccessfullyProcessedEntries() + " number of errors: " +batchProcessor.getTotalErrors() + " lastError" + batchProcessor.getLastError()); } else { - report = report + "\n" + " and successful batch update of " + batchProcessor.getTotalResults() + "tennants"; + sb.append("\n" + " and successful batch update of " + batchProcessor.getTotalResults() + "tennants"); } } - // done? - return report; + // Done + return sb.toString(); } /** @@ -592,22 +612,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher { public String doWork() throws Exception { - if(requiresTransaction()) - { - // execute in a transaction - RetryingTransactionCallback patchWork = new RetryingTransactionCallback() - { - public String execute() throws Exception - { - return applyImpl(); - } - }; - return transactionService.getRetryingTransactionHelper().doInTransaction(patchWork, false, true); - } - else - { - return applyImpl(); - } + return applyWithTxns(); } }; startTime = System.currentTimeMillis();