本文整理汇总了Java中javax.ws.rs.core.CacheControl.setNoTransform方法的典型用法代码示例。如果您正苦于以下问题:Java CacheControl.setNoTransform方法的具体用法?Java CacheControl.setNoTransform怎么用?Java CacheControl.setNoTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.CacheControl
的用法示例。
在下文中一共展示了CacheControl.setNoTransform方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newResponseBuilder
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
final ResponseBuilder newResponseBuilder(final Status status, @Nullable final Object entity,
@Nullable final GenericType<?> type) {
Preconditions.checkState(this.context.variant != null);
final ResponseBuilder builder = Response.status(status);
if (entity != null) {
builder.entity(type == null ? entity : new GenericEntity<Object>(entity, type
.getType()));
builder.variant(this.context.variant);
final CacheControl cacheControl = new CacheControl();
cacheControl.setNoStore(true);
if ("GET".equalsIgnoreCase(this.request.getMethod())
|| "HEAD".equalsIgnoreCase(this.request.getMethod())) {
builder.lastModified(this.context.lastModified);
builder.tag(this.context.etag);
if (isCachingEnabled()) {
cacheControl.setNoStore(false);
cacheControl.setMaxAge(0); // always stale, must revalidate each time
cacheControl.setMustRevalidate(true);
cacheControl.setPrivate(getUsername() != null);
cacheControl.setNoTransform(true);
}
}
builder.cacheControl(cacheControl);
}
return builder;
}
示例2: createCacheControl
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
/**
* Converts a {@code Cache-Control} annotation to a {@code Cache-Control}
* Jersey API object.
*
* @param annotation the annotation
*
* @return the Jersey API object
*
* @see javax.ws.rs.core.CacheControl
* @see com.github.autermann.jersey.cache.CacheControl
*/
private CacheControl createCacheControl(
com.github.autermann.jersey.cache.CacheControl annotation) {
CacheControl cacheControl = new CacheControl();
cacheControl.setPrivate(annotation._private() ||
annotation.privateFields().length > 0);
cacheControl.getPrivateFields()
.addAll(Arrays.asList(annotation.privateFields()));
cacheControl.setMustRevalidate(annotation.mustRevalidate());
cacheControl.setNoCache(annotation.noCache() ||
annotation.noCacheFields().length > 0);
cacheControl.getNoCacheFields()
.addAll(Arrays.asList(annotation.noCacheFields()));
cacheControl.setNoStore(annotation.noStore());
cacheControl.setNoTransform(annotation.noTransform());
cacheControl.setProxyRevalidate(annotation.proxyRevalidate());
cacheControl.setMaxAge(annotation.maxAge());
cacheControl.setSMaxAge(annotation.sMaxAge());
for (CacheControlExtension e : annotation.extensions()) {
cacheControl.getCacheExtension().put(e.key(), e.value());
}
return cacheControl;
}
示例3: fromString
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@Override
public CacheControl fromString(final String value) {
if (value == null) {
return null;
}
final CacheControl result = new CacheControl();
result.setPrivate(true);
result.setNoTransform(false);
for (final String directive : value.split(",\\s+")) {
if (directive.startsWith("max-age=")) {
result.setMaxAge(Integer.parseInt(directive.split("=")[1]));
} else if (directive.equals("must-revalidate")) {
result.setMustRevalidate(true);
} else if (directive.equals("no-cache")) {
result.setNoCache(true);
} else if (directive.equals("no-store")) {
result.setNoStore(true);
} else if (directive.equalsIgnoreCase("no-transform")) {
result.setNoTransform(true);
} else if (directive.equals("private")) {
result.setPrivate(true);
} else if (directive.equals("proxy-revalidate")) {
result.setProxyRevalidate(true);
} else if (directive.equals("public")) {
result.setPrivate(false);
} else if (directive.startsWith("s-maxage=")) {
result.setSMaxAge(Integer.parseInt(directive.split("=")[1]));
}
}
return result;
}
示例4: testSerializeFull
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@Test
public void testSerializeFull() {
final CacheControl c = new CacheControl();
c.setMaxAge(100);
c.setMustRevalidate(true);
c.setNoCache(true);
c.setNoStore(true);
c.setNoTransform(false);
c.setPrivate(true);
c.setProxyRevalidate(true);
c.setSMaxAge(200);
assertEquals(
"private, max-age=100, s-maxage=200, must-revalidate, no-cache, no-store, proxy-revalidate",
d.toString(c));
}
示例5: applyCachePolicyToResponse
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
/**
* Apply cache policy to a response.
*
* @param response The response builder.
* @param eTag The ETag of the resource.
* @param lastModified The last modified date of the resource.
* @return The response builder with the cache policy.
*/
private static Response.ResponseBuilder applyCachePolicyToResponse(Response.ResponseBuilder response, EntityTag eTag, Date lastModified) {
CacheControl cc = new CacheControl();
cc.setMaxAge(CACHE_SECOND);
cc.setNoTransform(false);
cc.setPrivate(false);
Calendar expirationDate = Calendar.getInstance();
expirationDate.add(Calendar.SECOND, CACHE_SECOND);
return response.cacheControl(cc)
.expires(expirationDate.getTime())
.lastModified(lastModified)
.tag(eTag);
}
示例6: getMostPopularPurchases
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@GET
@Path("/{username}")
public Response getMostPopularPurchases(
@PathParam("username")
final String username,
@QueryParam("limit") @DefaultValue("5")
final int limit)
throws UserNotFoundException {
// Get the list from our service and build a Java-Generics JAX-RS friendly entity.
List<PopularPurchase> purchases = service.getMostPopularPurchases(username, limit);
GenericEntity<List<PopularPurchase>> entity =
new GenericEntity<List<PopularPurchase>>(purchases) {};
// I can rely on the per-element dependent hashCode List contract:
// http://docs.oracle.com/javase/8/docs/api/java/util/List.html#hashCode
EntityTag etag = new EntityTag(Integer.toString(purchases.hashCode()));
CacheControl cacheControl = new CacheControl();
cacheControl.setNoTransform(true);
// I am not using age-based caching, just ETag-based.
// cacheControl.setMaxAge((int) SECONDS.convert(1, DAYS));
ResponseBuilder maybeResponse = request.evaluatePreconditions(etag);
if (maybeResponse == null) {
return Response.ok(entity).tag(etag).cacheControl(cacheControl).build();
} else {
return maybeResponse.cacheControl(cacheControl).build();
}
}
示例7: createCacheControl
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
private static CacheControl createCacheControl(Cacheable cacheable) {
CacheControl cacheControl = new CacheControl();
cacheControl.setMaxAge(cacheable.maxAge());
cacheControl.setMustRevalidate(cacheable.mustRevalidate());
cacheControl.setNoCache(cacheable.noCache());
cacheControl.setNoStore(cacheable.noStore());
cacheControl.setNoTransform(cacheable.noTransform());
cacheControl.setPrivate(cacheable.privateFlag());
cacheControl.setProxyRevalidate(cacheable.proxyRevalidate());
cacheControl.setSMaxAge(cacheable.sMaxAge());
cacheControl.getNoCacheFields().addAll(Arrays.asList(cacheable.noCacheFields()));
cacheControl.getPrivateFields().addAll(Arrays.asList(cacheable.privateFields()));
return cacheControl;
}
示例8: response
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
private Response response(ResponseBuilder builder, OAuth2AuditLog oAuth2AuditLog) {
CacheControl cacheControl = new CacheControl();
cacheControl.setNoTransform(false);
cacheControl.setNoStore(true);
builder.cacheControl(cacheControl);
builder.header("Pragma", "no-cache");
applicationAuditLogger.sendMessage(oAuth2AuditLog);
return builder.build();
}
示例9: requestClientInfo
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
public Response requestClientInfo(String accessToken, String authorization, SecurityContext securityContext) {
if (authorization != null && !authorization.isEmpty() && authorization.startsWith("Bearer ")) {
accessToken = authorization.substring(7);
}
log.debug("Attempting to request Client Info, Access token = {}, Is Secure = {}",
new Object[] { accessToken, securityContext.isSecure() });
Response.ResponseBuilder builder = Response.ok();
if (!ClientInfoParamsValidator.validateParams(accessToken)) {
builder = Response.status(400);
builder.entity(errorResponseFactory.getErrorAsJson(ClientInfoErrorResponseType.INVALID_REQUEST));
} else {
AuthorizationGrant authorizationGrant = authorizationGrantList.getAuthorizationGrantByAccessToken(accessToken);
if (authorizationGrant == null) {
builder = Response.status(400);
builder.entity(errorResponseFactory.getErrorAsJson(ClientInfoErrorResponseType.INVALID_TOKEN));
} else {
CacheControl cacheControl = new CacheControl();
cacheControl.setPrivate(true);
cacheControl.setNoTransform(false);
cacheControl.setNoStore(true);
builder.cacheControl(cacheControl);
builder.header("Pragma", "no-cache");
builder.entity(getJSonResponse(authorizationGrant.getClient(),
authorizationGrant.getScopes()));
}
}
return builder.build();
}
示例10: buildCacheControl
import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
public CacheControl buildCacheControl() {
CacheControl cacheControl = new CacheControl();
cacheControl.setNoTransform(false); // Default is true
if (_maxAge.isPresent()) {
cacheControl.setMaxAge((int) _maxAge.get().toSeconds());
}
if (_sharedMaxAge.isPresent()) {
cacheControl.setSMaxAge((int) _maxAge.get().toSeconds());
}
if (_privateFields.size() > 0) {
cacheControl.setPrivate(true);
cacheControl.getPrivateFields().addAll(_privateFields);
}
if (_noCacheFields.size() > 0) {
cacheControl.setNoCache(true);
cacheControl.getNoCacheFields().addAll(_noCacheFields);
}
for (CacheControlFlag flag : _flags) {
switch (flag) {
case NO_CACHE:
cacheControl.setNoCache(true);
break;
case NO_STORE:
cacheControl.setNoStore(true);
break;
case MUST_REVALIDATE:
cacheControl.setMustRevalidate(true);
break;
case PROXY_REVALIDATE:
cacheControl.setProxyRevalidate(true);
break;
case NO_TRANSFORM:
cacheControl.setNoTransform(true);
break;
case PRIVATE:
cacheControl.setPrivate(true);
break;
case PUBLIC:
// public is not directly supported by the CacheControl object, so use extension map
cacheControl.getCacheExtension().put("public", "");
break;
default:
checkState(false, "Unhandled cache control flag: " + flag);
break;
}
}
// Although the docs don't state it explicitly, both null and empty string get converted to a bare directive
// for cache extensions.
cacheControl.getCacheExtension().putAll(_cacheExtensions);
return cacheControl;
}