Caldav: remove quotes on etag for Evolution

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1721 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-06-28 08:25:33 +00:00
parent 9dc774e01b
commit a2e8f1f07d
4 changed files with 25 additions and 2 deletions

View File

@ -259,7 +259,8 @@ public class CaldavConnection extends AbstractConnection {
reportItems(request);
// event requests
} else if (request.isPut()) {
String etag = request.getHeader("if-match");
// remove quotes on etag for Evolution
String etag = StringUtil.removeQuotes(request.getHeader("if-match"));
String noneMatch = request.getHeader("if-none-match");
ExchangeSession.ItemResult itemResult = session.createOrUpdateItem(request.getFolderPath(), lastPath, request.getBody(), etag, noneMatch);
sendHttpResponse(itemResult.status, buildEtagHeader(itemResult.etag), null, "", true);

View File

@ -1187,7 +1187,7 @@ public class EwsExchangeSession extends ExchangeSession {
if (currentItem != null) {
currentItemId = new ItemId(currentItem);
currentEtag = currentItem.get(Field.get("etag").getResponseName());
LOGGER.debug("Existing item found with etag: " + currentEtag + " id: " + currentItemId.id);
LOGGER.debug("Existing item found with etag: " + currentEtag + " client etag: "+etag+" id: " + currentItemId.id);
}
if ("*".equals(noneMatch)) {
// create requested

View File

@ -385,4 +385,21 @@ public final class StringUtil {
}
return result;
}
/**
* Remove quotes if present on value.
* @param value input value
* @return unquoted string
*/
public static String removeQuotes(String value) {
String result = value;
if (result.startsWith("\"") || result.startsWith("{") || result.startsWith("(")) {
result = result.substring(1);
}
if (result.endsWith("\"") || result.endsWith("}") || result.endsWith(")")) {
result = result.substring(0, result.length() - 1);
}
return result;
}
}

View File

@ -97,4 +97,9 @@ public class StringUtilTest extends TestCase {
System.out.println("Elapsed: " + (System.currentTimeMillis() - startTime) + " ms");
}
}
public void testRemoveQuotes() {
assertEquals("test", StringUtil.removeQuotes("test"));
assertEquals("test", StringUtil.removeQuotes("\"test\""));
}
}