Java Code Examples for javax.ws.rs.core.CacheControl#setNoStore()

The following examples show how to use javax.ws.rs.core.CacheControl#setNoStore() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheControlBuilder.java    From everrest with Eclipse Public License 2.0 6 votes vote down vote up
public CacheControl build() {
    CacheControl cacheControl = new CacheControl();
    cacheControl.setMustRevalidate(mustRevalidate);
    cacheControl.setProxyRevalidate(proxyRevalidate);
    cacheControl.setMaxAge(maxAge);
    cacheControl.setSMaxAge(sMaxAge);
    cacheControl.setNoCache(noCache);
    cacheControl.setPrivate(privateFlag);
    cacheControl.setNoTransform(noTransform);
    cacheControl.setNoStore(noStore);
    if (privateFields != null) {
        cacheControl.getPrivateFields().addAll(privateFields);
    }
    if (noCacheFields != null) {
        cacheControl.getNoCacheFields().addAll(noCacheFields);
    }
    if (cacheExtension != null) {
        cacheControl.getCacheExtension().putAll(cacheExtension);
    }
    return cacheControl;
}
 
Example 2
Source File: ProcessorWebUtils.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
static Response.ResponseBuilder applyCacheControl(Response.ResponseBuilder response) {
    CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(true);
    cacheControl.setNoCache(true);
    cacheControl.setNoStore(true);
    return response.cacheControl(cacheControl);
}
 
Example 3
Source File: RuleResource.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private ResponseBuilder noCache(ResponseBuilder response) {
    CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(true);
    cacheControl.setNoCache(true);
    cacheControl.setNoStore(true);
    return response.cacheControl(cacheControl);
}
 
Example 4
Source File: ApplicationResource.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Edit the response headers to indicating no caching.
 *
 * @param response response
 * @return builder
 */
protected ResponseBuilder noCache(final ResponseBuilder response) {
    final CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(true);
    cacheControl.setNoCache(true);
    cacheControl.setNoStore(true);
    return response.cacheControl(cacheControl);
}
 
Example 5
Source File: ApplicationResource.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Edit the response headers to indicating no caching.
 *
 * @param response response
 * @return builder
 */
protected Response.ResponseBuilder noCache(final Response.ResponseBuilder response) {
    final CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(true);
    cacheControl.setNoCache(true);
    cacheControl.setNoStore(true);
    return response.cacheControl(cacheControl);
}
 
Example 6
Source File: MCRCacheFilter.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
private CacheControl getCacheConrol(MCRCacheControl cacheControlAnnotation) {
    CacheControl cc = new CacheControl();
    if (cacheControlAnnotation != null) {
        cc.setMaxAge(
            (int) cacheControlAnnotation.maxAge().unit().toSeconds(cacheControlAnnotation.maxAge().time()));
        cc.setSMaxAge(
            (int) cacheControlAnnotation.sMaxAge().unit().toSeconds(cacheControlAnnotation.sMaxAge().time()));
        Optional.ofNullable(cacheControlAnnotation.private_())
            .filter(MCRCacheControl.FieldArgument::active)
            .map(MCRCacheControl.FieldArgument::fields)
            .map(Stream::of)
            .ifPresent(s -> {
                cc.setPrivate(true);
                cc.getPrivateFields().addAll(s.collect(Collectors.toList()));
            });
        if (cacheControlAnnotation.public_()) {
            cc.getCacheExtension().put("public", null);
        }
        cc.setNoTransform(cacheControlAnnotation.noTransform());
        cc.setNoStore(cacheControlAnnotation.noStore());
        Optional.ofNullable(cacheControlAnnotation.noCache())
            .filter(MCRCacheControl.FieldArgument::active)
            .map(MCRCacheControl.FieldArgument::fields)
            .map(Stream::of)
            .ifPresent(s -> {
                cc.setNoCache(true);
                cc.getNoCacheFields().addAll(s.collect(Collectors.toList()));
            });
        cc.setMustRevalidate(cacheControlAnnotation.mustRevalidate());
        cc.setProxyRevalidate(cacheControlAnnotation.proxyRevalidate());
    } else {
        cc.setNoTransform(false); //should have been default
    }
    return cc;
}
 
Example 7
Source File: ProcessorWebUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
static Response.ResponseBuilder applyCacheControl(Response.ResponseBuilder response) {
    CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(true);
    cacheControl.setNoCache(true);
    cacheControl.setNoStore(true);
    return response.cacheControl(cacheControl);
}
 
Example 8
Source File: RuleResource.java    From nifi with Apache License 2.0 5 votes vote down vote up
private ResponseBuilder noCache(ResponseBuilder response) {
    CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(true);
    cacheControl.setNoCache(true);
    cacheControl.setNoStore(true);
    return response.cacheControl(cacheControl);
}
 
Example 9
Source File: ApplicationResource.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Edit the response headers to indicating no caching.
 *
 * @param response response
 * @return builder
 */
protected ResponseBuilder noCache(final ResponseBuilder response) {
    final CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(true);
    cacheControl.setNoCache(true);
    cacheControl.setNoStore(true);
    return response.cacheControl(cacheControl);
}
 
Example 10
Source File: CacheControlUtil.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static CacheControl noCache() {

        CacheControl cacheControl = new CacheControl();
        cacheControl.setMustRevalidate(true);
        cacheControl.setNoCache(true);
        cacheControl.setNoStore(true);

        return cacheControl;
    }
 
Example 11
Source File: CacheControlHeaderProvider.java    From cxf with Apache License 2.0 4 votes vote down vote up
public CacheControl fromString(String c) {
    boolean isPrivate = false;
    List<String> privateFields = new ArrayList<>();
    boolean noCache = false;
    List<String> noCacheFields = new ArrayList<>();
    boolean noStore = false;
    boolean noTransform = false;
    boolean mustRevalidate = false;
    boolean proxyRevalidate = false;
    int maxAge = -1;
    int sMaxAge = -1;
    Map<String, String> extensions = new HashMap<>();

    String[] tokens = getTokens(c);
    for (String rawToken : tokens) {
        String token = rawToken.trim();
        if (token.startsWith(MAX_AGE)) {
            maxAge = Integer.parseInt(token.substring(MAX_AGE.length() + 1));
        } else if (token.startsWith(SMAX_AGE)) {
            sMaxAge = Integer.parseInt(token.substring(SMAX_AGE.length() + 1));
        } else if (token.startsWith(PUBLIC)) {
            // ignore
        } else if (token.startsWith(NO_STORE)) {
            noStore = true;
        } else if (token.startsWith(NO_TRANSFORM)) {
            noTransform = true;
        } else if (token.startsWith(MUST_REVALIDATE)) {
            mustRevalidate = true;
        } else if (token.startsWith(PROXY_REVALIDATE)) {
            proxyRevalidate = true;
        } else if (token.startsWith(PRIVATE)) {
            isPrivate = true;
            addFields(privateFields, token);
        }  else if (token.startsWith(NO_CACHE)) {
            noCache = true;
            addFields(noCacheFields, token);
        } else {
            String[] extPair = token.split("=");
            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;
}