net.craftforge.essential.controller
Class Setup

java.lang.Object
  extended by net.craftforge.essential.controller.Setup

public class Setup
extends Object

Data structure containing all external (request and configuration) information for the phases.

Since:
06.02.2011
Author:
Christian Bick

Constructor Summary
Setup(ResourceManager resourceManager, DocumentationManager documentationManager, Configuration configuration, Request request, Response response)
          Constructs the setup.
 
Method Summary
 String getAcceptedCharset()
          Gets the encoding charset for result serialization.
 String getAcceptedMediaType()
          Gets the media type for result serialization.
 Map<String,String[]> getAllParameters()
          Gets all query, form and resource parameters.
 BodyHandler getBodyHandler()
          Gets the body handler.
 Configuration getConfiguration()
          Gets the controller configuration.
 DocumentationManager getDocumentationManager()
          Gets the documentation manager.
 HeaderHandler getHeaderHandler()
          Gets the header handler.
 String getHttpMethod()
          Gets the HTTP method for result serialization.
 ParameterHandler getParameterHandler()
          Gets the parameter handler.
 Map<String,String[]> getPathParameters()
          Gets the resource parameters.
 PropertyHandler getPropertyHandler()
          Gets the property handler.
 Map<String,String[]> getQueryParameters()
          Gets the URI query parameters.
 Request getRequest()
          Gets the normalized HTTP request.
 InputStream getRequestBodyInputStream()
          Gets the body input stream.
 String getRequestUrlInfoPart()
          Gets the request URL info part.
 String getRequestUrlMetaPart()
          Gets the request URL meta part.
 String getRequestUrlResourcePart()
          Gets the request URL resource path by removing the meta data part from the URL info part.
 ResourceManager getResourceManager()
          Gets the resource manager.
 Response getResponse()
          Gets the normalized HTTP response.
 OutputStream getResponseBodyOutputStream()
          Gets the output stream for streaming the serialized response body.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Setup

public Setup(ResourceManager resourceManager,
             DocumentationManager documentationManager,
             Configuration configuration,
             Request request,
             Response response)
Constructs the setup.

Parameters:
resourceManager - The resource manager
documentationManager - The documentation manager
configuration - The controller configuration
request - The normalized HTTP request
response - The normalized HTTP response
Method Detail

getParameterHandler

public ParameterHandler getParameterHandler()
Gets the parameter handler. The parameter handler provides a convenient access to the HTTP parameters submitted.

Returns:
The parameter handler

getHeaderHandler

public HeaderHandler getHeaderHandler()
Gets the header handler. The header handler provides a convenient access to the HTTP headers submitted.

Returns:
The header handler

getBodyHandler

public BodyHandler getBodyHandler()
Gets the body handler. The body handler provides a convenient access to the HTTP body submitted.

Returns:
The body handler

getPropertyHandler

public PropertyHandler getPropertyHandler()
Gets the property handler. The property handler provides a convenient access to the controller configuration properties.

Returns:
The property handler

getAcceptedMediaType

public String getAcceptedMediaType()
                            throws ControllerException
Gets the media type for result serialization. Will use the accepted media type of the request if not overridden in the URL meta part of the URL info part. (e.g. my/path.json)

Returns:
The media type
Throws:
ControllerException - if the header was not submitted not and no default value is set

getAcceptedCharset

public String getAcceptedCharset()
                          throws ControllerException
Gets the encoding charset for result serialization. Will use the accepted charset of the request.

Returns:
The encoding charset
Throws:
ControllerException - if the header was not submitted not and no default value is set

getHttpMethod

public String getHttpMethod()
Gets the HTTP method for result serialization. Will use the HTTP method of the request if not overridden in the URL meta part of the URL info part. (e.g. my/path.put)

Returns:
The HTTP method

getResourceManager

public ResourceManager getResourceManager()
Gets the resource manager.

Returns:
The resource manager

getDocumentationManager

public DocumentationManager getDocumentationManager()
Gets the documentation manager.

Returns:
The documentation manager

getConfiguration

public Configuration getConfiguration()
Gets the controller configuration.

Returns:
The controller configuration

getRequestUrlResourcePart

public String getRequestUrlResourcePart()
Gets the request URL resource path by removing the meta data part from the URL info part. This is everything in the URL info part from the beginning until the first occurring dot (excluded). (my/path.put.xml -> my/path)

Returns:
The request URL resource part

getRequestUrlMetaPart

public String getRequestUrlMetaPart()
Gets the request URL meta part. This is everything in the URL info part from the first occurring dot (included) till the end. (my/path.put.xml -> .put.xml)

Returns:
The request URL meta part

getRequestUrlInfoPart

public String getRequestUrlInfoPart()
Gets the request URL info part. This is the part that is used by the framework for all allocation, path parameter and meta data related information gathering.

Returns:
The request URL info part

getQueryParameters

public Map<String,String[]> getQueryParameters()
Gets the URI query parameters.

Returns:
The query parameter map

getPathParameters

public Map<String,String[]> getPathParameters()
Gets the resource parameters.

Returns:
The path parameter map

getAllParameters

public Map<String,String[]> getAllParameters()
Gets all query, form and resource parameters.

Returns:
The parameter map

getRequestBodyInputStream

public InputStream getRequestBodyInputStream()
Gets the body input stream. Will return null if HTTP method is not PUT or POST and if the header 'Content-Type' is set to application/x-www-form-urlencoded.

Returns:
The input stream of the request body

getResponseBodyOutputStream

public OutputStream getResponseBodyOutputStream()
Gets the output stream for streaming the serialized response body.

Returns:
The output stream

getRequest

public Request getRequest()
Gets the normalized HTTP request.

Returns:
The HTTP request

getResponse

public Response getResponse()
Gets the normalized HTTP response.

Returns:
The HTTP response


Copyright © 2011. All Rights Reserved.