Package org.restheart.exchange
Class Exchange<T>
- java.lang.Object
-
- org.restheart.exchange.Exchange<T>
-
- Type Parameters:
T-
public abstract class Exchange<T> extends Object
The root class in the exchange hierarchy. An exchange wraps undertow HttpServerExchange to provide simplified access to elements of the request and of the response, such as query parameters, headers and content- Author:
- Andrea Di Cesare
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPP_FORM_URLENCODED_TYPEstatic StringAPPLICATION_PDF_TYPEstatic StringHAL_JSON_MEDIA_TYPESupported content typesprotected static io.undertow.util.AttachmentKey<Boolean>IN_ERROR_KEYstatic StringJSON_MEDIA_TYPEprotected static org.slf4j.LoggerLOGGERstatic intMAX_BUFFERSstatic intMAX_CONTENT_SIZEstatic StringMULTIPART_FORM_DATA_TYPEprotected io.undertow.server.HttpServerExchangewrapped
-
Constructor Summary
Constructors Constructor Description Exchange(io.undertow.server.HttpServerExchange exchange)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract StringgetContentType()io.undertow.server.HttpServerExchangegetExchange()protected io.undertow.server.HttpServerExchangegetWrappedExchange()booleanisAccountInRole(String role)helper method to check if authenticated account is in the specified rolebooleanisAuthenticated()helper method to check if request is authenticatedstatic booleanisAuthenticated(io.undertow.server.HttpServerExchange exchange)booleanisContentTypeJson()helper method to check if the request content is JsonbooleanisContentTypeText()helper method to check if the request content is textbooleanisContentTypeXml()helper method to check if the request content is XmbooleanisInError()static booleanisInError(io.undertow.server.HttpServerExchange exchange)static booleanresponseInterceptorsExecuted(io.undertow.server.HttpServerExchange exchange)voidsetInError(boolean inError)static voidsetInError(io.undertow.server.HttpServerExchange exchange)static voidsetResponseInterceptorsExecuted(io.undertow.server.HttpServerExchange exchange)static voidupdateBufferSize(int bufferSize)
-
-
-
Field Detail
-
LOGGER
protected static org.slf4j.Logger LOGGER
-
HAL_JSON_MEDIA_TYPE
public static final String HAL_JSON_MEDIA_TYPE
Supported content types- See Also:
- Constant Field Values
-
JSON_MEDIA_TYPE
public static final String JSON_MEDIA_TYPE
- See Also:
- Constant Field Values
-
APP_FORM_URLENCODED_TYPE
public static final String APP_FORM_URLENCODED_TYPE
- See Also:
- Constant Field Values
-
APPLICATION_PDF_TYPE
public static final String APPLICATION_PDF_TYPE
- See Also:
- Constant Field Values
-
MULTIPART_FORM_DATA_TYPE
public static final String MULTIPART_FORM_DATA_TYPE
- See Also:
- Constant Field Values
-
IN_ERROR_KEY
protected static final io.undertow.util.AttachmentKey<Boolean> IN_ERROR_KEY
-
MAX_CONTENT_SIZE
public static final int MAX_CONTENT_SIZE
- See Also:
- Constant Field Values
-
MAX_BUFFERS
public static int MAX_BUFFERS
-
wrapped
protected final io.undertow.server.HttpServerExchange wrapped
-
-
Method Detail
-
updateBufferSize
public static void updateBufferSize(int bufferSize)
-
getWrappedExchange
protected io.undertow.server.HttpServerExchange getWrappedExchange()
- Returns:
- the wrapped HttpServerExchange
-
isInError
public static boolean isInError(io.undertow.server.HttpServerExchange exchange)
-
isAuthenticated
public static boolean isAuthenticated(io.undertow.server.HttpServerExchange exchange)
-
setInError
public static void setInError(io.undertow.server.HttpServerExchange exchange)
-
responseInterceptorsExecuted
public static boolean responseInterceptorsExecuted(io.undertow.server.HttpServerExchange exchange)
-
setResponseInterceptorsExecuted
public static void setResponseInterceptorsExecuted(io.undertow.server.HttpServerExchange exchange)
-
getExchange
public io.undertow.server.HttpServerExchange getExchange()
-
getContentType
public abstract String getContentType()
-
isContentTypeJson
public boolean isContentTypeJson()
helper method to check if the request content is Json- Returns:
- true if Content-Type request header is application/json
-
isInError
public boolean isInError()
- Returns:
- ttrue if request is errored
-
setInError
public void setInError(boolean inError)
- Parameters:
inError- the inError to set
-
isContentTypeXml
public boolean isContentTypeXml()
helper method to check if the request content is Xm- Returns:
- true if Content-Type request header is application/xml or text/xml
-
isContentTypeText
public boolean isContentTypeText()
helper method to check if the request content is text- Returns:
- true if Content-Type request header starts with text/
-
isAuthenticated
public boolean isAuthenticated()
helper method to check if request is authenticated- Returns:
- true if request is authenticated
-
isAccountInRole
public boolean isAccountInRole(String role)
helper method to check if authenticated account is in the specified role- Parameters:
role-- Returns:
-
-