1 23 24 package com.sun.enterprise.config.serverbeans; 25 26 import org.xml.sax.helpers.DefaultHandler ; 27 import org.xml.sax.SAXParseException ; 28 import org.xml.sax.InputSource ; 29 import org.xml.sax.SAXException ; 30 import java.io.FileInputStream ; 31 import java.io.File ; 32 import java.io.InputStream ; 33 34 import java.util.logging.Logger ; 35 import java.util.logging.Level ; 36 38 import com.sun.enterprise.util.RelativePathResolver; 42 43 public class ServerValidationHandler extends DefaultHandler { 44 45 47 public static final String SERVER_8_DTD_PUBLIC_ID = 48 "-//Sun Microsystems Inc.//DTD Sun ONE Application Server 8.0//EN"; 49 50 public static final String SERVER_8_DTD_PUBLIC_ID_PATH = 51 "/sun-domain_1_2.dtd"; 52 53 57 public void error(SAXParseException e) 59 throws SAXParseException 60 { 61 68 throw e; 69 } 70 71 public void warning(SAXParseException e) 73 throws SAXParseException 74 { 75 82 } 84 85 public void fatalError(SAXParseException e) 86 throws SAXParseException { 87 94 throw e; 95 } 96 97 101 public InputSource resolveEntity(String publicID, String systemID) throws SAXException { 102 InputSource is = null; 103 try { 104 InputStream i = this.getClass().getResourceAsStream( SERVER_8_DTD_PUBLIC_ID_PATH ); 105 if( i!= null ) { 106 return new InputSource (i); 107 } 108 109 110 is = new InputSource ( 111 new FileInputStream ( 112 new File (new java.net.URI ( 113 RelativePathResolver.resolvePath(systemID))))); 114 } catch(Exception e) { 115 throw new SAXException ("cannot resolve dtd", e); 116 } 117 return is; 118 } 119 } 120 | Popular Tags |