Class BeCPGTrashcanCleaner

java.lang.Object
org.alfresco.trashcan.TrashcanCleaner
fr.becpg.repo.admin.BeCPGTrashcanCleaner

public class BeCPGTrashcanCleaner extends org.alfresco.trashcan.TrashcanCleaner
This class is capable of cleaning the trashcan without depending on searches over the archive store. So the corresponding index core could be deactivated with no impact on its execution. It will clean() the trashcan according to defined deleteBatchCount and keepPeriod properties.

deleteBatchCount: It will set how many nodes in trashcan to delete at maximum during clean() execution. By default the value is 1000.

keepPeriod: The time period (in Duration format) for which documents in trashcan are kept. Any nodes archived less than the value specified won't be deleted during clean() execution.

Author:
Rui Fernandes, sglover
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
     
    private final int
     
    private final Duration
     
    private static final org.apache.commons.logging.Log
     
    private org.alfresco.repo.node.archive.NodeArchiveService
     
    private final org.alfresco.service.cmr.repository.NodeService
     
    private final org.alfresco.service.transaction.TransactionService
     
    private List<org.alfresco.service.cmr.repository.NodeRef>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BeCPGTrashcanCleaner(org.alfresco.service.cmr.repository.NodeService nodeService, org.alfresco.service.transaction.TransactionService transactionService, int deleteBatchCount, String keepPeriod, org.alfresco.repo.node.archive.NodeArchiveService nodeArchiveService)
    Constructor for BeCPGTrashcanCleaner.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    The method that will clean the specified archiveStoreUrl to the limits defined by the values set for deleteBatchCount and keepPeriod.
    private int
    deleteNodes(List<org.alfresco.service.cmr.repository.NodeRef> nodes)
    It deletes the List of NodeRef received as argument.
    private List<org.alfresco.service.cmr.repository.NodeRef>
    It returns the List of NodeRef of the archive store set to be deleted according to configuration for deleteBatchCount and keepPeriod.
    long
    It returns the number of nodes present on trashcan.
    private List<org.alfresco.service.cmr.repository.ChildAssociationRef>
    It will return the first deleteBatchCount ChildAssociationRefs of type ContentModel.ASSOC_CHILDREN from the archive store set.
    private boolean
    olderThanDaysToKeep(org.alfresco.service.cmr.repository.NodeRef node)
    It checks if the archived node has been archived since longer than keepPeriod.

    Methods inherited from class java.lang.Object

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

    • logger

      private static final org.apache.commons.logging.Log logger
    • nodeService

      private final org.alfresco.service.cmr.repository.NodeService nodeService
    • transactionService

      private final org.alfresco.service.transaction.TransactionService transactionService
    • archiveStoreUrl

      private final String archiveStoreUrl
      See Also:
    • deleteBatchCount

      private final int deleteBatchCount
    • keepPeriod

      private final Duration keepPeriod
    • trashcanNodes

      private List<org.alfresco.service.cmr.repository.NodeRef> trashcanNodes
    • nodeArchiveService

      private org.alfresco.repo.node.archive.NodeArchiveService nodeArchiveService
  • Constructor Details

    • BeCPGTrashcanCleaner

      public BeCPGTrashcanCleaner(org.alfresco.service.cmr.repository.NodeService nodeService, org.alfresco.service.transaction.TransactionService transactionService, int deleteBatchCount, String keepPeriod, org.alfresco.repo.node.archive.NodeArchiveService nodeArchiveService)

      Constructor for BeCPGTrashcanCleaner.

      Parameters:
      nodeService - a NodeService object
      transactionService - a TransactionService object
      deleteBatchCount - a int
      keepPeriod - a String object
      nodeArchiveService - a NodeArchiveService object
  • Method Details

    • deleteNodes

      private int deleteNodes(List<org.alfresco.service.cmr.repository.NodeRef> nodes)
      It deletes the List of NodeRef received as argument.
      Parameters:
      nodes - return The number of deleted nodes
    • getBatchToDelete

      private List<org.alfresco.service.cmr.repository.NodeRef> getBatchToDelete()
      It returns the List of NodeRef of the archive store set to be deleted according to configuration for deleteBatchCount and keepPeriod.
      Returns:
    • getTrashcanChildAssocs

      private List<org.alfresco.service.cmr.repository.ChildAssociationRef> getTrashcanChildAssocs()
      It will return the first deleteBatchCount ChildAssociationRefs of type ContentModel.ASSOC_CHILDREN from the archive store set.
      Returns:
    • olderThanDaysToKeep

      private boolean olderThanDaysToKeep(org.alfresco.service.cmr.repository.NodeRef node)
      It checks if the archived node has been archived since longer than keepPeriod. If keepPeriod is 0 or negative it will return always true.
      Parameters:
      node -
      Returns:
    • getNumberOfNodesInTrashcan

      public long getNumberOfNodesInTrashcan()
      It returns the number of nodes present on trashcan.
      Overrides:
      getNumberOfNodesInTrashcan in class org.alfresco.trashcan.TrashcanCleaner
      Returns:
      a long
    • clean

      public void clean()
      The method that will clean the specified archiveStoreUrl to the limits defined by the values set for deleteBatchCount and keepPeriod.
      Overrides:
      clean in class org.alfresco.trashcan.TrashcanCleaner