[Cosmo-dev] Issues found in caldav4j library
Floristan, Juan Jose
juanjo.floristan at hp.com
Tue Oct 23 06:49:19 PDT 2007
Hello.
My name is Juanjo Floristán. I am a spanish HP's employee who is developing an application that gets connected to a calendar using your caldav client library. I have found a couple of issues that I would like to discuss with you. First of all, I must say that I am using the latest version of CalDav4j (caldav4j-0.3-SNAPSHOT.jar) downloaded from http://svn.osafoundation.org/server/caldav/trunk/. The two issues I have found are the following ones:
1. When a new resource is received from the calendar server as the response of a report method, the client supposes that an absolute path is received in the href tag, so it has problems when the server sends a relative path. That is, the current code is like this:
protected static String stripHost(String href){
int indexOfColon = href.indexOf(":");
int index = href.indexOf("/", indexOfColon + 3);
return href.substring(index);
}
So, when the href is relative (so it doesn't contain a ":" char), the indexOfColon value would be "-1" and the index value would not be correctly calculated. To make this code work, I have manually made the following changes:
protected static String stripHost(String href){
int indexOfColon = href.indexOf(":");
int index = 0;
if (indexOfColon > 0){
index = href.indexOf("/", indexOfColon + 3);
}
return href.substring(index);
}
This may be used as a possible reference for you if you consider that the issue has been correctly identified as a bug.
2. When using a REPORT method, the client is not setting the HTTP "Content-Length" header, so, finally, the http-client is not sending the body. This issue is far more complex to resolve. A possible alternative would be to add the header in the addRequestHeaders method of the CalDAVReportMethod class, but the code would be duplicated from the one that exists in the EntityEnclosingMethod of the commons HTTPClient library. Another way would be to change the class hierarchy of the CalDAVReportMethod class, so that it extends the EntityEnclosingMethod of the commons HTTPClient library (that already properly sets the "Content-Length" header), but this is a quite complex change with major consequences. In your library the PutMethod class already extends the EntityEnclosingMethod (through extending org.apache.commons.httpclient.methods.PutMethod), so this proposal would be similar to the PutMethod case. What do you think about this?
Many thanks for your help in advance. Any comments are welcome.
Best regards,
Juanjo Floristán
More information about the cosmo-dev
mailing list