public static class OslcResponses.OslcResponseBuilder extends Object
Modifier and Type | Method and Description |
---|---|
OslcResponses.OslcResponseBuilder |
alertInfo(String message)
Adds a
X-com-sodius-web-alert-info header in the response, whose value is a rich text to display
in the calling web page as a information notification. |
OslcResponses.OslcResponseBuilder |
alertSuccess(String message)
Adds a
X-com-sodius-web-alert-success header in the response, whose value is a rich text to display
in the calling web page as a success notification. |
OslcResponses.OslcResponseBuilder |
alertWarning(String message)
Adds a
X-com-sodius-web-alert-warning header in the response, whose value is a rich text to display
in the calling web page as a warning notification. |
Response |
build()
Deprecated.
Starting with 1.13, rather use
build(HttpServletRequest, HttpHeaders) |
Response |
build(HttpServletRequest request,
HttpHeaders headers)
Converts the underlying entity, if any, to a
StreamingOutput and creates a Response instance from the current ResponseBuilder. |
WebApplicationException |
buildException()
Creates a WebApplicationException that wraps the response.
|
OslcResponses.OslcResponseBuilder |
header(String name,
Object value)
Add a header to the ResponseBuilder.
|
OslcResponses.OslcResponseBuilder |
headers(ClientResponse response,
String... names)
Copies headers matching the specified header names from the specified response into this builder.
|
OslcResponses.OslcResponseBuilder |
headers(MultivaluedMap<String,?> headers,
String... names)
Copies headers matching the specified header names from the specified map into this builder.
|
OslcResponses.OslcResponseBuilder |
headers(ResourceResponse<?> response,
String... names)
Copies headers matching the specified header names from the specified response into this builder.
|
OslcResponses.OslcResponseBuilder |
noCache()
Adds or replaces existing cache management headers to this builder, in order to prevent the response from being cached.
|
public OslcResponses.OslcResponseBuilder header(String name, Object value)
name
- the name of the header.value
- the value of the header. If value is null
then all current headers of the same name will be removed.public OslcResponses.OslcResponseBuilder headers(ResourceResponse<?> response, String... names)
If no header names are provided, the copied headers will default to:
ETag
Last-Modified
If headers were automatically copied when creating this builder instance, they are no modified by this operation.
response
- a response whose headers are to copy.names
- the headers names to copy. Any response header not part of this list is ignored.OslcResponses.from(ResourceResponse)
public OslcResponses.OslcResponseBuilder headers(ClientResponse response, String... names)
If no header names are provided, the copied headers will default to:
Cache-Control
Content-Type
Content-Length
ETag
Expires
Last-Modified
If headers were automatically copied when creating this builder instance, they are no modified by this operation.
response
- a response whose headers are to copy.names
- the headers names to copy. Any response header not part of this list is ignored.OslcResponses.from(ClientResponse)
public OslcResponses.OslcResponseBuilder headers(MultivaluedMap<String,?> headers, String... names)
If no header names are provided, this method has no effect.
headers
- a map of headers.names
- the headers names to copy. Any header not part of this list is ignored.public OslcResponses.OslcResponseBuilder noCache()
The headers are:
Cache-Control
Pragma
Expires
public OslcResponses.OslcResponseBuilder alertSuccess(String message)
X-com-sodius-web-alert-success
header in the response, whose value is a rich text to display
in the calling web page as a success notification.
This shall be used for example to confirm the creation of an element on server side, as requested by the user.
The message must contain valid XHTML content, so that HTML formatting can be used to render the message in the web page (e.g. <strong> elements).
Such notification is usually displayed at top right of the screen and auto hides after a few seconds.
message
- the rich text message to display in the caller web page.public OslcResponses.OslcResponseBuilder alertInfo(String message)
X-com-sodius-web-alert-info
header in the response, whose value is a rich text to display
in the calling web page as a information notification.
This shall be used for example to let the user know the request was fulfilled
but he has another action to take to complete the overall process.
The message must contain valid XHTML content, so that HTML formatting can be used to render the message in the web page (e.g. <strong> elements).
Such notification is usually displayed at top right of the screen.
message
- the rich text message to display in the caller web page.public OslcResponses.OslcResponseBuilder alertWarning(String message)
X-com-sodius-web-alert-warning
header in the response, whose value is a rich text to display
in the calling web page as a warning notification.
This shall be used for example to let the user know the request was fulfilled
but something is suspicious and he's recommended to review some settings.
The message must contain valid XHTML content, so that HTML formatting can be used to render the message in the web page (e.g. <strong> elements).
Such notification is usually displayed at top right of the screen.
message
- the rich text message to display in the caller web page.public Response build(HttpServletRequest request, HttpHeaders headers)
StreamingOutput
and creates a Response instance from the current ResponseBuilder.
The builder is reset to a blank state.
This conversion capability is usually the responsibility of the JAX-RS framework.
However there are cases where the list of providers used or the priority of those providers cannot be controlled.
This method uses OslcStreams
to serialize the entity and control the providers used for that.
Refer to the documentation of OslcStreams
for more information
request
- the servlet request to inject into providers.headers
- the HTTP headers to inject into providers.IllegalArgumentException
- if either the entity type or media type is not supported by this class.OslcStreams.toStream(Object, HttpServletRequest, HttpHeaders)
@Deprecated public Response build()
build(HttpServletRequest, HttpHeaders)
Callers are now recommended to rather use build(HttpServletRequest, HttpHeaders)
,
which converts the underlying entity, if any, to a StreamingOutput
.
This improves reliability of responses and independence on the deployment.
public WebApplicationException buildException()