Class VersionMismatchExceptionMapper

java.lang.Object
uk.co.jasonmarston.kiunzi.utility.exception.mapper.VersionMismatchExceptionMapper
All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.domain.exception.VersionMismatchException>

@Provider public class VersionMismatchExceptionMapper extends Object implements jakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.domain.exception.VersionMismatchException>
Maps VersionMismatchException instances to HTTP 409 conflict responses.

This mapper is used when optimistic locking detects that the client's expected version does not match the current stored version of the aggregate.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a mapper for optimistic-locking version mismatches.
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.ws.rs.core.Response
    toResponse(uk.co.jasonmarston.kiunzi.utility.domain.exception.VersionMismatchException ex)
    Converts the supplied version-mismatch exception into an HTTP response.

    Methods inherited from class java.lang.Object

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

    • VersionMismatchExceptionMapper

      public VersionMismatchExceptionMapper()
      Creates a mapper for optimistic-locking version mismatches.
  • Method Details

    • toResponse

      public jakarta.ws.rs.core.Response toResponse(uk.co.jasonmarston.kiunzi.utility.domain.exception.VersionMismatchException ex)
      Converts the supplied version-mismatch exception into an HTTP response.
      Specified by:
      toResponse in interface jakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.domain.exception.VersionMismatchException>
      Parameters:
      ex - the optimistic-locking exception raised while processing the request
      Returns:
      an HTTP 409 response containing an ErrorResponse body