From e359be7632e5d65c2e08934bb2e5062db47d513f Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 29 Jun 2016 18:41:31 -0400 Subject: [PATCH] Don't inject TransportPercolateAction into RestPercolateAction Instead use the client. This will help us build the actions more easily in the future. --- .../resources/checkstyle_suppressions.xml | 1 - .../percolator/RestMultiPercolateAction.java | 8 +++----- .../percolator/RestPercolateAction.java | 20 +++++++++---------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml index 5a08a834c3c..71f2cf85ab4 100644 --- a/buildSrc/src/main/resources/checkstyle_suppressions.xml +++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml @@ -1168,7 +1168,6 @@ - diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/RestMultiPercolateAction.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/RestMultiPercolateAction.java index a2902a9a7c2..41de2de42d1 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/RestMultiPercolateAction.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/RestMultiPercolateAction.java @@ -36,13 +36,10 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestMultiPercolateAction extends BaseRestHandler { private final boolean allowExplicitIndex; - private final TransportMultiPercolateAction action; @Inject - public RestMultiPercolateAction(Settings settings, RestController controller, Client client, - TransportMultiPercolateAction action) { + public RestMultiPercolateAction(Settings settings, RestController controller, Client client) { super(settings, client); - this.action = action; controller.registerHandler(POST, "/_mpercolate", this); controller.registerHandler(POST, "/{index}/_mpercolate", this); controller.registerHandler(POST, "/{index}/{type}/_mpercolate", this); @@ -61,7 +58,8 @@ public class RestMultiPercolateAction extends BaseRestHandler { multiPercolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("index"))); multiPercolateRequest.documentType(restRequest.param("type")); multiPercolateRequest.add(RestActions.getRestContent(restRequest), allowExplicitIndex); - action.execute(multiPercolateRequest, new RestToXContentListener(restChannel)); + client.execute(MultiPercolateAction.INSTANCE, multiPercolateRequest, + new RestToXContentListener(restChannel)); } } diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/RestPercolateAction.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/RestPercolateAction.java index b752cc55f6c..6dffd5518c8 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/RestPercolateAction.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/RestPercolateAction.java @@ -36,13 +36,9 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestPercolateAction extends BaseRestHandler { - - private final TransportPercolateAction action; - @Inject - public RestPercolateAction(Settings settings, RestController controller, Client client, TransportPercolateAction action) { + public RestPercolateAction(Settings settings, RestController controller, Client client) { super(settings, client); - this.action = action; controller.registerHandler(GET, "/{index}/{type}/_percolate", this); controller.registerHandler(POST, "/{index}/{type}/_percolate", this); @@ -54,7 +50,8 @@ public class RestPercolateAction extends BaseRestHandler { controller.registerHandler(GET, "/{index}/{type}/_percolate/count", countHandler); controller.registerHandler(POST, "/{index}/{type}/_percolate/count", countHandler); - RestCountPercolateExistingDocHandler countExistingDocHandler = new RestCountPercolateExistingDocHandler(settings, controller, client); + RestCountPercolateExistingDocHandler countExistingDocHandler = new RestCountPercolateExistingDocHandler(settings, controller, + client); controller.registerHandler(GET, "/{index}/{type}/{id}/_percolate/count", countExistingDocHandler); controller.registerHandler(POST, "/{index}/{type}/{id}/_percolate/count", countExistingDocHandler); } @@ -67,10 +64,11 @@ public class RestPercolateAction extends BaseRestHandler { percolateRequest.source(RestActions.getRestContent(restRequest)); percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions())); - executePercolate(percolateRequest, restChannel); + executePercolate(client, percolateRequest, restChannel); } - void parseExistingDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) { + void parseExistingDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, + final Client client) { String index = restRequest.param("index"); String type = restRequest.param("type"); percolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("percolate_index", index))); @@ -91,11 +89,11 @@ public class RestPercolateAction extends BaseRestHandler { percolateRequest.source(RestActions.getRestContent(restRequest)); percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions())); - executePercolate(percolateRequest, restChannel); + executePercolate(client, percolateRequest, restChannel); } - void executePercolate(final PercolateRequest percolateRequest, final RestChannel restChannel) { - action.execute(percolateRequest, new RestToXContentListener<>(restChannel)); + void executePercolate(final Client client, final PercolateRequest percolateRequest, final RestChannel restChannel) { + client.execute(PercolateAction.INSTANCE, percolateRequest, new RestToXContentListener<>(restChannel)); } @Override