Skip to content
Snippets Groups Projects
Commit c3198408 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Fix for F5

parent 0e3853fb
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!596Resolve "Report bug utility issues"
Pipeline #8479 failed
package lcsb.mapviewer.api.minervanet;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import lcsb.mapviewer.model.user.ConfigurationElementType;
import lcsb.mapviewer.services.interfaces.IConfigurationService;
......@@ -50,11 +51,24 @@ public class MinervaNetController {
try (CloseableHttpResponse response = client.execute(post)) {
HttpEntity responseEntity = response.getEntity();
String responseBody = EntityUtils.toString(responseEntity, "UTF-8");
if (response.getStatusLine().getStatusCode() != 200) {
logger.error("Could not submit report to MinervaNet. Reason: " + responseBody);
if (response.getStatusLine().getStatusCode() != 200 || !responseBodyValid(responseBody)) {
String error = "Could not submit report to MinervaNet. Reason: " + responseBody;
logger.error(error);
throw new ReportSubmissionException(error);
}
}
}
}
private boolean responseBodyValid(String body) {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY);
try {
mapper.readTree(body);
} catch (IOException e) {
return false;
}
return true;
}
}
package lcsb.mapviewer.api.minervanet;
public class ReportSubmissionException extends RuntimeException {
public ReportSubmissionException() {
super();
}
public ReportSubmissionException(String message) {
super(message);
}
public ReportSubmissionException(String message, Throwable cause) {
super(message, cause);
}
public ReportSubmissionException(Throwable cause) {
super(cause);
}
protected ReportSubmissionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment