mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Format fixing during investigation of ALF-20086
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55727 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -228,12 +228,12 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
|
||||
public void setRequiresTransaction(boolean requiresTransaction)
|
||||
{
|
||||
this.requiresTransaction = requiresTransaction;
|
||||
this.requiresTransaction = requiresTransaction;
|
||||
}
|
||||
|
||||
public boolean requiresTransaction()
|
||||
{
|
||||
return requiresTransaction;
|
||||
return requiresTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,17 +441,17 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
}
|
||||
String report = applyInternal();
|
||||
|
||||
if ((tenantAdminService != null) && tenantAdminService.isEnabled() && applyToTenants)
|
||||
if ((tenantAdminService != null) && tenantAdminService.isEnabled() && applyToTenants)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("call applyInternal for all tennants");
|
||||
}
|
||||
final List<Tenant> tenants = tenantAdminService.getAllTenants();
|
||||
final List<Tenant> tenants = tenantAdminService.getAllTenants();
|
||||
|
||||
BatchProcessWorkProvider<Tenant> provider = new BatchProcessWorkProvider<Tenant>()
|
||||
{
|
||||
Iterator<Tenant> i = tenants.iterator();
|
||||
BatchProcessWorkProvider<Tenant> provider = new BatchProcessWorkProvider<Tenant>()
|
||||
{
|
||||
Iterator<Tenant> i = tenants.iterator();
|
||||
|
||||
@Override
|
||||
public int getTotalEstimatedWorkSize()
|
||||
@@ -471,10 +471,10 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
BatchProcessor<Tenant> batchProcessor = new BatchProcessor<Tenant>(
|
||||
"AbstractPatch Processor for " + id,
|
||||
BatchProcessor<Tenant> batchProcessor = new BatchProcessor<Tenant>(
|
||||
"AbstractPatch Processor for " + id,
|
||||
transactionHelper,
|
||||
provider, // collection of tenants
|
||||
10, // worker threads,
|
||||
@@ -483,8 +483,8 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
logger,
|
||||
1000);
|
||||
|
||||
BatchProcessWorker worker = new BatchProcessWorker<Tenant>()
|
||||
{
|
||||
BatchProcessWorker worker = new BatchProcessWorker<Tenant>()
|
||||
{
|
||||
@Override
|
||||
public String getIdentifier(Tenant entry)
|
||||
{
|
||||
@@ -515,17 +515,17 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Now do the work
|
||||
// Now do the work
|
||||
int numberOfInvocations = batchProcessor.process(worker, true);
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("batch worker finished processing id:" + id);
|
||||
}
|
||||
|
||||
if(batchProcessor.getTotalErrors() > 0)
|
||||
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();
|
||||
}
|
||||
@@ -536,7 +536,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
}
|
||||
|
||||
// done?
|
||||
return report;
|
||||
return report;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -548,7 +548,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
*/
|
||||
public String applyAsync() throws PatchException
|
||||
{
|
||||
return apply(true);
|
||||
return apply(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,14 +558,13 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
*/
|
||||
public synchronized String apply() throws PatchException
|
||||
{
|
||||
return apply(false);
|
||||
return apply(false);
|
||||
}
|
||||
|
||||
private String apply(boolean async)
|
||||
{
|
||||
|
||||
if(!async)
|
||||
{
|
||||
if (!async)
|
||||
{
|
||||
// Do we bug out of patch execution
|
||||
if (deferred)
|
||||
{
|
||||
@@ -577,7 +576,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The patch has already been executed: \n" + " patch: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check properties
|
||||
checkProperties();
|
||||
@@ -593,22 +592,22 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
{
|
||||
public String doWork() throws Exception
|
||||
{
|
||||
if(requiresTransaction())
|
||||
{
|
||||
if(requiresTransaction())
|
||||
{
|
||||
// execute in a transaction
|
||||
RetryingTransactionCallback<String> patchWork = new RetryingTransactionCallback<String>()
|
||||
{
|
||||
public String execute() throws Exception
|
||||
{
|
||||
return applyImpl();
|
||||
}
|
||||
};
|
||||
return transactionService.getRetryingTransactionHelper().doInTransaction(patchWork, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return applyImpl();
|
||||
}
|
||||
RetryingTransactionCallback<String> patchWork = new RetryingTransactionCallback<String>()
|
||||
{
|
||||
public String execute() throws Exception
|
||||
{
|
||||
return applyImpl();
|
||||
}
|
||||
};
|
||||
return transactionService.getRetryingTransactionHelper().doInTransaction(patchWork, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return applyImpl();
|
||||
}
|
||||
}
|
||||
};
|
||||
startTime = System.currentTimeMillis();
|
||||
@@ -735,16 +734,18 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
||||
* Should the patch be deferred? And not run at bootstrap.
|
||||
* @param deferred
|
||||
*/
|
||||
public void setDeferred(boolean deferred) {
|
||||
this.deferred = deferred;
|
||||
}
|
||||
public void setDeferred(boolean deferred)
|
||||
{
|
||||
this.deferred = deferred;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
public boolean isDeferred() {
|
||||
return deferred;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
public boolean isDeferred()
|
||||
{
|
||||
return deferred;
|
||||
}
|
||||
|
||||
private int getReportingInterval(long soFar, long toGo)
|
||||
{
|
||||
|
@@ -48,11 +48,10 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* The first use-case is when there is a child called cm:shared and we want to patch a folder with app:shared
|
||||
*
|
||||
* @author mrogers
|
||||
*
|
||||
*/
|
||||
public class SharedFolderPatch extends GenericBootstrapPatch
|
||||
{
|
||||
private JobLockService jobLockService;
|
||||
private JobLockService jobLockService;
|
||||
|
||||
private long LOCK_TIME_TO_LIVE=10000;
|
||||
private long LOCK_REFRESH_TIME=5000;
|
||||
@@ -103,9 +102,9 @@ public class SharedFolderPatch extends GenericBootstrapPatch
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
StoreRef storeRef = importerBootstrap.getStoreRef();
|
||||
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
||||
if (getRenamePath() != null)
|
||||
@@ -123,24 +122,24 @@ public class SharedFolderPatch extends GenericBootstrapPatch
|
||||
}
|
||||
else if (results.size() == 1)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("There is an existing node in the way path:" + getRenamePath());
|
||||
}
|
||||
// A node already exists that we must rename.
|
||||
NodeRef existingNodeRef = results.get(0);
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("There is an existing node in the way path:" + getRenamePath());
|
||||
}
|
||||
// A node already exists that we must rename.
|
||||
NodeRef existingNodeRef = results.get(0);
|
||||
|
||||
// get the path of the parent node e.g. company_home
|
||||
LinkedList<String> folderElements = new LinkedList<String>(Arrays.asList(getRenamePath().split("/")));
|
||||
folderElements.removeLast();
|
||||
// get the path of the parent node e.g. company_home
|
||||
LinkedList<String> folderElements = new LinkedList<String>(Arrays.asList(getRenamePath().split("/")));
|
||||
folderElements.removeLast();
|
||||
|
||||
StringBuffer parentPath = new StringBuffer();
|
||||
|
||||
for(String folder : folderElements)
|
||||
{
|
||||
parentPath.append("/");
|
||||
parentPath.append(folder);
|
||||
}
|
||||
for(String folder : folderElements)
|
||||
{
|
||||
parentPath.append("/");
|
||||
parentPath.append(folder);
|
||||
}
|
||||
|
||||
List<NodeRef> parentResults = searchService.selectNodes(
|
||||
rootNodeRef,
|
||||
@@ -154,49 +153,53 @@ public class SharedFolderPatch extends GenericBootstrapPatch
|
||||
|
||||
NodeRef parentNodeRef = parentResults.get(0);
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Found the parent node - doing a move parentNodeRef:" + parentNodeRef);
|
||||
}
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Found the parent node - doing a move parentNodeRef:" + parentNodeRef);
|
||||
}
|
||||
|
||||
// rename the existing node
|
||||
nodeService.moveNode(existingNodeRef, parentNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName( NamespaceService.APP_MODEL_1_0_URI, "shared"));
|
||||
// rename the existing node
|
||||
nodeService.moveNode(existingNodeRef, parentNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName( NamespaceService.APP_MODEL_1_0_URI, "shared"));
|
||||
return I18NUtil.getMessage(MSG_RENAMED, renamePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Something has gone horribly wrong if we get here - we have multiple parents, or none despite finding the node earlier
|
||||
throw new PatchException(ERR_MULTIPLE_FOUND, parentPath.toString());
|
||||
throw new PatchException(ERR_MULTIPLE_FOUND, parentPath.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Else run the normal GenericBootstrapPatch implementation
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Node does not already exist, Running the Generic Bootstrap Patch");
|
||||
}
|
||||
return super.applyInternal();
|
||||
}
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Node does not already exist, Running the Generic Bootstrap Patch");
|
||||
}
|
||||
return super.applyInternal();
|
||||
}
|
||||
|
||||
public void setRenamePath(String renamePath) {
|
||||
this.renamePath = renamePath;
|
||||
}
|
||||
public void setRenamePath(String renamePath)
|
||||
{
|
||||
this.renamePath = renamePath;
|
||||
}
|
||||
|
||||
public String getRenamePath() {
|
||||
return renamePath;
|
||||
}
|
||||
public String getRenamePath()
|
||||
{
|
||||
return renamePath;
|
||||
}
|
||||
|
||||
public void setJobLockService(JobLockService jobLockService) {
|
||||
this.jobLockService = jobLockService;
|
||||
}
|
||||
public void setJobLockService(JobLockService jobLockService)
|
||||
{
|
||||
this.jobLockService = jobLockService;
|
||||
}
|
||||
|
||||
public JobLockService getJobLockService() {
|
||||
return jobLockService;
|
||||
}
|
||||
public JobLockService getJobLockService()
|
||||
{
|
||||
return jobLockService;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Job to initiate the {@link SharedFolderPatch} if it has been deferred
|
||||
*
|
||||
* @author Mark Rogers
|
||||
|
Reference in New Issue
Block a user