From dfe5bf53663b75b0c872043aebdd674692dba7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Thu, 14 Apr 2016 19:08:23 +0200 Subject: [PATCH] Adapt to removal of parseFieldMatcher getters and setters in core Original commit: elastic/x-pack-elasticsearch@4fd754d0aeec8720d2f0a9380c6aa51bb8aa4720 --- .../graph/rest/action/RestGraphAction.java | 40 +++++++++---------- .../xcontent/WatcherXContentParser.java | 21 ++-------- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/rest/action/RestGraphAction.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/rest/action/RestGraphAction.java index af74ba85f5d..6dbac8db07e 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/rest/action/RestGraphAction.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/rest/action/RestGraphAction.java @@ -119,15 +119,15 @@ public class RestGraphAction extends BaseRestHandler { } if (token == XContentParser.Token.START_ARRAY) { - if (context.parseFieldMatcher().match(fieldName, VERTICES_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, VERTICES_FIELD)) { parseVertices(parser, context, currentHop, graphRequest); } } else if (token == XContentParser.Token.START_OBJECT) { - if (context.parseFieldMatcher().match(fieldName, QUERY_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, QUERY_FIELD)) { currentHop.guidingQuery(context.parseInnerQueryBuilder()); - } else if (context.parseFieldMatcher().match(fieldName, CONNECTIONS_FIELD)) { + } else if (context.getParseFieldMatcher().match(fieldName, CONNECTIONS_FIELD)) { parseHop(parser, context, graphRequest.createNextHop(null), graphRequest); - } else if (context.parseFieldMatcher().match(fieldName, CONTROLS_FIELD)) { + } else if (context.getParseFieldMatcher().match(fieldName, CONTROLS_FIELD)) { if (currentHop.getParentHop() != null) { throw new ElasticsearchParseException( "Controls are a global setting that can only be set in the root " + fieldName, token.name()); @@ -165,7 +165,7 @@ public class RestGraphAction extends BaseRestHandler { token = parser.nextToken(); } if (token == XContentParser.Token.START_ARRAY) { - if (context.parseFieldMatcher().match(fieldName, INCLUDE_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, INCLUDE_FIELD)) { if (excludes != null) { throw new ElasticsearchParseException( "Graph vertices definition cannot contain both "+INCLUDE_FIELD.getPreferredName()+" and " @@ -181,7 +181,7 @@ public class RestGraphAction extends BaseRestHandler { fieldName = parser.currentName(); } else { if (token == XContentParser.Token.VALUE_STRING) { - if (context.parseFieldMatcher().match(fieldName, TERM_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, TERM_FIELD)) { includeTerm = parser.text(); } else { throw new ElasticsearchParseException( @@ -189,7 +189,7 @@ public class RestGraphAction extends BaseRestHandler { " clause has invalid property:" + fieldName); } } else if (token == XContentParser.Token.VALUE_NUMBER) { - if (context.parseFieldMatcher().match(fieldName, BOOST_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, BOOST_FIELD)) { boost = parser.floatValue(); } else { throw new ElasticsearchParseException( @@ -220,7 +220,7 @@ public class RestGraphAction extends BaseRestHandler { + token.name()); } } - } else if (context.parseFieldMatcher().match(fieldName, EXCLUDE_FIELD)) { + } else if (context.getParseFieldMatcher().match(fieldName, EXCLUDE_FIELD)) { if (includes != null) { throw new ElasticsearchParseException( "Graph vertices definition cannot contain both "+ INCLUDE_FIELD.getPreferredName()+ @@ -236,18 +236,18 @@ public class RestGraphAction extends BaseRestHandler { } } if (token == XContentParser.Token.VALUE_STRING) { - if (context.parseFieldMatcher().match(fieldName, FIELD_NAME_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, FIELD_NAME_FIELD)) { field = parser.text(); } else { throw new ElasticsearchParseException("Unknown string property: [" + fieldName + "]"); } } if (token == XContentParser.Token.VALUE_NUMBER) { - if (context.parseFieldMatcher().match(fieldName, SIZE_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, SIZE_FIELD)) { size = parser.intValue(); - } else if (context.parseFieldMatcher().match(fieldName, MIN_DOC_COUNT_FIELD)) { + } else if (context.getParseFieldMatcher().match(fieldName, MIN_DOC_COUNT_FIELD)) { minDocCount = parser.intValue(); - } else if (context.parseFieldMatcher().match(fieldName, SHARD_MIN_DOC_COUNT_FIELD)) { + } else if (context.getParseFieldMatcher().match(fieldName, SHARD_MIN_DOC_COUNT_FIELD)) { shardMinDocCount = parser.intValue(); } else { throw new ElasticsearchParseException("Unknown numeric property: [" + fieldName + "]"); @@ -287,37 +287,37 @@ public class RestGraphAction extends BaseRestHandler { if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_NUMBER) { - if (context.parseFieldMatcher().match(fieldName, SAMPLE_SIZE_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, SAMPLE_SIZE_FIELD)) { graphRequest.sampleSize(parser.intValue()); - } else if (context.parseFieldMatcher().match(fieldName, TIMEOUT_FIELD)) { + } else if (context.getParseFieldMatcher().match(fieldName, TIMEOUT_FIELD)) { graphRequest.timeout(TimeValue.timeValueMillis(parser.longValue())); } else { throw new ElasticsearchParseException("Unknown numeric property: [" + fieldName + "]"); } } else if (token == XContentParser.Token.VALUE_BOOLEAN) { - if (context.parseFieldMatcher().match(fieldName, SIGNIFICANCE_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, SIGNIFICANCE_FIELD)) { graphRequest.useSignificance(parser.booleanValue()); - } else if (context.parseFieldMatcher().match(fieldName, RETURN_DETAILED_INFO)) { + } else if (context.getParseFieldMatcher().match(fieldName, RETURN_DETAILED_INFO)) { graphRequest.returnDetailedInfo(parser.booleanValue()); } else{ throw new ElasticsearchParseException("Unknown boolean property: [" + fieldName + "]"); } } else if (token == XContentParser.Token.VALUE_STRING) { - if (context.parseFieldMatcher().match(fieldName, TIMEOUT_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, TIMEOUT_FIELD)) { graphRequest.timeout(TimeValue.parseTimeValue(parser.text(), null, "timeout")); } else { throw new ElasticsearchParseException("Unknown numeric property: [" + fieldName + "]"); } } else if (token == XContentParser.Token.START_OBJECT) { - if (context.parseFieldMatcher().match(fieldName, SAMPLE_DIVERSITY_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, SAMPLE_DIVERSITY_FIELD)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); token = parser.nextToken(); } - if (context.parseFieldMatcher().match(fieldName, FIELD_NAME_FIELD)) { + if (context.getParseFieldMatcher().match(fieldName, FIELD_NAME_FIELD)) { graphRequest.sampleDiversityField(parser.text()); - } else if (context.parseFieldMatcher().match(fieldName, MAX_DOCS_PER_VALUE_FIELD)) { + } else if (context.getParseFieldMatcher().match(fieldName, MAX_DOCS_PER_VALUE_FIELD)) { graphRequest.maxDocsPerDiversityValue(parser.intValue()); } else { throw new ElasticsearchParseException("Unknown property: [" + fieldName + "]"); diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/xcontent/WatcherXContentParser.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/xcontent/WatcherXContentParser.java index fd5bd6a21bd..0674b4820a9 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/xcontent/WatcherXContentParser.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/xcontent/WatcherXContentParser.java @@ -5,10 +5,13 @@ */ package org.elasticsearch.watcher.support.xcontent; +import java.io.IOException; +import java.util.List; +import java.util.Map; + import org.apache.lucene.util.BytesRef; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.xcontent.XContentLocation; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; @@ -17,10 +20,6 @@ import org.elasticsearch.watcher.support.clock.SystemClock; import org.elasticsearch.watcher.support.secret.Secret; import org.elasticsearch.watcher.support.secret.SecretService; -import java.io.IOException; -import java.util.List; -import java.util.Map; - /** * A xcontent parser that is used by watcher. This is a special parser that is * aware of watcher services. In particular, it's aware of the used {@link Clock} @@ -70,8 +69,6 @@ public class WatcherXContentParser implements XContentParser { private final XContentParser parser; private final @Nullable SecretService secretService; - private ParseFieldMatcher parseFieldMatcher = ParseFieldMatcher.EMPTY; - public WatcherXContentParser(XContentParser parser, Clock clock, @Nullable SecretService secretService) { this.clock = clock; this.parser = parser; @@ -258,16 +255,6 @@ public class WatcherXContentParser implements XContentParser { return parser.isClosed(); } - @Override - public ParseFieldMatcher getParseFieldMatcher() { - return parseFieldMatcher; - } - - @Override - public void setParseFieldMatcher(ParseFieldMatcher matcher) { - this.parseFieldMatcher = matcher; - } - @Override public void close() throws ElasticsearchException { parser.close();