summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2008-05-15 06:20:45 +0000
committerMaria Odea B. Ching <oching@apache.org>2008-05-15 06:20:45 +0000
commit65a63b95ec7fd72a29e42cecb0e198ac7ecb289d (patch)
tree2f6fbcc9ce522550a6a48027f7ba445c1a78a7ea
parentc86825783d2466503147be6ee59273a28c435ffa (diff)
downloadarchiva-65a63b95ec7fd72a29e42cecb0e198ac7ecb289d.tar.gz
archiva-65a63b95ec7fd72a29e42cecb0e198ac7ecb289d.zip
[MRM-773]
-fix the publish date of the rss entries -remove if condition in RepositoryContentConsumers.getStartDate() git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@656516 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java15
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersStub.java19
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java18
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.xml5
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedEntry.java14
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java4
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/AbstractArtifactsRssFeedProcessor.java9
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java7
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java9
10 files changed, 86 insertions, 16 deletions
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 045ed6a8b..bafc9ab66 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
@@ -309,18 +309,21 @@ public class RepositoryContentConsumers
{
this.selectedInvalidConsumers = selectedInvalidConsumers;
}
-
+
public void setStartTime( Date startTime )
{
this.startTime = startTime;
}
public Date getStartTime()
- {
- if( startTime == null )
- {
- startTime = new Date( System.currentTimeMillis() );
- }
+ {
+ startTime = new Date( System.currentTimeMillis() );
+
return startTime;
}
+
+ public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ {
+ this.archivaConfiguration = archivaConfiguration;
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersStub.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersStub.java
new file mode 100644
index 000000000..6cd952e74
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersStub.java
@@ -0,0 +1,19 @@
+package org.apache.maven.archiva.repository.scanner;
+
+import java.util.Date;
+
+public class RepositoryContentConsumersStub
+ extends RepositoryContentConsumers
+{
+ private Date startTimeForTest;
+
+ public void setStartTime( Date startTimeForTest )
+ {
+ this.startTimeForTest = startTimeForTest;
+ }
+
+ public Date getStartTime()
+ {
+ return startTimeForTest;
+ }
+}
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 06fd18abb..cf7d7726f 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
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.repository.scanner;
*/
import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
@@ -45,10 +46,21 @@ public class RepositoryContentConsumersTest
private RepositoryContentConsumers lookupRepositoryConsumers()
throws Exception
{
+ RepositoryContentConsumers consumerUtilStub = (RepositoryContentConsumers) lookup( RepositoryContentConsumers.class
+ .getName(), "test" );
+ ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.ROLE );
RepositoryContentConsumers consumerUtil = (RepositoryContentConsumers) lookup( RepositoryContentConsumers.class
- .getName() );
- assertNotNull( "RepositoryContentConsumers should not be null.", consumerUtil );
- return consumerUtil;
+ .getName() );
+
+ consumerUtilStub.setAvailableKnownConsumers( consumerUtil.getAvailableKnownConsumers() );
+ consumerUtilStub.setAvailableInvalidConsumers( consumerUtil.getAvailableInvalidConsumers() );
+ consumerUtilStub.setSelectedInvalidConsumers( consumerUtil.getSelectedInvalidConsumers() );
+ consumerUtilStub.setSelectedKnownConsumers( consumerUtil.getSelectedKnownConsumers() );
+ consumerUtilStub.setArchivaConfiguration( archivaConfiguration );
+
+ assertNotNull( "RepositoryContentConsumers should not be null.", consumerUtilStub );
+
+ return consumerUtilStub;
}
public void testGetSelectedKnownIds()
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.xml b/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.xml
index 11f6ff4af..57256f87d 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.xml
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.xml
@@ -134,6 +134,11 @@
<id>move-to-trash-then-notify</id>
</configuration>
</component>
+ <component>
+ <role>org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers</role>
+ <role-hint>test</role-hint>
+ <implementation>org.apache.maven.archiva.repository.scanner.RepositoryContentConsumersStub</implementation>
+ </component>
</components>
</component-set>
diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedEntry.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedEntry.java
index b9b455624..2090f9717 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedEntry.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedEntry.java
@@ -1,5 +1,7 @@
package org.apache.archiva.rss;
+import java.util.Date;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -45,6 +47,8 @@ public class RssFeedEntry
private String source;
+ private Date publishedDate;
+
public RssFeedEntry()
{
@@ -144,4 +148,14 @@ public class RssFeedEntry
{
this.source = source;
}
+
+ public Date getPublishedDate()
+ {
+ return publishedDate;
+ }
+
+ public void setPublishedDate( Date publishedDate )
+ {
+ this.publishedDate = publishedDate;
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java
index 8934ad6aa..1cf82879d 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java
@@ -62,7 +62,7 @@ public class RssFeedGenerator
feed.setLink( DEFAULT_LINK + queryString );
feed.setDescription( description );
feed.setLanguage( DEFAULT_LANGUAGE );
- feed.setPublishedDate( Calendar.getInstance().getTime() );
+ feed.setPublishedDate( dataEntries.get( dataEntries.size() - 1 ).getPublishedDate() );
feed.setFeedType( DEFAULT_FEEDTYPE );
feed.setEntries( getEntries( dataEntries ) );
@@ -82,7 +82,7 @@ public class RssFeedGenerator
{
entry = new SyndEntryImpl();
entry.setTitle( dataEntry.getTitle() );
- entry.setPublishedDate( Calendar.getInstance().getTime() );
+ entry.setPublishedDate( dataEntry.getPublishedDate() );
description = new SyndContentImpl();
description.setType( "text/plain" );
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 ecce863db..dd73456be 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
@@ -48,13 +48,14 @@ public abstract class AbstractArtifactsRssFeedProcessor
for ( ArchivaArtifact artifact : artifacts )
{
long whenGathered = artifact.getModel().getWhenGathered().getTime();
-
+
if ( tmp != whenGathered )
{
if ( entry != null )
- {
+ {
entry.setDescription( description );
entries.add( entry );
+ entry = null;
}
if ( !isRepoLevel )
@@ -62,6 +63,7 @@ public abstract class AbstractArtifactsRssFeedProcessor
entry =
new RssFeedEntry( getTitle() + "\'" + artifact.getGroupId() + ":" + artifact.getArtifactId() +
"\'" + " as of " + new Date( whenGathered ) );
+ entry.setPublishedDate( artifact.getModel().getWhenGathered() );
description = getDescription() + "\'" + artifact.getGroupId() + ":" + artifact.getArtifactId() +
"\'" + ": \n" + artifact.toString() + " | ";
}
@@ -69,6 +71,7 @@ public abstract class AbstractArtifactsRssFeedProcessor
{
String repoId = artifact.getModel().getRepositoryId();
entry = new RssFeedEntry( getTitle() + "\'" + repoId + "\'" + " as of " + new Date( whenGathered ) );
+ entry.setPublishedDate( artifact.getModel().getWhenGathered() );
description = getDescription() + "\'" + repoId + "\'" + ": \n" + artifact.toString() + " | ";
}
}
@@ -78,7 +81,7 @@ public abstract class AbstractArtifactsRssFeedProcessor
}
if ( idx == ( artifacts.size() - 1 ) )
- {
+ {
entry.setDescription( description );
entries.add( entry );
}
diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java
index e3ac7dabe..f3f1c6e6f 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java
@@ -20,6 +20,7 @@ package org.apache.archiva.rss;
*/
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
@@ -49,16 +50,21 @@ public class RssFeedGeneratorTest
{
List<RssFeedEntry> entries = new ArrayList<RssFeedEntry>();
RssFeedEntry entry = new RssFeedEntry( "Item 1" );
+
+ Date whenGathered = new Date( System.currentTimeMillis() );
entry.setDescription( "RSS 2.0 feed item 1." );
+ entry.setPublishedDate( whenGathered );
entries.add( entry );
entry = new RssFeedEntry( "Item 2" );
entry.setDescription( "RSS 2.0 feed item 2." );
+ entry.setPublishedDate( whenGathered );
entries.add( entry );
entry = new RssFeedEntry( "Item 3" );
entry.setDescription( "RSS 2.0 feed item 3." );
+ entry.setPublishedDate( whenGathered );
entries.add( entry );
SyndFeed feed =
@@ -68,6 +74,7 @@ public class RssFeedGeneratorTest
assertEquals( "http://localhost:8080/archiva/rss/generated-rss2.0-feed.xml", feed.getLink() );
assertEquals( "The test feed from Archiva.", feed.getDescription() );
assertEquals( "en-us", feed.getLanguage() );
+ assertEquals( entries.get( 2 ).getPublishedDate(), feed.getPublishedDate() );
List<SyndEntry> syndEntries = feed.getEntries();
assertEquals( 3, syndEntries.size() );
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 359c21efe..6865ac22f 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
@@ -119,9 +119,11 @@ public class NewArtifactsRssFeedProcessorTest
assertTrue( feed.getDescription().equals(
"New artifacts found in repository 'test-repo' during repository scan." ) );
assertTrue( feed.getLanguage().equals( "en-us" ) );
+ assertTrue( feed.getPublishedDate().equals( whenGathered ) );
List<SyndEntry> entries = feed.getEntries();
assertEquals( entries.size(), 1 );
assertTrue( entries.get( 0 ).getTitle().equals( "New Artifacts in Repository 'test-repo' as of " + whenGathered ) );
+ assertTrue( entries.get( 0 ).getPublishedDate().equals( whenGathered ) );
}
}
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 15f763c4d..968b183e1 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
@@ -64,7 +64,7 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
Date whenGathered = Calendar.getInstance().getTime();
whenGathered.setTime( 123456789 );
-
+
ArchivaArtifact artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-two", "1.0.1", "", "jar" );
artifact.getModel().setRepositoryId( "test-repo" );
artifact.getModel().setWhenGathered( whenGathered );
@@ -76,7 +76,7 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
artifacts.add( artifact );
Date whenGatheredNext = Calendar.getInstance().getTime();
- whenGatheredNext.setTime( 345678912 );
+ whenGatheredNext.setTime( 345678912 );
artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-two", "1.0.3-SNAPSHOT", "", "jar" );
artifact.getModel().setRepositoryId( "test-repo" );
@@ -99,14 +99,19 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
"New versions of artifact 'org.apache.archiva:artifact-two' found in repository 'test-repo' during repository scan.",
feed.getDescription() );
assertEquals( "en-us", feed.getLanguage() );
+ assertEquals( artifacts.get( 2 ).getModel().getWhenGathered(), feed.getPublishedDate() );
List<SyndEntry> entries = feed.getEntries();
assertEquals( 2, entries.size() );
+
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,
entries.get( 1 ).getTitle() );
+ assertEquals( whenGatheredNext, entries.get( 1 ).getPublishedDate() );
}
}