Ebeo / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

TokenCollection CreateDictionary method is broken (when used from the DocumentsListQuery class) #302

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try using that method on a TokenCollection, it fails

Firstly - the split method leaves an empty string as the first token.
Secondly - the CreateDictionary method expects each token to be either a key 
OR a value (after splitting the uri around { '?', '&', '=' }), while the 
DocumentsListQuery only splits around { '?', '&' } - each token is a 
"key=value" string. This means that even after skipping over the first token 
(can be done easily in several ways), it still won't work as expected (- it 
won't create a valid dictionary).

Original issue reported on code.google.com by ATGard...@gmail.com on 7 Dec 2009 at 8:30

GoogleCodeExporter commented 9 years ago
I should make those internal, they are only used to parse certain response 
bodies.
What are you using them for?

Frank

Original comment by fman...@gmail.com on 8 Dec 2009 at 1:06

GoogleCodeExporter commented 9 years ago
I created a subclass of DocumentsListQuery with a StartKey property, and 
overridden 
the ParseUri and CalculateQuery methods so they will handle the property 
correctly, 
so I can create a new Query object with the StartKey I received from a previous 
query, and then change its other properties before resubmitting it (I needed to 
change the NumberToRetrieve for the 2nd chunk).
I thought about using the CreateDictionary for the parsing, but at the end I 
just 
used a different approach.

It might be useful to handle the StartKey in the "real" DocumentsListQuery 
class as 
well, if you'd like the code.

Original comment by ATGard...@gmail.com on 8 Dec 2009 at 1:25

GoogleCodeExporter commented 9 years ago
startkey is refering to the token they are introducing in doclist 3.0?

Original comment by fman...@gmail.com on 8 Dec 2009 at 1:44

GoogleCodeExporter commented 9 years ago
I guess so..
The Next link uri has a "&start-key=somekindalongstringykey" element in it.
I just parsed it into a private field, when creating a DocumentsListQuery 
(actually, 
when creating my subclass), and later re-written it in the uri in 
CalculateQuery.
This way I was able to start by reading 15 elements in the first query (for 
example), 
and then for the 2nd and following chunks, increase the number to 100 easily 
(without 
strin editing the next link uri outside of the query object).

Original comment by ATGard...@gmail.com on 8 Dec 2009 at 2:03