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 CvsWeb2_0Interface extends ViewCvsInterface { 24 25 28 public CvsWeb2_0Interface(CVSGrab grabber) { 29 super(grabber); 30 31 setFilesXpath("//TR[TD/A/IMG/@alt = '[TXT]']"); 32 setDirectoriesXpath("//TR[TD/A/IMG/@alt = '[DIR]'][TD/A/@name != 'Attic']"); 33 setCheckoutPath("~checkout~/"); 34 setWebInterfaceType("cvsweb"); 35 } 36 37 43 public void detect(Document htmlPage) throws MarkerNotFoundException, InvalidVersionException { 44 JXPathContext context = JXPathContext.newContext(htmlPage); 45 context.setLenient(true); 46 String generator = (String ) context.getValue("//META[@name = 'generator']/@content"); 48 49 if (generator == null) { 50 generator = (String ) context.getValue("//comment()[starts-with(normalize-space(.),'FreeBSD-cvsweb')]"); 51 } 52 53 if (generator == null || generator.toLowerCase().indexOf("cvsweb") < 0) { 54 throw new MarkerNotFoundException("Not CvsWeb, found marker " + generator); 55 } 56 if (generator.indexOf(" 2.") < 0) { 57 throw new InvalidVersionException("Version not supported of CvsWeb: " + generator); 58 } 59 60 setType(generator); 61 } 62 63 67 protected String getVersionMarker() { 68 return null; 69 } 70 71 } 72 | Popular Tags |