Class OslcErrors

java.lang.Object
com.sodius.oslc.server.OslcErrors

public class OslcErrors extends Object
Constructs OSLC Error resources for a server to provide detailed information when responding with errors.
Since:
1.13.0
  • Method Details

    • status

      public static OslcErrors.OslcErrorBuilder status(Response.Status status, OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for the given HTTP status, error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      status - the HTTP status for the response.
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • status

      public static OslcErrors.OslcErrorBuilder status(int status, OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for the given HTTP status, error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      status - the HTTP status for the response.
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • badRequest

      public static OslcErrors.OslcErrorBuilder badRequest(OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for an HTTP 400 Bad Request error with the given error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • forbidden

      public static OslcErrors.OslcErrorBuilder forbidden(OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for an HTTP 403 Forbidden error with the given error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • notFound

      public static OslcErrors.OslcErrorBuilder notFound(OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for an HTTP 404 Not Found error with the given error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • preconditionFailed

      public static OslcErrors.OslcErrorBuilder preconditionFailed(OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for an HTTP 412 Precondition Failed error with the given error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • serviceUnavailable

      public static OslcErrors.OslcErrorBuilder serviceUnavailable(OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for an HTTP 503 Service Unavailable error with the given error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • serverError

      public static OslcErrors.OslcErrorBuilder serverError(OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for an HTTP 500 Internal Server Error with the given error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • unauthorized

      public static OslcErrors.OslcErrorBuilder unauthorized(OslcErrors.ErrorId identifier, String message)
      Creates a new OslcErrorBuilder for an HTTP 401 Unauthorized error with the given error identifier and message.

      As the OSLC specification does not define an identifier for the Error resource, remote OSLC applications will only display the message. This method automatically prefixes the message by the given identifier, so that it can be visible there.

      Parameters:
      identifier - the unique identifier of the error, for the end user to search for corresponding documentation and to report to its support.
      message - the error message for the end-user.
      Returns:
      a new OslcErrorBuilder
    • log

      public static void log(OslcError error)
      Log the given OSLC Error resource, provided a Logger instance was associated when creating the Error with OslcResponses.of(OslcError, Logger).

      This method logs the Error entity with following log level:

      • ERROR - if HTTP status is 500 or upper.
      • WARNING - if HTTP status is below 500 and the error has an associated cause.
      • DEBUG - in any other case.

      This method is called by the framework, when serializing a JAX-RS response. Developer should call it on his own only when operating in a non-JAX-RS environment.

      Parameters:
      error - the OSLC Error resource whose description is to build.
      Since:
      4.0.0