Coverage Report - net.sf.statcvs.output.ChoraIntegration
 
Classes in this File Line Coverage Branch Coverage Complexity
ChoraIntegration
82%
18/22
83%
5/6
1.5
 
 1  
 /*
 2  
         StatCvs - CVS statistics generation 
 3  
         Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
 4  
         http://statcvs.sf.net/
 5  
     
 6  
         This library is free software; you can redistribute it and/or
 7  
         modify it under the terms of the GNU Lesser General Public
 8  
         License as published by the Free Software Foundation; either
 9  
         version 2.1 of the License, or (at your option) any later version.
 10  
 
 11  
         This library is distributed in the hope that it will be useful,
 12  
         but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  
         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  
         Lesser General Public License for more details.
 15  
 
 16  
         You should have received a copy of the GNU Lesser General Public
 17  
         License along with this library; if not, write to the Free Software
 18  
         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19  
     
 20  
         $RCSfile: ChoraIntegration.java,v $
 21  
         $Date: 2008/04/02 11:22:15 $ 
 22  
 */
 23  
 package net.sf.statcvs.output;
 24  
 
 25  
 import java.util.HashSet;
 26  
 import java.util.Set;
 27  
 
 28  
 import net.sf.statcvs.model.Directory;
 29  
 import net.sf.statcvs.model.Revision;
 30  
 import net.sf.statcvs.model.VersionedFile;
 31  
 
 32  
 /**
 33  
  * Integration of the <a href="http://www.horde.org/chora/">Chora CVS Viewer</a>
 34  
  *
 35  
  * @author Richard Cyganiak
 36  
  * @version $Id: ChoraIntegration.java,v 1.12 2008/04/02 11:22:15 benoitx Exp $
 37  
  */
 38  
 public class ChoraIntegration implements WebRepositoryIntegration {
 39  
     private String baseURL;
 40  184
     private Set atticFileNames = new HashSet();
 41  
 
 42  
     /**
 43  
      * @param baseURL base URL of the Chora installation 
 44  
      */
 45  184
     public ChoraIntegration(final String baseURL) {
 46  184
         if (baseURL.endsWith("/")) {
 47  176
             this.baseURL = baseURL.substring(0, baseURL.length() - 1);
 48  
         } else {
 49  8
             this.baseURL = baseURL;
 50  
         }
 51  184
     }
 52  
 
 53  
     /**
 54  
      * @see net.sf.statcvs.output.WebRepositoryIntegration#getName
 55  
      */
 56  
     public String getName() {
 57  8
         return "Chora";
 58  
     }
 59  
 
 60  
     /**
 61  
      * @see net.sf.statcvs.output.WebRepositoryIntegration#getDirectoryUrl
 62  
      */
 63  
     public String getDirectoryUrl(final Directory directory) {
 64  0
         return baseURL + "/" + directory.getPath();
 65  
     }
 66  
 
 67  
     /**
 68  
      * @see net.sf.statcvs.output.WebRepositoryIntegration#getFileHistoryUrl
 69  
      */
 70  
     public String getFileHistoryUrl(final VersionedFile file) {
 71  48
         if (isInAttic(file)) {
 72  16
             final String path = file.getDirectory().getPath();
 73  16
             final String filename = file.getFilename();
 74  16
             return baseURL + "/" + path + "Attic/" + filename;
 75  
         }
 76  32
         return this.baseURL + "/" + file.getFilenameWithPath();
 77  
     }
 78  
 
 79  
     /**
 80  
      * @see net.sf.statcvs.output.WebRepositoryIntegration#getFileViewUrl(VersionedFile)
 81  
      */
 82  
     public String getFileViewUrl(final VersionedFile file) {
 83  16
         return getFileHistoryUrl(file) + "?r=HEAD";
 84  
     }
 85  
 
 86  
     /**
 87  
      * @see net.sf.statcvs.output.WebRepositoryIntegration#getFileViewUrl(VersionedFile)
 88  
      */
 89  
     public String getFileViewUrl(final Revision revision) {
 90  0
         return getFileHistoryUrl(revision.getFile()) + "?r=" + revision.getRevisionNumber();
 91  
     }
 92  
 
 93  
     /**
 94  
      * @see net.sf.statcvs.output.WebRepositoryIntegration#getDiffUrl
 95  
      */
 96  
     public String getDiffUrl(final Revision oldRevision, final Revision newRevision) {
 97  8
         if (!oldRevision.getFile().equals(newRevision.getFile())) {
 98  0
             throw new IllegalArgumentException("revisions must be of the same file");
 99  
         }
 100  8
         return getFileHistoryUrl(oldRevision.getFile()) + "?r1=" + oldRevision.getRevisionNumber() + "&r2=" + newRevision.getRevisionNumber();
 101  
     }
 102  
 
 103  
     /**
 104  
      * @see net.sf.statcvs.output.WebRepositoryIntegration#setAtticFileNames(java.util.Set)
 105  
      */
 106  
     public void setAtticFileNames(final Set atticFileNames) {
 107  8
         this.atticFileNames = atticFileNames;
 108  8
     }
 109  
 
 110  
     private boolean isInAttic(final VersionedFile file) {
 111  48
         return atticFileNames.contains(file.getFilenameWithPath());
 112  
     }
 113  
 
 114  
     public String getBaseUrl() {
 115  0
         return baseURL;
 116  
     }
 117  
 }