2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.common;
10 import static java.util.Objects.requireNonNull;
12 import java.io.Serializable;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.eclipse.jdt.annotation.Nullable;
17 * Extensible enumeration of {@code error-tag} values, as defined in
18 * <a href="https://datatracker.ietf.org/doc/html/rfc6241#appendix-A">RFC6241</a>. These values are an extensible
19 * enumeration, since YANG does not place restriction on possible values in
20 * <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-3.9">RFC8040</a>.
23 * Error tag defines overall error semantics. Additional tag-specific information may be associated with a particular
27 public final class ErrorTag implements Serializable {
29 * {@code access-denied} {@link ErrorTag}.
31 public static final ErrorTag ACCESS_DENIED = new ErrorTag("access-denied");
33 * {@code bad-attribute} {@link ErrorTag}. Covers mechanics specified in RFC6020 section 8.3.1, bullet 6
35 * For insert handling, if the value for the attributes "before" and
36 * "after" are not valid for the type of the appropriate key leafs,
37 * the server MUST reply with a "bad-attribute" error-tag in the rpc-
41 public static final ErrorTag BAD_ATTRIBUTE = new ErrorTag("bad-attribute");
43 * {@code bad-element} {@link ErrorTag}. Covers mechanics specified in RFC6020 section 8.3.1, bullet 3
45 * If data for more than one case branch of a choice is present, the
46 * server MUST reply with a "bad-element" in the rpc-error.
49 public static final ErrorTag BAD_ELEMENT = new ErrorTag("bad-element");
51 * {@code data-exists} {@link ErrorTag}.
53 public static final ErrorTag DATA_EXISTS = new ErrorTag("data-exists");
55 * {@code data-missing} {@link ErrorTag}. Covers mechanics specified in RFC6020 sections 13.5 through 13.7.
57 public static final ErrorTag DATA_MISSING = new ErrorTag("data-missing");
59 * {@code in-use} {@link ErrorTag}.
61 public static final ErrorTag IN_USE = new ErrorTag("in-use");
63 * {@code invalid-value} {@link ErrorTag}. Covers mechanics specified in RFC6020 section 8.3.1, bullet 1
65 * If a leaf data value does not match the type constraints for the
66 * leaf, including those defined in the type's "range", "length", and
67 * "pattern" properties, the server MUST reply with an
68 * "invalid-value" error-tag in the rpc-error, and with the error-
69 * app-tag and error-message associated with the constraint, if any
73 public static final ErrorTag INVALID_VALUE = new ErrorTag("invalid-value");
75 * {@code lock-denied} {@link ErrorTag}.
77 public static final ErrorTag LOCK_DENIED = new ErrorTag("lock-denied");
79 * {@code unknown-element} {@link ErrorTag}. Covers mechanics specified in
80 * <a href="https://datatracker.ietf.org/doc/html/rfc6241#page-80">RFC6241, Appendix A, last item</a>. Note the
81 * specification expressly forbids reporting this tag for NETCONF clients older than {@code :base:1.1}.
83 public static final ErrorTag MALFORMED_MESSAGE = new ErrorTag("malformed-message");
85 * {@code missing-attribute} {@link ErrorTag}.
87 public static final ErrorTag MISSING_ATTRIBUTE = new ErrorTag("missing-attribute");
89 * {@code missing-element} {@link ErrorTag}. Covers mechanics specified in RFC6020 section 8.3.1, bullet 2
91 * If all keys of a list entry are not present, the server MUST reply
92 * with a "missing-element" error-tag in the rpc-error.
94 * as well as RFC6020 section 7.13.2, paragraph 2
96 * If a leaf in the input tree has a "mandatory" statement with the
97 * value "true", the leaf MUST be present in a NETCONF RPC invocation.
98 * Otherwise, the server MUST return a "missing-element" error.
101 public static final ErrorTag MISSING_ELEMENT = new ErrorTag("missing-element");
103 * {@code operation-failed} {@link ErrorTag}. Covers mechanics specified in RFC6020 section 13.1 through 13.4.
105 public static final ErrorTag OPERATION_FAILED = new ErrorTag("operation-failed");
107 * {@code operation-not-supported} {@link ErrorTag}.
109 public static final ErrorTag OPERATION_NOT_SUPPORTED = new ErrorTag("operation-not-supported");
111 * {@code partial-operation} {@link ErrorTag}.
112 * @deprecated This error-info is obsolete since RFC6241.
114 @Deprecated(since = "RFC6241")
115 public static final ErrorTag PARTIAL_OPERATION = new ErrorTag("partial-operation");
117 * {@code resource-denied} {@link ErrorTag}.
119 public static final ErrorTag RESOURCE_DENIED = new ErrorTag("resource-denied");
121 * {@code rollback-failed} {@link ErrorTag}.
123 public static final ErrorTag ROLLBACK_FAILED = new ErrorTag("rollback-failed");
125 * {@code too-big} {@link ErrorTag}.
127 public static final ErrorTag TOO_BIG = new ErrorTag("too-big");
129 * {@code unknown-element} {@link ErrorTag}. Covers mechanics specified in RFC6020 section 8.3.1, bullet 7
131 * If the attributes "before" and "after" appears in any element that
132 * is not a list whose "ordered-by" property is "user", the server
133 * MUST reply with an "unknown-attribute" error-tag in the rpc-error.
136 public static final ErrorTag UNKNOWN_ATTRIBUTE = new ErrorTag("unknown-attribute");
138 * {@code unknown-element} {@link ErrorTag}. Covers mechanics specified in RFC6020 section 8.3.1, bullet 4
140 * If data for a node tagged with "if-feature" is present, and the
141 * feature is not supported by the device, the server MUST reply with
142 * an "unknown-element" error-tag in the rpc-error.
144 * as well as RFC6020 section 8.3.1, bullet 5
146 * If data for a node tagged with "when" is present, and the "when"
147 * condition evaluates to "false", the server MUST reply with an
148 * "unknown-element" error-tag in the rpc-error.
151 public static final ErrorTag UNKNOWN_ELEMENT = new ErrorTag("unknown-element");
153 * {@code unknown-namespace} {@link ErrorTag}.
155 public static final ErrorTag UNKNOWN_NAMESPACE = new ErrorTag("unknown-namespace");
157 private static final long serialVersionUID = 1L;
159 private final String elementBody;
161 public ErrorTag(final String elementBody) {
162 this.elementBody = requireNonNull(elementBody);
166 * Return the XML element body of this object.
168 * @return element body of this object
170 public String elementBody() {
175 public int hashCode() {
176 return elementBody.hashCode();
180 public boolean equals(final @Nullable Object obj) {
181 return obj == this || obj instanceof ErrorTag other && elementBody.equals(other.elementBody);
185 public String toString() {
189 Object writeReplace() {
190 return new ETv1(this);