1 5 package com.opensymphony.workflow.loader; 6 7 import org.xml.sax.EntityResolver ; 8 import org.xml.sax.InputSource ; 9 import org.xml.sax.SAXException ; 10 11 import java.io.IOException ; 12 import java.io.InputStream ; 13 14 import java.net.URL ; 15 16 17 22 public class DTDEntityResolver implements EntityResolver { 23 25 public InputSource resolveEntity(String publicId, String systemId) throws SAXException , IOException { 26 if (systemId == null) { 27 return null; 28 } 29 30 URL url = new URL (systemId); 31 String file = url.getFile(); 32 33 if ((file != null) && (file.indexOf('/') > -1)) { 34 file = file.substring(file.lastIndexOf('/') + 1); 35 } 36 37 if ("www.opensymphony.com".equals(url.getHost())) { 38 InputStream is = getClass().getResourceAsStream("/META-INF/" + file); 39 40 if (is == null) { 41 is = getClass().getResourceAsStream("/" + file); 42 } 43 44 if (is != null) { 45 return new InputSource (is); 46 } 47 } 48 49 return null; 50 } 51 } 52 | Popular Tags |