X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frest%2Fimpl%2FXmlToCompositeNodeReader.java;h=d71a12ff744c2b06b804a7d4a53487ec66739451;hp=5944d6003e9e1e33dba8a0b482a60de5f01ac4c0;hb=3591817114661bb7971d6d355186ff1b39636fcd;hpb=48daeb11697dbb83f554b64fe8702e21de3e0a12 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlToCompositeNodeReader.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlToCompositeNodeReader.java index 5944d6003e..d71a12ff74 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlToCompositeNodeReader.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlToCompositeNodeReader.java @@ -28,9 +28,13 @@ import org.opendaylight.controller.sal.restconf.impl.NodeWrapper; import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper; import org.opendaylight.yangtools.yang.data.api.Node; +@Deprecated public class XmlToCompositeNodeReader { private final static XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); + static { + xmlInputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", false); + } private XMLEventReader eventReader; public Node read(InputStream entityStream) throws XMLStreamException, @@ -45,7 +49,6 @@ public class XmlToCompositeNodeReader { } eventReader = xmlInputFactory.createXMLEventReader(entityStream); - if (eventReader.hasNext()) { XMLEvent element = eventReader.peek(); if (element.isStartDocument()) { @@ -110,7 +113,7 @@ public class XmlToCompositeNodeReader { return entityStream; } - private boolean isInputStreamEmpty(InputStream entityStream) throws IOException { + private boolean isInputStreamEmpty(final InputStream entityStream) throws IOException { boolean isEmpty = false; entityStream.mark(1); if (entityStream.read() == -1) { @@ -180,7 +183,7 @@ public class XmlToCompositeNodeReader { resolveValueOfElement(data, startElement)); } - private String getValueOf(StartElement startElement) throws XMLStreamException { + private String getValueOf(final StartElement startElement) throws XMLStreamException { String data = null; if (eventReader.hasNext()) { final XMLEvent innerEvent = eventReader.peek(); @@ -201,7 +204,7 @@ public class XmlToCompositeNodeReader { return data == null ? null : data.trim(); } - private String getAdditionalData(XMLEvent event) throws XMLStreamException { + private String getAdditionalData(final XMLEvent event) throws XMLStreamException { String data = ""; if (eventReader.hasNext()) { final XMLEvent innerEvent = eventReader.peek(); @@ -216,16 +219,16 @@ public class XmlToCompositeNodeReader { return data; } - private String getLocalNameFor(StartElement startElement) { + private String getLocalNameFor(final StartElement startElement) { return startElement.getName().getLocalPart(); } - private URI getNamespaceFor(StartElement startElement) { + private URI getNamespaceFor(final StartElement startElement) { String namespaceURI = startElement.getName().getNamespaceURI(); return namespaceURI.isEmpty() ? null : URI.create(namespaceURI); } - private Object resolveValueOfElement(String value, StartElement startElement) { + private Object resolveValueOfElement(final String value, final StartElement startElement) { // it could be instance-identifier Built-In Type if (value.startsWith("/")) { IdentityValuesDTO iiValue = RestUtil.asInstanceIdentifier(value, new RestUtil.PrefixMapingFromXml(