Package com.atlassian.confluence.pages
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 Summary
Constructors Constructor Description DefaultTrashManager(ContentEntityObjectDaoInternal<ContentEntityObject> contentEntityObjectDao, ContentEntityManager contentEntityManager, CustomContentManager customContentManager, org.springframework.transaction.PlatformTransactionManager transactionManager, PageManager pageManager, com.atlassian.event.api.EventPublisher eventPublisher, AttachmentManager attachmentManager, com.atlassian.bandana.BandanaManager bandanaManager)
Deprecated.since 8.0DefaultTrashManager(ContentEntityObjectDaoInternal<ContentEntityObject> contentEntityObjectDao, ContentEntityManager contentEntityManager, CustomContentManager customContentManager, org.springframework.transaction.PlatformTransactionManager transactionManager, PageManager pageManager, com.atlassian.event.api.EventPublisher eventPublisher, AttachmentManager attachmentManager, com.atlassian.bandana.BandanaManager bandanaManager, PaginationService paginationService, ContentFactory contentFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
emptyTrash(Space space)
Purge all of the trash in a given space.Optional<Instant>
findTrashDate(Content content)
Trash date is only available since Confluence 7.14.Optional<Instant>
findTrashDate(ContentEntityObject ceo)
Trash date is only available since Confluence 7.14.int
getNumberOfItemsInTrash(Space space)
Retrieve the total number of items in the trash for a given space.List<ContentEntityObject>
getTrashContents(Space space, int offset, int count)
Retrieve a subset of the contents of the trash for a particular space.PageResponse<Content>
getTrashContents(Space space, LimitedRequest request, Expansion[] expansions)
Retrieve a subset of the contents of the trash for a particular space.Optional<Instant>
getTrashDateMigrationTime()
All items that have been added to the trash before Confluence 7.14 don't have actual trash date.List<SpaceContentEntityObject>
getTrashedEntities(long contentIdOffset, int limit)
Fetch a batch of trashed content entitiesvoid
migrateTrashDate(String spaceKey, Instant trashTime)
Add trash date to existing items in the trash for a spacevoid
migrateTrashDate(Instant trashTime)
Add trash date to all existing items in the trashvoid
onShutdown()
void
onSpaceRemoval(SpaceRemoveEvent event)
void
onStart()
boolean
purge(String spaceKey, long contentId)
Remove one item from the trash.void
purge(List<SpaceContentEntityObject> trashEntities)
Delete a list of trashed entities
-
-
-
Constructor Detail
-
DefaultTrashManager
@Deprecated public DefaultTrashManager(ContentEntityObjectDaoInternal<ContentEntityObject> contentEntityObjectDao, ContentEntityManager contentEntityManager, CustomContentManager customContentManager, org.springframework.transaction.PlatformTransactionManager transactionManager, PageManager pageManager, com.atlassian.event.api.EventPublisher eventPublisher, AttachmentManager attachmentManager, com.atlassian.bandana.BandanaManager bandanaManager)
Deprecated.since 8.0
-
DefaultTrashManager
public DefaultTrashManager(ContentEntityObjectDaoInternal<ContentEntityObject> contentEntityObjectDao, ContentEntityManager contentEntityManager, CustomContentManager customContentManager, org.springframework.transaction.PlatformTransactionManager transactionManager, PageManager pageManager, com.atlassian.event.api.EventPublisher eventPublisher, AttachmentManager attachmentManager, com.atlassian.bandana.BandanaManager bandanaManager, PaginationService paginationService, ContentFactory contentFactory)
-
-
Method Detail
-
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 interfaceTrashManager
-
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 interfaceTrashManager
- 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 interfaceTrashManager
- Parameters:
spaceKey
- the space to purge the trash fromcontentId
- 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 interfaceTrashManager
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<Content> getTrashContents(Space space, LimitedRequest request, Expansion[] expansions) throws ServiceException
Description copied from interface:TrashManager
Retrieve a subset of the contents of the trash for a particular space.- Specified by:
getTrashContents
in interfaceTrashManager
request
- the pagination request, with a cursor which is an identifier to skip results from a previous query when paginating and limit for the resultexpansions
- the optional properties to expand on the result- Returns:
- the contents of the trash, up to the request limit
- Throws:
ServiceException
-
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 interfaceTrashManagerInternal
- 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 interfaceTrashManagerInternal
- Parameters:
spaceKey
- key of the space to apply trash datetrashTime
- 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 interfaceTrashManager
- 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 beOptional.empty()
2. If it has a contentproperty namedtrash-date
, trash date will betrash-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 beOptional.empty()
- Specified by:
findTrashDate
in interfaceTrashManagerInternal
- 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 beOptional.empty()
2. If it has a contentproperty namedtrash-date
, trash date will betrash-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 beOptional.empty()
- Specified by:
findTrashDate
in interfaceTrashManagerInternal
- 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 interfaceTrashManagerInternal
- Parameters:
contentIdOffset
- ids of returned entities must be greater than or equal to this valuelimit
- 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 interfaceTrashManagerInternal
- Parameters:
trashEntities
- trashed entities to be deleted from trash
-
-