"enterprise.deployment.io.errorcontext",
"archive {0} and deployment descriptor file {1}",
new Object []{ error, getDeploymentDescriptorPath()});
SAXParser sp = getSAXParser(getXMLValidation());
SaxParserHandler dh = SaxParserHandlerFactory.newInstance();
if (validationLevel.equals(FULL_VALIDATION)) {
dh.setStopOnError(true);
}
if (descriptor!=null) {
dh.setTopNode(getRootXMLNode(descriptor));
}
dh.setErrorReportingString(errorReporting);
InputSource input =new InputSource(is);
try {
sp.parse(input,dh);
} catch(SAXParseException e) {
DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.saxParserError",
new Object[]{e.getMessage()});
errorReporting += " " + e.getLocalizedMessage();
SAXParseException spe = new SAXParseException(errorReporting,
e.getSystemId(),
e.getPublicId(),
e.getLineNumber(),
e.getColumnNumber(),
e);
throw spe;
} catch(SAXException e) {
if (e.getException()!=null) {
e.getException().printStackTrace();
}
DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.saxParserError",
new Object[]{e.getMessage()});
return null;
} catch (IOException e) {
DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.saxParserError",
e.getMessage() == null ? "" : new Object[]{e.getMessage()});
// Let's check if the root cause of this IOException is failing to
// connect. If yes, it means two things:
// 1. The public id declared is not one of the pre-defined ones.
// So we need to ask user the check for typo.
// 2. If the user does intend to use the system id to go outside.
// We need to ask them to check whether they have proper
// access to the internet (proxy setting etc).
StackTraceElement[] stElements = e.getStackTrace();
for (int i = 0; i < stElements.length; i++) {
StackTraceElement stElement = stElements[i];
if (stElement.getClassName().equals("java.net.Socket") &&
stElement.getMethodName().equals("connect")) {
String msg = localStrings.getLocalString(
"enterprise.deployment.can_not_locate_dtd",
"Unable to locate the DTD to validate your deployment descriptor file [{1}] in archive [{0}]. Please make sure the DOCTYPE is correct (no typo in public ID or system ID) and you have proper access to the Internet.",
new Object []{ error, getDeploymentDescriptorPath()});
IOException ioe = new IOException(msg);
ioe.initCause(e);
throw ioe;
}
}
IOException ioe = new IOException(localStrings.getLocalString(
"enterprise.deployment.backend.error_parsing_descr",
"Error parsing descriptor: {0}", new Object[] {errorReporting}));
ioe.initCause(e);
throw ioe;
}
if (dh.getTopNode()!=null) {
Object topDesc = dh.getTopNode().getDescriptor();
if (topDesc instanceof Descriptor) {
return (Descriptor) topDesc;
}
}
return null;