Adapt to new QueryProcess<T> on Gerrit master ChangeQueryProcessor has now a different interface on Gerrit master and we need to inject it differently and query for changes using the ChangeData as actual type. Change-Id: I9b70f2fc4f19305aa21d0cc92cbeb2fb5a6703de
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java index dd8a9cb..ed1b915 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java
@@ -41,11 +41,12 @@ import com.google.gerrit.server.project.ProjectControl; import com.google.gerrit.server.project.RefControl; import com.google.gerrit.server.query.QueryParseException; +import com.google.gerrit.server.query.QueryProcessor; +import com.google.gerrit.server.query.QueryResult; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeQueryBuilder; +import com.google.gerrit.server.query.change.ChangeQueryProcessor; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gerrit.server.query.change.QueryProcessor; -import com.google.gerrit.server.query.change.QueryResult; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; @@ -77,7 +78,7 @@ private final GenericFactory userFactory; private final Provider<InternalChangeQuery> queryProvider; private final BatchUpdate.Factory updateFactory; - private final QueryProcessor qp; + private final QueryProcessor<ChangeData> qp; private final ChangeQueryBuilder changeQuery; @Inject @@ -87,7 +88,7 @@ IdentifiedUser.GenericFactory userFactory, Provider<InternalChangeQuery> queryProvider, BatchUpdate.Factory batchUpdateFactory, - QueryProcessor qp, + ChangeQueryProcessor qp, ChangeQueryBuilder changeQuery) { this.changeInserterFactory = changeInserterFactory; this.patchSetInserterFactory = patchSetInserterFactory; @@ -195,10 +196,10 @@ } private List<ChangeData> queryChangesForSha1(String pullRequestSha1) { - QueryResult results; + QueryResult<ChangeData> results; try { - results = qp.queryChanges(changeQuery.commit(pullRequestSha1)); - return results.changes(); + results = qp.query(changeQuery.commit(pullRequestSha1)); + return results.entities(); } catch (OrmException | QueryParseException e) { LOG.error("Invalid SHA1 " + pullRequestSha1 + ": cannot query changes for this pull request", e);
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java index 16ef7f9..882ded3 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
@@ -109,7 +109,7 @@ accountCache.evict(accountId); log.debug("Account cache evicted for {}", accountId); - } catch (AccountException | OrmException e) { + } catch (AccountException | OrmException | IOException e) { throw new ServletException("Cannot associate email '" + email + "' to current user '" + user + "'", e); }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java index 4fd0d66..3faa6b4 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java
@@ -23,8 +23,10 @@ import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.query.QueryParseException; +import com.google.gerrit.server.query.QueryProcessor; +import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeQueryBuilder; -import com.google.gerrit.server.query.change.QueryProcessor; +import com.google.gerrit.server.query.change.ChangeQueryProcessor; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; @@ -32,15 +34,11 @@ import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; - import com.googlesource.gerrit.plugins.github.GitHubConfig; import com.googlesource.gerrit.plugins.github.oauth.GitHubLogin; import org.eclipse.jgit.errors.IncorrectObjectTypeException; -import org.eclipse.jgit.errors.MissingObjectException; -import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevWalk; import org.kohsuke.github.GHIssueState; import org.kohsuke.github.GHPullRequest; import org.kohsuke.github.GHPullRequestCommitDetail; @@ -70,7 +68,7 @@ private final ProjectCache projectsCache; private final GitRepositoryManager repoMgr; private final Provider<ReviewDb> schema; - private final QueryProcessor qp; + private final QueryProcessor<ChangeData> qp; private final ChangeQueryBuilder changeQuery; @Inject @@ -78,7 +76,7 @@ GitRepositoryManager repoMgr, Provider<ReviewDb> schema, GitHubConfig config, - QueryProcessor qp, + ChangeQueryProcessor qp, ChangeQueryBuilder changeQuery) { this.projectsCache = projectsCache; this.repoMgr = repoMgr; @@ -203,8 +201,8 @@ for (GHPullRequestCommitDetail pullRequestCommit : ghPullRequest .listCommits()) { pullRequestToImport |= - qp.queryChanges(changeQuery.commit(pullRequestCommit.getSha())) - .changes().isEmpty(); + qp.query(changeQuery.commit(pullRequestCommit.getSha())) + .entities().isEmpty(); } return pullRequestToImport; } catch (OrmException | QueryParseException e) {