com.taggercat.handlers
Class AbstractURIPatternHandler

java.lang.Object
  extended by com.taggercat.handlers.AbstractRequestHandler
      extended by com.taggercat.handlers.AbstractURIPatternHandler
All Implemented Interfaces:
com.taggercat.el.ELPropertyResolver, RequestHandler

public abstract class AbstractURIPatternHandler
extends AbstractRequestHandler

This is a request handler to process requests that match URI Patterns. The URI pattern is declared with named placeholders such as: /requirements/{type}/{action}/{id}.
The placeholders are specified within the curly brace { and } delimiters.

Unlike the AbstractURIHandler, handlers of this class are not mapped into the controller using a Reg. Expression. Subsequently, these handlers are also not mapped in using the @Actions annotation. Rather, they must be mapped in with the @URIAction annotation.

If constraints are specified on the placeholders, then the placeholder values must also match the constraints.

If the Pattern contains an {action} placeholder, and that placeholder resolves to a non empty value, then the corresponding named action method in this class will be invoked. Or the action name is being specified on a POST with a tcURIActionName parameter. The corresponding action method must also meet the following criteria:

  1. The action method is annotated with @ActionMethod -- barring that, a matching method name
  2. The @ActionMethod annotated actionName matches the substitution value of the {action} placeholder
  3. That method accepts the same number of parameters as there are matching placeholders
  4. That method is available for the current request method; GET or POST
  5. The current user is in one of the specified permission groups ( if any)

If there is no {action} placeholder, you'll typically want to specify a defaultActionMehod in the URIAction annotation. Alternatively, you can use a tcActionName parameter to set the action name.

Otherwise, standard request handling will simply be applied to serve the current response page.

The names and matched values of the placeholder are available using getUriParameters(). If default values are specified, they are used in place of the any non matched placeholders.

See Also:
URIAction
 

Constructor Summary
AbstractURIPatternHandler()
           
 
Method Summary
static java.lang.Object convertStringToType(java.lang.String value, java.lang.Class<?> type)
          Converts a string value to a primitive type value (or String).
 java.util.Map<java.lang.String,java.lang.String> getUriParameters()
           
 URIPattern getUriPattern()
           
static boolean isPrimitiveType(java.lang.Class<?> clazz)
           
 boolean isUserInPermittedActionRole(java.util.List<java.lang.String> actionRoles)
          Checks if the current request's user has access permission to the handler.
 boolean isValidRequestMethod(javax.servlet.http.HttpServletRequest request, java.lang.Boolean validOnPosts, java.lang.Boolean validOnGets)
          Request handlers can optionally specify that they are accepted on POST, and or GET request methods.
 void setUriParameters(java.util.Map<java.lang.String,java.lang.String> uriParameters)
           
 void setUriPattern(URIPattern uriPattern)
           
 
Methods inherited from class com.taggercat.handlers.AbstractRequestHandler
disableClientCache, getDataSourceName, getErrorException, getErrorPage, getErrorPageMethod, getErrorReason, getExplicitDataSourceName, getExplicitDSN, getMatchedPattern, getModel, getRequestController, getResponsePage, getResponsePageMethod, getSessionExpiredPage, getUserName4Log, init, isAjaxRequest, onChainCompleted, resolveProperty, serverTemporaryFile, serveTemporaryFile, service, setActionName, setErrorPage, setErrorPageMethod, setErrorPageMethodToRedirect, setExplicitDataSourceName, setExplicitDSN, setMatchedPattern, setResponsePage, setResponsePageMethod, setResponsePageMethodToRedirect, setSessionExpiredPage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractURIPatternHandler

public AbstractURIPatternHandler()
Method Detail

isUserInPermittedActionRole

public boolean isUserInPermittedActionRole(java.util.List<java.lang.String> actionRoles)
Checks if the current request's user has access permission to the handler. The group names are assigned using the ActionPermission annotation. If permission group names are not specified, then everyone has permission.

Parameters:
actionRoles - the list of roles (groups) this action method is valid for
Returns:
true if the user has permission to the specific action

convertStringToType

public static java.lang.Object convertStringToType(java.lang.String value,
                                                   java.lang.Class<?> type)
Converts a string value to a primitive type value (or String).

Parameters:
value - the string
type - the new value type
Returns:
the converted value

isPrimitiveType

public static boolean isPrimitiveType(java.lang.Class<?> clazz)

isValidRequestMethod

public boolean isValidRequestMethod(javax.servlet.http.HttpServletRequest request,
                                    java.lang.Boolean validOnPosts,
                                    java.lang.Boolean validOnGets)
Request handlers can optionally specify that they are accepted on POST, and or GET request methods. This method returns true if the request handler applies to the current request method.

Parameters:
request - the current request
validOnPosts - set true of this is valid on POST requests
validOnGets - set true of this is valid on GET requests
Returns:
true if the request handler applies to the current request method

getUriParameters

public java.util.Map<java.lang.String,java.lang.String> getUriParameters()

setUriParameters

public void setUriParameters(java.util.Map<java.lang.String,java.lang.String> uriParameters)

getUriPattern

public URIPattern getUriPattern()

setUriPattern

public void setUriPattern(URIPattern uriPattern)