Merge "Fixed bug when Binding-Aware Data Change Listeners we're not triggered."
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / netconf / impl / mapping / operations / DefaultCloseSession.java
1 /*
2  * Copyright (c) 2013 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.impl.mapping.operations;
10
11 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
12 import org.opendaylight.controller.netconf.api.NetconfOperationRouter;
13 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
14 import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation;
15 import org.opendaylight.controller.netconf.util.xml.XmlElement;
16 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
17 import org.w3c.dom.Document;
18 import org.w3c.dom.Element;
19
20 public class DefaultCloseSession extends AbstractNetconfOperation {
21     public static final String CLOSE_SESSION = "close-session";
22
23     public DefaultCloseSession(String netconfSessionIdForReporting) {
24         super(netconfSessionIdForReporting);
25     }
26
27     @Override
28     protected HandlingPriority canHandle(String operationName, String netconfOperationNamespace) {
29         if (operationName.equals(CLOSE_SESSION) == false)
30             return HandlingPriority.CANNOT_HANDLE;
31         if (netconfOperationNamespace.equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0) == false)
32             return HandlingPriority.CANNOT_HANDLE;
33
34         return HandlingPriority.HANDLE_WITH_MAX_PRIORITY;
35     }
36
37     /**
38      * Close netconf operation router associated to this session, which in turn
39      * closes NetconfOperationServiceSnapshot with all NetconfOperationService
40      * instances
41      */
42     @Override
43     protected Element handle(Document document, XmlElement operationElement, NetconfOperationRouter opRouter)
44             throws NetconfDocumentedException {
45         opRouter.close();
46         return document.createElement(XmlNetconfConstants.OK);
47     }
48 }