Initial code drop of netconf protocol implementation
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / operations / AbstractConfigNetconfOperation.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.confignetconfconnector.operations;
10
11 import org.opendaylight.controller.config.util.ConfigRegistryClient;
12 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
13 import org.opendaylight.controller.netconf.api.NetconfOperationRouter;
14 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
15 import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation;
16 import org.opendaylight.controller.netconf.util.xml.XmlElement;
17 import org.w3c.dom.Document;
18 import org.w3c.dom.Element;
19
20 public abstract class AbstractConfigNetconfOperation extends AbstractNetconfOperation {
21
22     protected final ConfigRegistryClient configRegistryClient;
23
24     protected AbstractConfigNetconfOperation(ConfigRegistryClient configRegistryClient,
25             String netconfSessionIdForReporting) {
26         super(netconfSessionIdForReporting);
27         this.configRegistryClient = configRegistryClient;
28     }
29
30     @Override
31     protected HandlingPriority canHandle(String operationName, String operationNamespace) {
32         // TODO check namespace
33         return operationName.equals(getOperationName()) ? HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY
34                 : HandlingPriority.CANNOT_HANDLE;
35     }
36
37     protected abstract String getOperationName();
38
39     @Override
40     protected Element handle(Document document, XmlElement operationElement, NetconfOperationRouter opRouter)
41             throws NetconfDocumentedException {
42         return handle(document, operationElement);
43     }
44
45     protected abstract Element handle(Document document, XmlElement operationElement) throws NetconfDocumentedException;
46 }