GeoPubby  Version 0.1.0.0
RequestParamHandler Class Reference

Analyzes an HttpServletRequest to check for the presence of an ?output=n3 or =ttl or =rdfxml request parameter in the URI. More...

Collaboration diagram for RequestParamHandler:

Classes

class  WrappedRequest
 

Public Member Functions

 RequestParamHandler (HttpServletRequest request)
 
boolean isMatchingRequest ()
 
HttpServletRequest getModifiedRequest ()
 

Static Public Member Functions

static String removeOutputRequestParam (String uri)
 Removes the "output=foobar" part of a URI if present. More...
 

Static Package Functions

 [static initializer]
 

Private Member Functions

String identifyRequestedType (String parameterValue)
 

Private Attributes

final HttpServletRequest request
 
final String requestedType
 

Static Private Attributes

static final String ATTRIBUTE_NAME_IS_HANDLED
 
static final Map< String, String > mimeTypes = new HashMap<String,String>()
 

Detailed Description

Analyzes an HttpServletRequest to check for the presence of an ?output=n3 or =ttl or =rdfxml request parameter in the URI.

If present, returns a modified HttpServletRequest that has the appropriate MIME type in the Accept: header. This request can then be fed into the rest of our content negotiation based tooling.

Constructor & Destructor Documentation

◆ RequestParamHandler()

RequestParamHandler ( HttpServletRequest  request)
106  {
107  this.request = request;
108  requestedType = identifyRequestedType(request.getParameter("output"));
109  }
final String requestedType
Definition: RequestParamHandler.java:104
String identifyRequestedType(String parameterValue)
Definition: RequestParamHandler.java:122
final HttpServletRequest request
Definition: RequestParamHandler.java:103

References RequestParamHandler.identifyRequestedType(), RequestParamHandler.request, and RequestParamHandler.requestedType.

Member Function Documentation

◆ [static initializer]()

[static initializer]
staticpackage

◆ getModifiedRequest()

HttpServletRequest getModifiedRequest ( )
118  {
119  return new WrappedRequest();
120  }

Referenced by ModelResponse.ModelResponse().

◆ identifyRequestedType()

String identifyRequestedType ( String  parameterValue)
private
122  {
123  if (mimeTypes.containsKey(parameterValue)) {
124  return parameterValue;
125  }
126  return null;
127  }
static final Map< String, String > mimeTypes
Definition: RequestParamHandler.java:22

References RequestParamHandler.mimeTypes.

Referenced by RequestParamHandler.RequestParamHandler().

◆ isMatchingRequest()

boolean isMatchingRequest ( )
111  {
112  if ("true".equals(request.getAttribute(ATTRIBUTE_NAME_IS_HANDLED))) {
113  return false;
114  }
115  return requestedType != null;
116  }
static final String ATTRIBUTE_NAME_IS_HANDLED
Definition: RequestParamHandler.java:20

References RequestParamHandler.ATTRIBUTE_NAME_IS_HANDLED, RequestParamHandler.request, and RequestParamHandler.requestedType.

Referenced by ModelResponse.ModelResponse().

◆ removeOutputRequestParam()

static String removeOutputRequestParam ( String  uri)
static

Removes the "output=foobar" part of a URI if present.

94  {
95  // Remove the param: output=[a-z0-9]*
96  // There are two cases. The param can occur at the end of the URI,
97  // this is matched by the first part: [?&]param$
98  // Or it can occur elsewhere, then it's matched by param& with a
99  // lookbehind that requires [?&] to occur before the pattern.
100  return uri.replaceFirst("([?&]output=[a-z0-9]*$)|((?<=[?&])output=[a-z0-9]*&)", "");
101  }

Member Data Documentation

◆ ATTRIBUTE_NAME_IS_HANDLED

final String ATTRIBUTE_NAME_IS_HANDLED
staticprivate
Initial value:
=
"OutputRequestParamHandler.isHandled"

Referenced by RequestParamHandler.isMatchingRequest(), and RequestParamHandler.WrappedRequest.WrappedRequest().

◆ mimeTypes

final Map<String,String> mimeTypes = new HashMap<String,String>()
staticprivate

◆ request

◆ requestedType