Search in sources :

Example 76 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class Resource method getCookies.

@Path("getcookies")
@GET
public Response getCookies() {
    NewCookie cookie = new NewCookie(ResponseFilter.COOKIENAME, ResponseFilter.COOKIENAME);
    ResponseBuilder builder = createResponseWithHeader();
    Response response = builder.cookie(cookie).build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) NewCookie(jakarta.ws.rs.core.NewCookie) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 77 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class Resource method createResponseWithHeader.

// //////////////////////////////////////////////////////////////////
private ResponseBuilder createResponseWithHeader() {
    // get value of @Path(value)
    List<PathSegment> segments = info.getPathSegments();
    PathSegment last = segments.get(segments.size() - 1);
    // convert the value to ContextOperation
    ContextOperation op = ContextOperation.valueOf(last.getPath().toUpperCase());
    Response.ResponseBuilder builder = Response.ok();
    // set a header with ContextOperation so that the filter knows what to
    // do
    builder = builder.header(ResponseFilter.OPERATION, op.name());
    return builder;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) PathSegment(jakarta.ws.rs.core.PathSegment)

Example 78 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class Resource method setStatus.

@POST
@Path("setstatus")
public Response setStatus(String status) {
    ResponseBuilder builder = createResponseWithHeader();
    Response response = builder.entity(status).build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 79 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class Resource method getEntity.

@POST
@Path("getentity")
public Response getEntity(String entity) {
    ResponseBuilder builder = createResponseWithHeader();
    if (entity != null && entity.length() != 0)
        builder = builder.entity(entity.getBytes());
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 80 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class Resource method getEntityAnnotationsOnEntity.

@POST
@Path("getentityannotationsonentity")
public Response getEntityAnnotationsOnEntity(String entity) {
    ResponseBuilder builder = createResponseWithHeader();
    builder = builder.entity(new StringBeanWithAnnotation(entity));
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) StringBeanWithAnnotation(ee.jakarta.tck.ws.rs.common.provider.StringBeanWithAnnotation) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Aggregations

ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)80 Response (jakarta.ws.rs.core.Response)69 Path (jakarta.ws.rs.Path)41 Test (org.junit.jupiter.api.Test)34 POST (jakarta.ws.rs.POST)27 GET (jakarta.ws.rs.GET)14 Date (java.util.Date)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Annotation (java.lang.annotation.Annotation)4 VerificationResult (ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult)3 StringBean (ee.jakarta.tck.ws.rs.common.provider.StringBean)3 NewCookie (jakarta.ws.rs.core.NewCookie)3 RuntimeDelegate (jakarta.ws.rs.ext.RuntimeDelegate)3 IOException (java.io.IOException)3 StringBeanWithAnnotation (ee.jakarta.tck.ws.rs.common.provider.StringBeanWithAnnotation)2 Produces (jakarta.ws.rs.Produces)2 WebApplicationException (jakarta.ws.rs.WebApplicationException)2 EntityTag (jakarta.ws.rs.core.EntityTag)2 Link (jakarta.ws.rs.core.Link)2 InputStreamReader (java.io.InputStreamReader)2