use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class Undeployer method run.
@Override
public void run() throws Exception {
SimpleResponse response = undeploy();
String message = (response != null ? response.getMessage() : null);
if (message != null) {
logger.warn("Undeployment failed: {}", message);
return;
}
logger.info("Undeployment succeeded");
}
use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class WebApplicationExceptionMapper method toResponse.
@Override
public Response toResponse(WebApplicationException exception) {
Response response = exception.getResponse();
Throwable throwable = exception;
for (Throwable cause = throwable.getCause(); (cause != null && cause != throwable); throwable = cause) {
// Empty block
}
String message = throwable.getMessage();
if (message == null || ("").equals(message)) {
Response.Status status = (Response.Status) response.getStatusInfo();
message = status.getReasonPhrase();
}
// End if
// Strip the HTTP status code prefix
message = message.replaceFirst("HTTP\\s(\\d)+\\s", "");
SimpleResponse entity = new SimpleResponse();
entity.setMessage(message);
return (Response.fromResponse(response).entity(entity).type(MediaType.APPLICATION_JSON)).build();
}
use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class CsvEvaluator method evaluate.
/**
* @return <code>null</code> If the operation was successful.
*/
public SimpleResponse evaluate() throws Exception {
Operation<SimpleResponse> operation = new Operation<SimpleResponse>() {
@Override
public SimpleResponse perform(WebTarget target) throws Exception {
String delimiterChar = getDelimiterChar();
String quoteChar = getQuoteChar();
if (delimiterChar != null) {
target = target.queryParam("delimiterChar", delimiterChar);
if (quoteChar != null) {
target = target.queryParam("quoteChar", quoteChar);
}
}
try (InputStream is = new FileInputStream(getInput())) {
try (OutputStream os = new FileOutputStream(getOutput())) {
Invocation invocation = target.request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN).buildPost(Entity.text(is));
Response response = invocation.invoke();
Response.StatusType status = response.getStatusInfo();
switch(status.getFamily()) {
case CLIENT_ERROR:
case SERVER_ERROR:
return response.readEntity(SimpleResponse.class);
default:
break;
}
try (InputStream result = response.readEntity(InputStream.class)) {
ByteStreams.copy(result, os);
return null;
}
}
}
}
};
return execute(operation);
}
use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class ModelResourceTest method undeployForm.
private SimpleResponse undeployForm(String id) {
Response response = target("model/" + id).request(MediaType.APPLICATION_JSON).header("X-HTTP-Method-Override", "DELETE").post(null);
assertEquals(200, response.getStatus());
return response.readEntity(SimpleResponse.class);
}
Aggregations