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.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
54
55
56
57
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
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 }