Class EagerContentStoreCleaner
- java.lang.Object
-
- org.alfresco.repo.transaction.TransactionListenerAdapter
-
- org.alfresco.repo.content.cleanup.EagerContentStoreCleaner
-
- All Implemented Interfaces:
TransactionListener,org.alfresco.util.transaction.TransactionListener
public class EagerContentStoreCleaner extends TransactionListenerAdapter
This component is responsible cleaning up orphaned content. Clean-up happens at two levels. Eager cleanup: (since 3.2) Ifeager cleanupis activated, then this component listens to all content property change events and recorded for post-transaction processing. All orphaned content is deleted from the registered store(s). Note that anylistenersare called as normal; backup or scrubbing procedures should be plugged in as listeners if this is required. Lazy cleanup: This is triggered by means of aQuartz job. This is a heavy-weight process that effectively compares the database metadata with the content URLs controlled by the various stores. Once again, the listeners are called appropriately. How backup policies are affected: When restoring the system from a backup, the type of restore required is dictated by the cleanup policy being enforced. If eager cleanup is active, the system must
(a) have a listeners configured to backup the deleted content e.g.DeletedContentBackupCleanerListener, or
(b) ensure consistent backups across the database and content stores: backup when the system is not running; use a DB-based content store. This is the recommended route when running with eager cleanup. Lazy cleanup protects the content for a given period (e.g. 7 days) giving plenty of time for a backup to be taken; this allows hot backup without needing metadata-content consistency to be enforced.- Author:
- Derek Hulley
-
-
Constructor Summary
Constructors Constructor Description EagerContentStoreCleaner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterCommit()Cleans up all newly-orphaned contentvoidafterRollback()Invoked after transaction rollback.protected booleandeleteFromStore(java.lang.String contentUrl, org.alfresco.repo.content.ContentStore store)Attempts to delete the URL from the store, catching and reporing errors.booleandeleteFromStores(java.lang.String contentUrl)Delete the content URL from all storesvoidinit()Initializes the cleaner based on theeagerCleanupflag.voidregisterNewContentUrl(java.lang.String contentUrl)Queues orphaned content for post-transaction removalbooleanregisterOrphanedContentUrl(java.lang.String contentUrl)Queues orphaned content for post-transaction removalbooleanregisterOrphanedContentUrl(java.lang.String contentUrl, boolean force)Queues orphaned content for post-transaction removalvoidsetEagerOrphanCleanup(boolean eagerOrphanCleanup)voidsetListeners(java.util.List<ContentStoreCleanerListener> listeners)voidsetStores(java.util.List<org.alfresco.repo.content.ContentStore> stores)-
Methods inherited from class org.alfresco.repo.transaction.TransactionListenerAdapter
beforeCommit, beforeCompletion, flush
-
-
-
-
Method Detail
-
setEagerOrphanCleanup
public void setEagerOrphanCleanup(boolean eagerOrphanCleanup)
- Parameters:
eagerOrphanCleanup- true to enable this component, otherwise false
-
setStores
public void setStores(java.util.List<org.alfresco.repo.content.ContentStore> stores)
- Parameters:
stores- the content stores to clean
-
setListeners
public void setListeners(java.util.List<ContentStoreCleanerListener> listeners)
- Parameters:
listeners- the listeners that can react to deletions
-
init
public void init()
Initializes the cleaner based on theeagerCleanupflag.
-
registerNewContentUrl
public void registerNewContentUrl(java.lang.String contentUrl)
Queues orphaned content for post-transaction removal
-
registerOrphanedContentUrl
public boolean registerOrphanedContentUrl(java.lang.String contentUrl)
Queues orphaned content for post-transaction removal NB: Any content registered will be deleted if the current transaction commits and if 'eager' cleanup is turned on. Note that listeners are not called for this process.- Returns:
- Returns true if the content was scheduled for post-transaction deletion. If the return value is true then the calling code must delete the row entry for the content URL provided BEFORE THE TRANSACTION COMMITS!
-
registerOrphanedContentUrl
public boolean registerOrphanedContentUrl(java.lang.String contentUrl, boolean force)Queues orphaned content for post-transaction removal NB: Any content registered will be deleted if the current transaction commits and if 'eager' cleanup is turned on OR if 'force' is true. Note that listeners are not called for this process.- Parameters:
force- true for force the post-commit URL deletion regardless of the settingsetEagerOrphanCleanup(boolean).- Returns:
- Returns true if the content was scheduled for post-transaction deletion. If the return value is true then the calling code must delete the row entry for the content URL provided BEFORE THE TRANSACTION COMMITS!
-
afterCommit
public void afterCommit()
Cleans up all newly-orphaned content- Specified by:
afterCommitin interfaceTransactionListener- Specified by:
afterCommitin interfaceorg.alfresco.util.transaction.TransactionListener- Overrides:
afterCommitin classTransactionListenerAdapter
-
afterRollback
public void afterRollback()
Description copied from class:TransactionListenerAdapterInvoked after transaction rollback.Any exceptions generated here will only be logged and will have no effect on the state of the transaction.
Although all transaction resources are still available, this method should be used only for cleaning up resources after a rollback has occured.
- Specified by:
afterRollbackin interfaceTransactionListener- Specified by:
afterRollbackin interfaceorg.alfresco.util.transaction.TransactionListener- Overrides:
afterRollbackin classTransactionListenerAdapter
-
deleteFromStores
public boolean deleteFromStores(java.lang.String contentUrl)
Delete the content URL from all stores Note that listeners are called for this process.- Parameters:
contentUrl- the URL to delete- Returns:
- Returns true if all deletes were successful
-
deleteFromStore
protected boolean deleteFromStore(java.lang.String contentUrl, org.alfresco.repo.content.ContentStore store)Attempts to delete the URL from the store, catching and reporing errors.
-
-