From 9f9e588729ad5284d957db3ebebf6b8b36a1a817 Mon Sep 17 00:00:00 2001 From: mguessan Date: Sun, 18 Jan 2009 21:41:05 +0000 Subject: [PATCH] Fix Bug 2517478: check if fbdata is not empty git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@296 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index b85b013d..39a70b89 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -481,7 +481,7 @@ public class ExchangeSession { throw new IOException("Overwritten message " + messageUrl); } } else if (code != HttpURLConnection.HTTP_CREATED) { - throw new IOException("Unable to create message " + code + " " + putmethod.getStatusLine()); + throw new IOException("Unable to create message " + messageUrl + ": " + code + " " + putmethod.getStatusLine()); } } finally { if (bodyStream != null) { @@ -1308,36 +1308,38 @@ public class ExchangeSession { int endIndex = body.lastIndexOf(""); if (startIndex >= 0 && endIndex >= 0) { String fbdata = body.substring(startIndex + "".length(), endIndex); - Calendar currentCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - currentCal.setTime(startDate); + if (fbdata.length() > 0) { + Calendar currentCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + currentCal.setTime(startDate); - StringBuilder busyBuffer = new StringBuilder(); - boolean isBusy = fbdata.charAt(0) != '0' && fbdata.charAt(0) != '4'; - if (isBusy) { - busyBuffer.append(icalParser.format(currentCal.getTime())); - } - boolean knownAttendee = fbdata.charAt(0) != '4'; - for (int i = 1; i < fbdata.length(); i++) { - knownAttendee = knownAttendee || fbdata.charAt(i) != '4'; - currentCal.add(Calendar.MINUTE, interval); - if (isBusy && fbdata.charAt(i) == '0') { - // busy -> non busy - busyBuffer.append('/').append(icalParser.format(currentCal.getTime())); - } else if (!isBusy && (fbdata.charAt(i) != '0') && fbdata.charAt(0) != '4') { - // non busy -> busy - if (busyBuffer.length() > 0) { - busyBuffer.append(','); - } + StringBuilder busyBuffer = new StringBuilder(); + boolean isBusy = fbdata.charAt(0) != '0' && fbdata.charAt(0) != '4'; + if (isBusy) { busyBuffer.append(icalParser.format(currentCal.getTime())); } - isBusy = fbdata.charAt(i) != '0' && fbdata.charAt(0) != '4'; - } - // still busy at end - if (isBusy) { - busyBuffer.append('/').append(icalParser.format(currentCal.getTime())); - } - if (knownAttendee) { - result = busyBuffer.toString(); + boolean knownAttendee = fbdata.charAt(0) != '4'; + for (int i = 1; i < fbdata.length(); i++) { + knownAttendee = knownAttendee || fbdata.charAt(i) != '4'; + currentCal.add(Calendar.MINUTE, interval); + if (isBusy && fbdata.charAt(i) == '0') { + // busy -> non busy + busyBuffer.append('/').append(icalParser.format(currentCal.getTime())); + } else if (!isBusy && (fbdata.charAt(i) != '0') && fbdata.charAt(0) != '4') { + // non busy -> busy + if (busyBuffer.length() > 0) { + busyBuffer.append(','); + } + busyBuffer.append(icalParser.format(currentCal.getTime())); + } + isBusy = fbdata.charAt(i) != '0' && fbdata.charAt(0) != '4'; + } + // still busy at end + if (isBusy) { + busyBuffer.append('/').append(icalParser.format(currentCal.getTime())); + } + if (knownAttendee) { + result = busyBuffer.toString(); + } } } } finally {