aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/sl20
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-04-14 10:55:10 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-04-14 10:55:10 +0200
commit59d3d1c6e4c69055962fd652f057b0f15a2e3d4a (patch)
tree940dbff97c94f549ddba663d594e3ed785ef1fe3 /pdf-as-lib/src/main/java/at/gv/egiz/sl20
parent3257edead4eef7dd8a946ec0cdec46b7533706a5 (diff)
downloadpdf-as-4-59d3d1c6e4c69055962fd652f057b0f15a2e3d4a.tar.gz
pdf-as-4-59d3d1c6e4c69055962fd652f057b0f15a2e3d4a.tar.bz2
pdf-as-4-59d3d1c6e4c69055962fd652f057b0f15a2e3d4a.zip
log SL2.0 response in case of an non-parseable VDA response
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/sl20')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl20/utils/SL20JSONExtractorUtils.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl20/utils/SL20JSONExtractorUtils.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl20/utils/SL20JSONExtractorUtils.java
index 5fbce83b..8ed27e3c 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl20/utils/SL20JSONExtractorUtils.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl20/utils/SL20JSONExtractorUtils.java
@@ -12,6 +12,7 @@ import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.util.EntityUtils;
import org.jose4j.base64url.Base64Url;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -380,18 +381,26 @@ public class SL20JSONExtractorUtils {
}
private static JsonObject parseSL20ResultFromResponse(HttpEntity resp) throws Exception {
- if (resp != null && resp.getContent() != null) {
- JsonElement sl20Resp = new JsonParser().parse(new InputStreamReader(resp.getContent()));
- if (sl20Resp != null && sl20Resp.isJsonObject()) {
- return sl20Resp.getAsJsonObject();
+ if (resp != null && resp.getContent() != null) {
+ String htmlRespBody = EntityUtils.toString(resp);
+ try {
+ JsonElement sl20Resp = new JsonParser().parse(htmlRespBody);
+ if (sl20Resp != null && sl20Resp.isJsonObject()) {
+ return sl20Resp.getAsJsonObject();
- } else {
- log.warn("SL2.0 can NOT parse to a JSON object");
- throw new SLCommandoParserException();
+ } else {
+ log.warn("SL2.0 can NOT parse to a JSON object");
+ throw new SLCommandoParserException();
+
+ }
+
+ } catch (Exception e) {
+ log.info("Can NOT parse SL2.0 respone from VDA. Raw SL2.0 response: {}",
+ htmlRespBody);
+ throw new SLCommandoParserException(e);
}
-
-
+
} else {
log.warn("Can NOT find content in http response");
throw new SLCommandoParserException();