Class ArchiveController

java.lang.Object
ai.chatur.cortex.spring.archive.ArchiveController

@Controller public class ArchiveController extends Object
Web UI for exporting the approved assertions and importing a Turtle document back in.

Import is not a restore. It goes through ingest like any other incoming assertions — linted, SHACL-validated, reduced to what is novel, and staged on a branch — so an upload can no longer replace the graph, and lands on /branches for a human to approve rather than silently taking effect.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ArchiveController(ai.chatur.cortex.CortexArchive archive, ai.chatur.cortex.CortexIngestor ingestor)
    Creates the controller.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<String>
    Downloads the approved assertions as a dated Turtle file.
    org.springframework.web.servlet.view.RedirectView
    importAssertions(org.springframework.web.multipart.MultipartFile file, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    Stages an uploaded Turtle document on a branch for review.

    Methods inherited from class java.lang.Object

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

    • ArchiveController

      public ArchiveController(ai.chatur.cortex.CortexArchive archive, ai.chatur.cortex.CortexIngestor ingestor)
      Creates the controller.
      Parameters:
      archive - the archive role used to export the approved assertions
      ingestor - the ingestor role an uploaded document is staged through
  • Method Details

    • exportAssertions

      @GetMapping("/export") public org.springframework.http.ResponseEntity<String> exportAssertions()
      Downloads the approved assertions as a dated Turtle file.
      Returns:
      200 OK with the assertions as the response body, Content-Type: text/turtle, and a Content-Disposition attachment header naming the file cortex-assertions-<today>.ttl
    • importAssertions

      @PostMapping("/import") public org.springframework.web.servlet.view.RedirectView importAssertions(@RequestParam("file") org.springframework.web.multipart.MultipartFile file, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) throws IOException
      Stages an uploaded Turtle document on a branch for review.

      The extension check is not about trusting the upload — ingest parses it and rejects anything that is not Turtle regardless. It exists so the one predictable wrong upload gets a comprehensible answer: Cortex 0.1.0 exported .trig whole-dataset backups, and a raw parser error is not a useful way to learn those are no longer accepted.

      Parameters:
      file - the uploaded assertions, in Turtle syntax
      redirectAttributes - receives importNotice on success or importError on failure, rendered by the branches view
      Returns:
      a redirect to /branches
      Throws:
      IOException - if the uploaded file cannot be read