Remove DocumentedException.ErrorSeverity
[netconf.git] / netconf / netconf-util / src / main / java / org / opendaylight / netconf / util / mapping / 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.util.mapping;
9
10 import org.opendaylight.netconf.api.DocumentedException;
11 import org.opendaylight.netconf.api.xml.XmlElement;
12 import org.opendaylight.netconf.mapping.api.HandlingPriority;
13 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
14 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
15 import org.w3c.dom.Document;
16 import org.w3c.dom.Element;
17
18 public abstract class AbstractLastNetconfOperation extends AbstractNetconfOperation {
19
20     protected AbstractLastNetconfOperation(final String netconfSessionIdForReporting) {
21         super(netconfSessionIdForReporting);
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                     DocumentedException.ErrorType.APPLICATION,
31                     DocumentedException.ErrorTag.MALFORMED_MESSAGE,
32                     ErrorSeverity.ERROR);
33         }
34
35         return handleWithNoSubsequentOperations(document, operationElement);
36     }
37
38     @Override
39     protected HandlingPriority getHandlingPriority() {
40         return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
41     }
42
43     protected abstract Element handleWithNoSubsequentOperations(Document document,
44                                                                 XmlElement operationElement) throws DocumentedException;
45 }