X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fapi%2FNetconfDocumentedException.java;h=9cf78c930be985c47b373501d982d723b1408f3f;hb=refs%2Fchanges%2F13%2F23413%2F26;hp=1107572df1bda55be26504399697b7327f68636c;hpb=a92d9d6a21a0f6ca8d2153795721f500eaf29ee9;p=controller.git diff --git a/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfDocumentedException.java b/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfDocumentedException.java index 1107572df1..9cf78c930b 100644 --- a/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfDocumentedException.java +++ b/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfDocumentedException.java @@ -8,10 +8,9 @@ package org.opendaylight.controller.netconf.api; -import java.util.Collections; import java.util.Map; - -import org.opendaylight.protocol.framework.DocumentedException; +import org.opendaylight.controller.config.util.xml.DocumentedException; +import org.w3c.dom.Document; /** * Checked exception to communicate an error that needs to be sent to the @@ -19,93 +18,31 @@ import org.opendaylight.protocol.framework.DocumentedException; */ public class NetconfDocumentedException extends DocumentedException { - private static final long serialVersionUID = 1L; - - public enum ErrorType { - transport, rpc, protocol, application; - - public String getTagValue() { - return name(); - } - } - - public enum ErrorTag { - missing_attribute("missing-attribute"), unknown_element("unknown-element"), operation_not_supported( - "operation-not-supported"), bad_attribute("bad-attribute"), data_missing("data-missing"), operation_failed( - "operation-failed"), invalid_value("invalid-value"), malformed_message("malformed-message"); - - private final String tagValue; - - ErrorTag(final String tagValue) { - this.tagValue = tagValue; - } - - public String getTagValue() { - return this.tagValue; - } - } - - public enum ErrorSeverity { - error, warning; - - public String getTagValue() { - return name(); - } - } - - private final ErrorType errorType; - private final ErrorTag errorTag; - private final ErrorSeverity errorSeverity; - private final Map errorInfo; - - public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag, - final ErrorSeverity errorSeverity) { - this(message, errorType, errorTag, errorSeverity, Collections. emptyMap()); - } - - public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag, - final ErrorSeverity errorSeverity, final Map errorInfo) { + public NetconfDocumentedException(final String message) { super(message); - this.errorType = errorType; - this.errorTag = errorTag; - this.errorSeverity = errorSeverity; - this.errorInfo = errorInfo; - } - - public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType, - final ErrorTag errorTag, final ErrorSeverity errorSeverity) { - this(message, cause, errorType, errorTag, errorSeverity, Collections. emptyMap()); } - public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType, - final ErrorTag errorTag, final ErrorSeverity errorSeverity, final Map errorInfo) { - super(message, cause); - this.errorType = errorType; - this.errorTag = errorTag; - this.errorSeverity = errorSeverity; - this.errorInfo = errorInfo; + public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity) { + super(message, errorType, errorTag, errorSeverity); } - public ErrorType getErrorType() { - return this.errorType; + public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity, final Map errorInfo) { + super(message, errorType, errorTag, errorSeverity, errorInfo); } - public ErrorTag getErrorTag() { - return this.errorTag; + public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity) { + super(message, cause, errorType, errorTag, errorSeverity); } - public ErrorSeverity getErrorSeverity() { - return this.errorSeverity; + public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity, final Map errorInfo) { + super(message, cause, errorType, errorTag, errorSeverity, errorInfo); } - public Map getErrorInfo() { - return this.errorInfo; + public NetconfDocumentedException(DocumentedException e) { + super(e.getMessage(), e.getErrorType(), e.getErrorTag(), e.getErrorSeverity(), e.getErrorInfo()); } - @Override - public String toString() { - return "NetconfDocumentedException{" + "message=" + getMessage() + ", errorType=" + this.errorType - + ", errorTag=" + this.errorTag + ", errorSeverity=" + this.errorSeverity + ", errorInfo=" - + this.errorInfo + '}'; + public static NetconfDocumentedException fromXMLDocument( Document fromDoc) { + return new NetconfDocumentedException(DocumentedException.fromXMLDocument(fromDoc)); } }