mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- 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:
@@ -6,7 +6,7 @@
|
||||
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<form action="${url.match}" method="post">
|
||||
<form action="${url.serviceContext}${url.match}" method="post">
|
||||
<input type="hidden" name="reset" value="on">
|
||||
<table>
|
||||
<tr>
|
||||
|
@@ -21,5 +21,5 @@
|
||||
</#list>
|
||||
</table>
|
||||
<br>
|
||||
<table><tr><td><a href="${url.match}">List Web Scripts</a></td></tr></table>
|
||||
<table><tr><td><a href="${url.serviceContext}${url.match}">List Web Scripts</a></td></tr></table>
|
||||
</html>
|
@@ -6,7 +6,7 @@
|
||||
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<form action="${url.match}" method="post">
|
||||
<form action="${url.serviceContext}${url.match}" method="post">
|
||||
<input type="hidden" name="visible" value="<#if visible>false<#else>true</#if>">
|
||||
<table>
|
||||
<tr>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<form action="${url.match}" method="post">
|
||||
<form action="${url.serviceContext}${url.match}" method="post">
|
||||
<input type="hidden" name="visible" value="<#if visible>false<#else>true</#if>">
|
||||
<table>
|
||||
<tr>
|
||||
|
@@ -25,6 +25,8 @@
|
||||
<tr><td>
|
||||
<@recursestack status.exception/>
|
||||
</#if>
|
||||
<tr><td><b>Server</b>:<td>Alfresco ${server.edition} v${server.version} schema ${server.schema}
|
||||
<tr><td><b>Time</b>:<td>${date?datetime}
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -12,6 +12,8 @@
|
||||
<@recursestack status.exception/>
|
||||
</#if>
|
||||
</callstack>
|
||||
<server>Alfresco ${server.edition} v${server.version} schema ${server.schema}</server>
|
||||
<time>${date?datetime}</time>
|
||||
</response>
|
||||
|
||||
<#macro recursestack exception>
|
||||
|
@@ -9,8 +9,8 @@
|
||||
|
||||
<bean id="webscripts.test" class="org.alfresco.web.scripts.TestWebScriptServer">
|
||||
<property name="registry" ref="webscripts.registry" />
|
||||
<property name="serviceRegistry" ref="ServiceRegistry" />
|
||||
<property name="authenticationService" ref="authenticationService" />
|
||||
<property name="authorityService" ref="authorityService" />
|
||||
<property name="transactionHelper" ref="retryingTransactionHelper" />
|
||||
<property name="configService" ref="webClientConfigService" />
|
||||
<property name="messages">
|
||||
|
@@ -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;
|
||||
|
@@ -126,7 +126,7 @@ public class URLModel
|
||||
*/
|
||||
public String getMatch()
|
||||
{
|
||||
return getServiceContext() + req.getServiceMatch().getPath();
|
||||
return req.getServiceMatch().getPath();
|
||||
}
|
||||
|
||||
public String jsGet_match()
|
||||
|
@@ -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...
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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];
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user