Package javax.ws.rs.core

Examples of javax.ws.rs.core.Cookie


    }

    private static Object processCookieParam(Message m, String cookieName,
                              Class<?> pClass, Type genericType,
                              Annotation[] paramAnns, String defaultValue) {
        Cookie c = new HttpHeadersImpl(m).getCookies().get(cookieName);
       
        if (c == null && defaultValue != null) {
            c = Cookie.valueOf(cookieName + '=' + defaultValue);
        }
        if (c == null) {
            return null;
        }
       
        if (pClass.isAssignableFrom(Cookie.class)) {
            return c;
        }
       
        return InjectionUtils.handleParameter(c.getValue(), false, pClass, paramAnns,
                                              ParameterType.COOKIE, m);
    }
View Full Code Here


        headers.putSingle(HttpHeaders.COOKIE, "$Version=1;a=b");
        m.put(Message.PROTOCOL_HEADERS, headers);
        HttpHeaders h = new HttpHeadersImpl(m);
        Map<String, Cookie> cookies = h.getCookies();
        assertEquals(1, cookies.size());
        Cookie cookie = cookies.get("a");
        assertEquals("b", cookie.getValue());
        assertEquals(1, cookie.getVersion());
    }
View Full Code Here

            }
            List<String> cs = value.contains("$")
                ? Collections.singletonList(value)
                : getHeaderValues(HttpHeaders.COOKIE, value, getCookieSeparator());
            for (String c : cs) {
                Cookie cookie = Cookie.valueOf(c);
                cl.put(cookie.getName(), cookie);
            }
        }
        return cl;
    }
View Full Code Here

    }

    private static Object processCookieParam(Message m, String cookieName,
                              Class<?> pClass, Type genericType,
                              Annotation[] paramAnns, String defaultValue) {
        Cookie c = new HttpHeadersImpl(m).getCookies().get(cookieName);
       
        if (c == null && defaultValue != null) {
            c = Cookie.valueOf(cookieName + '=' + defaultValue);
        }
        if (c == null) {
            return null;
        }
       
        if (pClass.isAssignableFrom(Cookie.class)) {
            return c;
        }
       
        return InjectionUtils.handleParameter(c.getValue(), false, pClass, paramAnns,
                                              ParameterType.COOKIE, m);
    }
View Full Code Here

            }
            List<String> cs = value.contains("$")
                ? Collections.singletonList(value)
                : getHeaderValues(HttpHeaders.COOKIE, value, getCookieSeparator());
            for (String c : cs) {
                Cookie cookie = Cookie.valueOf(c);
                cl.put(cookie.getName(), cookie);
            }
        }
        return cl;
    }
View Full Code Here

    @Produces("text/plain")
    public String getCookies(@Context HttpHeaders headers,
            @PathParam("cookieName") String cookieName) {
        final Map<String, Cookie> cookies = headers.getCookies();
        try {
            cookies.put("notAllowed", new Cookie("notAllowed", "value"));
            throw new WebApplicationException(Response.serverError().entity(
                    "could add cookie notAllowed").build());
        } catch (UnsupportedOperationException uoe) {
            // not allowed
        }
        try {
            cookies.put("xyz", new Cookie("notAllowed", "value"));
            throw new WebApplicationException(Response.serverError().entity(
                    "could add xyz").build());
        } catch (UnsupportedOperationException uoe) {
            // not allowed
        }
        final Cookie cookie = cookies.get(cookieName);
        if (cookie == null) {
            return null;
        }
        return cookie.toString();
    }
View Full Code Here

     */
    public Map<String, Cookie> getCookies() {
        if (this.cookies == null) {
            final Map<String, Cookie> cookies = new HashMap<String, Cookie>();
            for (final org.restlet.data.Cookie rc : this.request.getCookies()) {
                final Cookie cookie = Converter.toJaxRsCookie(rc);
                cookies.put(cookie.getName(), cookie);
            }
            this.cookies = Collections.unmodifiableMap(cookies);
        }
        return this.cookies;
    }
View Full Code Here

                final Collection<Cookie> coll = createColl();
                for (final org.restlet.data.Cookie rc : cookies) {
                    if (!rc.getName().equals(cookieName)) {
                        continue;
                    }
                    final Cookie cookie = Converter.toJaxRsCookie(rc);
                    if (coll == null) {
                        return cookie;
                    }
                    coll.add(cookie);
                }
                if (coll == null) {
                    return null;
                }
                if (coll.isEmpty()) {
                    final String value = this.defaultValue.value();
                    coll.add(new Cookie(cookieName, value));
                }
                if (this.isArray) {
                    return Util.toArray(coll, Cookie.class);
                }
                return coll;
View Full Code Here

    }

    private static Object processCookieParam(Message m, String cookieName,
                              Class<?> pClass, Type genericType,
                              Annotation[] paramAnns, String defaultValue) {
        Cookie c = new HttpHeadersImpl(m).getCookies().get(cookieName);
       
        if (c == null && defaultValue != null) {
            c = Cookie.valueOf(cookieName + '=' + defaultValue);
        }
        if (c == null) {
            return null;
        }
       
        if (pClass.isAssignableFrom(Cookie.class)) {
            return c;
        }
       
        return InjectionUtils.handleParameter(c.getValue(), false, pClass, paramAnns,
                                              ParameterType.COOKIE, m);
    }
View Full Code Here

    if(cookieStrings == null) {
      return null;
    }
   
    for (String cookieString : cookieStrings){
      Cookie cookie = cp.fromString(cookieString);
      cookies.put(cookie.getName(), cookie);   
    }
    return cookies;
  }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Cookie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.