X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Foperations%2FCommit.java;h=57e356704f5d12bcf2649fe38c7f2e6c46827285;hp=592d8e4f3b657933b99144f5c769adf4895a5baf;hb=d651368d83292f7226a4e91adb55de98036c228f;hpb=dc43a61816ddd75e3ad3a3a30bf64c60ad8275a2 diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/Commit.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/Commit.java index 592d8e4f3b..57e356704f 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/Commit.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/Commit.java @@ -11,6 +11,8 @@ package org.opendaylight.controller.netconf.confignetconfconnector.operations; import java.util.HashMap; import java.util.Map; +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.util.ConfigRegistryClient; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; @@ -48,23 +50,26 @@ public class Commit extends AbstractConfigNetconfOperation { } @Override - protected Element handle(Document document, XmlElement xml) throws NetconfDocumentedException { + protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws NetconfDocumentedException { checkXml(xml); CommitStatus status; try { status = this.transactionProvider.commitTransaction(); } catch (final IllegalStateException e) { + // TODO Illegal state thrown when no transaction yet for user + // Throw other exception type, or create transaction automatically logger.warn("Commit failed: ", e); final Map errorInfo = new HashMap<>(); errorInfo.put(ErrorTag.operation_failed.name(), "Operation failed. Use 'get-config' or 'edit-config' before triggering 'commit' operation"); throw new NetconfDocumentedException(e.getMessage(), e, ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error, errorInfo); - } catch (final NetconfDocumentedException e) { - throw new NetconfDocumentedException( - "Unable to retrieve config snapshot after commit for persister, details: " + e.getMessage(), - ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error, e.getErrorInfo()); + } catch (ValidationException e) { + throw NetconfDocumentedException.wrap(e); + } catch (ConflictingVersionException e) { + throw NetconfDocumentedException.wrap(e); + } logger.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);