public static long getLastModified(HttpClient client, HttpURL url)
throws IOException, HttpException
{
Vector props = new Vector(1);
props.add(GETLASTMODIFIED);
PropFindMethod propFind = new PropFindMethod(url.getURI(), 0);
propFind.setPropertyNames(props.elements());
propFind.setFollowRedirects(true);
int status = client.executeMethod(propFind);
switch (status) {
case WebdavStatus.SC_MULTI_STATUS:
Property p = findProperty(propFind, GETLASTMODIFIED, url.getPath());
if (p != null) {
try {
Date d = GETLASTMODIFIED_FORMAT.parse(p.getPropertyAsString());
return d.getTime();
}
catch (ParseException e) {
throw new HttpException("Invalid lastmodified property: " +
p.getPropertyAsString());
}
}
throw new HttpException("PROPFIND does not return lastmodified.");
default:
HttpException ex = new HttpException();
ex.setReasonCode(status);
ex.setReason(propFind.getStatusText());
throw ex;
}
}