Remove DocumentedException.ErrorTag
[netconf.git] / netconf / netconf-api / src / main / java / org / opendaylight / netconf / api / xml / XmlElement.java
index d65f4de0aeb9147ea5d6f7f717d5eeb195ce82c1..c4346ee7e1d59f990e2a95fca3d23dee39cdeee3 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Optional;
 import javax.xml.XMLConstants;
 import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -87,7 +88,7 @@ public final class XmlElement {
                 } else {
                     if (!attribKey.startsWith(XMLConstants.XMLNS_ATTRIBUTE + ":")) {
                         throw new DocumentedException("Attribute doesn't start with :",
-                                ErrorType.APPLICATION, DocumentedException.ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
+                                ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
                     }
                     prefix = attribKey.substring(XMLConstants.XMLNS_ATTRIBUTE.length() + 1);
                 }
@@ -108,9 +109,9 @@ public final class XmlElement {
 
     public void checkName(final String expectedName) throws UnexpectedElementException {
         if (!getName().equals(expectedName)) {
-            throw new UnexpectedElementException(String.format("Expected %s xml element but was %s", expectedName,
-                    getName()),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
+            throw new UnexpectedElementException(
+                    String.format("Expected %s xml element but was %s", expectedName, getName()),
+                    ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
         }
     }
 
@@ -119,7 +120,7 @@ public final class XmlElement {
         if (!getNamespaceAttribute().equals(expectedNamespace)) {
             throw new UnexpectedNamespaceException(
                     String.format("Unexpected namespace %s should be %s", getNamespaceAttribute(), expectedNamespace),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
+                    ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
         }
     }
 
@@ -128,7 +129,7 @@ public final class XmlElement {
         if (!getNamespace().equals(expectedNamespace)) {
             throw new UnexpectedNamespaceException(
                     String.format("Unexpected namespace %s should be %s", getNamespace(), expectedNamespace),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
+                    ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
         }
     }
 
@@ -289,7 +290,7 @@ public final class XmlElement {
         if (children.size() != 1) {
             throw new DocumentedException(String.format("One element %s:%s expected in %s but was %s", namespace,
                     childName, toString(), children.size()),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
+                    ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
         }
 
         return children.get(0);
@@ -299,7 +300,7 @@ public final class XmlElement {
         List<XmlElement> nameElements = getChildElements(childName);
         if (nameElements.size() != 1) {
             throw new DocumentedException("One element " + childName + " expected in " + toString(),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
+                    ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
         }
         return nameElements.get(0);
     }
@@ -307,9 +308,9 @@ public final class XmlElement {
     public XmlElement getOnlyChildElement() throws DocumentedException {
         List<XmlElement> children = getChildElements();
         if (children.size() != 1) {
-            throw new DocumentedException(String.format("One element expected in %s but was %s", toString(),
-                    children.size()),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
+            throw new DocumentedException(
+                    String.format("One element expected in %s but was %s", toString(), children.size()),
+                    ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
         }
         return children.get(0);
     }
@@ -327,7 +328,7 @@ public final class XmlElement {
             }
         }
         throw new DocumentedException(getName() + " should contain text.",
-                ErrorType.APPLICATION, DocumentedException.ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
+                ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
     }
 
     public Optional<String> getOnlyTextContentOptionally() {
@@ -345,7 +346,7 @@ public final class XmlElement {
         String attribute = element.getAttribute(XMLConstants.XMLNS_ATTRIBUTE);
         if (attribute.isEmpty() || attribute.equals(DEFAULT_NAMESPACE_PREFIX)) {
             throw new MissingNameSpaceException(String.format("Element %s must specify namespace", toString()),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
+                    ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
         }
         return attribute;
     }
@@ -371,7 +372,7 @@ public final class XmlElement {
         Optional<String> namespaceURI = getNamespaceOptionally();
         if (namespaceURI.isEmpty()) {
             throw new MissingNameSpaceException(String.format("No namespace defined for %s", this),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
+                    ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
         }
         return namespaceURI.get();
     }
@@ -438,7 +439,7 @@ public final class XmlElement {
         }
         if (!childElements.isEmpty()) {
             throw new DocumentedException(String.format("Unrecognised elements %s in %s", childElements, this),
-                    ErrorType.APPLICATION, DocumentedException.ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
+                    ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
         }
     }