org.springjutsu.validation.util
Class RequestUtils

java.lang.Object
  extended by org.springjutsu.validation.util.RequestUtils

public class RequestUtils
extends Object

A utility class for manipulating requests, or for searching request metadata, etc.

Author:
Clark Duplichien

Field Summary
static String PATH_VAR_PATTERN
          A pattern describing a RESTful url variable
 
Constructor Summary
RequestUtils()
           
 
Method Summary
static Annotation findHandlerAnnotation(Class handlerClass, Class annotationClass)
          Find an annotation on the possibly proxied handler.
static String findMatchingRestPath(String[] candidateViewNames, String[] controllerPaths, javax.servlet.http.HttpServletRequest request)
          Since successView and validationFailureView can contain multiple possible redirection paths using the format incomingRequestPath=outgoingRedirectPath, we'll need to identify which incomingRequestPath best matches the request that generated this validation, and then return the view name (outgoingRedirectPath) associated with that path.
static String[] getControllerRequestPaths(org.springframework.web.method.HandlerMethod handler)
          Given a handler object, return the base controller class-level requestMapping paths.
static javax.servlet.http.HttpServletRequest getRequest()
           
static Map getRequestParameters()
           
static boolean isWebflowRequest()
           
static String removeLeadingAndTrailingSlashes(String path)
          Removes the leading and trailing slashes from a url path.
static String replaceRestPathVariables(String viewName, Map<String,Object> model, javax.servlet.http.HttpServletRequest request)
          Used by successView and validationFailureView.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_VAR_PATTERN

public static final String PATH_VAR_PATTERN
A pattern describing a RESTful url variable

See Also:
Constant Field Values
Constructor Detail

RequestUtils

public RequestUtils()
Method Detail

getRequest

public static javax.servlet.http.HttpServletRequest getRequest()
Returns:
the current thread-bound HttpServletRequest

getRequestParameters

public static Map getRequestParameters()

replaceRestPathVariables

public static String replaceRestPathVariables(String viewName,
                                              Map<String,Object> model,
                                              javax.servlet.http.HttpServletRequest request)
Used by successView and validationFailureView. If the user specifies a path containing RESTful url wildcards, evaluate those wildcard expressions against the current model map, and plug them into the url. If the wildcard is a multisegmented path, get the top level bean from the model map, and fetch the sub path using a beanwrapper instance.

Parameters:
viewName - The view potentially containing wildcards
model - the model map
request - the request
Returns:
a wildcard-substituted view name

findMatchingRestPath

public static String findMatchingRestPath(String[] candidateViewNames,
                                          String[] controllerPaths,
                                          javax.servlet.http.HttpServletRequest request)
Since successView and validationFailureView can contain multiple possible redirection paths using the format incomingRequestPath=outgoingRedirectPath, we'll need to identify which incomingRequestPath best matches the request that generated this validation, and then return the view name (outgoingRedirectPath) associated with that path. This is made simple by looking for the bestMatchingPattern that spring has already kindly exposed in the request attributes.

Parameters:
candidateViewNames - The possible views
controllerPaths - The base path(s) from the controller
request - the request
Returns:
the best matching view name to redirect to.

getControllerRequestPaths

public static String[] getControllerRequestPaths(org.springframework.web.method.HandlerMethod handler)
Given a handler object, return the base controller class-level requestMapping paths. In case the controller specifies one or more base path(s).

Parameters:
handler - the handler object
Returns:
the controller request paths.

findHandlerAnnotation

public static Annotation findHandlerAnnotation(Class handlerClass,
                                               Class annotationClass)
Find an annotation on the possibly proxied handler.

Parameters:
handler - The handler / controller
annotationClass - The annotation to find.
Returns:
The annotation, or null if not present.

removeLeadingAndTrailingSlashes

public static String removeLeadingAndTrailingSlashes(String path)
Removes the leading and trailing slashes from a url path.

Parameters:
path - the path
Returns:
the path without leading and trailing slashes.

isWebflowRequest

public static boolean isWebflowRequest()
Returns:
true if the current web request is associated with Spring Web Flow.


Copyright © 2013 Spring Jutsu. All Rights Reserved.