mirror of https://github.com/apache/archiva.git
[MRM-773]
-added the constraints for getting the different versions of a specific artifact -added the whenGathered field in beginScan(..) of RepositoryContentConsumer interface and updated all implementing consumers git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@652043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
36562a6696
commit
f4fc560e71
|
@ -19,6 +19,8 @@ package org.apache.maven.archiva.cli;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
|
@ -36,7 +38,7 @@ public abstract class AbstractProgressConsumer
|
|||
{
|
||||
private int count = 0;
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
this.count = 0;
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.maven.archiva.cli;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
|
@ -94,10 +95,10 @@ public class ProjectReaderConsumer
|
|||
return includes;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
super.beginScan( repository );
|
||||
super.beginScan( repository, whenGathered );
|
||||
this.repo = repository;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class AbstractMonitoredConsumer
|
|||
implements BaseConsumer
|
||||
{
|
||||
private Set<ConsumerMonitor> monitors = new HashSet<ConsumerMonitor>();
|
||||
|
||||
|
||||
public void addConsumerMonitor( ConsumerMonitor monitor )
|
||||
{
|
||||
monitors.add( monitor );
|
||||
|
@ -104,4 +104,6 @@ public abstract class AbstractMonitoredConsumer
|
|||
{
|
||||
return FileTypes.DEFAULT_EXCLUSIONS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.maven.archiva.consumers;
|
|||
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -56,9 +57,10 @@ public interface RepositoryContentConsumer extends BaseConsumer
|
|||
* </p>
|
||||
*
|
||||
* @param repository the repository that this consumer is being used for.
|
||||
* @param whenGathered the start of the repository scan
|
||||
* @throws ConsumerException if there was a problem with using the provided repository with the consumer.
|
||||
*/
|
||||
public void beginScan( ManagedRepositoryConfiguration repository ) throws ConsumerException;
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered ) throws ConsumerException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -95,5 +97,5 @@ public interface RepositoryContentConsumer extends BaseConsumer
|
|||
* method.
|
||||
* @return whether to process the unmodified files
|
||||
*/
|
||||
boolean isProcessUnmodified();
|
||||
boolean isProcessUnmodified();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.codehaus.plexus.registry.RegistryListener;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -113,7 +114,7 @@ public class ArtifactMissingChecksumsConsumer
|
|||
return false;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repo )
|
||||
public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
this.repositoryDir = new File( repo.getLocation() );
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.codehaus.plexus.registry.RegistryListener;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -88,7 +89,7 @@ public class AutoRemoveConsumer
|
|||
return false;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
this.repositoryDir = new File( repository.getLocation() );
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -90,7 +91,7 @@ public class AutoRenameConsumer
|
|||
return false;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
this.repositoryDir = new File( repository.getLocation() );
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.maven.archiva.consumers.core;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
|
@ -123,7 +124,7 @@ public class MetadataUpdaterConsumer
|
|||
this.includes = includes;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repoConfig )
|
||||
public void beginScan( ManagedRepositoryConfiguration repoConfig, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
try
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -96,7 +97,7 @@ public class ValidateChecksumConsumer
|
|||
return false;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
this.repositoryDir = new File( repository.getLocation() );
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.codehaus.plexus.registry.Registry;
|
|||
import org.codehaus.plexus.registry.RegistryListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -133,7 +134,7 @@ public class RepositoryPurgeConsumer
|
|||
return this.includes;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
try
|
||||
|
|
|
@ -111,7 +111,7 @@ public class RepositoryPurgeConsumerTest
|
|||
repoConfiguration.setRetentionCount( TEST_RETENTION_COUNT );
|
||||
addRepoToConfiguration( "retention-count", repoConfiguration );
|
||||
|
||||
repoPurgeConsumer.beginScan( repoConfiguration );
|
||||
repoPurgeConsumer.beginScan( repoConfiguration, null );
|
||||
|
||||
String repoRoot = prepareTestRepo();
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class RepositoryPurgeConsumerTest
|
|||
repoConfiguration.setDaysOlder( TEST_DAYS_OLDER );
|
||||
addRepoToConfiguration( "days-old", repoConfiguration );
|
||||
|
||||
repoPurgeConsumer.beginScan( repoConfiguration );
|
||||
repoPurgeConsumer.beginScan( repoConfiguration, null );
|
||||
|
||||
String repoRoot = prepareTestRepo();
|
||||
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-install-plugin";
|
||||
|
@ -228,7 +228,7 @@ public class RepositoryPurgeConsumerTest
|
|||
repoConfiguration.setDeleteReleasedSnapshots( false ); // Set to NOT delete released snapshots.
|
||||
addRepoToConfiguration( "retention-count", repoConfiguration );
|
||||
|
||||
repoPurgeConsumer.beginScan( repoConfiguration );
|
||||
repoPurgeConsumer.beginScan( repoConfiguration, null );
|
||||
|
||||
String repoRoot = prepareTestRepo();
|
||||
|
||||
|
@ -271,7 +271,7 @@ public class RepositoryPurgeConsumerTest
|
|||
repoConfiguration.setDeleteReleasedSnapshots( true );
|
||||
addRepoToConfiguration( "days-old", repoConfiguration );
|
||||
|
||||
repoPurgeConsumer.beginScan( repoConfiguration );
|
||||
repoPurgeConsumer.beginScan( repoConfiguration, null );
|
||||
|
||||
String repoRoot = prepareTestRepo();
|
||||
|
||||
|
|
|
@ -110,6 +110,8 @@ public class ArtifactUpdateDatabaseConsumer
|
|||
private File repositoryDir;
|
||||
|
||||
private List<String> includes = new ArrayList<String>();
|
||||
|
||||
private Date whenGathered;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
|
@ -136,13 +138,14 @@ public class ArtifactUpdateDatabaseConsumer
|
|||
return this.includes;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repo )
|
||||
public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
try
|
||||
{
|
||||
this.repository = repositoryFactory.getManagedRepositoryContent( repo.getId() );
|
||||
this.repositoryDir = new File( repository.getRepoRoot() );
|
||||
this.whenGathered = whenGathered;
|
||||
}
|
||||
catch(RepositoryException e)
|
||||
{
|
||||
|
@ -190,6 +193,12 @@ public class ArtifactUpdateDatabaseConsumer
|
|||
artifact.getModel().setSize( artifactFile.length() );
|
||||
artifact.getModel().setOrigin( "FileSystem" );
|
||||
artifact.getModel().setWhenProcessed( null );
|
||||
|
||||
// set this to when the artifact was first discovered in the repo
|
||||
if ( artifact.getModel().getWhenGathered() == null )
|
||||
{
|
||||
artifact.getModel().setWhenGathered( whenGathered );
|
||||
}
|
||||
|
||||
dao.getArtifactDAO().saveArtifact( artifact );
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -125,7 +126,7 @@ public class DependencyTreeGeneratorConsumer
|
|||
this.generatedRepositoryLocation = generatedRepositoryLocation;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
repositoryLocation = repository.getLocation();
|
||||
|
|
|
@ -67,7 +67,7 @@ public class DependencyTreeGeneratorConsumerTest
|
|||
public void testGenerateBasicTree()
|
||||
throws IOException, ConsumerException
|
||||
{
|
||||
consumer.beginScan( repository );
|
||||
consumer.beginScan( repository, null );
|
||||
|
||||
String path = "org/apache/maven/maven-core/2.0/maven-core-2.0.pom";
|
||||
consumer.processFile( path );
|
||||
|
@ -82,7 +82,7 @@ public class DependencyTreeGeneratorConsumerTest
|
|||
public void testInvalidCoordinate()
|
||||
throws IOException, ConsumerException
|
||||
{
|
||||
consumer.beginScan( repository );
|
||||
consumer.beginScan( repository, null );
|
||||
|
||||
String path = "openejb/jaxb-xjc/2.0EA3/jaxb-xjc-2.0EA3.pom";
|
||||
try
|
||||
|
@ -108,7 +108,7 @@ public class DependencyTreeGeneratorConsumerTest
|
|||
|
||||
DefaultProfileManager m = new DefaultProfileManager( container );
|
||||
|
||||
consumer.beginScan( repository );
|
||||
consumer.beginScan( repository, null );
|
||||
|
||||
String path = "org/apache/maven/surefire/surefire-testng/2.0/surefire-testng-2.0.pom";
|
||||
consumer.processFile( path );
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.codehaus.plexus.registry.RegistryListener;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -128,7 +129,7 @@ public class IndexContentConsumer
|
|||
return this.includes;
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repo )
|
||||
public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
try
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.maven.archiva.converter.legacy;
|
|||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
|
@ -81,7 +82,7 @@ public class LegacyConverterArtifactConsumer
|
|||
includes.add( "**/*.war" );
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
this.managedRepository = new ManagedDefaultRepositoryContent();
|
||||
|
|
|
@ -401,6 +401,16 @@
|
|||
The origin of this artifact. (Filesystem, Proxy, Deploy)
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>whenGathered</name>
|
||||
<identifier>false</identifier>
|
||||
<version>1.0.0+</version>
|
||||
<type>Date</type>
|
||||
<required>false</required>
|
||||
<description>
|
||||
When this artifact was gathered or disovered from the repository.
|
||||
</description>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
|
|
|
@ -23,20 +23,13 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.archiva.rss.processor.RssFeedProcessor;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.maven.archiva.configuration.FileTypes;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.maven.archiva.repository.RepositoryException;
|
||||
import org.apache.maven.archiva.repository.RepositoryNotFoundException;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.codehaus.plexus.util.DirectoryWalker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -63,16 +56,6 @@ public class DefaultRepositoryScanner
|
|||
*/
|
||||
private RepositoryContentConsumers consumerUtil;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private RepositoryContentFactory repositoryFactory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="new-artifacts"
|
||||
*/
|
||||
private RssFeedProcessor rssFeedProcessor;
|
||||
|
||||
public RepositoryScanStatistics scan( ManagedRepositoryConfiguration repository, long changesSince )
|
||||
throws RepositoryException
|
||||
{
|
||||
|
@ -142,13 +125,6 @@ public class DefaultRepositoryScanner
|
|||
|
||||
stats.setKnownConsumers( gatherIds( knownContentConsumers ) );
|
||||
stats.setInvalidConsumers( gatherIds( invalidContentConsumers ) );
|
||||
|
||||
if ( scannerInstance.getNewFiles() != null && scannerInstance.getNewFiles().size() > 0 )
|
||||
{
|
||||
// generate RSS feeds
|
||||
List<ArchivaArtifact> newArtifacts = getNewArtifacts( scannerInstance.getNewFiles(), repository.getId() );
|
||||
rssFeedProcessor.process( newArtifacts );
|
||||
}
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
@ -161,41 +137,5 @@ public class DefaultRepositoryScanner
|
|||
ids.add( consumer.getId() );
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
private List<ArchivaArtifact> getNewArtifacts( List<File> files, String repoId )
|
||||
{
|
||||
List<ArchivaArtifact> newArtifacts = new ArrayList<ArchivaArtifact>();
|
||||
|
||||
// TODO: filter the file types of artifacts that will be included in the rss feeds
|
||||
try
|
||||
{
|
||||
ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repoId );
|
||||
for( File file : files )
|
||||
{
|
||||
try
|
||||
{
|
||||
ArtifactReference ref = repository.toArtifactReference( file.getAbsolutePath() );
|
||||
ArchivaArtifact artifact = new ArchivaArtifact( ref.getGroupId(),ref.getArtifactId(), ref.getVersion(),
|
||||
ref.getClassifier(), ref.getType() );
|
||||
artifact.getModel().setRepositoryId( repoId );
|
||||
newArtifacts.add( artifact );
|
||||
}
|
||||
catch ( LayoutException le )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( RepositoryNotFoundException re )
|
||||
{
|
||||
log.error( re.getMessage() );
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
{
|
||||
log.error( e.getMessage() );
|
||||
}
|
||||
|
||||
return newArtifacts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.maven.archiva.repository.scanner;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -262,8 +263,8 @@ public class RepositoryContentConsumers
|
|||
{
|
||||
// Run the repository consumers
|
||||
try
|
||||
{
|
||||
Closure triggerBeginScan = new TriggerBeginScanClosure( repository );
|
||||
{
|
||||
Closure triggerBeginScan = new TriggerBeginScanClosure( repository, new Date( System.currentTimeMillis() ) );
|
||||
|
||||
List<KnownRepositoryContentConsumer> selectedKnownConsumers = getSelectedKnownConsumers();
|
||||
List<InvalidRepositoryContentConsumer> selectedInvalidConsumers = getSelectedInvalidConsumers();
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.maven.archiva.repository.scanner;
|
|||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.Closure;
|
||||
|
@ -67,8 +67,6 @@ public class RepositoryScannerInstance
|
|||
private ConsumerProcessFileClosure consumerProcessFile;
|
||||
|
||||
private ConsumerWantsFilePredicate consumerWantsFile;
|
||||
|
||||
private List<File> newFiles = new ArrayList<File>();
|
||||
|
||||
public RepositoryScannerInstance( ManagedRepositoryConfiguration repository,
|
||||
List<KnownRepositoryContentConsumer> knownConsumerList,
|
||||
|
@ -84,7 +82,7 @@ public class RepositoryScannerInstance
|
|||
stats = new RepositoryScanStatistics();
|
||||
stats.setRepositoryId( repository.getId() );
|
||||
|
||||
Closure triggerBeginScan = new TriggerBeginScanClosure( repository );
|
||||
Closure triggerBeginScan = new TriggerBeginScanClosure( repository, new Date( System.currentTimeMillis() ) );
|
||||
|
||||
CollectionUtils.forAllDo( knownConsumerList, triggerBeginScan );
|
||||
CollectionUtils.forAllDo( invalidConsumerList, triggerBeginScan );
|
||||
|
@ -129,8 +127,7 @@ public class RepositoryScannerInstance
|
|||
// Timestamp finished points to the last successful scan, not this current one.
|
||||
if ( file.lastModified() >= changesSince )
|
||||
{
|
||||
stats.increaseNewFileCount();
|
||||
newFiles.add( basefile );
|
||||
stats.increaseNewFileCount();
|
||||
}
|
||||
|
||||
consumerProcessFile.setBasefile( basefile );
|
||||
|
@ -160,8 +157,4 @@ public class RepositoryScannerInstance
|
|||
log.debug( "Repository Scanner: " + message );
|
||||
}
|
||||
|
||||
public List<File> getNewFiles()
|
||||
{
|
||||
return newFiles;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.maven.archiva.repository.scanner.functors;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.collections.Closure;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
|
@ -38,21 +40,29 @@ public class TriggerBeginScanClosure
|
|||
private Logger log = LoggerFactory.getLogger( TriggerBeginScanClosure.class );
|
||||
|
||||
private ManagedRepositoryConfiguration repository;
|
||||
|
||||
private Date whenGathered;
|
||||
|
||||
public TriggerBeginScanClosure( ManagedRepositoryConfiguration repository )
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public TriggerBeginScanClosure( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
{
|
||||
this( repository );
|
||||
this.whenGathered = whenGathered;
|
||||
}
|
||||
|
||||
public void execute( Object input )
|
||||
{
|
||||
if ( input instanceof RepositoryContentConsumer )
|
||||
{
|
||||
RepositoryContentConsumer consumer = (RepositoryContentConsumer) input;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
consumer.beginScan( repository );
|
||||
consumer.beginScan( repository, whenGathered );
|
||||
}
|
||||
catch ( ConsumerException e )
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
|||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -43,7 +44,7 @@ public class InvalidScanConsumer
|
|||
|
||||
private int processCount = 0;
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
/* do nothing */
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -70,7 +71,7 @@ public class KnownScanConsumer
|
|||
return "Scan Consumer (for testing)";
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
/* do nothing */
|
||||
|
|
|
@ -209,7 +209,7 @@ public class RepositoryContentConsumersTest
|
|||
ManagedRepositoryConfiguration repo = createRepository( "id", "name", getTestFile( "target/test-repo" ) );
|
||||
File testFile = getTestFile( "target/test-repo/path/to/test-file.txt" );
|
||||
|
||||
selectedKnownConsumer.beginScan( repo );
|
||||
selectedKnownConsumer.beginScan( repo, null );
|
||||
selectedKnownConsumer.getExcludes();
|
||||
knownControl.setReturnValue( Collections.EMPTY_LIST );
|
||||
selectedKnownConsumer.getIncludes();
|
||||
|
@ -218,7 +218,7 @@ public class RepositoryContentConsumersTest
|
|||
// knownConsumer.completeScan();
|
||||
knownControl.replay();
|
||||
|
||||
selectedInvalidConsumer.beginScan( repo );
|
||||
selectedInvalidConsumer.beginScan( repo, null );
|
||||
// invalidConsumer.completeScan();
|
||||
invalidControl.replay();
|
||||
|
||||
|
@ -232,7 +232,7 @@ public class RepositoryContentConsumersTest
|
|||
|
||||
File notIncludedTestFile = getTestFile( "target/test-repo/path/to/test-file.xml" );
|
||||
|
||||
selectedKnownConsumer.beginScan( repo );
|
||||
selectedKnownConsumer.beginScan( repo, null );
|
||||
selectedKnownConsumer.getExcludes();
|
||||
knownControl.setReturnValue( Collections.EMPTY_LIST );
|
||||
selectedKnownConsumer.getIncludes();
|
||||
|
@ -240,7 +240,7 @@ public class RepositoryContentConsumersTest
|
|||
// knownConsumer.completeScan();
|
||||
knownControl.replay();
|
||||
|
||||
selectedInvalidConsumer.beginScan( repo );
|
||||
selectedInvalidConsumer.beginScan( repo, null );
|
||||
selectedInvalidConsumer.processFile( _OS( "path/to/test-file.xml" ) );
|
||||
selectedInvalidConsumer.getId();
|
||||
invalidControl.setReturnValue( "invalid" );
|
||||
|
@ -257,13 +257,13 @@ public class RepositoryContentConsumersTest
|
|||
|
||||
File excludedTestFile = getTestFile( "target/test-repo/path/to/test-file.txt" );
|
||||
|
||||
selectedKnownConsumer.beginScan( repo );
|
||||
selectedKnownConsumer.beginScan( repo, null );
|
||||
selectedKnownConsumer.getExcludes();
|
||||
knownControl.setReturnValue( Collections.singletonList( "**/test-file.txt" ) );
|
||||
// knownConsumer.completeScan();
|
||||
knownControl.replay();
|
||||
|
||||
selectedInvalidConsumer.beginScan( repo );
|
||||
selectedInvalidConsumer.beginScan( repo, null );
|
||||
selectedInvalidConsumer.processFile( _OS( "path/to/test-file.txt" ) );
|
||||
selectedInvalidConsumer.getId();
|
||||
invalidControl.setReturnValue( "invalid" );
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
|||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +45,7 @@ public class SampleKnownConsumer
|
|||
*/
|
||||
private String id = "unset-id";
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository )
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
/* nothing to do */
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package org.apache.maven.archiva.database.constraints;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.database.Constraint;
|
||||
|
||||
/**
|
||||
* ArtifactVersionsConstraint
|
||||
*
|
||||
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
|
||||
* @version
|
||||
*/
|
||||
public class ArtifactVersionsConstraint
|
||||
extends AbstractDeclarativeConstraint
|
||||
implements Constraint
|
||||
{
|
||||
private String whereClause;
|
||||
|
||||
private String sortColumn = "repositoryId";
|
||||
|
||||
public ArtifactVersionsConstraint( String repoId, String groupId, String artifactId )
|
||||
{
|
||||
whereClause = "repositoryId == repoId && groupId == groupId && artifactId == artifactId";
|
||||
declParams = new String[] { "String repoId", "String groupId", "String artifactId" };
|
||||
params = new Object[] { repoId, groupId, artifactId };
|
||||
}
|
||||
|
||||
public ArtifactVersionsConstraint( String repoId, String groupId, String artifactId, String sortColumn )
|
||||
{
|
||||
this( repoId, groupId, artifactId );
|
||||
this.sortColumn = sortColumn;
|
||||
}
|
||||
|
||||
public String getSortColumn()
|
||||
{
|
||||
return sortColumn;
|
||||
}
|
||||
|
||||
public String getWhereCondition()
|
||||
{
|
||||
return whereClause;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,6 +33,8 @@ public class ArtifactsByRepositoryConstraint
|
|||
{
|
||||
private String whereClause;
|
||||
|
||||
private String sortColumn = "groupId";
|
||||
|
||||
public ArtifactsByRepositoryConstraint( String repoId )
|
||||
{
|
||||
whereClause = "repositoryId == repoId";
|
||||
|
@ -40,9 +42,15 @@ public class ArtifactsByRepositoryConstraint
|
|||
params = new Object[] { repoId };
|
||||
}
|
||||
|
||||
public ArtifactsByRepositoryConstraint( String repoId, String sortColumn )
|
||||
{
|
||||
this( repoId );
|
||||
this.sortColumn = sortColumn;
|
||||
}
|
||||
|
||||
public String getSortColumn()
|
||||
{
|
||||
return "groupId";
|
||||
return sortColumn;
|
||||
}
|
||||
|
||||
public String getWhereCondition()
|
||||
|
|
Loading…
Reference in New Issue