use of jakarta.ws.rs.core.NewCookie in project jaxrs-api by eclipse-ee4j.
the class ResponseTest method getHeaders.
@POST
@Path("headers")
public Response getHeaders(String headers) {
CacheControl ccl = new CacheControl();
NewCookie cookie = new NewCookie("cookie", "eikooc");
String encoding = "gzip";
Date date = Calendar.getInstance().getTime();
ResponseBuilder builder = Response.ok();
if (headers != null && headers.length() != 0) {
builder = builder.cacheControl(ccl).cookie(cookie).encoding(encoding).expires(date).language(Locale.CANADA_FRENCH);
}
return builder.build();
}
use of jakarta.ws.rs.core.NewCookie 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();
}
use of jakarta.ws.rs.core.NewCookie 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;
}
Aggregations