Hello CÃdric,

Yes, I got it to work. I was on the right track when I wrote the original
message but I had managed to get the HttpURL needed for the reportMethod
incorrect. Here is a piece of code that might work:

public void testReportMethod()
{
  WebdavResource webdav = null;

  try
  {
    // Create a HttpURL to the Slide server
    HttpURL slideUrl = new HttpURL("http://localhost:8080/slide/";);
    // Set username and password
    slideUrl.setUserinfo("userName", "password");
    // Create the connection to the Slide server
    webdav = new WebdavResource(slideUrl);
    // Set the path to the file you want to get.
    webdav.setPath("/slide/files/test.txt");
    // Get the HttpURL to the file whose history you want.
    HttpURL historyUrl = webdav.getHttpURL();
    // Specify the history properties you need, if all you want is the
    // history path then leave the vector empty. There are a few more
    // properties not listed here.
    Vector versionProperties = new Vector();
    versionProperties.add(new PropertyName("DAV:", "version-name"));
    versionProperties.add(new PropertyName("DAV:", "creator-displayname"));
    versionProperties.add(new PropertyName("DAV:", "getlastmodified"));
    versionProperties.add(new PropertyName("DAV:", "getcontentlength"));
    versionProperties.add(new PropertyName("DAV:", "comment"));
    // Generate the report...
    Enumeration reportResults = 
      webdav.reportMethod(historyUrl, versionProperties);

    while ((reportResults != null) && reportResults.hasMoreElements())
    {
      Object reportElement = reportResults.nextElement();

      // The elements returned should be a String (I don't personally like
      // this, but that is the way it is. You can override the
"reportMethod"
      // methods in WebdavResource if you want to change this behaviour).
      if (reportElement instanceof String)
      {
        String properties = (String)reportElement;
        // The String is a newline separated string of the history path
        // (i.e. where in the Slide repository the version history of the
        // file is located) followed by all the properties you specified
above.
        // Each elemement in the enumeration represents a version of the
file.
        // Note that the elements are not in order so if you want, for
instance,
        // the third version of the file you would first have to sort the
        // elements somehow. 
        StringTokenizer tokenizer = new StringTokenizer(properties, "\n");

        if (tokenizer.countTokens() > 0)
        {
          String historyPath = tokenizer.nextToken();
          // Now you have the path to the one version of the file. It might
          // be a good idea to add it to a vector or so ...
        }
      }
    }            
  }
  catch (Exception e)
  {
  }
}

Please note that most of this code is written from the top of my head and
there is not guarantee that it will work right away, However, it should
provide you with a good starting point, and please ask for more details if
you need them.

/Pontus


-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] Behalf Of CÃdric
Sent: Thursday, December 16, 2004 2:57 PM
To: [EMAIL PROTECTED]
Subject: Re: How to get version information for a file (Newbie Question)



Hi, 

 Have you find a solution, because i have same trouble with the reportMethod
!
 Thanks a lot.

 CF French.








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to