Package org.forgerock.http.protocol
Class Responses
- java.lang.Object
-
- org.forgerock.http.protocol.Responses
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E extends Exception>
AsyncFunction<E,Response,NeverThrowsException>internalServerError()
Utility method returning an async function that creates aResponse
with statusStatus.INTERNAL_SERVER_ERROR
and the exception set as the cause.static Response
newForbidden()
Generates an empty Forbidden response (403).static Response
newInternalServerError()
Generates an empty Internal Server Error response (500).static Response
newInternalServerError(Exception exception)
Generates an Internal Server Error response (500) containing the cause of the error response.static Response
newNotFound()
Generates an empty Not Found response (404).static <V,E extends Exception>
AsyncFunction<NeverThrowsException,V,E>noopExceptionAsyncFunction()
Utility method returning an empty async function, whose goal is to ease the transformation of aPromise
type.static <V,E extends Exception>
Function<NeverThrowsException,V,E>noopExceptionFunction()
Utility method returning an empty function, whose goal is to ease the transformation of aPromise
type.static <E extends Exception>
Function<E,Response,NeverThrowsException>onExceptionInternalServerError()
Utility function that returns aResponse
whose status isStatus.INTERNAL_SERVER_ERROR
and the exception attached to the response as the cause.
-
-
-
Method Detail
-
newInternalServerError
public static Response newInternalServerError()
Generates an empty Internal Server Error response (500).- Returns:
- an empty Internal Server Error response (500).
-
newInternalServerError
public static Response newInternalServerError(Exception exception)
Generates an Internal Server Error response (500) containing the cause of the error response.- Parameters:
exception
- wrapped exception- Returns:
- an empty Internal Server Error response 500 with the cause set.
-
newNotFound
public static Response newNotFound()
Generates an empty Not Found response (404).- Returns:
- an empty Not Found response (404).
-
newForbidden
public static Response newForbidden()
Generates an empty Forbidden response (403).- Returns:
- an empty Forbidden response (403).
-
noopExceptionFunction
public static <V,E extends Exception> Function<NeverThrowsException,V,E> noopExceptionFunction()
Utility method returning an empty function, whose goal is to ease the transformation of aPromise
type. Its main usage will be as the second argument inPromise.then(Function, Function)
. The implementation of this function is just to return null : as its name suggests it, anException
of typeNeverThrowsException
will never be thrown.- Type Parameters:
V
- The expected type of that functionE
- The newException
that can be thrown by this function.- Returns:
- a function that will return null and not throw any
Exception
.
-
noopExceptionAsyncFunction
public static <V,E extends Exception> AsyncFunction<NeverThrowsException,V,E> noopExceptionAsyncFunction()
Utility method returning an empty async function, whose goal is to ease the transformation of aPromise
type.Its main usage will be as the exception handling function in
Promise.thenAsync(AsyncFunction, AsyncFunction)
.The implementation of this function is throwing an
IllegalStateException
: as its name suggests, anException
of typeNeverThrowsException
can never be thrown anyway.- Type Parameters:
V
- The expected type of that async functionE
- The newException
type that can be thrown by this function.- Returns:
- an async function that will complete with an
IllegalStateException
if invoked (should never happen).
-
onExceptionInternalServerError
public static <E extends Exception> Function<E,Response,NeverThrowsException> onExceptionInternalServerError()
Utility function that returns aResponse
whose status isStatus.INTERNAL_SERVER_ERROR
and the exception attached to the response as the cause.- Type Parameters:
E
- The type of the incoming exception- Returns:
Response
whose status isStatus.INTERNAL_SERVER_ERROR
and the exception attached to the response as the cause.
-
internalServerError
public static <E extends Exception> AsyncFunction<E,Response,NeverThrowsException> internalServerError()
Utility method returning an async function that creates aResponse
with statusStatus.INTERNAL_SERVER_ERROR
and the exception set as the cause.- Type Parameters:
E
- The type of the incomingException
- Returns:
- an async function that creates a
Response
with statusStatus.INTERNAL_SERVER_ERROR
and the exception set as the cause.
-
-