1 package org.apache.archiva.rss.processor;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import java.util.List;
25 import org.apache.archiva.rss.RssFeedEntry;
26 import org.apache.archiva.rss.RssFeedGenerator;
27 import org.apache.maven.archiva.database.ArchivaDatabaseException;
28 import org.apache.maven.archiva.database.ArtifactDAO;
29 import org.apache.maven.archiva.database.Constraint;
30 import org.apache.maven.archiva.database.constraints.ArtifactVersionsConstraint;
31 import org.apache.maven.archiva.model.ArchivaArtifact;
33 import com.sun.syndication.feed.synd.SyndFeed;
36 * Retrieve and process new versions of an artifact from the database and
37 * generate a rss feed. The versions will be grouped by the date when the artifact
38 * was gathered. Each group will appear as one entry in the feed.
41 * @plexus.component role="org.apache.archiva.rss.processor.RssFeedProcessor" role-hint="new-versions"
43 public class NewVersionsOfArtifactRssFeedProcessor
44 extends AbstractArtifactsRssFeedProcessor
46 private static final String title = "New Versions of Artifact ";
48 private static final String desc = "These are the new versions of artifact ";
53 private RssFeedGenerator generator;
56 * @plexus.requirement role-hint="jdo"
58 private ArtifactDAO artifactDAO;
61 * Process all versions of the artifact which had a rss feed request.
63 public SyndFeed process( Map<String, String> reqParams ) throws ArchivaDatabaseException
65 String repoId = reqParams.get( RssFeedProcessor.KEY_REPO_ID );
66 String groupId = reqParams.get( RssFeedProcessor.KEY_GROUP_ID );
67 String artifactId = reqParams.get( RssFeedProcessor.KEY_ARTIFACT_ID );
69 if ( groupId != null && artifactId != null )
71 return processNewVersionsOfArtifact( repoId, groupId, artifactId );
77 private SyndFeed processNewVersionsOfArtifact( String repoId, String groupId, String artifactId )
78 throws ArchivaDatabaseException
81 Constraint artifactVersions = new ArtifactVersionsConstraint( repoId, groupId, artifactId, "whenGathered" );
82 List<ArchivaArtifact> artifacts = artifactDAO.queryArtifacts( artifactVersions );
84 List<RssFeedEntry> entries = processData( artifacts, false );
85 String key = groupId + ":" + artifactId;
87 return generator.generateFeed( getTitle() + "\'" + key + "\'", "New versions of artifact " + "\'" + key +
88 "\' found in repository " + "\'" + repoId + "\'" + " during repository scan.", entries );
91 public String getTitle()
96 public String getDescription()
101 public RssFeedGenerator getGenerator()
106 public void setGenerator( RssFeedGenerator generator )
108 this.generator = generator;
111 public ArtifactDAO getArtifactDAO()
116 public void setArtifactDAO( ArtifactDAO artifactDAO )
118 this.artifactDAO = artifactDAO;