org.ibisph.mvc.controller
Class GenericXMLXSLTTransformation

java.lang.Object
  extended by org.ibisph.mvc.controller.GenericXMLXSLTTransformation
All Implemented Interfaces:
org.springframework.web.servlet.mvc.Controller

public class GenericXMLXSLTTransformation
extends java.lang.Object
implements org.springframework.web.servlet.mvc.Controller

Generic XML / XSLT Transformation Controller. Performs XML/XSLT transformations based on HTTP URL request parameters. This controller provides backward compatibility with older bookmarked urls and testing of transformations before setting them into the "html" type request. This controller is NOT a typical Spring MVC controller as it handles the model (XML) and the view (XSLT) all within the controller. This controller did have the capability of creating a local file for output. However, since this is a big time security hole it was removed. Consider that a hacker could specify the xmlURL and xsltURL to their files then save the result to the local server then hit that page and have it do whatever they designed it to do or consider something like over writing the welcome page etc.

Author:
Garth Braithwaite, STG

Field Summary
protected  java.lang.String defaultContentType
           
protected  Transformation transformation
           
protected  java.lang.String webAppURLContextPrefixParameterName
           
protected  java.lang.String xmlPath
           
protected  java.lang.String xsltPath
           
 
Constructor Summary
GenericXMLXSLTTransformation()
          Blank constructor - all properties set with specific setter methods.
GenericXMLXSLTTransformation(java.lang.String xmlPath, java.lang.String xsltPath, Transformation transformation)
          Basic constructor which simply sets all three main properties.
 
Method Summary
 org.springframework.web.servlet.ModelAndView handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Spring Controller handleRequest implementation.
 void setDefaultResponseContentType(java.lang.String defaultContentType)
          Set the default content type that this controller should return to the user's browser.
 void setTransformation(Transformation transformation)
          Sets the XML/XSLT transformation object.
 void setWebAppURLContextPrefixParameterName(java.lang.String webAppURLContextPrefixParameterName)
          Sets "WebAppURLContextPrefix" Parameter Name.
 void setXMLPath(java.lang.String xmlPath)
          Sets XML base path prefix.
 void setXSLTPath(java.lang.String xsltPath)
          Sets XSLT base path prefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultContentType

protected java.lang.String defaultContentType

xmlPath

protected java.lang.String xmlPath

xsltPath

protected java.lang.String xsltPath

transformation

protected Transformation transformation

webAppURLContextPrefixParameterName

protected java.lang.String webAppURLContextPrefixParameterName
Constructor Detail

GenericXMLXSLTTransformation

public GenericXMLXSLTTransformation()
Blank constructor - all properties set with specific setter methods.


GenericXMLXSLTTransformation

public GenericXMLXSLTTransformation(java.lang.String xmlPath,
                                    java.lang.String xsltPath,
                                    Transformation transformation)
Basic constructor which simply sets all three main properties.

Parameters:
xmlPath - Optional base XML file path prefix.
xsltPath - Optional base XSLT file path prefix.
transformation - Required XML/XSLT transformation object.
Method Detail

setXMLPath

public void setXMLPath(java.lang.String xmlPath)
Sets XML base path prefix. The XML file is specified as part of the URL. The file's first location tried is this path concatenated with the URL xml parameter path.

Parameters:
xmlPath - Base XML file path prefix.

setXSLTPath

public void setXSLTPath(java.lang.String xsltPath)
Sets XSLT base path prefix. The XSLT file is specified as part of the URL. The file's first location tried is this path concatenated with the URL xslt parameter path.

Parameters:
xsltPath - Base XSLT file path prefix.

setTransformation

public void setTransformation(Transformation transformation)
Sets the XML/XSLT transformation object.

Parameters:
transformation - Required XML/XSLT transformation object.

setDefaultResponseContentType

public void setDefaultResponseContentType(java.lang.String defaultContentType)
Set the default content type that this controller should return to the user's browser.

Parameters:
defaultContentType - This value is typically text/html.

setWebAppURLContextPrefixParameterName

public void setWebAppURLContextPrefixParameterName(java.lang.String webAppURLContextPrefixParameterName)
Sets "WebAppURLContextPrefix" Parameter Name. This key is used by by the XSLT to get the value of the web application's context prefix to control the "ibis:" relative local URLs being built by the XSLT. This allows the XSLT code to be written with relative root paths so that the URLs are application name deployment independent.

Parameters:
webAppURLContextPrefixParameterName - Parameters map key that is passed as a parameter to the XSLT.

handleRequest

public org.springframework.web.servlet.ModelAndView handleRequest(javax.servlet.http.HttpServletRequest request,
                                                                  javax.servlet.http.HttpServletResponse response)
                                                           throws java.lang.Exception
Spring Controller handleRequest implementation. This is the main action handler that gets the specified XML and XSLT the creates the resultant product using the transformer and returns to the user. This controller checks for the following parameters:

Specified by:
handleRequest in interface org.springframework.web.servlet.mvc.Controller
Parameters:
request - HTTP Servlet Request passed from the servlet.
response - HTTP Servlet Response passed from the servlet.
Returns:
null - the model and view are already handled within this controller.
Throws:
java.lang.Exception