- Web Script Runtime now takes ServiceRegistry in constructor (not an explicit ever growing list of services)

- default status templates now include Alfresco server information & time of error for diagnostic purposes
- template url.match does not include service context anymore e.g. /alfresco/service/api/path/ is now just /api/path/
- added Retrying Transaction Helper to Service Registry

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6088 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2007-06-25 12:38:32 +00:00
parent 7bde225592
commit 4ede480475
14 changed files with 51 additions and 43 deletions

View File

@@ -44,6 +44,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.web.config.ServerConfigElement;
@@ -64,10 +65,10 @@ public class TestWebScriptServer
{
// dependencies
protected AuthenticationService authenticationService;
protected RetryingTransactionHelper retryingTransactionHelper;
protected AuthorityService authorityService;
protected DeclarativeWebScriptRegistry registry;
protected ConfigService configService;
protected ServiceRegistry serviceRegistry;
protected RetryingTransactionHelper retryingTransactionHelper;
/** Server Configuration */
private ServerConfigElement serverConfig;
@@ -106,6 +107,16 @@ public class TestWebScriptServer
this.registry = registry;
}
/**
* Sets the Service Registry
*
* @param registry
*/
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.serviceRegistry = serviceRegistry;
}
/**
* Sets the Config Service
*
@@ -124,14 +135,6 @@ public class TestWebScriptServer
this.authenticationService = authenticationService;
}
/**
* @param authorityService
*/
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}
/**
* Sets the Messages resource bundle
*
@@ -213,7 +216,7 @@ public class TestWebScriptServer
MockHttpServletRequest req = createRequest(method, uri);
MockHttpServletResponse res = new MockHttpServletResponse();
WebScriptRuntime runtime = new WebScriptServletRuntime(registry, retryingTransactionHelper, authorityService, null, req, res, serverConfig);
WebScriptRuntime runtime = new WebScriptServletRuntime(registry, serviceRegistry, null, req, res, serverConfig);
runtime.executeScript();
return res;
@@ -238,7 +241,7 @@ public class TestWebScriptServer
}
MockHttpServletResponse res = new MockHttpServletResponse();
WebScriptRuntime runtime = new WebScriptServletRuntime(registry, retryingTransactionHelper, authorityService, null, req, res, serverConfig);
WebScriptRuntime runtime = new WebScriptServletRuntime(registry, serviceRegistry, null, req, res, serverConfig);
runtime.executeScript();
return res;

View File

@@ -126,7 +126,7 @@ public class URLModel
*/
public String getMatch()
{
return getServiceContext() + req.getServiceMatch().getPath();
return req.getServiceMatch().getPath();
}
public String jsGet_match()

View File

@@ -25,6 +25,7 @@
package org.alfresco.web.scripts;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -35,6 +36,7 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.web.scripts.WebScriptDescription.RequiredAuthentication;
import org.alfresco.web.scripts.WebScriptDescription.RequiredTransaction;
@@ -61,6 +63,7 @@ public abstract class WebScriptRuntime
/** Component Dependencies */
private WebScriptRegistry registry;
private ServiceRegistry serviceRegistry;
private RetryingTransactionHelper retryingTransactionHelper;
private AuthorityService authorityService;
@@ -68,13 +71,14 @@ public abstract class WebScriptRuntime
* Construct
*
* @param registry web script registry
* @param transactionService transaction service
* @param serviceRegistry service registry
*/
public WebScriptRuntime(WebScriptRegistry registry, RetryingTransactionHelper transactionHelper, AuthorityService authorityService)
public WebScriptRuntime(WebScriptRegistry registry, ServiceRegistry serviceRegistry)
{
this.registry = registry;
this.retryingTransactionHelper = transactionHelper;
this.authorityService = authorityService;
this.serviceRegistry = serviceRegistry;
this.authorityService = serviceRegistry.getAuthorityService();
this.retryingTransactionHelper = serviceRegistry.getRetryingTransactionHelper();
}
/**
@@ -205,6 +209,8 @@ public abstract class WebScriptRuntime
Map<String, Object> model = new HashMap<String, Object>();
model.put("status", status);
model.put("url", new URLModel(req));
model.put("server", new ServerModel(serviceRegistry.getDescriptorService().getServerDescriptor()));
model.put("date", new Date());
// locate status template
// NOTE: search order...

View File

@@ -34,6 +34,7 @@ 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.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.web.config.ServerConfigElement;
import org.apache.commons.logging.Log;
@@ -56,8 +57,7 @@ public class WebScriptServlet extends HttpServlet
// Component Dependencies
private DeclarativeWebScriptRegistry registry;
private RetryingTransactionHelper transactionHelper;
private AuthorityService authorityService;
private ServiceRegistry serviceRegistry;
private WebScriptServletAuthenticator authenticator;
protected ConfigService configService;
@@ -71,8 +71,7 @@ public class WebScriptServlet extends HttpServlet
super.init();
ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
registry = (DeclarativeWebScriptRegistry)context.getBean("webscripts.registry");
transactionHelper = (RetryingTransactionHelper)context.getBean("retryingTransactionHelper");
authorityService = (AuthorityService)context.getBean("authorityService");
serviceRegistry = (ServiceRegistry)context.getBean(ServiceRegistry.SERVICE_REGISTRY);
configService = (ConfigService)context.getBean("webClientConfigService");
// retrieve authenticator via servlet initialisation parameter
@@ -108,7 +107,7 @@ public class WebScriptServlet extends HttpServlet
res.setHeader("Cache-Control", "no-cache");
res.setHeader("Pragma", "no-cache");
WebScriptRuntime runtime = new WebScriptServletRuntime(registry, transactionHelper, authorityService, authenticator, req, res, serverConfig);
WebScriptRuntime runtime = new WebScriptServletRuntime(registry, serviceRegistry, authenticator, req, res, serverConfig);
runtime.executeScript();
}

View File

@@ -27,8 +27,7 @@ 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.ServiceRegistry;
import org.alfresco.web.config.ServerConfigElement;
import org.alfresco.web.scripts.WebScriptDescription.RequiredAuthentication;
@@ -50,16 +49,15 @@ public class WebScriptServletRuntime extends WebScriptRuntime
* Construct
*
* @param registry
* @param transactionService
* @param serviceRegistry
* @param authenticator
* @param req
* @param res
*/
public WebScriptServletRuntime(WebScriptRegistry registry, RetryingTransactionHelper transactionHelper,
AuthorityService authorityService, WebScriptServletAuthenticator authenticator,
public WebScriptServletRuntime(WebScriptRegistry registry, ServiceRegistry serviceRegistry, WebScriptServletAuthenticator authenticator,
HttpServletRequest req, HttpServletResponse res, ServerConfigElement serverConfig)
{
super(registry, transactionHelper, authorityService);
super(registry, serviceRegistry);
this.req = req;
this.res = res;
this.authenticator = authenticator;

View File

@@ -38,6 +38,7 @@ import javax.faces.event.FacesEvent;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.web.scripts.DeclarativeWebScriptRegistry;
import org.alfresco.web.scripts.WebScriptMatch;
@@ -74,8 +75,7 @@ public class UIWebScript extends SelfRenderingComponent
private boolean scriptUrlModified = false;
private WebScriptRegistry registry;
private RetryingTransactionHelper txnHelper;
private AuthorityService authorityService;
private ServiceRegistry serviceRegistry;;
/**
* Default constructor
@@ -85,8 +85,7 @@ public class UIWebScript extends SelfRenderingComponent
WebApplicationContext ctx = FacesContextUtils.getRequiredWebApplicationContext(
FacesContext.getCurrentInstance());
this.registry = (DeclarativeWebScriptRegistry)ctx.getBean("webscripts.registry");
this.txnHelper = (RetryingTransactionHelper)ctx.getBean("retryingTransactionHelper");
this.authorityService = (AuthorityService)ctx.getBean("authorityService");
this.serviceRegistry = (ServiceRegistry)ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
}
/**
@@ -279,7 +278,7 @@ public class UIWebScript extends SelfRenderingComponent
WebScriptJSFRuntime(FacesContext fc, String scriptUrl)
{
super(registry, txnHelper, authorityService);
super(registry, serviceRegistry);
this.fc = fc;
this.scriptUrl = scriptUrl;
this.script = WebScriptURLRequest.splitURL(scriptUrl)[2];

View File

@@ -43,6 +43,7 @@ import javax.portlet.WindowState;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.web.scripts.DeclarativeWebScriptRegistry;
import org.alfresco.web.scripts.WebScript;
@@ -76,8 +77,7 @@ public class WebScriptPortlet implements Portlet
// Component Dependencies
protected DeclarativeWebScriptRegistry registry;
protected RetryingTransactionHelper transactionHelper;
protected AuthorityService authorityService;
protected ServiceRegistry serviceRegistry;
protected WebScriptPortletAuthenticator authenticator;
@@ -90,8 +90,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");
transactionHelper = (RetryingTransactionHelper)ctx.getBean("retryingTransactionHelper");
authorityService = (AuthorityService)ctx.getBean("authorityService");
serviceRegistry = (ServiceRegistry)ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
// retrieve authenticator via portlet initialization parameter
String authenticatorId = config.getInitParameter("authenticator");
@@ -237,7 +236,7 @@ public class WebScriptPortlet implements Portlet
*/
public WebScriptPortalRuntime(RenderRequest req, RenderResponse res, String requestUrl)
{
super(registry, transactionHelper, authorityService);
super(registry, serviceRegistry);
this.req = req;
this.res = res;
this.requestUrlParts = WebScriptURLRequest.splitURL(requestUrl);