Coverage Report - org.apache.archiva.rss.processor.AbstractArtifactsRssFeedProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractArtifactsRssFeedProcessor
0%
0/30
0%
0/10
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.ArrayList;
 23  
 import java.util.Date;
 24  
 import java.util.List;
 25  
 import java.util.Map;
 26  
 
 27  
 import org.apache.archiva.rss.RssFeedEntry;
 28  
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
 29  
 import org.apache.maven.archiva.model.ArchivaArtifact;
 30  
 
 31  
 import com.sun.syndication.feed.synd.SyndFeed;
 32  
 
 33  
 /**
 34  
  * @version
 35  
  */
 36  0
 public abstract class AbstractArtifactsRssFeedProcessor
 37  
     implements RssFeedProcessor
 38  
 {
 39  
     public abstract SyndFeed process( Map<String, String> reqParams ) throws ArchivaDatabaseException;
 40  
 
 41  
     protected List<RssFeedEntry> processData( List<ArchivaArtifact> artifacts, boolean isRepoLevel )
 42  
     {
 43  0
         long tmp = 0;
 44  0
         RssFeedEntry entry = null;
 45  0
         List<RssFeedEntry> entries = new ArrayList<RssFeedEntry>();
 46  0
         String description = "";
 47  0
         int idx = 0;
 48  0
         for ( ArchivaArtifact artifact : artifacts )
 49  
         {
 50  0
             long whenGathered = artifact.getModel().getWhenGathered().getTime();
 51  
             
 52  0
             if ( tmp != whenGathered )
 53  
             {
 54  0
                 if ( entry != null )
 55  
                 {                    
 56  0
                     entry.setDescription( description );
 57  0
                     entries.add( entry );
 58  0
                     entry = null;
 59  
                 }
 60  
                 
 61  0
                 if ( !isRepoLevel )
 62  
                 {
 63  0
                     entry =
 64  
                         new RssFeedEntry( getTitle() + "\'" + artifact.getGroupId() + ":" + artifact.getArtifactId() +
 65  
                             "\'" + " as of " + new Date( whenGathered ) );
 66  0
                     entry.setPublishedDate( artifact.getModel().getWhenGathered() );
 67  0
                     description = getDescription() + "\'" + artifact.getGroupId() + ":" + artifact.getArtifactId() +
 68  
                         "\'" + ": \n" + artifact.toString() + " | ";
 69  
                 }
 70  
                 else
 71  
                 {
 72  0
                     String repoId = artifact.getModel().getRepositoryId();
 73  0
                     entry = new RssFeedEntry( getTitle() + "\'" + repoId + "\'" + " as of " + new Date( whenGathered ) );
 74  0
                     entry.setPublishedDate( artifact.getModel().getWhenGathered() );
 75  0
                     description = getDescription() + "\'" + repoId + "\'" + ": \n" + artifact.toString() + " | ";
 76  0
                 }
 77  
             }
 78  
             else
 79  
             {
 80  0
                 description = description + artifact.toString() + " | ";
 81  
             }
 82  
 
 83  0
             if ( idx == ( artifacts.size() - 1 ) )
 84  
             {                
 85  0
                 entry.setDescription( description );
 86  0
                 entries.add( entry );
 87  
             }
 88  
 
 89  0
             tmp = whenGathered;
 90  0
             idx++;
 91  0
         }
 92  
 
 93  0
         return entries;
 94  
     }
 95  
 
 96  
     protected abstract String getTitle();
 97  
 
 98  
     protected abstract String getDescription();
 99  
 
 100  
 }