Update Tomas's name
[netconf.git] / protocol / netconf-server / src / main / java / org / opendaylight / netconf / server / api / operations / AbstractLastNetconfOperation.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 package org.opendaylight.netconf.server.api.operations;
9
10 import org.opendaylight.netconf.api.DocumentedException;
11 import org.opendaylight.netconf.api.xml.XmlElement;
12 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
13 import org.opendaylight.yangtools.yang.common.ErrorTag;
14 import org.opendaylight.yangtools.yang.common.ErrorType;
15 import org.w3c.dom.Document;
16 import org.w3c.dom.Element;
17
18 public abstract class AbstractLastNetconfOperation extends AbstractNetconfOperation {
19     protected AbstractLastNetconfOperation(final String netconfSessionIdForReporting) {
20         super(netconfSessionIdForReporting);
21     }
22
23     @Override
24     protected Element handle(final Document document, final XmlElement operationElement,
25                              final NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
26         if (!subsequentOperation.isExecutionTermination()) {
27             throw new DocumentedException(String.format(
28                     "No netconf operation expected to be subsequent to %s, but is %s", this, subsequentOperation),
29                     ErrorType.APPLICATION, ErrorTag.MALFORMED_MESSAGE, ErrorSeverity.ERROR);
30         }
31
32         return handleWithNoSubsequentOperations(document, operationElement);
33     }
34
35     @Override
36     protected HandlingPriority getHandlingPriority() {
37         return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
38     }
39
40     protected abstract Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement)
41         throws DocumentedException;
42 }