Decouple config and netconf subsystems.
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / operations / Commit.java
index 8a0830e48ad18c222b80db0d116b248af28a29ca..6e295580f92b3f50bd32777ab979d547a850c3da 100644 (file)
@@ -12,12 +12,12 @@ import com.google.common.base.Optional;
 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.config.facade.xml.ConfigSubsystemFacade;
+import org.opendaylight.controller.config.facade.xml.Datastore;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
 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.XmlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -27,15 +27,11 @@ public class Commit extends AbstractConfigNetconfOperation {
 
     private static final Logger LOG = LoggerFactory.getLogger(Commit.class);
 
-    private final TransactionProvider transactionProvider;
-
-    public Commit(TransactionProvider transactionProvider, ConfigRegistryClient configRegistryClient,
-            String netconfSessionIdForReporting) {
-        super(configRegistryClient, netconfSessionIdForReporting);
-        this.transactionProvider = transactionProvider;
+    public  Commit(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
+        super(configSubsystemFacade, netconfSessionIdForReporting);
     }
 
-    private static void checkXml(XmlElement xml) throws NetconfDocumentedException {
+    private static void checkXml(XmlElement xml) throws DocumentedException {
         xml.checkName(XmlNetconfConstants.COMMIT);
         xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
     }
@@ -46,15 +42,15 @@ public class Commit extends AbstractConfigNetconfOperation {
     }
 
     @Override
-    protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws NetconfDocumentedException {
+    protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
 
         checkXml(xml);
         CommitStatus status;
         try {
-            status = this.transactionProvider.commitTransaction();
+            status = getConfigSubsystemFacade().commitTransaction();
             LOG.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);
         } catch (ConflictingVersionException | ValidationException e) {
-            throw NetconfDocumentedException.wrap(e);
+            throw DocumentedException.wrap(e);
         }
         LOG.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);