Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-26 00:01:13 +0000
committerChris Aniszczyk2011-05-03 13:58:35 +0000
commit6689d9bb91121b00bfdb35032d65d66e5a24a554 (patch)
tree9f43cc5d3014521fbd4101400b573a32da32421f
parent0643f069a0a91db136a01b3e1c2826c3edfd5a2d (diff)
downloadegit-github-6689d9bb91121b00bfdb35032d65d66e5a24a554.tar.gz
egit-github-6689d9bb91121b00bfdb35032d65d66e5a24a554.tar.xz
egit-github-6689d9bb91121b00bfdb35032d65d66e5a24a554.zip
Set per_page query param to 100 for all requests
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 32d3cbb2..57ccf496 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 e61961b6..62a1a7a1 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$
+
}

Back to the top