Bug 722 - nagasena version bumped to 0000.0002.0038 51/6351/3
authorMartin Bobak <mbobak@cisco.com>
Wed, 23 Apr 2014 12:43:32 +0000 (14:43 +0200)
committerMartin Bobak <mbobak@cisco.com>
Thu, 24 Apr 2014 08:23:57 +0000 (10:23 +0200)
Change-Id: Ie755a9a613096aed6f134005d216716c59b90563
Signed-off-by: Martin Bobak <mbobak@cisco.com>
opendaylight/commons/opendaylight/pom.xml
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageToEXIEncoder.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/EXILibTest.java [deleted file]
third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0038.0.jar [moved from third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0035.0.jar with 85% similarity]
third-party/org.openexi/nagasena-rta/pom.xml
third-party/org.openexi/nagasena/nagasena-0000.0002.0038.0.jar [moved from third-party/org.openexi/nagasena/nagasena-0000.0002.0035.0.jar with 80% similarity]
third-party/org.openexi/nagasena/pom.xml
third-party/org.openexi/pom.xml

index 3839d5b2cb527373e4509f73094991dc8a7c520c..4a7a395693e76b3ff31018ee2b218ca5047f62d7 100644 (file)
@@ -40,7 +40,7 @@
     <exam.version>3.0.0</exam.version>
 
     <!-- OpenEXI third party lib for netconf-->
     <exam.version>3.0.0</exam.version>
 
     <!-- OpenEXI third party lib for netconf-->
-    <exi.nagasena.version>0000.0002.0035.0-SNAPSHOT</exi.nagasena.version>
+    <exi.nagasena.version>0000.0002.0038.0-SNAPSHOT</exi.nagasena.version>
     <failsafe.version>2.15</failsafe.version>
     <forwarding.staticrouting>0.5.2-SNAPSHOT</forwarding.staticrouting>
     <forwardingrulesmanager.version>0.6.0-SNAPSHOT</forwardingrulesmanager.version>
     <failsafe.version>2.15</failsafe.version>
     <forwarding.staticrouting>0.5.2-SNAPSHOT</forwarding.staticrouting>
     <forwardingrulesmanager.version>0.6.0-SNAPSHOT</forwardingrulesmanager.version>
index 5edec0d1bdae2fb252b185057bc46ca4f6079e67..8425ce07794a922b62b88911245a619af8643557 100644 (file)
@@ -7,28 +7,27 @@
  */
 package org.opendaylight.controller.netconf.util.handler;
 
  */
 package org.opendaylight.controller.netconf.util.handler;
 
-import java.io.ByteArrayInputStream;
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufOutputStream;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToByteEncoder;
 import java.io.OutputStream;
 import java.io.OutputStream;
-
+import javax.xml.transform.Transformer;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXTransformerFactory;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.openexi.sax.Transmogrifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.openexi.sax.Transmogrifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.xml.sax.InputSource;
-
-import com.google.common.base.Preconditions;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufOutputStream;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.MessageToByteEncoder;
 
 public final class NetconfMessageToEXIEncoder extends MessageToByteEncoder<NetconfMessage> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageToEXIEncoder.class);
 
 
 public final class NetconfMessageToEXIEncoder extends MessageToByteEncoder<NetconfMessage> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageToEXIEncoder.class);
 
-    //private static final SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
+    private static final SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
     private final NetconfEXICodec codec;
 
     public NetconfMessageToEXIEncoder(final NetconfEXICodec codec) {
     private final NetconfEXICodec codec;
 
     public NetconfMessageToEXIEncoder(final NetconfEXICodec codec) {
@@ -43,10 +42,8 @@ public final class NetconfMessageToEXIEncoder extends MessageToByteEncoder<Netco
             final Transmogrifier transmogrifier = codec.getTransmogrifier();
             transmogrifier.setOutputStream(os);
 
             final Transmogrifier transmogrifier = codec.getTransmogrifier();
             transmogrifier.setOutputStream(os);
 
-            // FIXME transformer not working, see EXILibTest
-            transmogrifier.encode(new InputSource(new ByteArrayInputStream(XmlUtil.toString(msg.getDocument()).getBytes())));
-            //final Transformer transformer = saxTransformerFactory.newTransformer();
-            //transformer.transform(new DOMSource(msg.getDocument()), new SAXResult(transmogrifier.getSAXTransmogrifier()));
+            final Transformer transformer = saxTransformerFactory.newTransformer();
+            transformer.transform(new DOMSource(msg.getDocument()), new SAXResult(transmogrifier.getSAXTransmogrifier()));
         }
     }
 }
         }
     }
 }
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/EXILibTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/EXILibTest.java
deleted file mode 100644 (file)
index 360e812..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.netconf.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.StringWriter;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openexi.proc.common.AlignmentType;
-import org.openexi.proc.common.GrammarOptions;
-import org.openexi.proc.grammars.GrammarCache;
-import org.openexi.sax.EXIReader;
-import org.openexi.sax.Transmogrifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-
-/**
- * This test case tests nagasena library used for exi encode/decode.
- *
- * This library does not work correctly, since it is impossible to encode and then decode DOM xml.
- * Encoding DOM using sax Transformer produces invalid xml, that cannot be decoded (Problem seems to be the namespace handling).
- *
- */
-@Ignore
-public class EXILibTest {
-
-    public static final AlignmentType ALIGNMENT_TYPE = AlignmentType.preCompress;
-
-    @Test
-    public void testExiLibWithSaxTransformer() throws Exception {
-        final byte[] encode = encodeEXI(getDom2());
-        final byte[] encodeWithTransformer = encodeEXITransformer(getDom2());
-
-        // System.err.println(Arrays.toString(encode));
-        // System.err.println(Arrays.toString(encodeWithTransformer));
-
-        // This works fine (encoded from string)
-        decodeEXI(encode);
-        // Error, encoded from Dom with Transformer cannot be decoded, Exception is thrown
-        //
-        // either:
-        // org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
-        //
-        // or:
-        // java.lang.NullPointerException
-        //
-        // depends on GrammarOptions.addNS(go); option set
-        decodeEXI(encodeWithTransformer);
-    }
-
-    private static final SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
-
-    public static byte[] encodeEXITransformer(final Element xml) throws Exception {
-        final Transmogrifier transmogrifier = new Transmogrifier();
-
-        transmogrifier.setAlignmentType(ALIGNMENT_TYPE);
-
-        final ByteArrayOutputStream out = new ByteArrayOutputStream();
-
-        transmogrifier.setGrammarCache(getGrammarCache());
-
-        transmogrifier.setOutputStream(out);
-
-        final Transformer transformer = saxTransformerFactory.newTransformer();
-        transformer.transform(new DOMSource(xml), new SAXResult(transmogrifier.getSAXTransmogrifier()));
-
-        return out.toByteArray();
-    }
-
-    public static byte[] encodeEXI(final Element xml) throws Exception {
-        final Transmogrifier transmogrifier = new Transmogrifier();
-
-        transmogrifier.setAlignmentType(ALIGNMENT_TYPE);
-
-        final ByteArrayOutputStream out = new ByteArrayOutputStream();
-
-        transmogrifier.setGrammarCache(getGrammarCache());
-
-        transmogrifier.setOutputStream(out);
-
-        transmogrifier.encode(new InputSource(new ByteArrayInputStream(toString(xml, false).getBytes())));
-
-        out.flush();
-
-        return out.toByteArray();
-    }
-
-    private static GrammarCache getGrammarCache() {
-        short go = GrammarOptions.DEFAULT_OPTIONS;
-
-        // This option on or off, nagasena still fails
-//        go = GrammarOptions.addNS(go);
-
-        return new GrammarCache(null, go);
-    }
-
-    public static Document decodeEXI(final byte[] input) throws Exception {
-
-        final GrammarCache grammarCache;
-        final DOMResult domResult = new DOMResult();
-
-        try(ByteArrayInputStream in = new ByteArrayInputStream(input)) {
-
-            final EXIReader reader = new EXIReader();
-
-            reader.setAlignmentType(ALIGNMENT_TYPE);
-            grammarCache = getGrammarCache();
-
-            reader.setGrammarCache(grammarCache);
-
-            final SAXTransformerFactory transformerFactory
-                    = (SAXTransformerFactory) TransformerFactory.newInstance();
-            final TransformerHandler handler = transformerFactory.newTransformerHandler();
-            handler.setResult(domResult);
-
-            reader.setContentHandler(handler);
-
-            reader.parse(new InputSource(in));
-        }
-
-        return (Document) domResult.getNode();
-    }
-
-    public static Element getDom() {
-        final Element dom;
-
-        final Document d = newDocument();
-
-        dom = d.createElement("rpc");
-        dom.setAttribute("xmlns", "a.b.c");
-        dom.setAttribute("message-id", "id");
-        dom.appendChild(d.createElement("inner"));
-
-        return dom;
-    }
-
-    public static Element getDom2() {
-        final Element dom;
-
-        final Document d = newDocument();
-
-        dom = d.createElementNS("a.b.c", "rpc");
-        dom.setAttribute("message-id", "id");
-        dom.appendChild(d.createElement("inner"));
-
-        return dom;
-    }
-
-    private static final DocumentBuilderFactory BUILDERFACTORY;
-
-    static {
-        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        factory.setNamespaceAware(true);
-        factory.setCoalescing(true);
-        factory.setIgnoringElementContentWhitespace(true);
-        factory.setIgnoringComments(true);
-        BUILDERFACTORY = factory;
-    }
-
-    private static Document newDocument() {
-        try {
-            final DocumentBuilder builder = BUILDERFACTORY.newDocumentBuilder();
-            return builder.newDocument();
-        } catch (final ParserConfigurationException e) {
-            throw new RuntimeException("Failed to create document", e);
-        }
-    }
-
-    private static String toString(final Element xml, final boolean addXmlDeclaration) {
-        try {
-            final Transformer transformer = TransformerFactory.newInstance().newTransformer();
-            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, addXmlDeclaration ? "no" : "yes");
-
-            final StreamResult result = new StreamResult(new StringWriter());
-            final DOMSource source = new DOMSource(xml);
-            transformer.transform(source, result);
-
-            return result.getWriter().toString();
-        } catch (IllegalArgumentException | TransformerFactoryConfigurationError | TransformerException e) {
-            throw new RuntimeException("Unable to serialize xml element " + xml, e);
-        }
-    }
-}
similarity index 85%
rename from third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0035.0.jar
rename to third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0038.0.jar
index 060b17152913558da98ab92344e60cb769860d7d..1b6a02710a7b4779a6853a44fbf3c3af72d00667 100644 (file)
Binary files a/third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0035.0.jar and b/third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0038.0.jar differ
index 6beba8c28bc188157c5da5e54a204dc80d9eee6f..98da51aca834e5ef20bc1df25f5b2b1719ac2acd 100644 (file)
@@ -13,7 +13,7 @@
     <parent>
         <groupId>org.opendaylight.controller.thirdparty</groupId>
         <artifactId>org.openexi</artifactId>
     <parent>
         <groupId>org.opendaylight.controller.thirdparty</groupId>
         <artifactId>org.openexi</artifactId>
-        <version>0000.0002.0035.0-SNAPSHOT</version>
+        <version>0000.0002.0038.0-SNAPSHOT</version>
     </parent>
 
     <groupId>org.opendaylight.controller.thirdparty</groupId>
     </parent>
 
     <groupId>org.opendaylight.controller.thirdparty</groupId>
@@ -21,7 +21,7 @@
     <packaging>bundle</packaging>
 
     <properties>
     <packaging>bundle</packaging>
 
     <properties>
-        <archive>nagasena-rta-0000.0002.0035.0.jar</archive>
+        <archive>nagasena-rta-0000.0002.0038.0.jar</archive>
     </properties>
 
     <build>
     </properties>
 
     <build>
similarity index 80%
rename from third-party/org.openexi/nagasena/nagasena-0000.0002.0035.0.jar
rename to third-party/org.openexi/nagasena/nagasena-0000.0002.0038.0.jar
index c566f27d8335e22ea9649b0fcfabb5363482c3a7..ffc28ead4b0f59ae0e7174b8274e386cb7923c1d 100644 (file)
Binary files a/third-party/org.openexi/nagasena/nagasena-0000.0002.0035.0.jar and b/third-party/org.openexi/nagasena/nagasena-0000.0002.0038.0.jar differ
index 297f15f201224f7bae1e75fe5659028f78c0361c..a890431ca652c3220c260b4365ec55c6b5d562b2 100644 (file)
@@ -13,7 +13,7 @@
     <parent>
         <groupId>org.opendaylight.controller.thirdparty</groupId>
         <artifactId>org.openexi</artifactId>
     <parent>
         <groupId>org.opendaylight.controller.thirdparty</groupId>
         <artifactId>org.openexi</artifactId>
-        <version>0000.0002.0035.0-SNAPSHOT</version>
+        <version>0000.0002.0038.0-SNAPSHOT</version>
     </parent>
 
     <groupId>org.opendaylight.controller.thirdparty</groupId>
     </parent>
 
     <groupId>org.opendaylight.controller.thirdparty</groupId>
@@ -21,7 +21,7 @@
     <packaging>bundle</packaging>
 
     <properties>
     <packaging>bundle</packaging>
 
     <properties>
-        <archive>nagasena-0000.0002.0035.0.jar</archive>
+        <archive>nagasena-0000.0002.0038.0.jar</archive>
     </properties>
 
     <build>
     </properties>
 
     <build>
index d623ef8cdc614e90edb0254872eb2039e37f6641..6369b294ba47688b45b9b5655e068fbe7a644760 100644 (file)
@@ -19,7 +19,7 @@
 
     <groupId>org.opendaylight.controller.thirdparty</groupId>
     <artifactId>org.openexi</artifactId>
 
     <groupId>org.opendaylight.controller.thirdparty</groupId>
     <artifactId>org.openexi</artifactId>
-    <version>0000.0002.0035.0-SNAPSHOT</version>
+    <version>0000.0002.0038.0-SNAPSHOT</version>
     <packaging>pom</packaging>
     <prerequisites>
         <maven>3.0.4</maven>
     <packaging>pom</packaging>
     <prerequisites>
         <maven>3.0.4</maven>