SilverHoodCorp / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

com.google.gdata.client.Query.appendQueryParameter doesn't check if feedUrl already contains ? char #263

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Use the following test case;

String user = "user@domain.com";

URL feedUrl = new
URL("http://www.google.com/calendar/feeds/default/owncalendars/full" +
"?xoauth_requestor_id=" + user);

CalendarQuery calQuery = new CalendarQuery(feedUrl);

calQuery.setMinimumStartTime(new DateTime());

System.out.println(calQuery.getUrl());      

What is the expected output? What do you see instead?

Expected Output:

http://www.google.com/calendar/feeds/default/owncalendars/full?xoauth_requestor_
id=user@domain.com&updated-min=2010-04-20T00%3A00%3A00.000

Incorrect Output (Note feedUrl already contained ? char, but
Query.appendQueryParameter doesn't take this into account, so uses ?
instead of &)

http://www.google.com/calendar/feeds/default/owncalendars/full?xoauth_requestor_
id=user@domain.com?updated-min=2010-04-20T00%3A00%3A00.000

What version of the product are you using? On what operating system?

1.4.1 / Linux

Please provide any additional information below.

If the feedUrl already contains the query delimiter '?' then it should
begin using the '&' char immediately, instead of adding it's own query
delimiter '?'

Original issue reported on code.google.com by ahughes...@gmail.com on 20 Apr 2010 at 9:04

GoogleCodeExporter commented 9 years ago
As a work-around please don't include query parameters in the feedUrl passed to 
the constructo 
of CalendarQuery and then call 
calQuery.setStringCustomParameter("xoauth_requestor_id", user).

Original comment by yanivin...@gmail.com on 28 Apr 2010 at 1:50

GoogleCodeExporter commented 9 years ago
Issue 257 has been merged into this issue.

Original comment by yanivin...@gmail.com on 28 Apr 2010 at 3:27

GoogleCodeExporter commented 9 years ago
Some of the API's, like Contacts, rely on paging to get the next set of entries 
(using the getNextLink() method). 
The return URL string of this method already has parameters amended to the URL 
to indicate where the next 
batch should start, max-entries, etc,.. 

Do you have suggestions on how to handle this case? Should we be parsing all of 
the parameters out of the 
getNextLink() URL and re-adding them to the query using 
setStringCustomParameter?

Original comment by vbt...@gmail.com on 3 May 2010 at 9:14

GoogleCodeExporter commented 9 years ago
vbt101: Yes.

Version 2.2.0-alpha of the client library is about to be released this week 
(hopefully).  It features a UriEntity class that takes in its constructor any 
encoded 
URI string and properly parses the query parameters exactly as vbt101 
requested.  
Since the version 2 library is completely independent of the version 1 library, 
you 
could use UriEntity to parse the query parameters, and then use that to 
initialize 
the Query class by calling setStringCustomParameter on each query parameter.  
Or if 
you are brave, you can just use version 2.2.0-alpha as your client library :)

For this particular use case, I even wrote a Google2LeggedOAuthUriEntity that 
has a 
field for xoauth_requestor_id.

http://code.google.com/p/gdata-java-
client/source/browse/branches/2/gdata/src/com/google/api/client/http/UriEntity.j
ava

http://code.google.com/p/gdata-java-
client/source/browse/branches/2/gdata/src/com/google/api/client/googleapis/auth/
oauth
/Google2LeggedOAuthUriEntity.java

Original comment by yanivin...@gmail.com on 4 May 2010 at 2:15