From e0c1f856facd58a184cc246d1827949d39009c09 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Fri, 1 Jun 2007 12:40:17 +0000 Subject: [PATCH] Added 'version' column to ADM entities - A patch will assign initial version values to the entities - Deprecated TransactionUtil in favour of the RetryingTransactionHelper - Renamed RetryingTransactionHelper.Callback to RetryingTransactionHelper.RetryingTransactionCallback The name Callback clashes with many other classes in the classpath - Moved loads of components to be included in the retry behaviour Duplicate name checks - This is done using a query, but the entity update is not written to the database early - Concurrent adds of the same-named child node will only fail at the end of the transaction - TODO: Detect the duplicate violation during transaction retrying Workaround for ADMLuceneTest - Disable session size resource management during tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5823 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/web/scripts/RepoStore.java | 56 ++++++++----------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/source/java/org/alfresco/web/scripts/RepoStore.java b/source/java/org/alfresco/web/scripts/RepoStore.java index 91f53aa109..90a2112120 100644 --- a/source/java/org/alfresco/web/scripts/RepoStore.java +++ b/source/java/org/alfresco/web/scripts/RepoStore.java @@ -34,7 +34,8 @@ import java.util.StringTokenizer; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.TransactionUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; @@ -44,7 +45,6 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.AbstractLifecycleBean; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; @@ -69,7 +69,7 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli protected String baseDir; // dependencies - protected TransactionService transactionService; + protected RetryingTransactionHelper retryingTransactionHelper; protected SearchService searchService; protected NodeService nodeService; protected ContentService contentService; @@ -77,19 +77,15 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli /** - * Sets transaction service - * - * @param transactionService + * Sets helper that provides transaction callbacks */ - public void setTransactionService(TransactionService transactionService) + public void setTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) { - this.transactionService = transactionService; + this.retryingTransactionHelper = retryingTransactionHelper; } /** * Sets the search service - * - * @param searchService */ public void setSearchService(SearchService searchService) { @@ -98,8 +94,6 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli /** * Sets the node service - * - * @param nodeService */ public void setNodeService(NodeService nodeService) { @@ -108,8 +102,6 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli /** * Sets the content service - * - * @param contentService */ public void setContentService(ContentService contentService) { @@ -118,8 +110,6 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli /** * Sets the namespace service - * - * @param namespaceService */ public void setNamespaceService(NamespaceService namespaceService) { @@ -128,8 +118,6 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli /** * Sets the repo store - * - * @param repoStore */ public void setStore(String repoStore) { @@ -188,9 +176,9 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli { public Object doWork() throws Exception { - return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public Object doWork() throws Exception + public Object execute() throws Exception { String query = "PATH:\"" + repoPath + "\""; ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query); @@ -261,9 +249,9 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli { public String[] doWork() throws Exception { - return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public String[] doWork() throws Exception + public String[] execute() throws Exception { int baseDirLength = baseDir.length() +1; List documentPaths = new ArrayList(); @@ -298,9 +286,9 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli { public InputStream doWork() throws Exception { - return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public InputStream doWork() throws Exception + public InputStream execute() throws Exception { NodeRef nodeRef = findNodeRef(documentPath); if (nodeRef == null) @@ -348,9 +336,9 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli { public Object doWork() throws Exception { - return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public Object doWork() throws Exception + public Object execute() throws Exception { RepoTemplateSource source = null; NodeRef nodeRef = findNodeRef(name); @@ -450,9 +438,9 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli { public Long doWork() throws Exception { - return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public Long doWork() throws Exception + public Long execute() throws Exception { ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); return reader.getLastModified(); @@ -474,9 +462,9 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli { public Reader doWork() throws Exception { - return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public Reader doWork() throws Exception + public Reader execute() throws Exception { ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); return new InputStreamReader(reader.getContentInputStream()); @@ -503,9 +491,9 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli { public ScriptLocation doWork() throws Exception { - return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public ScriptLocation doWork() throws Exception + public ScriptLocation execute() throws Exception { ScriptLocation location = null; NodeRef nodeRef = findNodeRef(path); @@ -551,9 +539,9 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli { public InputStream doWork() throws Exception { - return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public InputStream doWork() throws Exception + public InputStream execute() throws Exception { ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); return reader.getContentInputStream();