org.springframework.extensions.surf.mvc
Class VirtualizedResourceController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.support.WebContentGenerator
              extended by org.springframework.web.servlet.mvc.AbstractController
                  extended by org.springframework.extensions.webscripts.servlet.mvc.ResourceController
                      extended by org.springframework.extensions.surf.mvc.VirtualizedResourceController
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.mvc.Controller

public class VirtualizedResourceController
extends ResourceController

Virtualized Spring controller for retrieving and serving resources. This builds on the default resource controller provided by the Web Script Framework. It empowers the controller to retrieve resources from remote CMIS stores ahead of the web application. This empowers the web application with preview capabilities. This controller retrieves content by interrogating resource providers in the following order: 1) CMIS Resource Store (i.e. Alfresco Store) 2) Web application path 3) Delegation to default url handler (typically the Spring JS resource servlet) The first provider is only consulted if the Web Framework is running in preview mode. If the Web Framework is configured to run in production mode, virtualized resource stores are never considered. The following URL formats are supported: /resource/?e=&s=& /resource/?e=&s= /resource/?e= /resource/?s= /resource/ In the latter cases, the web framework's selected store and webapp are determined from session and reused. This enables the case for resources to be loaded as though they were local to disk (and located in the /resource context).

Author:
muzquiano

Field Summary
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
METHOD_GET, METHOD_HEAD, METHOD_POST
 
Constructor Summary
VirtualizedResourceController()
           
 
Method Summary
 boolean checkRemoteResourceExists(RequestContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path, String endpointId, String storeId, String webappId)
          Checks for the existence of a resource on a remote store
 boolean dispatchResource(String path, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Dispatches to the resource with the given path
 org.apache.commons.logging.Log getLogger()
           
 WebFrameworkServiceRegistry getServiceRegistry()
          Gets the service registry.
 boolean retrieveRemoteResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path, String endpointId, String storeId, String webappId)
          Retrieves content from the given remote store and streams back to the response
 void setServiceRegistry(WebFrameworkServiceRegistry webFrameworkServiceRegistry)
          Sets the service registry.
 
Methods inherited from class org.springframework.extensions.webscripts.servlet.mvc.ResourceController
commitResponse, copyStream, getDefaultUrl, handleRequestInternal, setDefaultUrl
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualizedResourceController

public VirtualizedResourceController()
Method Detail

setServiceRegistry

public void setServiceRegistry(WebFrameworkServiceRegistry webFrameworkServiceRegistry)
Sets the service registry.

Parameters:
webFrameworkServiceRegistry - the new service registry

getServiceRegistry

public WebFrameworkServiceRegistry getServiceRegistry()
Gets the service registry.

Returns:
the service registry

getLogger

public org.apache.commons.logging.Log getLogger()
Overrides:
getLogger in class ResourceController

dispatchResource

public boolean dispatchResource(String path,
                                javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
                         throws javax.servlet.ServletException,
                                IOException
Description copied from class: ResourceController
Dispatches to the resource with the given path

Overrides:
dispatchResource in class ResourceController
Parameters:
path - the path
request - the request
response - the response
Returns:
true, if the dispatch succeeded
Throws:
javax.servlet.ServletException
IOException

retrieveRemoteResource

public boolean retrieveRemoteResource(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      String path,
                                      String endpointId,
                                      String storeId,
                                      String webappId)
                               throws javax.servlet.ServletException,
                                      IOException
Retrieves content from the given remote store and streams back to the response

Parameters:
request - http servlet request
response - http servlet response
path - the path to be included
endpointId - the endpoint to utilize (optional)
storeId - the store to utilize (optional)
webappId - the webapp to utilize (optional)
Returns:
whether the resource was served back successfully
Throws:
javax.servlet.ServletException
IOException

checkRemoteResourceExists

public boolean checkRemoteResourceExists(RequestContext context,
                                         javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         String path,
                                         String endpointId,
                                         String storeId,
                                         String webappId)
                                  throws javax.servlet.ServletException,
                                         IOException
Checks for the existence of a resource on a remote store

Parameters:
context - the request context
request - http servlet request
response - http servlet response
path - the path to the asset
endpointId - the endpoint where the resource lives
storeId - the store within which the resource lives
webappId - the web application that the resource lives in
Returns:
Throws:
javax.servlet.ServletException
IOException


Copyright © 2009 SpringSource, Inc. All Rights Reserved.