1 7 package net.sourceforge.cvsgrab.web; 8 9 import net.sourceforge.cvsgrab.CVSGrab; 10 import net.sourceforge.cvsgrab.InvalidVersionException; 11 import net.sourceforge.cvsgrab.MarkerNotFoundException; 12 import net.sourceforge.cvsgrab.WebBrowser; 13 14 import org.apache.commons.jxpath.JXPathContext; 15 import org.w3c.dom.Document ; 16 17 18 25 public class ViewCvs0_9Interface extends ViewCvsInterface { 26 27 private String _root; 28 29 32 public ViewCvs0_9Interface(CVSGrab grabber) { 33 super(grabber); 34 } 35 36 42 public void detect(Document htmlPage) throws MarkerNotFoundException, InvalidVersionException { 43 super.detect(htmlPage); 44 45 _root = getGrabber().getProjectRoot(); 46 if (_root == null) { 47 JXPathContext context = JXPathContext.newContext(htmlPage); 48 context.setLenient(true); 49 String href = (String ) context.getValue("//A/@href[contains(., 'cvsroot=')]"); 50 if (href != null) { 51 _root = href.substring(href.indexOf("cvsroot=") + 8); 52 if (_root.indexOf('#') > 0) { 53 _root = _root.substring(0, _root.indexOf('#')); 54 } 55 if (_root.indexOf('&') > 0) { 56 _root = _root.substring(0, _root.indexOf('&')); 57 } 58 } 59 getGrabber().getWebOptions().setProjectRoot(_root); 60 } 61 } 62 63 protected String getVersionMarker() { 64 return "ViewCVS 0.9"; 65 } 66 67 70 public String getAltBaseUrl() { 71 String url = WebBrowser.forceFinalSlash(getGrabber().getRootUrl()); 72 url = WebBrowser.addQueryParam(getCvsrootParam(), getProjectRoot()); 73 url = WebBrowser.addQueryParam(url, getGrabber().getQueryParams()); 74 return url; 75 } 76 77 80 public String getProjectRoot() { 81 if (_root == null) { 82 _root = getGrabber().getProjectRoot(); 83 } 84 return _root; 85 } 86 87 90 public void setProjectRoot(String root) { 91 _root = root; 92 } 93 94 } 95 | Popular Tags |