mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Web Scripts: remove use of deprecated TransactionUtil.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5886 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<property name="registry" ref="webscripts.registry" />
|
||||
<property name="authenticationService" ref="authenticationService" />
|
||||
<property name="authorityService" ref="authorityService" />
|
||||
<property name="transactionService" ref="transactionComponent" />
|
||||
<property name="transactionHelper" ref="retryingTransactionHelper" />
|
||||
<property name="configService" ref="webClientConfigService" />
|
||||
<property name="messages">
|
||||
<bean class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||
|
@@ -56,7 +56,7 @@
|
||||
</bean>
|
||||
|
||||
<bean id="webscripts.context" class="org.alfresco.web.scripts.WebScriptContext">
|
||||
<property name="transactionService" ref="transactionComponent" />
|
||||
<property name="transactionHelper" ref="retryingTransactionHelper" />
|
||||
<property name="namespaceService" ref="namespaceService" />
|
||||
<property name="nodeService" ref="nodeService" />
|
||||
<property name="personService" ref="personService" />
|
||||
|
@@ -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<Object>()
|
||||
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object doWork() throws Throwable
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
authenticationService.validate(username);
|
||||
return null;
|
||||
|
@@ -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<Object>()
|
||||
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
@SuppressWarnings("synthetic-access")
|
||||
public Object doWork() throws Exception
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
List<NodeRef> refs = searchService.selectNodes(nodeService.getRootNode(companyHomeStore), companyHomePath, null, namespaceService, false);
|
||||
if (refs.size() != 1)
|
||||
|
@@ -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<Object> work = new TransactionUtil.TransactionWork<Object>()
|
||||
RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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];
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user