Improved the notification.
Change-Id: Ieca1ed6e5b93758924bc4db9b4a6ec4e06230650
diff --git a/src/main/java/de/ids_mannheim/korap/KrillCollection.java b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
index 58761d7..82b0908 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
@@ -86,7 +86,7 @@
try {
JsonNode json = mapper.readTree(jsonString);
- if (json.has("errors") & json.get("errors").size()>0){
+ if (json.has("errors") && json.get("errors").size()>0){
this.addError(StatusCode.INVALID_QUERY,"Json has errors.");
}
else if (json.has("collection")){
diff --git a/src/main/java/de/ids_mannheim/korap/response/Notifications.java b/src/main/java/de/ids_mannheim/korap/response/Notifications.java
index 274ca09..0d788b3 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Notifications.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Notifications.java
@@ -239,6 +239,13 @@
return this;
};
+ public Notifications addError (int code, String[] terms) {
+ if (this.errors == null)
+ this.errors = new Messages();
+ this.errors.add(code, terms[0], Arrays.copyOfRange(terms, 1, terms.length));
+ return this;
+ }
+
public Notifications addError (StatusCode status, String msg, String ... terms) {
if (this.errors == null)
this.errors = new Messages();