summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-25 20:01:13 (EDT)
committerChris Aniszczyk2011-05-03 09:58:35 (EDT)
commit6689d9bb91121b00bfdb35032d65d66e5a24a554 (patch)
tree9f43cc5d3014521fbd4101400b573a32da32421f
parent0643f069a0a91db136a01b3e1c2826c3edfd5a2d (diff)
downloadegit-github-6689d9bb91121b00bfdb35032d65d66e5a24a554.zip
egit-github-6689d9bb91121b00bfdb35032d65d66e5a24a554.tar.gz
egit-github-6689d9bb91121b00bfdb35032d65d66e5a24a554.tar.bz2
Set per_page query param to 100 for all requestsrefs/changes/51/3251/2
The default number of results is currently 30 if unspecified. Change-Id: I244ea4d3a784da70d578195033dd2686a3f7593a Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java24
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java5
2 files changed, 20 insertions, 9 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
index 32d3cbb..57ccf49 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
@@ -44,6 +44,9 @@ import org.apache.commons.httpclient.protocol.Protocol;
*/
public class GitHubClient {
+ private static final NameValuePair PER_PAGE_PARAM = new NameValuePair(
+ IGitHubConstants.PARAM_PER_PAGE, Integer.toString(100));
+
private static final AuthScope ANY_SCOPE = new AuthScope(
AuthScope.ANY_HOST, AuthScope.ANY_PORT);
@@ -167,12 +170,17 @@ public class GitHubClient {
* @return name value pair array
*/
protected NameValuePair[] getPairs(Map<String, String> data) {
- NameValuePair[] pairs = new NameValuePair[data.size()];
+ if (data == null || data.isEmpty())
+ return new NameValuePair[] { PER_PAGE_PARAM };
+
+ int size = data.containsKey(IGitHubConstants.PARAM_PER_PAGE) ? data
+ .size() : data.size() + 1;
+ NameValuePair[] pairs = new NameValuePair[size];
int i = 0;
- for (Entry<String, String> entry : data.entrySet()) {
- pairs[i] = new NameValuePair(entry.getKey(), entry.getValue());
- i++;
- }
+ for (Entry<String, String> entry : data.entrySet())
+ pairs[i++] = new NameValuePair(entry.getKey(), entry.getValue());
+ if (i < size)
+ pairs[i] = PER_PAGE_PARAM;
return pairs;
}
@@ -201,8 +209,7 @@ public class GitHubClient {
public InputStream getStream(String uri, Map<String, String> params)
throws IOException {
GetMethod method = createGet(uri);
- if (params != null && !params.isEmpty())
- method.setQueryString(getPairs(params));
+ method.setQueryString(getPairs(params));
try {
int status = this.client.executeMethod(this.hostConfig, method);
@@ -237,8 +244,7 @@ public class GitHubClient {
public <V> V get(String uri, Map<String, String> params, Type type)
throws IOException {
GetMethod method = createGet(uri);
- if (params != null && !params.isEmpty())
- method.setQueryString(getPairs(params));
+ method.setQueryString(getPairs(params));
try {
int status = this.client.executeMethod(this.hostConfig, method);
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
index e61961b..62a1a7a 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
@@ -120,4 +120,9 @@ public interface IGitHubConstants {
*/
String CHARSET_UTF8 = "UTF-8"; //$NON-NLS-1$
+ /**
+ * PARAM_PER_PAGE
+ */
+ String PARAM_PER_PAGE = "per_page"; //$NON-NLS-1$
+
}