Search in sources :

Example 1 with NotSupportedException

use of jakarta.ws.rs.NotSupportedException in project resteasy by resteasy.

the class ClosedResponseHandlingResource method getNotSupportedTraced.

@Path("/testNotSupportedTraced")
@GET
public String getNotSupportedTraced(@Context UriInfo uriInfo) {
    URI endpoint415 = UriBuilder.fromUri(uriInfo.getRequestUri()).path("415").build();
    Client client = ClientBuilder.newClient();
    try {
        return client.target(endpoint415).request().get(String.class);
    } catch (NotSupportedException e) {
        throw new ClosedResponseHandlingPleaseMapException(e.getResponse());
    } finally {
        client.close();
    }
}
Also used : Client(jakarta.ws.rs.client.Client) NotSupportedException(jakarta.ws.rs.NotSupportedException) URI(java.net.URI) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 2 with NotSupportedException

use of jakarta.ws.rs.NotSupportedException in project incubator-hugegraph by apache.

the class TaskAPI method update.

@PUT
@Timed
@Path("{id}")
@Status(Status.ACCEPTED)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public Map<String, Object> update(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") long id, @QueryParam("action") String action) {
    LOG.debug("Graph [{}] cancel task: {}", graph, id);
    if (!ACTION_CANCEL.equals(action)) {
        throw new NotSupportedException(String.format("Not support action '%s'", action));
    }
    TaskScheduler scheduler = graph(manager, graph).taskScheduler();
    HugeTask<?> task = scheduler.task(IdGenerator.of(id));
    if (!task.completed() && !task.cancelling()) {
        scheduler.cancel(task);
        if (task.cancelling() || task.cancelled()) {
            return task.asMap();
        }
    }
    assert task.completed() || task.cancelling();
    throw new BadRequestException(String.format("Can't cancel task '%s' which is completed or cancelling", id));
}
Also used : BadRequestException(jakarta.ws.rs.BadRequestException) NotSupportedException(jakarta.ws.rs.NotSupportedException) TaskScheduler(com.baidu.hugegraph.task.TaskScheduler) Path(jakarta.ws.rs.Path) TaskStatus(com.baidu.hugegraph.task.TaskStatus) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) PUT(jakarta.ws.rs.PUT)

Example 3 with NotSupportedException

use of jakarta.ws.rs.NotSupportedException in project incubator-hugegraph by apache.

the class GraphsAPI method getConf.

@GET
@Timed
@Path("{name}/conf")
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed("admin")
public File getConf(@Context GraphManager manager, @PathParam("name") String name) {
    LOG.debug("Get graph configuration by name '{}'", name);
    HugeGraph g = graph4admin(manager, name);
    HugeConfig config = (HugeConfig) g.configuration();
    File file = config.file();
    if (file == null) {
        throw new NotSupportedException("Can't access the api in " + "a node which started with non local file config.");
    }
    return file;
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeConfig(com.baidu.hugegraph.config.HugeConfig) NotSupportedException(jakarta.ws.rs.NotSupportedException) File(java.io.File) Path(jakarta.ws.rs.Path) RolesAllowed(jakarta.annotation.security.RolesAllowed) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(jakarta.ws.rs.GET)

Example 4 with NotSupportedException

use of jakarta.ws.rs.NotSupportedException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorTest.

/*
   * @testName: constructorTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:343; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new unsupported media type exception.
   * 
   * getResponse
   */
@Test
public void constructorTest() throws Fault {
    NotSupportedException e = new NotSupportedException();
    assertResponse(e);
}
Also used : NotSupportedException(jakarta.ws.rs.NotSupportedException) Test(org.junit.jupiter.api.Test)

Example 5 with NotSupportedException

use of jakarta.ws.rs.NotSupportedException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringThrowableTest.

/*
   * @testName: constructorStringThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1093; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new unsupported media type exception.
   * 
   * getResponse
   */
public void constructorStringThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        NotSupportedException e = new NotSupportedException(MESSAGE, t);
        assertResponse(e);
        assertCause(e, t);
        assertMessage(e);
    }
}
Also used : IOException(java.io.IOException) NotSupportedException(jakarta.ws.rs.NotSupportedException)

Aggregations

NotSupportedException (jakarta.ws.rs.NotSupportedException)14 IOException (java.io.IOException)4 BadRequestException (jakarta.ws.rs.BadRequestException)3 NotAcceptableException (jakarta.ws.rs.NotAcceptableException)3 NotAllowedException (jakarta.ws.rs.NotAllowedException)3 Path (jakarta.ws.rs.Path)3 Timed (com.codahale.metrics.annotation.Timed)2 ClientErrorException (jakarta.ws.rs.ClientErrorException)2 ForbiddenException (jakarta.ws.rs.ForbiddenException)2 GET (jakarta.ws.rs.GET)2 InternalServerErrorException (jakarta.ws.rs.InternalServerErrorException)2 NotAuthorizedException (jakarta.ws.rs.NotAuthorizedException)2 NotFoundException (jakarta.ws.rs.NotFoundException)2 Produces (jakarta.ws.rs.Produces)2 ServerErrorException (jakarta.ws.rs.ServerErrorException)2 Response (jakarta.ws.rs.core.Response)2 HugeGraph (com.baidu.hugegraph.HugeGraph)1 Status (com.baidu.hugegraph.api.filter.StatusFilter.Status)1 HugeConfig (com.baidu.hugegraph.config.HugeConfig)1 TaskScheduler (com.baidu.hugegraph.task.TaskScheduler)1