mirror of https://github.com/apache/nifi.git
NIFI-349:
- Setting namespace aware on all document builder factories.
This commit is contained in:
parent
42a2fc5f64
commit
750d215635
|
@ -35,7 +35,9 @@ public class XmlValidator {
|
|||
|
||||
public static void assertXmlValid(String xml) {
|
||||
try {
|
||||
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
|
||||
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
dbf.setNamespaceAware(true);
|
||||
dbf.newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
|
||||
} catch (SAXException | IOException | ParserConfigurationException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
|
|
@ -406,7 +406,9 @@ public class DataFlowDaoImpl implements DataFlowDao {
|
|||
|
||||
private byte[] getEmptyFlowBytes() throws IOException {
|
||||
try {
|
||||
final DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
docBuilderFactory.setNamespaceAware(true);
|
||||
final DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
|
||||
final Document document = docBuilder.newDocument();
|
||||
|
||||
final Element controller = document.createElement("flowController");
|
||||
|
|
|
@ -1085,8 +1085,9 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
|
|||
|
||||
private Document parse(final byte[] serialized) throws SAXException, ParserConfigurationException, IOException {
|
||||
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
final DocumentBuilder builder = docFactory.newDocumentBuilder();
|
||||
docFactory.setNamespaceAware(true);
|
||||
|
||||
final DocumentBuilder builder = docFactory.newDocumentBuilder();
|
||||
builder.setErrorHandler(new org.xml.sax.ErrorHandler() {
|
||||
@Override
|
||||
public void fatalError(final SAXParseException err) throws SAXException {
|
||||
|
@ -1483,6 +1484,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
|
|||
|
||||
private byte[] serializeControllerServices() throws ParserConfigurationException, TransformerException {
|
||||
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
docFactory.setNamespaceAware(true);
|
||||
|
||||
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
final Document document = docBuilder.newDocument();
|
||||
final Element rootElement = document.createElement("controllerServices");
|
||||
|
@ -1497,6 +1500,8 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
|
|||
|
||||
private byte[] serializeReportingTasks() throws ParserConfigurationException, TransformerException {
|
||||
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
docFactory.setNamespaceAware(true);
|
||||
|
||||
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
final Document document = docBuilder.newDocument();
|
||||
final Element rootElement = document.createElement("reportingTasks");
|
||||
|
|
|
@ -131,7 +131,10 @@ public class DataFlowManagementServiceImplTest {
|
|||
|
||||
private void verifyFlow() throws ParserConfigurationException, SAXException, IOException {
|
||||
final byte[] flowBytes = service.loadDataFlow().getDataFlow().getFlow();
|
||||
final DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
docFactory.setNamespaceAware(true);
|
||||
|
||||
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
final Document doc = docBuilder.parse(new ByteArrayInputStream(flowBytes));
|
||||
final Element controller = (Element) doc.getElementsByTagName("flowController").item(0);
|
||||
final Element rootGroup = (Element) controller.getElementsByTagName("rootGroup").item(0);
|
||||
|
|
|
@ -54,8 +54,9 @@ public class FlowUnmarshaller {
|
|||
}
|
||||
|
||||
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
|
||||
dbf.setNamespaceAware(true);
|
||||
|
||||
final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
|
||||
final Document document = docBuilder.parse(new ByteArrayInputStream(flowContents));
|
||||
final FlowSnippetDTO flowDto = new FlowSnippetDTO();
|
||||
|
||||
|
|
|
@ -71,6 +71,8 @@ public class StandardFlowSerializer implements FlowSerializer {
|
|||
try {
|
||||
// create a new, empty document
|
||||
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
docFactory.setNamespaceAware(true);
|
||||
|
||||
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
final Document doc = docBuilder.newDocument();
|
||||
|
||||
|
|
|
@ -345,7 +345,9 @@ public class StandardFlowSynchronizer implements FlowSynchronizer {
|
|||
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
final Schema schema = schemaFactory.newSchema(FLOW_XSD_RESOURCE);
|
||||
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
docFactory.setNamespaceAware(true);
|
||||
docFactory.setSchema(schema);
|
||||
|
||||
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
|
||||
// parse flow
|
||||
|
|
Loading…
Reference in New Issue