1 | |
package org.apache.archiva.rss.processor; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.util.List; |
23 | |
import java.util.Map; |
24 | |
|
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; |
32 | |
|
33 | |
import com.sun.syndication.feed.synd.SyndFeed; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 0 | public class NewVersionsOfArtifactRssFeedProcessor |
44 | |
extends AbstractArtifactsRssFeedProcessor |
45 | |
{ |
46 | |
private static final String title = "New Versions of Artifact "; |
47 | |
|
48 | |
private static final String desc = "These are the new versions of artifact "; |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
private RssFeedGenerator generator; |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
private ArtifactDAO artifactDAO; |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
public SyndFeed process( Map<String, String> reqParams ) throws ArchivaDatabaseException |
64 | |
{ |
65 | 0 | String repoId = reqParams.get( RssFeedProcessor.KEY_REPO_ID ); |
66 | 0 | String groupId = reqParams.get( RssFeedProcessor.KEY_GROUP_ID ); |
67 | 0 | String artifactId = reqParams.get( RssFeedProcessor.KEY_ARTIFACT_ID ); |
68 | |
|
69 | 0 | if ( groupId != null && artifactId != null ) |
70 | |
{ |
71 | 0 | return processNewVersionsOfArtifact( repoId, groupId, artifactId ); |
72 | |
} |
73 | |
|
74 | 0 | return null; |
75 | |
} |
76 | |
|
77 | |
private SyndFeed processNewVersionsOfArtifact( String repoId, String groupId, String artifactId ) |
78 | |
throws ArchivaDatabaseException |
79 | |
{ |
80 | |
|
81 | 0 | Constraint artifactVersions = new ArtifactVersionsConstraint( repoId, groupId, artifactId, "whenGathered" ); |
82 | 0 | List<ArchivaArtifact> artifacts = artifactDAO.queryArtifacts( artifactVersions ); |
83 | |
|
84 | 0 | List<RssFeedEntry> entries = processData( artifacts, false ); |
85 | 0 | String key = groupId + ":" + artifactId; |
86 | |
|
87 | 0 | return generator.generateFeed( getTitle() + "\'" + key + "\'", "New versions of artifact " + "\'" + key + |
88 | |
"\' found in repository " + "\'" + repoId + "\'" + " during repository scan.", entries ); |
89 | |
} |
90 | |
|
91 | |
public String getTitle() |
92 | |
{ |
93 | 0 | return title; |
94 | |
} |
95 | |
|
96 | |
public String getDescription() |
97 | |
{ |
98 | 0 | return desc; |
99 | |
} |
100 | |
|
101 | |
public RssFeedGenerator getGenerator() |
102 | |
{ |
103 | 0 | return generator; |
104 | |
} |
105 | |
|
106 | |
public void setGenerator( RssFeedGenerator generator ) |
107 | |
{ |
108 | 0 | this.generator = generator; |
109 | 0 | } |
110 | |
|
111 | |
public ArtifactDAO getArtifactDAO() |
112 | |
{ |
113 | 0 | return artifactDAO; |
114 | |
} |
115 | |
|
116 | |
public void setArtifactDAO( ArtifactDAO artifactDAO ) |
117 | |
{ |
118 | 0 | this.artifactDAO = artifactDAO; |
119 | 0 | } |
120 | |
|
121 | |
} |