Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-06-06 17:01:43 +0000
committerKevin Sawicki2012-06-06 17:01:43 +0000
commit3dbb4dd7e04e56da8fb8f46e0b1047a7225623c5 (patch)
treeb68f1d191c65914ee275fa0cea99215a7c5e5c64 /org.eclipse.egit.github.core/src
parentaa1af9f2743923d258fb41cace54f4c9810e8b19 (diff)
downloadegit-github-3dbb4dd7e04e56da8fb8f46e0b1047a7225623c5.tar.gz
egit-github-3dbb4dd7e04e56da8fb8f46e0b1047a7225623c5.tar.xz
egit-github-3dbb4dd7e04e56da8fb8f46e0b1047a7225623c5.zip
Use API v3 endpoint for repository search API
API v2 is being removed and is now provided as a legacy v3 API. Change-Id: Id1dea03486893b25012ae72518910a7d1bb3f4b9
Diffstat (limited to 'org.eclipse.egit.github.core/src')
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java10
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java8
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java25
3 files changed, 9 insertions, 34 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
index 99340ea0..5e992129 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
@@ -26,11 +26,9 @@ import static org.eclipse.egit.github.core.client.IGitHubConstants.AUTH_TOKEN;
import static org.eclipse.egit.github.core.client.IGitHubConstants.CHARSET_UTF8;
import static org.eclipse.egit.github.core.client.IGitHubConstants.CONTENT_TYPE_JSON;
import static org.eclipse.egit.github.core.client.IGitHubConstants.HOST_API;
-import static org.eclipse.egit.github.core.client.IGitHubConstants.HOST_API_V2;
import static org.eclipse.egit.github.core.client.IGitHubConstants.HOST_DEFAULT;
import static org.eclipse.egit.github.core.client.IGitHubConstants.HOST_GISTS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.PROTOCOL_HTTPS;
-import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_V2_API;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_V3_API;
import com.google.gson.Gson;
@@ -184,7 +182,7 @@ public class GitHubClient {
baseUri = uri.toString();
// Use URI prefix on non-standard host names
- if (HOST_API.equals(hostname) || HOST_API_V2.equals(hostname))
+ if (HOST_API.equals(hostname))
prefix = null;
else
prefix = SEGMENT_V3_API;
@@ -239,10 +237,10 @@ public class GitHubClient {
* @return configured URI
*/
protected String configureUri(final String uri) {
- if (prefix == null || uri.startsWith(SEGMENT_V2_API)
- || uri.startsWith(prefix))
+ if (prefix == null || uri.startsWith(prefix))
return uri;
- return prefix + uri;
+ else
+ return prefix + uri;
}
/**
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
index 575a5ca9..62cabd83 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
@@ -42,8 +42,6 @@ public interface IGitHubConstants {
/** */
String HOST_API = "api.github.com"; //$NON-NLS-1$
/** */
- String HOST_API_V2 = "github.com"; //$NON-NLS-1$
- /** */
String HOST_DEFAULT = "github.com"; //$NON-NLS-1$
/** */
String HOST_GISTS = "gist.github.com"; //$NON-NLS-1$
@@ -121,6 +119,8 @@ public interface IGitHubConstants {
/** */
String SEGMENT_LABELS = "/labels"; //$NON-NLS-1$
/** */
+ String SEGMENT_LEGACY = "/legacy"; //$NON-NLS-1$
+ /** */
String SEGMENT_LANGUAGES = "/languages"; //$NON-NLS-1$
/** */
String SEGMENT_MEMBERS = "/members"; //$NON-NLS-1$
@@ -173,8 +173,6 @@ public interface IGitHubConstants {
/** */
String SEGMENT_WATCHERS = "/watchers"; //$NON-NLS-1$
/** */
- String SEGMENT_V2_API = "/api/v2/json"; //$NON-NLS-1$
- /** */
String SEGMENT_V3_API = "/api/v3"; //$NON-NLS-1$
/** */
@@ -185,6 +183,4 @@ public interface IGitHubConstants {
/** */
String URL_API = PROTOCOL_HTTPS + "://" + HOST_API; //$NON-NLS-1$
- /** */
- String URL_API_V2 = PROTOCOL_HTTPS + "://" + HOST_API_V2; //$NON-NLS-1$
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java
index 75817acc..d74e091c 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java
@@ -18,6 +18,7 @@ import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_CONTR
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_FORKS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_HOOKS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_LANGUAGES;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_LEGACY;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_ORGS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_SEARCH;
@@ -25,7 +26,6 @@ import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_TAGS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_TEST;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_USER;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_USERS;
-import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_V2_API;
import static org.eclipse.egit.github.core.client.PagedRequest.PAGE_FIRST;
import static org.eclipse.egit.github.core.client.PagedRequest.PAGE_SIZE;
@@ -402,9 +402,6 @@ public class RepositoryService extends GitHubService {
/**
* Search for repositories matching query.
- * <p>
- * This method requires an API v2 configured {@link GitHubClient} as it is
- * not yet supported in API v3 clients.
*
* @param query
* @return list of repositories
@@ -417,9 +414,6 @@ public class RepositoryService extends GitHubService {
/**
* Search for repositories matching query.
- * <p>
- * This method requires an API v2 configured {@link GitHubClient} as it is
- * not yet supported in API v3 clients.
*
* @param query
* @param startPage
@@ -433,9 +427,6 @@ public class RepositoryService extends GitHubService {
/**
* Search for repositories matching language and query.
- * <p>
- * This method requires an API v2 configured {@link GitHubClient} as it is
- * not yet supported in API v3 clients.
*
* @param query
* @param language
@@ -449,9 +440,6 @@ public class RepositoryService extends GitHubService {
/**
* Search for repositories matching language and query.
- * <p>
- * This method requires an API v2 configured {@link GitHubClient} as it is
- * not yet supported in API v3 clients.
*
* @param query
* @param language
@@ -466,9 +454,8 @@ public class RepositoryService extends GitHubService {
if (query.length() == 0)
throw new IllegalArgumentException("Query cannot be empty"); //$NON-NLS-1$
- StringBuilder uri = new StringBuilder(SEGMENT_V2_API);
- uri.append(SEGMENT_REPOS);
- uri.append(SEGMENT_SEARCH);
+ StringBuilder uri = new StringBuilder(SEGMENT_LEGACY + SEGMENT_REPOS
+ + SEGMENT_SEARCH);
final String encodedQuery = URLEncoder.encode(query, CHARSET_UTF8)
.replace("+", "%20") //$NON-NLS-1$ //$NON-NLS-2$
.replace(".", "%2E"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -491,9 +478,6 @@ public class RepositoryService extends GitHubService {
/**
* Search for repositories matching search parameters.
- * <p>
- * This method requires an API v2 configured {@link GitHubClient} as it is
- * not yet supported in API v3 clients.
*
* @param params
* @return list of repositories
@@ -506,9 +490,6 @@ public class RepositoryService extends GitHubService {
/**
* Search for repositories matching search parameters.
- * <p>
- * This method requires an API v2 configured {@link GitHubClient} as it is
- * not yet supported in API v3 clients.
*
* @param queryParams
* @param startPage

Back to the top