SessionProviderService sessionProviderService =
(SessionProviderService)container.getComponentInstanceOfType(SessionProviderService.class);
RepositoryService repositoryService =
(RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
CommandService commandService = (CommandService)container.getComponentInstanceOfType(CommandService.class);
GenericWebAppContext ctx;
try
{
ctx =
new GenericWebAppContext(getServletContext(), request, response, sessionProviderService
.getSessionProvider(null), // null for
// ThreadLocalSessionProvider
repositoryService.getDefaultRepository());
}
catch (final RepositoryException e)
{
throw new IOException()
{
@Override
public Throwable getCause()
{
return e;
}
};
}
catch (final RepositoryConfigurationException e)
{
throw new IOException()
{
@Override
public Throwable getCause()
{
return e;
}
};
}
String catalogName = (String)ctx.get(WebConstants.CATALOG_NAME);
String wsName = (String)ctx.get("workspace");
if (wsName != null)
ctx.setCurrentWorkspace(wsName);
String currentPath = (String)ctx.get("path");
if (currentPath == null)
throw new ServletException("Path undefined " + request.getParameter("path") + " Request: "
+ request.getRequestURI());
try
{
Command cmd;
if (catalogName == null)
cmd = commandService.getCatalog().getCommand("displayResource");
else
cmd = commandService.getCatalog(catalogName).getCommand("displayResource");
if (cmd == null)
throw new Exception("No 'displayResource' command found");
ctx.put("path", currentPath);
ctx.put("cache-control-max-age", getServletConfig().getInitParameter("cache-control-max-age"));