Search in sources :

Example 1 with ParamEntityWithFromString

use of ee.jakarta.tck.ws.rs.ee.rs.ParamEntityWithFromString in project jaxrs-api by eclipse-ee4j.

the class CookieParamTest method cookieParamHandling.

@GET
public Response cookieParamHandling(@QueryParam("todo") String todo, @CookieParam("name1") @DefaultValue("abc") String value, @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithConstructor") ParamEntityWithConstructor paramEntityWithConstructor, @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithFromString") ParamEntityWithFromString paramEntityWithFromString, @DefaultValue("CookieParamTest") @CookieParam("ParamEntityWithValueOf") ParamEntityWithValueOf paramEntityWithValueOf, @DefaultValue("CookieParamTest") @CookieParam("SetParamEntityWithFromString") Set<ParamEntityWithFromString> setParamEntityWithFromString, @DefaultValue("CookieParamTest") @CookieParam("SortedSetParamEntityWithFromString") SortedSet<ParamEntityWithFromString> sortedSetParamEntityWithFromString, @DefaultValue("CookieParamTest") @CookieParam("ListParamEntityWithFromString") List<ParamEntityWithFromString> listParamEntityWithFromString, @CookieParam("ParamEntityThrowingWebApplicationException") ParamEntityThrowingWebApplicationException paramEntityThrowingWebApplicationException, @CookieParam("ParamEntityThrowingExceptionGivenByName") ParamEntityThrowingExceptionGivenByName paramEntityThrowingExceptionGivenByName) {
    sb = new StringBuilder();
    Response.ResponseBuilder respb = Response.status(200);
    if (todo == null) {
        sb.append("todo=null");
    } else if (todo.equalsIgnoreCase("setCookie")) {
        String cookie_name = "name1";
        String cookie_value = "value1";
        Cookie ck = new Cookie(cookie_name, cookie_value);
        NewCookie nck = new NewCookie(ck);
        respb = respb.cookie(nck);
        sb.append("setCookie=done");
    } else if (todo.equalsIgnoreCase("verifycookie")) {
        sb.append("name1" + "=" + value);
        sb.append("verifyCookie=done");
    } else if (todo.equals("")) {
        setReturnValues(paramEntityWithConstructor, paramEntityWithFromString, paramEntityWithValueOf, setParamEntityWithFromString, sortedSetParamEntityWithFromString, listParamEntityWithFromString, "");
        setReturnValues(fieldParamEntityWithConstructor, fieldParamEntityWithFromString, fieldParamEntityWithValueOf, fieldSetParamEntityWithFromString, fieldSortedSetParamEntityWithFromString, fieldListParamEntityWithFromString, FIELD);
    } else if (todo.contains("ParamEntity")) {
        setNewCookie(respb, todo);
        setReturnValues(paramEntityWithConstructor, paramEntityWithFromString, paramEntityWithValueOf, setParamEntityWithFromString, sortedSetParamEntityWithFromString, listParamEntityWithFromString, "");
        setReturnValues(fieldParamEntityWithConstructor, fieldParamEntityWithFromString, fieldParamEntityWithValueOf, fieldSetParamEntityWithFromString, fieldSortedSetParamEntityWithFromString, fieldListParamEntityWithFromString, FIELD);
    } else {
        sb.append("other stuff");
    }
    return respb.entity(sb.toString()).build();
}
Also used : Response(jakarta.ws.rs.core.Response) NewCookie(jakarta.ws.rs.core.NewCookie) Cookie(jakarta.ws.rs.core.Cookie) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) ParamEntityWithFromString(ee.jakarta.tck.ws.rs.ee.rs.ParamEntityWithFromString) NewCookie(jakarta.ws.rs.core.NewCookie) GET(jakarta.ws.rs.GET)

Aggregations

ParamEntityWithFromString (ee.jakarta.tck.ws.rs.ee.rs.ParamEntityWithFromString)1 GET (jakarta.ws.rs.GET)1 Cookie (jakarta.ws.rs.core.Cookie)1 NewCookie (jakarta.ws.rs.core.NewCookie)1 Response (jakarta.ws.rs.core.Response)1 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)1