From f4fc560e7162b814754976ba0feccc92037ee708 Mon Sep 17 00:00:00 2001
From: "Maria Odea B. Ching"
Date: Mon, 28 Apr 2008 02:17:44 +0000
Subject: [PATCH] [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
---
.../archiva/cli/AbstractProgressConsumer.java | 4 +-
.../archiva/cli/ProjectReaderConsumer.java | 5 +-
.../consumers/AbstractMonitoredConsumer.java | 4 +-
.../consumers/RepositoryContentConsumer.java | 6 +-
.../ArtifactMissingChecksumsConsumer.java | 3 +-
.../consumers/core/AutoRemoveConsumer.java | 3 +-
.../consumers/core/AutoRenameConsumer.java | 3 +-
.../core/MetadataUpdaterConsumer.java | 3 +-
.../core/ValidateChecksumConsumer.java | 3 +-
.../repository/RepositoryPurgeConsumer.java | 3 +-
.../RepositoryPurgeConsumerTest.java | 8 +--
.../ArtifactUpdateDatabaseConsumer.java | 11 +++-
.../DependencyTreeGeneratorConsumer.java | 3 +-
.../DependencyTreeGeneratorConsumerTest.java | 6 +-
.../lucene/IndexContentConsumer.java | 3 +-
.../LegacyConverterArtifactConsumer.java | 3 +-
.../src/main/mdo/archiva-base.xml | 10 +++
.../scanner/DefaultRepositoryScanner.java | 62 +------------------
.../scanner/RepositoryContentConsumers.java | 5 +-
.../scanner/RepositoryScannerInstance.java | 13 +---
.../functors/TriggerBeginScanClosure.java | 14 ++++-
.../scanner/InvalidScanConsumer.java | 3 +-
.../repository/scanner/KnownScanConsumer.java | 3 +-
.../RepositoryContentConsumersTest.java | 12 ++--
.../scanner/SampleKnownConsumer.java | 3 +-
.../ArtifactVersionsConstraint.java | 61 ++++++++++++++++++
.../ArtifactsByRepositoryConstraint.java | 10 ++-
27 files changed, 159 insertions(+), 108 deletions(-)
create mode 100644 archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraint.java
diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java
index 6e916fa19..9082418c2 100644
--- a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java
+++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java
@@ -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;
diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java
index 04f52768d..2986574c7 100644
--- a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java
+++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java
@@ -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;
}
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
index 2e626bebc..7c306e1e0 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
@@ -36,7 +36,7 @@ public abstract class AbstractMonitoredConsumer
implements BaseConsumer
{
private Set monitors = new HashSet();
-
+
public void addConsumerMonitor( ConsumerMonitor monitor )
{
monitors.add( monitor );
@@ -104,4 +104,6 @@ public abstract class AbstractMonitoredConsumer
{
return FileTypes.DEFAULT_EXCLUSIONS;
}
+
+
}
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
index b8d58dc46..9b23e1713 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
@@ -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
*
*
* @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;
/**
*
@@ -95,5 +97,5 @@ public interface RepositoryContentConsumer extends BaseConsumer
* method.
* @return whether to process the unmodified files
*/
- boolean isProcessUnmodified();
+ boolean isProcessUnmodified();
}
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
index 93f1c63be..553289929 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
@@ -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() );
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRemoveConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRemoveConsumer.java
index d8f84be2e..618b91f21 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRemoveConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRemoveConsumer.java
@@ -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() );
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRenameConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRenameConsumer.java
index 9f8709511..4c694473e 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRenameConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/AutoRenameConsumer.java
@@ -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() );
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java
index 43698fa9c..5119b3267 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java
@@ -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
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java
index cb3032847..66e0f24a6 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java
@@ -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() );
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
index 0300e022a..c29a647a8 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
@@ -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
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
index 46b290e2d..9653c2cc1 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
@@ -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();
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
index 5fd947e3f..af1dd6a3c 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
@@ -110,6 +110,8 @@ public class ArtifactUpdateDatabaseConsumer
private File repositoryDir;
private List includes = new ArrayList();
+
+ 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 );
}
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java
index 6d3bc514d..b5aa3eb9d 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java
@@ -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();
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java
index 0c28f19e7..c17d9ea2a 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/test/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumerTest.java
@@ -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 );
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java
index 95a9a561a..26d0cca6c 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java
@@ -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
diff --git a/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java b/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java
index a385c9087..f79c0cd87 100644
--- a/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java
+++ b/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java
@@ -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();
diff --git a/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml b/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
index e4286f737..9bf4c2017 100644
--- a/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
+++ b/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
@@ -401,6 +401,16 @@
The origin of this artifact. (Filesystem, Proxy, Deploy)
+
+ whenGathered
+ false
+ 1.0.0+
+ Date
+ false
+
+ When this artifact was gathered or disovered from the repository.
+
+
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java
index cdaca58e2..55ee37ca1 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java
@@ -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 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 getNewArtifacts( List files, String repoId )
- {
- List newArtifacts = new ArrayList();
-
- // 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;
- }
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java
index 396d2a9cd..549aba12a 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java
@@ -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 selectedKnownConsumers = getSelectedKnownConsumers();
List selectedInvalidConsumers = getSelectedInvalidConsumers();
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java
index d3d4b28f3..e24ed9fe5 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java
@@ -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 newFiles = new ArrayList();
public RepositoryScannerInstance( ManagedRepositoryConfiguration repository,
List 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 getNewFiles()
- {
- return newFiles;
- }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/TriggerBeginScanClosure.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/TriggerBeginScanClosure.java
index 26d15a380..cde504fde 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/TriggerBeginScanClosure.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/functors/TriggerBeginScanClosure.java
@@ -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 )
{
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java
index ce4868616..3a6e45ec0 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/InvalidScanConsumer.java
@@ -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 */
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java
index d259230ab..ba0cf6677 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/KnownScanConsumer.java
@@ -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 */
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java
index f4ad33e5b..e39878fce 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java
@@ -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" );
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java
index 150d347fa..e1f374c3a 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/SampleKnownConsumer.java
@@ -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 */
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraint.java
new file mode 100644
index 000000000..ef30d528d
--- /dev/null
+++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraint.java
@@ -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 Maria Odea Ching
+ * @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;
+ }
+
+}
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
index 97149654d..7a570a80b 100644
--- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
+++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
@@ -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()
--
2.39.5