Codota Logo
Resource.lastmodified
Code IndexAdd Codota to your IDE (free)

How to use
lastmodified
method
in
org.geoserver.platform.resource.Resource

Best Java code snippets using org.geoserver.platform.resource.Resource.lastmodified (Showing top 20 results out of 315)

  • Common ways to obtain Resource
private void myMethod () {
Resource r =
  • Codota IconGeoServerResourceLoader geoServerResourceLoader;String path;geoServerResourceLoader.get(path)
  • Codota IconResourceStore resourceStore;String path;resourceStore.get(path)
  • Codota IconFile file;Files.asResource(file)
  • Smart code suggestions by Codota
}
origin: geoserver/geoserver

@Override
public long lastmodified() {
  return delegate.lastmodified();
}
origin: geoserver/geoserver

@Override
public long lastModified() throws IOException {
  return resource.lastmodified();
}
origin: geoserver/geoserver

/** @return info about the watched file */
public String getFileInfo() {
  SimpleDateFormat sdf = new SimpleDateFormat();
  StringBuffer buff = new StringBuffer(path);
  buff.append(" last modified: ");
  buff.append(sdf.format(resource.lastmodified()));
  return buff.toString();
}
origin: geoserver/geoserver

  /**
   * Another method to avoid reloads if this object is registered
   *
   * @see GeoServerUserGroupService#registerUserGroupLoadedListener(UserGroupLoadedListener)
   */
  @Override
  public void usersAndGroupsChanged(UserGroupLoadedEvent event) {
    // avoid unnecessary reloads
    setLastModified(resource.lastmodified());
    LOGGER.info("Adjusted last modified for file: " + path);
  }
}
origin: geoserver/geoserver

/** Determines if the underlying file has been modified since the last check. */
public boolean isModified() {
  long now = System.currentTimeMillis();
  if ((now - lastCheck) > 1000) {
    lastCheck = now;
    stale =
        (resource.getType() != Type.UNDEFINED)
            && (resource.lastmodified() != lastModified);
  }
  return stale;
}
origin: geoserver/geoserver

  /**
   * Another method to avoid reloads if this object is registered
   *
   * @see GeoServerRoleService#registerRoleLoadedListener(RoleLoadedListener)
   */
  @Override
  public void rolesChanged(RoleLoadedEvent event) {
    // avoid reloads
    setLastModified(resource.lastmodified());
    LOGGER.info("Adjusted last modified for file: " + path);
  }
}
origin: geoserver/geoserver

/**
 * return true if a write lock is hold by this file watcher
 *
 * @throws IOException
 */
public boolean hasWriteLock() throws IOException {
  return Resources.exists(lockFile) && lockFile.lastmodified() == lockFileLastModified;
}
origin: geoserver/geoserver

/**
 * return true if a write lock is hold by another file watcher
 *
 * @throws IOException
 */
public boolean hasForeignWriteLock() throws IOException {
  return Resources.exists(lockFile) && lockFile.lastmodified() != lockFileLastModified;
}
origin: geoserver/geoserver

/** remove the lockfile */
public void writeUnLock() {
  if (Resources.exists(lockFile)) {
    if (lockFile.lastmodified() == lockFileLastModified) {
      lockFileLastModified = 0;
      lockFile.delete();
    } else {
      LOGGER.warning("Tried to unlock foreign lock: " + lockFile.path());
    }
  } else {
    LOGGER.warning("Tried to unlock not exisiting lock: " + lockFile.path());
  }
}
origin: geoserver/geoserver

/**
 * Search for resources using pattern and last modified time.
 *
 * @param resource Resource indicated
 * @param lastModified time stamp to search from
 * @return list of modified resources
 */
public static List<Resource> search(Resource resource, long lastModified) {
  if (resource.getType() == Type.DIRECTORY) {
    ArrayList<Resource> results = new ArrayList<Resource>();
    for (Resource child : resource.list()) {
      switch (child.getType()) {
        case RESOURCE:
          if (child.lastmodified() > lastModified) {
            results.add(child);
          }
          break;
        default:
          break;
      }
    }
    return results;
  }
  return Collections.emptyList();
}
origin: geoserver/geoserver

/**
 * Reads the file updating the last check timestamp.
 *
 * <p>Subclasses can override {@link #parseFileContents(InputStream)} to do something when the
 * file is read.
 *
 * @return parsed file contents
 */
public T read() throws IOException {
  T result = null;
  if (resource.getType() == Type.RESOURCE) {
    InputStream is = null;
    try {
      is = resource.in();
      result = parseFileContents(is);
      lastModified = resource.lastmodified();
      lastCheck = System.currentTimeMillis();
      stale = false;
    } finally {
      if (is != null) {
        is.close();
      }
    }
  }
  return result;
}
origin: geoserver/geoserver

/** Test constellation and call {@link #doOnChange()} if necessary */
protected void checkAndConfigure() {
  boolean fileExists;
  try {
    fileExists = resource.getType() == Type.RESOURCE;
  } catch (SecurityException e) {
    LOGGER.warning("Was not allowed to read check file existance, file:[" + path + "].");
    setTerminate(true); // there is no point in continuing
    return;
  }
  if (fileExists) {
    long l = resource.lastmodified(); // this can also throw a SecurityException
    if (testAndSetLastModified(l)) { // however, if we reached this point this
      doOnChange(); // is very unlikely.
      warnedAlready = false;
    }
  } else {
    if (!warnedAlready) {
      LOGGER.warning("[" + path + "] does not exist.");
      warnedAlready = true;
    }
  }
}
origin: geoserver/geoserver

/**
 * Try to get a lock
 *
 * @throws IOException
 */
public void writeLock() throws IOException {
  if (hasWriteLock()) return; // already locked
  if (Resources.exists(lockFile)) {
    LOGGER.warning("Cannot obtain  lock: " + lockFile.path());
    Properties props = new Properties();
    try (InputStream in = lockFile.in()) {
      props.load(in);
    }
    throw new IOException(Util.convertPropsToString(props, "Already locked"));
  } else { // success
    writeLockFileContent(lockFile);
    lockFileLastModified = lockFile.lastmodified();
    LOGGER.info("Successful lock: " + lockFile.path());
  }
}
origin: geoserver/geoserver

@Theory
public void theoryExtantHaveDate(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, defined());
  long result = res.lastmodified();
  assertThat(result, notNullValue());
}
origin: geoserver/geoserver

    new RoleFileWatcher(resource, service, resource.lastmodified());
service.registerRoleLoadedListener(watcher);
watcher.start();
origin: org.geoserver.extension/gs-wps-core

  public void run() {
    long newLastModified = configFile.lastmodified();
    if (lastModified == null || newLastModified != lastModified) {
      lastModified = newLastModified;
      loadConfiguration();
    }
  }
}
origin: org.geoserver/gs-gwc

  @Override
  public int compare(Resource o1, Resource o2) {
    return (int) (o1.lastmodified() - o2.lastmodified());
  }
});
origin: org.geoserver/gs-wms

  /** Returns true if the backing file does not exist any more, or has been modified */
  public boolean isStale() {
    return !Resources.exists(file) || (file.lastmodified() != lastModified);
  }
}
origin: org.geoserver.community/gs-jdbcstore

  @Theory
  public void theoryModifiedUpdated(String path) throws Exception {
    Resource res = getResource(path);

    assumeThat(res, not(directory()));

    long lastmod = res.lastmodified();

    OutputStream out = res.out();
    out.write(1234);
    out.close();

    assertTrue(res.lastmodified() > lastmod);
  }
}
origin: org.geoserver/gs-platform

@Theory
public void theoryExtantHaveDate(String path) throws Exception {
  Resource res = getResource(path);
  assumeThat(res, defined());
  long result = res.lastmodified();
  assertThat(result, notNullValue());
}
org.geoserver.platform.resourceResourcelastmodified

Javadoc

Time this resource was last modified.

Popular methods of Resource

  • out
  • getType
  • in
  • get
  • dir
  • file
  • path
  • delete
  • name
  • list
  • parent
  • addListener
  • parent,
  • addListener,
  • renameTo,
  • getContents,
  • removeListener,
  • load,
  • lock,
  • save,
  • setContents

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • putExtra (Intent)
  • orElseThrow (Optional)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • ImageIO (javax.imageio)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now