Class DefaultTrashManager

java.lang.Object
com.atlassian.confluence.pages.DefaultTrashManager
All Implemented Interfaces:
TrashManagerInternal, TrashManager

public class DefaultTrashManager extends Object implements TrashManagerInternal
This class provides utility methods for operating on the Trash
  • Constructor Details

  • Method Details

    • onStart

      @PostConstruct public void onStart()
    • onShutdown

      @PreDestroy public void onShutdown()
    • emptyTrash

      public void emptyTrash(Space space)
      Description copied from interface: TrashManager
      Purge all of the trash in a given space.
      Specified by:
      emptyTrash in interface TrashManager
    • getNumberOfItemsInTrash

      public int getNumberOfItemsInTrash(Space space)
      Description copied from interface: TrashManager
      Retrieve the total number of items in the trash for a given space.
      Specified by:
      getNumberOfItemsInTrash in interface TrashManager
      Returns:
      the number of items in the trash for that space
    • purge

      public boolean purge(String spaceKey, long contentId)
      Description copied from interface: TrashManager
      Remove one item from the trash. If no content exists with the given ID, nothing will be done. If the content exists but is not in the trash, or does not belong to the correct space, an exception will be thrown
      Specified by:
      purge in interface TrashManager
      Parameters:
      spaceKey - the space to purge the trash from
      contentId - the id of the item to remove from the trash @return true if content was purged, false if no content was found with that ID
      Returns:
      true if content was purged, false if no matching content was found
    • getTrashContents

      public List<ContentEntityObject> getTrashContents(Space space, int offset, int count)
      Description copied from interface: TrashManager
      Retrieve a subset of the contents of the trash for a particular space.
      Specified by:
      getTrashContents in interface TrashManager
      offset - the offset of the first item to retrieve (0-based)
      count - the maximum number of items to retrieve
      Returns:
      the contents of the trash, up to the maximum number provided
    • getTrashContents

      public PageResponse<ContentEntityObject> getTrashContents(String spaceKey, LimitedRequest request)
      Description copied from interface: TrashManager
      Retrieve a subset of the contents of the trash for a particular space.
      Specified by:
      getTrashContents in interface TrashManager
      Parameters:
      spaceKey - the key of the space where the trash contents belong to
      request - the pagination request, with a cursor which is an identifier to skip results from a previous query when paginating and limit for the result
      Returns:
      the contents of the trash, up to the request limit
    • migrateTrashDate

      public void migrateTrashDate(Instant trashTime)
      Description copied from interface: TrashManagerInternal
      Add trash date to all existing items in the trash
      Specified by:
      migrateTrashDate in interface TrashManagerInternal
      Parameters:
      trashTime - timestamp to use as trash date
    • migrateTrashDate

      public void migrateTrashDate(String spaceKey, Instant trashTime)
      Description copied from interface: TrashManagerInternal
      Add trash date to existing items in the trash for a space
      Specified by:
      migrateTrashDate in interface TrashManagerInternal
      Parameters:
      spaceKey - key of the space to apply trash date
      trashTime - timestamp to use as trash date
    • onSpaceRemoval

      @EventListener public void onSpaceRemoval(SpaceRemoveEvent event)
    • getTrashDateMigrationTime

      public Optional<Instant> getTrashDateMigrationTime()
      Description copied from interface: TrashManager
      All items that have been added to the trash before Confluence 7.14 don't have actual trash date. For the purpose of retention rules, trash date of these items default to time when the concept of trash date is first introduced to this instance ie. the first time this instance is upgraded to Confluence 7.14 or later.
      Specified by:
      getTrashDateMigrationTime in interface TrashManager
      Returns:
      default trash date for items added to the trash before Confluence 7.14 or Optional.empty() if this instance is freshly installed with Confluence 7.14 or later.
    • findTrashDate

      public Optional<Instant> findTrashDate(ContentEntityObject ceo)
      Description copied from interface: TrashManagerInternal
      Trash date is only available since Confluence 7.14. The rules to determine effective trash date for a content entity in general is: 1. If it is not in trash, trash date will be Optional.empty() 2. If it has a contentproperty named trash-date, trash date will be trash-date 3. If it belongs to a space which has a trash-date set in bandana, trash date will be that value 4. If there is a global trash-date set in bandana, trash date will be that value 5. Otherwise, trash date will be Optional.empty()
      Specified by:
      findTrashDate in interface TrashManagerInternal
      Parameters:
      ceo - a content entity object to determine trash date
      Returns:
      when ceo was added to the trash if that data is available
    • findTrashDate

      public Optional<Instant> findTrashDate(Content content)
      Description copied from interface: TrashManagerInternal
      Trash date is only available since Confluence 7.14. The rules to determine effective trash date for a content entity in general is: 1. If it is not in trash, trash date will be Optional.empty() 2. If it has a contentproperty named trash-date, trash date will be trash-date 3. If it belongs to a space which has a trash-date set in bandana, trash date will be that value 4. If there is a global trash-date set in bandana, trash date will be that value 5. Otherwise, trash date will be Optional.empty()
      Specified by:
      findTrashDate in interface TrashManagerInternal
      Parameters:
      content - a com.atlassian.confluence.api.model.content.Content to determine trash date
      Returns:
      when content was added to the trash if that data is available
    • getTrashedEntities

      public List<SpaceContentEntityObject> getTrashedEntities(long contentIdOffset, int limit)
      Description copied from interface: TrashManagerInternal
      Fetch a batch of trashed content entities
      Specified by:
      getTrashedEntities in interface TrashManagerInternal
      Parameters:
      contentIdOffset - ids of returned entities must be greater than or equal to this value
      limit - maximum number of entities to return
    • purge

      public void purge(List<SpaceContentEntityObject> trashEntities)
      Description copied from interface: TrashManagerInternal
      Delete a list of trashed entities
      Specified by:
      purge in interface TrashManagerInternal
      Parameters:
      trashEntities - trashed entities to be deleted from trash