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() );
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
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 );