Skip to content

Align remaining controllers to domain responses #5

@WilliamAGH

Description

@WilliamAGH

Objective

Replace remaining Map/ad-hoc response shapes in web controllers with domain response records, keeping domain framework-free and contracts explicit.

Inventory (current Map/ad-hoc usage)

  • BaseController: handleServiceException/handleValidationException/createSuccessResponse use Map
  • ExceptionResponseBuilder: buildErrorResponse/buildSuccessResponse return Map
  • IngestionController: /api/ingest and /api/ingest/local return Map
  • CustomErrorController: handleApiError returns Map

Tasks

  • Create domain package for ingestion responses (e.g., domain/ingestion)
    • Add IngestionRunOutcome (fields: status, message)
    • Add IngestionLocalOutcome (fields: status, processed, dir)
    • Add IngestionErrorResponse (fields: status, message, details nullable)
    • Add sealed interfaces IngestionResponse and IngestionLocalResponse with permitted types
    • Javadoc all public records per JD1–JD8
  • Create domain error response(s) for API errors (e.g., domain/errors)
    • Add ApiErrorResponse (fields: status, message, details nullable)
    • Add sealed interface ApiResponse if reused beyond CustomErrorController/BaseController
    • Ensure no Spring/HTTP imports in domain
  • Refactor ExceptionResponseBuilder to return domain responses
    • Replace Map returns with domain response records
    • Remove HashMap/Map usage
  • Refactor BaseController to use domain responses
    • Update method signatures to ResponseEntity of domain response interface
  • Refactor IngestionController to return domain responses
    • /api/ingest -> IngestionRunOutcome on success
    • /api/ingest/local -> IngestionLocalOutcome on success
    • Validation + IO/runtime errors -> IngestionErrorResponse
    • Update method Javadocs to remove Map references
  • Refactor CustomErrorController API path to return domain error response
    • Replace handleApiError Map response with ApiErrorResponse
  • Update any tests asserting old Map shapes
    • WebMvc/MockMvc tests (if present) should assert new JSON fields
  • Verify policy compliance
    • No Map<String,Object> in controllers for these paths
    • Domain types free of framework imports
    • No generic identifiers (ND rules)

Validation

  • Run ./gradlew test
  • If failures, update tests or domain contracts accordingly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions