View Javadoc

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: ViewVcIntegration.java,v $
21  	$Date: 2009/06/02 13:27:20 $
22  */
23  package net.sf.statcvs.output;
24  
25  import net.sf.statcvs.model.Revision;
26  import net.sf.statcvs.model.VersionedFile;
27  
28  /**
29   * Integration of ViewVC
30   *
31   * @author Richard Cyganiak
32   * @author Jason Kealey
33   *
34   * @version $Id: ViewVcIntegration.java,v 1.4 2009/06/02 13:27:20 benoitx Exp $
35   */
36  public class ViewVcIntegration extends ViewCvsIntegration {
37      /**
38       * @param baseURL base URL of the ViewVC installation
39       */
40      public ViewVcIntegration(final String baseURL) {
41          super(baseURL);
42      }
43  
44      /**
45       * @see net.sf.statsvn.output.WebRepositoryIntegration#getName
46       */
47      public String getName() {
48          return "ViewVC";
49      }
50  
51      protected String getFileUrl(final VersionedFile file, final String parameter) {
52          String filename;
53          //		if (isInAttic(file)) {
54          //			String path = file.getDirectory().getPath();
55          //			filename = "/" + path + "Attic/" + file.getFilename();
56          //
57          //		} else {
58          filename = "/" + file.getFilenameWithPath();
59          //		}
60  
61          String append = parameter;
62          if (getPostfix() != null) {
63              append += (append.length() > 0) ? "&" + getPostfix() : "?" + getPostfix();
64          }
65          return getBaseUrl() + filename + append;
66      }
67  
68      /**
69       * @see net.sf.statcvs.output.WebRepositoryIntegration#getDiffUrl
70       */
71      public String getDiffUrl(final Revision oldRevision, final Revision newRevision) {
72          if (!oldRevision.getFile().equals(newRevision.getFile())) {
73              throw new IllegalArgumentException("revisions must be of the same file");
74          }
75          // because of ViewCVS limitations regarding dead files.
76          if (isInAttic(newRevision.getFile())) {
77              return getFileViewUrl(newRevision);
78          } else {
79              return getFileUrl(oldRevision.getFile(), "?r1=" + oldRevision.getRevisionNumber() + "&r2=" + newRevision.getRevisionNumber());
80          }
81      }
82  }