Coverage Report - org.apache.archiva.rss.processor.NewVersionsOfArtifactRssFeedProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
NewVersionsOfArtifactRssFeedProcessor
0%
0/20
0%
0/4
0
 
 1  
 package org.apache.archiva.rss.processor;
 2  
 
 3  
 /*
 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
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 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
 19  
  * under the License.
 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  
  * 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.
 39  
  * 
 40  
  * @version
 41  
  * @plexus.component role="org.apache.archiva.rss.processor.RssFeedProcessor" role-hint="new-versions"
 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  
      * @plexus.requirement
 52  
      */
 53  
     private RssFeedGenerator generator;
 54  
 
 55  
     /**
 56  
      * @plexus.requirement role-hint="jdo"
 57  
      */
 58  
     private ArtifactDAO artifactDAO;
 59  
 
 60  
     /**
 61  
      * Process all versions of the artifact which had a rss feed request.
 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  
 }