Package org.apache.wicket.util.time

Examples of org.apache.wicket.util.time.Time


  public Time lastModifiedTime()
  {
    try
    {
      // get url modification timestamp
      final Time time = Connections.getLastModified(url);

      // if timestamp changed: update content length and last modified date
      if (Objects.equal(time, lastModified) == false)
      {
        lastModified = time;
View Full Code Here


    final Entry entry = modifiableToEntry.get(modifiable);

    // Found it?
    if (entry == null)
    {
      Time lastModifiedTime = modifiable.lastModifiedTime();
      if (lastModifiedTime != null)
      {
        // Construct new entry
        final Entry newEntry = new Entry();
View Full Code Here

        {
          final Entry entry = iter.next();

          // If the modifiable has been modified after the last known
          // modification time
          final Time modifiableLastModified = entry.modifiable.lastModifiedTime();
          if ((modifiableLastModified != null) &&
            modifiableLastModified.after(entry.lastModifiedTime))
          {
            // Notify all listeners that the modifiable was modified
            entry.listeners.notifyListeners();

            // Update timestamp
View Full Code Here

          // Get resource stream
          IResourceStream stream = resource.getResourceStream();

          // Get last modified time from stream
          Time time = stream.lastModifiedTime();

          try
          {
            stream.close();
          }
          catch (IOException e)
          {
            // ignore
          }

          return time != null ? time.getMilliseconds() : -1;
        }
      }
      catch (AbortException e)
      {
        return -1;
View Full Code Here

    RequestParameters requestParameters = new RequestParameters();
    requestParameters.setResourceKey(resourceReference.getSharedResourceKey());
    if (getApplication().getResourceSettings().getAddLastModifiedTimeToResourceReferenceUrl() &&
      !Strings.isEmpty(resourceReference.getName()))
    {
      Time time = resourceReference.lastModifiedTime();
      if (time != null)
      {
        if (parameters == null)
        {
          parameters = new ValueMap();
          parameters.put("wicket:lm", new Long(time.getMilliseconds()));
        }
      }
    }

    requestParameters.setParameters(parameters);
View Full Code Here

      return sendResourceError(resourceResponse, HttpServletResponse.SC_NOT_FOUND,
          "Unable to find resource");
    }

    // add Last-Modified header (to support HEAD requests and If-Modified-Since)
    final Time lastModified = resourceStream.lastModifiedTime();

    resourceResponse.setLastModified(lastModified);

    if (resourceResponse.dataNeedsToBeWritten(attributes))
    {
View Full Code Here

    if (response instanceof WebResponse)
    {
      WebResponse webResponse = (WebResponse)response;

      // 1. Last Modified
      Time lastModified = data.getLastModified();
      if (lastModified != null)
      {
        webResponse.setLastModifiedTime(lastModified);
      }
View Full Code Here

     *         <code>false</code> otherwise.
     */
    public boolean dataNeedsToBeWritten(Attributes attributes)
    {
      WebRequest request = (WebRequest)attributes.getRequest();
      Time ifModifiedSince = request.getIfModifiedSinceHeader();

      if (ifModifiedSince != null && lastModified != null)
      {
        // [Last-Modified] headers have a maximum precision of one second
        // so we have to truncate the milliseconds part for a proper compare.
        // that's stupid, since changes within one second will not be reliably
        // detected by the client ... any hint or clarification to improve this
        // situation will be appreciated...
        Time roundedLastModified = Time.millis(lastModified.getMilliseconds() / 1000 * 1000);

        return ifModifiedSince.before(roundedLastModified);
      }
      else
      {
View Full Code Here

      // set Content-Type (may be null)
      resourceResponse.setContentType(resourceStream.getContentType());

      // add Last-Modified header (to support HEAD requests and If-Modified-Since)
      final Time lastModified = resourceStream.lastModifiedTime();

      if (lastModified != null)
        resourceResponse.setLastModified(lastModified);

      try
View Full Code Here

  @Override
  protected ResourceResponse newResourceResponse(Attributes attributes)
  {
    ResourceResponse data = new ResourceResponse();
    Time lastModifiedTime = stream.lastModifiedTime();
    if (lastModifiedTime != null)
    {
      data.setLastModified(lastModifiedTime);
    }
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.time.Time

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.