Beispiel #1
0
  /** Contact the remote WebDAV server and fetch all properties. */
  private void reload(Location location) throws IOException {

    /* Do an OPTIONS over onto the location */
    location = this.options(location);

    /* Do a PROPFIND to figure out the properties and the children */
    final Iterator iterator = this.propfind(location).iterator();
    final Map children = new HashMap();
    while (iterator.hasNext()) {
      final Resource resource = (Resource) iterator.next();
      final Path path = resource.location.getPath();
      if (path.size() == 0) {
        resource.location = location.resolve(resource.location);
        this.resource = resource;
      } else if (path.size() == 1) {
        final Path.Element element = (Path.Element) path.get(0);
        if ("..".equals(element.getName())) continue;
        children.put(element.toString(), resource);
      }
    }

    /* Check if the current resource was discovered */
    if (this.resource == null) throw new IOException("Current resource not returned in PROOPFIND");

    /* Don't actually allow resources to be modified */
    this.children = Collections.unmodifiableMap(children);
  }