diff --git a/config/alfresco/web-scripts-application-context-test.xml b/config/alfresco/web-scripts-application-context-test.xml index c44792d9a8..3511494ec6 100644 --- a/config/alfresco/web-scripts-application-context-test.xml +++ b/config/alfresco/web-scripts-application-context-test.xml @@ -11,7 +11,7 @@ - + diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index ac61906acb..d4ec3d9e94 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -56,7 +56,7 @@ - + diff --git a/source/java/org/alfresco/web/scripts/TestWebScriptServer.java b/source/java/org/alfresco/web/scripts/TestWebScriptServer.java index d85bf3893a..7c1137a569 100644 --- a/source/java/org/alfresco/web/scripts/TestWebScriptServer.java +++ b/source/java/org/alfresco/web/scripts/TestWebScriptServer.java @@ -40,10 +40,10 @@ import org.alfresco.config.ConfigService; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.TransactionUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.transaction.TransactionService; import org.alfresco.web.config.ServerConfigElement; import org.springframework.context.ApplicationContext; import org.springframework.context.MessageSource; @@ -62,7 +62,7 @@ public class TestWebScriptServer { // dependencies protected AuthenticationService authenticationService; - protected TransactionService transactionService; + protected RetryingTransactionHelper retryingTransactionHelper; protected AuthorityService authorityService; protected DeclarativeWebScriptRegistry registry; protected ConfigService configService; @@ -87,13 +87,11 @@ public class TestWebScriptServer /** - * Sets the 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; } /** @@ -213,7 +211,7 @@ public class TestWebScriptServer MockHttpServletRequest req = createRequest(method, uri); MockHttpServletResponse res = new MockHttpServletResponse(); - WebScriptRuntime runtime = new WebScriptServletRuntime(registry, transactionService, authorityService, null, req, res, serverConfig); + WebScriptRuntime runtime = new WebScriptServletRuntime(registry, retryingTransactionHelper, authorityService, null, req, res, serverConfig); runtime.executeScript(); return res; @@ -238,7 +236,7 @@ public class TestWebScriptServer } MockHttpServletResponse res = new MockHttpServletResponse(); - WebScriptRuntime runtime = new WebScriptServletRuntime(registry, transactionService, authorityService, null, req, res, serverConfig); + WebScriptRuntime runtime = new WebScriptServletRuntime(registry, retryingTransactionHelper, authorityService, null, req, res, serverConfig); runtime.executeScript(); return res; @@ -291,9 +289,9 @@ public class TestWebScriptServer { try { - TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { - public Object doWork() throws Throwable + public Object execute() throws Exception { authenticationService.validate(username); return null; diff --git a/source/java/org/alfresco/web/scripts/WebScriptContext.java b/source/java/org/alfresco/web/scripts/WebScriptContext.java index 1a3b2a75b8..778e5311b2 100644 --- a/source/java/org/alfresco/web/scripts/WebScriptContext.java +++ b/source/java/org/alfresco/web/scripts/WebScriptContext.java @@ -28,14 +28,14 @@ import java.util.List; 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.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.security.PersonService; 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; @@ -54,7 +54,7 @@ public class WebScriptContext implements ApplicationContextAware, ApplicationLis private ProcessorLifecycle lifecycle = new ProcessorLifecycle(); // dependencies - private TransactionService transactionService; + private RetryingTransactionHelper retryingTransactionHelper; private NamespaceService namespaceService; private SearchService searchService; private NodeService nodeService; @@ -87,13 +87,11 @@ public class WebScriptContext implements ApplicationContextAware, ApplicationLis } /** - * Sets the 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; } /** @@ -174,10 +172,10 @@ public class WebScriptContext implements ApplicationContextAware, ApplicationLis */ protected void initContext() { - TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork() + retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { @SuppressWarnings("synthetic-access") - public Object doWork() throws Exception + public Object execute() throws Exception { List refs = searchService.selectNodes(nodeService.getRootNode(companyHomeStore), companyHomePath, null, namespaceService, false); if (refs.size() != 1) diff --git a/source/java/org/alfresco/web/scripts/WebScriptRuntime.java b/source/java/org/alfresco/web/scripts/WebScriptRuntime.java index 698809657e..623b9b6019 100644 --- a/source/java/org/alfresco/web/scripts/WebScriptRuntime.java +++ b/source/java/org/alfresco/web/scripts/WebScriptRuntime.java @@ -33,9 +33,9 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.i18n.I18NUtil; import org.alfresco.repo.content.MimetypeMap; 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.security.AuthorityService; -import org.alfresco.service.transaction.TransactionService; import org.alfresco.web.scripts.WebScriptDescription.RequiredAuthentication; import org.alfresco.web.scripts.WebScriptDescription.RequiredTransaction; import org.apache.commons.logging.Log; @@ -61,7 +61,7 @@ public abstract class WebScriptRuntime /** Component Dependencies */ private WebScriptRegistry registry; - private TransactionService transactionService; + private RetryingTransactionHelper retryingTransactionHelper; private AuthorityService authorityService; /** @@ -70,10 +70,10 @@ public abstract class WebScriptRuntime * @param registry web script registry * @param transactionService transaction service */ - public WebScriptRuntime(WebScriptRegistry registry, TransactionService transactionService, AuthorityService authorityService) + public WebScriptRuntime(WebScriptRegistry registry, RetryingTransactionHelper transactionHelper, AuthorityService authorityService) { this.registry = registry; - this.transactionService = transactionService; + this.retryingTransactionHelper = transactionHelper; this.authorityService = authorityService; } @@ -149,9 +149,9 @@ public abstract class WebScriptRuntime else { // encapsulate script within transaction - TransactionUtil.TransactionWork work = new TransactionUtil.TransactionWork() + RetryingTransactionCallback work = new RetryingTransactionCallback() { - public Object doWork() throws Throwable + public Object execute() throws Exception { if (logger.isDebugEnabled()) logger.debug("Begin transaction: " + description.getRequiredTransaction()); @@ -167,11 +167,11 @@ public abstract class WebScriptRuntime if (description.getRequiredTransaction() == RequiredTransaction.required) { - TransactionUtil.executeInUserTransaction(transactionService, work); + retryingTransactionHelper.doInTransaction(work); } else { - TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, work); + retryingTransactionHelper.doInTransaction(work, false, true); } } } diff --git a/source/java/org/alfresco/web/scripts/WebScriptServlet.java b/source/java/org/alfresco/web/scripts/WebScriptServlet.java index 310d4691ce..06db7d5b6a 100644 --- a/source/java/org/alfresco/web/scripts/WebScriptServlet.java +++ b/source/java/org/alfresco/web/scripts/WebScriptServlet.java @@ -33,8 +33,8 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.config.Config; import org.alfresco.config.ConfigService; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.transaction.TransactionService; import org.alfresco.web.config.ServerConfigElement; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -56,7 +56,7 @@ public class WebScriptServlet extends HttpServlet // Component Dependencies private DeclarativeWebScriptRegistry registry; - private TransactionService transactionService; + private RetryingTransactionHelper transactionHelper; private AuthorityService authorityService; private WebScriptServletAuthenticator authenticator; protected ConfigService configService; @@ -71,7 +71,7 @@ public class WebScriptServlet extends HttpServlet super.init(); ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); registry = (DeclarativeWebScriptRegistry)context.getBean("webscripts.registry"); - transactionService = (TransactionService)context.getBean("transactionComponent"); + transactionHelper = (RetryingTransactionHelper)context.getBean("retryingTransactionHelper"); authorityService = (AuthorityService)context.getBean("authorityService"); configService = (ConfigService)context.getBean("webClientConfigService"); @@ -108,7 +108,7 @@ public class WebScriptServlet extends HttpServlet res.setHeader("Cache-Control", "no-cache"); res.setHeader("Pragma", "no-cache"); - WebScriptRuntime runtime = new WebScriptServletRuntime(registry, transactionService, authorityService, authenticator, req, res, serverConfig); + WebScriptRuntime runtime = new WebScriptServletRuntime(registry, transactionHelper, authorityService, authenticator, req, res, serverConfig); runtime.executeScript(); } diff --git a/source/java/org/alfresco/web/scripts/WebScriptServletRuntime.java b/source/java/org/alfresco/web/scripts/WebScriptServletRuntime.java index 033333b69d..5a811a84a4 100644 --- a/source/java/org/alfresco/web/scripts/WebScriptServletRuntime.java +++ b/source/java/org/alfresco/web/scripts/WebScriptServletRuntime.java @@ -27,8 +27,8 @@ package org.alfresco.web.scripts; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.transaction.TransactionService; import org.alfresco.web.config.ServerConfigElement; import org.alfresco.web.scripts.WebScriptDescription.RequiredAuthentication; @@ -55,11 +55,11 @@ public class WebScriptServletRuntime extends WebScriptRuntime * @param req * @param res */ - public WebScriptServletRuntime(WebScriptRegistry registry, TransactionService transactionService, + public WebScriptServletRuntime(WebScriptRegistry registry, RetryingTransactionHelper transactionHelper, AuthorityService authorityService, WebScriptServletAuthenticator authenticator, HttpServletRequest req, HttpServletResponse res, ServerConfigElement serverConfig) { - super(registry, transactionService, authorityService); + super(registry, transactionHelper, authorityService); this.req = req; this.res = res; this.authenticator = authenticator; diff --git a/source/java/org/alfresco/web/scripts/jsf/UIWebScript.java b/source/java/org/alfresco/web/scripts/jsf/UIWebScript.java index 06d8e7ac16..746e8782d3 100644 --- a/source/java/org/alfresco/web/scripts/jsf/UIWebScript.java +++ b/source/java/org/alfresco/web/scripts/jsf/UIWebScript.java @@ -37,8 +37,8 @@ import javax.faces.event.ActionEvent; import javax.faces.event.FacesEvent; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.transaction.TransactionService; import org.alfresco.web.scripts.DeclarativeWebScriptRegistry; import org.alfresco.web.scripts.WebScriptMatch; import org.alfresco.web.scripts.WebScriptRegistry; @@ -70,7 +70,7 @@ public class UIWebScript extends SelfRenderingComponent private boolean scriptUrlModified = false; private WebScriptRegistry registry; - private TransactionService txnService; + private RetryingTransactionHelper txnHelper; private AuthorityService authorityService; /** @@ -81,7 +81,7 @@ public class UIWebScript extends SelfRenderingComponent WebApplicationContext ctx = FacesContextUtils.getRequiredWebApplicationContext( FacesContext.getCurrentInstance()); this.registry = (DeclarativeWebScriptRegistry)ctx.getBean("webscripts.registry"); - this.txnService = (TransactionService)ctx.getBean("transactionComponent"); + this.txnHelper = (RetryingTransactionHelper)ctx.getBean("retryingTransactionHelper"); this.authorityService = (AuthorityService)ctx.getBean("authorityService"); } @@ -228,7 +228,7 @@ public class UIWebScript extends SelfRenderingComponent WebScriptJSFRuntime(FacesContext fc, String scriptUrl) { - super(registry, txnService, authorityService); + super(registry, txnHelper, authorityService); this.fc = fc; this.scriptUrl = scriptUrl; this.script = WebScriptURLRequest.splitURL(scriptUrl)[2]; diff --git a/source/java/org/alfresco/web/scripts/portlet/WebScriptPortlet.java b/source/java/org/alfresco/web/scripts/portlet/WebScriptPortlet.java index 8bba515194..bc5dea8a86 100644 --- a/source/java/org/alfresco/web/scripts/portlet/WebScriptPortlet.java +++ b/source/java/org/alfresco/web/scripts/portlet/WebScriptPortlet.java @@ -39,8 +39,8 @@ import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.WindowState; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.transaction.TransactionService; import org.alfresco.web.scripts.DeclarativeWebScriptRegistry; import org.alfresco.web.scripts.WebScript; import org.alfresco.web.scripts.WebScriptDescription; @@ -73,7 +73,7 @@ public class WebScriptPortlet implements Portlet // Component Dependencies protected DeclarativeWebScriptRegistry registry; - protected TransactionService transactionService; + protected RetryingTransactionHelper transactionHelper; protected AuthorityService authorityService; protected WebScriptPortletAuthenticator authenticator; @@ -87,7 +87,7 @@ public class WebScriptPortlet implements Portlet PortletContext portletCtx = config.getPortletContext(); WebApplicationContext ctx = (WebApplicationContext)portletCtx.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); registry = (DeclarativeWebScriptRegistry)ctx.getBean("webscripts.registry"); - transactionService = (TransactionService)ctx.getBean("transactionComponent"); + transactionHelper = (RetryingTransactionHelper)ctx.getBean("retryingTransactionHelper"); authorityService = (AuthorityService)ctx.getBean("authorityService"); authenticator = (WebScriptPortletAuthenticator)ctx.getBean("webscripts.authenticator.jsr168"); } @@ -212,7 +212,7 @@ public class WebScriptPortlet implements Portlet */ public WebScriptPortalRuntime(RenderRequest req, RenderResponse res, String requestUrl) { - super(registry, transactionService, authorityService); + super(registry, transactionHelper, authorityService); this.req = req; this.res = res; this.requestUrlParts = WebScriptURLRequest.splitURL(requestUrl);