Search in sources :

Example 71 with ResponseBuilder

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

the class Resource method getLocation.

@POST
@Path("getlocation")
public Response getLocation(String uri) throws URISyntaxException {
    ResponseBuilder builder = createResponseWithHeader();
    if (uri != null && uri.length() != 0)
        builder = builder.location(new URI(uri));
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) URI(java.net.URI) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 72 with ResponseBuilder

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

the class Resource method getDate.

@POST
@Path("getdate")
public Response getDate(String text) {
    ResponseBuilder builder = createResponseWithHeader();
    if (text != null && text.length() != 0) {
        long milis = Long.valueOf(text);
        Date date = new Date(milis);
        builder = builder.header("Date", date);
    }
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Date(java.util.Date) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 73 with ResponseBuilder

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

the class Resource method getHeadersIsMutable.

@GET
@Path("getheadersismutable")
public Response getHeadersIsMutable() {
    ResponseBuilder builder = createResponseWithHeader();
    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) GET(jakarta.ws.rs.GET)

Example 74 with ResponseBuilder

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

the class Resource method hasEntity.

@POST
@Path("hasentity")
public Response hasEntity(String entity) {
    ResponseBuilder builder = createResponseWithHeader();
    if (entity != null && entity.length() != 0)
        builder = builder.entity(entity);
    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 75 with ResponseBuilder

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

the class Resource method getHeaderStringByHeader.

@POST
@Path("getheaderstringheader")
public Response getHeaderStringByHeader(String content) {
    ResponseBuilder builder = createResponseWithHeader();
    if (content.equals("toString"))
        builder = builder.header(ResponseFilter.HEADER, new StringBuilder().append(ResponseFilter.ENTITY));
    if (content.equals("commaSeparated")) {
        builder = builder.header(ResponseFilter.HEADER, new StringBuilder().append(ResponseFilter.ENTITY));
        builder = builder.header(ResponseFilter.HEADER, ResponseFilter.ENTITY);
    }
    if (content.equals("headerDelegate")) {
        StringBean bean = new StringBean(ResponseFilter.ENTITY);
        builder = builder.header(ResponseFilter.HEADER, bean);
    }
    if (content.equalsIgnoreCase("entity"))
        builder = builder.header(ResponseFilter.HEADER, content);
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) StringBean(ee.jakarta.tck.ws.rs.common.provider.StringBean) 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