Test case for failing j2ee plugin when proxies cache a bad DTD.
The entities weren't being resolved locally. Refactor and fix bad resource name git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113236 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5e82d07dfc
commit
394d4ceaf2
@ -71,7 +71,7 @@ import org.xml.sax.SAXException;
|
||||
* A class to resolve external entity definitions for j2ee artifacts.
|
||||
*
|
||||
* @author dion
|
||||
* @version $Id: J2EEEntityResolver.java,v 1.3 2003/02/23 11:29:29 dion Exp $
|
||||
* @version $Id: J2EEEntityResolver.java,v 1.4 2003/03/31 03:02:07 dion Exp $
|
||||
*/
|
||||
public class J2EEEntityResolver implements EntityResolver
|
||||
{
|
||||
@ -81,27 +81,30 @@ public class J2EEEntityResolver implements EntityResolver
|
||||
/** log for debug output */
|
||||
private static final Log LOG = LogFactory.getLog(J2EEEntityResolver.class);
|
||||
|
||||
/** list of j2ee dtds that are being made available */
|
||||
public static final String[] J2EE_DTDS = new String[] {
|
||||
"-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN",
|
||||
"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN",
|
||||
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN",
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",
|
||||
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
|
||||
};
|
||||
public static final String[] J2EE_RESOURCES = new String[] {
|
||||
"/plugin-resources/application-client_1_3.dtd",
|
||||
"/plugin-resources/application_1_3.dtd",
|
||||
"/plugin-resources/ejb-jar_2_0.dtd",
|
||||
"/plugin-resources/web-app_2.2.dtd",
|
||||
"/plugin-resources/web-app_2_3.dtd",
|
||||
"/plugin-resources/web-jsptaglibrary_1_2.dtd"
|
||||
};
|
||||
|
||||
/** Creates a new instance of EntityResolver */
|
||||
public J2EEEntityResolver()
|
||||
{
|
||||
idToResource.put(
|
||||
"-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN",
|
||||
"/plugin-resources/application-client_1_3.dtd");
|
||||
idToResource.put(
|
||||
"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN",
|
||||
"/plugin-resources/application_1_3.dtd");
|
||||
idToResource.put(
|
||||
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN",
|
||||
"/plugin-resources/ejb-jar_2_0.dtd");
|
||||
idToResource.put(
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",
|
||||
"/plugin-resources/web-app_2_2.dtd");
|
||||
idToResource.put(
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",
|
||||
"/plugin-resources/web-app_2_3.dtd");
|
||||
idToResource.put(
|
||||
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN",
|
||||
"/plugin-resources/web-jsptaglibrary_1_2.dtd");
|
||||
for (int i = 0; i < J2EE_DTDS.length; i++) {
|
||||
idToResource.put(J2EE_DTDS[i], J2EE_RESOURCES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/** resolve the entity given by the provided Ids
|
||||
@ -114,12 +117,15 @@ public class J2EEEntityResolver implements EntityResolver
|
||||
public InputSource resolveEntity(String publicId, String systemId) throws
|
||||
SAXException, IOException
|
||||
{
|
||||
LOG.debug("resolving entity with publicId='" + publicId + ", systemId='" + systemId + "'");
|
||||
if (publicId != null)
|
||||
{
|
||||
String resource = (String) idToResource.get(publicId);
|
||||
LOG.debug("resource found in map ='" + resource + "'" );
|
||||
if (resource != null)
|
||||
{
|
||||
InputStream in = getClass().getResourceAsStream(resource);
|
||||
LOG.debug("input stream ='" + in + "'" );
|
||||
if (in != null)
|
||||
{
|
||||
return new InputSource(in);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user