Package javax.ws.rs.core

Examples of javax.ws.rs.core.CacheControl


                String value = extPair.length == 2 ? extPair[1] : "";
                extensions.put(extPair[0], value);
            }
        }
       
        CacheControl cc = new CacheControl();
        cc.setMaxAge(maxAge);
        cc.setSMaxAge(sMaxAge);
        cc.setPrivate(isPrivate);
        cc.getPrivateFields().addAll(privateFields);
        cc.setMustRevalidate(mustRevalidate);
        cc.setProxyRevalidate(proxyRevalidate);
        cc.setNoCache(noCache);
        cc.getNoCacheFields().addAll(noCacheFields);
        cc.setNoStore(noStore);
        cc.setNoTransform(noTransform);
        cc.getCacheExtension().putAll(extensions);
       
        return cc;
    }
View Full Code Here


            vars.put("Global",          manager.getGlobalModel());
            vars.put("Explorers",       manager);
        }
       
        try {
            CacheControl cc = new CacheControl();
            cc.setMaxAge(MAX_AGE.get());
            cc.setNoCache(false);
            return Response
                .ok(SharedFreemarker.getInstance().render(subResources + ".ftl", vars), mediaType)
                .cacheControl(cc)
                .expires(new Date(System.currentTimeMillis() + 3600 * 1000))
                .tag(new String(Hex.encodeHex(MessageDigest.getInstance("MD5").digest(subResources.getBytes()))))
View Full Code Here

       
    if (buffer == null)
      throw new NotFoundException();
    else  {
      if (CACHE_ENABLED.get()) {
        CacheControl cc = new CacheControl();
        cc.setMaxAge(MAX_AGE.get());
        cc.setNoCache(false);
        return Response
            .ok(buffer, mediaType)
            .cacheControl(cc)
            .expires(new Date(System.currentTimeMillis() + 3600 * 1000))
            .tag(new String(Hex.encodeHex(MessageDigest.getInstance("MD5").digest(subResources.getBytes()))))
View Full Code Here

    @Test
    public void forCacheControl() {
        final Parser<CacheControl> parser = Parser.forCacheControl();

        final CacheControl cc1 = createCacheControl();
        cc1.setMaxAge(2000);
        final CacheControl cc2 = createCacheControl();
        cc2.setNoCache(true);
        for (final CacheControl v : new CacheControl[] { cc1, cc2 }) {
            final String asString = parser.asString(v);
            final CacheControl valueOf = parser.valueOf(asString);
            assertThat(v.getMaxAge(), is(equalTo(valueOf.getMaxAge())));
            assertThat(v.isNoCache(), is(equalTo(valueOf.isNoCache())));
        }
    }
View Full Code Here

            assertThat(v.isNoCache(), is(equalTo(valueOf.isNoCache())));
        }
    }

    private static CacheControl createCacheControl() {
        final CacheControl cacheControl = new CacheControl();
        cacheControl.getCacheExtension(); // workaround for bug in
                                          // CacheControl's equals() method
        cacheControl.getNoCacheFields(); // workaround for bug in CacheControl's
                                         // equals() method
        return cacheControl;
    }
View Full Code Here

        assertThat(contentType, hasSubType("json"));
        assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects/homepage"));
        assertThat(contentType, is(RepresentationType.HOME_PAGE.getMediaType()));

        // then
        final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
        assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
        assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
    }
View Full Code Here

        assertThat(contentType, hasSubType("json"));
        assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects/user"));
        assertThat(contentType, is(RepresentationType.USER.getMediaType()));

        // then
        final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
        assertThat(cacheControl, hasMaxAge(60 * 60));
        assertThat(cacheControl.getMaxAge(), is(60 * 60));
    }
View Full Code Here

        assertThat(contentType, hasSubType("json"));
        assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects/version"));
        assertThat(contentType, is(RepresentationType.VERSION.getMediaType()));

        // then
        final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
        assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
        assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
    }
View Full Code Here

        serializer.serialize(System.out, userNode.getGraph(), SupportedFormat.TURTLE);
       
        URI pageUri = uriInfo.getBaseUriBuilder().path("/system/console").build();
       
        // header Cache-control: no-cache, just in case intermediaries are holding onto old stuff
        CacheControl cc = new CacheControl();
        cc.setNoCache(true);
       
        // see other my not be the best response, but does seem the best given the jax-rs things available
        return Response.seeOther(pageUri).cacheControl(cc).build();
  }
View Full Code Here

      if (sent == null) System.out.println("No If-None-Match sent by client");

      EntityTag tag = new EntityTag(Integer.toString(cust.hashCode()));

      CacheControl cc = new CacheControl();
      cc.setMaxAge(5);


      Response.ResponseBuilder builder = request.evaluatePreconditions(tag);
      if (builder != null)
      {
View Full Code Here

TOP

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

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.