import com.google.common.base.Strings;
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"),
}
}
+ private QueryParametersParser() {
+
+ }
+
public static WriterParameters parseWriterParameters(final UriInfo info) {
return parseParams(info, false);
}
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\""));
}