Package com.sodius.oslc.server
Class OslcResponses
java.lang.Object
com.sodius.oslc.server.OslcResponses
Constructs responses containing a
OSLC-Core-Version header and possibly an OSLC Error entity.- Since:
- 1.3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA class used to build Response instances -
Method Summary
Modifier and TypeMethodDescriptionaccepted()Create a new ResponseBuilder with an Accepted status.Create a new ResponseBuilder with an Accepted status and a representation.Deprecated.badRequest(String message) Deprecated.UseOslcErrors.badRequest(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for a created resource, set the location header using the supplied value.Create a new ResponseBuilder for a created resource, set the location header using the supplied value.error(int status) Deprecated.UseOslcErrors.status(Response.Status, ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Deprecated.UseOslcErrors.status(Response.Status, ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.error(Response.Status status) Deprecated.UseOslcErrors.status(Response.Status, ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.error(Response.Status status, String message) Deprecated.UseOslcErrors.status(Response.Status, ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Deprecated.UseOslcErrors.forbidden(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.Deprecated.UseOslcErrors.forbidden(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.from(ClientResponse response) Create a new ResponseBuilder with the status and entity provided by the specified response.from(ResourceResponse<?> response) Create a new ResponseBuilder with the status and entity provided by the specified response.Create a new ResponseBuilder for an empty response.notFound()Deprecated.UseOslcErrors.notFound(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.Deprecated.UseOslcErrors.notFound(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Deprecated.Won't be removed, but rather useof(OslcError, Logger)insteadCreate a new ResponseBuilder for the provided OSLC error entity and logger.ok()Create a new ResponseBuilder with an OK status.Create a new ResponseBuilder with an OK status and a representation.Deprecated.UseOslcErrors.preconditionFailed(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.preconditionFailed(String message) Deprecated.UseOslcErrors.preconditionFailed(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Deprecated.UseOslcErrors.serverError(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.serverError(String message) Deprecated.UseOslcErrors.serverError(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Deprecated.UseOslcErrors.serviceUnavailable(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.serviceUnavailable(String message) Deprecated.UseOslcErrors.serviceUnavailable(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Deprecated.UseOslcErrors.unauthorized(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.unauthorized(String message) Deprecated.UseOslcErrors.unauthorized(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.
-
Method Details
-
from
Create a new ResponseBuilder with the status and entity provided by the specified response.Below is the list of headers automatically copied, if present, from the specified response into the builder:
ETagLast-Modified
- Parameters:
response- the response to copy into the created builder.- Returns:
- a new ResponseBuilder.
-
from
Create a new ResponseBuilder with the status and entity provided by the specified response.The specified client response is expected to contain a input stream as entity. In such case, this method copies the input stream into a byte array. This byte array is then set as entity in the created builder instance.
Below is the list of headers automatically copied, if present, from the specified response into the builder:
Cache-ControlContent-TypeContent-LengthETagExpiresLast-Modified
- Parameters:
response- the response to copy into the created builder.- Returns:
- a new ResponseBuilder.
- Throws:
IOException- if the entity stream cannot be retrieved.
-
ok
Create a new ResponseBuilder with an OK status.- Returns:
- a new ResponseBuilder.
-
ok
Create a new ResponseBuilder with an OK status and a representation.- Parameters:
entity- the representation entity data.- Returns:
- a new ResponseBuilder.
-
noContent
Create a new ResponseBuilder for an empty response.- Returns:
- a new ResponseBuilder.
-
created
Create a new ResponseBuilder for a created resource, set the location header using the supplied value.- Parameters:
location- the content location.- Returns:
- a new ResponseBuilder.
-
created
Create a new ResponseBuilder for a created resource, set the location header using the supplied value.- Parameters:
location- the content location.entity- the representation entity data.- Returns:
- a new ResponseBuilder.
-
accepted
Create a new ResponseBuilder with an Accepted status.- Returns:
- a new ResponseBuilder.
-
accepted
Create a new ResponseBuilder with an Accepted status and a representation.- Parameters:
entity- the representation entity data.- Returns:
- a new ResponseBuilder.
-
notFound
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder notFound()Deprecated.UseOslcErrors.notFound(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.Create a new ResponseBuilder for a non found resource. The response will contain an OSLC Error entity with the specified HTTP status.- Returns:
- a new ResponseBuilder.
-
notFound
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder notFound(String message) Deprecated.UseOslcErrors.notFound(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for a non found resource with an error message. The response will contain an OSLC Error entity with the specified HTTP status and error message.- Parameters:
message- the associated error message.- Returns:
- a new ResponseBuilder.
-
badRequest
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder badRequest()Deprecated.UseOslcErrors.badRequest(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.Create a new ResponseBuilder for a bad request The response will contain an OSLC Error entity with the specified HTTP status.- Returns:
- a new ResponseBuilder.
-
badRequest
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder badRequest(String message) Deprecated.UseOslcErrors.badRequest(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for a bad request. The response will contain an OSLC Error entity with the specified HTTP status and error message.- Parameters:
message- the associated error message.- Returns:
- a new ResponseBuilder.
-
unauthorized
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder unauthorized()Deprecated.UseOslcErrors.unauthorized(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.Create a new ResponseBuilder for an unauthorized access. The response will contain an OSLC Error entity with the specified HTTP status.- Returns:
- a new ResponseBuilder.
-
unauthorized
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder unauthorized(String message) Deprecated.UseOslcErrors.unauthorized(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for an unauthorized access. The response will contain an OSLC Error entity with the specified HTTP status and error message.- Parameters:
message- the associated error message.- Returns:
- a new ResponseBuilder.
-
forbidden
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder forbidden()Deprecated.UseOslcErrors.forbidden(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.Create a new ResponseBuilder for a forbidden access. The response will contain an OSLC Error entity with the specified HTTP status.- Returns:
- a new ResponseBuilder.
-
forbidden
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder forbidden(String message) Deprecated.UseOslcErrors.forbidden(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for a forbidden access. The response will contain an OSLC Error entity with the specified HTTP status and error message.- Parameters:
message- the associated error message.- Returns:
- a new ResponseBuilder.
-
serverError
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder serverError()Deprecated.UseOslcErrors.serverError(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.Create a new ResponseBuilder with a server error status. The response will contain an OSLC Error entity with the specified HTTP status.- Returns:
- a new ResponseBuilder.
-
serverError
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder serverError(String message) Deprecated.UseOslcErrors.serverError(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for a server error status. The response will contain an OSLC Error entity with the specified HTTP status and error message.- Parameters:
message- the associated error message.- Returns:
- a new ResponseBuilder.
-
preconditionFailed
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder preconditionFailed()Deprecated.UseOslcErrors.preconditionFailed(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.Create a new ResponseBuilder for a precondition that was not verified. The response will contain an OSLC Error entity with the specified HTTP status.- Returns:
- a new ResponseBuilder.
-
preconditionFailed
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder preconditionFailed(String message) Deprecated.UseOslcErrors.preconditionFailed(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for a precondition that was not verified. The response will contain an OSLC Error entity with the specified HTTP status and error message.- Parameters:
message- the associated error message.- Returns:
- a new ResponseBuilder.
-
error
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder error(Response.Status status) Deprecated.UseOslcErrors.status(Response.Status, ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for the provided error status. The response will contain an OSLC Error entity with the specified HTTP status.- Parameters:
status- the error status.- Returns:
- a new ResponseBuilder.
-
error
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder error(Response.Status status, String message) Deprecated.UseOslcErrors.status(Response.Status, ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for the provided error status and message. The response will contain an OSLC Error entity with the specified HTTP status and error message.- Parameters:
status- the error status.message- the associated error message.- Returns:
- a new ResponseBuilder.
-
error
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder error(int status) Deprecated.UseOslcErrors.status(Response.Status, ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for the provided error status. The response will contain an OSLC Error entity with the specified HTTP status.- Parameters:
status- the error status.- Returns:
- a new ResponseBuilder.
-
error
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder error(int status, String message) Deprecated.UseOslcErrors.status(Response.Status, ErrorId, String)andof(OslcError, Logger)for enhanced error reporting.Create a new ResponseBuilder for the provided error status and message. The response will contain an OSLC Error entity with the specified HTTP status and error message.- Parameters:
status- the error status.message- the associated error message.- Returns:
- a new ResponseBuilder.
-
of
@Deprecated(since="1.13.0", forRemoval=false) public static OslcResponses.OslcResponseBuilder of(OslcError error) Deprecated.Won't be removed, but rather useof(OslcError, Logger)insteadCreate a new ResponseBuilder for the provided OSLC error entity. Client should useOslcErrorsto build such entity.Client is recommended to rather use
of(OslcError, Logger), unless the logging strategy of that method is not appropriate for a specific case.- Parameters:
error- the OSLC Error entity.- Returns:
- a new ResponseBuilder.
- Since:
- 1.13.0
- See Also:
-
of
Create a new ResponseBuilder for the provided OSLC error entity and logger. Client should useOslcErrorsto build such entity.- Parameters:
error- the OSLC Error entity.logger- the Logger instance to use when the framework is to log this error.- Returns:
- a new ResponseBuilder.
- Since:
- 1.13.0
- See Also:
-
OslcErrors.badRequest(ErrorId, String)andof(OslcError, Logger)for enhanced error reporting with an error message.