Hi google stuff, I'd like to tell you first how much I appreciate your product and ideas: very much ;-)
I'm participating to the android GDC2 and since it's very near, I'll really apreciate your answers. I'm experiencing a problem maybe with the batch processor: everything works fine for the batch update (I verify BatchUtils.isSuccess(entry) is true for each entry). I followed exactly your tutorial on http://code.google.com/intl/fr/apis/calendar/docs/2.0/developers_guide_java.html#batch but when I go and read again my feed (that i've just saved, gdataFeedEntry.getExtendedProperty() returns empty lists) To be more specific, I can show you relevent parts of my code, all this code is surely annoying but there's maybe no other way for you to see if I'm doing sth wrong: here I update the feed events private void batchUpdateEntry(EntityEventTimeEntry pojoEntry, CalendarEventEntry gdataFeedEntry) { ExtendedProperty entityId = new ExtendedProperty(); entityId.setName(EXTENDED_PROPERTY_ENTRY_ID); String entryId = "" + pojoEntry.getId(); entityId.setValue(entryId); BatchUtils.setBatchId(gdataFeedEntry, entryId); BatchUtils.setBatchOperationType(gdataFeedEntry, BatchOperationType.UPDATE); } protected void batchRecurrenceUpdate(CalendarEventEntry gdataFeedEntry, EventRecurrence recurrence) { String entryRecurrenceId; ExtendedProperty recurrenceIdProperty = new ExtendedProperty(); recurrenceIdProperty.setName(EXTENDED_PROPERTY_ENTRY_RECURRENCE_ID); entryRecurrenceId = "" + recurrence.getId(); recurrenceIdProperty.setValue(entryRecurrenceId); BatchUtils.setBatchId(gdataFeedEntry, "-" + entryRecurrenceId); BatchUtils.setBatchOperationType(gdataFeedEntry, BatchOperationType.UPDATE); } the caller is this one (nothing special) protected List<CalendarEventEntry> fillDbWithGoogleCalendar (List<Item<EntityEventTimeEntry, CalendarEventEntry>> toInsert) throws BusinessException { List<CalendarEventEntry> toReturn = new ArrayList<CalendarEventEntry> (); for (Item<EntityEventTimeEntry, CalendarEventEntry> eventTimeEntry : toInsert) { //.... done in my for loop when saving data to db em.persist(pojoEntry); if (recurrence != null) { batchRecurrenceUpdate(gdataFeedEntry, recurrence); } batchUpdateEntry(pojoEntry, gdataFeedEntry); toReturn.add(gdataFeedEntry); //.... } And here's my public global method that launches the overall process: public List<CalendarEventEntry> fillDbWithGoogleCalendar (EntityCalendar geoLocation) throws BusinessException, SystemException { try { CalendarService myService = createCalendarService (geoLocation.getOwner()); List<CalendarEntry> calendars = getAvailableCalendars(myService); FeedResultsReader feedResults = loadEvents(myService, geoLocation, calendars); List<CalendarEventEntry> inserted = fillDbWithGoogleCalendar (feedResults.getToInsert()); // Add the entries to a new feed. CalendarEventFeed batchRequest = new CalendarEventFeed(); for (CalendarEventEntry calendarEventEntry : inserted) { batchRequest.getEntries().add(calendarEventEntry); } // Get the batch link URL and send the batch request there. Link batchLink = feedResults.getEventFeed().getLink (Link.Rel.FEED_BATCH, Link.Type.ATOM); CalendarEventFeed batchResponse = myService.batch(new URL (batchLink.getHref()), batchRequest); boolean isSuccess = true; List<CalendarEventEntry> entries = batchResponse.getEntries(); for (CalendarEventEntry entry : entries) { String batchId = BatchUtils.getBatchId(entry); if (!BatchUtils.isSuccess(entry)) { isSuccess = false; BatchStatus status = BatchUtils.getBatchStatus(entry); System.err.println("\n" + batchId + " failed (" + status.getReason () + ") " + status.getContent()); } } if (isSuccess) { System.out.println("Successfully updated all " + entries.size() + " events of calendar " + geoLocation.getCalendarId() + "via batch request."); } return inserted; } catch (MalformedURLException ex) { throw new SystemException(ex); } catch (IOException ex) { throw new SystemException(ex); } catch (ServiceException ex) { throw new SystemException(ex); } } I have the confirmation message that the batch have executed correctly: 15:23:07,074 INFO [STDOUT] Successfully updated all 102 events of calendar http://www.google.com/calendar/feeds/default/calendars/[email protected] batch request. Now when I read the feeds again, I want to know which events are already in db, but none of the events is marked with an extention property: the List extensions is always empty protected Item<Long, Long> readExtendedProperties(CalendarEventEntry gdataFeedEntry) { String entryId = null; String entryRecurrenceId = null; List<ExtendedProperty> extensions = gdataFeedEntry.getExtendedProperty(); for (ExtendedProperty extendedProperty : extensions) { if (EXTENDED_PROPERTY_ENTRY_ID.equals(extendedProperty.getName())) { entryId = extendedProperty.getValue(); } else if (EXTENDED_PROPERTY_ENTRY_RECURRENCE_ID.equals (extendedProperty.getName())) { entryRecurrenceId = extendedProperty.getValue(); } } if (entryId != null || entryRecurrenceId != null) return new Item<Long, Long>(entryId != null ? Long.parseLong (entryId) : 0, entryRecurrenceId != null ? -Long.parseLong (entryRecurrenceId) : 0); else return null; } Do I have to specify that I want events extentions props to be loaded? Here's my query code protected FeedResultsReader loadEvents(CalendarService myService, EntityCalendar calendar, List<CalendarEntry> calendars) throws UnsetPropertyException, EntryNotFoundException, MalformedURLException, IOException, ServiceException { URL feedUrl; String calendarId = calendar.getCalendarId(); if (calendarId == null) throw new UnsetPropertyException("calendarId"); String calendarName = calendar.getName(); CalendarEntry found = null; for (int i = 0; i < calendars.size(); i++) { CalendarEntry entry = calendars.get(i); String entryId = URLDecoder.decode(entry.getId(), Constants.UTF_8); System.out.print("\t" + entryId); System.out.println(" :\t" + entry.getTitle().getPlainText()); if (calendarId.equals(entryId)) { found = entry; break; } } // Strange problem : seems the @ is url encoded. If for any reason fails by // id, try to find it by name if (found == null) { if (calendarName == null) throw new UnsetPropertyException("calendarId"); for (int i = 0; i < calendars.size(); i++) { CalendarEntry entry = calendars.get(i); String entryName = entry.getTitle().getPlainText(); if (calendarId.equals(entryName)) { found = entry; break; } } } if (found == null) throw new EntryNotFoundException(" name: " + calendarName + "(" + calendarId + ")"); String selectedCalendarFeedUrl = constructCalendarFeedUrl(found.getId ()); System.out.println("loadinf feed entries:" + selectedCalendarFeedUrl); feedUrl = new URL(selectedCalendarFeedUrl); CalendarQuery nextWeek = new CalendarQuery(feedUrl); DateTime minStart = new DateTime(System.currentTimeMillis()); nextWeek.setMinimumStartTime(minStart); nextWeek.setMaximumStartTime(new DateTime(System.currentTimeMillis() + period)); // nextWeek.setStringCustomParameter(RECURRENCE_EXPANSION_START, // "2009-07-16T00:00:00-08:00"); // nextWeek.setStringCustomParameter(RECURRENCE_EXPANSION_END, // "2009-07-24T00:00:00-08:00"); nextWeek.setStringCustomParameter(SINGLE_EVENTS, "false"); nextWeek.setStringCustomParameter(ORDER_BY, "starttime"); FeedResultsReader toReturn = new FeedResultsReader(calendar); toReturn.setEventFeed(myService.query(nextWeek, CalendarEventFeed.class)); toReturn.readFeed(); return toReturn; } Best Regards, Zied Hamdi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Calendar Data API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-calendar-help-dataapi?hl=en -~----------~----~----~----~------~----~------~--~---
