use of org.openecard.addon.bind.ResponseBody in project open-ecard by ecsec.
the class HttpAppPluginActionHandler method addHTTPEntity.
private void addHTTPEntity(HttpResponse response, BindingResult bindingResult) {
ResponseBody responseBody = bindingResult.getBody();
if (responseBody != null && responseBody.hasValue()) {
LOG.debug("BindingResult contains a body.");
// determine content type
ContentType ct = ContentType.create(responseBody.getMimeType(), Charset.forName("UTF-8"));
StringEntity entity = new StringEntity(responseBody.getValue(), ct);
response.setEntity(entity);
// evaluate Base64 flag
if (responseBody.isBase64()) {
response.setHeader("Content-Transfer-Encoding", "Base64");
}
} else {
LOG.debug("BindingResult contains no body.");
if (bindingResult.getResultMessage() != null) {
ContentType ct = ContentType.create("text/plain", Charset.forName("UTF-8"));
StringEntity entity = new StringEntity(bindingResult.getResultMessage(), ct);
response.setEntity(entity);
}
}
}
Aggregations