outputStream.close();
if (connection.getResponseCode() == HttpURLConnection.HTTP_CREATED) {
LOG.info("Resumable upload is complete and successful.");
return (PhotoEntry) ParseUtil.readEntry(new ParseSource(connection.getInputStream()));
}
} else if (connection.getResponseCode() == HttpURLConnection.HTTP_CREATED) {
// It's possible that the Picasa upload associated with the specific resumable upload URL
// had previously completed successfully. In that case, the response to the initial */* PUT
// will be a 201 Created with the new PhotoEntry. This is probably an edge case.
LOG.info("Resumable upload is complete and successful.");
return (PhotoEntry) ParseUtil.readEntry(new ParseSource(connection.getInputStream()));
} else {
// The IllegalArgumentException should be treated by the calling code as
// something that is not recoverable, which is to say the resumable upload attempt
// should be stopped.
throw new IllegalArgumentException(String.format("HTTP POST to %s returned status %d (%s).",