geyrix57 / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

AtomParser in 1.3.1 does not work as in 1.2.x #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version: 1.3.1-alph
Java environment: Android 2.3

I have some code which worked with version 1.2.0:

List<GDocEntry> entries;
HttpRequest request = transport.buildGetRequest();
request.url = getDocUrl();

HttpResponse response = request.execute();
GDocFeed feed = response.parseAs(GDocFeed.class);
entries = feed.entries;

With version 1.3.1, entries is alway null. I'm obviusly missing something that 
has to be changed for 1.3.1.

Here is how I initialize the AtomParser:

private static final XmlNamespaceDictionary DICTIONARY = new 
XmlNamespaceDictionary()
    .set("", "http://www.w3.org/2005/Atom")
    .set("app", "http://www.w3.org/2007/app")
    .set("atom", "http://www.w3.org/2005/Atom")
    .set("batch", "http://schemas.google.com/gdata/batch")
    .set("docs", "http://schemas.google.com/docs/2007")
    .set("gAcl", "http://schemas.google.com/acl/2007")
    .set("gd", "http://schemas.google.com/g/2005")
    .set("openSearch", "http://a9.com/-/spec/opensearch/1.1/")
    .set("xml", "http://www.w3.org/XML/1998/namespace");

         //...
    transport = new ApacheHttpTransport();
    GoogleHeaders headers = new GoogleHeaders();
    headers.setApplicationName("AGoban");
    headers.gdataVersion = "3";
    transport.defaultHeaders = headers;
    AtomParser parser = new AtomParser();
    parser.namespaceDictionary = DICTIONARY;
    Log.d(TAG, "AtomParser: " + parser.namespaceDictionary);
    transport.addParser(parser);

Original issue reported on code.google.com by Christia...@gmail.com on 6 Mar 2011 at 6:28

GoogleCodeExporter commented 9 years ago
Thanks for the feedback.  This is a common problem encountered when upgrading 
from 1.2 to 1.3.  This is indeed an incompatible.

Remove this line and it will hopefully work:

    .set("atom", "http://www.w3.org/2005/Atom")

Basically, what is going on is that now the mapping is one-to-one, so it is not 
possible to map both the default namespace and the "atom" namespace to 
"http://www.w3.org/2005/Atom".  So when you call:

    .set("", "http://www.w3.org/2005/Atom")
    .set("atom", "http://www.w3.org/2005/Atom")

It remaps "http://www.w3.org/2005/Atom" to "atom" instead of "".

Original comment by yan...@google.com on 7 Mar 2011 at 2:09