Merge change I3e9f81b8 into eclair
* changes:
Backporting a fix to a problem with parsing partial feeds that was uncovered in the new unittests in the open source depot
diff --git a/src/com/google/wireless/gdata/calendar/data/CalendarEntry.java b/src/com/google/wireless/gdata/calendar/data/CalendarEntry.java
index 6e49a9f..0d9e8d8 100644
--- a/src/com/google/wireless/gdata/calendar/data/CalendarEntry.java
+++ b/src/com/google/wireless/gdata/calendar/data/CalendarEntry.java
@@ -35,6 +35,11 @@
* Access level constant indicating the user owns this calendar.
*/
public static final byte ACCESS_OWNER = 4;
+
+ /**
+ * Access level constant indicating the user is a domain admin.
+ */
+ public static final byte ACCESS_ROOT = 5;
private byte accessLevel = ACCESS_READ;
// TODO: rename to feed Url?
diff --git a/src/com/google/wireless/gdata/calendar/parser/xml/XmlCalendarsGDataParser.java b/src/com/google/wireless/gdata/calendar/parser/xml/XmlCalendarsGDataParser.java
index 431fd43..9619834 100644
--- a/src/com/google/wireless/gdata/calendar/parser/xml/XmlCalendarsGDataParser.java
+++ b/src/com/google/wireless/gdata/calendar/parser/xml/XmlCalendarsGDataParser.java
@@ -81,6 +81,8 @@
accesslevel = CalendarEntry.ACCESS_EDITOR;
} else if ("owner".equals(accesslevelStr)) {
accesslevel = CalendarEntry.ACCESS_OWNER;
+ } else if ("root".equals(accesslevelStr)) {
+ accesslevel = CalendarEntry.ACCESS_ROOT;
}
calendarEntry.setAccessLevel(accesslevel);
} else if ("color".equals(name)) {
diff --git a/src/com/google/wireless/gdata/calendar/serializer/xml/XmlEventEntryGDataSerializer.java b/src/com/google/wireless/gdata/calendar/serializer/xml/XmlEventEntryGDataSerializer.java
index bcc209b..3fe8c27 100644
--- a/src/com/google/wireless/gdata/calendar/serializer/xml/XmlEventEntryGDataSerializer.java
+++ b/src/com/google/wireless/gdata/calendar/serializer/xml/XmlEventEntryGDataSerializer.java
@@ -60,9 +60,13 @@
serializer.endTag(NAMESPACE_GCAL_URI, "sendEventNotifications");
}
+ // TODO: sending these values can cause server crashes, e.g. if modifying attendee
+ // status while sending guestsCanModify=false
+ /*
serializeGuestsCanModify(serializer, entry.getGuestsCanModify());
serializeGuestsCanInviteOthers(serializer, entry.getGuestsCanInviteOthers());
serializeGuestsCanSeeGuests(serializer, entry.getGuestsCanSeeGuests());
+ */
Enumeration attendees = entry.getAttendees().elements();
while (attendees.hasMoreElements()) {
diff --git a/src/com/google/wireless/gdata2/calendar/client/CalendarClient.java b/src/com/google/wireless/gdata2/calendar/client/CalendarClient.java
deleted file mode 100644
index faf4bed..0000000
--- a/src/com/google/wireless/gdata2/calendar/client/CalendarClient.java
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.client;
-
-import com.google.wireless.gdata2.calendar.data.CalendarEntry;
-import com.google.wireless.gdata2.client.GDataClient;
-import com.google.wireless.gdata2.client.GDataParserFactory;
-import com.google.wireless.gdata2.client.GDataServiceClient;
-import com.google.wireless.gdata2.client.HttpException;
-import com.google.wireless.gdata2.client.QueryParams;
-import com.google.wireless.gdata2.parser.GDataParser;
-import com.google.wireless.gdata2.parser.ParseException;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * GDataServiceClient for accessing Google Calendar. This client can access and
- * parse both the meta feed (list of calendars for a user) and events feeds
- * (calendar entries for a specific user). The parsers this class uses handle
- * the XML version of feeds.
- */
-// TODO: add a method that applies projections such as cutting the attendees.
-public class CalendarClient extends GDataServiceClient {
- /** Service value for calendar. */
- public static final String SERVICE = "cl";
-
- public static final String PROJECTION_PRIVATE_FULL = "/private/full";
- public static final String PROJECTION_PRIVATE_SELF_ATTENDANCE = "/private/full-selfattendance";
-
- /** Standard base url for a calendar feed. */
- private static final String CALENDAR_BASE_FEED_URL =
- "http://www.google.com/calendar/feeds/";
-
- /**
- * Create a new CalendarClient. Uses the standard base URL for calendar feeds.
- * @param client The GDataClient that should be used to authenticate
- * requests, retrieve feeds, etc.
- * @param factory The factory that should be used to obtain {@link GDataParser}s used by this
- * client.
- */
- public CalendarClient(GDataClient client, GDataParserFactory factory) {
- super(client, factory);
- }
-
- /* (non-Javadoc)
- * @see GDataServiceClient#getServiceName
- */
- public String getServiceName() {
- return SERVICE;
- }
-
- /**
- * Returns the protocol version used by this GDataServiceClient,
- * in the form of a "2.1" string. For Calendar, we use the
- * default
- *
- * @return String
- */
- public String getProtocolVersion() {
- return DEFAULT_GDATA_VERSION;
- }
-
-
-
- /**
- * Returns the url for the default feed for a user, after applying the
- * provided QueryParams.
- * @param username The username for this user.
- * @param projection the projection to use
- * @param params The QueryParams that should be applied to the default feed.
- * @return The url that should be used to retrieve a user's default feed.
- */
- public String getDefaultCalendarUrl(String username, String projection, QueryParams params) {
- String feedUrl = CALENDAR_BASE_FEED_URL + getGDataClient().encodeUri(username);
- feedUrl += projection;
- if (params == null) {
- return feedUrl;
- }
- return params.generateQueryUrl(feedUrl);
- }
-
- /**
- * Returns the url for the metafeed for user, which contains the information about
- * the user's calendars.
- * @param username The username for this user.
- * @return The url that should be used to retrieve a user's default feed.
- */
- public String getUserCalendarsUrl(String username) {
- return CALENDAR_BASE_FEED_URL + getGDataClient().encodeUri(username);
- }
-
- /**
- * Fetches the meta feed containing the list of calendars for a user. The
- * caller is responsible for closing the returned {@link GDataParser}.
- *
- * @param feedUrl the URL of the user calendars feed
- * @param authToken The authentication token for this user
- * @return A GDataParser with the meta feed containing the list of
- * calendars for this user.
- * @throws ParseException Thrown if the feed could not be fetched.
- */
- public GDataParser getParserForUserCalendars(String feedUrl, String authToken)
- throws ParseException, IOException, HttpException {
- GDataClient gDataClient = getGDataClient();
- InputStream is = gDataClient.getFeedAsStream(feedUrl, authToken, null /* etag */, getProtocolVersion());
- return getGDataParserFactory().createParser(CalendarEntry.class, is);
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/client/package.html b/src/com/google/wireless/gdata2/calendar/client/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/calendar/client/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/calendar/data/CalendarEntry.java b/src/com/google/wireless/gdata2/calendar/data/CalendarEntry.java
deleted file mode 100644
index 069d0af..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/CalendarEntry.java
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.data;
-
-import com.google.wireless.gdata2.data.Entry;
-
-/**
- * Entry containing information about a calendar.
- */
-public class CalendarEntry extends Entry {
-
- /**
- * Access level constant indicating the user has no access to a calendar.
- */
- public static final byte ACCESS_NONE = 0;
-
- /**
- * Access level constant indicating the user can read (but not write) to
- * a calendar.
- */
- public static final byte ACCESS_READ = 1;
-
- /**
- * Access level constant indicating the user can only view free-busy
- * information for a calendar.
- */
- public static final byte ACCESS_FREEBUSY = 2;
-
- /**
- * Access level constant indicating the user can edit this calendar.
- */
- public static final byte ACCESS_EDITOR = 3;
-
- /**
- * Access level constant indicating the user owns this calendar.
- */
- public static final byte ACCESS_OWNER = 4;
-
- private byte accessLevel = ACCESS_READ;
- // TODO: rename to feed Url?
- private String alternateLink = null;
- private String color = null;
- private boolean hidden = false;
- private boolean selected = true;
- private String timezone = null;
-
- /**
- * Creates a new, empty calendar entry.
- */
- public CalendarEntry() {
- }
-
- public void clear() {
- super.clear();
- accessLevel = ACCESS_READ;
- alternateLink = null;
- color = null;
- hidden = false;
- selected = true;
- timezone = null;
- }
-
- /**
- * @return the accessLevel
- */
- public byte getAccessLevel() {
- return accessLevel;
- }
-
- /**
- * @param accessLevel the accessLevel to set
- */
- public void setAccessLevel(byte accessLevel) {
- this.accessLevel = accessLevel;
- }
-
- /**
- * @return the alternateLink
- */
- public String getAlternateLink() {
- return alternateLink;
- }
-
- /**
- * @param alternateLink the alternateLink to set
- */
- public void setAlternateLink(String alternateLink) {
- this.alternateLink = alternateLink;
- }
-
- /**
- * @return the color
- */
- public String getColor() {
- return color;
- }
-
- /**
- * @param color the color to set
- */
- public void setColor(String color) {
- this.color = color;
- }
-
- /**
- * @return the hidden
- */
- public boolean isHidden() {
- return hidden;
- }
-
- /**
- * @param hidden the hidden to set
- */
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
-
- /**
- * @return the selected
- */
- public boolean isSelected() {
- return selected;
- }
-
- /**
- * @param selected the selected to set
- */
- public void setSelected(boolean selected) {
- this.selected = selected;
- }
-
- /**
- * @return the timezone
- */
- public String getTimezone() {
- return timezone;
- }
-
- /**
- * @param timezone the timezone to set
- */
- public void setTimezone(String timezone) {
- this.timezone = timezone;
- }
-
- public void toString(StringBuffer sb) {
- sb.append("ACCESS LEVEL: ");
- sb.append(accessLevel);
- sb.append('\n');
- appendIfNotNull(sb, "ALTERNATE LINK", alternateLink);
- appendIfNotNull(sb, "COLOR", color);
- sb.append("HIDDEN: ");
- sb.append(hidden);
- sb.append('\n');
- sb.append("SELECTED: ");
- sb.append(selected);
- sb.append('\n');
- appendIfNotNull(sb, "TIMEZONE", timezone);
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/data/CalendarsFeed.java b/src/com/google/wireless/gdata2/calendar/data/CalendarsFeed.java
deleted file mode 100644
index b2b4669..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/CalendarsFeed.java
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.data;
-
-import com.google.wireless.gdata2.data.Feed;
-
-/**
- * Meta feed containing the list of calendars for a user.
- */
-public class CalendarsFeed extends Feed {
-
- /**
- * Creates a new empty calendars feed.
- */
- public CalendarsFeed() {
- }
-
-}
diff --git a/src/com/google/wireless/gdata2/calendar/data/EventEntry.java b/src/com/google/wireless/gdata2/calendar/data/EventEntry.java
deleted file mode 100644
index e5a5f9c..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/EventEntry.java
+++ /dev/null
@@ -1,327 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.data;
-
-import com.google.wireless.gdata2.data.Entry;
-
-import java.util.Hashtable;
-import java.util.Vector;
-import java.util.Enumeration;
-
-/**
- * Entry containing information about an event in a calendar.
- */
-public class EventEntry extends Entry {
-
- // TODO: pack all of these enums into an int
-
- /**
- * Status constant indicating that a user's attendance at an event is
- * tentative.
- */
- public static final byte STATUS_TENTATIVE = 0;
-
- /**
- * Status constant indicating that a user's attendance at an event is
- * confirmed.
- */
- public static final byte STATUS_CONFIRMED = 1;
-
- /**
- * Status constant indicating that an event has been cancelled.
- */
- public static final byte STATUS_CANCELED = 2;
-
- /**
- * Visibility constant indicating that an event uses the user's default
- * visibility.
- */
- public static final byte VISIBILITY_DEFAULT = 0;
-
- /**
- * Visibility constant indicating that an event has been marked
- * confidential.
- */
- public static final byte VISIBILITY_CONFIDENTIAL = 1;
-
- /**
- * Visibility constant indicating that an event has been marked private.
- */
- public static final byte VISIBILITY_PRIVATE = 2;
-
- /**
- * Visibility constant indicating that an event has been marked public.
- */
- public static final byte VISIBILITY_PUBLIC = 3;
-
- /**
- * Transparency constant indicating that an event has been marked opaque.
- */
- public static final byte TRANSPARENCY_OPAQUE = 0;
-
- /**
- * Transparency constant indicating that an event has been marked
- * transparent.
- */
- public static final byte TRANSPARENCY_TRANSPARENT = 1;
-
- private byte status = STATUS_TENTATIVE;
- private String recurrence = null;
- private byte visibility = VISIBILITY_DEFAULT;
- private byte transparency = TRANSPARENCY_OPAQUE;
- private Vector attendees = new Vector();
- private Vector whens = new Vector();
- private Vector reminders = null;
- private String originalEventId = null;
- private String originalEventStartTime = null;
- private String where = null;
- private String commentsUri = null;
- private Hashtable extendedProperties = null;
- private boolean quickAdd = false;
-
- /**
- * Creates a new empty event entry.
- */
- public EventEntry() {
- }
-
- /*
- * (non-Javadoc)
- * @see com.google.wireless.gdata2.data.Entry#clear()
- */
- public void clear() {
- super.clear();
- status = STATUS_TENTATIVE;
- recurrence = null;
- visibility = VISIBILITY_DEFAULT;
- transparency = TRANSPARENCY_OPAQUE;
- attendees.removeAllElements();
- whens.removeAllElements();
- reminders = null;
- originalEventId = null;
- originalEventStartTime = null;
- where = null;
- commentsUri = null;
- extendedProperties = null;
- quickAdd = false;
- }
-
- /**
- * @return the recurrence
- */
- public String getRecurrence() {
- return recurrence;
- }
-
- /**
- * @param recurrence the recurrence to set
- */
- public void setRecurrence(String recurrence) {
- this.recurrence = recurrence;
- }
-
- /**
- * @return the status
- */
- public byte getStatus() {
- return status;
- }
-
- /**
- * @param status the status to set
- */
- public void setStatus(byte status) {
- this.status = status;
- }
-
- /**
- * @return the transparency
- */
- public byte getTransparency() {
- return transparency;
- }
-
- /**
- * @param transparency the transparency to set
- */
- public void setTransparency(byte transparency) {
- this.transparency = transparency;
- }
-
- /**
- * @return the visibility
- */
- public byte getVisibility() {
- return visibility;
- }
-
- /**
- * @param visibility the visibility to set
- */
- public void setVisibility(byte visibility) {
- this.visibility = visibility;
- }
-
- public void clearAttendees() {
- attendees.removeAllElements();
- }
-
- public void addAttendee(Who attendee) {
- attendees.addElement(attendee);
- }
-
- public Vector getAttendees() {
- return attendees;
- }
-
- public void clearWhens() {
- whens.removeAllElements();
- }
-
- public void addWhen(When when) {
- whens.addElement(when);
- }
-
- public Vector getWhens() {
- return whens;
- }
-
- public When getFirstWhen() {
- if (whens.isEmpty()) {
- return null;
- }
- return (When) whens.elementAt(0);
- }
-
- public Vector getReminders() {
- return reminders;
- }
-
- public void addReminder(Reminder reminder) {
- if (reminders == null) {
- reminders = new Vector();
- }
- reminders.addElement(reminder);
- }
-
- public void clearReminders() {
- reminders = null;
- }
-
- public String getOriginalEventId() {
- return originalEventId;
- }
-
- public void setOriginalEventId(String originalEventId) {
- this.originalEventId = originalEventId;
- }
-
- public String getOriginalEventStartTime() {
- return originalEventStartTime;
- }
-
- public void setOriginalEventStartTime(String originalEventStartTime) {
- this.originalEventStartTime = originalEventStartTime;
- }
-
- /**
- * @return the where
- */
- public String getWhere() {
- return where;
- }
-
- /**
- * @param where the where to set
- */
- public void setWhere(String where) {
- this.where = where;
- }
-
- public Hashtable getExtendedProperties() {
- return extendedProperties;
- }
-
- public String getExtendedProperty(String name) {
- if (extendedProperties == null) {
- return null;
- }
- String value = null;
- if (extendedProperties.containsKey(name)) {
- value = (String) extendedProperties.get(name);
- }
- return value;
- }
-
- public void addExtendedProperty(String name, String value) {
- if (extendedProperties == null) {
- extendedProperties = new Hashtable();
- }
- extendedProperties.put(name, value);
- }
-
- public void clearExtendedProperties() {
- extendedProperties = null;
- }
-
- public String getCommentsUri() {
- return commentsUri;
- }
-
- public void setCommentsUri(String commentsUri) {
- this.commentsUri = commentsUri;
- }
-
- public boolean isQuickAdd() {
- return quickAdd;
- }
-
- public void setQuickAdd(boolean quickAdd) {
- this.quickAdd = quickAdd;
- }
-
- public void toString(StringBuffer sb) {
- super.toString(sb);
- sb.append("STATUS: " + status + "\n");
- appendIfNotNull(sb, "RECURRENCE", recurrence);
- sb.append("VISIBILITY: " + visibility + "\n");
- sb.append("TRANSPARENCY: " + transparency + "\n");
-
- appendIfNotNull(sb, "ORIGINAL_EVENT_ID", originalEventId);
- appendIfNotNull(sb, "ORIGINAL_START_TIME", originalEventStartTime);
-
- sb.append("QUICK_ADD: " + (quickAdd ? "true" : "false"));
-
- Enumeration whos = this.attendees.elements();
- while (whos.hasMoreElements()) {
- Who who = (Who) whos.nextElement();
- who.toString(sb);
- }
-
- Enumeration times = this.whens.elements();
- while (times.hasMoreElements()) {
- When when = (When) times.nextElement();
- when.toString(sb);
- }
- if (reminders != null) {
- Enumeration alarms = reminders.elements();
- while (alarms.hasMoreElements()) {
- Reminder reminder = (Reminder) alarms.nextElement();
- reminder.toString(sb);
- }
- }
- appendIfNotNull(sb, "WHERE", where);
- appendIfNotNull(sb, "COMMENTS", commentsUri);
- if (extendedProperties != null) {
- Enumeration entryNames = extendedProperties.keys();
- while (entryNames.hasMoreElements()) {
- String name = (String) entryNames.nextElement();
- String value = (String) extendedProperties.get(name);
- sb.append(name);
- sb.append(':');
- sb.append(value);
- sb.append('\n');
- }
- }
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/data/EventsFeed.java b/src/com/google/wireless/gdata2/calendar/data/EventsFeed.java
deleted file mode 100644
index b524e26..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/EventsFeed.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.data;
-
-import com.google.wireless.gdata2.data.Feed;
-
-/**
- * Feed containing events in a calendar.
- */
-public class EventsFeed extends Feed {
-
- private String timezone = null;
-
- /**
- * Creates a new empty events feed.
- */
- public EventsFeed() {
- }
-
- /**
- * @return the timezone
- */
- public String getTimezone() {
- return timezone;
- }
-
- /**
- * @param timezone the timezone to set
- */
- public void setTimezone(String timezone) {
- this.timezone = timezone;
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/data/Recurrence.java b/src/com/google/wireless/gdata2/calendar/data/Recurrence.java
deleted file mode 100644
index 17a0a49..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/Recurrence.java
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.data;
-
-/**
- * Container for information about a Recurrence.
- */
-// TODO: get rid of this?
-public class Recurrence {
-
- private final String recurrence;
-
- /**
- * Creates a new recurrence for the provide recurrence string.
- * @param recurrence The recurrence string that should be parsed.
- */
- public Recurrence(String recurrence) {
- this.recurrence = recurrence;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return recurrence;
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/data/Reminder.java b/src/com/google/wireless/gdata2/calendar/data/Reminder.java
deleted file mode 100644
index 9672123..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/Reminder.java
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-package com.google.wireless.gdata2.calendar.data;
-
-/**
- * Contains information about a reminder for an event.
- */
-public class Reminder {
- /**
- * Default reminder method as defined on the calendar server.
- */
- public static final byte METHOD_DEFAULT = 0;
-
- /**
- * Reminder that uses e-mail for notification.
- */
- public static final byte METHOD_EMAIL = 1;
-
- /**
- * Reminder that uses sms for notification.
- */
- public static final byte METHOD_SMS = 2;
-
- /**
- * Reminder that uses a local alert for notification.
- */
- public static final byte METHOD_ALERT = 3;
-
- /**
- * Reminder that uses a calendar-wide default time for the alarm.
- */
- public static final int MINUTES_DEFAULT = -1;
-
- // do absolute times work with recurrences?
- // private String absoluteTime;
- private int minutes = MINUTES_DEFAULT;
- private byte method = METHOD_DEFAULT;
-
- /**
- * Creates a new empty reminder.
- */
- public Reminder() {
- }
-
- /**
- * Returns the method of the reminder.
- * @return The method of the reminder.
- */
- public byte getMethod() {
- return method;
- }
-
- /**
- * Sets the method of the reminder.
- * @param method The method of the reminder.
- */
- public void setMethod(byte method) {
- this.method = method;
- }
-
- /**
- * Gets how many minutes before an event that the reminder should be
- * triggered.
- * @return How many minutes before an event that the reminder should be
- * triggered.
- */
- public int getMinutes() {
- return minutes;
- }
-
- /**
- * Sets how many minutes before an event that the reminder should be
- * triggered.
- * @param minutes How many minutes before an event that the reminder should
- * be triggered.
- */
- public void setMinutes(int minutes) {
- this.minutes = minutes;
- }
-
- public void toString(StringBuffer sb) {
- sb.append("REMINDER MINUTES: " + minutes);
- sb.append("\n");
- sb.append("REMINDER METHOD: " + method);
- sb.append("\n");
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- toString(sb);
- return sb.toString();
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/data/When.java b/src/com/google/wireless/gdata2/calendar/data/When.java
deleted file mode 100644
index a2b1975..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/When.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-package com.google.wireless.gdata2.calendar.data;
-
-import com.google.wireless.gdata2.data.StringUtils;
-
-/**
- * Contains information about the start and end of an instance of an event.
- */
-public class When {
- private final String startTime;
- private final String endTime;
-
- /**
- * Creates a new When.
- * @param startTime The start of the event.
- * @param endTime The end of the event.
- */
- public When(String startTime, String endTime) {
- this.startTime = startTime;
- this.endTime = endTime;
- }
-
- /**
- * Returns the start time for the event.
- * @return The start time for the event.
- */
- public String getStartTime() {
- return startTime;
- }
-
- /**
- * Returns the end time for the event.
- * @return The end time for the event.
- */
- public String getEndTime() {
- return endTime;
- }
-
- public void toString(StringBuffer sb) {
- if (!StringUtils.isEmpty(startTime)) {
- sb.append("START TIME: " + startTime + "\n");
- }
- if (!StringUtils.isEmpty(endTime)) {
- sb.append("END TIME: " + endTime + "\n");
- }
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- toString(sb);
- return sb.toString();
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/data/Who.java b/src/com/google/wireless/gdata2/calendar/data/Who.java
deleted file mode 100644
index 8a21dfa..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/Who.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.google.wireless.gdata2.calendar.data;
-
-import com.google.wireless.gdata2.data.StringUtils;
-
-/**
- * Contains information about a event attendee.
- */
-public class Who {
-
- /**
- * No attendee relationhip set. Used in {@link #setRelationship}
- * and {@link #getRelationship}.
- */
- public static final byte RELATIONSHIP_NONE = 0;
-
- /**
- * A general meeting/event attendee. Used in {@link #setRelationship}
- * and {@link #getRelationship}.
- */
- public static final byte RELATIONSHIP_ATTENDEE = 1;
-
- /**
- * Event organizer. An organizer is not necessary an attendee.
- * Used in {@link #setRelationship} and {@link #getRelationship}.
- */
- public static final byte RELATIONSHIP_ORGANIZER = 2;
-
- /**
- * Performer. Similar to {@link #RELATIONSHIP_SPEAKER}, but with more emphasis on art than
- * speech delivery.
- * Used in {@link #setRelationship} and {@link #getRelationship}.
- */
- public static final byte RELATIONSHIP_PERFORMER = 3;
-
- /**
- * Speaker. Used in {@link #setRelationship} and {@link #getRelationship}.
- */
- public static final byte RELATIONSHIP_SPEAKER = 4;
-
- /**
- * No attendee type set. Used in {@link #setType} and {@link #getType}.
- */
- public static final byte TYPE_NONE = 0;
-
- /**
- * Optional attendee. Used in {@link #setType} and {@link #getType}.
- */
- public static final byte TYPE_OPTIONAL = 1;
-
- /**
- * Required attendee. Used in {@link #setType} and {@link #getType}.
- */
- public static final byte TYPE_REQUIRED = 2;
-
- /**
- * No attendee status set. Used in {@link #setStatus} and {@link #getStatus}.
- */
- public static final byte STATUS_NONE = 0;
-
-
- /**
- * Attendee has accepted. Used in {@link #setStatus} and {@link #getStatus}.
- */
- public static final byte STATUS_ACCEPTED = 1;
-
- /**
- * Attendee has declined. Used in {@link #setStatus} and {@link #getStatus}.
- */
- public static final byte STATUS_DECLINED = 2;
-
- /**
- * Invitation has been sent, but the person has not accepted.
- * Used in {@link #setStatus} and {@link #getStatus}.
- */
- public static final byte STATUS_INVITED = 3;
-
- /**
- * Attendee has accepted tentatively. Used in {@link #setStatus} and {@link #getStatus}.
- */
- public static final byte STATUS_TENTATIVE = 4;
-
- private String email;
- private String value;
- private byte relationship = RELATIONSHIP_NONE;
- private byte type = TYPE_NONE;
- private byte status = STATUS_NONE;
-
- /**
- * Creates a new Who, representing event attendee information.
- */
- public Who() {
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public byte getRelationship() {
- return relationship;
- }
-
- public void setRelationship(byte relationship) {
- this.relationship = relationship;
- }
-
- public byte getType() {
- return type;
- }
-
- public void setType(byte type) {
- this.type = type;
- }
-
- public byte getStatus() {
- return status;
- }
-
- public void setStatus(byte status) {
- this.status = status;
- }
-
- protected void toString(StringBuffer sb) {
- if (!StringUtils.isEmpty(email)) {
- sb.append("EMAIL: " + email + "\n");
- }
-
- if (!StringUtils.isEmpty(value)) {
- sb.append("VALUE: " + value + "\n");
- }
-
- sb.append("RELATIONSHIP: " + relationship + "\n");
- sb.append("TYPE: " + type + "\n");
- sb.append("STATUS: " + status + "\n");
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- toString(sb);
- return sb.toString();
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/data/package.html b/src/com/google/wireless/gdata2/calendar/data/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/calendar/data/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/calendar/package.html b/src/com/google/wireless/gdata2/calendar/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/calendar/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/calendar/parser/package.html b/src/com/google/wireless/gdata2/calendar/parser/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/calendar/parser/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarGDataParserFactory.java b/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarGDataParserFactory.java
deleted file mode 100644
index 6146ad1..0000000
--- a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarGDataParserFactory.java
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.parser.xml;
-
-import com.google.wireless.gdata2.calendar.data.CalendarEntry;
-import com.google.wireless.gdata2.calendar.data.EventEntry;
-import com.google.wireless.gdata2.calendar.serializer.xml.XmlEventEntryGDataSerializer;
-import com.google.wireless.gdata2.client.GDataParserFactory;
-import com.google.wireless.gdata2.data.Entry;
-import com.google.wireless.gdata2.parser.GDataParser;
-import com.google.wireless.gdata2.parser.ParseException;
-import com.google.wireless.gdata2.parser.xml.XmlParserFactory;
-import com.google.wireless.gdata2.serializer.GDataSerializer;
-import com.google.wireless.gdata2.serializer.xml.XmlBatchGDataSerializer;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.InputStream;
-import java.util.Enumeration;
-
-/**
- * GDataParserFactory that creates XML GDataParsers and GDataSerializers for
- * Google Calendar.
- */
-public class XmlCalendarGDataParserFactory implements GDataParserFactory {
-
- private final XmlParserFactory xmlFactory;
-
- public XmlCalendarGDataParserFactory(XmlParserFactory xmlFactory) {
- this.xmlFactory = xmlFactory;
- }
-
- /**
- * Returns a parser for a calendars meta-feed.
- *
- * @param is The input stream to be parsed.
- * @return A parser for the stream.
- */
- public GDataParser createCalendarsFeedParser(InputStream is)
- throws ParseException {
- XmlPullParser xmlParser;
- try {
- xmlParser = xmlFactory.createParser();
- } catch (XmlPullParserException xppe) {
- throw new ParseException("Could not create XmlPullParser", xppe);
- }
- return new XmlCalendarsGDataParser(is, xmlParser);
- }
-
- /*
- * (non-javadoc)
- *
- * @see GDataParserFactory#createParser
- */
- public GDataParser createParser(InputStream is) throws ParseException {
- XmlPullParser xmlParser;
- try {
- xmlParser = xmlFactory.createParser();
- } catch (XmlPullParserException xppe) {
- throw new ParseException("Could not create XmlPullParser", xppe);
- }
- return new XmlEventsGDataParser(is, xmlParser);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.google.wireless.gdata2.client.GDataParserFactory#createParser(
- * int, java.io.InputStream)
- */
- public GDataParser createParser(Class entryClass, InputStream is)
- throws ParseException {
- if (entryClass == CalendarEntry.class) {
- return createCalendarsFeedParser(is);
- } else if (entryClass == EventEntry.class) {
- return createParser(is);
- }
- throw new IllegalArgumentException("Unknown entry class '" + entryClass.getName()
- + "' specified.");
- }
-
- /**
- * Creates a new {@link GDataSerializer} for the provided entry. The entry
- * <strong>must</strong> be an instance of {@link EventEntry}.
- *
- * @param entry The {@link EventEntry} that should be serialized.
- * @return The {@link GDataSerializer} that will serialize this entry.
- * @throws IllegalArgumentException Thrown if entry is not an
- * {@link EventEntry}.
- * @see GDataParserFactory#createSerializer
- */
- public GDataSerializer createSerializer(Entry entry) {
- if (!(entry instanceof EventEntry)) {
- throw new IllegalArgumentException("Expected EventEntry!");
- }
- EventEntry eventEntry = (EventEntry) entry;
- return new XmlEventEntryGDataSerializer(xmlFactory, eventEntry);
- }
-
- /**
- * Creates a new {@link GDataSerializer} for the given batch.
- *
- * @param batch the {@link Enumeration} of entries in the batch.
- * @return The {@link GDataSerializer} that will serialize this batch.
- */
- public GDataSerializer createSerializer(Enumeration batch) {
- return new XmlBatchGDataSerializer(this, xmlFactory, batch);
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarsGDataParser.java b/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarsGDataParser.java
deleted file mode 100644
index 6a8d2c4..0000000
--- a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarsGDataParser.java
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.parser.xml;
-
-import com.google.wireless.gdata2.calendar.data.CalendarEntry;
-import com.google.wireless.gdata2.calendar.data.CalendarsFeed;
-import com.google.wireless.gdata2.data.Entry;
-import com.google.wireless.gdata2.data.Feed;
-import com.google.wireless.gdata2.parser.ParseException;
-import com.google.wireless.gdata2.parser.xml.XmlGDataParser;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * GDataParser for the meta feed listing a user's calendars.
- */
-public class XmlCalendarsGDataParser extends XmlGDataParser {
-
- /**
- * Creates a new XmlCalendarsGDataParser.
- * @param is The InputStream containing the calendars feed.
- * @throws ParseException Thrown if an XmlPullParser could not be created.
- */
- public XmlCalendarsGDataParser(InputStream is, XmlPullParser parser)
- throws ParseException {
- super(is, parser);
- }
-
- /*
- * (non-Javadoc)
- * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createFeed()
- */
- protected Feed createFeed() {
- return new CalendarsFeed();
- }
-
- /*
- * (non-Javadoc)
- * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createEntry()
- */
- protected Entry createEntry() {
- return new CalendarEntry();
- }
-
- /*
- * (non-Javadoc)
- * @see XmlGDataParser#handleExtraElementInEntry
- */
- protected void handleExtraElementInEntry(Entry entry)
- throws XmlPullParserException, IOException {
-
- XmlPullParser parser = getParser();
-
- if (!(entry instanceof CalendarEntry)) {
- throw new IllegalArgumentException("Expected CalendarEntry!");
- }
- CalendarEntry calendarEntry = (CalendarEntry) entry;
-
- // NOTE: all of these names are assumed to be in the "gcal" namespace.
- // we do not bother checking that here.
- String name = parser.getName();
- if ("accesslevel".equals(name)) {
- String accesslevelStr = parser.getAttributeValue(null /* ns */,
- "value");
- byte accesslevel = CalendarEntry.ACCESS_READ;
- if ("none".equals(accesslevelStr)) {
- accesslevel = CalendarEntry.ACCESS_NONE;
- } else if ("read".equals(accesslevelStr)) {
- accesslevel = CalendarEntry.ACCESS_READ;
- } else if ("freebusy".equals(accesslevelStr)) {
- accesslevel = CalendarEntry.ACCESS_FREEBUSY;
- } else if ("contributor".equals(accesslevelStr)) {
- // contributor is the access level that used to be used, but it seems to have
- // been deprecated in favor of "editor".
- accesslevel = CalendarEntry.ACCESS_EDITOR;
- } else if ("editor".equals(accesslevelStr)) {
- accesslevel = CalendarEntry.ACCESS_EDITOR;
- } else if ("owner".equals(accesslevelStr)) {
- accesslevel = CalendarEntry.ACCESS_OWNER;
- }
- calendarEntry.setAccessLevel(accesslevel);
- } else if ("color".equals(name)) {
- String color =
- parser.getAttributeValue(null /* ns */, "value");
- calendarEntry.setColor(color);
- } else if ("hidden".equals(name)) {
- String hiddenStr =
- parser.getAttributeValue(null /* ns */, "value");
- boolean hidden = false;
- if ("false".equals(hiddenStr)) {
- hidden = false;
- } else if ("true".equals(hiddenStr)) {
- hidden = true;
- }
- calendarEntry.setHidden(hidden);
- // if the calendar is hidden, it cannot be selected.
- if (hidden) {
- calendarEntry.setSelected(false);
- }
- } else if ("selected".equals(name)) {
- String selectedStr =
- parser.getAttributeValue(null /* ns */, "value");
- boolean selected = false;
- if ("false".equals(selectedStr)) {
- selected = false;
- } else if ("true".equals(selectedStr)) {
- selected = true;
- }
- calendarEntry.setSelected(selected);
- } else if ("timezone".equals(name)) {
- String timezone =
- parser.getAttributeValue(null /* ns */, "value");
- calendarEntry.setTimezone(timezone);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see XmlGDataParser#handleExtraLinkInEntry
- */
- protected void handleExtraLinkInEntry(String rel,
- String type,
- String href,
- Entry entry)
- throws XmlPullParserException, IOException {
- if (("alternate".equals(rel)) &&
- ("application/atom+xml".equals(type))) {
- CalendarEntry calendarEntry = (CalendarEntry) entry;
- calendarEntry.setAlternateLink(href);
- }
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlEventsGDataParser.java b/src/com/google/wireless/gdata2/calendar/parser/xml/XmlEventsGDataParser.java
deleted file mode 100644
index 38f8272..0000000
--- a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlEventsGDataParser.java
+++ /dev/null
@@ -1,425 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.parser.xml;
-
-import com.google.wireless.gdata2.calendar.data.EventEntry;
-import com.google.wireless.gdata2.calendar.data.EventsFeed;
-import com.google.wireless.gdata2.calendar.data.When;
-import com.google.wireless.gdata2.calendar.data.Reminder;
-import com.google.wireless.gdata2.calendar.data.Who;
-import com.google.wireless.gdata2.data.Entry;
-import com.google.wireless.gdata2.data.Feed;
-import com.google.wireless.gdata2.data.StringUtils;
-import com.google.wireless.gdata2.data.XmlUtils;
-import com.google.wireless.gdata2.parser.ParseException;
-import com.google.wireless.gdata2.parser.xml.XmlGDataParser;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * GDataParser for an events feed containing events in a calendar.
- */
-public class XmlEventsGDataParser extends XmlGDataParser {
-
- // whether or not we've seen reminders directly under the entry.
- // the calendar feed sends duplicate <reminder> entries in case of
- // recurrences, if the recurrences are expanded.
- // if the <reminder> elements precede the <when> elements, we'll only
- // process the <reminder> elements directly under the entry and ignore
- // the <reminder> elements within a <when>.
- // if the <when> elements precede the <reminder> elements, we'll first
- // process reminders under the when, and then we'll clear them and process
- // the reminders directly under the entry (which should take precedence).
- // if we only see <reminder> as direct children of the entry or only see
- // <reminder> as children of <when> elements, there is no conflict.
- private boolean hasSeenReminder = false;
-
- /**
- * Creates a new XmlEventsGDataParser.
- * @param is The InputStream that should be parsed.
- * @throws ParseException Thrown if a parser cannot be created.
- */
- public XmlEventsGDataParser(InputStream is, XmlPullParser parser)
- throws ParseException {
- super(is, parser);
- }
-
- /*
- * (non-Javadoc)
- * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createFeed()
- */
- protected Feed createFeed() {
- return new EventsFeed();
- }
-
- /*
- * (non-Javadoc)
- * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createEntry()
- */
- protected Entry createEntry() {
- return new EventEntry();
- }
-
- protected void handleEntry(Entry entry) throws XmlPullParserException,
- IOException, ParseException {
- hasSeenReminder = false; // Reset the state for the new entry
- super.handleEntry(entry);
- }
-
- protected void handleExtraElementInFeed(Feed feed)
- throws XmlPullParserException, IOException {
- XmlPullParser parser = getParser();
- if (!(feed instanceof EventsFeed)) {
- throw new IllegalArgumentException("Expected EventsFeed!");
- }
- EventsFeed eventsFeed = (EventsFeed) feed;
- String name = parser.getName();
- if ("timezone".equals(name)) {
- String timezone = parser.getAttributeValue(null /* ns */, "value");
- if (!StringUtils.isEmpty(timezone)) {
- eventsFeed.setTimezone(timezone);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see XmlGDataParser#handleExtraElementInEntry
- */
- protected void handleExtraElementInEntry(Entry entry)
- throws XmlPullParserException, IOException, ParseException {
-
- XmlPullParser parser = getParser();
-
- if (!(entry instanceof EventEntry)) {
- throw new IllegalArgumentException("Expected EventEntry!");
- }
- EventEntry eventEntry = (EventEntry) entry;
-
- // NOTE: all of these names are assumed to be in the "gd" namespace.
- // we do not bother checking that here.
-
- String name = parser.getName();
- if ("eventStatus".equals(name)) {
- String eventStatusStr = parser.getAttributeValue(null, "value");
- byte eventStatus = EventEntry.STATUS_TENTATIVE;
- if ("http://schemas.google.com/g/2005#event.canceled".
- equals(eventStatusStr)) {
- eventStatus = EventEntry.STATUS_CANCELED;
- } else if ("http://schemas.google.com/g/2005#event.confirmed".
- equals(eventStatusStr)) {
- eventStatus = EventEntry.STATUS_CONFIRMED;
- } else if ("http://schemas.google.com/g/2005#event.tentative".
- equals(eventStatusStr)) {
- eventStatus = EventEntry.STATUS_TENTATIVE;
- }
- eventEntry.setStatus(eventStatus);
- } else if ("recurrence".equals(name)) {
- String recurrence = XmlUtils.extractChildText(parser);
- eventEntry.setRecurrence(recurrence);
- } else if ("transparency".equals(name)) {
- String transparencyStr = parser.getAttributeValue(null, "value");
- byte transparency = EventEntry.TRANSPARENCY_OPAQUE;
- if ("http://schemas.google.com/g/2005#event.opaque".
- equals(transparencyStr)) {
- transparency = EventEntry.TRANSPARENCY_OPAQUE;
- } else if ("http://schemas.google.com/g/2005#event.transparent".
- equals(transparencyStr)) {
- transparency = EventEntry.TRANSPARENCY_TRANSPARENT;
- }
- eventEntry.setTransparency(transparency);
- } else if ("visibility".equals(name)) {
- String visibilityStr = parser.getAttributeValue(null, "value");
- byte visibility = EventEntry.VISIBILITY_DEFAULT;
- if ("http://schemas.google.com/g/2005#event.confidential".
- equals(visibilityStr)) {
- visibility = EventEntry.VISIBILITY_CONFIDENTIAL;
- } else if ("http://schemas.google.com/g/2005#event.default"
- .equals(visibilityStr)) {
- visibility = EventEntry.VISIBILITY_DEFAULT;
- } else if ("http://schemas.google.com/g/2005#event.private"
- .equals(visibilityStr)) {
- visibility = EventEntry.VISIBILITY_PRIVATE;
- } else if ("http://schemas.google.com/g/2005#event.public"
- .equals(visibilityStr)) {
- visibility = EventEntry.VISIBILITY_PUBLIC;
- }
- eventEntry.setVisibility(visibility);
- } else if ("who".equals(name)) {
- handleWho(eventEntry);
- } else if ("when".equals(name)) {
- handleWhen(eventEntry);
- } else if ("reminder".equals(name)) {
- if (!hasSeenReminder) {
- // if this is the first <reminder> we've seen directly under the
- // entry, clear any previously seen reminders (under <when>s)
- eventEntry.clearReminders();
- hasSeenReminder = true;
- }
- handleReminder(eventEntry);
- } else if ("originalEvent".equals(name)) {
- handleOriginalEvent(eventEntry);
- } else if ("where".equals(name)) {
- String where = parser.getAttributeValue(null /* ns */,
- "valueString");
- String rel = parser.getAttributeValue(null /* ns */,
- "rel");
- if (StringUtils.isEmpty(rel) ||
- "http://schemas.google.com/g/2005#event".equals(rel)) {
- eventEntry.setWhere(where);
- }
- // TODO: handle entryLink?
- } else if ("feedLink".equals(name)) {
- // TODO: check that the parent is a gd:comments
- String commentsUri = parser.getAttributeValue(null /* ns */, "href");
- eventEntry.setCommentsUri(commentsUri);
- } else if ("extendedProperty".equals(name)) {
- String propertyName = parser.getAttributeValue(null /* ns */, "name");
- String propertyValue = parser.getAttributeValue(null /* ns */, "value");
- eventEntry.addExtendedProperty(propertyName, propertyValue);
- }
- }
-
- private void handleWho(EventEntry eventEntry)
- throws XmlPullParserException, IOException, ParseException {
-
- XmlPullParser parser = getParser();
-
- int eventType = parser.getEventType();
- String name = parser.getName();
-
- if (eventType != XmlPullParser.START_TAG ||
- (!"who".equals(parser.getName()))) {
- // should not happen.
- throw new
- IllegalStateException("Expected <who>: Actual "
- + "element: <"
- + name + ">");
- }
-
- String email =
- parser.getAttributeValue(null /* ns */, "email");
- String relString =
- parser.getAttributeValue(null /* ns */, "rel");
- String value =
- parser.getAttributeValue(null /* ns */, "valueString");
-
- Who who = new Who();
- who.setEmail(email);
- who.setValue(value);
- byte rel = Who.RELATIONSHIP_NONE;
- if ("http://schemas.google.com/g/2005#event.attendee".equals(relString)) {
- rel = Who.RELATIONSHIP_ATTENDEE;
- } else if ("http://schemas.google.com/g/2005#event.organizer".equals(relString)) {
- rel = Who.RELATIONSHIP_ORGANIZER;
- } else if ("http://schemas.google.com/g/2005#event.performer".equals(relString)) {
- rel = Who.RELATIONSHIP_PERFORMER;
- } else if ("http://schemas.google.com/g/2005#event.speaker".equals(relString)) {
- rel = Who.RELATIONSHIP_SPEAKER;
- } else if (StringUtils.isEmpty(relString)) {
- rel = Who.RELATIONSHIP_ATTENDEE;
- } else {
- throw new ParseException("Unexpected rel: " + relString);
- }
- who.setRelationship(rel);
-
- eventEntry.addAttendee(who);
-
- while (eventType != XmlPullParser.END_DOCUMENT) {
- switch (eventType) {
- case XmlPullParser.START_TAG:
- name = parser.getName();
- if ("attendeeStatus".equals(name)) {
- String statusString =
- parser.getAttributeValue(null /* ns */, "value");
- byte status = Who.STATUS_NONE;
- if ("http://schemas.google.com/g/2005#event.accepted".
- equals(statusString)) {
- status = Who.STATUS_ACCEPTED;
- } else if ("http://schemas.google.com/g/2005#event.declined".
- equals(statusString)) {
- status = Who.STATUS_DECLINED;
- } else if ("http://schemas.google.com/g/2005#event.invited".
- equals(statusString)) {
- status = Who.STATUS_INVITED;
- } else if ("http://schemas.google.com/g/2005#event.tentative".
- equals(statusString)) {
- status = Who.STATUS_TENTATIVE;
- } else if (StringUtils.isEmpty(statusString)) {
- status = Who.STATUS_TENTATIVE;
- } else {
- throw new ParseException("Unexpected status: " + statusString);
- }
- who.setStatus(status);
- } else if ("attendeeType".equals(name)) {
- String typeString= XmlUtils.extractChildText(parser);
- byte type = Who.TYPE_NONE;
- if ("http://schemas.google.com/g/2005#event.optional".equals(typeString)) {
- type = Who.TYPE_OPTIONAL;
- } else if ("http://schemas.google.com/g/2005#event.required".
- equals(typeString)) {
- type = Who.TYPE_REQUIRED;
- } else if (StringUtils.isEmpty(typeString)) {
- type = Who.TYPE_REQUIRED;
- } else {
- throw new ParseException("Unexpected type: " + typeString);
- }
- who.setType(type);
- }
- break;
- case XmlPullParser.END_TAG:
- name = parser.getName();
- if ("who".equals(name)) {
- return;
- }
- default:
- // ignore
- }
-
- eventType = parser.next();
- }
- }
-
- private void handleWhen(EventEntry eventEntry)
- throws XmlPullParserException, IOException {
-
- XmlPullParser parser = getParser();
-
- int eventType = parser.getEventType();
- String name = parser.getName();
-
- if (eventType != XmlPullParser.START_TAG ||
- (!"when".equals(parser.getName()))) {
- // should not happen.
- throw new
- IllegalStateException("Expected <when>: Actual "
- + "element: <"
- + name + ">");
- }
-
- String startTime =
- parser.getAttributeValue(null /* ns */, "startTime");
- String endTime =
- parser.getAttributeValue(null /* ns */, "endTime");
-
- When when = new When(startTime, endTime);
- eventEntry.addWhen(when);
- boolean firstWhen = eventEntry.getWhens().size() == 1;
- // we only parse reminders under the when if reminders have not already
- // been handled (directly under the entry, or in a previous when for
- // this entry)
- boolean handleReminders = firstWhen && !hasSeenReminder;
-
- eventType = parser.next();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- switch (eventType) {
- case XmlPullParser.START_TAG:
- name = parser.getName();
- if ("reminder".equals(name)) {
- // only want to store reminders on the first when. they
- // should have the same values for all other instances.
- if (handleReminders) {
- handleReminder(eventEntry);
- }
- }
- break;
- case XmlPullParser.END_TAG:
- name = parser.getName();
- if ("when".equals(name)) {
- return;
- }
- default:
- // ignore
- }
-
- eventType = parser.next();
- }
- }
-
- private void handleReminder(EventEntry eventEntry) {
- XmlPullParser parser = getParser();
-
- Reminder reminder = new Reminder();
- eventEntry.addReminder(reminder);
-
- String methodStr = parser.getAttributeValue(null /* ns */,
- "method");
- String minutesStr = parser.getAttributeValue(null /* ns */,
- "minutes");
- String hoursStr = parser.getAttributeValue(null /* ns */,
- "hours");
- String daysStr = parser.getAttributeValue(null /* ns */,
- "days");
-
- if (!StringUtils.isEmpty(methodStr)) {
- if ("alert".equals(methodStr)) {
- reminder.setMethod(Reminder.METHOD_ALERT);
- } else if ("email".equals(methodStr)) {
- reminder.setMethod(Reminder.METHOD_EMAIL);
- } else if ("sms".equals(methodStr)) {
- reminder.setMethod(Reminder.METHOD_SMS);
- }
- }
-
- int minutes = Reminder.MINUTES_DEFAULT;
- if (!StringUtils.isEmpty(minutesStr)) {
- minutes = StringUtils.parseInt(minutesStr, minutes);
- } else if (!StringUtils.isEmpty(hoursStr)) {
- minutes = 60*StringUtils.parseInt(hoursStr, minutes);
- } else if (!StringUtils.isEmpty(daysStr)) {
- minutes = 24*60*StringUtils.parseInt(daysStr, minutes);
- }
- // TODO: support absolute times?
- if (minutes < 0) {
- minutes = Reminder.MINUTES_DEFAULT;
- }
- reminder.setMinutes(minutes);
- }
-
- private void handleOriginalEvent(EventEntry eventEntry)
- throws XmlPullParserException, IOException {
-
- XmlPullParser parser = getParser();
-
- int eventType = parser.getEventType();
- String name = parser.getName();
-
- if (eventType != XmlPullParser.START_TAG ||
- (!"originalEvent".equals(parser.getName()))) {
- // should not happen.
- throw new
- IllegalStateException("Expected <originalEvent>: Actual "
- + "element: <"
- + name + ">");
- }
-
- eventEntry.setOriginalEventId(
- parser.getAttributeValue(null /* ns */, "href"));
-
- eventType = parser.next();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- switch (eventType) {
- case XmlPullParser.START_TAG:
- name = parser.getName();
- if ("when".equals(name)) {
- eventEntry.setOriginalEventStartTime(
- parser.getAttributeValue(null/*ns*/, "startTime"));
- }
- break;
- case XmlPullParser.END_TAG:
- name = parser.getName();
- if ("originalEvent".equals(name)) {
- return;
- }
- default:
- // ignore
- }
-
- eventType = parser.next();
- }
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/parser/xml/package.html b/src/com/google/wireless/gdata2/calendar/parser/xml/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/calendar/parser/xml/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/calendar/serializer/package.html b/src/com/google/wireless/gdata2/calendar/serializer/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/calendar/serializer/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/calendar/serializer/xml/XmlEventEntryGDataSerializer.java b/src/com/google/wireless/gdata2/calendar/serializer/xml/XmlEventEntryGDataSerializer.java
deleted file mode 100644
index ce16a77..0000000
--- a/src/com/google/wireless/gdata2/calendar/serializer/xml/XmlEventEntryGDataSerializer.java
+++ /dev/null
@@ -1,410 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.calendar.serializer.xml;
-
-import com.google.wireless.gdata2.calendar.data.EventEntry;
-import com.google.wireless.gdata2.calendar.data.When;
-import com.google.wireless.gdata2.calendar.data.Reminder;
-import com.google.wireless.gdata2.calendar.data.Who;
-import com.google.wireless.gdata2.data.StringUtils;
-import com.google.wireless.gdata2.parser.xml.XmlGDataParser;
-import com.google.wireless.gdata2.parser.xml.XmlParserFactory;
-import com.google.wireless.gdata2.parser.ParseException;
-import com.google.wireless.gdata2.serializer.xml.XmlEntryGDataSerializer;
-
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-
-/**
- * Serializes Google Calendar event entries into the Atom XML format.
- */
-// TODO: move all strings into constants. share with parser?
-public class XmlEventEntryGDataSerializer extends XmlEntryGDataSerializer {
-
- public static final String NAMESPACE_GCAL = "gCal";
- public static final String NAMESPACE_GCAL_URI =
- "http://schemas.google.com/gCal/2005";
-
- public XmlEventEntryGDataSerializer(XmlParserFactory factory,
- EventEntry entry) {
- super(factory, entry);
- }
-
- protected EventEntry getEventEntry() {
- return (EventEntry) getEntry();
- }
-
- protected void declareExtraEntryNamespaces(XmlSerializer serializer)
- throws IOException {
- serializer.setPrefix(NAMESPACE_GCAL, NAMESPACE_GCAL_URI);
- }
-
- /* (non-Javadoc)
- * @see XmlEntryGDataSerializer#serializeExtraEntryContents
- */
- protected void serializeExtraEntryContents(XmlSerializer serializer,
- int format)
- throws IOException, ParseException {
- EventEntry entry = getEventEntry();
-
- serializeEventStatus(serializer, entry.getStatus());
- serializeTransparency(serializer, entry.getTransparency());
- serializeVisibility(serializer, entry.getVisibility());
- Enumeration attendees = entry.getAttendees().elements();
- while (attendees.hasMoreElements()) {
- Who attendee = (Who) attendees.nextElement();
- serializeWho(serializer, entry, attendee);
- }
-
- serializeRecurrence(serializer, entry.getRecurrence());
- // either serialize reminders directly under the entry, or serialize
- // whens (with reminders within the whens) -- should be just one.
- if (entry.getRecurrence() != null) {
- if (entry.getReminders() != null) {
- Enumeration reminders = entry.getReminders().elements();
- while (reminders.hasMoreElements()) {
- Reminder reminder = (Reminder) reminders.nextElement();
- serializeReminder(serializer, reminder);
- }
- }
- } else {
- Enumeration whens = entry.getWhens().elements();
- while (whens.hasMoreElements()) {
- When when = (When) whens.nextElement();
- serializeWhen(serializer, entry, when);
- }
- }
- serializeOriginalEvent(serializer,
- entry.getOriginalEventId(),
- entry.getOriginalEventStartTime());
- serializeWhere(serializer, entry.getWhere());
-
- serializeCommentsUri(serializer, entry.getCommentsUri());
-
- Hashtable extendedProperties = entry.getExtendedProperties();
- if (extendedProperties != null) {
- Enumeration propertyNames = extendedProperties.keys();
- while (propertyNames.hasMoreElements()) {
- String propertyName = (String) propertyNames.nextElement();
- String propertyValue = (String) extendedProperties.get(propertyName);
- serializeExtendedProperty(serializer, propertyName, propertyValue);
- }
- }
-
- serializeQuickAdd(serializer, entry.isQuickAdd());
- }
-
- private static void serializeEventStatus(XmlSerializer serializer,
- byte status)
- throws IOException {
-
- String statusString;
-
- switch (status) {
- case EventEntry.STATUS_TENTATIVE:
- statusString = "http://schemas.google.com/g/2005#event.tentative";
- break;
- case EventEntry.STATUS_CANCELED:
- statusString = "http://schemas.google.com/g/2005#event.canceled";
- break;
- case EventEntry.STATUS_CONFIRMED:
- statusString = "http://schemas.google.com/g/2005#event.confirmed";
- break;
- default:
- // should not happen
- // TODO: log this
- statusString = "http://schemas.google.com/g/2005#event.tentative";
- }
-
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "eventStatus");
- serializer.attribute(null /* ns */, "value", statusString);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "eventStatus");
- }
-
- private static void serializeRecurrence(XmlSerializer serializer,
- String recurrence)
- throws IOException {
- if (StringUtils.isEmpty(recurrence)) {
- return;
- }
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "recurrence");
- serializer.text(recurrence);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "recurrence");
- }
-
- private static void serializeTransparency(XmlSerializer serializer,
- byte transparency)
- throws IOException {
-
- String transparencyString;
-
- switch (transparency) {
- case EventEntry.TRANSPARENCY_OPAQUE:
- transparencyString =
- "http://schemas.google.com/g/2005#event.opaque";
- break;
- case EventEntry.TRANSPARENCY_TRANSPARENT:
- transparencyString =
- "http://schemas.google.com/g/2005#event.transparent";
- break;
- default:
- // should not happen
- // TODO: log this
- transparencyString =
- "http://schemas.google.com/g/2005#event.transparent";
- }
-
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "transparency");
- serializer.attribute(null /* ns */, "value", transparencyString);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "transparency");
- }
-
-
- private static void serializeVisibility(XmlSerializer serializer,
- byte visibility)
- throws IOException {
-
- String visibilityString;
-
- switch (visibility) {
- case EventEntry.VISIBILITY_DEFAULT:
- visibilityString = "http://schemas.google.com/g/2005#event.default";
- break;
- case EventEntry.VISIBILITY_CONFIDENTIAL:
- visibilityString =
- "http://schemas.google.com/g/2005#event.confidential";
- break;
- case EventEntry.VISIBILITY_PRIVATE:
- visibilityString = "http://schemas.google.com/g/2005#event.private";
- break;
- case EventEntry.VISIBILITY_PUBLIC:
- visibilityString = "http://schemas.google.com/g/2005#event.public";
- break;
- default:
- // should not happen
- // TODO: log this
- visibilityString = "http://schemas.google.com/g/2005#event.default";
- }
-
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "visibility");
- serializer.attribute(null /* ns */, "value", visibilityString);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "visibility");
- }
-
- private static void serializeWho(XmlSerializer serializer,
- EventEntry entry,
- Who who)
- throws IOException, ParseException {
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "who");
- String email = who.getEmail();
- if (!StringUtils.isEmpty(email)) {
- serializer.attribute(null /* ns */, "email", email);
- }
-
- String value = who.getValue();
- if (!StringUtils.isEmpty(value)) {
- serializer.attribute(null /* ns */, "valueString", value);
- }
-
- String rel = null;
- switch (who.getRelationship()) {
- case Who.RELATIONSHIP_NONE:
- break;
- case Who.RELATIONSHIP_ATTENDEE:
- rel = "http://schemas.google.com/g/2005#event.attendee";
- break;
- case Who.RELATIONSHIP_ORGANIZER:
- rel = "http://schemas.google.com/g/2005#event.organizer";
- break;
- case Who.RELATIONSHIP_PERFORMER:
- rel = "http://schemas.google.com/g/2005#event.performer";
- break;
- case Who.RELATIONSHIP_SPEAKER:
- rel = "http://schemas.google.com/g/2005#event.speaker";
- break;
- default:
- throw new ParseException("Unexpected rel: " + who.getRelationship());
- }
- if (!StringUtils.isEmpty(rel)) {
- serializer.attribute(null /* ns */, "rel", rel);
- }
-
- String status = null;
- switch (who.getStatus()) {
- case Who.STATUS_NONE:
- break;
- case Who.STATUS_ACCEPTED:
- status = "http://schemas.google.com/g/2005#event.accepted";
- break;
- case Who.STATUS_DECLINED:
- status = "http://schemas.google.com/g/2005#event.declined";
- break;
- case Who.STATUS_INVITED:
- status = "http://schemas.google.com/g/2005#event.invited";
- break;
- case Who.STATUS_TENTATIVE:
- status = "http://schemas.google.com/g/2005#event.tentative";
- break;
- default:
- throw new ParseException("Unexpected status: " + who.getStatus());
- }
- if (!StringUtils.isEmpty(status)) {
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI,
- "attendeeStatus");
- serializer.attribute(null /* ns */, "value", status);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI,
- "attendeeStatus");
- }
-
- String type = null;
- switch (who.getType()) {
- case Who.TYPE_NONE:
- break;
- case Who.TYPE_REQUIRED:
- type = "http://schemas.google.com/g/2005#event.required";
- break;
- case Who.TYPE_OPTIONAL:
- type = "http://schemas.google.com/g/2005#event.optional";
- break;
- default:
- throw new ParseException("Unexpected type: " + who.getType());
- }
- if (!StringUtils.isEmpty(type)) {
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI,
- "attendeeType");
- serializer.attribute(null /* ns */, "value", type);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "attendeeType");
- }
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "who");
- }
-
- private static void serializeWhen(XmlSerializer serializer,
- EventEntry entry,
- When when)
- throws IOException {
- // TODO: throw exn if startTime is empty but endTime is not?
- String startTime = when.getStartTime();
- String endTime = when.getEndTime();
- if (StringUtils.isEmpty(when.getStartTime())) {
- return;
- }
-
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "when");
- serializer.attribute(null /* ns */, "startTime", startTime);
- if (!StringUtils.isEmpty(endTime)) {
- serializer.attribute(null /* ns */, "endTime", endTime);
- }
- if (entry.getReminders() != null) {
- Enumeration reminders = entry.getReminders().elements();
- while (reminders.hasMoreElements()) {
- Reminder reminder = (Reminder) reminders.nextElement();
- serializeReminder(serializer, reminder);
- }
- }
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "when");
- }
-
- private static void serializeReminder(XmlSerializer serializer,
- Reminder reminder)
- throws IOException {
-
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "reminder");
- byte method = reminder.getMethod();
- String methodStr = null;
- switch (method) {
- case Reminder.METHOD_ALERT:
- methodStr = "alert";
- break;
- case Reminder.METHOD_EMAIL:
- methodStr = "email";
- break;
- case Reminder.METHOD_SMS:
- methodStr = "sms";
- break;
- }
- if (methodStr != null) {
- serializer.attribute(null /* ns */, "method", methodStr);
- }
-
- int minutes = reminder.getMinutes();
- if (minutes != Reminder.MINUTES_DEFAULT) {
- serializer.attribute(null /* ns */, "minutes",
- Integer.toString(minutes));
- }
-
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "reminder");
- }
-
- private static void serializeOriginalEvent(XmlSerializer serializer,
- String originalEventId,
- String originalEventTime)
- throws IOException {
- if (StringUtils.isEmpty(originalEventId) ||
- StringUtils.isEmpty(originalEventTime)) {
- return;
- }
-
-
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "originalEvent");
- int index = originalEventId.lastIndexOf('/');
- if (index != -1) {
- String id = originalEventId.substring(index + 1);
- if (!StringUtils.isEmpty(id)) {
- serializer.attribute(null /* ns */, "id", id);
- }
- }
- serializer.attribute(null /* ns */, "href", originalEventId);
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "when");
- serializer.attribute(null /* ns */, "startTime", originalEventTime);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "when");
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "originalEvent");
- }
-
-
- private static void serializeWhere(XmlSerializer serializer,
- String where)
- throws IOException {
- if (StringUtils.isEmpty(where)) {
- return;
- }
-
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "where");
- serializer.attribute(null /* ns */, "valueString", where);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "where");
- }
-
- private static void serializeCommentsUri(XmlSerializer serializer,
- String commentsUri)
- throws IOException {
- if (commentsUri == null) {
- return;
- }
-
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "feedLink");
- serializer.attribute(null /* ns */, "href", commentsUri);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "feedLink");
- }
-
- private static void serializeExtendedProperty(XmlSerializer serializer,
- String name,
- String value)
- throws IOException {
- serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "extendedProperty");
- serializer.attribute(null /* ns */, "name", name);
- serializer.attribute(null /* ns */, "value", value);
- serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "extendedProperty");
- }
-
- private static void serializeQuickAdd(XmlSerializer serializer,
- boolean quickAdd) throws IOException {
- if (quickAdd) {
- serializer.startTag(NAMESPACE_GCAL, "quickadd");
- serializer.attribute(null /* ns */, "value", "true");
- serializer.endTag(NAMESPACE_GCAL, "quickadd");
- }
- }
-}
diff --git a/src/com/google/wireless/gdata2/calendar/serializer/xml/package.html b/src/com/google/wireless/gdata2/calendar/serializer/xml/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/calendar/serializer/xml/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/client/BadRequestException.java b/src/com/google/wireless/gdata2/client/BadRequestException.java
new file mode 100644
index 0000000..6e2e98b
--- /dev/null
+++ b/src/com/google/wireless/gdata2/client/BadRequestException.java
@@ -0,0 +1,37 @@
+// Copyright 2009 The Android Open Source Project.
+
+package com.google.wireless.gdata2.client;
+
+import com.google.wireless.gdata2.GDataException;
+
+/**
+ * Exception thrown when the server returns a 400 Bad Request.
+ */
+public class BadRequestException extends GDataException {
+
+ /**
+ * Creates a new AuthenticationException.
+ */
+ public BadRequestException() {
+ }
+
+ /**
+ * Creates a new BadRequestException with a supplied message.
+ * @param message The message for the exception.
+ */
+ public BadRequestException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a new BadRequestException with a supplied message and
+ * underlying cause.
+ *
+ * @param message The message for the exception.
+ * @param cause Another throwable that was caught and wrapped in this
+ * exception.
+ */
+ public BadRequestException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
\ No newline at end of file
diff --git a/src/com/google/wireless/gdata2/client/GDataServiceClient.java b/src/com/google/wireless/gdata2/client/GDataServiceClient.java
index dfdc31f..5e0aea1 100644
--- a/src/com/google/wireless/gdata2/client/GDataServiceClient.java
+++ b/src/com/google/wireless/gdata2/client/GDataServiceClient.java
@@ -169,10 +169,12 @@
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with the
* GData service.
+ * @throws BadRequestException thrown if the server returns a 400
+ * @throws ForbiddenException thrown if the server returns a 403
*/
public Entry createEntry(String feedUrl, String authToken, Entry entry)
throws ConflictDetectedException, AuthenticationException, PreconditionFailedException,
- HttpException, ParseException, IOException, ForbiddenException {
+ HttpException, ParseException, IOException, ForbiddenException, BadRequestException {
GDataSerializer serializer = gDataParserFactory.createSerializer(entry);
try {
InputStream is =
@@ -241,10 +243,13 @@
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with the
* GData service.
+ * @throws BadRequestException thrown if the server returns a 400
+ * @throws ForbiddenException thrown if the server returns a 403
+ * @throws ResourceNotFoundException Thrown if the resource was not found.
*/
public Entry updateEntry(Entry entry, String authToken) throws AuthenticationException,
ConflictDetectedException, PreconditionFailedException, HttpException, ParseException,
- IOException, ForbiddenException, ResourceNotFoundException {
+ IOException, ForbiddenException, ResourceNotFoundException, BadRequestException {
String editUri = entry.getEditUri();
if (StringUtils.isEmpty(editUri)) {
throw new ParseException("No edit URI -- cannot update.");
@@ -286,11 +291,14 @@
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with the
* GData service.
+ * @throws BadRequestException thrown if the server returns a 400
+ * @throws ForbiddenException thrown if the server returns a 403
+ * @throws ResourceNotFoundException Thrown if the resource was not found.
*/
public MediaEntry updateMediaEntry(String editUri, InputStream inputStream, String contentType,
String authToken, String eTag) throws AuthenticationException, ConflictDetectedException,
PreconditionFailedException, HttpException, ParseException, IOException,
- ForbiddenException, ResourceNotFoundException {
+ ForbiddenException, ResourceNotFoundException, BadRequestException {
if (StringUtils.isEmpty(editUri)) {
throw new IllegalArgumentException("No edit URI -- cannot update.");
}
@@ -323,11 +331,14 @@
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with the
* GData service.
+ * @throws BadRequestException thrown if the server returns a 400
+ * @throws ForbiddenException thrown if the server returns a 403
+ * @throws ResourceNotFoundException Thrown if the resource was not found.
*/
public void deleteEntry(String editUri, String authToken, String eTag)
throws AuthenticationException, ConflictDetectedException, PreconditionFailedException,
HttpException, ParseException, IOException, ForbiddenException,
- ResourceNotFoundException {
+ ResourceNotFoundException, BadRequestException {
try {
gDataClient.deleteEntry(editUri, authToken, eTag);
} catch (HttpException e) {
@@ -365,10 +376,12 @@
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with the
* GData service.
+ * @throws BadRequestException thrown if the server returns a 400
+ * @throws ForbiddenException thrown if the server returns a 403
*/
public GDataParser submitBatch(Class feedEntryClass, String batchUrl, String authToken,
Enumeration entries) throws AuthenticationException, HttpException, ParseException,
- IOException, ForbiddenException {
+ IOException, ForbiddenException, BadRequestException {
GDataSerializer serializer = gDataParserFactory.createSerializer(entries);
try {
InputStream is =
@@ -417,14 +430,15 @@
}
protected void convertHttpExceptionsForBatches(String message, HttpException cause)
- throws AuthenticationException, ParseException, HttpException, ForbiddenException {
+ throws AuthenticationException, ParseException, HttpException, ForbiddenException,
+ BadRequestException {
switch (cause.getStatusCode()) {
case HttpException.SC_FORBIDDEN:
throw new ForbiddenException(message, cause);
case HttpException.SC_UNAUTHORIZED:
throw new AuthenticationException(message, cause);
case HttpException.SC_BAD_REQUEST:
- throw new ParseException(message + ": " + cause);
+ throw new BadRequestException(message, cause);
default:
throw new HttpException(message + ": " + cause.getMessage(), cause.getStatusCode(), cause
.getResponseStream());
@@ -435,7 +449,7 @@
HttpException cause)
throws ConflictDetectedException, AuthenticationException, PreconditionFailedException,
ParseException, HttpException, IOException, ForbiddenException,
- ResourceNotFoundException {
+ ResourceNotFoundException, BadRequestException {
switch (cause.getStatusCode()) {
case HttpException.SC_CONFLICT:
Entry entry = null;
@@ -447,7 +461,7 @@
}
throw new ConflictDetectedException(entry);
case HttpException.SC_BAD_REQUEST:
- throw new ParseException(message + ": " + cause);
+ throw new BadRequestException(message, cause);
case HttpException.SC_FORBIDDEN:
throw new ForbiddenException(message, cause);
case HttpException.SC_UNAUTHORIZED:
diff --git a/src/com/google/wireless/gdata2/contacts/data/CalendarLink.java b/src/com/google/wireless/gdata2/contacts/data/CalendarLink.java
index ad1f9d1..71fef94 100644
--- a/src/com/google/wireless/gdata2/contacts/data/CalendarLink.java
+++ b/src/com/google/wireless/gdata2/contacts/data/CalendarLink.java
@@ -14,12 +14,19 @@
public static final byte TYPE_WORK = 2;
public static final byte TYPE_FREE_BUSY = 3;
-
/**
* default empty constructor
*/
public CalendarLink() {}
+ /**
+ * constructor that allows initialization
+ */
+ public CalendarLink(String href, byte type, String label, boolean isPrimary) {
+ super(type, label, isPrimary);
+ setHRef(href);
+ }
+
private String href;
/**
diff --git a/src/com/google/wireless/gdata2/contacts/data/ContactEntry.java b/src/com/google/wireless/gdata2/contacts/data/ContactEntry.java
index 906f9a4..00d7b4c 100644
--- a/src/com/google/wireless/gdata2/contacts/data/ContactEntry.java
+++ b/src/com/google/wireless/gdata2/contacts/data/ContactEntry.java
@@ -49,6 +49,8 @@
private String birthday;
private String billingInformation;
+ public static final String GENDER_MALE = "male";
+ public static final String GENDER_FEMALE = "female";
public static final byte TYPE_PRIORITY_HIGH = 1;
public static final byte TYPE_PRIORITY_NORMAL = 2;
public static final byte TYPE_PRIORITY_LOW = 3;
@@ -635,7 +637,7 @@
for (Enumeration iter = jots.elements();
iter.hasMoreElements(); ) {
sb.append(" ");
- sb.append ((String) iter.nextElement());
+ sb.append ((Jot) iter.nextElement());
sb.append("\n");
}
for (Enumeration iter = languages.elements();
@@ -666,6 +668,11 @@
public void validate() throws ParseException {
super.validate();
+ if (gender != null && !GENDER_FEMALE.equals(gender) && !GENDER_MALE.equals(gender)) {
+ throw new ParseException(
+ String.format("invalid gender \"%s\", must be one of \"%s\" or \"%s\"",
+ gender, GENDER_FEMALE, GENDER_MALE));
+ }
for (Enumeration iter = emailAddresses.elements(); iter.hasMoreElements(); ) {
((EmailAddress) iter.nextElement()).validate();
}
diff --git a/src/com/google/wireless/gdata2/contacts/data/ExternalId.java b/src/com/google/wireless/gdata2/contacts/data/ExternalId.java
index 25c124a..f0c1bc2 100644
--- a/src/com/google/wireless/gdata2/contacts/data/ExternalId.java
+++ b/src/com/google/wireless/gdata2/contacts/data/ExternalId.java
@@ -26,6 +26,14 @@
public ExternalId() {}
/**
+ * constructor that allows initialization
+ */
+ public ExternalId(String value, byte type, String label) {
+ super(type, label);
+ setValue(value);
+ }
+
+ /**
* The value of this external ID.
*/
public String getValue() {
@@ -40,10 +48,20 @@
}
public void toString(StringBuffer sb) {
+ sb.append("ExternalId");
super.toString(sb);
if (!StringUtils.isEmpty(value)) {
sb.append(" value:").append(value);
}
}
+
+ /**
+ * override default behaviour, an externalId has its own rules for type and label
+ */
+ public void validate() throws ParseException {
+ if (value == null) {
+ throw new ParseException("the value must be set");
+ }
+ }
}
diff --git a/src/com/google/wireless/gdata2/contacts/data/GroupMembershipInfo.java b/src/com/google/wireless/gdata2/contacts/data/GroupMembershipInfo.java
index 70136d0..d328773 100644
--- a/src/com/google/wireless/gdata2/contacts/data/GroupMembershipInfo.java
+++ b/src/com/google/wireless/gdata2/contacts/data/GroupMembershipInfo.java
@@ -15,6 +15,14 @@
*/
public GroupMembershipInfo() {}
+ /**
+ * constructor that allows initializing the GroupMembershipInfo
+ */
+ public GroupMembershipInfo(String groupId, boolean deleted) {
+ setGroup(groupId);
+ setDeleted(deleted);
+ }
+
public String getGroup() {
return group;
}
diff --git a/src/com/google/wireless/gdata2/contacts/data/Jot.java b/src/com/google/wireless/gdata2/contacts/data/Jot.java
index ce896a7..81a92b9 100644
--- a/src/com/google/wireless/gdata2/contacts/data/Jot.java
+++ b/src/com/google/wireless/gdata2/contacts/data/Jot.java
@@ -4,6 +4,7 @@
package com.google.wireless.gdata2.contacts.data;
import com.google.wireless.gdata2.parser.ParseException;
+import com.google.wireless.gdata2.data.StringUtils;
/**
@@ -18,14 +19,46 @@
public static final byte TYPE_USER = 4;
public static final byte TYPE_OTHER = 5;
+ private String value;
+
/**
* default empty constructor
*/
public Jot() {}
/**
+ * constructor that allows initialization
+ */
+ public Jot(String value, byte type, String label) {
+ super(type, label);
+ setValue(value);
+ }
+
+ /**
* override default behaviour, a jot is not relying on either
* label or type
*/
public void validate() throws ParseException {}
+
+ /**
+ * The value of this Jot
+ */
+ public String getValue() {
+ return this.value;
+ }
+
+ /**
+ * The value of this Jot.
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public void toString(StringBuffer sb) {
+ sb.append("Jot");
+ super.toString(sb);
+ if (!StringUtils.isEmpty(value)) {
+ sb.append(" value:").append(value);
+ }
+ }
}
diff --git a/src/com/google/wireless/gdata2/contacts/data/Language.java b/src/com/google/wireless/gdata2/contacts/data/Language.java
index e04c1e4..0ca6ae3 100644
--- a/src/com/google/wireless/gdata2/contacts/data/Language.java
+++ b/src/com/google/wireless/gdata2/contacts/data/Language.java
@@ -26,6 +26,14 @@
*/
public Language() {}
+ /**
+ * constructor that allows initialization
+ */
+ public Language(String label, String code) {
+ setLabel(label);
+ setCode(code);
+ }
+
/**
* A freeform name of a language. Must not be empty or all
* whitespace.
@@ -70,7 +78,7 @@
public void toString(StringBuffer sb) {
- sb.append("ExternalId");
+ sb.append("Language");
if (!StringUtils.isEmpty(code)) {
sb.append(" code:").append(code);
}
diff --git a/src/com/google/wireless/gdata2/contacts/data/UserDefinedField.java b/src/com/google/wireless/gdata2/contacts/data/UserDefinedField.java
index 8696422..c127a68 100644
--- a/src/com/google/wireless/gdata2/contacts/data/UserDefinedField.java
+++ b/src/com/google/wireless/gdata2/contacts/data/UserDefinedField.java
@@ -71,7 +71,7 @@
public void toString(StringBuffer sb) {
- sb.append("ExternalId");
+ sb.append("UserDefinedField");
if (!StringUtils.isEmpty(key)) {
sb.append(" key:").append(key);
}
diff --git a/src/com/google/wireless/gdata2/contacts/parser/xml/XmlContactsGDataParser.java b/src/com/google/wireless/gdata2/contacts/parser/xml/XmlContactsGDataParser.java
index bcc3469..47ef50a 100644
--- a/src/com/google/wireless/gdata2/contacts/parser/xml/XmlContactsGDataParser.java
+++ b/src/com/google/wireless/gdata2/contacts/parser/xml/XmlContactsGDataParser.java
@@ -445,7 +445,7 @@
} else if (XmlNametable.GC_LANGUAGE.equals(name)) {
Language language = new Language();
language.setCode(parser.getAttributeValue(null /* ns */, XmlNametable.CODE));
- language.setLabel(parser.getAttributeValue(null /* */, XmlNametable.VALUE));
+ language.setLabel(parser.getAttributeValue(null /* */, XmlNametable.LABEL));
contactEntry.addLanguage(language);
} else if (XmlNametable.GC_MAIDENNAME.equals(name)) {
contactEntry.setMaidenName(XmlUtils.extractChildText(parser));
diff --git a/src/com/google/wireless/gdata2/contacts/serializer/xml/XmlContactEntryGDataSerializer.java b/src/com/google/wireless/gdata2/contacts/serializer/xml/XmlContactEntryGDataSerializer.java
index 2efb158..78e898a 100644
--- a/src/com/google/wireless/gdata2/contacts/serializer/xml/XmlContactEntryGDataSerializer.java
+++ b/src/com/google/wireless/gdata2/contacts/serializer/xml/XmlContactEntryGDataSerializer.java
@@ -151,7 +151,7 @@
// now serialize simple properties
serializeElement(serializer, entry.getDirectoryServer(), XmlNametable.GC_DIRECTORYSERVER);
- serializeElement(serializer, entry.getGender(), XmlNametable.GC_GENDER);
+ serializeGenderElement(serializer, entry.getGender());
serializeElement(serializer, entry.getInitials(), XmlNametable.GC_INITIALS);
serializeElement(serializer, entry.getMaidenName(), XmlNametable.GC_MAIDENNAME);
serializeElement(serializer, entry.getMileage(), XmlNametable.GC_MILEAGE);
@@ -508,6 +508,14 @@
serializer.endTag(XmlContactsGDataParser.NAMESPACE_CONTACTS_URI, elementName);
}
+ private static void serializeGenderElement(XmlSerializer serializer, String value)
+ throws IOException {
+ if (StringUtils.isEmpty(value)) return;
+ serializer.startTag(XmlContactsGDataParser.NAMESPACE_CONTACTS_URI, XmlNametable.GC_GENDER);
+ serializer.attribute(null /* ns */, XmlNametable.VALUE, value);
+ serializer.endTag(XmlContactsGDataParser.NAMESPACE_CONTACTS_URI, XmlNametable.GC_GENDER);
+ }
+
private static void serializeElement(XmlSerializer serializer, byte value, String elementName,
Hashtable typeToRelMap) throws IOException {
if (value == TypedElement.TYPE_NONE) return;
diff --git a/src/com/google/wireless/gdata2/data/Entry.java b/src/com/google/wireless/gdata2/data/Entry.java
index a1a73a4..f0ac78a 100644
--- a/src/com/google/wireless/gdata2/data/Entry.java
+++ b/src/com/google/wireless/gdata2/data/Entry.java
@@ -132,7 +132,7 @@
* @param type the contentType to set
*/
public void setContentType(String type) {
- this.contentType = content;
+ this.contentType = type;
}
/**
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/client/SubscribedFeedsClient.java b/src/com/google/wireless/gdata2/subscribedfeeds/client/SubscribedFeedsClient.java
deleted file mode 100644
index 734f185..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/client/SubscribedFeedsClient.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata2.subscribedfeeds.client;
-
-import com.google.wireless.gdata2.client.GDataClient;
-import com.google.wireless.gdata2.client.GDataParserFactory;
-import com.google.wireless.gdata2.client.GDataServiceClient;
-
-/**
- * GDataServiceClient for accessing Subscribed Feeds. This client can access
- * subscribed feeds for specific users. The parser this class uses handles
- * the XML version of feeds.
- */
-public class SubscribedFeedsClient extends GDataServiceClient {
-
- /** Service value for contacts. This is only used for downloads; uploads
- * are done using the service that corresponds to the subscribed feed. */
- public static final String SERVICE = "mail";
-
- /**
- * Create a new SubscribedFeedsClient.
- * @param client The GDataClient that should be used to authenticate
- * requests, retrieve feeds, etc.
- */
- public SubscribedFeedsClient(GDataClient client, GDataParserFactory factory) {
- super(client, factory);
- }
-
- /*
- * (non-Javadoc)
- * @see GDataServiceClient#getServiceName()
- */
- public String getServiceName() {
- return SERVICE;
- }
-
- /**
- * Returns the protocol version used by this GDataServiceClient,
- * in the form of a string. Subscribed feeds is using the default
- *
- * @return protocolVersion
- */
- public String getProtocolVersion() {
- return DEFAULT_GDATA_VERSION;
- }
-}
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/client/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/client/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/client/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/data/FeedUrl.java b/src/com/google/wireless/gdata2/subscribedfeeds/data/FeedUrl.java
deleted file mode 100644
index 523f8ea..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/data/FeedUrl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-** Copyright 2006, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** See the License for the specific language governing permissions and
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** limitations under the License.
-*/
-
-package com.google.wireless.gdata2.subscribedfeeds.data;
-
-/**
- * The FeedUrl GData type.
- */
-public class FeedUrl {
- private String feed;
- private String service;
- private String authToken;
-
- public FeedUrl() {
- }
-
- public FeedUrl(String feed, String service, String authToken) {
- setFeed(feed);
- setService(service);
- setAuthToken(authToken);
- }
-
- public String getFeed() {
- return feed;
- }
-
- public void setFeed(String feed) {
- this.feed = feed;
- }
-
- public String getService() {
- return service;
- }
-
- public void setService(String service) {
- this.service = service;
- }
-
- public String getAuthToken() {
- return authToken;
- }
-
- public void setAuthToken(String authToken) {
- this.authToken = authToken;
- }
-
- public void toString(StringBuffer sb) {
- sb.append("FeedUrl");
- sb.append(" url:").append(getFeed());
- sb.append(" service:").append(getService());
- sb.append(" authToken:").append(getAuthToken());
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- toString(sb);
- return sb.toString();
- }
-}
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsEntry.java b/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsEntry.java
deleted file mode 100644
index 319d6fd..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsEntry.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-package com.google.wireless.gdata2.subscribedfeeds.data;
-
-import com.google.wireless.gdata2.data.Entry;
-
-/**
- * Entry containing information about a contact.
- */
-public class SubscribedFeedsEntry extends Entry {
- private FeedUrl feedUrl;
- private String routingInfo;
- private String clientToken;
-
- public String getClientToken() {
- return clientToken;
- }
-
- public void setClientToken(String clientToken) {
- this.clientToken = clientToken;
- }
-
- public SubscribedFeedsEntry() {
- super();
- }
-
- public FeedUrl getSubscribedFeed() {
- return feedUrl;
- }
-
- public void setSubscribedFeed(FeedUrl feedUrl) {
- this.feedUrl = feedUrl;
- }
-
- public String getRoutingInfo() {
- return routingInfo;
- }
-
- public void setRoutingInfo(String routingInfo) {
- this.routingInfo = routingInfo;
- }
-
- /*
- * (non-Javadoc)
- * @see com.google.wireless.gdata2.data.Entry#clear()
- */
- public void clear() {
- super.clear();
- }
-
- public void toString(StringBuffer sb) {
- super.toString(sb);
- }
-}
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsFeed.java b/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsFeed.java
deleted file mode 100644
index 6eb600e..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsFeed.java
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-package com.google.wireless.gdata2.subscribedfeeds.data;
-
-import com.google.wireless.gdata2.data.Feed;
-
-/**
- * Feed containing contacts.
- */
-public class SubscribedFeedsFeed extends Feed {
- /**
- * Creates a new empty events feed.
- */
- public SubscribedFeedsFeed() {
- }
-}
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/data/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/data/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/data/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/parser/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/parser/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/parser/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParser.java b/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParser.java
deleted file mode 100644
index 5f5cb6d..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParser.java
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-package com.google.wireless.gdata2.subscribedfeeds.parser.xml;
-
-import com.google.wireless.gdata2.data.Entry;
-import com.google.wireless.gdata2.data.Feed;
-import com.google.wireless.gdata2.data.XmlUtils;
-import com.google.wireless.gdata2.parser.ParseException;
-import com.google.wireless.gdata2.parser.xml.XmlGDataParser;
-import com.google.wireless.gdata2.subscribedfeeds.data.FeedUrl;
-import com.google.wireless.gdata2.subscribedfeeds.data.SubscribedFeedsEntry;
-import com.google.wireless.gdata2.subscribedfeeds.data.SubscribedFeedsFeed;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * GDataParser for a subscribed feeds feed.
- */
-public class XmlSubscribedFeedsGDataParser extends XmlGDataParser {
- /**
- * Creates a new XmlSubscribedFeedsGDataParser.
- * @param is The InputStream that should be parsed.
- * @throws ParseException Thrown if a parser cannot be created.
- */
- public XmlSubscribedFeedsGDataParser(InputStream is, XmlPullParser parser)
- throws ParseException {
- super(is, parser);
- }
-
- /*
- * (non-Javadoc)
- * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createFeed()
- */
- protected Feed createFeed() {
- return new SubscribedFeedsFeed();
- }
-
- /*
- * (non-Javadoc)
- * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createEntry()
- */
- protected Entry createEntry() {
- return new SubscribedFeedsEntry();
- }
-
- protected void handleExtraElementInEntry(Entry entry)
- throws XmlPullParserException, IOException {
- XmlPullParser parser = getParser();
-
- if (!(entry instanceof SubscribedFeedsEntry)) {
- throw new IllegalArgumentException("Expected SubscribedFeedsEntry!");
- }
- SubscribedFeedsEntry subscribedFeedsEntry =
- (SubscribedFeedsEntry) entry;
- String name = parser.getName();
- if ("feedurl".equals(name)) {
- FeedUrl feedUrl = new FeedUrl();
- feedUrl.setFeed(parser.getAttributeValue(null /* ns */, "value"));
- feedUrl.setService(parser.getAttributeValue(null /* ns */, "service"));
- feedUrl.setAuthToken(parser.getAttributeValue(null /* ns */, "authtoken"));
- subscribedFeedsEntry.setSubscribedFeed(feedUrl);
- }
- if ("routingInfo".equals(name)) {
- subscribedFeedsEntry.setRoutingInfo(
- XmlUtils.extractChildText(parser));
- }
- if ("clientToken".equals(name)) {
- subscribedFeedsEntry.setClientToken(
- XmlUtils.extractChildText(parser));
- }
- }
-}
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParserFactory.java b/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParserFactory.java
deleted file mode 100644
index 2e606dd..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParserFactory.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.google.wireless.gdata2.subscribedfeeds.parser.xml;
-
-import com.google.wireless.gdata2.client.GDataParserFactory;
-import com.google.wireless.gdata2.data.Entry;
-import com.google.wireless.gdata2.parser.GDataParser;
-import com.google.wireless.gdata2.parser.ParseException;
-import com.google.wireless.gdata2.parser.xml.XmlParserFactory;
-import com.google.wireless.gdata2.serializer.GDataSerializer;
-import com.google.wireless.gdata2.serializer.xml.XmlBatchGDataSerializer;
-import com.google.wireless.gdata2.subscribedfeeds.data.SubscribedFeedsEntry;
-import com.google.wireless.gdata2.subscribedfeeds.serializer.xml.XmlSubscribedFeedsEntryGDataSerializer;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.InputStream;
-import java.util.Enumeration;
-
-/**
- * GDataParserFactory that creates XML GDataParsers and GDataSerializers for
- * Subscribed Feeds.
- */
-public class XmlSubscribedFeedsGDataParserFactory implements
- GDataParserFactory {
- private final XmlParserFactory xmlFactory;
-
- public XmlSubscribedFeedsGDataParserFactory(XmlParserFactory xmlFactory) {
- this.xmlFactory = xmlFactory;
- }
-
- /*
- * (non-javadoc)
- *
- * @see GDataParserFactory#createParser
- */
- public GDataParser createParser(InputStream is) throws ParseException {
- XmlPullParser xmlParser;
- try {
- xmlParser = xmlFactory.createParser();
- } catch (XmlPullParserException xppe) {
- throw new ParseException("Could not create XmlPullParser", xppe);
- }
- return new XmlSubscribedFeedsGDataParser(is, xmlParser);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see GDataParserFactory#createMetaFeedParser(int, java.io.InputStream)
- */
- public GDataParser createParser(Class entryClass, InputStream is)
- throws ParseException {
- if (entryClass != SubscribedFeedsEntry.class) {
- throw new IllegalArgumentException(
- "SubscribedFeeds supports only a single feed type");
- }
- // we don't have feed sub-types, so just return the default
- return createParser(is);
- }
-
-
- /**
- * Creates a new {@link GDataSerializer} for the provided entry. The entry
- * <strong>must</strong> be an instance of {@link SubscribedFeedsEntry}.
- *
- * @param entry The {@link SubscribedFeedsEntry} that should be
- * serialized.
- * @return The {@link GDataSerializer} that will serialize this entry.
- * @throws IllegalArgumentException Thrown if entry is not a
- * {@link SubscribedFeedsEntry}.
- * @see com.google.wireless.gdata2.client.GDataParserFactory#createSerializer
- */
- public GDataSerializer createSerializer(Entry entry) {
- if (!(entry instanceof SubscribedFeedsEntry)) {
- throw new IllegalArgumentException(
- "Expected SubscribedFeedsEntry!");
- }
- SubscribedFeedsEntry subscribedFeedsEntry =
- (SubscribedFeedsEntry) entry;
- return new XmlSubscribedFeedsEntryGDataSerializer(xmlFactory,
- subscribedFeedsEntry);
- }
-
- /**
- * Creates a new {@link GDataSerializer} for the given batch.
- *
- * @param batch the {@link Enumeration} of entries in the batch.
- * @return The {@link GDataSerializer} that will serialize this batch.
- */
- public GDataSerializer createSerializer(Enumeration batch) {
- return new XmlBatchGDataSerializer(this, xmlFactory, batch);
- }
-}
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/serializer/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/XmlSubscribedFeedsEntryGDataSerializer.java b/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/XmlSubscribedFeedsEntryGDataSerializer.java
deleted file mode 100644
index ed018b2..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/XmlSubscribedFeedsEntryGDataSerializer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.google.wireless.gdata2.subscribedfeeds.serializer.xml;
-
-import com.google.wireless.gdata2.data.StringUtils;
-import com.google.wireless.gdata2.serializer.xml.XmlEntryGDataSerializer;
-import com.google.wireless.gdata2.subscribedfeeds.data.FeedUrl;
-import com.google.wireless.gdata2.subscribedfeeds.data.SubscribedFeedsEntry;
-import com.google.wireless.gdata2.parser.xml.XmlParserFactory;
-
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.IOException;
-
-/**
- * Serializes the SubscribedFeedEntry into the Atom XML format.
- */
-public class XmlSubscribedFeedsEntryGDataSerializer extends
- XmlEntryGDataSerializer {
- public static final String NAMESPACE_GSYNC = "gsync";
- public static final String NAMESPACE_GSYNC_URI =
- "http://schemas.google.com/gsync/data";
-
- public XmlSubscribedFeedsEntryGDataSerializer(XmlParserFactory factory,
- SubscribedFeedsEntry entry) {
- super(factory, entry);
- }
-
- protected SubscribedFeedsEntry getSubscribedFeedsEntry() {
- return (SubscribedFeedsEntry) getEntry();
- }
-
- protected void declareExtraEntryNamespaces(XmlSerializer serializer)
- throws IOException {
- serializer.setPrefix(NAMESPACE_GSYNC, NAMESPACE_GSYNC_URI);
- }
-
- /* (non-Javadoc)
- * @see XmlEntryGDataSerializer#serializeExtraEntryContents
- */
- protected void serializeExtraEntryContents(XmlSerializer serializer,
- int format)
- throws IOException {
- SubscribedFeedsEntry entry = getSubscribedFeedsEntry();
-
- serializeFeedUrl(serializer, entry.getSubscribedFeed());
- serializeClientToken(serializer, entry.getClientToken());
- serializeRoutingInfo(serializer, entry.getRoutingInfo());
- }
-
- private static void serializeFeedUrl(XmlSerializer serializer,
- FeedUrl feedUrl)
- throws IOException {
- serializer.startTag(NAMESPACE_GSYNC_URI, "feedurl");
- serializer.attribute(null /* ns */, "value", feedUrl.getFeed());
- serializer.attribute(null /* ns */, "service", feedUrl.getService());
- serializer.attribute(null /* ns */, "authtoken", feedUrl.getAuthToken());
- serializer.endTag(NAMESPACE_GSYNC_URI, "feedurl");
- }
-
- private static void serializeClientToken(XmlSerializer serializer,
- String clientToken)
- throws IOException {
- if (StringUtils.isEmpty(clientToken)) {
- clientToken = "";
- }
- serializer.startTag(NAMESPACE_GSYNC_URI, "clientToken");
- serializer.text(clientToken);
- serializer.endTag(NAMESPACE_GSYNC_URI, "clientToken");
- }
-
- private static void serializeRoutingInfo(XmlSerializer serializer,
- String routingInfo)
- throws IOException {
- if (StringUtils.isEmpty(routingInfo)) {
- routingInfo = "";
- }
- serializer.startTag(NAMESPACE_GSYNC_URI, "routingInfo");
- serializer.text(routingInfo);
- serializer.endTag(NAMESPACE_GSYNC_URI, "routingInfo");
- }
-}
diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
- {@hide}
-</body>
-</html>