Updated handling errors from Koral and fixed tests.
Change-Id: I7ff3caa35d247b4707c11315cf2e653eed9a689b
diff --git a/core/Changes b/core/Changes
index 378a85e..9b7e5b6 100644
--- a/core/Changes
+++ b/core/Changes
@@ -1,8 +1,10 @@
# version 0.61.6
-06/02/2018
+06/02/2019
- Added default foundry for structure layer (margaretha)
- Added authentication to metadata controller (margaretha, issue #38)
- Updated search krill error handling (margaretha)
+18/02/2019
+ - Updated handling errors from Koral (margaretha)
# version 0.61.5
17/12/2018
diff --git a/core/pom.xml b/core/pom.xml
index 109ef97..e4e6694 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -227,7 +227,7 @@
<dependency>
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>Koral</artifactId>
- <version>[0.31,)</version>
+ <version>[0.33,)</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
diff --git a/core/src/main/java/de/ids_mannheim/korap/utils/KoralCollectionQueryBuilder.java b/core/src/main/java/de/ids_mannheim/korap/utils/KoralCollectionQueryBuilder.java
index aebfbf6..a6260cb 100644
--- a/core/src/main/java/de/ids_mannheim/korap/utils/KoralCollectionQueryBuilder.java
+++ b/core/src/main/java/de/ids_mannheim/korap/utils/KoralCollectionQueryBuilder.java
@@ -1,8 +1,8 @@
package de.ids_mannheim.korap.utils;
+import java.util.HashMap;
import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
+import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
@@ -12,7 +12,6 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.query.serialize.CollectionQueryProcessor;
import de.ids_mannheim.korap.response.Notifications;
-import de.ids_mannheim.korap.web.CoreResponseHandler;
import edu.emory.mathcs.backport.java.util.Arrays;
/**
@@ -31,9 +30,6 @@
private JsonNode base;
private StringBuilder builder;
private String mergeOperator;
- @Autowired
- private CoreResponseHandler responseHandler;
-
public KoralCollectionQueryBuilder () {
this(false);
@@ -113,21 +109,27 @@
new CollectionQueryProcessor(this.verbose);
tree.process(this.builder.toString());
if (tree.getErrors().size() > 0) {
- Notifications notif = new Notifications();
- int code;
+ // legacy support
for (List<Object> e : tree.getErrors()) {
- code = (int) e.get(0);
- if (e.get(1) instanceof String) {
- notif.addError(code, (String) e.get(1));
- }
- else {
+ if (e.get(1) instanceof String[]) {
+ Notifications notif = new Notifications();
+ int code = (int) e.get(0);
notif.addError(code, (String[]) e.get(1));
+ String notificationStr = notif.toJsonString();
+ throw new KustvaktException(StatusCodes.SERIALIZATION_FAILED,
+ notificationStr, true);
+ }
+ else{
+ break;
}
}
-
- String notificationStr = notif.toJsonString();
+ // -- end of legacy support
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("errors", tree.getErrors());
+ String errors = JsonUtils.toJSON(map);
throw new KustvaktException(StatusCodes.SERIALIZATION_FAILED,
- notificationStr, true);
+ errors, true);
}
request = JsonUtils.valueToTree(tree.getRequestMap());
}