Use ErrorSeverity.elementBody() in RestconfError 35/107235/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Aug 2023 15:51:26 +0000 (17:51 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Aug 2023 16:33:06 +0000 (18:33 +0200)
ErrorSeverity provides the element body through a dedicated method, do
to use toLowerCase().

Change-Id: I5a036dc65de8b798f2dd0eb1121f27f00c4752c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6151f0444151183903debc231039dbf3183cd560)

restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/errors/RestconfError.java

index f44717bdf86bde647d2b17053ce090421b45575e..fbf66610efe66c29619735557e5747b0b081cea5 100644 (file)
@@ -9,9 +9,7 @@ package org.opendaylight.restconf.common.errors;
 
 import static java.util.Objects.requireNonNull;
 
-import java.io.Serial;
 import java.io.Serializable;
-import java.util.Locale;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcError;
@@ -28,7 +26,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
  *     See also <a href="https://tools.ietf.org/html/draft-bierman-netconf-restconf-02">RESTCONF</a>.
  */
 public class RestconfError implements Serializable {
-    @Serial
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
     private final ErrorType errorType;
@@ -149,8 +147,7 @@ public class RestconfError implements Serializable {
             if (rpcError.getCause() != null) {
                 localErrorInfo = rpcError.getCause().getMessage();
             } else if (rpcError.getSeverity() != null) {
-                localErrorInfo = "<severity>" + rpcError.getSeverity().toString().toLowerCase(Locale.ROOT)
-                        + "</severity>";
+                localErrorInfo = "<severity>" + rpcError.getSeverity().elementBody() + "</severity>";
             }
         } else {
             localErrorInfo = rpcError.getInfo();