use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class ModelResource method undeploy.
@DELETE
@Path("{id:" + ModelRegistry.ID_REGEX + "}")
@RolesAllowed(value = { "admin" })
@Produces(MediaType.APPLICATION_JSON)
public SimpleResponse undeploy(@PathParam("id") String id) {
Model model = this.modelRegistry.get(id);
if (model == null) {
throw new NotFoundException("Model \"" + id + "\" not found");
}
boolean success = this.modelRegistry.remove(id, model);
if (!success) {
throw new InternalServerErrorException("Concurrent modification");
}
final String prefix = createNamePrefix(id);
MetricFilter filter = new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
return name.startsWith(prefix);
}
};
this.metricRegistry.removeMatching(filter);
SimpleResponse response = new SimpleResponse();
return response;
}
use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class CsvEvaluator method run.
@Override
public void run() throws Exception {
SimpleResponse response = evaluate();
String message = (response != null ? response.getMessage() : null);
if (message != null) {
logger.warn("CSV evaluation failed: {}", message);
return;
}
logger.info("CSV evaluation succeeded");
}
use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class ModelResourceTest method undeploy.
private SimpleResponse undeploy(String id) {
Response response = target("model/" + id).request(MediaType.APPLICATION_JSON).delete();
assertEquals(200, response.getStatus());
assertNotNull(response.getHeaderString(Headers.SERVICE));
return response.readEntity(SimpleResponse.class);
}
use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class WebApplicationExceptionMapperTest method getMessage.
private static String getMessage(WebApplicationException exception) {
WebApplicationExceptionMapper exceptionMapper = new WebApplicationExceptionMapper();
Response response = exceptionMapper.toResponse(exception);
SimpleResponse entity = (SimpleResponse) response.getEntity();
return entity.getMessage();
}
use of org.openscoring.common.SimpleResponse in project openscoring by openscoring.
the class Undeployer method undeploy.
/**
* @return <code>null</code> If the operation was successful.
*/
public SimpleResponse undeploy() throws Exception {
Operation<SimpleResponse> operation = new Operation<SimpleResponse>() {
@Override
public SimpleResponse perform(WebTarget target) {
Invocation invocation = target.request(MediaType.APPLICATION_JSON).buildDelete();
Response response = invocation.invoke();
return response.readEntity(SimpleResponse.class);
}
};
return execute(operation);
}
Aggregations