The getUserAvailability() api is not returning the expected results/events.
It seems that the timewindow argument is mis-interrepted as UTC instead of my local timezone.
For this test I have 4 meeting events configured for user ps5502 (using EST) as follows:
Event1: March 4th 19:00 to 20:00
Event2: March 5th 10:00 to 11:00
Event3: March 5th 14:00 to 17:00
Event4: March 5th 19:00 to 19:30
I'm testing against a 2010 exchange server and you can see from this test code output
that I'm getting back events 1, 2, 3 where I should be getting events 2, 3, 4
for the specified time window (which is from the start of today to the start of tomorrow - 24hrs).
2015-03-05 18:50:09,490 [main] jvh.ewsClient.EWSClient INFO - buildStartEndTime() start Thu Mar 05 00:00:00 EST 2015 end Fri Mar 06 00:00:00 EST 2015
2015-03-05 18:50:10,099 [main] jvh.ewsClient.EWSClient INFO - getAvailability() start Thu Mar 05 00:00:00 EST 2015 end Fri Mar 06 00:00:00 EST 2015
2015-03-05 18:50:10,099 [main] jvh.ewsClient.EWSClient INFO - getAvailability() results for ps5502@ca.avaya.com events: 3
2015-03-05 18:50:10,099 [main] jvh.ewsClient.EWSClient INFO - getAvailability() event 1 start: Wed Mar 04 19:00:00 EST 2015 end: Wed Mar 04 20:00:00 EST 2015
2015-03-05 18:50:10,100 [main] jvh.ewsClient.EWSClient INFO - getAvailability() event 2 start: Thu Mar 05 10:00:00 EST 2015 end: Thu Mar 05 11:00:00 EST 2015
2015-03-05 18:50:10,100 [main] jvh.ewsClient.EWSClient INFO - getAvailability() event 3 start: Thu Mar 05 14:00:00 EST 2015 end: Thu Mar 05 17:00:00 EST 2015
Test code as follows:
private TimeWindow buildStartEndTime()
{
final Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND));
final Date start = cal.getTime();
cal.add(Calendar.DATE, 1);
final Date end = cal.getTime();
LOG.info("buildStartEndTime() start " + start + " end " + end);
return new TimeWindow(start, end);
}
private void testAvailabilityService()
{
final List<String> attendeeList = Arrays.asList("ps5502@ca.avaya.com");
final TimeWindow tw = buildStartEndTime();
getAvailability(attendeeList, tw);
}
private void getAvailability(List<String> attendeeList, final TimeWindow tw)
{
final List<AttendeeInfo> attendees = new ArrayList<AttendeeInfo>();
for (final String attendee : attendeeList)
{
attendees.add(new AttendeeInfo(attendee));
}
try
{
GetUserAvailabilityResults results = service.getUserAvailability(attendees, tw, AvailabilityData.FreeBusyAndSuggestions);
LOG.info("getAvailability() start " + tw.getStartTime() + " end " + tw.getEndTime());
int userIndex = 0;
for (AttendeeAvailability attendeeAvailability : results.getAttendeesAvailability())
{
if (attendeeAvailability.getErrorCode() == ServiceError.NoError)
{
LOG.info("getAvailability() results for " + attendees.get(userIndex).getSmtpAddress() + " events: " + attendeeAvailability.getCalendarEvents().size());
// loop thru the rec'd events
int eventCount = 1;
for (CalendarEvent calEvent : attendeeAvailability.getCalendarEvents())
{
LOG.info("getAvailability() event " + eventCount + " start: " + calEvent.getStartTime() + " end: " + calEvent.getEndTime()); // + " " + " details: " + calEvent.getDetails() + " subject: " + (calEvent.getDetails() == null ? "null" : calEvent.getDetails().getSubject()));
eventCount++;
}
}
else
{
LOG.info("getAvailability() error for " + attendees.get(userIndex).getSmtpAddress() + ": "+ attendeeAvailability.getErrorCode());
}
userIndex++;
}
}
catch (Exception e)
{
LOG.error("getAvailability() failed", e);
}
}
BTW... I executed this same test with the older version 1.1.5 and it does the same thing.
However, the old version sends back calendar events in UTC where the lastest 2.0 code
sends the events back in my local timezone (ie: EST). (which is better :-) )
Test results using the 1.1.5 version:
2015-03-05 19:16:07,743 [main] jvh.ewsClient.EWSClient INFO - buildStartEndTime() start Thu Mar 05 00:00:00 EST 2015 end Fri Mar 06 00:00:00 EST 2015
2015-03-05 19:16:09,568 [main] jvh.ewsClient.EWSClient INFO - getAvailability() start Thu Mar 05 00:00:00 EST 2015 end Fri Mar 06 00:00:00 EST 2015
2015-03-05 19:16:09,568 [main] jvh.ewsClient.EWSClient INFO - getAvailability() results for ps5502@ca.avaya.com events: 3
2015-03-05 19:16:09,568 [main] jvh.ewsClient.EWSClient INFO - getAvailability() event 1 start: Thu Mar 05 00:00:00 EST 2015 end: Thu Mar 05 01:00:00 EST 2015
2015-03-05 19:16:09,569 [main] jvh.ewsClient.EWSClient INFO - getAvailability() event 2 start: Thu Mar 05 15:00:00 EST 2015 end: Thu Mar 05 16:00:00 EST 2015
2015-03-05 19:16:09,570 [main] jvh.ewsClient.EWSClient INFO - getAvailability() event 3 start: Thu Mar 05 19:00:00 EST 2015 end: Thu Mar 05 22:00:00 EST 2015
The
getUserAvailability()api is not returning the expected results/events.It seems that the timewindow argument is mis-interrepted as UTC instead of my local timezone.
For this test I have 4 meeting events configured for user ps5502 (using EST) as follows:
Event1: March 4th 19:00 to 20:00
Event2: March 5th 10:00 to 11:00
Event3: March 5th 14:00 to 17:00
Event4: March 5th 19:00 to 19:30
I'm testing against a 2010 exchange server and you can see from this test code output
that I'm getting back events 1, 2, 3 where I should be getting events 2, 3, 4
for the specified time window (which is from the start of today to the start of tomorrow - 24hrs).
Test code as follows:
BTW... I executed this same test with the older version 1.1.5 and it does the same thing.
However, the old version sends back calendar events in UTC where the lastest 2.0 code
sends the events back in my local timezone (ie: EST). (which is better :-) )
Test results using the 1.1.5 version: