1 7 package net.sourceforge.cvsgrab.web; 8 9 import net.sourceforge.cvsgrab.CVSGrab; 10 import net.sourceforge.cvsgrab.RemoteFile; 11 import net.sourceforge.cvsgrab.WebBrowser; 12 13 import org.apache.commons.httpclient.URIException; 14 import org.apache.commons.jxpath.JXPathContext; 15 16 17 24 public class ViewCvs0_7Interface extends ViewCvsInterface { 25 26 29 public ViewCvs0_7Interface(CVSGrab grabber) { 30 super(grabber); 31 32 setFilesXpath("//TR[TD//A/IMG/@alt = '[FILE_ICON]']"); 33 setFileNameXpath("TD[1]/A/@name"); 34 setDirectoriesXpath("//TR[TD//A/IMG/@alt = '[DIR_ICON]'][TD/A/@name != 'Attic']"); 35 setDirectoryXpath("TD[1]/A/@name"); 36 setCheckoutPath("~checkout~/"); 37 } 38 39 44 public String getDownloadUrl(String rootUrl, RemoteFile file) { 45 try { 46 String url = WebBrowser.forceFinalSlash(rootUrl); 48 String dir = file.getDirectory().getDirectoryPath(); 49 url += getCheckoutPath(); 50 url += WebBrowser.forceFinalSlash(quote(dir)); 51 url += quote(file.getName()); 52 url = WebBrowser.addQueryParam(url, "rev", quote(file.getVersion())); 53 url = WebBrowser.addQueryParam(url, getQueryParams()); 54 return url; 55 } catch (URIException ex) { 56 ex.printStackTrace(); 57 throw new RuntimeException ("Cannot create URI"); 58 } 59 } 60 61 protected String getVersionMarker() { 62 return "ViewCVS 0.7"; 63 } 64 65 protected void adjustFile(RemoteFile file, JXPathContext nodeContext) { 66 super.adjustFile(file, nodeContext); 67 String href = (String ) nodeContext.getValue("TD/A/@href"); 68 if (href.startsWith("Attic/")) { 69 file.setInAttic(true); 70 } 71 } 72 73 } 74 | Popular Tags |