}
try
{
Map<String, String> map = new HashMap<>();
SyndFeed feed = null;
if ( isAllowed( req, repoId, groupId, artifactId ) )
{
if ( repoId != null )
{
// new artifacts in repo feed request
processor = wac.getBean( "rssFeedProcessor#new-artifacts", RssFeedProcessor.class );
map.put( RssFeedProcessor.KEY_REPO_ID, repoId );
}
else if ( ( groupId != null ) && ( artifactId != null ) )
{
// TODO: this only works for guest - we could pass in the list of repos
// new versions of artifact feed request
processor = wac.getBean( "rssFeedProcessor#new-versions", RssFeedProcessor.class );
map.put( RssFeedProcessor.KEY_GROUP_ID, groupId );
map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId );
}
}
else
{
res.sendError( HttpServletResponse.SC_UNAUTHORIZED, USER_NOT_AUTHORIZED );
return;
}
RepositorySession repositorySession = repositorySessionFactory.createSession();
try
{
feed = processor.process( map, repositorySession.getRepository() );
}
finally
{
repositorySession.close();
}
if ( feed == null )
{
res.sendError( HttpServletResponse.SC_NO_CONTENT, "No information available." );
return;
}
res.setContentType( MIME_TYPE );
if ( repoId != null )
{
feed.setLink( req.getRequestURL().toString() );
}
else if ( ( groupId != null ) && ( artifactId != null ) )
{
feed.setLink( req.getRequestURL().toString() );
}
SyndFeedOutput output = new SyndFeedOutput();
output.output( feed, res.getWriter() );
}