Class ResourceRegistryExceptionMapper

java.lang.Object
org.gcube.informationsystem.resourceregistry.rest.providers.ResourceRegistryExceptionMapper
All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException>

@Provider public class ResourceRegistryExceptionMapper extends Object implements jakarta.ws.rs.ext.ExceptionMapper<org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException>
Global JAX-RS ExceptionMapper that maps every ResourceRegistryException thrown by the service into an HTTP error Response.

The mapped status code is derived from the exception's concrete subtype (e.g. NotFoundException → 404, AlreadyPresentException/ ContextLifecycleException/SchemaViolationException → 409, AvailableInAnotherContextException/ContextVisibilityException → 403), defaulting to 400 Bad Request for any other subtype and 500 Internal Server Error for a bare ResourceRegistryException. The body is built by ErrorResponseBody; the stack trace is always logged server-side.

Author:
Luca Frosini (ISTI - CNR)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.ws.rs.core.Response
    toResponse(org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException exception)
    Maps the given exception to an HTTP error Response: selects the status code from the exception's concrete subtype (see the class Javadoc), always logs the stack trace, and sets the error body through ErrorResponseBody.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResourceRegistryExceptionMapper

      public ResourceRegistryExceptionMapper()
  • Method Details

    • toResponse

      public jakarta.ws.rs.core.Response toResponse(org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException exception)
      Maps the given exception to an HTTP error Response: selects the status code from the exception's concrete subtype (see the class Javadoc), always logs the stack trace, and sets the error body through ErrorResponseBody.
      Specified by:
      toResponse in interface jakarta.ws.rs.ext.ExceptionMapper<org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException>
      Parameters:
      exception - the exception to map
      Returns:
      the mapped HTTP error response