use of com.sun.enterprise.deployment.node.RootXMLNode in project Payara by payara.
the class DeploymentDescriptorFile method read.
/**
* read and parse a J2EE Deployment Descriptor input file and
* return the constructed DOL descriptors for the J2EE Module
*
* @param descriptor if the read is incremental, the descriptor to apply the DDs to
* @param is the input stream for the XML file
* @return the DOL descriptor for the J2EE Module
*/
@SuppressWarnings("unchecked")
public T read(T descriptor, InputStream is) throws IOException, SAXParseException {
errorReportingString = FileUtils.revertFriendlyFilenameExtension(errorReportingString);
String error = (errorReportingString == null) ? errorReportingString : new File(errorReportingString).getName();
String errorReporting = localStrings.getLocalString("enterprise.deployment.io.errorcontext", "archive {0} and deployment descriptor file {1}", 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) {
DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.saxParserError", new Object[] { e.getMessage() });
DOLUtils.getDefaultLogger().log(Level.SEVERE, "Error occurred", e);
return null;
} catch (IOException e) {
DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.saxParserError", e.getMessage() == null ? "" : new Object[] { e.getMessage() });
// access to the internet (proxy setting etc).
for (StackTraceElement stElement : e.getStackTrace()) {
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.", 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}", errorReporting));
ioe.initCause(e);
throw ioe;
}
if (dh.getTopNode() != null) {
return ((RootXMLNode<T>) dh.getTopNode()).getDescriptor();
}
return null;
}
use of com.sun.enterprise.deployment.node.RootXMLNode in project Payara by payara.
the class WLSApplicationRuntimeDDFile method getRootXMLNode.
/**
* @return a RootXMLNode responsible for handling the deployment
* descriptors associated with this J2EE module
*
* @param the descriptor for which we need the node
*/
public RootXMLNode getRootXMLNode(Descriptor descriptor) {
if (descriptor instanceof Application) {
Application application = (Application) descriptor;
RootXMLNode node = application.getRootNode(getDeploymentDescriptorPath());
if (node == null) {
node = new WeblogicApplicationNode(application);
application.addRootNode(getDeploymentDescriptorPath(), node);
}
return node;
}
return new WeblogicApplicationNode();
}
Aggregations