X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2Fmapping%2Foperations%2FDefaultCommit.java;h=742255f973ca4eaebf79958e4c67d251e3a1b922;hp=d6940a1a453fcaaf14f4e6e30292f8dbc427256d;hb=6dfafe7c19c5e79bce2cb8aa2470b23360c08147;hpb=6dae254dbc2940d1f0f372d65d69b0e0dda415fe diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java index d6940a1a45..742255f973 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java @@ -9,34 +9,33 @@ package org.opendaylight.controller.netconf.impl.mapping.operations; import com.google.common.base.Preconditions; +import java.io.InputStream; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter; -import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer; +import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; +import org.opendaylight.controller.netconf.impl.CommitNotifier; import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider; +import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter; import org.opendaylight.controller.netconf.mapping.api.HandlingPriority; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution; import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation; 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.io.InputStream; - public class DefaultCommit extends AbstractNetconfOperation { - private static final Logger logger = LoggerFactory.getLogger(DefaultCommit.class); + private static final Logger LOG = LoggerFactory.getLogger(DefaultCommit.class); private static final String NOTIFY_ATTR = "notify"; - private final DefaultCommitNotificationProducer notificationProducer; + private final CommitNotifier notificationProducer; private final CapabilityProvider cap; private final NetconfOperationRouter operationRouter; - public DefaultCommit(DefaultCommitNotificationProducer notifier, CapabilityProvider cap, + public DefaultCommit(CommitNotifier notifier, CapabilityProvider cap, String netconfSessionIdForReporting, NetconfOperationRouter netconfOperationRouter) { super(netconfSessionIdForReporting); this.notificationProducer = notifier; @@ -64,16 +63,16 @@ public class DefaultCommit extends AbstractNetconfOperation { @Override public Document handle(Document requestMessage, NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException { - Preconditions.checkArgument(subsequentOperation.isExecutionTermination() == false, + Preconditions.checkArgument(!subsequentOperation.isExecutionTermination(), "Subsequent netconf operation expected by %s", this); if (isCommitWithoutNotification(requestMessage)) { - logger.debug("Skipping commit notification"); + LOG.debug("Skipping commit notification"); } else { // Send commit notification if commit was not issued by persister - requestMessage = removePersisterAttributes(requestMessage); + removePersisterAttributes(requestMessage); Element cfgSnapshot = getConfigSnapshot(operationRouter); - logger.debug("Config snapshot retrieved successfully {}", cfgSnapshot); + LOG.debug("Config snapshot retrieved successfully {}", cfgSnapshot); notificationProducer.sendCommitNotification("ok", cfgSnapshot, cap.getCapabilities()); } @@ -90,10 +89,8 @@ public class DefaultCommit extends AbstractNetconfOperation { return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.increasePriority(1); } - private Document removePersisterAttributes(Document message) { - final Element documentElement = message.getDocumentElement(); - documentElement.removeAttribute(NOTIFY_ATTR); - return message; + private void removePersisterAttributes(Document message) { + message.getDocumentElement().removeAttribute(NOTIFY_ATTR); } private boolean isCommitWithoutNotification(Document message) { @@ -102,16 +99,16 @@ public class DefaultCommit extends AbstractNetconfOperation { xmlElement = XmlElement.fromDomElementWithExpected(message.getDocumentElement(), XmlNetconfConstants.RPC_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); } catch (NetconfDocumentedException e) { - logger.trace("Commit operation is not valid due to {}",e); + LOG.trace("Commit operation is not valid due to ",e); return false; } String attr = xmlElement.getAttribute(NOTIFY_ATTR); - if (attr == null || attr.equals("")) + if (attr == null || attr.equals("")){ return false; - else if (attr.equals(Boolean.toString(false))) { - logger.debug("Commit operation received with notify=false attribute {}", message); + } else if (attr.equals(Boolean.toString(false))) { + LOG.debug("Commit operation received with notify=false attribute {}", message); return true; } else { return false;