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)
|
public void setRequiresTransaction(boolean requiresTransaction)
|
||||||
{
|
{
|
||||||
this.requiresTransaction = requiresTransaction;
|
this.requiresTransaction = requiresTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean requiresTransaction()
|
public boolean requiresTransaction()
|
||||||
{
|
{
|
||||||
return requiresTransaction;
|
return requiresTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -441,17 +441,17 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
|||||||
}
|
}
|
||||||
String report = applyInternal();
|
String report = applyInternal();
|
||||||
|
|
||||||
if ((tenantAdminService != null) && tenantAdminService.isEnabled() && applyToTenants)
|
if ((tenantAdminService != null) && tenantAdminService.isEnabled() && applyToTenants)
|
||||||
{
|
{
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("call applyInternal for all tennants");
|
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>()
|
BatchProcessWorkProvider<Tenant> provider = new BatchProcessWorkProvider<Tenant>()
|
||||||
{
|
{
|
||||||
Iterator<Tenant> i = tenants.iterator();
|
Iterator<Tenant> i = tenants.iterator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTotalEstimatedWorkSize()
|
public int getTotalEstimatedWorkSize()
|
||||||
@@ -471,10 +471,10 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
|||||||
}
|
}
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BatchProcessor<Tenant> batchProcessor = new BatchProcessor<Tenant>(
|
BatchProcessor<Tenant> batchProcessor = new BatchProcessor<Tenant>(
|
||||||
"AbstractPatch Processor for " + id,
|
"AbstractPatch Processor for " + id,
|
||||||
transactionHelper,
|
transactionHelper,
|
||||||
provider, // collection of tenants
|
provider, // collection of tenants
|
||||||
10, // worker threads,
|
10, // worker threads,
|
||||||
@@ -482,9 +482,9 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
|||||||
applicationEventPublisher,
|
applicationEventPublisher,
|
||||||
logger,
|
logger,
|
||||||
1000);
|
1000);
|
||||||
|
|
||||||
BatchProcessWorker worker = new BatchProcessWorker<Tenant>()
|
BatchProcessWorker worker = new BatchProcessWorker<Tenant>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier(Tenant entry)
|
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);
|
int numberOfInvocations = batchProcessor.process(worker, true);
|
||||||
|
|
||||||
if(logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("batch worker finished processing id:" + id);
|
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();
|
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?
|
// done?
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -547,8 +547,8 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
|||||||
* @throws PatchException if the patch failed to be applied
|
* @throws PatchException if the patch failed to be applied
|
||||||
*/
|
*/
|
||||||
public String applyAsync() throws PatchException
|
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
|
public synchronized String apply() throws PatchException
|
||||||
{
|
{
|
||||||
return apply(false);
|
return apply(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String apply(boolean async)
|
private String apply(boolean async)
|
||||||
{
|
{
|
||||||
|
if (!async)
|
||||||
if(!async)
|
{
|
||||||
{
|
|
||||||
// Do we bug out of patch execution
|
// Do we bug out of patch execution
|
||||||
if (deferred)
|
if (deferred)
|
||||||
{
|
{
|
||||||
@@ -577,8 +576,8 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
|||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("The patch has already been executed: \n" + " patch: " + this);
|
throw new AlfrescoRuntimeException("The patch has already been executed: \n" + " patch: " + this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check properties
|
// check properties
|
||||||
checkProperties();
|
checkProperties();
|
||||||
|
|
||||||
@@ -593,22 +592,22 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
|||||||
{
|
{
|
||||||
public String doWork() throws Exception
|
public String doWork() throws Exception
|
||||||
{
|
{
|
||||||
if(requiresTransaction())
|
if(requiresTransaction())
|
||||||
{
|
{
|
||||||
// execute in a transaction
|
// execute in a transaction
|
||||||
RetryingTransactionCallback<String> patchWork = new RetryingTransactionCallback<String>()
|
RetryingTransactionCallback<String> patchWork = new RetryingTransactionCallback<String>()
|
||||||
{
|
{
|
||||||
public String execute() throws Exception
|
public String execute() throws Exception
|
||||||
{
|
{
|
||||||
return applyImpl();
|
return applyImpl();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return transactionService.getRetryingTransactionHelper().doInTransaction(patchWork, false, true);
|
return transactionService.getRetryingTransactionHelper().doInTransaction(patchWork, false, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return applyImpl();
|
return applyImpl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
@@ -735,16 +734,18 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
|
|||||||
* Should the patch be deferred? And not run at bootstrap.
|
* Should the patch be deferred? And not run at bootstrap.
|
||||||
* @param deferred
|
* @param deferred
|
||||||
*/
|
*/
|
||||||
public void setDeferred(boolean deferred) {
|
public void setDeferred(boolean deferred)
|
||||||
this.deferred = deferred;
|
{
|
||||||
}
|
this.deferred = deferred;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public boolean isDeferred() {
|
public boolean isDeferred()
|
||||||
return deferred;
|
{
|
||||||
}
|
return deferred;
|
||||||
|
}
|
||||||
|
|
||||||
private int getReportingInterval(long soFar, long toGo)
|
private int getReportingInterval(long soFar, long toGo)
|
||||||
{
|
{
|
||||||
|
@@ -48,15 +48,14 @@ 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
|
* 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
|
* @author mrogers
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SharedFolderPatch extends GenericBootstrapPatch
|
public class SharedFolderPatch extends GenericBootstrapPatch
|
||||||
{
|
{
|
||||||
private JobLockService jobLockService;
|
private JobLockService jobLockService;
|
||||||
|
|
||||||
private long LOCK_TIME_TO_LIVE=10000;
|
private long LOCK_TIME_TO_LIVE=10000;
|
||||||
private long LOCK_REFRESH_TIME=5000;
|
private long LOCK_REFRESH_TIME=5000;
|
||||||
|
|
||||||
private String renamePath;
|
private String renamePath;
|
||||||
|
|
||||||
private Log logger = LogFactory.getLog(SharedFolderPatch.class);
|
private Log logger = LogFactory.getLog(SharedFolderPatch.class);
|
||||||
@@ -103,9 +102,9 @@ public class SharedFolderPatch extends GenericBootstrapPatch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String applyInternal() throws Exception
|
protected String applyInternal() throws Exception
|
||||||
{
|
{
|
||||||
StoreRef storeRef = importerBootstrap.getStoreRef();
|
StoreRef storeRef = importerBootstrap.getStoreRef();
|
||||||
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
||||||
if (getRenamePath() != null)
|
if (getRenamePath() != null)
|
||||||
@@ -123,25 +122,25 @@ public class SharedFolderPatch extends GenericBootstrapPatch
|
|||||||
}
|
}
|
||||||
else if (results.size() == 1)
|
else if (results.size() == 1)
|
||||||
{
|
{
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("There is an existing node in the way path:" + getRenamePath());
|
logger.debug("There is an existing node in the way path:" + getRenamePath());
|
||||||
}
|
}
|
||||||
// A node already exists that we must rename.
|
// A node already exists that we must rename.
|
||||||
NodeRef existingNodeRef = results.get(0);
|
NodeRef existingNodeRef = results.get(0);
|
||||||
|
|
||||||
// get the path of the parent node e.g. company_home
|
// get the path of the parent node e.g. company_home
|
||||||
LinkedList<String> folderElements = new LinkedList<String>(Arrays.asList(getRenamePath().split("/")));
|
LinkedList<String> folderElements = new LinkedList<String>(Arrays.asList(getRenamePath().split("/")));
|
||||||
folderElements.removeLast();
|
folderElements.removeLast();
|
||||||
|
|
||||||
StringBuffer parentPath = new StringBuffer();
|
StringBuffer parentPath = new StringBuffer();
|
||||||
|
|
||||||
for(String folder : folderElements)
|
for(String folder : folderElements)
|
||||||
{
|
{
|
||||||
parentPath.append("/");
|
parentPath.append("/");
|
||||||
parentPath.append(folder);
|
parentPath.append(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NodeRef> parentResults = searchService.selectNodes(
|
List<NodeRef> parentResults = searchService.selectNodes(
|
||||||
rootNodeRef,
|
rootNodeRef,
|
||||||
parentPath.toString(),
|
parentPath.toString(),
|
||||||
@@ -151,52 +150,56 @@ public class SharedFolderPatch extends GenericBootstrapPatch
|
|||||||
|
|
||||||
if(parentResults.size()==1)
|
if(parentResults.size()==1)
|
||||||
{
|
{
|
||||||
|
|
||||||
NodeRef parentNodeRef = parentResults.get(0);
|
NodeRef parentNodeRef = parentResults.get(0);
|
||||||
|
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Found the parent node - doing a move parentNodeRef:" + parentNodeRef);
|
logger.debug("Found the parent node - doing a move parentNodeRef:" + parentNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rename the existing node
|
// rename the existing node
|
||||||
nodeService.moveNode(existingNodeRef, parentNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName( NamespaceService.APP_MODEL_1_0_URI, "shared"));
|
nodeService.moveNode(existingNodeRef, parentNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName( NamespaceService.APP_MODEL_1_0_URI, "shared"));
|
||||||
return I18NUtil.getMessage(MSG_RENAMED, renamePath);
|
return I18NUtil.getMessage(MSG_RENAMED, renamePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Something has gone horribly wrong if we get here - we have multiple parents, or none despite finding the node earlier
|
// 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
|
// Else run the normal GenericBootstrapPatch implementation
|
||||||
|
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Node does not already exist, Running the Generic Bootstrap Patch");
|
logger.debug("Node does not already exist, Running the Generic Bootstrap Patch");
|
||||||
}
|
}
|
||||||
return super.applyInternal();
|
return super.applyInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenamePath(String renamePath) {
|
public void setRenamePath(String renamePath)
|
||||||
this.renamePath = renamePath;
|
{
|
||||||
}
|
this.renamePath = renamePath;
|
||||||
|
}
|
||||||
|
|
||||||
public String getRenamePath() {
|
public String getRenamePath()
|
||||||
return renamePath;
|
{
|
||||||
}
|
return renamePath;
|
||||||
|
}
|
||||||
public void setJobLockService(JobLockService jobLockService) {
|
|
||||||
this.jobLockService = jobLockService;
|
public void setJobLockService(JobLockService jobLockService)
|
||||||
}
|
{
|
||||||
|
this.jobLockService = jobLockService;
|
||||||
|
}
|
||||||
|
|
||||||
public JobLockService getJobLockService() {
|
public JobLockService getJobLockService()
|
||||||
return jobLockService;
|
{
|
||||||
}
|
return jobLockService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job to initiate the {@link SharedFolderPatch} if it has been deferred
|
* Job to initiate the {@link SharedFolderPatch} if it has been deferred
|
||||||
*
|
*
|
||||||
* @author Mark Rogers
|
* @author Mark Rogers
|
||||||
|
Reference in New Issue
Block a user