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=d49fe1a11629b0c5a9110b82973eac91ea25ba44;hp=561aab9052f3ac5d040369fa89f799406a64d525;hb=6dae254dbc2940d1f0f372d65d69b0e0dda415fe;hpb=7f0272398ce3dab7ceddd998c7bb510df3b28838 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 561aab9052..d49fe1a116 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 @@ -8,17 +8,11 @@ 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; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType; import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider; import org.opendaylight.controller.netconf.util.xml.XmlElement; import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; @@ -42,7 +36,7 @@ public class Commit extends AbstractConfigNetconfOperation { this.transactionProvider = transactionProvider; } - private static void checkXml(XmlElement xml) { + private static void checkXml(XmlElement xml) throws NetconfDocumentedException { xml.checkName(XmlNetconfConstants.COMMIT); xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); } @@ -54,25 +48,14 @@ public class Commit extends AbstractConfigNetconfOperation { @Override protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws NetconfDocumentedException { - checkXml(xml); + 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 (ValidationException e) { + logger.trace("Datastore {} committed successfully: {}", Datastore.candidate, status); + } catch (ConflictingVersionException | ValidationException e) { throw NetconfDocumentedException.wrap(e); - } catch (ConflictingVersionException e) { - throw NetconfDocumentedException.wrap(e); - } logger.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);