Remove RestconfError.ErrorType
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / restconf / impl / QueryParametersParser.java
index 783700bcba5f47bd6ba534a6843dae4e1a30f837..aea1864d414adda34e9ff45d6359fb3d3becad71 100644 (file)
@@ -12,8 +12,9 @@ import javax.ws.rs.core.UriInfo;
 import org.opendaylight.restconf.common.context.WriterParameters;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
+import org.opendaylight.yangtools.yang.common.ErrorType;
 
-public class QueryParametersParser {
+public final class QueryParametersParser {
 
     private enum UriParameters {
         PRETTY_PRINT("prettyPrint"),
@@ -31,6 +32,10 @@ public class QueryParametersParser {
         }
     }
 
+    private QueryParametersParser() {
+
+    }
+
     public static WriterParameters parseWriterParameters(final UriInfo info) {
         return parseParams(info, false);
     }
@@ -49,17 +54,17 @@ public class QueryParametersParser {
         String param = info.getQueryParameters(false).getFirst(UriParameters.DEPTH.toString());
         if (!Strings.isNullOrEmpty(param) && !"unbounded".equals(param)) {
             try {
-                final int depth = Integer.valueOf(param);
+                final int depth = Integer.parseInt(param);
                 if (depth < 1) {
                     throw new RestconfDocumentedException(
-                            new RestconfError(RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE,
+                            new RestconfError(ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE,
                             "Invalid depth parameter: " + depth, null,
                             "The depth parameter must be an integer > 1 or \"unbounded\""));
                 }
                 wpBuilder.setDepth(depth);
             } catch (final NumberFormatException e) {
-                throw new RestconfDocumentedException(new RestconfError(
-                        RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE,
+                throw new RestconfDocumentedException(e, new RestconfError(
+                        ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE,
                         "Invalid depth parameter: " + e.getMessage(), null,
                         "The depth parameter must be an integer > 1 or \"unbounded\""));
             }