Class CleanupEntityBuilder

java.lang.Object
org.exoplatform.addons.documents.cleanup.rest.util.CleanupEntityBuilder

public class CleanupEntityBuilder extends Object
Domain model to REST DTO mapping. No business logic.
  • Method Details

    • build

      public static CampaignRestEntity build(CleanupCampaign campaign)
    • build

      public static CampaignItemRestEntity build(CleanupCampaignItem item, org.exoplatform.social.core.manager.IdentityManager identityManager)
      Item DTO WITHOUT its failure detail — the safe default, see build(CleanupCampaignItem, IdentityManager, boolean).
      Parameters:
      item - item to map
      identityManager - identity manager resolving the owner
      Returns:
      the item DTO, its failureDetail left null
    • build

      public static CampaignItemRestEntity build(CleanupCampaignItem item, org.exoplatform.social.core.manager.IdentityManager identityManager, boolean includeFailureDetail)
      Item DTO, its administrator-only failure DETAIL included only when asked for.

      THE FLAG IS A SECURITY BOUNDARY, not a convenience: this very DTO is served both to administrators (GET {id}/items) and to end users (GET published/my-items, @Secured("users")). The failure detail carries exception messages and stack frames that can name nodes and paths OUTSIDE the calling user's visibility — a ReferentialIntegrityException names the REFERENCING node, e.g. a shortcut living in a space the user is not a member of. So the admin endpoint passes true and the user one passes false, explicitly, and the default overload above omits it.

      failureReason stays on BOTH paths: it is now a bare, stable message code, so it leaks nothing.

      Parameters:
      item - item to map
      identityManager - identity manager resolving the owner
      includeFailureDetail - true ONLY on an administrator-restricted endpoint
      Returns:
      the item DTO
    • build

      public static PagedResult<CampaignItemRestEntity> build(org.springframework.data.domain.Page<CleanupCampaignItem> page, org.exoplatform.social.core.manager.IdentityManager identityManager)
      Page of item DTOs WITHOUT their failure detail — the safe default, see build(Page, IdentityManager, boolean).
      Parameters:
      page - page of items to map
      identityManager - identity manager resolving the owners
      Returns:
      the paged DTOs, their failureDetail left null
    • build

      public static PagedResult<CampaignItemRestEntity> build(org.springframework.data.domain.Page<CleanupCampaignItem> page, org.exoplatform.social.core.manager.IdentityManager identityManager, boolean includeFailureDetail)
      Page of item DTOs, their administrator-only failure detail included only when asked for — same security boundary as build(CleanupCampaignItem, IdentityManager, boolean), read that javadoc before touching this flag.
      Parameters:
      page - page of items to map
      identityManager - identity manager resolving the owners
      includeFailureDetail - true ONLY on an administrator-restricted endpoint
      Returns:
      the paged DTOs
    • build

      Parameters:
      progress - per-unit breakdown of a dry run
      Returns:
      its REST representation, with the in-flight units mapped along
    • build

      public static CampaignScanUnitRestEntity build(CleanupScanUnit unit)
    • build

      public static CampaignFailureGroupRestEntity build(CleanupFailureGroup failureGroup)
    • build

      public static CampaignComparisonRestEntity build(CleanupComparison comparison)
    • build

      public static KeepItemsResultRestEntity build(CleanupBulkResult result)
    • build

      public static MyItemsSummaryRestEntity build(CleanupUserSummary summary)
    • buildDefaults

      public static CampaignRestEntity buildDefaults(CleanupParams params, int maxScanThreads)
      The platform DEFAULTS as the creation form consumes them: the same field names a campaign carries, so the form fills from either shape, plus the ceiling the scan-thread input must not exceed.
      Parameters:
      params - platform default parameters
      maxScanThreads - highest reader-thread count the server accepts
      Returns:
      the defaults, as a campaign-shaped payload
    • toParamOverrides

      public static CleanupParams toParamOverrides(CampaignRestEntity entity)
      Parameters:
      entity - creation request body
      Returns:
      partial parameter overrides (null fields defaulted downstream)