]> source.dussan.org Git - archiva.git/commitdiff
[MRM-883]
authorMaria Odea B. Ching <oching@apache.org>
Fri, 25 Jul 2008 10:47:53 +0000 (10:47 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Fri, 25 Jul 2008 10:47:53 +0000 (10:47 +0000)
-do not generate feed if there are no information available
-return 204 if no information/update available

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@679754 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java
archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java

index 2bff45def7cf6e19a3739bd27bea6312376b08b5..4b05a36fc78801a36256990e7ada25e7fe5853a8 100644 (file)
@@ -50,14 +50,16 @@ public class RssFeedGenerator
 
     public static String DEFAULT_LANGUAGE = "en-us";
 
-    //private String DEFAULT_LINK = "http://localhost:8080/archiva/rss/";
-
     public SyndFeed generateFeed( String title, String description, List<RssFeedEntry> dataEntries )
     {
+        if( dataEntries.size() ==  0 )
+        {
+            log.debug( "No updates found, feed not generated." );
+            return null;
+        }
+        
         SyndFeed feed = new SyndFeedImpl();
-
-        feed.setTitle( title );
-        //feed.setLink( DEFAULT_LINK + queryString );
+        feed.setTitle( title );        
         feed.setDescription( description );
         feed.setLanguage( DEFAULT_LANGUAGE );
         feed.setPublishedDate( dataEntries.get( dataEntries.size() - 1 ).getPublishedDate() );
index 0c8287be0dc40d0c5c6aa45cb73c0ac7a80c0ab4..356177ef81b35a222641dca25a67eb4695b25256 100644 (file)
@@ -81,6 +81,16 @@ public class RssFeedGeneratorTest
         assertEquals( "Item 2", syndEntries.get( 1 ).getTitle() );
         assertEquals( "Item 3", syndEntries.get( 2 ).getTitle() );
     }
+    
+    public void testNoDataEntries()
+        throws Exception
+    {
+        List<RssFeedEntry> entries = new ArrayList<RssFeedEntry>();
+        SyndFeed feed =
+            generator.generateFeed( "Test Feed", "The test feed from Archiva.", entries );
+
+        assertNull( feed );
+    }
 
     /*
      * this test might need to be removed since
index 267c8137e74c7a00fead1c21f58bc0a719954798..caedf31bff8d779a00e642e5703f879c7ac2f582 100644 (file)
@@ -149,9 +149,15 @@ public class RssFeedServlet
                 return;
             }
 
-            feed = processor.process( map );
+            feed = processor.process( map );            
+            if( feed == null )
+            {
+                res.sendError( HttpServletResponse.SC_NO_CONTENT, "No information available." );
+                return;
+            }
+            
             res.setContentType( MIME_TYPE );
-
+            
             if ( repoId != null )
             {
                 feed.setLink( req.getRequestURL() + "?repoId=" + repoId );