[Lada-commits] [PATCH 5 of 5] Handle wrong parameter format and remove duplicate conditionals
Wald Commits
scm-commit at wald.intevation.org
Fri Dec 16 12:19:56 CET 2016
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1481886820 -3600
# Node ID e0b461d4cd8eab73e102f96e87062f0ea514c5f0
# Parent 86ef81592f67abe22be5a4e2c69236cfaa5a97bd
Handle wrong parameter format and remove duplicate conditionals.
diff -r 86ef81592f67 -r e0b461d4cd8e src/main/java/de/intevation/lada/rest/stamm/DeskriptorService.java
--- a/src/main/java/de/intevation/lada/rest/stamm/DeskriptorService.java Fri Dec 16 12:06:34 2016 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/DeskriptorService.java Fri Dec 16 12:13:40 2016 +0100
@@ -105,19 +105,19 @@
repository.entityManager("stamm"),
Deskriptoren.class);
builder.and("sn", 0).not();
- if (params.containsKey("layer") &&
- !params.containsKey("parents")) {
- String layer = params.getFirst("layer");
- builder.and("ebene", layer);
- }
- else {
- String layer = params.getFirst("layer");
- String parents = params.getFirst("parents");
- builder.and("ebene", layer);
- List<String> parentList = new ArrayList<String>();
- String[] parentArray = parents.split(", ");
- parentList = Arrays.asList(parentArray);
- builder.andIn("vorgaenger", parentList);
+ try {
+ builder.and("ebene",
+ Integer.valueOf(params.getFirst("layer")));
+ builder.and("ebene", params.getFirst("layer"));
+ if (params.containsKey("parents")) {
+ String parents = params.getFirst("parents");
+ List<String> parentList = new ArrayList<String>();
+ String[] parentArray = parents.split(", ");
+ parentList = Arrays.asList(parentArray);
+ builder.andIn("vorgaenger", parentList);
+ }
+ } catch (NumberFormatException nfe) {
+ return new Response(false, 612, null);
}
return repository.filter(builder.getQuery(), "stamm");
}
More information about the Lada-commits
mailing list