Class CleanupCampaignRest

java.lang.Object
org.exoplatform.addons.documents.cleanup.rest.CleanupCampaignRest

@RestController @RequestMapping("/cleanup/campaigns") public class CleanupCampaignRest extends Object
  • Constructor Details

    • CleanupCampaignRest

      public CleanupCampaignRest()
  • Method Details

    • getCampaigns

      @Secured("administrators") @GetMapping(produces="application/json") public List<CampaignRestEntity> getCampaigns()
    • getDefaults

      @Secured("administrators") @GetMapping(path="defaults", produces="application/json") public CampaignRestEntity getDefaults()
    • createCampaign

      @Secured("administrators") @PostMapping(consumes="application/json", produces="application/json") @ResponseStatus(ACCEPTED) public CampaignRestEntity createCampaign(@RequestBody CampaignRestEntity campaignEntity)
      ASYNCHRONOUS: the campaign row is created synchronously, its dry-run scan is handed off to a worker thread — hence the 202. The returned campaign carries no scan result yet; the scan progress and the SIMULATED completion are pushed on the /eXo/Application/CleanupCampaign CometD channel (campaign.progress / campaign.stateChanged events).
    • getCampaign

      @Secured("administrators") @GetMapping(path="{id}", produces="application/json") public CampaignRestEntity getCampaign(@PathVariable("id") long id)
    • updateCampaign

      @Secured("administrators") @PatchMapping(path="{id}", consumes="application/json", produces="application/json") public CampaignRestEntity updateCampaign(@PathVariable("id") long id, @RequestBody UpdateCampaignRestEntity updateEntity)
      PATCH on the campaign resource rather than an {id}/rename or {id}/grace sub-resource: this updates ATTRIBUTES of the campaign, it triggers no action and no lifecycle transition — unlike the publish / execute sub-resources next to it, which do. ONE endpoint for the whole editable set, each field applied only when the body carries it: a second endpoint per attribute would multiply round-trips for a form the console submits at once. Answers the updated campaign so the console re-renders its list and its header from the response instead of refetching.
    • cancelCampaign

      @Secured("administrators") @PostMapping("{id}/cancel") @ResponseStatus(NO_CONTENT) public void cancelCampaign(@PathVariable("id") long id)
    • deleteCampaign

      @Secured("administrators") @DeleteMapping("{id}") @ResponseStatus(NO_CONTENT) public void deleteCampaign(@PathVariable("id") long id)
      204 and not 202, deliberately, although the report rows are dropped asynchronously (see CleanupCampaignService#deleteCampaign): the campaign row is gone before this answers, so the resource really IS deleted and nothing about it is still pending. What continues in the background is the collection of rows no query can reach any more — the reason it is not done here being that a simulated campaign's report holds hundreds of thousands of them, and no REST call may depend on work whose duration grows with the corpus.
    • publishCampaign

      @Secured("administrators") @PostMapping(path="{id}/publish", produces="application/json") public CampaignRestEntity publishCampaign(@PathVariable("id") long id)
    • executeCampaign

      @Secured("administrators") @PostMapping(path="{id}/execute", produces="application/json") @ResponseStatus(ACCEPTED) public CampaignRestEntity executeCampaign(@PathVariable("id") long id)
      ASYNCHRONOUS: the campaign is switched to EXECUTING synchronously, the batched purge itself is handed off to a worker thread — hence the 202. The purge progress and the COMPLETED transition are pushed on the /eXo/Application/CleanupCampaign CometD channel (campaign.progress / campaign.stateChanged events).
    • retryCampaign

      @Secured("administrators") @PostMapping(path="{id}/retry", produces="application/json") @ResponseStatus(ACCEPTED) public CampaignRestEntity retryCampaign(@PathVariable("id") long id)
      A sub-resource POST, unlike the rename PATCH next to it: a retry is an ACTION with a lifecycle transition behind it (COMPLETED back to EXECUTING), not the update of an attribute.

      ASYNCHRONOUS like execute: the failed items are requeued and the campaign switched to EXECUTING synchronously, the purge itself is handed off to a worker thread — hence the 202. Progress is pushed on the /eXo/Application/CleanupCampaign CometD channel.

    • getCampaignFailures

      @Secured("administrators") @GetMapping(path="{id}/failures", produces="application/json") public List<CampaignFailureGroupRestEntity> getCampaignFailures(@PathVariable("id") long id)
      Grouped failures of a campaign, so the console can show WHY items were skipped and which of those failures a retry would re-attempt — the retryable flag is the SERVER's answer, the client never decides it.

      Answers an EMPTY list when the campaign has no failed item, and also once the retention job archived and purged its item rows: the groups are computed over those rows and are not part of the summary snapshotted at completion.

    • getCampaignScanUnits

      @Secured("administrators") @GetMapping(path="{id}/scan-units", produces="application/json") public CampaignScanUnitProgressRestEntity getCampaignScanUnits(@PathVariable("id") long id)
      Grouped failures of a campaign's dry-run SCAN, so the console can say that the report the administrator is about to publish does NOT cover the whole tree, and WHY — one entry per subtree failure reason, with how many subtrees carry it.

      Answers an EMPTY list for every campaign whose scan covered the whole tree, which is the normal case: only a scan the worker RECORDED as incomplete — subtrees that failed every walk attempt they had — has anything to report here. A subtree that failed while attempts remain is not one of them: the campaign is still DRY_RUN_RUNNING and the watchdog is re-walking it.

    • getCampaignScanFailures

      @Secured("administrators") @GetMapping(path="{id}/scan-failures", produces="application/json") public List<CampaignFailureGroupRestEntity> getCampaignScanFailures(@PathVariable("id") long id)
    • getCampaignItems

      @Secured("administrators") @GetMapping(path="{id}/items", produces="application/json") public PagedResult<CampaignItemRestEntity> getCampaignItems(@PathVariable("id") long id, @RequestParam(name="ownerIdentityId",required=false) Long ownerIdentityId, @RequestParam(name="state",required=false) String state, @RequestParam(name="action",required=false) String action, @RequestParam(name="minSize",required=false) Long minSize, @RequestParam(name="search",required=false) String search, @RequestParam(name="page",required=false,defaultValue="0") int page, @RequestParam(name="size",required=false,defaultValue="20") int size, @RequestParam(name="sort",required=false) String sort)
    • compareCampaigns

      @Secured("administrators") @GetMapping(path="{id}/compare/{otherId}", produces="application/json") public CampaignComparisonRestEntity compareCampaigns(@PathVariable("id") long id, @PathVariable("otherId") long otherId)
    • getCampaignArchive

      @Secured("administrators") @GetMapping(path="{id}/archive") public org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> getCampaignArchive(@PathVariable("id") long id)
      STREAMED: the report is written page by page to the response body, so the download starts immediately and a large campaign never materializes its CSV in memory. The availability check runs BEFORE the streaming starts, since the HTTP status is committed as soon as the first byte flows.
    • getMyItems

      @Secured("users") @GetMapping(path="published/my-items", produces="application/json") public PagedResult<CampaignItemRestEntity> getMyItems(jakarta.servlet.http.HttpServletRequest request, @RequestParam(name="search",required=false) String search, @RequestParam(name="page",required=false,defaultValue="0") int page, @RequestParam(name="size",required=false,defaultValue="20") int size, @RequestParam(name="sort",required=false) String sort)
    • getMyItemsSummary

      @Secured("users") @GetMapping(path="published/my-items/summary", produces="application/json") public MyItemsSummaryRestEntity getMyItemsSummary(jakarta.servlet.http.HttpServletRequest request)