Bug 4455 - Inconsistent COMMIT operation handling when no transactions are present 95/32595/5
authorJakub Morvay <jmorvay@cisco.com>
Thu, 14 Jan 2016 16:02:42 +0000 (17:02 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 18 Jan 2016 16:21:21 +0000 (16:21 +0000)
Return positive response for commit operation in config subsystem
netconf northbound even if no candidate transaction is open for session.

Need to be merged after https://git.opendaylight.org/gerrit/#/c/32598/

Change-Id: Ia6ce2aa6ffdfafc47f69ae7315669f64b653c514
Signed-off-by: Jakub Morvay <jmorvay@cisco.com>
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/NoTransactionFoundException.java [deleted file]
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java

diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/NoTransactionFoundException.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/NoTransactionFoundException.java
deleted file mode 100644 (file)
index c1a9def..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.facade.xml.exception;
-
-import java.util.Collections;
-import java.util.Map;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-
-public class NoTransactionFoundException extends DocumentedException {
-    private static final long serialVersionUID = 1L;
-
-    public NoTransactionFoundException(final String message, final ErrorType errorType, final ErrorTag errorTag,
-                                          final ErrorSeverity errorSeverity) {
-        this(message, errorType, errorTag, errorSeverity, Collections.<String, String> emptyMap());
-    }
-
-    public NoTransactionFoundException(final String message, final ErrorType errorType, final ErrorTag errorTag,
-                                          final ErrorSeverity errorSeverity, final Map<String, String> errorInfo){
-        super(message,errorType,errorTag,errorSeverity,errorInfo);
-    }
-
-}
index 743be1e..716ed79 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.config.facade.xml.transactions;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import javax.management.InstanceNotFoundException;
@@ -18,10 +19,8 @@ import javax.management.ObjectName;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.facade.xml.exception.NoTransactionFoundException;
 import org.opendaylight.controller.config.util.ConfigRegistryClient;
 import org.opendaylight.controller.config.util.ConfigTransactionClient;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -123,8 +122,7 @@ public class TransactionProvider implements AutoCloseable {
     /**
      * Commit and notification send must be atomic
      */
-    public CommitStatus commitTransaction() throws ValidationException, ConflictingVersionException,
-        NoTransactionFoundException {
+    public CommitStatus commitTransaction() throws ValidationException, ConflictingVersionException {
         return commitTransaction(configRegistryClient);
     }
 
@@ -132,12 +130,11 @@ public class TransactionProvider implements AutoCloseable {
      * Commit and notification send must be atomic
      * @param configRegistryClient
      */
-    public synchronized CommitStatus commitTransaction(final ConfigRegistryClient configRegistryClient) throws ValidationException, ConflictingVersionException, NoTransactionFoundException {
+    public synchronized CommitStatus commitTransaction(final ConfigRegistryClient configRegistryClient) throws ValidationException, ConflictingVersionException {
         if (!getTransaction().isPresent()){
-            throw new NoTransactionFoundException("No transaction found for session " + sessionIdForReporting,
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+            //making empty commit without prior opened transaction, just return commit status with empty lists
+            LOG.debug("Making commit without open candidate transaction for session {}", sessionIdForReporting);
+            return new CommitStatus(Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
         }
         final Optional<ObjectName> maybeTaON = getTransaction();
         ObjectName taON = maybeTaON.get();