summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2013-07-12 09:19:30 (EDT)
committer Tomasz Zarna2013-07-12 09:19:30 (EDT)
commitafd9a826ca6875b52eabe889b01b17137e25c562 (patch)
treea552b3314e9051819dbaaf82331122865967ea7a
parent995a703a48fd744585c753e382ef71aae1433c99 (diff)
downloadorg.eclipse.mylyn.reviews-afd9a826ca6875b52eabe889b01b17137e25c562.zip
org.eclipse.mylyn.reviews-afd9a826ca6875b52eabe889b01b17137e25c562.tar.gz
org.eclipse.mylyn.reviews-afd9a826ca6875b52eabe889b01b17137e25c562.tar.bz2
395059: allow querying changes as Anonymousrefs/changes/83/14183/3
Bug: 395059 Change-Id: I1f9dcbc2ef91359769c4a421409c18fc4a7b69f3 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=395059 Signed-off-by: Tomasz Zarna <tomasz.zarna@tasktop.com>
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java
index d067f4b..0042441 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java
@@ -96,6 +96,8 @@ public class GerritClient extends ReviewsClient {
private static final Pattern GERRIT_VERSION_PATTERN = Pattern.compile("Powered by Gerrit Code Review (.+)</p>"); //$NON-NLS-1$
+ private static final Version GERRIT_VERSION_2_6 = new Version(2, 6, 0);
+
private abstract class Operation<T> implements AsyncCallback<T> {
private Throwable exception;
@@ -567,7 +569,7 @@ public class GerritClient extends ReviewsClient {
* user. On Gerrit 2.4 and earlier closed reviews are not included.
*/
public List<GerritQueryResult> queryMyReviews(IProgressMonitor monitor) throws GerritException {
- if (!restQueryAPIEnabled) {
+ if (hasJsonRpcApi(monitor) && !restQueryAPIEnabled) {
try {
final Account account = getAccount(monitor);
AccountDashboardInfo ad = execute(monitor, new Operation<AccountDashboardInfo>() {
@@ -593,6 +595,11 @@ public class GerritClient extends ReviewsClient {
return executeQueryRest(monitor, "owner:self OR reviewer:self"); //$NON-NLS-1$
}
+ private boolean hasJsonRpcApi(IProgressMonitor monitor) throws GerritException {
+ Version version = getCachedVersion(monitor);
+ return version.compareTo(GERRIT_VERSION_2_6) < 0;
+ }
+
/**
* Returns watched changes of the currently logged in user
*/
@@ -723,7 +730,7 @@ public class GerritClient extends ReviewsClient {
public List<GerritQueryResult> executeQuery(IProgressMonitor monitor, final String queryString)
throws GerritException {
- if (!restQueryAPIEnabled) {
+ if (hasJsonRpcApi(monitor) && !restQueryAPIEnabled) {
try {
SingleListChangeInfo sl = execute(monitor, new Operation<SingleListChangeInfo>() {
@Override