summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-15 16:12:08 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-15 16:12:08 -0800
commit7f3a40f64f813633d4d7ae8df6250212a55a0d15 (patch)
tree62788164cfefb3e80e799e08f3e50e4ea876e9cc
parenteea01ce34f9d965d6186c78271d05a1e246c1caf (diff)
downloadgdata-7f3a40f64f813633d4d7ae8df6250212a55a0d15.tar.gz
auto import from //branches/cupcake/...@126645
-rw-r--r--src/com/google/wireless/gdata/ConflictDetectedException.java32
-rw-r--r--src/com/google/wireless/gdata/calendar/client/CalendarClient.java14
-rw-r--r--src/com/google/wireless/gdata/client/AllDeletedUnavailableException.java36
-rw-r--r--src/com/google/wireless/gdata/client/AuthenticationException.java37
-rw-r--r--src/com/google/wireless/gdata/client/GDataServiceClient.java186
-rw-r--r--src/com/google/wireless/gdata/client/ResourceNotFoundException.java50
-rwxr-xr-xsrc/com/google/wireless/gdata/spreadsheets/client/SpreadsheetsClient.java92
-rw-r--r--src/com/google/wireless/gdata/subscribedfeeds/client/SubscribedFeedsClient.java17
8 files changed, 65 insertions, 399 deletions
diff --git a/src/com/google/wireless/gdata/ConflictDetectedException.java b/src/com/google/wireless/gdata/ConflictDetectedException.java
deleted file mode 100644
index efd918e..0000000
--- a/src/com/google/wireless/gdata/ConflictDetectedException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata;
-
-import com.google.wireless.gdata.data.Entry;
-
-/**
- * A ConflictDetectedException is thrown when the server detects a conflict
- * between the Entry which the client is trying to insert or modify and an
- * existing Entry. Typically this is because the version of the Entry being
- * uploaded by the client is older than the version on the server, but it may
- * also indicate the violation of some other constraint (e.g., key uniqueness).
- */
-public class ConflictDetectedException extends GDataException {
-
- private final Entry conflictingEntry;
-
- /**
- * Creates a new ConflictDetectedException with the given entry.
- * @param conflictingEntry the conflicting entry state returned by the server.
- */
- public ConflictDetectedException(Entry conflictingEntry) {
- this.conflictingEntry = conflictingEntry;
- }
-
- /**
- * @return the conflicting Entry returned by the server.
- */
- public Entry getConflictingEntry() {
- return conflictingEntry;
- }
-}
diff --git a/src/com/google/wireless/gdata/calendar/client/CalendarClient.java b/src/com/google/wireless/gdata/calendar/client/CalendarClient.java
index 8710079..c9d4a92 100644
--- a/src/com/google/wireless/gdata/calendar/client/CalendarClient.java
+++ b/src/com/google/wireless/gdata/calendar/client/CalendarClient.java
@@ -3,13 +3,11 @@
package com.google.wireless.gdata.calendar.client;
import com.google.wireless.gdata.calendar.data.CalendarEntry;
-import com.google.wireless.gdata.client.AuthenticationException;
import com.google.wireless.gdata.client.GDataClient;
import com.google.wireless.gdata.client.GDataParserFactory;
import com.google.wireless.gdata.client.GDataServiceClient;
import com.google.wireless.gdata.client.HttpException;
import com.google.wireless.gdata.client.QueryParams;
-import com.google.wireless.gdata.client.AllDeletedUnavailableException;
import com.google.wireless.gdata.parser.GDataParser;
import com.google.wireless.gdata.parser.ParseException;
@@ -90,15 +88,9 @@ public class CalendarClient extends GDataServiceClient {
* @throws ParseException Thrown if the feed could not be fetched.
*/
public GDataParser getParserForUserCalendars(String feedUrl, String authToken)
- throws AuthenticationException, ParseException, IOException,
- AllDeletedUnavailableException {
+ throws ParseException, IOException, HttpException {
GDataClient gDataClient = getGDataClient();
- try {
- InputStream is = gDataClient.getFeedAsStream(feedUrl, authToken);
- return getGDataParserFactory().createParser(CalendarEntry.class, is);
- } catch (HttpException e) {
- convertHttpExceptionForReads("Could not fetch calendars feed", e);
- return null; // never reached
- }
+ InputStream is = gDataClient.getFeedAsStream(feedUrl, authToken);
+ return getGDataParserFactory().createParser(CalendarEntry.class, is);
}
}
diff --git a/src/com/google/wireless/gdata/client/AllDeletedUnavailableException.java b/src/com/google/wireless/gdata/client/AllDeletedUnavailableException.java
deleted file mode 100644
index 038cc87..0000000
--- a/src/com/google/wireless/gdata/client/AllDeletedUnavailableException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.google.wireless.gdata.client;
-
-import com.google.wireless.gdata.GDataException;
-
-/**
- * Exception thrown when the tombstones for a feed have expired. When the
- * client gets this it should refetch the entire feed.
- */
-public class AllDeletedUnavailableException extends GDataException {
-
- /**
- * Creates a new AuthenticationException.
- */
- public AllDeletedUnavailableException() {
- }
-
- /**
- * Creates a new AllDeletedUnavailableException with a supplied message.
- * @param message The message for the exception.
- */
- public AllDeletedUnavailableException(String message) {
- super(message);
- }
-
- /**
- * Creates a new AllDeletedUnavailableException 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 AllDeletedUnavailableException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/src/com/google/wireless/gdata/client/AuthenticationException.java b/src/com/google/wireless/gdata/client/AuthenticationException.java
deleted file mode 100644
index 68866ce..0000000
--- a/src/com/google/wireless/gdata/client/AuthenticationException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.google.wireless.gdata.client;
-
-import com.google.wireless.gdata.GDataException;
-
-/**
- * Exception thrown when a user's credentials could not be authenticated.
- */
-public class AuthenticationException extends GDataException {
-
- /**
- * Creates a new AuthenticationException.
- */
- public AuthenticationException() {
- }
-
- /**
- * Creates a new AuthenticationException with a supplied message.
- * @param message The message for the exception.
- */
- public AuthenticationException(String message) {
- super(message);
- }
-
- /**
- * Creates a new AuthenticationException 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 AuthenticationException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/src/com/google/wireless/gdata/client/GDataServiceClient.java b/src/com/google/wireless/gdata/client/GDataServiceClient.java
index 8b32885..4eae5b1 100644
--- a/src/com/google/wireless/gdata/client/GDataServiceClient.java
+++ b/src/com/google/wireless/gdata/client/GDataServiceClient.java
@@ -3,9 +3,8 @@
package com.google.wireless.gdata.client;
import com.google.wireless.gdata.data.Entry;
-import com.google.wireless.gdata.data.StringUtils;
import com.google.wireless.gdata.data.MediaEntry;
-import com.google.wireless.gdata.ConflictDetectedException;
+import com.google.wireless.gdata.data.StringUtils;
import com.google.wireless.gdata.parser.GDataParser;
import com.google.wireless.gdata.parser.ParseException;
import com.google.wireless.gdata.serializer.GDataSerializer;
@@ -20,9 +19,6 @@ public abstract class GDataServiceClient {
private final GDataClient gDataClient;
private final GDataParserFactory gDataParserFactory;
- // TODO: remove this, after coordinating with other developers.
- private static final boolean PARSE_CONFLICTING_ENTRIES = false;
-
public GDataServiceClient(GDataClient gDataClient,
GDataParserFactory gDataParserFactory) {
this.gDataClient = gDataClient;
@@ -67,25 +63,18 @@ public abstract class GDataServiceClient {
* returned {@link GDataParser}.
*
* @param feedEntryClass the class of Entry that is contained in the feed
- * @param feedUrl The URL of the feed that should be fetched.
+ * @param feedUrl ThAe URL of the feed that should be fetched.
* @param authToken The authentication token for this user.
* @return A {@link GDataParser} for the requested feed.
- * @throws AuthenticationException Thrown if the server considers the
- * authToken invalid.
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with
* the GData service.
+ * @throws HttpException Thrown if the http response contains a result other than 2xx
*/
public GDataParser getParserForFeed(Class feedEntryClass, String feedUrl, String authToken)
- throws AuthenticationException, ParseException, IOException,
- AllDeletedUnavailableException {
- try {
- InputStream is = gDataClient.getFeedAsStream(feedUrl, authToken);
- return gDataParserFactory.createParser(feedEntryClass, is);
- } catch (HttpException e) {
- convertHttpExceptionForReads("Could not fetch feed.", e);
- return null; // never reached
- }
+ throws ParseException, IOException, HttpException {
+ InputStream is = gDataClient.getFeedAsStream(feedUrl, authToken);
+ return gDataParserFactory.createParser(feedEntryClass, is);
}
/**
@@ -95,19 +84,12 @@ public abstract class GDataServiceClient {
* @param mediaEntryUrl The URL of the media entry that should be fetched.
* @param authToken The authentication token for this user.
* @return A {@link InputStream} for the requested media entry.
- * @throws AuthenticationException Thrown if the server considers the
- * authToken invalid.
* @throws IOException Thrown if an error occurs while communicating with
* the GData service.
*/
public InputStream getMediaEntryAsStream(String mediaEntryUrl, String authToken)
- throws AuthenticationException, IOException, ResourceNotFoundException {
- try {
- return gDataClient.getMediaEntryAsStream(mediaEntryUrl, authToken);
- } catch (HttpException e) {
- convertHttpExceptionForMediaEntries("Could not fetch media entry " + mediaEntryUrl, e);
- return null; // never reached
- }
+ throws IOException, HttpException {
+ return gDataClient.getMediaEntryAsStream(mediaEntryUrl, authToken);
}
/**
@@ -119,25 +101,16 @@ public abstract class GDataServiceClient {
* @param entry The entry that should be created.
* @return The entry returned by the server as a result of creating the
* provided entry.
- * @throws AuthenticationException Thrown if the server considers the
- * authToken invalid.
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with
* the GData service.
- * @throws ConflictDetectedException Thrown if the server detects an
- * existing entry that conflicts with this one.
+ * @throws HttpException if the service returns an error response
*/
public Entry createEntry(String feedUrl, String authToken, Entry entry)
- throws AuthenticationException, ParseException, IOException,
- ConflictDetectedException {
+ throws ParseException, IOException, HttpException {
GDataSerializer serializer = gDataParserFactory.createSerializer(entry);
- try {
- InputStream is = gDataClient.createEntry(feedUrl, authToken, serializer);
- return parseEntry(entry.getClass(), is);
- } catch (HttpException e) {
- convertHttpExceptionForWrites(entry.getClass(), "Could not create entry.", e);
- return null; // never reached.
- }
+ InputStream is = gDataClient.createEntry(feedUrl, authToken, serializer);
+ return parseEntry(entry.getClass(), is);
}
/**
@@ -145,22 +118,16 @@ public abstract class GDataServiceClient {
* @param entryClass the type of entry to expect
* @param id of the entry to fetch.
* @param authToken The authentication token for this user. @return The entry returned by the server.
- * @throws AuthenticationException Thrown if the server considers the
- * authToken invalid.
* @throws ParseException Thrown if the server response cannot be parsed.
+ * @throws HttpException if the service returns an error response
* @throws IOException Thrown if an error occurs while communicating with
* the GData service.
+ * @return The entry returned by the server
*/
public Entry getEntry(Class entryClass, String id, String authToken)
- throws AuthenticationException, ParseException, IOException,
- AllDeletedUnavailableException {
- try {
- InputStream is = getGDataClient().getFeedAsStream(id, authToken);
- return parseEntry(entryClass, is);
- } catch (HttpException e) {
- convertHttpExceptionForReads("Could not fetch entry.", e);
- return null; // never reached
- }
+ throws ParseException, IOException, HttpException {
+ InputStream is = getGDataClient().getFeedAsStream(id, authToken);
+ return parseEntry(entryClass, is);
}
/**
@@ -171,36 +138,21 @@ public abstract class GDataServiceClient {
* @param authToken The authentication token for this user.
* @return The entry returned by the server as a result of updating the
* provided entry.
- * @throws AuthenticationException Thrown if the server considers the
- * authToken invalid.
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with
* the GData service.
- * @throws ConflictDetectedException Thrown if the server detects an
- * existing entry that conflicts with this one, or if the server version of
- * this entry has changed since it was retrieved.
+ * @throws HttpException if the service returns an error response
*/
public Entry updateEntry(Entry entry, String authToken)
- throws AuthenticationException, ParseException, IOException,
- ConflictDetectedException {
+ throws ParseException, IOException, HttpException {
String editUri = entry.getEditUri();
if (StringUtils.isEmpty(editUri)) {
throw new ParseException("No edit URI -- cannot update.");
}
GDataSerializer serializer = gDataParserFactory.createSerializer(entry);
- try {
- InputStream is = gDataClient.updateEntry(editUri,
- authToken,
- serializer);
- return parseEntry(entry.getClass(), is);
- } catch (HttpException e) {
- if (e.getStatusCode() == HttpException.SC_NOT_FOUND) {
- throw new ParseException("Could not update entry.", e);
- }
- convertHttpExceptionForWrites(entry.getClass(), "Could not update entry.", e);
- return null; // never reached
- }
+ InputStream is = gDataClient.updateEntry(editUri, authToken, serializer);
+ return parseEntry(entry.getClass(), is);
}
/**
@@ -214,32 +166,19 @@ public abstract class GDataServiceClient {
* @param authToken The authentication token for this user.
* @return The entry returned by the server as a result of updating the
* provided entry.
- * @throws AuthenticationException Thrown if the server considers the
- * authToken invalid.
+ * @throws HttpException if the service returns an error response
* @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with
* the GData service.
- * @throws ConflictDetectedException Thrown if the server detects an
- * existing entry that conflicts with this one, or if the server version of
- * this entry has changed since it was retrieved.
*/
- public MediaEntry updateMediaEntry(String editUri, InputStream inputStream,
- String contentType,
- String authToken)
- throws AuthenticationException, ParseException, IOException,
- ConflictDetectedException {
+ public MediaEntry updateMediaEntry(String editUri, InputStream inputStream, String contentType,
+ String authToken) throws IOException, HttpException, ParseException {
if (StringUtils.isEmpty(editUri)) {
- throw new ParseException("No edit URI -- cannot update.");
+ throw new IllegalArgumentException("No edit URI -- cannot update.");
}
- try {
- InputStream is = gDataClient.updateMediaEntry(editUri, authToken,
- inputStream, contentType);
- return (MediaEntry)parseEntry(MediaEntry.class, is);
- } catch (HttpException e) {
- convertHttpExceptionForWrites(MediaEntry.class, "Could not update entry.", e);
- return null; // never reached
- }
+ InputStream is = gDataClient.updateMediaEntry(editUri, authToken, inputStream, contentType);
+ return (MediaEntry)parseEntry(MediaEntry.class, is);
}
/**
@@ -247,27 +186,13 @@ public abstract class GDataServiceClient {
*
* @param editUri The editUri for the entry that should be deleted.
* @param authToken The authentication token for this user.
- * @throws AuthenticationException Thrown if the server considers the
- * authToken invalid.
- * @throws ParseException Thrown if the server response cannot be parsed.
* @throws IOException Thrown if an error occurs while communicating with
* the GData service.
- * @throws ConflictDetectedException Thrown if the server version of
- * this entry has changed since it was retrieved.
+ * @throws HttpException if the service returns an error response
*/
public void deleteEntry(String editUri, String authToken)
- throws AuthenticationException, ConflictDetectedException,
- ParseException, IOException {
- try {
- gDataClient.deleteEntry(editUri, authToken);
- } catch (HttpException e) {
- if (e.getStatusCode() == HttpException.SC_NOT_FOUND) {
- // the server does not know about this entry.
- // nothing to delete.
- return;
- }
- convertHttpExceptionForWrites(null, "Unable to delete", e);
- }
+ throws IOException, HttpException {
+ gDataClient.deleteEntry(editUri, authToken);
}
private Entry parseEntry(Class entryClass, InputStream is) throws ParseException, IOException {
@@ -281,55 +206,4 @@ public abstract class GDataServiceClient {
}
}
}
-
- protected void convertHttpExceptionForReads(String message, HttpException cause)
- throws AuthenticationException, IOException, AllDeletedUnavailableException {
- switch (cause.getStatusCode()) {
- case HttpException.SC_FORBIDDEN:
- case HttpException.SC_UNAUTHORIZED:
- throw new AuthenticationException(message, cause);
- case HttpException.SC_GONE:
- throw new AllDeletedUnavailableException(message, cause);
- default:
- throw new IOException(message + ": " + cause.getMessage());
- }
- }
-
- protected void convertHttpExceptionForMediaEntries(String message, HttpException cause)
- throws AuthenticationException, IOException, ResourceNotFoundException {
- switch (cause.getStatusCode()) {
- case HttpException.SC_FORBIDDEN:
- case HttpException.SC_UNAUTHORIZED:
- throw new AuthenticationException(message, cause);
- case HttpException.SC_NOT_FOUND:
- throw new ResourceNotFoundException(message, cause);
- default:
- throw new IOException(message + ": " + cause.getMessage());
- }
- }
-
- protected void convertHttpExceptionForWrites(Class entryClass, String message,
- HttpException cause) throws ConflictDetectedException,
- AuthenticationException, ParseException, IOException {
- switch (cause.getStatusCode()) {
- case HttpException.SC_CONFLICT:
- Entry entry = null;
- if (PARSE_CONFLICTING_ENTRIES) {
- if (entryClass != null) {
- InputStream is = cause.getResponseStream();
- if (is != null) {
- entry = parseEntry(entryClass, cause.getResponseStream());
- }
- }
- }
- throw new ConflictDetectedException(entry);
- case HttpException.SC_BAD_REQUEST:
- throw new ParseException(message + ": " + cause.getMessage());
- case HttpException.SC_FORBIDDEN:
- case HttpException.SC_UNAUTHORIZED:
- throw new AuthenticationException(message, cause);
- default:
- throw new IOException(message + ": " + cause.getMessage());
- }
- }
}
diff --git a/src/com/google/wireless/gdata/client/ResourceNotFoundException.java b/src/com/google/wireless/gdata/client/ResourceNotFoundException.java
deleted file mode 100644
index 86c3040..0000000
--- a/src/com/google/wireless/gdata/client/ResourceNotFoundException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-** Copyright 2008, 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.gdata.client;
-
-import com.google.wireless.gdata.GDataException;
-
-/**
- * Exception thrown when a specified resource does not exist
- */
-public class ResourceNotFoundException extends GDataException {
-
- /**
- * Creates a new ResourceNotFoundException.
- */
- public ResourceNotFoundException() {
- }
-
- /**
- * Creates a new ResourceNotFoundException with a supplied message.
- * @param message The message for the exception.
- */
- public ResourceNotFoundException(String message) {
- super(message);
- }
-
- /**
- * Creates a new ResourceNotFoundException 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 ResourceNotFoundException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/src/com/google/wireless/gdata/spreadsheets/client/SpreadsheetsClient.java b/src/com/google/wireless/gdata/spreadsheets/client/SpreadsheetsClient.java
index 8b19918..388856d 100755
--- a/src/com/google/wireless/gdata/spreadsheets/client/SpreadsheetsClient.java
+++ b/src/com/google/wireless/gdata/spreadsheets/client/SpreadsheetsClient.java
@@ -1,13 +1,10 @@
// Copyright 2007 The Android Open Source Project
package com.google.wireless.gdata.spreadsheets.client;
-import com.google.wireless.gdata.ConflictDetectedException;
-import com.google.wireless.gdata.client.AuthenticationException;
import com.google.wireless.gdata.client.GDataClient;
import com.google.wireless.gdata.client.GDataParserFactory;
import com.google.wireless.gdata.client.GDataServiceClient;
import com.google.wireless.gdata.client.HttpException;
-import com.google.wireless.gdata.client.AllDeletedUnavailableException;
import com.google.wireless.gdata.data.Entry;
import com.google.wireless.gdata.data.StringUtils;
import com.google.wireless.gdata.parser.GDataParser;
@@ -84,44 +81,29 @@ public class SpreadsheetsClient extends GDataServiceClient {
* method figure out which parser to create.
* @param feedUri the URI of the feed to be fetched and parsed
* @param authToken the current authToken to use for the request @return a parser for the indicated feed
- * @throws AuthenticationException if the authToken is not valid
+ * @throws HttpException if an http error is encountered
* @throws ParseException if the response from the server could not be
* parsed
*/
private GDataParser getParserForTypedFeed(Class feedEntryClass, String feedUri,
- String authToken) throws AuthenticationException,
- ParseException, IOException, AllDeletedUnavailableException {
+ String authToken) throws ParseException, IOException, HttpException {
GDataClient gDataClient = getGDataClient();
GDataParserFactory gDataParserFactory = getGDataParserFactory();
- try {
- InputStream is = gDataClient.getFeedAsStream(feedUri, authToken);
- return gDataParserFactory.createParser(feedEntryClass, is);
- } catch (HttpException e) {
- convertHttpExceptionForReads("Could not fetch parser feed.", e);
- return null; // never reached
- }
+ InputStream is = gDataClient.getFeedAsStream(feedUri, authToken);
+ return gDataParserFactory.createParser(feedEntryClass, is);
}
/* (non-javadoc)
* @see GDataServiceClient#createEntry
*/
public Entry createEntry(String feedUri, String authToken, Entry entry)
- throws AuthenticationException, ConflictDetectedException,
- ParseException, IOException {
+ throws ParseException, IOException, HttpException {
GDataParserFactory factory = getGDataParserFactory();
GDataSerializer serializer = factory.createSerializer(entry);
- InputStream is;
- try {
- is = getGDataClient().createEntry(feedUri, authToken,
- serializer);
- } catch (HttpException e) {
- convertHttpExceptionForWrites(entry.getClass(), "Could not update entry.", e);
- return null; // never reached.
- }
-
+ InputStream is = getGDataClient().createEntry(feedUri, authToken, serializer);
GDataParser parser = factory.createParser(entry.getClass(), is);
try {
return parser.parseStandaloneEntry();
@@ -136,13 +118,12 @@ public class SpreadsheetsClient extends GDataServiceClient {
* @param feedUri the URI of the feed to be fetched and parsed
* @param authToken the current authToken to use for the request
* @return a parser for the indicated feed
- * @throws AuthenticationException if the authToken is not valid
+ * @throws HttpException if an http error is encountered
* @throws ParseException if the response from the server could not be
* parsed
*/
public GDataParser getParserForCellsFeed(String feedUri, String authToken)
- throws AuthenticationException, ConflictDetectedException,
- ParseException, IOException, AllDeletedUnavailableException {
+ throws ParseException, IOException, HttpException {
return getParserForTypedFeed(CellEntry.class, feedUri, authToken);
}
@@ -152,18 +133,21 @@ public class SpreadsheetsClient extends GDataServiceClient {
* the feed type from the URI alone, this method assumes the default feed
* type! This is probably NOT what you want. Please use the
* getParserFor[Type]Feed methods.
- *
+ *
* @param feedEntryClass
- *@param feedUri the URI of the feed to be fetched and parsed
- * @param authToken the current authToken to use for the request @return a parser for the indicated feed
- * @throws AuthenticationException if the authToken is not valid
+ * @param feedUri the URI of the feed to be fetched and parsed
+ * @param authToken the current authToken to use for the request
+ * @return a parser for the indicated feed
+ * @throws HttpException if an http error is encountered
* @throws ParseException if the response from the server could not be
* parsed
*/
public GDataParser getParserForFeed(Class feedEntryClass, String feedUri, String authToken)
- throws AuthenticationException, ParseException, IOException,
- AllDeletedUnavailableException {
- return getParserForTypedFeed(SpreadsheetEntry.class, feedUri, authToken);
+ throws ParseException, IOException, HttpException {
+ GDataClient gDataClient = getGDataClient();
+ GDataParserFactory gDataParserFactory = getGDataParserFactory();
+ InputStream is = gDataClient.getFeedAsStream(feedUri, authToken);
+ return gDataParserFactory.createParser(feedEntryClass, is);
}
/**
@@ -172,13 +156,12 @@ public class SpreadsheetsClient extends GDataServiceClient {
* @param feedUri the URI of the feed to be fetched and parsed
* @param authToken the current authToken to use for the request
* @return a parser for the indicated feed
- * @throws AuthenticationException if the authToken is not valid
+ * @throws HttpException if an http error is encountered
* @throws ParseException if the response from the server could not be
* parsed
*/
public GDataParser getParserForListFeed(String feedUri, String authToken)
- throws AuthenticationException, ParseException, IOException,
- AllDeletedUnavailableException {
+ throws ParseException, IOException, HttpException {
return getParserForTypedFeed(ListEntry.class, feedUri, authToken);
}
@@ -188,16 +171,13 @@ public class SpreadsheetsClient extends GDataServiceClient {
* @param feedUri the URI of the feed to be fetched and parsed
* @param authToken the current authToken to use for the request
* @return a parser for the indicated feed
- * @throws AuthenticationException if the authToken is not valid
+ * @throws HttpException if an http error is encountered
* @throws ParseException if the response from the server could not be
* parsed
*/
- public GDataParser getParserForSpreadsheetsFeed(String feedUri,
- String authToken)
- throws AuthenticationException, ParseException, IOException,
- AllDeletedUnavailableException {
- return getParserForTypedFeed(SpreadsheetEntry.class, feedUri,
- authToken);
+ public GDataParser getParserForSpreadsheetsFeed(String feedUri, String authToken)
+ throws ParseException, IOException, HttpException {
+ return getParserForTypedFeed(SpreadsheetEntry.class, feedUri, authToken);
}
/**
@@ -206,14 +186,12 @@ public class SpreadsheetsClient extends GDataServiceClient {
* @param feedUri the URI of the feed to be fetched and parsed
* @param authToken the current authToken to use for the request
* @return a parser for the indicated feed
- * @throws AuthenticationException if the authToken is not valid
+ * @throws HttpException if an http error is encountered
* @throws ParseException if the response from the server could not be
* parsed
*/
- public GDataParser getParserForWorksheetsFeed(String feedUri,
- String authToken)
- throws AuthenticationException, ParseException, IOException,
- AllDeletedUnavailableException {
+ public GDataParser getParserForWorksheetsFeed(String feedUri, String authToken)
+ throws ParseException, IOException, HttpException {
return getParserForTypedFeed(WorksheetEntry.class, feedUri, authToken);
}
@@ -227,15 +205,14 @@ public class SpreadsheetsClient extends GDataServiceClient {
* @param authToken the current authToken to be used for the operation
* @return An Entry containing the re-parsed version of the entry returned
* by the server in response to the update.
- * @throws AuthenticationException if the authToken is invalid
+ * @throws HttpException if an http error is encountered
* @throws ParseException if the server returned an error, if the server's
* response was unparseable (unlikely), or if <code>entry</code>
* is of a read-only type
* @throws IOException on network error
*/
public Entry updateEntry(Entry entry, String authToken)
- throws AuthenticationException, ConflictDetectedException,
- ParseException, IOException {
+ throws ParseException, IOException, HttpException {
GDataParserFactory factory = getGDataParserFactory();
GDataSerializer serializer = factory.createSerializer(entry);
@@ -244,16 +221,7 @@ public class SpreadsheetsClient extends GDataServiceClient {
throw new ParseException("No edit URI -- cannot update.");
}
- InputStream is;
- try {
- is = getGDataClient().updateEntry(editUri,
- authToken,
- serializer);
- } catch (HttpException e) {
- convertHttpExceptionForWrites(entry.getClass(), "Could not update entry.", e);
- return null; // never reached
- }
-
+ InputStream is = getGDataClient().updateEntry(editUri, authToken, serializer);
GDataParser parser = factory.createParser(entry.getClass(), is);
try {
return parser.parseStandaloneEntry();
diff --git a/src/com/google/wireless/gdata/subscribedfeeds/client/SubscribedFeedsClient.java b/src/com/google/wireless/gdata/subscribedfeeds/client/SubscribedFeedsClient.java
index 632e8e3..ede852b 100644
--- a/src/com/google/wireless/gdata/subscribedfeeds/client/SubscribedFeedsClient.java
+++ b/src/com/google/wireless/gdata/subscribedfeeds/client/SubscribedFeedsClient.java
@@ -2,21 +2,9 @@
package com.google.wireless.gdata.subscribedfeeds.client;
-import com.google.wireless.gdata.client.AuthenticationException;
import com.google.wireless.gdata.client.GDataClient;
-import com.google.wireless.gdata.client.GDataServiceClient;
-import com.google.wireless.gdata.client.QueryParams;
import com.google.wireless.gdata.client.GDataParserFactory;
-import com.google.wireless.gdata.data.Entry;
-import com.google.wireless.gdata.parser.GDataParser;
-import com.google.wireless.gdata.parser.ParseException;
-import com.google.wireless.gdata.serializer.xml.XmlEntryGDataSerializer;
-import com.google.wireless.gdata.subscribedfeeds.data.SubscribedFeedsEntry;
-import com.google.wireless.gdata.subscribedfeeds.parser.xml.XmlSubscribedFeedsGDataParser;
-import com.google.wireless.gdata.subscribedfeeds.serializer.xml.XmlSubscribedFeedsEntryGDataSerializer;
-
-import java.io.IOException;
-import java.io.InputStream;
+import com.google.wireless.gdata.client.GDataServiceClient;
/**
* GDataServiceClient for accessing Subscribed Feeds. This client can access
@@ -34,8 +22,7 @@ public class SubscribedFeedsClient extends GDataServiceClient {
* @param client The GDataClient that should be used to authenticate
* requests, retrieve feeds, etc.
*/
- public SubscribedFeedsClient(GDataClient client,
- GDataParserFactory factory) {
+ public SubscribedFeedsClient(GDataClient client, GDataParserFactory factory) {
super(client, factory);
}