Search in sources :

Example 1 with SimpleResponse

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;
}
Also used : MetricFilter(com.codahale.metrics.MetricFilter) SimpleResponse(org.openscoring.common.SimpleResponse) NotFoundException(javax.ws.rs.NotFoundException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) Metric(com.codahale.metrics.Metric) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces)

Example 2 with SimpleResponse

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");
}
Also used : SimpleResponse(org.openscoring.common.SimpleResponse)

Example 3 with SimpleResponse

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);
}
Also used : EvaluationResponse(org.openscoring.common.EvaluationResponse) BatchEvaluationResponse(org.openscoring.common.BatchEvaluationResponse) BatchModelResponse(org.openscoring.common.BatchModelResponse) ModelResponse(org.openscoring.common.ModelResponse) SimpleResponse(org.openscoring.common.SimpleResponse) Response(javax.ws.rs.core.Response)

Example 4 with SimpleResponse

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();
}
Also used : Response(javax.ws.rs.core.Response) SimpleResponse(org.openscoring.common.SimpleResponse) SimpleResponse(org.openscoring.common.SimpleResponse)

Example 5 with SimpleResponse

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);
}
Also used : Response(javax.ws.rs.core.Response) SimpleResponse(org.openscoring.common.SimpleResponse) Invocation(javax.ws.rs.client.Invocation) SimpleResponse(org.openscoring.common.SimpleResponse) WebTarget(javax.ws.rs.client.WebTarget)

Aggregations

SimpleResponse (org.openscoring.common.SimpleResponse)9 Response (javax.ws.rs.core.Response)6 Invocation (javax.ws.rs.client.Invocation)2 WebTarget (javax.ws.rs.client.WebTarget)2 BatchEvaluationResponse (org.openscoring.common.BatchEvaluationResponse)2 BatchModelResponse (org.openscoring.common.BatchModelResponse)2 EvaluationResponse (org.openscoring.common.EvaluationResponse)2 ModelResponse (org.openscoring.common.ModelResponse)2 Metric (com.codahale.metrics.Metric)1 MetricFilter (com.codahale.metrics.MetricFilter)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 DELETE (javax.ws.rs.DELETE)1 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1 NotFoundException (javax.ws.rs.NotFoundException)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1