| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ChoraIntegration |
|
| 1.3;1.3 |
| 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: 2004/10/12 07:22:42 $ | |
| 22 | */ | |
| 23 | package net.sf.statsvn.output; | |
| 24 | ||
| 25 | import java.util.Set; | |
| 26 | ||
| 27 | import net.sf.statcvs.model.Directory; | |
| 28 | import net.sf.statcvs.model.Revision; | |
| 29 | import net.sf.statcvs.model.VersionedFile; | |
| 30 | import net.sf.statcvs.output.WebRepositoryIntegration; | |
| 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.9 2004/10/12 07:22:42 cyganiak Exp $ | |
| 37 | */ | |
| 38 | public class ChoraIntegration implements WebRepositoryIntegration { | |
| 39 | private String baseURL; | |
| 40 | ||
| 41 | /** | |
| 42 | * @param baseURL | |
| 43 | * base URL of the Chora installation | |
| 44 | */ | |
| 45 | 0 | public ChoraIntegration(final String baseURL) { |
| 46 | 0 | if (baseURL.endsWith("/")) { |
| 47 | 0 | this.baseURL = baseURL.substring(0, baseURL.length() - 1); |
| 48 | } else { | |
| 49 | 0 | this.baseURL = baseURL; |
| 50 | } | |
| 51 | 0 | } |
| 52 | ||
| 53 | /** | |
| 54 | * @see net.sf.statsvn.output.WebRepositoryIntegration#getName | |
| 55 | */ | |
| 56 | public String getName() { | |
| 57 | 0 | return "Chora"; |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 | * @see net.sf.statsvn.output.WebRepositoryIntegration#getDirectoryUrl | |
| 62 | */ | |
| 63 | public String getDirectoryUrl(final Directory directory) { | |
| 64 | 0 | return baseURL + "/?f=" + directory.getPath(); |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * @see net.sf.statsvn.output.WebRepositoryIntegration#getFileHistoryUrl | |
| 69 | */ | |
| 70 | public String getFileHistoryUrl(final VersionedFile file) { | |
| 71 | // chora doesn't seem to support deleted files for subversion | |
| 72 | // repositories | |
| 73 | // if (isInAttic(file)) { | |
| 74 | // String path = file.getDirectory().getPath(); | |
| 75 | // String filename = file.getFilename(); | |
| 76 | // return baseURL + "/" + path + "Attic/" + filename; | |
| 77 | // } | |
| 78 | 0 | return this.baseURL + "/?f=" + file.getFilenameWithPath(); |
| 79 | } | |
| 80 | ||
| 81 | private String getFileViewBaseUrl(final VersionedFile file) { | |
| 82 | 0 | return this.baseURL + "/co.php?f=" + file.getFilenameWithPath(); |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * @see net.sf.statsvn.output.WebRepositoryIntegration#getFileViewUrl(VersionedFile) | |
| 87 | */ | |
| 88 | public String getFileViewUrl(final VersionedFile file) { | |
| 89 | 0 | return getFileViewBaseUrl(file) + "&r=HEAD"; |
| 90 | } | |
| 91 | ||
| 92 | /** | |
| 93 | * @see net.sf.statsvn.output.WebRepositoryIntegration#getFileViewUrl(VersionedFile) | |
| 94 | */ | |
| 95 | public String getFileViewUrl(final Revision revision) { | |
| 96 | 0 | return getFileViewBaseUrl(revision.getFile()) + "&r=" + revision.getRevisionNumber(); |
| 97 | } | |
| 98 | ||
| 99 | /** | |
| 100 | * @see net.sf.statsvn.output.WebRepositoryIntegration#getDiffUrl | |
| 101 | */ | |
| 102 | public String getDiffUrl(final Revision oldRevision, final Revision newRevision) { | |
| 103 | 0 | if (!oldRevision.getFile().equals(newRevision.getFile())) { |
| 104 | 0 | throw new IllegalArgumentException("revisions must be of the same file"); |
| 105 | } | |
| 106 | ||
| 107 | 0 | return this.baseURL + "/diff.php?f=" + oldRevision.getFile().getFilenameWithPath() + "&r1=" + oldRevision.getRevisionNumber() + "&r2=" |
| 108 | + newRevision.getRevisionNumber() + "&ty=h"; | |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * @see net.sf.statsvn.output.WebRepositoryIntegration#setAtticFileNames(java.util.Set) | |
| 113 | */ | |
| 114 | public void setAtticFileNames(final Set atticFileNames) { | |
| 115 | // this.atticFileNames = atticFileNames; | |
| 116 | 0 | } |
| 117 | ||
| 118 | public String getBaseUrl() { | |
| 119 | 0 | return baseURL; |
| 120 | } | |
| 121 | } |