
package propget;

/**
 * Title:        propget
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      Webware
 * @author Paulo Lopes
 * @version 1.0
 */

import java.util.*;
import org.apache.webdav.util.HttpURL;
import org.apache.webdav.util.WebdavResource;

public class Propget {

  Propget() {
  }


  public static void main (String args[]) throws Exception {

    String string_url = args [0];
    String uri = args [1];
    String property = args [2];

    System.out.println("address : " + string_url);
    System.out.println("uri : " + uri);
    System.out.println("property : " + property);

    HttpURL http_url = new HttpURL(string_url);

    WebdavResource webdav_resource = new WebdavResource(http_url);

    Vector properties = new Vector();
    properties.addElement(property);

    if (! string_url.endsWith("/"))
      string_url = string_url + "/";

    Enumeration property_values = webdav_resource.propfindMethod(string_url + uri, properties);

    System.out.print("Getting properties '" + (string_url + uri) + "': ");

    if (property_values.hasMoreElements()) {
      while (property_values.hasMoreElements()) {
        System.out.println(property_values.nextElement());
      }
    } else {
      System.err.println("failed.");
      System.err.println(webdav_resource.getStatusMessage());
    }

    webdav_resource.close();

  }

}