tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1547947 - in /tomcat/tc7.0.x/trunk: java/org/apache/jasper/xmlparser/ParserUtils.java res/checkstyle/org-import-control.xml
Date Wed, 04 Dec 2013 22:48:52 GMT
Author: markt
Date: Wed Dec  4 22:48:52 2013
New Revision: 1547947

URL: http://svn.apache.org/r1547947
Log:
Convert ParserUtils to use the new ErrorHandler and EntityResolver

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
    tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java?rev=1547947&r1=1547946&r2=1547947&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java Wed Dec  4 22:48:52
2013
@@ -24,11 +24,10 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.jasper.Constants;
 import org.apache.jasper.JasperException;
 import org.apache.jasper.compiler.Localizer;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.descriptor.DigesterFactory;
+import org.apache.tomcat.util.descriptor.XmlErrorHandler;
 import org.w3c.dom.Comment;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
@@ -56,13 +55,13 @@ public class ParserUtils {
     /**
      * An error handler for use when parsing XML documents.
      */
-    static ErrorHandler errorHandler = new MyErrorHandler();
+    static ErrorHandler errorHandler = new XmlErrorHandler();
 
     /**
      * An entity resolver for use when parsing XML documents.
      */
-    static EntityResolver entityResolver = new MyEntityResolver();
-
+    static EntityResolver entityResolver = DigesterFactory.SERVLET_API_RESOLVER;
+    
     private final boolean validating;
 
     public ParserUtils(boolean validating) {
@@ -198,56 +197,3 @@ public class ParserUtils {
         return (treeNode);
     }
 }
-
-
-// ------------------------------------------------------------ Private Classes
-
-class MyEntityResolver implements EntityResolver {
-
-    @Override
-    public InputSource resolveEntity(String publicId, String systemId)
-            throws SAXException {
-        for (int i = 0; i < Constants.CACHED_DTD_PUBLIC_IDS.size(); i++) {
-            String cachedDtdPublicId = Constants.CACHED_DTD_PUBLIC_IDS.get(i);
-            if (cachedDtdPublicId.equals(publicId)) {
-                String resourcePath =
-                    Constants.CACHED_DTD_RESOURCE_PATHS.get(i);
-                InputStream input = this.getClass().getResourceAsStream(
-                        resourcePath);
-                if (input == null) {
-                    throw new SAXException(Localizer.getMessage(
-                            "jsp.error.internal.filenotfound", resourcePath));
-                }
-                InputSource isrc = new InputSource(input);
-                return isrc;
-            }
-        }
-        Log log = LogFactory.getLog(MyEntityResolver.class);
-        if (log.isDebugEnabled())
-            log.debug("Resolve entity failed" + publicId + " " + systemId);
-        log.error(Localizer.getMessage("jsp.error.parse.xml.invalidPublicId",
-                publicId));
-        return null;
-    }
-}
-
-class MyErrorHandler implements ErrorHandler {
-
-    @Override
-    public void warning(SAXParseException ex) throws SAXException {
-        Log log = LogFactory.getLog(MyErrorHandler.class);
-        if (log.isDebugEnabled())
-            log.debug("ParserUtils: warning ", ex);
-        // We ignore warnings
-    }
-
-    @Override
-    public void error(SAXParseException ex) throws SAXException {
-        throw ex;
-    }
-
-    @Override
-    public void fatalError(SAXParseException ex) throws SAXException {
-        throw ex;
-    }
-}

Modified: tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml?rev=1547947&r1=1547946&r2=1547947&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml (original)
+++ tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml Wed Dec  4 22:48:52 2013
@@ -95,6 +95,7 @@
     <allow pkg="org.apache.jasper"/>
     <allow pkg="org.apache.juli"/>
     <allow pkg="org.apache.tomcat" exact-match="true"/>
+    <allow pkg="org.apache.tomcat.util.descriptor"/>
     <allow pkg="org.apache.tomcat.util.scan"/>
     <allow pkg="org.apache.tools.ant"/>
     <allow pkg="org.eclipse.jdt"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message