return handleUncacheableOperation();
}
public void updateState(MethodReturn ret)
{
ResourceStateHandler resourceStateHandler = ResourceStateConfig.getResourceStateHandler();
if (ret.getCacheInfo() != null && (ret.getCacheInfo().isCacheEnabled() || ret.isEtagGenerationEnabled())) // only GET can declare cache
{
long dateModified;
long expires = 0;
String etag;
ResourceState resourceState = resourceStateHandler.get(key);
if (!ret.getCacheInfo().isCacheEnabled())
{
expires = (GET.ONE_DAY*1000)+System.currentTimeMillis();
}
if (resourceState != null && !resourceState.isExpired())
{
etag = resourceState.getEtag();
dateModified = resourceState.getDateModified();
if (ret.getCacheInfo().isCacheEnabled())
{
expires = ret.getCacheInfo().defineExpires(System.currentTimeMillis());
}
}
else
{
etag = generateEtag(ret.getReturn());
dateModified = System.currentTimeMillis();
if (ret.getCacheInfo().isCacheEnabled())
{
expires = ret.getCacheInfo().defineExpires(dateModified);
}
}
resourceStateHandler.add(key, dateModified, expires, etag);
ret.setDateModified(dateModified);
EntityTag entityTag = (etag != null)?new EntityTag(etag):null;
ret.setEtag(entityTag);
}
else
{
resourceStateHandler.remove(key);
}
}