public void writeMeetingToGoogle(JDCConnection oConn, Meeting oMeet)
throws IOException, SQLException, MalformedURLException, ServiceException {
URL postUrl = new URL("https://www.google.com/calendar/feeds/"+sEMail+"/private/full");
CalendarEventEntry oEvnt;
if (oMeet.isNull(DB.id_icalendar)) {
oEvnt = new CalendarEventEntry();
oEvnt.setIcalUID(oMeet.getString(DB.gu_meeting)+"@hipergate.org");
oEvnt.setTitle(new PlainTextConstruct(oMeet.getStringNull(DB.tx_meeting,"")));
oEvnt.setContent(new PlainTextConstruct(oMeet.getStringNull(DB.de_meeting,"")));
When oTimes = new When();
String sTimeZone = DBCommand.queryStr(oConn, "SELECT "+DB.tx_timezone+" FROM "+DB.k_fellows+" WHERE "+DB.gu_fellow+"='"+oMeet.getString(DB.gu_fellow)+"'");
if (null==sTimeZone) {
oTimes.setStartTime(new DateTime(oMeet.getDate(DB.dt_start)));
oTimes.setEndTime(new DateTime(oMeet.getDate(DB.dt_end)));
} else {
int lSign = sTimeZone.charAt(0)=='+' ? 1 : -1;
String[] aTimeZone = Gadgets.split2(sTimeZone.substring(1),':');
SimpleTimeZone oTmz = new SimpleTimeZone(lSign*(Integer.parseInt(aTimeZone[0])*3600000+Integer.parseInt(aTimeZone[1])*60000), sTimeZone);
oTimes.setStartTime(new DateTime(oMeet.getDate(DB.dt_start),oTmz));
oTimes.setEndTime(new DateTime(oMeet.getDate(DB.dt_end),oTmz));
}
oEvnt.addTime(oTimes);
DBSubset oFlws = oMeet.getFellows(oConn);
for (int f=0; f<oFlws.getRowCount(); f++) {
if (!oFlws.isNull(4,f)) {
EventWho oEwho = new EventWho();
oEwho.setEmail(oFlws.getString(4,f));
oEvnt.addParticipant(oEwho);
} // fi
} // next
oEvnt = oCalSrv.insert(postUrl, oEvnt);
if (!oMeet.isNull(DB.bo_private))
oEvnt.getVisibility().setValue(oMeet.getShort(DB.bo_private)==0 ? Visibility.PUBLIC_VALUE : Visibility.PRIVATE_VALUE);
DBCommand.executeUpdate(oConn, "UPDATE "+DB.k_meetings+" SET "+DB.id_icalendar+"='"+oMeet.getString(DB.gu_meeting)+"@hipergate.org"+"' WHERE "+DB.gu_meeting+"='"+oMeet.getString(DB.gu_meeting)+"'");
} else {
URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/private/full");
CalendarQuery myQuery = new CalendarQuery(feedUrl);
myQuery.setMinimumStartTime(new DateTime(oMeet.getDate(DB.dt_start)));
myQuery.setMaximumStartTime(new DateTime(oMeet.getDate(DB.dt_end)));
CalendarEventFeed oFeed = oCalSrv.query(myQuery, CalendarEventFeed.class);
for (int i = 0; i < oFeed.getEntries().size(); i++) {
oEvnt = oFeed.getEntries().get(i);
if (oEvnt.getIcalUID().equals(oMeet.getString(DB.id_icalendar))) {
oEvnt.setTitle(new PlainTextConstruct(oMeet.getStringNull(DB.tx_meeting,"")));
oEvnt.setContent(new PlainTextConstruct(oMeet.getStringNull(DB.de_meeting,"")));
if (oMeet.isNull(DB.bo_private))
oEvnt.getVisibility().setValue(Visibility.DEFAULT_VALUE);
else
oEvnt.getVisibility().setValue(oMeet.getShort(DB.bo_private)==0 ? Visibility.PUBLIC_VALUE : Visibility.PRIVATE_VALUE);
When oTimes = new When();
oTimes.setStartTime(new DateTime(oMeet.getDate(DB.dt_start)));
oTimes.setEndTime(new DateTime(oMeet.getDate(DB.dt_end)));
oEvnt.addTime(oTimes);
DBSubset oFlws = oMeet.getFellows(oConn);
for (int f=0; f<oFlws.getRowCount(); f++) {
if (!oFlws.isNull(4,f)) {
EventWho oEwho = new EventWho();
oEwho.setEmail(oFlws.getString(4,f));
oEvnt.addParticipant(oEwho);
} // fi
} // next
if (DebugFile.trace)
DebugFile.writeln("CalendarService.update("+new URL(oEvnt.getEditLink().getHref()).toString()+","+oEvnt.getIcalUID());
oCalSrv.update(new URL(oEvnt.getEditLink().getHref()), oEvnt);
break;
} // fi
} // next
} // fi
} // writeMeetingToGoogle