1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

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
This commit is contained in:
mguessan 2009-01-18 21:41:05 +00:00
parent 4f75dea6b7
commit 9f9e588729

View File

@ -481,7 +481,7 @@ public class ExchangeSession {
throw new IOException("Overwritten message " + messageUrl); throw new IOException("Overwritten message " + messageUrl);
} }
} else if (code != HttpURLConnection.HTTP_CREATED) { } 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 { } finally {
if (bodyStream != null) { if (bodyStream != null) {
@ -1308,36 +1308,38 @@ public class ExchangeSession {
int endIndex = body.lastIndexOf("</a:fbdata>"); int endIndex = body.lastIndexOf("</a:fbdata>");
if (startIndex >= 0 && endIndex >= 0) { if (startIndex >= 0 && endIndex >= 0) {
String fbdata = body.substring(startIndex + "<a:fbdata>".length(), endIndex); String fbdata = body.substring(startIndex + "<a:fbdata>".length(), endIndex);
Calendar currentCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); if (fbdata.length() > 0) {
currentCal.setTime(startDate); Calendar currentCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
currentCal.setTime(startDate);
StringBuilder busyBuffer = new StringBuilder(); StringBuilder busyBuffer = new StringBuilder();
boolean isBusy = fbdata.charAt(0) != '0' && fbdata.charAt(0) != '4'; boolean isBusy = fbdata.charAt(0) != '0' && fbdata.charAt(0) != '4';
if (isBusy) { 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(',');
}
busyBuffer.append(icalParser.format(currentCal.getTime())); busyBuffer.append(icalParser.format(currentCal.getTime()));
} }
isBusy = fbdata.charAt(i) != '0' && fbdata.charAt(0) != '4'; boolean knownAttendee = fbdata.charAt(0) != '4';
} for (int i = 1; i < fbdata.length(); i++) {
// still busy at end knownAttendee = knownAttendee || fbdata.charAt(i) != '4';
if (isBusy) { currentCal.add(Calendar.MINUTE, interval);
busyBuffer.append('/').append(icalParser.format(currentCal.getTime())); if (isBusy && fbdata.charAt(i) == '0') {
} // busy -> non busy
if (knownAttendee) { busyBuffer.append('/').append(icalParser.format(currentCal.getTime()));
result = busyBuffer.toString(); } 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 { } finally {