org.apache.archiva.consumers.core.repository
Class RepositoryPurgeConsumer

java.lang.Object
  extended by org.apache.archiva.consumers.AbstractMonitoredConsumer
      extended by org.apache.archiva.consumers.core.repository.RepositoryPurgeConsumer
All Implemented Interfaces:
Consumer, KnownRepositoryContentConsumer, RepositoryContentConsumer, org.apache.archiva.redback.components.registry.RegistryListener

@Service(value="knownRepositoryContentConsumer#repository-purge")
@Scope(value="prototype")
public class RepositoryPurgeConsumer
extends AbstractMonitoredConsumer
implements KnownRepositoryContentConsumer, org.apache.archiva.redback.components.registry.RegistryListener

Consumer for removing old snapshots in the repository based on the criteria specified by the user.


Field Summary
private  RepositoryPurge cleanUp
           
private  ArchivaConfiguration configuration
           
private  boolean deleteReleasedSnapshots
           
private  String description
          default-value="Purge repository of old snapshots"
private  FileTypes filetypes
           
private  String id
          default-value="repository-purge"
private  List<String> includes
           
private  List<RepositoryListener> listeners
           
private  ManagedRepositoryAdmin managedRepositoryAdmin
           
private  MetadataTools metadataTools
           
private  RepositoryPurge repoPurge
           
private  RepositoryContentFactory repositoryContentFactory
           
private  RepositorySession repositorySession
           
private  RepositorySessionFactory repositorySessionFactory
          FIXME: this could be multiple implementations and needs to be configured.
 
Constructor Summary
RepositoryPurgeConsumer()
           
 
Method Summary
 void afterConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry, String propertyName, Object propertyValue)
           
 void beforeConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry, String propertyName, Object propertyValue)
           
 void beginScan(ManagedRepository repository, Date whenGathered)
           Event that triggers at the beginning of a scan.
 void beginScan(ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo)
           Event that triggers at the beginning of a scan, where you can also indicate whether the consumers will be executed on an entire repository or on a specific resource.
 void completeScan()
           Event that triggers on the completion of a scan.
 void completeScan(boolean executeOnEntireRepo)
           
 RepositoryPurge getCleanUp()
           
 ArchivaConfiguration getConfiguration()
           
 String getDescription()
          The human readable description for this consumer.
 List<String> getExcludes()
          Get the list of excluded file patterns for this consumer.
 FileTypes getFiletypes()
           
 String getId()
          This is the id for the consumer.
 List<String> getIncludes()
          Get the list of included file patterns for this consumer.
 MetadataTools getMetadataTools()
           
 RepositoryPurge getRepoPurge()
           
 RepositoryContentFactory getRepositoryContentFactory()
           
 RepositorySession getRepositorySession()
           
 RepositorySessionFactory getRepositorySessionFactory()
           
 void initialize()
           
private  void initIncludes()
           
 boolean isDeleteReleasedSnapshots()
           
 boolean isPermanent()
          Flag indicating permanance of consumer.
 boolean isProcessUnmodified()
          Whether the consumer should process files that have not been modified since the time passed in to the scan method.
 void processFile(String path)
           Event indicating a file is to be processed by this consumer.
 void processFile(String path, boolean executeOnEntireRepo)
           
 void setCleanUp(RepositoryPurge cleanUp)
           
 void setConfiguration(ArchivaConfiguration configuration)
           
 void setDeleteReleasedSnapshots(boolean deleteReleasedSnapshots)
           
 void setFiletypes(FileTypes filetypes)
           
 void setMetadataTools(MetadataTools metadataTools)
           
 void setRepoPurge(RepositoryPurge repoPurge)
           
 void setRepositoryContentFactory(RepositoryContentFactory repositoryContentFactory)
           
 void setRepositorySession(RepositorySession repositorySession)
           
 void setRepositorySessionFactory(RepositorySessionFactory repositorySessionFactory)
           
 
Methods inherited from class org.apache.archiva.consumers.AbstractMonitoredConsumer
addConsumerMonitor, getDefaultArtifactExclusions, removeConsumerMonitor, triggerConsumerError, triggerConsumerInfo, triggerConsumerWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.archiva.consumers.Consumer
addConsumerMonitor, removeConsumerMonitor
 

Field Detail

id

private String id
default-value="repository-purge"


description

private String description
default-value="Purge repository of old snapshots"


configuration

@Inject
@Named(value="archivaConfiguration#default")
private ArchivaConfiguration configuration

managedRepositoryAdmin

@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin

repositoryContentFactory

@Inject
@Named(value="repositoryContentFactory#default")
private RepositoryContentFactory repositoryContentFactory

metadataTools

@Inject
private MetadataTools metadataTools

filetypes

@Inject
@Named(value="fileTypes")
private FileTypes filetypes

includes

private List<String> includes

repoPurge

private RepositoryPurge repoPurge

cleanUp

private RepositoryPurge cleanUp

deleteReleasedSnapshots

private boolean deleteReleasedSnapshots

listeners

@Inject
private List<RepositoryListener> listeners

repositorySessionFactory

@Inject
private RepositorySessionFactory repositorySessionFactory
FIXME: this could be multiple implementations and needs to be configured.


repositorySession

private RepositorySession repositorySession
Constructor Detail

RepositoryPurgeConsumer

public RepositoryPurgeConsumer()
Method Detail

getId

public String getId()
Description copied from interface: Consumer
This is the id for the consumer.

Specified by:
getId in interface Consumer
Returns:
the consumer id.

getDescription

public String getDescription()
Description copied from interface: Consumer
The human readable description for this consumer.

Specified by:
getDescription in interface Consumer
Returns:
the human readable description for this consumer.

isPermanent

public boolean isPermanent()
Description copied from interface: Consumer
Flag indicating permanance of consumer. (if it can be disabled or not)

Specified by:
isPermanent in interface Consumer
Returns:
true indicating that consumer is permanent and cannot be disabled.

getExcludes

public List<String> getExcludes()
Description copied from interface: RepositoryContentConsumer
Get the list of excluded file patterns for this consumer.

Specified by:
getExcludes in interface RepositoryContentConsumer
Returns:
the list of String patterns. (example: "**/*.pom") - (can be null for no exclusions)

getIncludes

public List<String> getIncludes()
Description copied from interface: RepositoryContentConsumer
Get the list of included file patterns for this consumer.

Specified by:
getIncludes in interface RepositoryContentConsumer
Returns:
the list of String patterns. (example: "**/*.pom")

beginScan

public void beginScan(ManagedRepository repository,
                      Date whenGathered)
               throws ConsumerException
Description copied from interface: RepositoryContentConsumer

Event that triggers at the beginning of a scan.

NOTE: This would be a good place to initialize the consumer, to lock any resources, and to generally start tracking the scan as a whole.

Specified by:
beginScan in interface RepositoryContentConsumer
Parameters:
repository - the repository that this consumer is being used for.
whenGathered - the start of the repository scan
Throws:
ConsumerException - if there was a problem with using the provided repository with the consumer.

beginScan

public void beginScan(ManagedRepository repository,
                      Date whenGathered,
                      boolean executeOnEntireRepo)
               throws ConsumerException
Description copied from interface: RepositoryContentConsumer

Event that triggers at the beginning of a scan, where you can also indicate whether the consumers will be executed on an entire repository or on a specific resource.

Specified by:
beginScan in interface RepositoryContentConsumer
Parameters:
repository - the repository that this consumer is being used for.
whenGathered - the start of the repository scan
executeOnEntireRepo - flags whether the consumer will be executed on an entire repository or just on a specific resource
Throws:
ConsumerException - if there was a problem with using the provided repository with the consumer.
See Also:
RepositoryContentConsumer.beginScan(ManagedRepository, java.util.Date)

processFile

public void processFile(String path)
                 throws ConsumerException
Description copied from interface: RepositoryContentConsumer

Event indicating a file is to be processed by this consumer.

NOTE: The consumer does not need to process the file immediately, can can opt to queue and/or track the files to be processed in batch. Just be sure to complete the processing by the RepositoryContentConsumer.completeScan() event.

Specified by:
processFile in interface RepositoryContentConsumer
Parameters:
path - the relative file path (in the repository) to process.
Throws:
ConsumerException - if there was a problem processing this file.

processFile

public void processFile(String path,
                        boolean executeOnEntireRepo)
                 throws Exception
Specified by:
processFile in interface RepositoryContentConsumer
Throws:
Exception

completeScan

public void completeScan()
Description copied from interface: RepositoryContentConsumer

Event that triggers on the completion of a scan.

NOTE: If the consumer opted to batch up processing requests in the RepositoryContentConsumer.processFile(String) event this would be the last opportunity to drain any processing queue's.

Specified by:
completeScan in interface RepositoryContentConsumer

completeScan

public void completeScan(boolean executeOnEntireRepo)
Specified by:
completeScan in interface RepositoryContentConsumer

afterConfigurationChange

public void afterConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry,
                                     String propertyName,
                                     Object propertyValue)
Specified by:
afterConfigurationChange in interface org.apache.archiva.redback.components.registry.RegistryListener

beforeConfigurationChange

public void beforeConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry,
                                      String propertyName,
                                      Object propertyValue)
Specified by:
beforeConfigurationChange in interface org.apache.archiva.redback.components.registry.RegistryListener

initIncludes

private void initIncludes()

initialize

@PostConstruct
public void initialize()

isProcessUnmodified

public boolean isProcessUnmodified()
Description copied from interface: RepositoryContentConsumer
Whether the consumer should process files that have not been modified since the time passed in to the scan method.

Specified by:
isProcessUnmodified in interface RepositoryContentConsumer
Overrides:
isProcessUnmodified in class AbstractMonitoredConsumer
Returns:
whether to process the unmodified files

getConfiguration

public ArchivaConfiguration getConfiguration()

setConfiguration

public void setConfiguration(ArchivaConfiguration configuration)

getRepositoryContentFactory

public RepositoryContentFactory getRepositoryContentFactory()

setRepositoryContentFactory

public void setRepositoryContentFactory(RepositoryContentFactory repositoryContentFactory)

getMetadataTools

public MetadataTools getMetadataTools()

setMetadataTools

public void setMetadataTools(MetadataTools metadataTools)

getFiletypes

public FileTypes getFiletypes()

setFiletypes

public void setFiletypes(FileTypes filetypes)

getRepoPurge

public RepositoryPurge getRepoPurge()

setRepoPurge

public void setRepoPurge(RepositoryPurge repoPurge)

getCleanUp

public RepositoryPurge getCleanUp()

setCleanUp

public void setCleanUp(RepositoryPurge cleanUp)

isDeleteReleasedSnapshots

public boolean isDeleteReleasedSnapshots()

setDeleteReleasedSnapshots

public void setDeleteReleasedSnapshots(boolean deleteReleasedSnapshots)

getRepositorySessionFactory

public RepositorySessionFactory getRepositorySessionFactory()

setRepositorySessionFactory

public void setRepositorySessionFactory(RepositorySessionFactory repositorySessionFactory)

getRepositorySession

public RepositorySession getRepositorySession()

setRepositorySession

public void setRepositorySession(RepositorySession repositorySession)


Copyright © 2006-2013 The Apache Software Foundation. All Rights Reserved.