1 6 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 13 import org.apache.commons.jxpath.JXPathContext; 14 import org.w3c.dom.Document ; 15 16 23 public class CvsWeb3_0Interface extends ViewCvsInterface { 24 25 28 public CvsWeb3_0Interface(CVSGrab grabber) { 29 super(grabber); 30 31 setFilesXpath("//TR/TD[@class = 'file']"); 32 setFileNameXpath("A[2]/text()"); 33 setFileVersionXpath("./following::node()/A/text()"); 34 setDirectoriesXpath("//TR/TD[@class = 'dir'][A/@name][A/@name != 'Attic' and A/@href !='../']"); 35 setDirectoryXpath("A/@name"); 36 setCheckoutPath("~checkout~/"); 37 setWebInterfaceType("cvsweb"); 38 } 39 40 46 public void detect(Document htmlPage) throws MarkerNotFoundException, InvalidVersionException { 47 JXPathContext context = JXPathContext.newContext(htmlPage); 48 context.setLenient(true); 49 String generator = (String ) context.getValue("//META[@name = 'generator']/@content"); 51 52 if (generator == null) { 53 generator = (String ) context.getValue("//comment()[starts-with(normalize-space(.),'FreeBSD-cvsweb')]"); 54 } 55 56 if (generator == null || generator.toLowerCase().indexOf("cvsweb") < 0) { 57 throw new MarkerNotFoundException("Not CvsWeb, found marker " + generator); 58 } 59 if (generator.indexOf(" 3.") < 0) { 60 throw new InvalidVersionException("Version not supported of CvsWeb: " + generator); 61 } 62 63 setType(generator); 64 } 65 66 70 protected String getVersionMarker() { 71 return null; 72 } 73 74 } 75 | Popular Tags |