Class 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 Detail

      • 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
      • buildDescription

        public static void buildDescription​(OslcError error,
                                            HttpServletRequest request)
        Requests to build the HTML description of this OSLC Error resource, based on its various attributes and the given request information. This method sets the computed description on the Error resource and logs the error information, if a Logger instance was associated with the Error in OslcResponses.of(OslcError, Logger).

        This method logs the Error entity with following log level:

        • DEBUG - if HTTP status is below 500.
        • ERROR - if HTTP status is 500 or upper.

        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.
        request - the HTTP request