1 16 package org.directwebremoting.impl; 17 18 import java.io.InputStream ; 19 20 import org.directwebremoting.extend.DwrConstants; 21 import org.directwebremoting.util.Logger; 22 import org.directwebremoting.util.Messages; 23 import org.xml.sax.EntityResolver ; 24 import org.xml.sax.InputSource ; 25 import org.xml.sax.SAXException ; 26 27 28 33 public final class DTDEntityResolver implements EntityResolver 34 { 35 38 public InputSource resolveEntity(String publicId, String systemId) throws SAXException 39 { 40 for (int i = 0; i < MAPPINGS.length; i++) 41 { 42 if (publicId.equals(MAPPINGS[i][0])) 43 { 44 if (i != MAPPINGS.length - 1) 45 { 46 String doctype = "<!DOCTYPE dwr PUBLIC \"" + 47 MAPPINGS[MAPPINGS.length - 1][0] + "\" \"http://getahead.org/dwr/" + 48 MAPPINGS[MAPPINGS.length - 1][1] + "\">"; 49 50 log.warn("Deprecated public id in dwr.xml. Use: " + doctype); 51 } 52 53 String dtdname = DwrConstants.PACKAGE + MAPPINGS[i][1]; 54 InputStream raw = getClass().getResourceAsStream(dtdname); 55 return new InputSource (raw); 56 } 57 } 58 59 throw new SAXException (Messages.getString("DTDEntityResolver.ResolveFailed", publicId, systemId)); 60 } 61 62 67 private static final String [][] MAPPINGS = 68 { 69 { "-//GetAhead Limited//DTD Direct Web Remoting 0.4//EN", "/dwr10.dtd"}, 70 { "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN", "/dwr10.dtd"}, 71 { "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN", "/dwr20.dtd"}, 72 }; 73 74 77 private static final Logger log = Logger.getLogger(DTDEntityResolver.class); 78 } 79 | Popular Tags |