Package org.forgerock.http.protocol
Class Responses
java.lang.Object
org.forgerock.http.protocol.Responses
Provide out-of-the-box, pre-configured
Response objects.-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Exception>
AsyncFunction<E,Response, NeverThrowsException> Utility method returning an async function that creates aResponsewith statusStatus.INTERNAL_SERVER_ERRORand the exception set as the cause.static ResponseGenerates an empty Forbidden response (403).static ResponseGenerates an empty Internal Server Error response (500).static ResponsenewInternalServerError(Exception exception) Generates an Internal Server Error response (500) containing the cause of the error response.static ResponseGenerates an empty Not Found response (404).static <V,E extends Exception>
AsyncFunction<NeverThrowsException,V, E> Utility method returning an empty async function, whose goal is to ease the transformation of aPromisetype.static <V,E extends Exception>
Function<NeverThrowsException,V, E> Utility method returning an empty function, whose goal is to ease the transformation of aPromisetype.static <E extends Exception>
Function<E,Response, NeverThrowsException> Utility function that returns aResponsewhose status isStatus.INTERNAL_SERVER_ERRORand the exception attached to the response as the cause.
-
Method Details
-
newInternalServerError
Generates an empty Internal Server Error response (500).- Returns:
- an empty Internal Server Error response (500).
-
newInternalServerError
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
Generates an empty Not Found response (404).- Returns:
- an empty Not Found response (404).
-
newForbidden
Generates an empty Forbidden response (403).- Returns:
- an empty Forbidden response (403).
-
noopExceptionFunction
Utility method returning an empty function, whose goal is to ease the transformation of aPromisetype. 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, anExceptionof typeNeverThrowsExceptionwill never be thrown.- Type Parameters:
V- The expected type of that functionE- The newExceptionthat 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, noopExceptionAsyncFunction()E> Utility method returning an empty async function, whose goal is to ease the transformation of aPromisetype.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, anExceptionof typeNeverThrowsExceptioncan never be thrown anyway.- Type Parameters:
V- The expected type of that async functionE- The newExceptiontype that can be thrown by this function.- Returns:
- an async function that will complete with an
IllegalStateExceptionif invoked (should never happen).
-
onExceptionInternalServerError
public static <E extends Exception> Function<E,Response, onExceptionInternalServerError()NeverThrowsException> Utility function that returns aResponsewhose status isStatus.INTERNAL_SERVER_ERRORand the exception attached to the response as the cause.- Type Parameters:
E- The type of the incoming exception- Returns:
Responsewhose status isStatus.INTERNAL_SERVER_ERRORand the exception attached to the response as the cause.
-
internalServerError
public static <E extends Exception> AsyncFunction<E,Response, internalServerError()NeverThrowsException> Utility method returning an async function that creates aResponsewith statusStatus.INTERNAL_SERVER_ERRORand the exception set as the cause.- Type Parameters:
E- The type of the incomingException- Returns:
- an async function that creates a
Responsewith statusStatus.INTERNAL_SERVER_ERRORand the exception set as the cause.
-