Merge changes I20578f97,I629c909b,I54f04c99,I9c1e3a28,Ie681c8c5
authorTomas Cere <tcere@cisco.com>
Tue, 16 Aug 2016 16:06:07 +0000 (16:06 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 16 Aug 2016 16:06:07 +0000 (16:06 +0000)
* changes:
  Bug 6325 - Fix for draft15 update
  Bug 6325 - upgrade draft11 to draft15 - added timestamp & etag
  Bug 6325 - upgrade draft11 to draft15 - change get modules
  Bug 6325 - upgrade draft11 to draft15 - change media types
  Bug 6325 - upgrade draft11 to draft15 - renaming

55 files changed:
restconf/sal-rest-connector/src/main/java/org/opendaylight/RestconfWrapperProviders.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYinBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/api/Draft02.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/AbstractIdentifierAwareJaxRsProvider.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonNormalizedNodeBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPATCHBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeJsonBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeXmlBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/PATCHJsonBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/PATCHXmlBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPATCHBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/Draft15.java [moved from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/Draft11.java with 86% similarity]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/RestConnectorProvider.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/RestconfApplication.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/references/SchemaContextRef.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/wrapper/services/Draft15ServicesWrapperImpl.java [moved from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/common/wrapper/services/Draft11ServicesWrapperImpl.java with 91% similarity]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/Handler.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/TransactionChainHandler.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/api/Draft15BaseServicesWrapper.java [moved from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/api/Draft11BaseServicesWrapper.java with 94% similarity]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/api/RestconfModulesService.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/api/RestconfOperationsService.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/api/RestconfSchemaService.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/api/RestconfStreamsService.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceImpl.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceImpl.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/services/api/Draft15TransactionServicesWrapper.java [moved from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/services/api/Draft11TransactionServicesWrapper.java with 92% similarity]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/services/api/RestconfDataService.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/services/api/RestconfInvokeOperationsService.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/services/impl/RestconfDataServiceImpl.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/transaction/TransactionVarsWrapper.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/utils/DeleteDataTransactionUtil.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/utils/PatchDataTransactionUtil.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/utils/PostDataTransactionUtil.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/utils/PutDataTransactionUtil.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/utils/ReadDataTransactionUtil.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/utils/TransactionUtil.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/mapping/RestconfMappingNodeUtil.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/patch/Draft15AbstractIdentifierAwareJaxRsProvider.java [moved from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/patch/Draft11AbstractIdentifierAwareJaxRsProvider.java with 95% similarity]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/patch/Draft15JsonToPATCHBodyReader.java [moved from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/patch/Draft11JsonToPATCHBodyReader.java with 96% similarity]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/patch/Draft15StringModuleInstanceIdentifierCodec.java [moved from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/patch/Draft11StringModuleInstanceIdentifierCodec.java with 91% similarity]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/patch/Draft15XmlToPATCHBodyReader.java [moved from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/patch/Draft11XmlToPATCHBodyReader.java with 97% similarity]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/schema/context/RestconfSchemaUtil.java
restconf/sal-rest-connector/src/main/resources/WEB-INF/web.xml
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/Draft11AbstractBodyReaderTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestDraft11JsonPATCHBodyReader.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestDraft11XmlPATCHBodyReader.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/RestConnectorProviderTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceTestUtils.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/utils/DeleteDataTransactionUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/mapping/RestconfMappingNodeUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/schema/context/RestconfSchemaUtilTest.java

index 308b144e97c7b4aa45c8727d295f8ceef2db518f..98ab9a1173b61064b6a9d1b1533ab9835e8e0758 100644 (file)
@@ -16,21 +16,21 @@ import org.opendaylight.restconf.RestConnectorProvider;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 
 /**
- * Wrapping providers from restconf draft02 and draft11.
+ * Wrapping providers from restconf draft02 and draft15.
  *
  */
 public class RestconfWrapperProviders implements AutoCloseable, RestConnector {
 
     // DRAFT02
     private final RestconfProviderImpl providerDraft02;
-    // DRAFT11
-    private final RestConnectorProvider providerDraft11;
+    // DRAFT15
+    private final RestConnectorProvider providerDraft15;
 
     /**
      * Init both providers:
      * <ul>
      * <li>draft02 - {@link RestconfProviderImpl}
-     * <li>draft11 - {@link RestConnectorProvider}
+     * <li>draft15 - {@link RestConnectorProvider}
      * </ul>
      *
      * @param port
@@ -41,15 +41,14 @@ public class RestconfWrapperProviders implements AutoCloseable, RestConnector {
         this.providerDraft02 = new RestconfProviderImpl();
         this.providerDraft02.setWebsocketPort(port);
 
-        // Init draft11 provider
-        this.providerDraft11 = new RestConnectorProvider();
+        this.providerDraft15 = new RestConnectorProvider();
     }
 
     /**
      * Register both providers, which will use the SAL layer:
      * <ul>
      * <li>draft02 - {@link RestconfProviderImpl}
-     * <li>draft11 - {@link RestConnectorProvider}
+     * <li>draft15 - {@link RestConnectorProvider}
      * </ul>
      *
      * @param broker
@@ -59,8 +58,8 @@ public class RestconfWrapperProviders implements AutoCloseable, RestConnector {
         // Register draft02 provider
         broker.registerProvider(this.providerDraft02);
 
-        // Register draft11 provider
-        broker.registerProvider(this.providerDraft11);
+        // Register draft15 provider
+        broker.registerProvider(this.providerDraft15);
     }
 
     /**
@@ -78,7 +77,7 @@ public class RestconfWrapperProviders implements AutoCloseable, RestConnector {
     @Override
     public void close() throws Exception {
         this.providerDraft02.close();
-        this.providerDraft11.close();
+        this.providerDraft15.close();
     }
 
 }
index d6fb46010018a5ca3414410d360a50b13a97698c..699c3a1828374f11e2274c235d1c0c83a23b257b 100644 (file)
@@ -18,10 +18,10 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 
 @Provider
-@Produces({ SchemaRetrievalService.YANG_MEDIA_TYPE, Draft11.MediaTypes.YANG })
+@Produces({ SchemaRetrievalService.YANG_MEDIA_TYPE, Draft15.MediaTypes.YANG })
 public class SchemaExportContentYangBodyWriter implements MessageBodyWriter<SchemaExportContext> {
 
     @Override
index 2dabce3b718f7d3fbf768ed3b4c104b1a615f5e0..ef6e2cc0cf1e25ee1a60377df9cce2693d560f1f 100644 (file)
@@ -18,12 +18,12 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 import javax.xml.stream.XMLStreamException;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.model.export.YinExportUtils;
 
 @Provider
-@Produces({ SchemaRetrievalService.YIN_MEDIA_TYPE, Draft11.MediaTypes.YIN + RestconfConstants.XML })
+@Produces({ SchemaRetrievalService.YIN_MEDIA_TYPE, Draft15.MediaTypes.YIN + RestconfConstants.XML })
 public class SchemaExportContentYinBodyWriter implements MessageBodyWriter<SchemaExportContext> {
 
     @Override
index 3b3882d3ae27f8ba0ce03975e9065ae6d8ad1dc4..0b2839b3a7a48ce3c51e6a8828997708926f7919 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.netconf.sal.rest.api;
 
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.yangtools.yang.common.QName;
 
 /**
  * @deprecated Do not use old implementation of restconf draft. It will be
- *             replaced by {@link Draft11}.
+ *             replaced by {@link Draft15}.
  *
  */
 @Deprecated
index 84aea20d74cc15afeb1cc710469ab5b956eb50cf..60997f78420e78d6951adcfd34be767c4ac54346 100644 (file)
@@ -14,11 +14,11 @@ import javax.ws.rs.core.UriInfo;
 import org.opendaylight.netconf.sal.rest.api.RestconfConstants;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
-import org.opendaylight.restconf.utils.patch.Draft11AbstractIdentifierAwareJaxRsProvider;
+import org.opendaylight.restconf.utils.patch.Draft15AbstractIdentifierAwareJaxRsProvider;
 
 /**
  * @deprecated This class will be replaced by
- * {@link Draft11AbstractIdentifierAwareJaxRsProvider}
+ * {@link Draft15AbstractIdentifierAwareJaxRsProvider}
  */
 @Deprecated
 public class AbstractIdentifierAwareJaxRsProvider {
index 2195dc21ae3f0fe021b2f457854b938daab7e58e..fd2b14102a7315ae6069567056303b4d82f557de 100644 (file)
@@ -30,7 +30,7 @@ import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
@@ -52,9 +52,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Provider
-@Consumes({ Draft02.MediaTypes.DATA + RestconfService.JSON, Draft11.MediaTypes.DATA + RestconfConstants.JSON,
-        Draft02.MediaTypes.OPERATION + RestconfService.JSON, Draft11.MediaTypes.OPERATION + RestconfConstants.JSON,
-        MediaType.APPLICATION_JSON })
+@Consumes({ Draft02.MediaTypes.DATA + RestconfService.JSON, Draft02.MediaTypes.OPERATION + RestconfService.JSON,
+        Draft15.MediaTypes.DATA + RestconfConstants.JSON, MediaType.APPLICATION_JSON })
 public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsProvider implements MessageBodyReader<NormalizedNodeContext> {
 
     private final static Logger LOG = LoggerFactory.getLogger(JsonNormalizedNodeBodyReader.class);
index a9aa44c2c9f8c414af69564d850127e62be406ea..112f1c2b5dc029dad70eef3353ff062353d91004 100644 (file)
@@ -37,7 +37,7 @@ import org.opendaylight.netconf.sal.restconf.impl.PATCHEntity;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.utils.patch.Draft11JsonToPATCHBodyReader;
+import org.opendaylight.restconf.utils.patch.Draft15JsonToPATCHBodyReader;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -52,7 +52,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * @deprecated This class will be replaced by {@link Draft11JsonToPATCHBodyReader}
+ * @deprecated This class will be replaced by {@link Draft15JsonToPATCHBodyReader}
  */
 @Deprecated
 @Provider
index 09c4b724c2a8f235563cda66d0fd8461a92ff751..b262758fc71b33cac7fd53b6107b1487b8d21e32 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.netconf.sal.rest.api.RestconfNormalizedNodeWriter;
 import org.opendaylight.netconf.sal.rest.api.RestconfService;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -47,9 +47,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 @Provider
 @Produces({ Draft02.MediaTypes.API + RestconfService.JSON, Draft02.MediaTypes.DATA + RestconfService.JSON,
-        Draft02.MediaTypes.OPERATION + RestconfService.JSON,
-        Draft11.MediaTypes.API + RestconfConstants.JSON, Draft11.MediaTypes.DATA + RestconfConstants.JSON,
-        Draft11.MediaTypes.OPERATION + RestconfConstants.JSON, MediaType.APPLICATION_JSON })
+        Draft02.MediaTypes.OPERATION + RestconfService.JSON, Draft15.MediaTypes.DATA + RestconfConstants.JSON,
+        MediaType.APPLICATION_JSON })
 public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<NormalizedNodeContext> {
 
     private static final int DEFAULT_INDENT_SPACES_NUM = 2;
index 41417f93d0697f03bed455303546fd716f9c237b..576ea8f82acd3c998944698445882a199b570516 100644 (file)
@@ -30,8 +30,7 @@ import org.opendaylight.netconf.sal.rest.api.RestconfNormalizedNodeWriter;
 import org.opendaylight.netconf.sal.rest.api.RestconfService;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.restconf.Draft11;
-import org.opendaylight.restconf.utils.RestconfConstants;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@@ -45,9 +44,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 @Provider
 @Produces({ Draft02.MediaTypes.API + RestconfService.XML, Draft02.MediaTypes.DATA + RestconfService.XML,
-        Draft02.MediaTypes.OPERATION + RestconfService.XML,
-        Draft11.MediaTypes.API + RestconfConstants.XML, Draft11.MediaTypes.DATA + RestconfConstants.XML,
-        Draft11.MediaTypes.OPERATION + RestconfConstants.XML, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+        Draft02.MediaTypes.OPERATION + RestconfService.XML, Draft15.MediaTypes.DATA, MediaType.APPLICATION_XML,
+        MediaType.TEXT_XML })
 public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter<NormalizedNodeContext> {
 
     private static final XMLOutputFactory XML_FACTORY;
index 21e2b870452dbe80f44d6d729bfa4a866d02d839..b5a87966e483e5afc942d9e2b3321bfbefd2f62f 100644 (file)
@@ -27,14 +27,14 @@ import org.opendaylight.netconf.sal.rest.api.RestconfService;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusEntity;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory;
 
 
 @Provider
 @Produces({Draft02.MediaTypes.PATCH_STATUS + RestconfService.JSON,
-        Draft11.MediaTypes.PATCH_STATUS + RestconfConstants.JSON})
+        Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.JSON})
 public class PATCHJsonBodyWriter implements MessageBodyWriter<PATCHStatusContext> {
 
     @Override
index a4ac36178cccca6280977e4b01f6384a6ab7b4b8..d0ae879d69ada24b43aae47afd32c113882b9bfe 100644 (file)
@@ -28,12 +28,12 @@ import org.opendaylight.netconf.sal.rest.api.RestconfService;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusEntity;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 
 @Provider
 @Produces({Draft02.MediaTypes.PATCH_STATUS + RestconfService.XML,
-        Draft11.MediaTypes.PATCH_STATUS + RestconfConstants.XML})
+        Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.XML})
 public class PATCHXmlBodyWriter implements MessageBodyWriter<PATCHStatusContext> {
 
     private static final XMLOutputFactory XML_FACTORY;
index 72ec47d3b9839b505dec5904c35451608081a3ed..97867111a7b10602bccf1b2a99e05424da9f2dc8 100644 (file)
@@ -34,8 +34,7 @@ import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft11;
-import org.opendaylight.restconf.utils.RestconfConstants;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlUtils;
@@ -57,9 +56,8 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 @Provider
-@Consumes({ Draft02.MediaTypes.DATA + RestconfService.XML, Draft11.MediaTypes.DATA + RestconfConstants.XML,
-        Draft02.MediaTypes.OPERATION + RestconfService.XML, Draft11.MediaTypes.OPERATION + RestconfConstants.XML,
-    MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+@Consumes({ Draft02.MediaTypes.DATA + RestconfService.XML, Draft02.MediaTypes.OPERATION + RestconfService.XML,
+        Draft15.MediaTypes.DATA, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
 public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsProvider implements MessageBodyReader<NormalizedNodeContext> {
 
     private final static Logger LOG = LoggerFactory.getLogger(XmlNormalizedNodeBodyReader.class);
index eb12029af965d7c11d362c19f24739c7fdab5e4f..dd2bf8b1cf9ae1630ab0c0d5b6ff4a5608a07b65 100644 (file)
@@ -37,7 +37,7 @@ import org.opendaylight.netconf.sal.restconf.impl.PATCHEntity;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.utils.patch.Draft11XmlToPATCHBodyReader;
+import org.opendaylight.restconf.utils.patch.Draft15XmlToPATCHBodyReader;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -59,7 +59,7 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 /**
- * @deprecated This class will be replaced by {@link Draft11XmlToPATCHBodyReader}
+ * @deprecated This class will be replaced by {@link Draft15XmlToPATCHBodyReader}
  */
 @Deprecated
 @Provider
similarity index 86%
rename from restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/Draft11.java
rename to restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/Draft15.java
index dabb74e211b667a92f3d6d2fb05f57240fd19ec1..885229515cb589fdc720ef2e4c5e1a6096bc0301 100644 (file)
@@ -20,13 +20,13 @@ import org.opendaylight.yangtools.yang.common.QName;
  * </ul>
  * </ul>
  *
- * We used old revision {@link Draft11.RestconfModule#REVISION} of restconf yang
+ * We used old revision {@link Draft15.RestconfModule#REVISION} of restconf yang
  * because the latest restconf draft has to be supported by Yang 1.1 and we are
  * not. Then, this is only partial implementation of the latest restconf draft.
  */
-public final class Draft11 {
+public final class Draft15 {
 
-    private Draft11() {
+    private Draft15() {
         throw new UnsupportedOperationException("Util class");
     }
 
@@ -40,13 +40,9 @@ public final class Draft11 {
             throw new UnsupportedOperationException("Util class");
         }
 
-        public static final String API = "application/yang.api";
-        public static final String DATASTORE = "application/yang.datastore";
-        public static final String DATA = "application/yang.data";
-        public static final String OPERATION = "application/yang.operation";
+        public static final String DATA = "application/yang-data";
         public static final String PATCH = "application/yang.patch";
         public static final String PATCH_STATUS = "application/yang.patch-status";
-        public static final String ERRORS = "application/yang.errors";
         public static final String YIN = "application/yin";
         public static final String YANG = "application/yang";
     }
@@ -83,8 +79,8 @@ public final class Draft11 {
 
         public static final String ERROR_LIST_SCHEMA_NODE = "error";
 
-        public static final QName IETF_RESTCONF_QNAME = QName.create(Draft11.RestconfModule.NAMESPACE, Draft11.RestconfModule.REVISION,
-                Draft11.RestconfModule.NAME);
+        public static final QName IETF_RESTCONF_QNAME = QName.create(Draft15.RestconfModule.NAMESPACE, Draft15.RestconfModule.REVISION,
+                Draft15.RestconfModule.NAME);
 
         public static final QName ERRORS_CONTAINER_QNAME = QName.create(IETF_RESTCONF_QNAME, ERRORS_CONTAINER_SCHEMA_NODE);
 
index 5ce439ca73ccbd97c4f462bc2c6463c32836d5db..8205eba6adfcfa0604de47b3c756fd2e28ea437d 100644 (file)
@@ -5,6 +5,7 @@
  * 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.restconf;
 
 import com.google.common.base.Preconditions;
@@ -16,13 +17,12 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListen
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 import org.opendaylight.controller.sal.core.api.Provider;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.netconf.sal.rest.api.RestConnector;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
-import org.opendaylight.restconf.common.wrapper.services.Draft11ServicesWrapperImpl;
+import org.opendaylight.restconf.common.wrapper.services.Draft15ServicesWrapperImpl;
 import org.opendaylight.restconf.handlers.DOMDataBrokerHandler;
 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.handlers.RpcServiceHandler;
@@ -34,19 +34,18 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Provider for restconf draft11.
+ * Provider for restconf draft15.
  *
  */
 public class RestConnectorProvider implements Provider, RestConnector, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(RestConnectorProvider.class);
 
-    private final TransactionChainListener transactionListener = new TransactionChainListener() {
+    public static final TransactionChainListener transactionListener = new TransactionChainListener() {
         @Override
         public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
                 final AsyncTransaction<?, ?> transaction, final Throwable cause) {
             LOG.warn("TransactionChain({}) {} FAILED!", chain, transaction.getIdentifier(), cause);
-            chain.close();
             resetTransactionChainForAdapaters(chain);
             throw new RestconfDocumentedException("TransactionChain(" + chain + ") not committed correctly", cause);
         }
@@ -58,14 +57,14 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
     };
 
     private ListenerRegistration<SchemaContextListener> listenerRegistration;
-    private DOMDataBroker dataBroker;
-    private DOMTransactionChain transactionChain;
+    private static TransactionChainHandler transactionChainHandler;
+    private static DOMDataBroker dataBroker;
 
     @Override
     public void onSessionInitiated(final ProviderSession session) {
         final SchemaService schemaService = Preconditions.checkNotNull(session.getService(SchemaService.class));
 
-        final Draft11ServicesWrapperImpl wrapperServices = Draft11ServicesWrapperImpl.getInstance();
+        final Draft15ServicesWrapperImpl wrapperServices = Draft15ServicesWrapperImpl.getInstance();
 
         final SchemaContextHandler schemaCtxHandler = new SchemaContextHandler();
         this.listenerRegistration = schemaService.registerSchemaContextListener(schemaCtxHandler);
@@ -73,30 +72,32 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
         final DOMMountPointServiceHandler domMountPointServiceHandler = new DOMMountPointServiceHandler(
                 session.getService(DOMMountPointService.class));
 
-        this.dataBroker = session.getService(DOMDataBroker.class);
-        final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(this.dataBroker);
+        RestConnectorProvider.dataBroker = session.getService(DOMDataBroker.class);
+        final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(RestConnectorProvider.dataBroker);
 
-        this.transactionChain = this.dataBroker.createTransactionChain(this.transactionListener);
-        final TransactionChainHandler transactionChainHandler = new TransactionChainHandler(this.transactionChain);
+        RestConnectorProvider.transactionChainHandler = new TransactionChainHandler(RestConnectorProvider.dataBroker
+                .createTransactionChain(RestConnectorProvider.transactionListener));
 
         final DOMRpcService rpcService = session.getService(DOMRpcService.class);
         final RpcServiceHandler rpcServiceHandler = new RpcServiceHandler(rpcService);
 
-        wrapperServices.setHandlers(schemaCtxHandler, domMountPointServiceHandler, transactionChainHandler,
-                brokerHandler, rpcServiceHandler);
+        wrapperServices.setHandlers(schemaCtxHandler, domMountPointServiceHandler,
+                RestConnectorProvider.transactionChainHandler, brokerHandler, rpcServiceHandler);
     }
 
     /**
-     * After {@link TransactionChain} failed, this is creating new transaction
-     * with listener.
+     * After {@link TransactionChain} failed, this updates {@link TransactionChainHandler} with new transaction chain.
      *
      * @param chain
      *            - old {@link TransactionChain}
      */
-    private void resetTransactionChainForAdapaters(final TransactionChain<?, ?> chain) {
-        LOG.trace("Resetting TransactionChain({}) to {}", chain, this.transactionChain);
-        this.transactionChain = Preconditions.checkNotNull(this.dataBroker)
-                .createTransactionChain(this.transactionListener);
+    public static void resetTransactionChainForAdapaters(final TransactionChain<?, ?> chain) {
+        LOG.trace("Resetting TransactionChain({})", chain);
+        chain.close();
+        RestConnectorProvider.transactionChainHandler.update(
+                Preconditions.checkNotNull(RestConnectorProvider.dataBroker).createTransactionChain(
+                        RestConnectorProvider.transactionListener)
+        );
     }
 
     @Override
@@ -106,11 +107,14 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
 
     @Override
     public void close() throws Exception {
+        // close registration
         if (this.listenerRegistration != null) {
             this.listenerRegistration.close();
         }
-        if (this.transactionChain != null) {
-            this.transactionChain.close();
+
+        // close transaction chain
+        if (RestConnectorProvider.transactionChainHandler != null) {
+            RestConnectorProvider.transactionChainHandler.get().close();
         }
     }
 }
index 4a2886915707719a49ca74f23d7e08013a2bb5e0..c00cd4cd08291b260902f73f027ddc259bee99cb 100644 (file)
@@ -20,9 +20,9 @@ import org.opendaylight.netconf.sal.rest.impl.PATCHJsonBodyWriter;
 import org.opendaylight.netconf.sal.rest.impl.PATCHXmlBodyWriter;
 import org.opendaylight.netconf.sal.rest.impl.RestconfDocumentedExceptionMapper;
 import org.opendaylight.netconf.sal.rest.impl.XmlNormalizedNodeBodyReader;
-import org.opendaylight.restconf.common.wrapper.services.Draft11ServicesWrapperImpl;
-import org.opendaylight.restconf.utils.patch.Draft11JsonToPATCHBodyReader;
-import org.opendaylight.restconf.utils.patch.Draft11XmlToPATCHBodyReader;
+import org.opendaylight.restconf.common.wrapper.services.Draft15ServicesWrapperImpl;
+import org.opendaylight.restconf.utils.patch.Draft15JsonToPATCHBodyReader;
+import org.opendaylight.restconf.utils.patch.Draft15XmlToPATCHBodyReader;
 
 public class RestconfApplication extends Application {
 
@@ -31,7 +31,7 @@ public class RestconfApplication extends Application {
         return ImmutableSet.<Class<?>> builder().add(NormalizedNodeJsonBodyWriter.class)
                 .add(NormalizedNodeXmlBodyWriter.class).add(JsonNormalizedNodeBodyReader.class)
                 .add(XmlNormalizedNodeBodyReader.class).add(SchemaExportContentYinBodyWriter.class)
-                .add(Draft11JsonToPATCHBodyReader.class).add(Draft11XmlToPATCHBodyReader.class)
+                .add(Draft15JsonToPATCHBodyReader.class).add(Draft15XmlToPATCHBodyReader.class)
                 .add(PATCHJsonBodyWriter.class).add(PATCHXmlBodyWriter.class)
                 .add(SchemaExportContentYangBodyWriter.class).add(RestconfDocumentedExceptionMapper.class)
                 .build();
@@ -40,7 +40,7 @@ public class RestconfApplication extends Application {
     @Override
     public Set<Object> getSingletons() {
         final Set<Object> singletons = new HashSet<>();
-        singletons.add(Draft11ServicesWrapperImpl.getInstance());
+        singletons.add(Draft15ServicesWrapperImpl.getInstance());
         return singletons;
     }
 }
index c15ffa3865e63d47b3a6e1adf7f6495002d519e2..84fb1bd8246db8bab2608044b14521c7a26af016 100644 (file)
@@ -12,7 +12,7 @@ import java.net.URI;
 import java.util.Date;
 import java.util.Set;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -73,13 +73,13 @@ public final class SchemaContextRef {
 
     /**
      * Get {@link Module} by ietf-restconf qname from
-     * {@link Draft11.RestconfModule}
+     * {@link Draft15.RestconfModule}
      *
      * @return {@link Module}
      */
     public Module getRestconfModule() {
-        return this.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME.getNamespace(),
-                Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
+        return this.findModuleByNamespaceAndRevision(Draft15.RestconfModule.IETF_RESTCONF_QNAME.getNamespace(),
+                Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
     }
 
     /**
@@ -19,7 +19,7 @@ import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.handlers.RpcServiceHandler;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.rest.services.api.Draft11BaseServicesWrapper;
+import org.opendaylight.restconf.rest.services.api.Draft15BaseServicesWrapper;
 import org.opendaylight.restconf.rest.services.api.RestconfModulesService;
 import org.opendaylight.restconf.rest.services.api.RestconfOperationsService;
 import org.opendaylight.restconf.rest.services.api.RestconfSchemaService;
@@ -28,7 +28,7 @@ import org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceImpl;
 import org.opendaylight.restconf.rest.services.impl.RestconfOperationsServiceImpl;
 import org.opendaylight.restconf.rest.services.impl.RestconfSchemaServiceImpl;
 import org.opendaylight.restconf.rest.services.impl.RestconfStreamsServiceImpl;
-import org.opendaylight.restconf.restful.services.api.Draft11TransactionServicesWrapper;
+import org.opendaylight.restconf.restful.services.api.Draft15TransactionServicesWrapper;
 import org.opendaylight.restconf.restful.services.api.RestconfDataService;
 import org.opendaylight.restconf.restful.services.api.RestconfInvokeOperationsService;
 import org.opendaylight.restconf.restful.services.api.RestconfStreamsSubscriptionService;
@@ -39,13 +39,13 @@ import org.opendaylight.restconf.restful.services.impl.RestconfStreamsSubscripti
 /**
  * Wrapper for services:
  * <ul>
- * <li>{@link Draft11BaseServicesWrapper}
- * <li>{@link Draft11TransactionServicesWrapper}
+ * <li>{@link Draft15BaseServicesWrapper}
+ * <li>{@link Draft15TransactionServicesWrapper}
  * </ul>
  *
  */
 @Path("/")
-public class Draft11ServicesWrapperImpl implements Draft11BaseServicesWrapper, Draft11TransactionServicesWrapper {
+public class Draft15ServicesWrapperImpl implements Draft15BaseServicesWrapper, Draft15TransactionServicesWrapper {
 
     private RestconfDataService delegRestconfDataService;
     private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
@@ -55,14 +55,14 @@ public class Draft11ServicesWrapperImpl implements Draft11BaseServicesWrapper, D
     private RestconfStreamsService delegRestStrsService;
     private RestconfSchemaService delegRestSchService;
 
-    private Draft11ServicesWrapperImpl() {
+    private Draft15ServicesWrapperImpl() {
     }
 
     private static class InstanceHolder {
-        public static final Draft11ServicesWrapperImpl INSTANCE = new Draft11ServicesWrapperImpl();
+        public static final Draft15ServicesWrapperImpl INSTANCE = new Draft15ServicesWrapperImpl();
     }
 
-    public static Draft11ServicesWrapperImpl getInstance() {
+    public static Draft15ServicesWrapperImpl getInstance() {
         return InstanceHolder.INSTANCE;
     }
 
@@ -102,7 +102,7 @@ public class Draft11ServicesWrapperImpl implements Draft11BaseServicesWrapper, D
     }
 
     @Override
-    public NormalizedNodeContext readData(final String identifier, final UriInfo uriInfo) {
+    public Response readData(final String identifier, final UriInfo uriInfo) {
         return this.delegRestconfDataService.readData(identifier, uriInfo);
     }
 
index 69c2276e13179280206cbcbde0fceddfbfa8e650..ceece0ffdd88faae2d75ea288cd367be2d917136 100644 (file)
@@ -5,9 +5,8 @@
  * 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.restconf.handlers;
 
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+package org.opendaylight.restconf.handlers;
 
 /**
  * Handler for handling object prepared by provider for Restconf services
@@ -20,7 +19,15 @@ interface Handler<T> {
     /**
      * Get prepared object
      *
-     * @return {@link DOMTransactionChain}
+     * @return T
      */
     T get();
+
+    /**
+     * Update object
+     *
+     * @param object
+     *            - new object to update old object
+     */
+    default void update(T object) {}
 }
index 450a8ed2b6607cd19446c096d21964cf054799ae..7cceef1dcd170e4332f43fbb06bd3874579fad0b 100644 (file)
@@ -5,6 +5,7 @@
  * 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.restconf.handlers;
 
 import com.google.common.base.Preconditions;
@@ -17,7 +18,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
  */
 public class TransactionChainHandler implements Handler<DOMTransactionChain> {
 
-    private final DOMTransactionChain transactionChain;
+    private DOMTransactionChain transactionChain;
 
     /**
      * Prepare transaction chain service for Restconf services
@@ -29,6 +30,12 @@ public class TransactionChainHandler implements Handler<DOMTransactionChain> {
         this.transactionChain = transactionChain;
     }
 
+    @Override
+    public void update(final DOMTransactionChain transactionChain) {
+        Preconditions.checkNotNull(transactionChain);
+        this.transactionChain = transactionChain;
+    }
+
     @Override
     public DOMTransactionChain get() {
         return this.transactionChain;
@@ -17,6 +17,6 @@ package org.opendaylight.restconf.rest.services.api;
  * </ul>
  *
  */
-public interface Draft11BaseServicesWrapper
+public interface Draft15BaseServicesWrapper
         extends RestconfModulesService, RestconfOperationsService, RestconfStreamsService, RestconfSchemaService {
 }
index efc41ab2d9b0e0c4eb2df82279ff84931a9904a5..5715ebf49b53019ce33ecb0d6f3a81bf2a82cfba 100644 (file)
@@ -15,7 +15,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 
 /**
@@ -31,9 +31,9 @@ public interface RestconfModulesService {
      * @return {@link NormalizedNodeContext}
      */
     @GET
-    @Path("data/ietf-yang-library:modules")
-    @Produces({ Draft11.MediaTypes.API + RestconfConstants.JSON, Draft11.MediaTypes.API + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Path("data/ietf-yang-library:modules-state")
+    @Produces({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     public NormalizedNodeContext getModules(@Context UriInfo uriInfo);
 
     /**
@@ -47,9 +47,9 @@ public interface RestconfModulesService {
      * @return {@link NormalizedNodeContext}
      */
     @GET
-    @Path("data/ietf-yang-library:modules/{identifier:.+}")
-    @Produces({ Draft11.MediaTypes.API + RestconfConstants.JSON, Draft11.MediaTypes.API + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Path("data/ietf-yang-library:modules-state/{identifier:.+}")
+    @Produces({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     public NormalizedNodeContext getModules(@PathParam("identifier") String identifier, @Context UriInfo uriInfo);
 
     /**
@@ -64,8 +64,8 @@ public interface RestconfModulesService {
      * @return {@link NormalizedNodeContext}
      */
     @GET
-    @Path("data/ietf-yang-library:modules/module/{identifier:.+}")
-    @Produces({ Draft11.MediaTypes.API + RestconfConstants.JSON, Draft11.MediaTypes.API + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Path("data/ietf-yang-library:modules-state/module/{identifier:.+}")
+    @Produces({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     public NormalizedNodeContext getModule(@PathParam("identifier") String identifier, @Context UriInfo uriInfo);
 }
\ No newline at end of file
index b6c065dfa63c4b48208f5def4d5dc3823b20083c..e9726d4a5fa2d89c73e6726696590dff4fd06506 100644 (file)
@@ -15,7 +15,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 
 /**
@@ -34,8 +34,8 @@ public interface RestconfOperationsService {
      */
     @GET
     @Path("/operations")
-    @Produces({ Draft11.MediaTypes.API + RestconfConstants.JSON, Draft11.MediaTypes.API + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Produces({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     public NormalizedNodeContext getOperations(@Context UriInfo uriInfo);
 
     /**
@@ -49,7 +49,7 @@ public interface RestconfOperationsService {
      */
     @GET
     @Path("/operations/{identifier:.+}")
-    @Produces({ Draft11.MediaTypes.API + RestconfConstants.JSON, Draft11.MediaTypes.API + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Produces({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     public NormalizedNodeContext getOperations(@PathParam("identifier") String identifier, @Context UriInfo uriInfo);
 }
\ No newline at end of file
index f23411e04d770f666bdc600c93eff9bfa26b1f1c..071cb9123f12f4bb8853027477c1d01c78156419 100644 (file)
@@ -12,7 +12,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 
 /**
@@ -30,7 +30,7 @@ public interface RestconfSchemaService {
      * @return {@link SchemaExportContext}
      */
     @GET
-    @Produces({ Draft11.MediaTypes.YANG, Draft11.MediaTypes.YIN + RestconfConstants.XML })
+    @Produces({ Draft15.MediaTypes.YANG, Draft15.MediaTypes.YIN + RestconfConstants.XML })
     @Path("data/ietf-yang-library:modules/module/{identifier:.+}/schema")
     SchemaExportContext getSchema(@PathParam("identifier") String identifier);
 }
index 268d420b9af487809ec3db49139dd3309b10e757..9b385de7d2f9ba55535b0e3771b8ad3543bb4e7f 100644 (file)
@@ -14,7 +14,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 
 /**
@@ -33,7 +33,7 @@ public interface RestconfStreamsService {
      */
     @GET
     @Path("data/ietf-restconf-monitoring:restconf-state/streams")
-    @Produces({ Draft11.MediaTypes.API + RestconfConstants.JSON, Draft11.MediaTypes.API + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Produces({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     public NormalizedNodeContext getAvailableStreams(@Context UriInfo uriInfo);
 }
\ No newline at end of file
index afefd6d45722b1bc80f855e53ee360c6a40a770a..4709f624ebe41eef0e9338a6b7fede07acd9f6bd 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.common.references.SchemaContextRef;
 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
@@ -117,7 +117,7 @@ public class RestconfModulesServiceImpl implements RestconfModulesService {
         final MapNode moduleMap = RestconfMappingNodeUtil
                 .restconfMappingNode(schemaContextRef.getRestconfModule(), modules);
         final DataSchemaNode moduleSchemaNode = RestconfSchemaUtil.getRestconfSchemaNode(
-                schemaContextRef.getRestconfModule(), Draft11.RestconfModule.MODULE_LIST_SCHEMA_NODE);
+                schemaContextRef.getRestconfModule(), Draft15.RestconfModule.MODULE_LIST_SCHEMA_NODE);
         Preconditions.checkState(moduleSchemaNode instanceof ListSchemaNode);
         if (mountPoint == null) {
             return new NormalizedNodeContext(
@@ -148,7 +148,7 @@ public class RestconfModulesServiceImpl implements RestconfModulesService {
 
         final MapNode mapNodes = RestconfMappingNodeUtil.restconfMappingNode(restconfModule, modules);
         final DataSchemaNode schemaNode = RestconfSchemaUtil.getRestconfSchemaNode(restconfModule,
-                Draft11.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE);
+                Draft15.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE);
         Preconditions.checkState(schemaNode instanceof ContainerSchemaNode);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> modulContainerSchemaNodeBuilder = Builders
                 .containerBuilder((ContainerSchemaNode) schemaNode);
index 1346e50142d14f1bf56d10223fab39041a49eaa2..9188bd8d6dd5a72356c44ace08adcd26570079a8 100644 (file)
@@ -13,7 +13,7 @@ import javax.ws.rs.core.UriInfo;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.streams.listeners.Notificator;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.common.references.SchemaContextRef;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
@@ -56,7 +56,7 @@ public class RestconfStreamsServiceImpl implements RestconfStreamsService {
         final Set<String> availableStreams = Notificator.getStreamNames();
 
         final DataSchemaNode streamListSchemaNode = RestconfSchemaUtil.getRestconfSchemaNode(
-                schemaContextRef.getRestconfModule(), Draft11.MonitoringModule.STREAM_LIST_SCHEMA_NODE);
+                schemaContextRef.getRestconfModule(), Draft15.MonitoringModule.STREAM_LIST_SCHEMA_NODE);
         Preconditions.checkState(streamListSchemaNode instanceof ListSchemaNode);
         final CollectionNodeBuilder<MapEntryNode, MapNode> listStreamBuilder = Builders
                 .mapBuilder((ListSchemaNode) streamListSchemaNode);
@@ -66,7 +66,7 @@ public class RestconfStreamsServiceImpl implements RestconfStreamsService {
         }
 
         final DataSchemaNode streamContSchemaNode = RestconfSchemaUtil.getRestconfSchemaNode(
-                schemaContextRef.getRestconfModule(), Draft11.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE);
+                schemaContextRef.getRestconfModule(), Draft15.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE);
         Preconditions.checkState(streamContSchemaNode instanceof ContainerSchemaNode);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> streamsContainerBuilder = Builders
                 .containerBuilder((ContainerSchemaNode) streamContSchemaNode);
index d7ae1f65df41e80c647504a2280072b18021d4e2..f1f3b7e348f7ae07b87b9c074a709b5e73b68de8 100644 (file)
@@ -24,7 +24,7 @@ import org.opendaylight.netconf.sal.rest.impl.PATCH;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 
 /**
@@ -45,9 +45,9 @@ public interface RestconfDataService {
      */
     @GET
     @Path("/data/{identifier:.+}")
-    @Produces({ Draft11.MediaTypes.DATA + RestconfConstants.JSON, Draft11.MediaTypes.DATA + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
-    NormalizedNodeContext readData(@Encoded @PathParam("identifier") String identifier,
+    @Produces({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    Response readData(@Encoded @PathParam("identifier") String identifier,
             @Context UriInfo uriInfo);
 
     /**
@@ -61,8 +61,8 @@ public interface RestconfDataService {
      */
     @PUT
     @Path("/data/{identifier:.+}")
-    @Consumes({ Draft11.MediaTypes.DATA + RestconfConstants.JSON, Draft11.MediaTypes.DATA + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Consumes({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     Response putData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload);
 
     /**
@@ -78,8 +78,8 @@ public interface RestconfDataService {
      */
     @POST
     @Path("/data/{identifier:.+}")
-    @Consumes({ Draft11.MediaTypes.DATA + RestconfConstants.JSON, Draft11.MediaTypes.DATA + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Consumes({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     Response postData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
             @Context UriInfo uriInfo);
 
@@ -94,8 +94,8 @@ public interface RestconfDataService {
      */
     @POST
     @Path("/data")
-    @Consumes({ Draft11.MediaTypes.DATA + RestconfConstants.JSON, Draft11.MediaTypes.DATA + RestconfConstants.XML,
-            MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Consumes({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     Response postData(NormalizedNodeContext payload, @Context UriInfo uriInfo);
 
     /**
@@ -123,9 +123,9 @@ public interface RestconfDataService {
      */
     @PATCH
     @Path("/data/{identifier:.+}")
-    @Consumes({ Draft11.MediaTypes.PATCH + RestconfConstants.JSON, Draft11.MediaTypes.PATCH + RestconfConstants.XML })
-    @Produces({ Draft11.MediaTypes.PATCH_STATUS + RestconfConstants.JSON,
-            Draft11.MediaTypes.PATCH_STATUS + RestconfConstants.XML })
+    @Consumes({ Draft15.MediaTypes.PATCH + RestconfConstants.JSON, Draft15.MediaTypes.PATCH + RestconfConstants.XML })
+    @Produces({ Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.JSON,
+            Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.XML })
     PATCHStatusContext patchData(@Encoded @PathParam("identifier") String identifier, PATCHContext context,
             @Context UriInfo uriInfo);
 
@@ -140,8 +140,8 @@ public interface RestconfDataService {
      */
     @PATCH
     @Path("/data")
-    @Consumes({ Draft11.MediaTypes.PATCH + RestconfConstants.JSON, Draft11.MediaTypes.PATCH + RestconfConstants.XML })
-    @Produces({ Draft11.MediaTypes.PATCH_STATUS + RestconfConstants.JSON,
-            Draft11.MediaTypes.PATCH_STATUS + RestconfConstants.XML })
+    @Consumes({ Draft15.MediaTypes.PATCH + RestconfConstants.JSON, Draft15.MediaTypes.PATCH + RestconfConstants.XML })
+    @Produces({ Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.JSON,
+            Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.XML })
     PATCHStatusContext patchData(PATCHContext context, @Context UriInfo uriInfo);
 }
index 91a45556b9c3fe96bea83185f0fbc1164a174fbd..0cb12ada8ef98ea7d07da08c8e2b93e819e5cfa0 100644 (file)
@@ -17,7 +17,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 
 /**
@@ -41,14 +41,10 @@ public interface RestconfInvokeOperationsService {
      */
     @POST
     @Path("/operations/{identifier:.+}")
-    @Produces({ Draft11.MediaTypes.OPERATION + RestconfConstants.JSON,
-            Draft11.MediaTypes.OPERATION + RestconfConstants.XML, Draft11.MediaTypes.DATA + RestconfConstants.JSON,
-            Draft11.MediaTypes.DATA + RestconfConstants.XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
-            MediaType.TEXT_XML })
-    @Consumes({ Draft11.MediaTypes.OPERATION + RestconfConstants.JSON,
-            Draft11.MediaTypes.OPERATION + RestconfConstants.XML, Draft11.MediaTypes.DATA + RestconfConstants.JSON,
-            Draft11.MediaTypes.DATA + RestconfConstants.XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
-            MediaType.TEXT_XML })
+    @Produces({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
+    @Consumes({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA, MediaType.APPLICATION_JSON,
+            MediaType.APPLICATION_XML, MediaType.TEXT_XML })
     NormalizedNodeContext invokeRpc(@Encoded @PathParam("identifier") String identifier,
             NormalizedNodeContext payload, @Context UriInfo uriInfo);
 }
index a6187f5fa39f022513afaddf85a232315791db74..95645334cbfacc1d6a2876d86bc9c9158fb707ad 100644 (file)
@@ -9,16 +9,20 @@ package org.opendaylight.restconf.restful.services.impl;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.restconf.RestConnectorProvider;
 import org.opendaylight.restconf.common.references.SchemaContextRef;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.handlers.TransactionChainHandler;
@@ -53,25 +57,36 @@ public class RestconfDataServiceImpl implements RestconfDataService {
     }
 
     @Override
-    public NormalizedNodeContext readData(final String identifier, final UriInfo uriInfo) {
+    public Response readData(final String identifier, final UriInfo uriInfo) {
         Preconditions.checkNotNull(identifier);
         final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get());
 
-        final InstanceIdentifierContext<?> instanceIdentifier = ParserIdentifier.toInstanceIdentifier(identifier, schemaContextRef.get());
+        final InstanceIdentifierContext<?> instanceIdentifier = ParserIdentifier.toInstanceIdentifier(identifier,
+                schemaContextRef.get());
         final DOMMountPoint mountPoint = instanceIdentifier.getMountPoint();
         final String value = uriInfo.getQueryParameters().getFirst(RestconfDataServiceConstant.CONTENT);
 
-        DOMDataReadWriteTransaction transaction = null;
+        DOMTransactionChain transaction = null;
         if (mountPoint == null) {
-            transaction = this.transactionChainHandler.get().newReadWriteTransaction();
+            transaction = this.transactionChainHandler.get();
         } else {
             transaction = transactionOfMountPoint(mountPoint);
         }
         final TransactionVarsWrapper transactionNode = new TransactionVarsWrapper(instanceIdentifier, mountPoint,
                 transaction);
         final NormalizedNode<?, ?> node = ReadDataTransactionUtil.readData(value, transactionNode);
-
-        return new NormalizedNodeContext(instanceIdentifier, node);
+        final SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
+        dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
+        final String etag = '"' + node.getNodeType().getModule().getFormattedRevision()
+                + node.getNodeType().getLocalName() + '"';
+        Response resp = null;
+        if ((value == null) || value.contains(RestconfDataServiceConstant.ReadData.CONFIG)) {
+            resp = Response.status(200).entity(new NormalizedNodeContext(instanceIdentifier, node)).header("ETag", etag)
+                    .header("Last-Modified", dateFormatGmt.toString()).build();
+        } else {
+            resp = Response.status(200).entity(new NormalizedNodeContext(instanceIdentifier, node)).build();
+        }
+        return resp;
     }
 
     @Override
@@ -87,10 +102,10 @@ public class RestconfDataServiceImpl implements RestconfDataService {
         PutDataTransactionUtil.validateListKeysEqualityInPayloadAndUri(payload);
 
         final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
-        DOMDataReadWriteTransaction transaction = null;
+        DOMTransactionChain transaction = null;
         SchemaContextRef ref = null;
         if (mountPoint == null) {
-            transaction = this.transactionChainHandler.get().newReadWriteTransaction();
+            transaction = this.transactionChainHandler.get();
             ref = new SchemaContextRef(this.schemaContextHandler.get());
         } else {
             transaction = transactionOfMountPoint(mountPoint);
@@ -112,10 +127,10 @@ public class RestconfDataServiceImpl implements RestconfDataService {
         Preconditions.checkNotNull(payload);
 
         final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
-        DOMDataReadWriteTransaction transaction = null;
+        DOMTransactionChain transaction = null;
         SchemaContextRef ref = null;
         if (mountPoint == null) {
-            transaction = this.transactionChainHandler.get().newReadWriteTransaction();
+            transaction = this.transactionChainHandler.get();
             ref = new SchemaContextRef(this.schemaContextHandler.get());
         } else {
             transaction = transactionOfMountPoint(mountPoint);
@@ -133,9 +148,9 @@ public class RestconfDataServiceImpl implements RestconfDataService {
                 schemaContextRef.get());
 
         final DOMMountPoint mountPoint = instanceIdentifier.getMountPoint();
-        final DOMDataReadWriteTransaction transaction;
+        final DOMTransactionChain transaction;
         if (mountPoint == null) {
-            transaction = this.transactionChainHandler.get().newReadWriteTransaction();
+            transaction = this.transactionChainHandler.get();
         } else {
             transaction = transactionOfMountPoint(mountPoint);
         }
@@ -156,10 +171,10 @@ public class RestconfDataServiceImpl implements RestconfDataService {
         Preconditions.checkNotNull(context);
         final DOMMountPoint mountPoint = context.getInstanceIdentifierContext().getMountPoint();
 
-        final DOMDataReadWriteTransaction transaction;
+        final DOMTransactionChain transaction;
         final SchemaContextRef ref;
         if (mountPoint == null) {
-            transaction = this.transactionChainHandler.get().newReadWriteTransaction();
+            transaction = this.transactionChainHandler.get();
             ref = new SchemaContextRef(this.schemaContextHandler.get());
         } else {
             transaction = transactionOfMountPoint(mountPoint);
@@ -178,10 +193,10 @@ public class RestconfDataServiceImpl implements RestconfDataService {
      * @param mountPoint
      * @return {@link DOMDataReadWriteTransaction}
      */
-    private static DOMDataReadWriteTransaction transactionOfMountPoint(final DOMMountPoint mountPoint) {
+    private static DOMTransactionChain transactionOfMountPoint(final DOMMountPoint mountPoint) {
         final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class);
         if (domDataBrokerService.isPresent()) {
-            return domDataBrokerService.get().newReadWriteTransaction();
+            return domDataBrokerService.get().createTransactionChain(RestConnectorProvider.transactionListener);
         } else {
             final String errMsg = "DOM data broker service isn't available for mount point "
                     + mountPoint.getIdentifier();
index 1789d30933d98d992258066d5ecde44971068b50..23b3875f86540adae724b28699049c2ec6074329 100644 (file)
@@ -8,8 +8,8 @@
 package org.opendaylight.restconf.restful.transaction;
 
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
 
 /**
@@ -21,7 +21,7 @@ public final class TransactionVarsWrapper {
     private final InstanceIdentifierContext<?> instanceIdentifier;
     private final DOMMountPoint mountPoint;
     private LogicalDatastoreType configuration = null;
-    private final DOMDataReadWriteTransaction transaction;
+    private final DOMTransactionChain transactionChain;
 
     /**
      * Set base type of variables, which ones we need for transaction.
@@ -32,15 +32,15 @@ public final class TransactionVarsWrapper {
      *            - {@link InstanceIdentifierContext} of data for transaction
      * @param mountPoint
      *            - mount point if is present
-     * @param transaction
-     *            - {@link DOMDataReadWriteTransaction} transaction for
-     *            operations
+     * @param transactionChain
+     *            - transaction chain for creating specific type of transaction
+     *            in specific operation
      */
     public TransactionVarsWrapper(final InstanceIdentifierContext<?> instanceIdentifier, final DOMMountPoint mountPoint,
-            final DOMDataReadWriteTransaction transaction) {
+            final DOMTransactionChain transactionChain) {
         this.instanceIdentifier = instanceIdentifier;
         this.mountPoint = mountPoint;
-        this.transaction = transaction;
+        this.transactionChain = transactionChain;
     }
 
     /**
@@ -82,11 +82,12 @@ public final class TransactionVarsWrapper {
     }
 
     /**
-     * Get specific type of transaction
+     * Get transaction chain for creating specific transaction for specific
+     * operation
      *
-     * @return specific type transaction
+     * @return transaction chain
      */
-    public DOMDataReadWriteTransaction getTransaction() {
-        return this.transaction;
+    public DOMTransactionChain getTransactionChain() {
+        return this.transactionChain;
     }
 }
index 53c19c5fe96fce213f6a983f777b5c43733ea8d9..15ce3f76608dc9d6d4e5024ede52b77da6ce76c9 100644 (file)
@@ -12,6 +12,7 @@ import javax.ws.rs.core.Response;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.restconf.restful.transaction.TransactionVarsWrapper;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
@@ -34,7 +35,8 @@ public final class DeleteDataTransactionUtil {
      */
     public static Response deleteData(final TransactionVarsWrapper transactionNode) {
         final CheckedFuture<Void, TransactionCommitFailedException> future = submitData(
-                transactionNode.getTransaction(), transactionNode.getInstanceIdentifier().getInstanceIdentifier());
+                transactionNode.getTransactionChain(), transactionNode.getTransactionChain().newReadWriteTransaction(),
+                transactionNode.getInstanceIdentifier().getInstanceIdentifier());
         final ResponseFactory response = new ResponseFactory();
         FutureCallbackTx.addCallback(future, RestconfDataServiceConstant.DeleteData.DELETE_TX_TYPE, response);
         return response.build();
@@ -43,6 +45,8 @@ public final class DeleteDataTransactionUtil {
     /**
      * Delete data via transaction. Return error if data to delete does not exist.
      *
+     * @param transactionChain
+     *            - transaction chain
      * @param readWriteTx
      *            - read and write transaction
      * @param path
@@ -50,8 +54,9 @@ public final class DeleteDataTransactionUtil {
      * @return {@link CheckedFuture}
      */
     private static CheckedFuture<Void, TransactionCommitFailedException> submitData(
-            final DOMDataReadWriteTransaction readWriteTx, final YangInstanceIdentifier path) {
-        TransactionUtil.checkItemExists(readWriteTx, LogicalDatastoreType.CONFIGURATION, path,
+            final DOMTransactionChain transactionChain, final DOMDataReadWriteTransaction readWriteTx,
+            final YangInstanceIdentifier path) {
+        TransactionUtil.checkItemExists(transactionChain, readWriteTx, LogicalDatastoreType.CONFIGURATION, path,
                 RestconfDataServiceConstant.DeleteData.DELETE_TX_TYPE);
         readWriteTx.delete(LogicalDatastoreType.CONFIGURATION, path);
         return readWriteTx.submit();
index 09cdf6a6e2284ef6bbe5f7cb6ef2601c8da321db..4741592977562a631056fe57949ff4f220ddeaa3 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.util.concurrent.CheckedFuture;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
@@ -26,6 +27,7 @@ import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
+import org.opendaylight.restconf.RestConnectorProvider;
 import org.opendaylight.restconf.common.references.SchemaContextRef;
 import org.opendaylight.restconf.restful.transaction.TransactionVarsWrapper;
 import org.opendaylight.restconf.restful.utils.RestconfDataServiceConstant.PatchData;
@@ -56,6 +58,7 @@ public final class PatchDataTransactionUtil {
                                                final SchemaContextRef schemaContextRef) {
         final List<PATCHStatusEntity> editCollection = new ArrayList<>();
         int errorCounter = 0;
+        final DOMDataReadWriteTransaction tx = transactionNode.getTransactionChain().newReadWriteTransaction();
 
         for (final PATCHEntity patchEntity : context.getData()) {
             final PATCHEditOperation operation = PATCHEditOperation.valueOf(patchEntity.getOperation().toUpperCase());
@@ -65,8 +68,7 @@ public final class PatchDataTransactionUtil {
                     if (errorCounter == 0) {
                         try {
                             createDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                                    patchEntity.getTargetNode(), patchEntity.getNode(),
-                                    transactionNode.getTransaction(), schemaContextRef);
+                                    patchEntity.getTargetNode(), patchEntity.getNode(), tx, schemaContextRef);
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(), true, null));
                         } catch (final RestconfDocumentedException e) {
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(),
@@ -78,8 +80,8 @@ public final class PatchDataTransactionUtil {
                 case DELETE:
                     if (errorCounter == 0) {
                         try {
-                            deleteDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                                    patchEntity.getTargetNode(), transactionNode.getTransaction());
+                            deleteDataWithinTransaction(LogicalDatastoreType.CONFIGURATION, patchEntity.getTargetNode(),
+                                    tx);
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(), true, null));
                         } catch (final RestconfDocumentedException e) {
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(),
@@ -92,8 +94,7 @@ public final class PatchDataTransactionUtil {
                     if (errorCounter == 0) {
                         try {
                             mergeDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                                    patchEntity.getTargetNode(), patchEntity.getNode(), transactionNode.getTransaction(),
-                                    schemaContextRef);
+                                    patchEntity.getTargetNode(), patchEntity.getNode(), tx, schemaContextRef);
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(), true, null));
                         } catch (final RestconfDocumentedException e) {
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(),
@@ -106,8 +107,7 @@ public final class PatchDataTransactionUtil {
                     if (errorCounter == 0) {
                         try {
                             replaceDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                                    patchEntity.getTargetNode(), patchEntity.getNode(), schemaContextRef,
-                                    transactionNode.getTransaction());
+                                    patchEntity.getTargetNode(), patchEntity.getNode(), schemaContextRef, tx);
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(), true, null));
                         } catch (final RestconfDocumentedException e) {
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(),
@@ -119,8 +119,8 @@ public final class PatchDataTransactionUtil {
                 case REMOVE:
                     if (errorCounter == 0) {
                         try {
-                            removeDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                                    patchEntity.getTargetNode(), transactionNode.getTransaction());
+                            removeDataWithinTransaction(LogicalDatastoreType.CONFIGURATION, patchEntity.getTargetNode(),
+                                    tx);
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(), true, null));
                         } catch (final RestconfDocumentedException e) {
                             editCollection.add(new PATCHStatusEntity(patchEntity.getEditId(),
@@ -141,8 +141,7 @@ public final class PatchDataTransactionUtil {
         // if no errors then submit transaction, otherwise cancel
         if (errorCounter == 0) {
             final ResponseFactory response = new ResponseFactory();
-            final CheckedFuture<Void, TransactionCommitFailedException> future = transactionNode
-                    .getTransaction().submit();
+            final CheckedFuture<Void, TransactionCommitFailedException> future = tx.submit();
 
             try {
                 FutureCallbackTx.addCallback(future, PatchData.PATCH_TX_TYPE, response);
@@ -154,7 +153,8 @@ public final class PatchDataTransactionUtil {
 
             return new PATCHStatusContext(context.getPatchId(), ImmutableList.copyOf(editCollection), true, null);
         } else {
-            transactionNode.getTransaction().cancel();
+            tx.cancel();
+            RestConnectorProvider.resetTransactionChainForAdapaters(transactionNode.getTransactionChain());
             return new PATCHStatusContext(context.getPatchId(), ImmutableList.copyOf(editCollection), false, null);
         }
     }
@@ -186,7 +186,7 @@ public final class PatchDataTransactionUtil {
                                                     final YangInstanceIdentifier path,
                                                     final DOMDataReadWriteTransaction readWriteTransaction) {
         LOG.trace("Delete {} within Restconf PATCH: {}", dataStore.name(), path);
-        TransactionUtil.checkItemExists(readWriteTransaction, dataStore, path, PatchData.PATCH_TX_TYPE);
+        checkItemExistsWithinTransaction(readWriteTransaction, dataStore, path);
         readWriteTransaction.delete(dataStore, path);
     }
 
@@ -265,20 +265,62 @@ public final class PatchDataTransactionUtil {
                 final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
 
                 if (errorIfExists) {
-                    TransactionUtil.checkItemDoesNotExists(
-                            rWTransaction, dataStore, childPath, PatchData.PATCH_TX_TYPE);
+                    checkItemDoesNotExistsWithinTransaction(rWTransaction, dataStore, childPath);
                 }
 
                 rWTransaction.put(dataStore, childPath, child);
             }
         } else {
             if (errorIfExists) {
-                TransactionUtil.checkItemDoesNotExists(
-                        rWTransaction, dataStore, path, PatchData.PATCH_TX_TYPE);
+                checkItemDoesNotExistsWithinTransaction(rWTransaction, dataStore, path);
             }
 
             TransactionUtil.ensureParentsByMerge(path, schemaContext, rWTransaction);
             rWTransaction.put(dataStore, path, payload);
         }
     }
+
+    /**
+     * Check if items already exists at specified {@code path}. Throws {@link RestconfDocumentedException} if
+     * data does NOT already exists.
+     * @param rWTransaction Transaction
+     * @param store Datastore
+     * @param path Path to be checked
+     */
+    public static void checkItemExistsWithinTransaction(final DOMDataReadWriteTransaction rWTransaction,
+                                       final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        final CheckedFuture<Boolean, ReadFailedException> future = rWTransaction.exists(store, path);
+        final FutureDataFactory<Boolean> response = new FutureDataFactory<>();
+
+        FutureCallbackTx.addCallback(future, PatchData.PATCH_TX_TYPE, response);
+
+        if (!response.result) {
+            final String errMsg = "Operation via Restconf was not executed because data does not exist";
+            LOG.trace("{}:{}", errMsg, path);
+            throw new RestconfDocumentedException(
+                    "Data does not exist", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, path);
+        }
+    }
+
+    /**
+     * Check if items do NOT already exists at specified {@code path}. Throws {@link RestconfDocumentedException} if
+     * data already exists.
+     * @param rWTransaction Transaction
+     * @param store Datastore
+     * @param path Path to be checked
+     */
+    public static void checkItemDoesNotExistsWithinTransaction(final DOMDataReadWriteTransaction rWTransaction,
+                                              final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        final CheckedFuture<Boolean, ReadFailedException> future = rWTransaction.exists(store, path);
+        final FutureDataFactory<Boolean> response = new FutureDataFactory<>();
+
+        FutureCallbackTx.addCallback(future, PatchData.PATCH_TX_TYPE, response);
+
+        if (response.result) {
+            final String errMsg = "Operation via Restconf was not executed because data already exists";
+            LOG.trace("{}:{}", errMsg, path);
+            throw new RestconfDocumentedException(
+                    "Data already exists", ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, path);
+        }
+    }
 }
index 778acd9734df942d004e55a8c8c67c37ec4966a9..f507837630e83d2c0b5b836130a203dba85187a4 100644 (file)
@@ -15,6 +15,7 @@ import javax.ws.rs.core.UriInfo;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.restconf.common.references.SchemaContextRef;
 import org.opendaylight.restconf.restful.transaction.TransactionVarsWrapper;
@@ -89,32 +90,34 @@ public final class PostDataTransactionUtil {
     private static CheckedFuture<Void, TransactionCommitFailedException> submitData(final YangInstanceIdentifier path,
             final NormalizedNode<?, ?> data, final TransactionVarsWrapper transactionNode,
             final SchemaContext schemaContext) {
-        final DOMDataReadWriteTransaction transaction = transactionNode.getTransaction();
+        final DOMTransactionChain transactionChain = transactionNode.getTransactionChain();
+        final DOMDataReadWriteTransaction transaction = transactionChain.newReadWriteTransaction();
         final NormalizedNode<?, ?> node = ImmutableNodes.fromInstanceId(schemaContext, path);
         transaction.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create(node.getIdentifier()), node);
         TransactionUtil.ensureParentsByMerge(path, schemaContext, transaction);
 
         if (data instanceof MapNode) {
             for (final MapEntryNode child : ((MapNode) data).getValue()) {
-                putChild(child, transaction, path);
+                putChild(child, transactionChain, transaction, path);
             }
         } else if (data instanceof AugmentationNode) {
             for (final DataContainerChild<? extends PathArgument, ?> child : ((AugmentationNode) data).getValue()) {
-                putChild(child, transaction, path);
+                putChild(child, transactionChain, transaction, path);
             }
         } else if (data instanceof ChoiceNode) {
             for (final DataContainerChild<? extends PathArgument, ?> child : ((ChoiceNode) data).getValue()) {
-                putChild(child, transaction, path);
+                putChild(child, transactionChain, transaction, path);
             }
         } else if (data instanceof LeafSetNode<?>) {
             for (final LeafSetEntryNode<?> child : ((LeafSetNode<?>) data).getValue()) {
-                putChild(child, transaction, path);
+                putChild(child, transactionChain, transaction, path);
             }
         } else if (data instanceof ContainerNode) {
             for (final DataContainerChild<? extends PathArgument, ?> child : ((ContainerNode) data).getValue()) {
-                putChild(child, transaction, path);
+                putChild(child, transactionChain, transaction, path);
             }
         }
+
         return transaction.submit();
     }
 
@@ -123,15 +126,18 @@ public final class PostDataTransactionUtil {
      *
      * @param child
      *            - data
+     * @param transactionChain
+     *            - transaction chain
      * @param readWriteTx
      *            - transaction
      * @param path
      *            - path to data
      */
-    private static void putChild(final NormalizedNode<?, ?> child, final DOMDataReadWriteTransaction readWriteTx,
-            final YangInstanceIdentifier path) {
+    private static void putChild(final NormalizedNode<?, ?> child, final DOMTransactionChain transactionChain,
+                                 final DOMDataReadWriteTransaction readWriteTx, final YangInstanceIdentifier path) {
         final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
-        TransactionUtil.checkItemDoesNotExists(readWriteTx, LogicalDatastoreType.CONFIGURATION, childPath,
+        TransactionUtil.checkItemDoesNotExists(
+                transactionChain, readWriteTx, LogicalDatastoreType.CONFIGURATION, childPath,
                 RestconfDataServiceConstant.PostData.POST_TX_TYPE);
         readWriteTx.put(LogicalDatastoreType.CONFIGURATION, childPath, child);
     }
index d0302cfcd3488e32ffc91d9e6b847e4edf4363d6..8db0b433f40507cce4d20c9aa48c018575a19b9a 100644 (file)
@@ -139,7 +139,7 @@ public final class PutDataTransactionUtil {
         final ResponseFactory responseFactory = new ResponseFactory(
                 ReadDataTransactionUtil.readData(RestconfDataServiceConstant.ReadData.CONFIG, transactionNode));
         final CheckedFuture<Void, TransactionCommitFailedException> submitData = submitData(path, schemaCtxRef.get(),
-                transactionNode.getTransaction(), payload.getData());
+                transactionNode.getTransactionChain().newWriteOnlyTransaction(), payload.getData());
         FutureCallbackTx.addCallback(submitData, RestconfDataServiceConstant.PutData.PUT_TX_TYPE, responseFactory);
         return responseFactory.build();
     }
index 425f23bf702ed4c313c9791698669ac45c2b8d20..5f0d995b00c54b5970789d501cd5196b88589b34 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.restconf.restful.utils;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
+import java.util.Collection;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
@@ -18,6 +19,7 @@ import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
 import org.opendaylight.restconf.restful.transaction.TransactionVarsWrapper;
 import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
@@ -30,7 +32,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 
@@ -90,7 +94,7 @@ public final class ReadDataTransactionUtil {
     private static NormalizedNode<?, ?> readDataViaTransaction(final TransactionVarsWrapper transactionNode) {
         if (transactionNode.getLogicalDatastoreType() != null) {
             final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> listenableFuture = transactionNode
-                    .getTransaction().read(transactionNode.getLogicalDatastoreType(),
+                    .getTransactionChain().newReadOnlyTransaction().read(transactionNode.getLogicalDatastoreType(),
                             transactionNode.getInstanceIdentifier().getInstanceIdentifier());
             final NormalizedNodeFactory dataFactory = new NormalizedNodeFactory();
             FutureCallbackTx.addCallback(listenableFuture, RestconfDataServiceConstant.ReadData.READ_TYPE_TX,
@@ -118,7 +122,7 @@ public final class ReadDataTransactionUtil {
         final NormalizedNode<?, ?> configDataNode = readDataViaTransaction(transactionNode);
 
         // if no data exists
-        if (stateDataNode == null && configDataNode == null) {
+        if ((stateDataNode == null) && (configDataNode == null)) {
             throw new RestconfDocumentedException(
                     "Request could not be completed because the relevant data model content does not exist",
                     ErrorType.PROTOCOL,
@@ -209,21 +213,50 @@ public final class ReadDataTransactionUtil {
      */
     private static NormalizedNode<?, ?> prepareData(final NormalizedNode<?, ?> configDataNode,
             final NormalizedNode<?, ?> stateDataNode) {
-        final MapNode immutableStateData = ImmutableNodes.mapNodeBuilder(stateDataNode.getNodeType())
+
+        if (configDataNode instanceof MapNode) { // part for lists mapping
+            final MapNode immutableStateData = ImmutableNodes.mapNodeBuilder(stateDataNode.getNodeType())
                 .addChild((MapEntryNode) stateDataNode).build();
-        final MapNode immutableConfigData = ImmutableNodes.mapNodeBuilder(configDataNode.getNodeType())
+            final MapNode immutableConfigData = ImmutableNodes.mapNodeBuilder(configDataNode.getNodeType())
                 .addChild((MapEntryNode) configDataNode).build();
-
-        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = ImmutableNodes
+            final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = ImmutableNodes
                 .mapEntryBuilder();
-        mapEntryBuilder.withNodeIdentifier((NodeIdentifierWithPredicates) configDataNode.getIdentifier());
+            mapEntryBuilder.withNodeIdentifier((NodeIdentifierWithPredicates) configDataNode.getIdentifier());
 
-        // MAP CONFIG DATA
-        mapDataNode(immutableConfigData, mapEntryBuilder);
-        // MAP STATE DATA
-        mapDataNode(immutableStateData, mapEntryBuilder);
+            // MAP CONFIG DATA
+            mapDataNode(immutableConfigData, mapEntryBuilder);
+            // MAP STATE DATA
+            mapDataNode(immutableStateData, mapEntryBuilder);
+            return ImmutableNodes.mapNodeBuilder(configDataNode.getNodeType()).addChild(mapEntryBuilder.build()).build();
+        } else if (configDataNode instanceof ContainerNode) { // part for
+                                                              // containers
+                                                              // mapping
+            final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder = Builders
+                    .containerBuilder((ContainerNode) configDataNode);
+            // MAP CONFIG DATA
+            mapCont(containerBuilder, ((ContainerNode) configDataNode).getValue());
+            // MAP STATE DATA
+            mapCont(containerBuilder, ((ContainerNode) stateDataNode).getValue());
 
-        return ImmutableNodes.mapNodeBuilder(configDataNode.getNodeType()).addChild(mapEntryBuilder.build()).build();
+            return containerBuilder.build();
+        } else {
+            throw new RestconfDocumentedException("Bad type of node.");
+        }
+    }
+
+    /**
+     * Map data to builder
+     *
+     * @param containerBuilder
+     *            - builder for mapping data
+     * @param childs
+     *            - childs of data (container)
+     */
+    private static void mapCont(final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder,
+            final Collection<DataContainerChild<? extends PathArgument, ?>> childs) {
+        for (final DataContainerChild<? extends PathArgument, ?> child : childs) {
+            containerBuilder.addChild(child);
+        }
     }
 
     /**
index 6f63088d50085dd2806498ea3807719965dbe31d..2cd6899e3290b34289efa4b5d08cbc1f743e8ed1 100644 (file)
@@ -5,6 +5,7 @@
  * 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.restconf.restful.utils;
 
 import com.google.common.base.Preconditions;
@@ -16,9 +17,11 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
+import org.opendaylight.restconf.RestConnectorProvider;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -88,12 +91,14 @@ public final class TransactionUtil {
     /**
      * Check if items already exists at specified {@code path}. Throws {@link RestconfDocumentedException} if
      * data does NOT already exists.
+     * @param transactionChain Transaction chain
      * @param rWTransaction Transaction
      * @param store Datastore
      * @param path Path to be checked
      * @param operationType Type of operation (READ, POST, PUT, DELETE...)
      */
-    public static void checkItemExists(final DOMDataReadWriteTransaction rWTransaction,
+    public static void checkItemExists(final DOMTransactionChain transactionChain,
+                                       final DOMDataReadWriteTransaction rWTransaction,
                                        final LogicalDatastoreType store, final YangInstanceIdentifier path,
                                        final String operationType) {
         final CheckedFuture<Boolean, ReadFailedException> future = rWTransaction.exists(store, path);
@@ -102,6 +107,11 @@ public final class TransactionUtil {
         FutureCallbackTx.addCallback(future, operationType, response);
 
         if (!response.result) {
+            // close transaction and reset transaction chain
+            rWTransaction.cancel();
+            RestConnectorProvider.resetTransactionChainForAdapaters(transactionChain);
+
+            // throw error
             final String errMsg = "Operation via Restconf was not executed because data does not exist";
             LOG.trace("{}:{}", errMsg, path);
             throw new RestconfDocumentedException(
@@ -112,12 +122,14 @@ public final class TransactionUtil {
     /**
      * Check if items do NOT already exists at specified {@code path}. Throws {@link RestconfDocumentedException} if
      * data already exists.
+     * @param transactionChain Transaction chain
      * @param rWTransaction Transaction
      * @param store Datastore
      * @param path Path to be checked
      * @param operationType Type of operation (READ, POST, PUT, DELETE...)
      */
-    public static void checkItemDoesNotExists(final DOMDataReadWriteTransaction rWTransaction,
+    public static void checkItemDoesNotExists(final DOMTransactionChain transactionChain,
+                                              final DOMDataReadWriteTransaction rWTransaction,
                                               final LogicalDatastoreType store, final YangInstanceIdentifier path,
                                               final String operationType) {
         final CheckedFuture<Boolean, ReadFailedException> future = rWTransaction.exists(store, path);
@@ -126,6 +138,11 @@ public final class TransactionUtil {
         FutureCallbackTx.addCallback(future, operationType, response);
 
         if (response.result) {
+            // close transaction and reset transaction chain
+            rWTransaction.cancel();
+            RestConnectorProvider.resetTransactionChainForAdapaters(transactionChain);
+
+            // throw error
             final String errMsg = "Operation via Restconf was not executed because data already exists";
             LOG.trace("{}:{}", errMsg, path);
             throw new RestconfDocumentedException(
index 939f3ac7550ec3c6b7fb96a87c8ecc4b01cd979f..71997144c7e10f4cf49a41376934b13130ca4c77 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.restconf.utils.mapping;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.Set;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 import org.opendaylight.restconf.utils.schema.context.RestconfSchemaUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -50,7 +50,7 @@ public final class RestconfMappingNodeUtil {
      */
     public static MapNode restconfMappingNode(final Module restconfModule, final Set<Module> modules) {
         final DataSchemaNode modulListSchemaNode = RestconfSchemaUtil.getRestconfSchemaNode(restconfModule,
-                Draft11.RestconfModule.MODULE_LIST_SCHEMA_NODE);
+                Draft15.RestconfModule.MODULE_LIST_SCHEMA_NODE);
         Preconditions.checkState(modulListSchemaNode instanceof ListSchemaNode);
 
         final CollectionNodeBuilder<MapEntryNode, MapNode> listModuleBuilder = Builders
@@ -16,7 +16,7 @@ import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
 import org.opendaylight.restconf.utils.parser.ParserIdentifier;
 
-public class Draft11AbstractIdentifierAwareJaxRsProvider {
+public class Draft15AbstractIdentifierAwareJaxRsProvider {
 
     private static final String POST = "POST";
 
@@ -35,7 +35,7 @@ import org.opendaylight.netconf.sal.restconf.impl.PATCHEntity;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -51,11 +51,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Provider
-@Consumes({Draft11.MediaTypes.PATCH + RestconfConstants.JSON})
-public class Draft11JsonToPATCHBodyReader extends Draft11AbstractIdentifierAwareJaxRsProvider
+@Consumes({Draft15.MediaTypes.PATCH + RestconfConstants.JSON})
+public class Draft15JsonToPATCHBodyReader extends Draft15AbstractIdentifierAwareJaxRsProvider
         implements MessageBodyReader<PATCHContext> {
 
-    private final static Logger LOG = LoggerFactory.getLogger(Draft11JsonToPATCHBodyReader.class);
+    private final static Logger LOG = LoggerFactory.getLogger(Draft15JsonToPATCHBodyReader.class);
     private String patchId;
 
     @Override
@@ -115,9 +115,9 @@ public class Draft11JsonToPATCHBodyReader extends Draft11AbstractIdentifierAware
 
     private List<PATCHEntity> read(final JsonReader in, final InstanceIdentifierContext path) throws IOException {
         final List<PATCHEntity> resultCollection = new ArrayList<>();
-        final Draft11StringModuleInstanceIdentifierCodec codec = new Draft11StringModuleInstanceIdentifierCodec(
+        final Draft15StringModuleInstanceIdentifierCodec codec = new Draft15StringModuleInstanceIdentifierCodec(
                 path.getSchemaContext());
-        final Draft11JsonToPATCHBodyReader.PatchEdit edit = new Draft11JsonToPATCHBodyReader.PatchEdit();
+        final Draft15JsonToPATCHBodyReader.PatchEdit edit = new Draft15JsonToPATCHBodyReader.PatchEdit();
 
         while (in.hasNext()) {
             switch (in.peek()) {
@@ -169,7 +169,7 @@ public class Draft11JsonToPATCHBodyReader extends Draft11AbstractIdentifierAware
      */
     private void parseByName(@Nonnull final String name, @Nonnull final PatchEdit edit,
                              @Nonnull final JsonReader in, @Nonnull final InstanceIdentifierContext path,
-                             @Nonnull final Draft11StringModuleInstanceIdentifierCodec codec,
+                             @Nonnull final Draft15StringModuleInstanceIdentifierCodec codec,
                              @Nonnull final List<PATCHEntity> resultCollection) throws IOException {
         switch (name) {
             case "edit" :
@@ -208,7 +208,7 @@ public class Draft11JsonToPATCHBodyReader extends Draft11AbstractIdentifierAware
      */
     private void readEditDefinition(@Nonnull final PatchEdit edit, @Nonnull final JsonReader in,
                                     @Nonnull final InstanceIdentifierContext path,
-                                    @Nonnull final Draft11StringModuleInstanceIdentifierCodec codec) throws IOException {
+                                    @Nonnull final Draft15StringModuleInstanceIdentifierCodec codec) throws IOException {
         final StringBuffer value = new StringBuffer();
         in.beginObject();
 
@@ -17,19 +17,19 @@ import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-final class Draft11StringModuleInstanceIdentifierCodec extends AbstractModuleStringInstanceIdentifierCodec {
+final class Draft15StringModuleInstanceIdentifierCodec extends AbstractModuleStringInstanceIdentifierCodec {
 
     private final DataSchemaContextTree dataContextTree;
     private final SchemaContext context;
     private final String defaultPrefix;
 
-    Draft11StringModuleInstanceIdentifierCodec(SchemaContext context) {
+    Draft15StringModuleInstanceIdentifierCodec(SchemaContext context) {
         this.context = Preconditions.checkNotNull(context);
         this.dataContextTree = DataSchemaContextTree.from(context);
         this.defaultPrefix = "";
     }
 
-    Draft11StringModuleInstanceIdentifierCodec(SchemaContext context, @Nonnull String defaultPrefix) {
+    Draft15StringModuleInstanceIdentifierCodec(SchemaContext context, @Nonnull String defaultPrefix) {
         this.context = Preconditions.checkNotNull(context);
         this.dataContextTree = DataSchemaContextTree.from(context);
         this.defaultPrefix = defaultPrefix;
@@ -35,7 +35,7 @@ import org.opendaylight.netconf.sal.restconf.impl.PATCHEntity;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -58,11 +58,11 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 @Provider
-@Consumes({Draft11.MediaTypes.PATCH + RestconfConstants.XML})
-public class Draft11XmlToPATCHBodyReader extends Draft11AbstractIdentifierAwareJaxRsProvider implements
+@Consumes({Draft15.MediaTypes.PATCH + RestconfConstants.XML})
+public class Draft15XmlToPATCHBodyReader extends Draft15AbstractIdentifierAwareJaxRsProvider implements
         MessageBodyReader<PATCHContext> {
 
-    private final static Logger LOG = LoggerFactory.getLogger(Draft11XmlToPATCHBodyReader.class);
+    private final static Logger LOG = LoggerFactory.getLogger(Draft15XmlToPATCHBodyReader.class);
     private static final DocumentBuilderFactory BUILDERFACTORY;
 
     static {
@@ -148,7 +148,7 @@ public class Draft11XmlToPATCHBodyReader extends Draft11AbstractIdentifierAwareJ
                     URI.create(namespace)).iterator().next();
 
             // initialize codec + set default prefix derived from module name
-            final Draft11StringModuleInstanceIdentifierCodec codec = new Draft11StringModuleInstanceIdentifierCodec(
+            final Draft15StringModuleInstanceIdentifierCodec codec = new Draft15StringModuleInstanceIdentifierCodec(
                     pathContext.getSchemaContext(), module.getName());
 
             // find complete path to target and target schema node
@@ -235,7 +235,7 @@ public class Draft11XmlToPATCHBodyReader extends Draft11AbstractIdentifierAwareJ
 
     /**
      * Prepare non-conditional XPath suitable for deserialization
-     * with {@link Draft11StringModuleInstanceIdentifierCodec}
+     * with {@link Draft15StringModuleInstanceIdentifierCodec}
      * @param schemaNode Top schema node
      * @param target Edit operation target
      * @param value Element with value
index fbeb7d938345e31a7469e79d13e7e9fa04bfb9a6..151811bb0b69789493b8e6d2bfe0cd52302b397c 100644 (file)
@@ -13,7 +13,7 @@ import java.util.Set;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
@@ -44,7 +44,7 @@ public final class RestconfSchemaUtil {
 
         final Set<GroupingDefinition> groupings = restconfModule.getGroupings();
         final GroupingDefinition restGroup = findSchemaNodeInCollection(groupings,
-                Draft11.RestconfModule.RESTCONF_GROUPING_SCHEMA_NODE);
+                Draft15.RestconfModule.RESTCONF_GROUPING_SCHEMA_NODE);
         final Collection<DataSchemaNode> childNodes = restGroup.getChildNodes();
         final DataSchemaNode restCont = childNodes.iterator().next();
 
@@ -64,31 +64,31 @@ public final class RestconfSchemaUtil {
     private static DataSchemaNode findSchemaNode(final DataSchemaNode restCont, final String schemaNodeName) {
         switch (schemaNodeName) {
             //MODULES
-            case Draft11.RestconfModule.MODULE_LIST_SCHEMA_NODE:
+            case Draft15.RestconfModule.MODULE_LIST_SCHEMA_NODE:
                 final DataSchemaNode moduleListSchNode = findSchemaNodeInCollection(
                         ((DataNodeContainer) findSchemaNode(restCont,
-                                Draft11.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE)).getChildNodes(),
-                        Draft11.RestconfModule.MODULE_LIST_SCHEMA_NODE);
+                                Draft15.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE)).getChildNodes(),
+                        Draft15.RestconfModule.MODULE_LIST_SCHEMA_NODE);
                 Preconditions.checkNotNull(moduleListSchNode);
                 return moduleListSchNode;
-            case Draft11.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE:
+            case Draft15.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE:
                 final DataSchemaNode modulesContSchNode = findSchemaNodeInCollection(((DataNodeContainer) restCont).getChildNodes(),
-                        Draft11.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE);
+                        Draft15.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE);
                 Preconditions.checkNotNull(modulesContSchNode);
                 return modulesContSchNode;
 
             //STREAMS
-            case Draft11.MonitoringModule.STREAM_LIST_SCHEMA_NODE:
+            case Draft15.MonitoringModule.STREAM_LIST_SCHEMA_NODE:
                 final DataSchemaNode streamListSchNode = findSchemaNodeInCollection(
                         ((DataNodeContainer) findSchemaNode(restCont,
-                                Draft11.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE)).getChildNodes(),
-                        Draft11.MonitoringModule.STREAM_LIST_SCHEMA_NODE);
+                                Draft15.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE)).getChildNodes(),
+                        Draft15.MonitoringModule.STREAM_LIST_SCHEMA_NODE);
                 Preconditions.checkNotNull(streamListSchNode);
                 return streamListSchNode;
-            case Draft11.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE:
+            case Draft15.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE:
                 final DataSchemaNode streamsContSchNode = findSchemaNodeInCollection(
                         ((DataNodeContainer) restCont).getChildNodes(),
-                        Draft11.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE);
+                        Draft15.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE);
                 Preconditions.checkNotNull(streamsContSchNode);
                 return streamsContSchNode;
             default:
index bdb149f14f8074143533ec63033869b8c7880742..509fcdefab26549f89cf99e8516df6c596df8078 100644 (file)
@@ -60,7 +60,7 @@
 
     <servlet-mapping>
         <servlet-name>Restconf</servlet-name>
-        <url-pattern>/11/*</url-pattern>
+        <url-pattern>/15/*</url-pattern>
     </servlet-mapping>
 
     <filter>
index ff7b770fbb9376355ee72d349d6abfec9d2fc736..d70c119bd412b3b6bde7ce3f619b42f7357e88af 100644 (file)
@@ -24,7 +24,7 @@ import org.opendaylight.netconf.sal.rest.api.RestconfConstants;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
-import org.opendaylight.restconf.utils.patch.Draft11AbstractIdentifierAwareJaxRsProvider;
+import org.opendaylight.restconf.utils.patch.Draft15AbstractIdentifierAwareJaxRsProvider;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public abstract class Draft11AbstractBodyReaderTest {
@@ -36,10 +36,10 @@ public abstract class Draft11AbstractBodyReaderTest {
 
     public Draft11AbstractBodyReaderTest() throws NoSuchFieldException,
             SecurityException {
-        uriField = Draft11AbstractIdentifierAwareJaxRsProvider.class
+        uriField = Draft15AbstractIdentifierAwareJaxRsProvider.class
                 .getDeclaredField("uriInfo");
         uriField.setAccessible(true);
-        requestField = Draft11AbstractIdentifierAwareJaxRsProvider.class
+        requestField = Draft15AbstractIdentifierAwareJaxRsProvider.class
                 .getDeclaredField("request");
         requestField.setAccessible(true);
         mediaType = getMediaType();
@@ -52,7 +52,7 @@ public abstract class Draft11AbstractBodyReaderTest {
         return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext);
     }
 
-    protected static <T extends Draft11AbstractIdentifierAwareJaxRsProvider> void mockBodyReader(
+    protected static <T extends Draft15AbstractIdentifierAwareJaxRsProvider> void mockBodyReader(
             final String identifier, final T normalizedNodeProvider,
             final boolean isPost) throws NoSuchFieldException,
             SecurityException, IllegalArgumentException, IllegalAccessException {
index 02acc09b932f726a297d3efc268e977a654c832b..fd6353200f59acb99869e6c31f842c2c2c1946c8 100644 (file)
@@ -18,17 +18,17 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
-import org.opendaylight.restconf.utils.patch.Draft11JsonToPATCHBodyReader;
+import org.opendaylight.restconf.utils.patch.Draft15JsonToPATCHBodyReader;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class TestDraft11JsonPATCHBodyReader extends Draft11AbstractBodyReaderTest {
 
-    private final Draft11JsonToPATCHBodyReader jsonPATCHBodyReader;
+    private final Draft15JsonToPATCHBodyReader jsonPATCHBodyReader;
     private static SchemaContext schemaContext;
 
     public TestDraft11JsonPATCHBodyReader() throws NoSuchFieldException, SecurityException {
         super();
-        jsonPATCHBodyReader = new Draft11JsonToPATCHBodyReader();
+        jsonPATCHBodyReader = new Draft15JsonToPATCHBodyReader();
     }
 
     @Override
index a8955fa5ee9a399e006dd03f8d6fe677d5ce5829..2d957ece36846814129d13d11258191827bbf3f9 100644 (file)
@@ -17,17 +17,17 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
-import org.opendaylight.restconf.utils.patch.Draft11XmlToPATCHBodyReader;
+import org.opendaylight.restconf.utils.patch.Draft15XmlToPATCHBodyReader;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class TestDraft11XmlPATCHBodyReader extends Draft11AbstractBodyReaderTest {
 
-    private final Draft11XmlToPATCHBodyReader xmlPATCHBodyReader;
+    private final Draft15XmlToPATCHBodyReader xmlPATCHBodyReader;
     private static SchemaContext schemaContext;
 
     public TestDraft11XmlPATCHBodyReader() throws NoSuchFieldException, SecurityException {
         super();
-        xmlPATCHBodyReader = new Draft11XmlToPATCHBodyReader();
+        xmlPATCHBodyReader = new Draft15XmlToPATCHBodyReader();
     }
 
     @Override
index 9b3b450b747cb3308a82d1e503e57c205f0ced75..f2ade260efe4152460a147736a72244d6b645b20 100644 (file)
@@ -171,5 +171,6 @@ public class RestConnectorProviderTest {
 
         // verify interaction
         verify(this.mockRegistration, times(1)).close();
+        verify(mockTransactionChain, times(1)).close();
     }
 }
index ff100dbdf496047c22eab110d92416d8ece8ee9f..f2811b1df59de646c7362ad06801f911479ac25c 100644 (file)
@@ -47,7 +47,7 @@ import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft11.RestconfModule;
+import org.opendaylight.restconf.Draft15.RestconfModule;
 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.rest.services.api.RestconfModulesService;
index 4f221b0ae1663bab8c1fd673c515ec1bb80c631a..2d9d4a33d076fc3edc228d8faab69d76dc2dfa7c 100644 (file)
@@ -30,7 +30,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl;
 import org.opendaylight.controller.md.sal.dom.broker.spi.mount.SimpleDOMMountPoint;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.utils.RestconfConstants;
@@ -194,8 +194,8 @@ class RestconfModulesServiceTestUtils {
 
         when(schemaContext.findModuleByNamespaceAndRevision(any(URI.class), any(Date.class))).thenAnswer(invocation -> {
             final Object[] args = invocation.getArguments();
-            if (args[0] == Draft11.RestconfModule.IETF_RESTCONF_QNAME.getNamespace()
-                    && args[1] == Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()) {
+            if (args[0] == Draft15.RestconfModule.IETF_RESTCONF_QNAME.getNamespace()
+                    && args[1] == Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision()) {
                 return parseCustomRestconfSource(restconfModuleName).findModuleByName(
                         restconfModuleName, (Date) args[1]);
             } else {
index acd5ae6dfbc8cc32935ccf885906a247e98d96cc..c0c306f8e069078732a96fd3f3654849dab45630 100644 (file)
@@ -37,7 +37,7 @@ import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
 import org.opendaylight.netconf.sal.streams.listeners.Notificator;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
 import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeConstants;
@@ -108,8 +108,8 @@ public class RestconfStreamsServiceTest {
     public void getAvailableStreamsTest() throws Exception {
         // prepare conditions - get correct Restconf module
         when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
-        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
-                .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
+        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft15.RestconfModule.IETF_RESTCONF_QNAME
+                .getNamespace(), Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
                 .thenReturn(getTestingRestconfModule("ietf-restconf"));
 
         // make test
@@ -142,8 +142,8 @@ public class RestconfStreamsServiceTest {
     public void getAvailableStreamsMissingRestconfModuleNegativeTest() {
         // prepare conditions - get null Restconf module
         when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
-        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
-                .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision())).thenReturn(null);
+        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft15.RestconfModule.IETF_RESTCONF_QNAME
+                .getNamespace(), Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision())).thenReturn(null);
 
         // make test
         this.thrown.expect(NullPointerException.class);
@@ -159,8 +159,8 @@ public class RestconfStreamsServiceTest {
     public void getAvailableStreamsMissingListStreamNegativeTest() {
         // prepare conditions - get Restconf module with missing list stream
         when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
-        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
-                .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
+        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft15.RestconfModule.IETF_RESTCONF_QNAME
+                .getNamespace(), Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
                 .thenReturn(getTestingRestconfModule("restconf-module-with-missing-list-stream"));
 
         // make test and verify
@@ -186,8 +186,8 @@ public class RestconfStreamsServiceTest {
     public void getAvailableStreamsMissingContainerStreamsNegativeTest() {
         // prepare conditions - get Restconf module with missing container streams
         when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
-        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
-                .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
+        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft15.RestconfModule.IETF_RESTCONF_QNAME
+                .getNamespace(), Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
                 .thenReturn(getTestingRestconfModule("restconf-module-with-missing-container-streams"));
 
         // make test and verify
@@ -212,8 +212,8 @@ public class RestconfStreamsServiceTest {
     public void getAvailableStreamsIllegalListStreamNegativeTest() {
         // prepare conditions - get Restconf module with illegal list stream
         when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
-        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
-                .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
+        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft15.RestconfModule.IETF_RESTCONF_QNAME
+                .getNamespace(), Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
                 .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-list-stream"));
 
         // make test
@@ -229,8 +229,8 @@ public class RestconfStreamsServiceTest {
     public void getAvailableStreamsIllegalContainerStreamsNegativeTest() {
         // prepare conditions - get Restconf module with illegal container streams
         when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
-        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
-                .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
+        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft15.RestconfModule.IETF_RESTCONF_QNAME
+                .getNamespace(), Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
                 .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-container-streams"));
 
         // make test
@@ -246,8 +246,8 @@ public class RestconfStreamsServiceTest {
     public void getAvailableStreamsIllegalLeafDescriptionNegativeTest() {
         // prepare conditions - get Restconf module with illegal leaf description in list stream
         when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
-        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft11.RestconfModule.IETF_RESTCONF_QNAME
-                .getNamespace(), Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
+        when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft15.RestconfModule.IETF_RESTCONF_QNAME
+                .getNamespace(), Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
                 .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-leaf-description"));
 
         // make test
@@ -262,7 +262,7 @@ public class RestconfStreamsServiceTest {
      * @return Restconf module
      */
     private Module getTestingRestconfModule(final String s) {
-        return this.schemaContext.findModuleByName(s, Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
+        return this.schemaContext.findModuleByName(s, Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
     }
 
     /**
index f867ab1d1a2eef09765f229139e42d7759be5e57..38db430eab408064dfeaa85318aeebb7fa218c1a 100644 (file)
@@ -10,33 +10,71 @@ package org.opendaylight.restconf.restful.utils;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
 
 import com.google.common.util.concurrent.Futures;
+import java.lang.reflect.Field;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
+import org.opendaylight.restconf.RestConnectorProvider;
+import org.opendaylight.restconf.handlers.TransactionChainHandler;
 import org.opendaylight.restconf.restful.transaction.TransactionVarsWrapper;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class DeleteDataTransactionUtilTest {
-    @Mock DOMDataReadWriteTransaction transaction;
-    @Mock InstanceIdentifierContext<?> context;
+    @Mock
+    private DOMTransactionChain transactionChain;
+    @Mock
+    private InstanceIdentifierContext<?> context;
+    @Mock
+    private DOMDataReadWriteTransaction readWrite;
+
+    // Fields used when delete operation fails to reset transaction chain
+    private static Field handler;
+    private static Field broker;
+
+    @BeforeClass
+    public static void setup() throws Exception {
+        DeleteDataTransactionUtilTest.handler = RestConnectorProvider.class.getDeclaredField("transactionChainHandler");
+        DeleteDataTransactionUtilTest.broker = RestConnectorProvider.class.getDeclaredField("dataBroker");
+
+        DeleteDataTransactionUtilTest.handler.setAccessible(true);
+        DeleteDataTransactionUtilTest.handler.set(RestConnectorProvider.class, mock(TransactionChainHandler.class));
+
+        DeleteDataTransactionUtilTest.broker.setAccessible(true);
+        DeleteDataTransactionUtilTest.broker.set(RestConnectorProvider.class, mock(DOMDataBroker.class));
+    }
+
+    @AfterClass
+    public static void clean() throws Exception {
+        DeleteDataTransactionUtilTest.handler.set(RestConnectorProvider.class, null);
+        DeleteDataTransactionUtilTest.handler.setAccessible(false);
+
+        DeleteDataTransactionUtilTest.broker.set(RestConnectorProvider.class, null);
+        DeleteDataTransactionUtilTest.broker.setAccessible(false);
+    }
 
     @Before
     public void init() throws Exception {
         MockitoAnnotations.initMocks(this);
-        Mockito.when(this.transaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
-        Mockito.when(context.getInstanceIdentifier()).thenReturn(YangInstanceIdentifier.EMPTY);
+        Mockito.when(this.transactionChain.newReadWriteTransaction()).thenReturn(this.readWrite);
+        Mockito.when(this.readWrite.submit()).thenReturn(Futures.immediateCheckedFuture(null));
+        Mockito.when(this.context.getInstanceIdentifier()).thenReturn(YangInstanceIdentifier.EMPTY);
     }
 
     /**
@@ -45,12 +83,13 @@ public class DeleteDataTransactionUtilTest {
     @Test
     public void deleteData() throws Exception {
         // assert that data to delete exists
-        Mockito.when(this.transaction.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY))
+        Mockito.when(this.transactionChain.newReadWriteTransaction().exists(LogicalDatastoreType.CONFIGURATION,
+                YangInstanceIdentifier.EMPTY))
                 .thenReturn(Futures.immediateCheckedFuture(Boolean.TRUE));
 
         // test
         final Response response = DeleteDataTransactionUtil.deleteData(
-                new TransactionVarsWrapper(this.context, null, this.transaction));
+                new TransactionVarsWrapper(this.context, null, this.transactionChain));
 
         // assert success
         assertEquals("Not expected response received", Status.OK.getStatusCode(), response.getStatus());
@@ -62,12 +101,13 @@ public class DeleteDataTransactionUtilTest {
     @Test
     public void deleteDataNegativeTest() throws Exception {
         // assert that data to delete does NOT exist
-        Mockito.when(this.transaction.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY))
+        Mockito.when(this.transactionChain.newReadWriteTransaction().exists(LogicalDatastoreType.CONFIGURATION,
+                YangInstanceIdentifier.EMPTY))
                 .thenReturn(Futures.immediateCheckedFuture(Boolean.FALSE));
 
         // test and assert error
         try {
-            DeleteDataTransactionUtil.deleteData(new TransactionVarsWrapper(this.context, null, this.transaction));
+            DeleteDataTransactionUtil.deleteData(new TransactionVarsWrapper(this.context, null, this.transactionChain));
             fail("Delete operation should fail due to missing data");
         } catch (final RestconfDocumentedException e) {
             assertEquals(ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
index 9590d3eea06589cafdbd61285be3afc2773095a0..21d21a1e3c3ffdcf87ca1599d1780b53bfb5d9e5 100644 (file)
@@ -35,9 +35,9 @@ import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft11;
-import org.opendaylight.restconf.Draft11.MonitoringModule;
-import org.opendaylight.restconf.Draft11.RestconfModule;
+import org.opendaylight.restconf.Draft15;
+import org.opendaylight.restconf.Draft15.MonitoringModule;
+import org.opendaylight.restconf.Draft15.RestconfModule;
 import org.opendaylight.restconf.utils.schema.context.RestconfSchemaUtil;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
@@ -756,7 +756,7 @@ public class RestconfMappingNodeUtilTest {
      */
     private Module getTestingRestconfModule(final String s) {
         return RestconfMappingNodeUtilTest.schemaContext.findModuleByName(
-                s, Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
+                s, Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
     }
 
     /**
index 7fd781ad0134e3f64ce2d2659096493f1c416136..314cbe66a09a0f2804718acedb34047bb34cafa4 100644 (file)
@@ -11,8 +11,8 @@ package org.opendaylight.restconf.utils.schema.context;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
-import static org.opendaylight.restconf.Draft11.MonitoringModule;
-import static org.opendaylight.restconf.Draft11.RestconfModule;
+import static org.opendaylight.restconf.Draft15.MonitoringModule;
+import static org.opendaylight.restconf.Draft15.RestconfModule;
 
 import com.google.common.collect.Sets;
 import java.util.NoSuchElementException;
@@ -23,7 +23,7 @@ import org.junit.rules.ExpectedException;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
-import org.opendaylight.restconf.Draft11;
+import org.opendaylight.restconf.Draft15;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -389,6 +389,6 @@ public class RestconfSchemaUtilTest {
      * @return Restconf module
      */
     private Module getTestingRestconfModule(final String s) {
-        return schemaContext.findModuleByName(s, Draft11.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
+        return schemaContext.findModuleByName(s, Draft15.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
     }
 }