Remove unused ParseFieldMatcher argument from SearchInput and SearchTransform parse methods
Original commit: elastic/x-pack-elasticsearch@6cf7323961
This commit is contained in:
parent
4359a0508f
commit
cd2e608ecc
|
@ -5,15 +5,12 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.input.search;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.xpack.watcher.input.Input;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.search.WatcherSearchTemplateRequest;
|
||||
|
@ -108,9 +105,7 @@ public class SearchInput implements Input {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static SearchInput parse(Logger inputLogger, String watchId, XContentParser parser,
|
||||
ParseFieldMatcher parseFieldMatcher,
|
||||
SearchRequestParsers searchRequestParsers) throws IOException {
|
||||
public static SearchInput parse(String watchId, XContentParser parser) throws IOException {
|
||||
WatcherSearchTemplateRequest request = null;
|
||||
Set<String> extract = null;
|
||||
TimeValue timeout = null;
|
||||
|
@ -123,8 +118,7 @@ public class SearchInput implements Input {
|
|||
currentFieldName = parser.currentName();
|
||||
} else if (Field.REQUEST.match(currentFieldName)) {
|
||||
try {
|
||||
request = WatcherSearchTemplateRequest.fromXContent(inputLogger, parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE,
|
||||
parseFieldMatcher, searchRequestParsers);
|
||||
request = WatcherSearchTemplateRequest.fromXContent(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE);
|
||||
} catch (ElasticsearchParseException srpe) {
|
||||
throw new ElasticsearchParseException("could not parse [{}] input for watch [{}]. failed to parse [{}]", srpe, TYPE,
|
||||
watchId, currentFieldName);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.input.search;
|
||||
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
@ -24,8 +23,6 @@ import java.io.IOException;
|
|||
public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Result, ExecutableSearchInput> {
|
||||
private final WatcherClientProxy client;
|
||||
private final TimeValue defaultTimeout;
|
||||
private final SearchRequestParsers searchRequestParsers;
|
||||
private final ParseFieldMatcher parseFieldMatcher;
|
||||
private final WatcherSearchTemplateService searchTemplateService;
|
||||
|
||||
public SearchInputFactory(Settings settings, InternalClient client, SearchRequestParsers searchRequestParsers,
|
||||
|
@ -36,9 +33,7 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
|
|||
public SearchInputFactory(Settings settings, WatcherClientProxy client, SearchRequestParsers searchRequestParsers,
|
||||
NamedXContentRegistry xContentRegistry, ScriptService scriptService) {
|
||||
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
|
||||
this.parseFieldMatcher = new ParseFieldMatcher(settings);
|
||||
this.client = client;
|
||||
this.searchRequestParsers = searchRequestParsers;
|
||||
this.defaultTimeout = settings.getAsTime("xpack.watcher.input.search.default_timeout", null);
|
||||
this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, searchRequestParsers, xContentRegistry);
|
||||
}
|
||||
|
@ -50,8 +45,7 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
|
|||
|
||||
@Override
|
||||
public SearchInput parseInput(String watchId, XContentParser parser) throws IOException {
|
||||
return SearchInput.parse(inputLogger, watchId, parser,
|
||||
parseFieldMatcher, searchRequestParsers);
|
||||
return SearchInput.parse(watchId, parser);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.search;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
|
@ -19,7 +18,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptType;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -161,10 +159,7 @@ public class WatcherSearchTemplateRequest implements ToXContent {
|
|||
/**
|
||||
* Reads a new watcher search request instance for the specified parser.
|
||||
*/
|
||||
public static WatcherSearchTemplateRequest fromXContent(Logger logger, XContentParser parser,
|
||||
SearchType searchType,
|
||||
ParseFieldMatcher parseFieldMatcher,
|
||||
SearchRequestParsers searchRequestParsers) throws IOException {
|
||||
public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, SearchType searchType) throws IOException {
|
||||
List<String> indices = new ArrayList<>();
|
||||
List<String> types = new ArrayList<>();
|
||||
IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS;
|
||||
|
|
|
@ -5,15 +5,12 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.transform.search;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.search.WatcherSearchTemplateRequest;
|
||||
import org.elasticsearch.xpack.watcher.transform.Transform;
|
||||
|
@ -91,10 +88,7 @@ public class SearchTransform implements Transform {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static SearchTransform parse(Logger transformLogger, String watchId,
|
||||
XContentParser parser,
|
||||
ParseFieldMatcher parseFieldMatcher,
|
||||
SearchRequestParsers searchRequestParsers) throws IOException {
|
||||
public static SearchTransform parse(String watchId, XContentParser parser) throws IOException {
|
||||
WatcherSearchTemplateRequest request = null;
|
||||
TimeValue timeout = null;
|
||||
DateTimeZone dynamicNameTimeZone = null;
|
||||
|
@ -106,8 +100,7 @@ public class SearchTransform implements Transform {
|
|||
currentFieldName = parser.currentName();
|
||||
} else if (Field.REQUEST.match(currentFieldName)) {
|
||||
try {
|
||||
request = WatcherSearchTemplateRequest.fromXContent(transformLogger, parser,
|
||||
ExecutableSearchTransform.DEFAULT_SEARCH_TYPE, parseFieldMatcher, searchRequestParsers);
|
||||
request = WatcherSearchTemplateRequest.fromXContent(parser, ExecutableSearchTransform.DEFAULT_SEARCH_TYPE);
|
||||
} catch (ElasticsearchParseException srpe) {
|
||||
throw new ElasticsearchParseException("could not parse [{}] transform for watch [{}]. failed to parse [{}]", srpe,
|
||||
TYPE, watchId, currentFieldName);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.transform.search;
|
||||
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
@ -23,8 +22,6 @@ import java.io.IOException;
|
|||
public class SearchTransformFactory extends TransformFactory<SearchTransform, SearchTransform.Result, ExecutableSearchTransform> {
|
||||
protected final WatcherClientProxy client;
|
||||
private final TimeValue defaultTimeout;
|
||||
private final SearchRequestParsers searchRequestParsers;
|
||||
private final ParseFieldMatcher parseFieldMatcher;
|
||||
private final WatcherSearchTemplateService searchTemplateService;
|
||||
|
||||
public SearchTransformFactory(Settings settings, InternalClient client, SearchRequestParsers searchRequestParsers,
|
||||
|
@ -36,8 +33,6 @@ public class SearchTransformFactory extends TransformFactory<SearchTransform, Se
|
|||
NamedXContentRegistry xContentRegistry, ScriptService scriptService) {
|
||||
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
|
||||
this.client = client;
|
||||
this.parseFieldMatcher = new ParseFieldMatcher(settings);
|
||||
this.searchRequestParsers = searchRequestParsers;
|
||||
this.defaultTimeout = settings.getAsTime("xpack.watcher.transform.search.default_timeout", null);
|
||||
this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, searchRequestParsers, xContentRegistry);
|
||||
}
|
||||
|
@ -49,8 +44,7 @@ public class SearchTransformFactory extends TransformFactory<SearchTransform, Se
|
|||
|
||||
@Override
|
||||
public SearchTransform parseTransform(String watchId, XContentParser parser) throws IOException {
|
||||
return SearchTransform.parse(transformLogger, watchId, parser,
|
||||
parseFieldMatcher, searchRequestParsers);
|
||||
return SearchTransform.parse(watchId, parser);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
|
@ -123,7 +122,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
|||
request.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
XContentParser parser = createParser(builder);
|
||||
assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT));
|
||||
WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent(logger, parser, DEFAULT_SEARCH_TYPE, null, null);
|
||||
WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent(parser, DEFAULT_SEARCH_TYPE);
|
||||
|
||||
assertThat(result.getIndices(), arrayContainingInAnyOrder(expectedIndices != null ? expectedIndices : new String[0]));
|
||||
assertThat(result.getTypes(), arrayContainingInAnyOrder(expectedTypes != null ? expectedTypes : new String[0]));
|
||||
|
@ -212,7 +211,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
|||
|
||||
XContentParser parser = createParser(builder);
|
||||
assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT));
|
||||
WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent(logger, parser, DEFAULT_SEARCH_TYPE, null, null);
|
||||
WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent(parser, DEFAULT_SEARCH_TYPE);
|
||||
|
||||
assertThat(result.getIndices(), arrayContainingInAnyOrder(indices));
|
||||
assertThat(result.getTypes(), arrayContainingInAnyOrder(types));
|
||||
|
|
|
@ -31,9 +31,7 @@ public class WatcherSearchTemplateRequestTests extends ESTestCase {
|
|||
private void assertTemplate(String source, String expectedScript, String expectedLang, Map<String, Object> expectedParams) {
|
||||
try (XContentParser parser = createParser(JsonXContent.jsonXContent, source)) {
|
||||
parser.nextToken();
|
||||
|
||||
WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent(
|
||||
logger, parser, randomFrom(SearchType.values()), null, null);
|
||||
WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent(parser, randomFrom(SearchType.values()));
|
||||
assertNotNull(result.getTemplate());
|
||||
assertThat(result.getTemplate().getIdOrCode(), equalTo(expectedScript));
|
||||
assertThat(result.getTemplate().getLang(), equalTo(expectedLang));
|
||||
|
|
Loading…
Reference in New Issue