3551d674d6b502e0de54d9d5b490ecafc4bf0239
[netconf.git] /
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.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
13 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
14 import org.opendaylight.yangtools.yang.common.ErrorTag;
15 import org.opendaylight.yangtools.yang.common.ErrorType;
16 import org.w3c.dom.Document;
17 import org.w3c.dom.Element;
18
19 public abstract class AbstractLastNetconfOperation extends AbstractNetconfOperation {
20     protected AbstractLastNetconfOperation(final SessionIdType sessionId) {
21         super(sessionId);
22     }
23
24     @Override
25     protected Element handle(final Document document, final XmlElement operationElement,
26                              final NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
27         if (!subsequentOperation.isExecutionTermination()) {
28             throw new DocumentedException(String.format(
29                     "No netconf operation expected to be subsequent to %s, but is %s", this, subsequentOperation),
30                     ErrorType.APPLICATION, ErrorTag.MALFORMED_MESSAGE, ErrorSeverity.ERROR);
31         }
32
33         return handleWithNoSubsequentOperations(document, operationElement);
34     }
35
36     @Override
37     protected HandlingPriority getHandlingPriority() {
38         return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
39     }
40
41     protected abstract Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement)
42         throws DocumentedException;
43 }