1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.waarp.openr66.protocol.http.rest.handler;
22
23 import com.fasterxml.jackson.databind.JsonNode;
24 import com.fasterxml.jackson.databind.node.ObjectNode;
25 import org.waarp.common.exception.InvalidArgumentException;
26 import org.waarp.common.utility.ParametersChecker;
27 import org.waarp.gateway.kernel.rest.RestArgument;
28
29 import java.util.Iterator;
30 import java.util.Map.Entry;
31
32
33
34
35 public class HttpRestV1Utils {
36 private HttpRestV1Utils() {
37
38 }
39
40
41
42
43
44
45
46
47 public static void checkSanity(final ObjectNode objectNode)
48 throws InvalidArgumentException {
49 final Iterator<Entry<String, JsonNode>> iterator = objectNode.fields();
50 while (iterator.hasNext()) {
51 final Entry<String, JsonNode> next = iterator.next();
52 ParametersChecker.checkSanityString(next.getValue().asText());
53 }
54 }
55
56
57
58
59
60
61
62
63 public static void checkSanity(final RestArgument argument)
64 throws InvalidArgumentException {
65 checkSanity(argument.getBody());
66 checkSanity(argument.getUriArgs());
67 }
68 }