summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-rss
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2010-12-29 06:14:04 +0000
committerBrett Porter <brett@apache.org>2010-12-29 06:14:04 +0000
commitf56609efad6393b10c861446ec11ddda00f9a218 (patch)
tree05aad2cd341eff4c2c1e3397e8a93570ef27bcfc /archiva-modules/archiva-web/archiva-rss
parenta44b2ac9dd664f3a93e2a7001afd507abb218110 (diff)
downloadarchiva-f56609efad6393b10c861446ec11ddda00f9a218.tar.gz
archiva-f56609efad6393b10c861446ec11ddda00f9a218.zip
[MRM-1330] refactor access around the concept of a "repository session". See Javadoc for some notes. This should be a single entry point for application users of either the metadata repository, resolution, or storage access. The session needs to be explicitly closed (and modifications saved) to facilitate some storage mechanisms.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1053542 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-rss')
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/AbstractArtifactsRssFeedProcessor.java12
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java9
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java8
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/RssFeedProcessor.java3
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java3
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java37
6 files changed, 31 insertions, 41 deletions
diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/AbstractArtifactsRssFeedProcessor.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/AbstractArtifactsRssFeedProcessor.java
index 0dca954c7..939bfd27e 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/AbstractArtifactsRssFeedProcessor.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/AbstractArtifactsRssFeedProcessor.java
@@ -19,22 +19,10 @@ package org.apache.archiva.rss.processor;
* under the License.
*/
-import org.apache.archiva.metadata.repository.MetadataRepository;
-
public abstract class AbstractArtifactsRssFeedProcessor
implements RssFeedProcessor
{
- /**
- * @plexus.requirement
- */
- protected MetadataRepository metadataRepository;
-
protected abstract String getTitle();
protected abstract String getDescription();
-
- public void setMetadataRepository( MetadataRepository metadataRepository )
- {
- this.metadataRepository = metadataRepository;
- }
}
diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
index 027ce4ee3..bac85d9c1 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
@@ -22,6 +22,7 @@ package org.apache.archiva.rss.processor;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.rss.RssFeedEntry;
import org.apache.archiva.rss.RssFeedGenerator;
@@ -64,7 +65,7 @@ public class NewArtifactsRssFeedProcessor
* Process the newly discovered artifacts in the repository. Generate feeds for new artifacts in the repository and
* new versions of artifact.
*/
- public SyndFeed process( Map<String, String> reqParams )
+ public SyndFeed process( Map<String, String> reqParams, MetadataRepository metadataRepository )
throws FeedException
{
log.debug( "Process new artifacts into rss feeds." );
@@ -72,20 +73,20 @@ public class NewArtifactsRssFeedProcessor
String repoId = reqParams.get( RssFeedProcessor.KEY_REPO_ID );
if ( repoId != null )
{
- return processNewArtifactsInRepo( repoId );
+ return processNewArtifactsInRepo( repoId, metadataRepository );
}
return null;
}
- private SyndFeed processNewArtifactsInRepo( String repoId )
+ private SyndFeed processNewArtifactsInRepo( String repoId, MetadataRepository metadataRepository )
throws FeedException
{
Calendar greaterThanThisDate = Calendar.getInstance( GMT_TIME_ZONE );
greaterThanThisDate.add( Calendar.DATE, -( getNumberOfDaysBeforeNow() ) );
greaterThanThisDate.clear( Calendar.MILLISECOND );
- List<ArtifactMetadata> artifacts = null;
+ List<ArtifactMetadata> artifacts;
try
{
artifacts = metadataRepository.getArtifactsByDateRange( repoId, greaterThanThisDate.getTime(), null );
diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java
index f90b22a2a..b731b4f43 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java
@@ -22,6 +22,7 @@ package org.apache.archiva.rss.processor;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.MetadataResolutionException;
import org.apache.archiva.rss.RssFeedEntry;
@@ -59,7 +60,7 @@ public class NewVersionsOfArtifactRssFeedProcessor
/**
* Process all versions of the artifact which had a rss feed request.
*/
- public SyndFeed process( Map<String, String> reqParams )
+ public SyndFeed process( Map<String, String> reqParams, MetadataRepository metadataRepository )
throws FeedException
{
String groupId = reqParams.get( RssFeedProcessor.KEY_GROUP_ID );
@@ -67,13 +68,14 @@ public class NewVersionsOfArtifactRssFeedProcessor
if ( groupId != null && artifactId != null )
{
- return processNewVersionsOfArtifact( groupId, artifactId );
+ return processNewVersionsOfArtifact( groupId, artifactId, metadataRepository );
}
return null;
}
- private SyndFeed processNewVersionsOfArtifact( String groupId, String artifactId )
+ private SyndFeed processNewVersionsOfArtifact( String groupId, String artifactId,
+ MetadataRepository metadataRepository )
throws FeedException
{
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/RssFeedProcessor.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/RssFeedProcessor.java
index d8d7cb878..c87689a24 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/RssFeedProcessor.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/RssFeedProcessor.java
@@ -21,6 +21,7 @@ package org.apache.archiva.rss.processor;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
+import org.apache.archiva.metadata.repository.MetadataRepository;
import java.util.Map;
@@ -35,6 +36,6 @@ public interface RssFeedProcessor
public static final String KEY_ARTIFACT_ID = "artifactId";
- SyndFeed process( Map<String, String> reqParams )
+ SyndFeed process( Map<String, String> reqParams, MetadataRepository metadataRepository )
throws FeedException;
}
diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java
index 686ea2663..f221ee5ee 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java
@@ -59,7 +59,6 @@ public class NewArtifactsRssFeedProcessorTest
newArtifactsProcessor.setGenerator( new RssFeedGenerator() );
metadataRepository = new MetadataRepositoryMock();
- newArtifactsProcessor.setMetadataRepository( metadataRepository );
}
@SuppressWarnings( "unchecked" )
@@ -83,7 +82,7 @@ public class NewArtifactsRssFeedProcessorTest
Map<String, String> reqParams = new HashMap<String, String>();
reqParams.put( RssFeedProcessor.KEY_REPO_ID, TEST_REPO );
- SyndFeed feed = newArtifactsProcessor.process( reqParams );
+ SyndFeed feed = newArtifactsProcessor.process( reqParams, metadataRepository );
// check that the date used in the call is close to the one passed (5 seconds difference at most)
Calendar cal = Calendar.getInstance( TimeZone.getTimeZone( "GMT" ) );
diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java
index 043293db6..e36312b2b 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java
@@ -60,10 +60,9 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
- newVersionsProcessor.setMetadataRepository( metadataRepository );
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public void testProcess()
throws Exception
{
@@ -80,23 +79,23 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
reqParams.put( RssFeedProcessor.KEY_GROUP_ID, GROUP_ID );
reqParams.put( RssFeedProcessor.KEY_ARTIFACT_ID, ARTIFACT_ID );
- metadataRepositoryControl.expectAndReturn( metadataRepository.getRepositories(),
- Collections.singletonList( TEST_REPO ) );
- metadataRepositoryControl.expectAndReturn(
- metadataRepository.getProjectVersions( TEST_REPO, GROUP_ID, ARTIFACT_ID ),
- Arrays.asList( "1.0.1", "1.0.2", "1.0.3-SNAPSHOT" ) );
- metadataRepositoryControl.expectAndReturn(
- metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, "1.0.1" ),
- Collections.singletonList( artifact1 ) );
- metadataRepositoryControl.expectAndReturn(
- metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, "1.0.2" ),
- Collections.singletonList( artifact2 ) );
- metadataRepositoryControl.expectAndReturn(
- metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, "1.0.3-SNAPSHOT" ),
- Collections.singletonList( artifact3 ) );
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getRepositories(), Collections.singletonList(
+ TEST_REPO ) );
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO, GROUP_ID,
+ ARTIFACT_ID ), Arrays.asList(
+ "1.0.1", "1.0.2", "1.0.3-SNAPSHOT" ) );
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID,
+ "1.0.1" ),
+ Collections.singletonList( artifact1 ) );
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID,
+ "1.0.2" ),
+ Collections.singletonList( artifact2 ) );
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID,
+ "1.0.3-SNAPSHOT" ),
+ Collections.singletonList( artifact3 ) );
metadataRepositoryControl.replay();
- SyndFeed feed = newVersionsProcessor.process( reqParams );
+ SyndFeed feed = newVersionsProcessor.process( reqParams, metadataRepository );
assertEquals( "New Versions of Artifact 'org.apache.archiva:artifact-two'", feed.getTitle() );
assertEquals( "New versions of artifact 'org.apache.archiva:artifact-two' found during repository scan.",
@@ -108,8 +107,8 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
assertEquals( 2, entries.size() );
- assertEquals( "New Versions of Artifact 'org.apache.archiva:artifact-two' as of " + whenGathered,
- entries.get( 0 ).getTitle() );
+ assertEquals( "New Versions of Artifact 'org.apache.archiva:artifact-two' as of " + whenGathered, entries.get(
+ 0 ).getTitle() );
assertEquals( whenGathered, entries.get( 0 ).getPublishedDate() );
assertEquals( "New Versions of Artifact 'org.apache.archiva:artifact-two' as of " + whenGatheredNext,