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=8eaaecfbb4d90904e16f7853980ea872b81fb97b;hp=6391a1edad5755cbc97e315b4815356482e54067;hb=25a9fb7730311a5ca298d8c6c8b24f0afb0e27be;hpb=ca923718510fffbf66c2a0c6f41a3638d59495e9 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 6391a1edad..8eaaecfbb4 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 @@ -13,19 +13,16 @@ 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.api.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider; import org.opendaylight.controller.netconf.util.xml.XmlElement; -import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; +import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -import java.util.HashMap; -import java.util.Map; +import com.google.common.base.Optional; public class Commit extends AbstractConfigNetconfOperation { @@ -39,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); } @@ -50,29 +47,19 @@ public class Commit extends AbstractConfigNetconfOperation { } @Override - protected Element handle(Document document, XmlElement xml) throws NetconfDocumentedException { - checkXml(xml); + protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws NetconfDocumentedException { + checkXml(xml); CommitStatus status; try { status = this.transactionProvider.commitTransaction(); - } catch (final IllegalStateException e) { - // FIXME: when can IllegalStateException occur? - 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); - return document.createElement(XmlNetconfConstants.OK); + return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent()); } }