/**
  * Gets the elapsed duration since this application was initialized.
  *
  * @return the uptime
  */
 public Duration getUptime() {
   final DateTime startup = getStartupDate();
   if (null != startup) {
     return Duration.elapsed(Time.valueOf(startup.toDate()));
   }
   return Duration.NONE;
 }
示例#2
0
  /**
   * Sets the last-modified header field and the expires field.
   *
   * @param when
   */
  protected final void setLastModified(Date when) {
    if (when == null) {
      return;
    }

    if (when.before(app().getBootDate())) {
      // last-modified can not be before the Gitblit boot date
      // this helps ensure that pages are properly refreshed after a
      // server config change
      when = app().getBootDate();
    }

    int expires = app().settings().getInteger(Keys.web.pageCacheExpires, 0);
    WebResponse response = (WebResponse) getResponse();
    response.setLastModifiedTime(Time.valueOf(when));
    response.setDateHeader(
        "Expires", System.currentTimeMillis() + Duration.minutes(expires).getMilliseconds());
  }