1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 public ChoraIntegration(final String baseURL) {
46 if (baseURL.endsWith("/")) {
47 this.baseURL = baseURL.substring(0, baseURL.length() - 1);
48 } else {
49 this.baseURL = baseURL;
50 }
51 }
52
53 /**
54 * @see net.sf.statsvn.output.WebRepositoryIntegration#getName
55 */
56 public String getName() {
57 return "Chora";
58 }
59
60 /**
61 * @see net.sf.statsvn.output.WebRepositoryIntegration#getDirectoryUrl
62 */
63 public String getDirectoryUrl(final Directory directory) {
64 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
72
73
74
75
76
77
78 return this.baseURL + "/?f=" + file.getFilenameWithPath();
79 }
80
81 private String getFileViewBaseUrl(final VersionedFile file) {
82 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 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 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 if (!oldRevision.getFile().equals(newRevision.getFile())) {
104 throw new IllegalArgumentException("revisions must be of the same file");
105 }
106
107 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
116 }
117
118 public String getBaseUrl() {
119 return baseURL;
120 }
121 }