BugFix: Add the BeanReceiver plumbing to the top-level query commands
An earlier change made ChangeQueryProcessor implement the BeanReceiver interface, but that's not sufficient to support the real use cases. In order for the ChangeQueryProcessor to get the DynamicBeans invoked with a query, the Query and QueryChanges commands need to set the DynamicBeans on the ChangeQueryProcessor. Change-Id: I087cde95a109fda8b4ca879b293e3586041c3a77
This commit is contained in:
@@ -24,6 +24,7 @@ import com.google.gerrit.index.query.QueryResult;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
|
import com.google.gerrit.server.DynamicOptions;
|
||||||
import com.google.gerrit.server.config.TrackingFooters;
|
import com.google.gerrit.server.config.TrackingFooters;
|
||||||
import com.google.gerrit.server.data.ChangeAttribute;
|
import com.google.gerrit.server.data.ChangeAttribute;
|
||||||
import com.google.gerrit.server.data.PatchSetAttribute;
|
import com.google.gerrit.server.data.PatchSetAttribute;
|
||||||
@@ -180,6 +181,10 @@ public class OutputStreamQuery {
|
|||||||
this.outputFormat = fmt;
|
this.outputFormat = fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDynamicBean(String plugin, DynamicOptions.DynamicBean dynamicBean) {
|
||||||
|
queryProcessor.setDynamicBean(plugin, dynamicBean);
|
||||||
|
}
|
||||||
|
|
||||||
public void query(String queryString) throws IOException {
|
public void query(String queryString) throws IOException {
|
||||||
out =
|
out =
|
||||||
new PrintWriter( //
|
new PrintWriter( //
|
||||||
|
@@ -25,6 +25,7 @@ import com.google.gerrit.extensions.restapi.TopLevelResource;
|
|||||||
import com.google.gerrit.index.query.QueryParseException;
|
import com.google.gerrit.index.query.QueryParseException;
|
||||||
import com.google.gerrit.index.query.QueryRequiresAuthException;
|
import com.google.gerrit.index.query.QueryRequiresAuthException;
|
||||||
import com.google.gerrit.index.query.QueryResult;
|
import com.google.gerrit.index.query.QueryResult;
|
||||||
|
import com.google.gerrit.server.DynamicOptions;
|
||||||
import com.google.gerrit.server.change.ChangeJson;
|
import com.google.gerrit.server.change.ChangeJson;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
@@ -38,7 +39,7 @@ import java.util.EnumSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
public class QueryChanges implements RestReadView<TopLevelResource> {
|
public class QueryChanges implements RestReadView<TopLevelResource>, DynamicOptions.BeanReceiver {
|
||||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
private final ChangeJson.Factory json;
|
private final ChangeJson.Factory json;
|
||||||
@@ -81,6 +82,10 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
|||||||
imp.setStart(start);
|
imp.setStart(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDynamicBean(String plugin, DynamicOptions.DynamicBean dynamicBean) {
|
||||||
|
imp.setDynamicBean(plugin, dynamicBean);
|
||||||
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
QueryChanges(ChangeJson.Factory json, ChangeQueryBuilder qb, ChangeQueryProcessor qp) {
|
QueryChanges(ChangeJson.Factory json, ChangeQueryBuilder qb, ChangeQueryProcessor qp) {
|
||||||
this.json = json;
|
this.json = json;
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.sshd.commands;
|
package com.google.gerrit.sshd.commands;
|
||||||
|
|
||||||
|
import com.google.gerrit.server.DynamicOptions;
|
||||||
import com.google.gerrit.server.query.change.OutputStreamQuery;
|
import com.google.gerrit.server.query.change.OutputStreamQuery;
|
||||||
import com.google.gerrit.server.query.change.OutputStreamQuery.OutputFormat;
|
import com.google.gerrit.server.query.change.OutputStreamQuery.OutputFormat;
|
||||||
import com.google.gerrit.sshd.CommandMetaData;
|
import com.google.gerrit.sshd.CommandMetaData;
|
||||||
@@ -24,7 +25,7 @@ import org.kohsuke.args4j.Argument;
|
|||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
@CommandMetaData(name = "query", description = "Query the change database")
|
@CommandMetaData(name = "query", description = "Query the change database")
|
||||||
public class Query extends SshCommand {
|
public class Query extends SshCommand implements DynamicOptions.BeanReceiver {
|
||||||
@Inject private OutputStreamQuery processor;
|
@Inject private OutputStreamQuery processor;
|
||||||
|
|
||||||
@Option(name = "--format", metaVar = "FMT", usage = "Output display format")
|
@Option(name = "--format", metaVar = "FMT", usage = "Output display format")
|
||||||
@@ -103,6 +104,10 @@ public class Query extends SshCommand {
|
|||||||
processor.query(join(query, " "));
|
processor.query(join(query, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDynamicBean(String plugin, DynamicOptions.DynamicBean dynamicBean) {
|
||||||
|
processor.setDynamicBean(plugin, dynamicBean);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void parseCommandLine() throws UnloggedFailure {
|
protected void parseCommandLine() throws UnloggedFailure {
|
||||||
processor.setOutput(out, OutputFormat.TEXT);
|
processor.setOutput(out, OutputFormat.TEXT);
|
||||||
|
Reference in New Issue
Block a user