Package org.cruxframework.crux.core.server.rest.state

Examples of org.cruxframework.crux.core.server.rest.state.ResourceStateHandler$ResourceState


    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);
    }
  }
View Full Code Here


   * Handle Cacheable GETS
   * @return
   */
  private MethodReturn handleCacheableOperation()
  {
    ResourceStateHandler resourceStateHandler = ResourceStateConfig.getResourceStateHandler();
    ResourceState resourceState = resourceStateHandler.get(key);
    if (resourceState == null)
    {
      return null;
    }
    else
View Full Code Here

   * Handle PUT/POST/DELETE/uncacheable GETs
   * @return
   */
  private MethodReturn handleUncacheableOperation()
  {
    ResourceStateHandler resourceStateHandler = ResourceStateConfig.getResourceStateHandler();
    ResourceState resourceState = resourceStateHandler.get(key);
    ConditionalResponse conditionalResponse = evaluatePreconditions(resourceState == null || resourceState.isExpired()?null:resourceState);
    if (conditionalResponse == null)
    {
      return null;
    }
View Full Code Here

TOP

Related Classes of org.cruxframework.crux.core.server.rest.state.ResourceStateHandler$ResourceState

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.