5a980c44d3e80276979d5dcd9a08ca3e85c69e75
[controller.git] / opendaylight / netconf / mdsal-netconf-connector / src / main / java / org / opendaylight / controller / netconf / mdsal / connector / ops / Commit.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.netconf.mdsal.connector.ops;
10
11 import com.google.common.base.Optional;
12 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
13 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
14 import org.opendaylight.controller.netconf.mdsal.connector.TransactionProvider;
15 import org.opendaylight.controller.netconf.util.mapping.AbstractLastNetconfOperation;
16 import org.opendaylight.controller.netconf.util.xml.XmlElement;
17 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20 import org.w3c.dom.Document;
21 import org.w3c.dom.Element;
22
23 public class Commit extends AbstractLastNetconfOperation{
24
25     private static final Logger LOG = LoggerFactory.getLogger(Commit.class);
26
27     private static final String OPERATION_NAME = "commit";
28     private final TransactionProvider transactionProvider;
29
30     public Commit(final String netconfSessionIdForReporting, final TransactionProvider transactionProvider) {
31         super(netconfSessionIdForReporting);
32         this.transactionProvider = transactionProvider;
33
34     }
35
36     @Override
37     protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) throws NetconfDocumentedException {
38
39         boolean commitStatus = transactionProvider.commitTransaction();
40         LOG.trace("Transaction commited succesfuly {}", commitStatus);
41
42         return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
43     }
44
45     @Override
46     protected String getOperationName() {
47         return OPERATION_NAME;
48     }
49
50 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.