1 23 24 29 30 package com.sun.enterprise.tools.admingui.handlers; 31 32 import com.iplanet.jato.RequestManager; 33 35 import org.xml.sax.EntityResolver ; 36 import org.xml.sax.InputSource ; 37 import java.io.File ; 38 import java.io.InputStream ; 39 import java.net.URL ; 40 import javax.servlet.ServletContext ; 41 42 47 48 public class CCEntityResolver implements EntityResolver { public InputSource resolveEntity (String publicId, String systemId) { 50 if (systemId != null && (systemId.startsWith("http")==false) && 58 (systemId.endsWith(".xml") || systemId.endsWith(".dtd"))) { 59 InputStream resourceStream = null; 60 int i = systemId.indexOf("dtd/"); 61 if (i >= 0) { 62 systemId = "xml/" + systemId.substring(i); 63 resourceStream = getClass().getClassLoader() 66 .getResourceAsStream(systemId); 67 if (resourceStream == null) { 68 String sURL = "file:///" + 70 RequestManager.getRequestContext().getServletContext() 71 .getRealPath(systemId); 72 try { 74 resourceStream = new URL (sURL).openStream(); 75 } catch (Exception ex) { 76 } 78 } 79 } 80 if (resourceStream != null) { 81 return new InputSource (resourceStream); 82 } 83 } 84 return null; 87 } 88 } 89 | Popular Tags |