Remove some usages of ParseFieldMatcher in favour of using ParseField directly (elastic/elasticsearch#4495)
Relates to elastic/elasticsearch#19552 Relates to elastic/elasticsearch#22130 Original commit: elastic/x-pack-elasticsearch@85d2a4cdbf
This commit is contained in:
parent
d210213fc9
commit
3532e34aaa
|
@ -96,9 +96,9 @@ public class HttpProxy implements ToXContent, Streamable {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.HOST)) {
|
} else if (Field.HOST.match(currentFieldName)) {
|
||||||
host = parser.text();
|
host = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PORT)) {
|
} else if (Field.PORT.match(currentFieldName)) {
|
||||||
port = parser.intValue();
|
port = parser.intValue();
|
||||||
if (port <= 0 || port >= 65535) {
|
if (port <= 0 || port >= 65535) {
|
||||||
throw new ElasticsearchParseException("Proxy port must be between 1 and 65534, but was " + port);
|
throw new ElasticsearchParseException("Proxy port must be between 1 and 65534, but was " + port);
|
||||||
|
|
|
@ -256,17 +256,17 @@ public class HttpRequest implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PROXY)) {
|
} else if (Field.PROXY.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
builder.proxy(HttpProxy.parse(parser));
|
builder.proxy(HttpProxy.parse(parser));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElasticsearchParseException("could not parse http request. could not parse [{}] field", currentFieldName);
|
throw new ElasticsearchParseException("could not parse http request. could not parse [{}] field", currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.AUTH)) {
|
} else if (Field.AUTH.match(currentFieldName)) {
|
||||||
builder.auth(httpAuthRegistry.parse(parser));
|
builder.auth(httpAuthRegistry.parse(parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.CONNECTION_TIMEOUT)) {
|
} else if (HttpRequest.Field.CONNECTION_TIMEOUT.match(currentFieldName)) {
|
||||||
builder.connectionTimeout(TimeValue.timeValueMillis(parser.longValue()));
|
builder.connectionTimeout(TimeValue.timeValueMillis(parser.longValue()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.CONNECTION_TIMEOUT_HUMAN)) {
|
} else if (HttpRequest.Field.CONNECTION_TIMEOUT_HUMAN.match(currentFieldName)) {
|
||||||
// Users and 2.x specify the timeout this way
|
// Users and 2.x specify the timeout this way
|
||||||
try {
|
try {
|
||||||
builder.connectionTimeout(WatcherDateTimeUtils.parseTimeValue(parser,
|
builder.connectionTimeout(WatcherDateTimeUtils.parseTimeValue(parser,
|
||||||
|
@ -275,9 +275,9 @@ public class HttpRequest implements ToXContent {
|
||||||
throw new ElasticsearchParseException("could not parse http request template. invalid time value for [{}] field",
|
throw new ElasticsearchParseException("could not parse http request template. invalid time value for [{}] field",
|
||||||
pe, currentFieldName);
|
pe, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.READ_TIMEOUT)) {
|
} else if (HttpRequest.Field.READ_TIMEOUT.match(currentFieldName)) {
|
||||||
builder.readTimeout(TimeValue.timeValueMillis(parser.longValue()));
|
builder.readTimeout(TimeValue.timeValueMillis(parser.longValue()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.READ_TIMEOUT_HUMAN)) {
|
} else if (HttpRequest.Field.READ_TIMEOUT_HUMAN.match(currentFieldName)) {
|
||||||
// Users and 2.x specify the timeout this way
|
// Users and 2.x specify the timeout this way
|
||||||
try {
|
try {
|
||||||
builder.readTimeout(WatcherDateTimeUtils.parseTimeValue(parser, HttpRequest.Field.READ_TIMEOUT.toString()));
|
builder.readTimeout(WatcherDateTimeUtils.parseTimeValue(parser, HttpRequest.Field.READ_TIMEOUT.toString()));
|
||||||
|
@ -286,35 +286,35 @@ public class HttpRequest implements ToXContent {
|
||||||
pe, currentFieldName);
|
pe, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.HEADERS)) {
|
if (Field.HEADERS.match(currentFieldName)) {
|
||||||
builder.setHeaders((Map) WatcherUtils.flattenModel(parser.map()));
|
builder.setHeaders((Map) WatcherUtils.flattenModel(parser.map()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PARAMS)) {
|
} else if (Field.PARAMS.match(currentFieldName)) {
|
||||||
builder.setParams((Map) WatcherUtils.flattenModel(parser.map()));
|
builder.setParams((Map) WatcherUtils.flattenModel(parser.map()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.BODY)) {
|
} else if (Field.BODY.match(currentFieldName)) {
|
||||||
builder.body(parser.text());
|
builder.body(parser.text());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse http request. unexpected object field [{}]",
|
throw new ElasticsearchParseException("could not parse http request. unexpected object field [{}]",
|
||||||
currentFieldName);
|
currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.SCHEME)) {
|
if (Field.SCHEME.match(currentFieldName)) {
|
||||||
builder.scheme(Scheme.parse(parser.text()));
|
builder.scheme(Scheme.parse(parser.text()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.METHOD)) {
|
} else if (Field.METHOD.match(currentFieldName)) {
|
||||||
builder.method(HttpMethod.parse(parser.text()));
|
builder.method(HttpMethod.parse(parser.text()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.HOST)) {
|
} else if (Field.HOST.match(currentFieldName)) {
|
||||||
builder.host = parser.text();
|
builder.host = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PATH)) {
|
} else if (Field.PATH.match(currentFieldName)) {
|
||||||
builder.path(parser.text());
|
builder.path(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.BODY)) {
|
} else if (Field.BODY.match(currentFieldName)) {
|
||||||
builder.body(parser.text());
|
builder.body(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.URL)) {
|
} else if (Field.URL.match(currentFieldName)) {
|
||||||
builder.fromUrl(parser.text());
|
builder.fromUrl(parser.text());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse http request. unexpected string field [{}]",
|
throw new ElasticsearchParseException("could not parse http request. unexpected string field [{}]",
|
||||||
currentFieldName);
|
currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PORT)) {
|
if (Field.PORT.match(currentFieldName)) {
|
||||||
builder.port = parser.intValue();
|
builder.port = parser.intValue();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse http request. unexpected numeric field [{}]",
|
throw new ElasticsearchParseException("could not parse http request. unexpected numeric field [{}]",
|
||||||
|
|
|
@ -277,21 +277,21 @@ public class HttpRequestTemplate implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.PROXY)) {
|
} else if (HttpRequest.Field.PROXY.match(currentFieldName)) {
|
||||||
builder.proxy(HttpProxy.parse(parser));
|
builder.proxy(HttpProxy.parse(parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.PATH)) {
|
} else if (HttpRequest.Field.PATH.match(currentFieldName)) {
|
||||||
builder.path(parseFieldTemplate(currentFieldName, parser));
|
builder.path(parseFieldTemplate(currentFieldName, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.HEADERS)) {
|
} else if (HttpRequest.Field.HEADERS.match(currentFieldName)) {
|
||||||
builder.putHeaders(parseFieldTemplates(currentFieldName, parser));
|
builder.putHeaders(parseFieldTemplates(currentFieldName, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.PARAMS)) {
|
} else if (HttpRequest.Field.PARAMS.match(currentFieldName)) {
|
||||||
builder.putParams(parseFieldTemplates(currentFieldName, parser));
|
builder.putParams(parseFieldTemplates(currentFieldName, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.BODY)) {
|
} else if (HttpRequest.Field.BODY.match(currentFieldName)) {
|
||||||
builder.body(parseFieldTemplate(currentFieldName, parser));
|
builder.body(parseFieldTemplate(currentFieldName, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.URL)) {
|
} else if (HttpRequest.Field.URL.match(currentFieldName)) {
|
||||||
builder.fromUrl(parser.text());
|
builder.fromUrl(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.CONNECTION_TIMEOUT)) {
|
} else if (HttpRequest.Field.CONNECTION_TIMEOUT.match(currentFieldName)) {
|
||||||
builder.connectionTimeout(TimeValue.timeValueMillis(parser.longValue()));
|
builder.connectionTimeout(TimeValue.timeValueMillis(parser.longValue()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.CONNECTION_TIMEOUT_HUMAN)) {
|
} else if (HttpRequest.Field.CONNECTION_TIMEOUT_HUMAN.match(currentFieldName)) {
|
||||||
// Users and 2.x specify the timeout this way
|
// Users and 2.x specify the timeout this way
|
||||||
try {
|
try {
|
||||||
builder.connectionTimeout(WatcherDateTimeUtils.parseTimeValue(parser,
|
builder.connectionTimeout(WatcherDateTimeUtils.parseTimeValue(parser,
|
||||||
|
@ -300,9 +300,9 @@ public class HttpRequestTemplate implements ToXContent {
|
||||||
throw new ElasticsearchParseException("could not parse http request template. invalid time value for [{}] field",
|
throw new ElasticsearchParseException("could not parse http request template. invalid time value for [{}] field",
|
||||||
pe, currentFieldName);
|
pe, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.READ_TIMEOUT)) {
|
} else if (HttpRequest.Field.READ_TIMEOUT.match(currentFieldName)) {
|
||||||
builder.readTimeout(TimeValue.timeValueMillis(parser.longValue()));
|
builder.readTimeout(TimeValue.timeValueMillis(parser.longValue()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.READ_TIMEOUT_HUMAN)) {
|
} else if (HttpRequest.Field.READ_TIMEOUT_HUMAN.match(currentFieldName)) {
|
||||||
// Users and 2.x specify the timeout this way
|
// Users and 2.x specify the timeout this way
|
||||||
try {
|
try {
|
||||||
builder.readTimeout(WatcherDateTimeUtils.parseTimeValue(parser, HttpRequest.Field.READ_TIMEOUT.toString()));
|
builder.readTimeout(WatcherDateTimeUtils.parseTimeValue(parser, HttpRequest.Field.READ_TIMEOUT.toString()));
|
||||||
|
@ -311,25 +311,25 @@ public class HttpRequestTemplate implements ToXContent {
|
||||||
pe, currentFieldName);
|
pe, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.AUTH)) {
|
if (HttpRequest.Field.AUTH.match(currentFieldName)) {
|
||||||
builder.auth(httpAuthRegistry.parse(parser));
|
builder.auth(httpAuthRegistry.parse(parser));
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse http request template. unexpected object field [{}]",
|
throw new ElasticsearchParseException("could not parse http request template. unexpected object field [{}]",
|
||||||
currentFieldName);
|
currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.SCHEME)) {
|
if (HttpRequest.Field.SCHEME.match(currentFieldName)) {
|
||||||
builder.scheme(Scheme.parse(parser.text()));
|
builder.scheme(Scheme.parse(parser.text()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.METHOD)) {
|
} else if (HttpRequest.Field.METHOD.match(currentFieldName)) {
|
||||||
builder.method(HttpMethod.parse(parser.text()));
|
builder.method(HttpMethod.parse(parser.text()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.HOST)) {
|
} else if (HttpRequest.Field.HOST.match(currentFieldName)) {
|
||||||
builder.host = parser.text();
|
builder.host = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse http request template. unexpected string field [{}]",
|
throw new ElasticsearchParseException("could not parse http request template. unexpected string field [{}]",
|
||||||
currentFieldName);
|
currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.PORT)) {
|
if (HttpRequest.Field.PORT.match(currentFieldName)) {
|
||||||
builder.port = parser.intValue();
|
builder.port = parser.intValue();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse http request template. unexpected numeric field [{}]",
|
throw new ElasticsearchParseException("could not parse http request template. unexpected numeric field [{}]",
|
||||||
|
|
|
@ -189,13 +189,13 @@ public class HttpResponse implements ToXContent {
|
||||||
} else if (currentFieldName == null) {
|
} else if (currentFieldName == null) {
|
||||||
throw new ElasticsearchParseException("could not parse http response. expected a field name but found [{}] instead", token);
|
throw new ElasticsearchParseException("could not parse http response. expected a field name but found [{}] instead", token);
|
||||||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.STATUS)) {
|
if (Field.STATUS.match(currentFieldName)) {
|
||||||
status = parser.intValue();
|
status = parser.intValue();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse http response. unknown numeric field [{}]", currentFieldName);
|
throw new ElasticsearchParseException("could not parse http response. unknown numeric field [{}]", currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.BODY)) {
|
if (Field.BODY.match(currentFieldName)) {
|
||||||
body = parser.text();
|
body = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse http response. unknown string field [{}]", currentFieldName);
|
throw new ElasticsearchParseException("could not parse http response. unknown string field [{}]", currentFieldName);
|
||||||
|
|
|
@ -93,7 +93,7 @@ public enum DataAttachment implements ToXContent {
|
||||||
} else if (currentFieldName == null) {
|
} else if (currentFieldName == null) {
|
||||||
throw new ElasticsearchParseException("could not parse data attachment. expected [{}] field but found [{}] instead",
|
throw new ElasticsearchParseException("could not parse data attachment. expected [{}] field but found [{}] instead",
|
||||||
Field.FORMAT.getPreferredName(), token);
|
Field.FORMAT.getPreferredName(), token);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.FORMAT)) {
|
} else if (Field.FORMAT.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
dataAttachment = resolve(parser.text());
|
dataAttachment = resolve(parser.text());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -180,25 +180,25 @@ public class Email implements ToXContent {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if ((token.isValue() || token == XContentParser.Token.START_OBJECT || token == XContentParser.Token.START_ARRAY) &&
|
} else if ((token.isValue() || token == XContentParser.Token.START_OBJECT || token == XContentParser.Token.START_ARRAY) &&
|
||||||
currentFieldName != null) {
|
currentFieldName != null) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ID)) {
|
if (Field.ID.match(currentFieldName)) {
|
||||||
email.id(parser.text());
|
email.id(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.FROM)) {
|
} else if (Field.FROM.match(currentFieldName)) {
|
||||||
email.from(Address.parse(currentFieldName, token, parser));
|
email.from(Address.parse(currentFieldName, token, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REPLY_TO)) {
|
} else if (Field.REPLY_TO.match(currentFieldName)) {
|
||||||
email.replyTo(AddressList.parse(currentFieldName, token, parser));
|
email.replyTo(AddressList.parse(currentFieldName, token, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TO)) {
|
} else if (Field.TO.match(currentFieldName)) {
|
||||||
email.to(AddressList.parse(currentFieldName, token, parser));
|
email.to(AddressList.parse(currentFieldName, token, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.CC)) {
|
} else if (Field.CC.match(currentFieldName)) {
|
||||||
email.cc(AddressList.parse(currentFieldName, token, parser));
|
email.cc(AddressList.parse(currentFieldName, token, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.BCC)) {
|
} else if (Field.BCC.match(currentFieldName)) {
|
||||||
email.bcc(AddressList.parse(currentFieldName, token, parser));
|
email.bcc(AddressList.parse(currentFieldName, token, parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PRIORITY)) {
|
} else if (Field.PRIORITY.match(currentFieldName)) {
|
||||||
email.priority(Email.Priority.resolve(parser.text()));
|
email.priority(Email.Priority.resolve(parser.text()));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.SENT_DATE)) {
|
} else if (Field.SENT_DATE.match(currentFieldName)) {
|
||||||
email.sentDate(new DateTime(parser.text(), DateTimeZone.UTC));
|
email.sentDate(new DateTime(parser.text(), DateTimeZone.UTC));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.SUBJECT)) {
|
} else if (Field.SUBJECT.match(currentFieldName)) {
|
||||||
email.subject(parser.text());
|
email.subject(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.BODY)) {
|
} else if (Field.BODY.match(currentFieldName)) {
|
||||||
String bodyField = currentFieldName;
|
String bodyField = currentFieldName;
|
||||||
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
||||||
email.textBody(parser.text());
|
email.textBody(parser.text());
|
||||||
|
@ -208,9 +208,9 @@ public class Email implements ToXContent {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (currentFieldName == null) {
|
} else if (currentFieldName == null) {
|
||||||
throw new ElasticsearchParseException("could not parse email. empty [{}] field", bodyField);
|
throw new ElasticsearchParseException("could not parse email. empty [{}] field", bodyField);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Email.Field.BODY_TEXT)) {
|
} else if (Email.Field.BODY_TEXT.match(currentFieldName)) {
|
||||||
email.textBody(parser.text());
|
email.textBody(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Email.Field.BODY_HTML)) {
|
} else if (Email.Field.BODY_HTML.match(currentFieldName)) {
|
||||||
email.htmlBody(parser.text());
|
email.htmlBody(parser.text());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse email. unexpected field [{}.{}] field", bodyField,
|
throw new ElasticsearchParseException("could not parse email. unexpected field [{}.{}] field", bodyField,
|
||||||
|
@ -456,9 +456,9 @@ public class Email implements ToXContent {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, ADDRESS_EMAIL_FIELD)) {
|
if (ADDRESS_EMAIL_FIELD.match(currentFieldName)) {
|
||||||
email = parser.text();
|
email = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, ADDRESS_NAME_FIELD)) {
|
} else if (ADDRESS_NAME_FIELD.match(currentFieldName)) {
|
||||||
name = parser.text();
|
name = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse [" + field + "] object as address. unknown address " +
|
throw new ElasticsearchParseException("could not parse [" + field + "] object as address. unknown address " +
|
||||||
|
|
|
@ -341,9 +341,9 @@ public class EmailTemplate implements ToXContent {
|
||||||
private final EmailTemplate.Builder builder = builder();
|
private final EmailTemplate.Builder builder = builder();
|
||||||
|
|
||||||
public boolean handle(String fieldName, XContentParser parser) throws IOException {
|
public boolean handle(String fieldName, XContentParser parser) throws IOException {
|
||||||
if (ParseFieldMatcher.STRICT.match(fieldName, Email.Field.FROM)) {
|
if (Email.Field.FROM.match(fieldName)) {
|
||||||
builder.from(TextTemplate.parse(parser));
|
builder.from(TextTemplate.parse(parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(fieldName, Email.Field.REPLY_TO)) {
|
} else if (Email.Field.REPLY_TO.match(fieldName)) {
|
||||||
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
|
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
|
||||||
List<TextTemplate> templates = new ArrayList<>();
|
List<TextTemplate> templates = new ArrayList<>();
|
||||||
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
||||||
|
@ -353,7 +353,7 @@ public class EmailTemplate implements ToXContent {
|
||||||
} else {
|
} else {
|
||||||
builder.replyTo(TextTemplate.parse(parser));
|
builder.replyTo(TextTemplate.parse(parser));
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(fieldName, Email.Field.TO)) {
|
} else if (Email.Field.TO.match(fieldName)) {
|
||||||
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
|
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
|
||||||
List<TextTemplate> templates = new ArrayList<>();
|
List<TextTemplate> templates = new ArrayList<>();
|
||||||
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
||||||
|
@ -363,7 +363,7 @@ public class EmailTemplate implements ToXContent {
|
||||||
} else {
|
} else {
|
||||||
builder.to(TextTemplate.parse(parser));
|
builder.to(TextTemplate.parse(parser));
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(fieldName, Email.Field.CC)) {
|
} else if (Email.Field.CC.match(fieldName)) {
|
||||||
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
|
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
|
||||||
List<TextTemplate> templates = new ArrayList<>();
|
List<TextTemplate> templates = new ArrayList<>();
|
||||||
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
||||||
|
@ -373,7 +373,7 @@ public class EmailTemplate implements ToXContent {
|
||||||
} else {
|
} else {
|
||||||
builder.cc(TextTemplate.parse(parser));
|
builder.cc(TextTemplate.parse(parser));
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(fieldName, Email.Field.BCC)) {
|
} else if (Email.Field.BCC.match(fieldName)) {
|
||||||
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
|
if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
|
||||||
List<TextTemplate> templates = new ArrayList<>();
|
List<TextTemplate> templates = new ArrayList<>();
|
||||||
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
||||||
|
@ -383,11 +383,11 @@ public class EmailTemplate implements ToXContent {
|
||||||
} else {
|
} else {
|
||||||
builder.bcc(TextTemplate.parse(parser));
|
builder.bcc(TextTemplate.parse(parser));
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(fieldName, Email.Field.PRIORITY)) {
|
} else if (Email.Field.PRIORITY.match(fieldName)) {
|
||||||
builder.priority(TextTemplate.parse(parser));
|
builder.priority(TextTemplate.parse(parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(fieldName, Email.Field.SUBJECT)) {
|
} else if (Email.Field.SUBJECT.match(fieldName)) {
|
||||||
builder.subject(TextTemplate.parse(parser));
|
builder.subject(TextTemplate.parse(parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(fieldName, Email.Field.BODY)) {
|
} else if (Email.Field.BODY.match(fieldName)) {
|
||||||
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
||||||
builder.textBody(TextTemplate.parse(parser));
|
builder.textBody(TextTemplate.parse(parser));
|
||||||
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||||
|
@ -398,9 +398,9 @@ public class EmailTemplate implements ToXContent {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (currentFieldName == null) {
|
} else if (currentFieldName == null) {
|
||||||
throw new ElasticsearchParseException("could not parse email template. empty [{}] field", fieldName);
|
throw new ElasticsearchParseException("could not parse email template. empty [{}] field", fieldName);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Email.Field.BODY_TEXT)) {
|
} else if (Email.Field.BODY_TEXT.match(currentFieldName)) {
|
||||||
builder.textBody(TextTemplate.parse(parser));
|
builder.textBody(TextTemplate.parse(parser));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Email.Field.BODY_HTML)) {
|
} else if (Email.Field.BODY_HTML.match(currentFieldName)) {
|
||||||
builder.htmlBody(TextTemplate.parse(parser));
|
builder.htmlBody(TextTemplate.parse(parser));
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse email template. unknown field [{}.{}] field",
|
throw new ElasticsearchParseException("could not parse email template. unknown field [{}.{}] field",
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class DataAttachmentParser implements EmailAttachmentParser<DataAttachmen
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (Strings.hasLength(currentFieldName) && ParseFieldMatcher.STRICT.match(currentFieldName, Fields.FORMAT)) {
|
} else if (Strings.hasLength(currentFieldName) && Fields.FORMAT.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
dataAttachment = resolve(parser.text());
|
dataAttachment = resolve(parser.text());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -61,11 +61,11 @@ public class HttpEmailAttachementParser implements EmailAttachmentParser<HttpReq
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.CONTENT_TYPE)) {
|
} else if (Fields.CONTENT_TYPE.match(currentFieldName)) {
|
||||||
contentType = parser.text();
|
contentType = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.INLINE)) {
|
} else if (Fields.INLINE.match(currentFieldName)) {
|
||||||
inline = parser.booleanValue();
|
inline = parser.booleanValue();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.REQUEST)) {
|
} else if (Fields.REQUEST.match(currentFieldName)) {
|
||||||
requestTemplate = requestTemplateParser.parse(parser);
|
requestTemplate = requestTemplateParser.parse(parser);
|
||||||
} else {
|
} else {
|
||||||
String msg = "Unknown field name [" + currentFieldName + "] in http request attachment configuration";
|
String msg = "Unknown field name [" + currentFieldName + "] in http request attachment configuration";
|
||||||
|
|
|
@ -249,9 +249,9 @@ public class HipChatMessage implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.FROM)) {
|
} else if (Field.FROM.match(currentFieldName)) {
|
||||||
from = parser.text();
|
from = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ROOM)) {
|
} else if (Field.ROOM.match(currentFieldName)) {
|
||||||
List<TextTemplate> templates = new ArrayList<>();
|
List<TextTemplate> templates = new ArrayList<>();
|
||||||
if (token == XContentParser.Token.START_ARRAY) {
|
if (token == XContentParser.Token.START_ARRAY) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
|
@ -271,7 +271,7 @@ public class HipChatMessage implements ToXContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rooms = templates.toArray(new TextTemplate[templates.size()]);
|
rooms = templates.toArray(new TextTemplate[templates.size()]);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.USER)) {
|
} else if (Field.USER.match(currentFieldName)) {
|
||||||
List<TextTemplate> templates = new ArrayList<>();
|
List<TextTemplate> templates = new ArrayList<>();
|
||||||
if (token == XContentParser.Token.START_ARRAY) {
|
if (token == XContentParser.Token.START_ARRAY) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
|
@ -291,28 +291,28 @@ public class HipChatMessage implements ToXContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
users = templates.toArray(new TextTemplate[templates.size()]);
|
users = templates.toArray(new TextTemplate[templates.size()]);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.COLOR)) {
|
} else if (Field.COLOR.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
color = TextTemplate.parse(parser);
|
color = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException | IllegalArgumentException e) {
|
} catch (ElasticsearchParseException | IllegalArgumentException e) {
|
||||||
throw new ElasticsearchParseException("failed to parse hipchat message. failed to parse [{}] field", e,
|
throw new ElasticsearchParseException("failed to parse hipchat message. failed to parse [{}] field", e,
|
||||||
Field.COLOR.getPreferredName());
|
Field.COLOR.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.NOTIFY)) {
|
} else if (Field.NOTIFY.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
||||||
notify = parser.booleanValue();
|
notify = parser.booleanValue();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("failed to parse hipchat message. failed to parse [{}] field, expected a " +
|
throw new ElasticsearchParseException("failed to parse hipchat message. failed to parse [{}] field, expected a " +
|
||||||
"boolean value but found [{}]", Field.NOTIFY.getPreferredName(), token);
|
"boolean value but found [{}]", Field.NOTIFY.getPreferredName(), token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.BODY)) {
|
} else if (Field.BODY.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
body = TextTemplate.parse(parser);
|
body = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("failed to parse hipchat message. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("failed to parse hipchat message. failed to parse [{}] field", pe,
|
||||||
Field.BODY.getPreferredName());
|
Field.BODY.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.FORMAT)) {
|
} else if (Field.FORMAT.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
messageFormat = HipChatMessage.Format.parse(parser);
|
messageFormat = HipChatMessage.Format.parse(parser);
|
||||||
} catch (IllegalArgumentException ilae) {
|
} catch (IllegalArgumentException ilae) {
|
||||||
|
|
|
@ -161,12 +161,12 @@ public class JiraIssue implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ERRORS)) {
|
} else if (Field.ERRORS.match(currentFieldName)) {
|
||||||
Map<String, Object> fieldErrors = parser.mapOrdered();
|
Map<String, Object> fieldErrors = parser.mapOrdered();
|
||||||
for (Map.Entry<String, Object> entry : fieldErrors.entrySet()) {
|
for (Map.Entry<String, Object> entry : fieldErrors.entrySet()) {
|
||||||
errors.add("Field [" + entry.getKey() + "] has error [" + String.valueOf(entry.getValue()) + "]");
|
errors.add("Field [" + entry.getKey() + "] has error [" + String.valueOf(entry.getValue()) + "]");
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ERROR_MESSAGES)) {
|
} else if (Field.ERROR_MESSAGES.match(currentFieldName)) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
errors.add(parser.text());
|
errors.add(parser.text());
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,58 +290,58 @@ public class IncidentEvent implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.INCIDENT_KEY)) {
|
} else if (Fields.INCIDENT_KEY.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
incidentKey = TextTemplate.parse(parser);
|
incidentKey = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException e) {
|
} catch (ElasticsearchParseException e) {
|
||||||
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
||||||
Fields.INCIDENT_KEY.getPreferredName());
|
Fields.INCIDENT_KEY.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.DESCRIPTION)) {
|
} else if (Fields.DESCRIPTION.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
description = TextTemplate.parse(parser);
|
description = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException e) {
|
} catch (ElasticsearchParseException e) {
|
||||||
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
||||||
Fields.DESCRIPTION.getPreferredName());
|
Fields.DESCRIPTION.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.CLIENT)) {
|
} else if (Fields.CLIENT.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
client = TextTemplate.parse(parser);
|
client = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException e) {
|
} catch (ElasticsearchParseException e) {
|
||||||
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
||||||
Fields.CLIENT.getPreferredName());
|
Fields.CLIENT.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.CLIENT_URL)) {
|
} else if (Fields.CLIENT_URL.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
clientUrl = TextTemplate.parse(parser);
|
clientUrl = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException e) {
|
} catch (ElasticsearchParseException e) {
|
||||||
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
||||||
Fields.CLIENT_URL.getPreferredName());
|
Fields.CLIENT_URL.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.ACCOUNT)) {
|
} else if (Fields.ACCOUNT.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
account = parser.text();
|
account = parser.text();
|
||||||
} catch (ElasticsearchParseException e) {
|
} catch (ElasticsearchParseException e) {
|
||||||
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
||||||
Fields.CLIENT_URL.getPreferredName());
|
Fields.CLIENT_URL.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.PROXY)) {
|
} else if (Fields.PROXY.match(currentFieldName)) {
|
||||||
proxy = HttpProxy.parse(parser);
|
proxy = HttpProxy.parse(parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.EVENT_TYPE)) {
|
} else if (Fields.EVENT_TYPE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
eventType = TextTemplate.parse(parser);
|
eventType = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException e) {
|
} catch (ElasticsearchParseException e) {
|
||||||
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}]",
|
||||||
Fields.EVENT_TYPE.getPreferredName());
|
Fields.EVENT_TYPE.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.ATTACH_PAYLOAD)) {
|
} else if (Fields.ATTACH_PAYLOAD.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
||||||
attachPayload = parser.booleanValue();
|
attachPayload = parser.booleanValue();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}], " +
|
throw new ElasticsearchParseException("could not parse pager duty event template. failed to parse field [{}], " +
|
||||||
"expected a boolean value but found [{}] instead", Fields.ATTACH_PAYLOAD.getPreferredName(), token);
|
"expected a boolean value but found [{}] instead", Fields.ATTACH_PAYLOAD.getPreferredName(), token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.CONTEXT)) {
|
} else if (Fields.CONTEXT.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.START_ARRAY) {
|
if (token == XContentParser.Token.START_ARRAY) {
|
||||||
List<IncidentEventContext.Template> list = new ArrayList<>();
|
List<IncidentEventContext.Template> list = new ArrayList<>();
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class IncidentEventContext implements ToXContent {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (Strings.hasLength(currentFieldName)) {
|
} else if (Strings.hasLength(currentFieldName)) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TYPE)) {
|
if (XField.TYPE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
type = Type.valueOf(parser.text().toUpperCase(Locale.ROOT));
|
type = Type.valueOf(parser.text().toUpperCase(Locale.ROOT));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -211,13 +211,13 @@ public class IncidentEventContext implements ToXContent {
|
||||||
throw new ElasticsearchParseException(msg, e, currentFieldName);
|
throw new ElasticsearchParseException(msg, e, currentFieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.HREF)) {
|
if (XField.HREF.match(currentFieldName)) {
|
||||||
href = parsedTemplate;
|
href = parsedTemplate;
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TEXT)) {
|
} else if (XField.TEXT.match(currentFieldName)) {
|
||||||
text = parsedTemplate;
|
text = parsedTemplate;
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.SRC)) {
|
} else if (XField.SRC.match(currentFieldName)) {
|
||||||
src = parsedTemplate;
|
src = parsedTemplate;
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.ALT)) {
|
} else if (XField.ALT.match(currentFieldName)) {
|
||||||
alt = parsedTemplate;
|
alt = parsedTemplate;
|
||||||
} else {
|
} else {
|
||||||
String msg = "could not parse trigger incident event context. unknown field [{}]";
|
String msg = "could not parse trigger incident event context. unknown field [{}]";
|
||||||
|
|
|
@ -115,11 +115,11 @@ public class SentEvent implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.MESSAGE)) {
|
} else if (XField.MESSAGE.match(currentFieldName)) {
|
||||||
message = parser.text();
|
message = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.CODE)) {
|
} else if (XField.CODE.match(currentFieldName)) {
|
||||||
// we don't use this code.. so just consume the token
|
// we don't use this code.. so just consume the token
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.ERRORS)) {
|
} else if (XField.ERRORS.match(currentFieldName)) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
errors.add(parser.text());
|
errors.add(parser.text());
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,70 +307,70 @@ public class Attachment implements MessageElement {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.FALLBACK)) {
|
} else if (XField.FALLBACK.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
fallback = TextTemplate.parse(parser);
|
fallback = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.FALLBACK);
|
XField.FALLBACK);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.COLOR)) {
|
} else if (XField.COLOR.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
color = TextTemplate.parse(parser);
|
color = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.COLOR);
|
XField.COLOR);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.PRETEXT)) {
|
} else if (XField.PRETEXT.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
pretext = TextTemplate.parse(parser);
|
pretext = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.PRETEXT);
|
XField.PRETEXT);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.AUTHOR_NAME)) {
|
} else if (XField.AUTHOR_NAME.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
authorName = TextTemplate.parse(parser);
|
authorName = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.AUTHOR_NAME);
|
XField.AUTHOR_NAME);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.AUTHOR_LINK)) {
|
} else if (XField.AUTHOR_LINK.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
authorLink = TextTemplate.parse(parser);
|
authorLink = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.AUTHOR_LINK);
|
XField.AUTHOR_LINK);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.AUTHOR_ICON)) {
|
} else if (XField.AUTHOR_ICON.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
authorIcon = TextTemplate.parse(parser);
|
authorIcon = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.AUTHOR_ICON);
|
XField.AUTHOR_ICON);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TITLE)) {
|
} else if (XField.TITLE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
title = TextTemplate.parse(parser);
|
title = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.TITLE);
|
XField.TITLE);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TITLE_LINK)) {
|
} else if (XField.TITLE_LINK.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
titleLink = TextTemplate.parse(parser);
|
titleLink = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.TITLE_LINK);
|
XField.TITLE_LINK);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TEXT)) {
|
} else if (XField.TEXT.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
text = TextTemplate.parse(parser);
|
text = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.TEXT);
|
XField.TEXT);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.FIELDS)) {
|
} else if (XField.FIELDS.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.START_ARRAY) {
|
if (token == XContentParser.Token.START_ARRAY) {
|
||||||
List<Field.Template> list = new ArrayList<>();
|
List<Field.Template> list = new ArrayList<>();
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
|
@ -390,14 +390,14 @@ public class Attachment implements MessageElement {
|
||||||
XField.FIELDS);
|
XField.FIELDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.IMAGE_URL)) {
|
} else if (XField.IMAGE_URL.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
imageUrl = TextTemplate.parse(parser);
|
imageUrl = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment. failed to parse [{}] field", pe,
|
||||||
XField.IMAGE_URL);
|
XField.IMAGE_URL);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.THUMB_URL)) {
|
} else if (XField.THUMB_URL.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
thumbUrl = TextTemplate.parse(parser);
|
thumbUrl = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
|
|
@ -63,14 +63,14 @@ public class DynamicAttachments implements MessageElement {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.LIST_PATH)) {
|
} else if (XField.LIST_PATH.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
listPath = parser.text();
|
listPath = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse dynamic attachments. expected a string value for [{}] field, " +
|
throw new ElasticsearchParseException("could not parse dynamic attachments. expected a string value for [{}] field, " +
|
||||||
"but found [{}]", XField.LIST_PATH.getPreferredName(), token);
|
"but found [{}]", XField.LIST_PATH.getPreferredName(), token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TEMPLATE)) {
|
} else if (XField.TEMPLATE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
template = Attachment.Template.parse(parser);
|
template = Attachment.Template.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
|
|
@ -118,21 +118,21 @@ class Field implements MessageElement {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TITLE)) {
|
} else if (XField.TITLE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
title = TextTemplate.parse(parser);
|
title = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment field. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment field. failed to parse [{}] field", pe,
|
||||||
XField.TITLE);
|
XField.TITLE);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.VALUE)) {
|
} else if (XField.VALUE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
value = TextTemplate.parse(parser);
|
value = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse message attachment field. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse message attachment field. failed to parse [{}] field", pe,
|
||||||
XField.VALUE);
|
XField.VALUE);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.SHORT)) {
|
} else if (XField.SHORT.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
||||||
isShort = parser.booleanValue();
|
isShort = parser.booleanValue();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -254,14 +254,14 @@ public class SlackMessage implements MessageElement {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.FROM)) {
|
} else if (XField.FROM.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
builder.setFrom(TextTemplate.parse(parser));
|
builder.setFrom(TextTemplate.parse(parser));
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse slack message. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse slack message. failed to parse [{}] field", pe,
|
||||||
XField.FROM.getPreferredName());
|
XField.FROM.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TO)) {
|
} else if (XField.TO.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.START_ARRAY) {
|
if (token == XContentParser.Token.START_ARRAY) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
try {
|
try {
|
||||||
|
@ -279,21 +279,21 @@ public class SlackMessage implements MessageElement {
|
||||||
XField.TO.getPreferredName());
|
XField.TO.getPreferredName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.TEXT)) {
|
} else if (XField.TEXT.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
builder.setText(TextTemplate.parse(parser));
|
builder.setText(TextTemplate.parse(parser));
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse slack message. failed to parse [{}] field", pe,
|
throw new ElasticsearchParseException("could not parse slack message. failed to parse [{}] field", pe,
|
||||||
XField.TEXT.getPreferredName());
|
XField.TEXT.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.ICON)) {
|
} else if (XField.ICON.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
builder.setIcon(TextTemplate.parse(parser));
|
builder.setIcon(TextTemplate.parse(parser));
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
throw new ElasticsearchParseException("could not parse slack message. failed to parse [{}] field.", pe,
|
throw new ElasticsearchParseException("could not parse slack message. failed to parse [{}] field.", pe,
|
||||||
XField.ICON.getPreferredName());
|
XField.ICON.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.ATTACHMENTS)) {
|
} else if (XField.ATTACHMENTS.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.START_ARRAY) {
|
if (token == XContentParser.Token.START_ARRAY) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
try {
|
try {
|
||||||
|
@ -311,7 +311,7 @@ public class SlackMessage implements MessageElement {
|
||||||
XField.ATTACHMENTS.getPreferredName());
|
XField.ATTACHMENTS.getPreferredName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, XField.DYNAMIC_ATTACHMENTS)) {
|
} else if (XField.DYNAMIC_ATTACHMENTS.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
builder.setDynamicAttachments(DynamicAttachments.parse(parser));
|
builder.setDynamicAttachments(DynamicAttachments.parse(parser));
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ChangePasswordRequestBuilder
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.PASSWORD)) {
|
} else if (User.Fields.PASSWORD.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
String password = parser.text();
|
String password = parser.text();
|
||||||
char[] passwordChars = password.toCharArray();
|
char[] passwordChars = password.toCharArray();
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class PutUserRequestBuilder extends ActionRequestBuilder<PutUserRequest,
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.PASSWORD)) {
|
} else if (User.Fields.PASSWORD.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
String password = parser.text();
|
String password = parser.text();
|
||||||
char[] passwordChars = password.toCharArray();
|
char[] passwordChars = password.toCharArray();
|
||||||
|
@ -111,7 +111,7 @@ public class PutUserRequestBuilder extends ActionRequestBuilder<PutUserRequest,
|
||||||
throw new ElasticsearchParseException(
|
throw new ElasticsearchParseException(
|
||||||
"expected field [{}] to be of type string, but found [{}] instead", currentFieldName, token);
|
"expected field [{}] to be of type string, but found [{}] instead", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.PASSWORD_HASH)) {
|
} else if (User.Fields.PASSWORD_HASH.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
char[] passwordChars = parser.text().toCharArray();
|
char[] passwordChars = parser.text().toCharArray();
|
||||||
passwordHash(passwordChars);
|
passwordHash(passwordChars);
|
||||||
|
@ -119,41 +119,41 @@ public class PutUserRequestBuilder extends ActionRequestBuilder<PutUserRequest,
|
||||||
throw new ElasticsearchParseException(
|
throw new ElasticsearchParseException(
|
||||||
"expected field [{}] to be of type string, but found [{}] instead", currentFieldName, token);
|
"expected field [{}] to be of type string, but found [{}] instead", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.ROLES)) {
|
} else if (User.Fields.ROLES.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
roles(Strings.commaDelimitedListToStringArray(parser.text()));
|
roles(Strings.commaDelimitedListToStringArray(parser.text()));
|
||||||
} else {
|
} else {
|
||||||
roles(XContentUtils.readStringArray(parser, false));
|
roles(XContentUtils.readStringArray(parser, false));
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.FULL_NAME)) {
|
} else if (User.Fields.FULL_NAME.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
fullName(parser.text());
|
fullName(parser.text());
|
||||||
} else if (token != XContentParser.Token.VALUE_NULL) {
|
} else if (token != XContentParser.Token.VALUE_NULL) {
|
||||||
throw new ElasticsearchParseException(
|
throw new ElasticsearchParseException(
|
||||||
"expected field [{}] to be of type string, but found [{}] instead", currentFieldName, token);
|
"expected field [{}] to be of type string, but found [{}] instead", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.EMAIL)) {
|
} else if (User.Fields.EMAIL.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
email(parser.text());
|
email(parser.text());
|
||||||
} else if (token != XContentParser.Token.VALUE_NULL) {
|
} else if (token != XContentParser.Token.VALUE_NULL) {
|
||||||
throw new ElasticsearchParseException(
|
throw new ElasticsearchParseException(
|
||||||
"expected field [{}] to be of type string, but found [{}] instead", currentFieldName, token);
|
"expected field [{}] to be of type string, but found [{}] instead", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.METADATA)) {
|
} else if (User.Fields.METADATA.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
metadata(parser.map());
|
metadata(parser.map());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException(
|
throw new ElasticsearchParseException(
|
||||||
"expected field [{}] to be of type object, but found [{}] instead", currentFieldName, token);
|
"expected field [{}] to be of type object, but found [{}] instead", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.ENABLED)) {
|
} else if (User.Fields.ENABLED.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
||||||
enabled(parser.booleanValue());
|
enabled(parser.booleanValue());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException(
|
throw new ElasticsearchParseException(
|
||||||
"expected field [{}] to be of type boolean, but found [{}] instead", currentFieldName, token);
|
"expected field [{}] to be of type boolean, but found [{}] instead", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, User.Fields.USERNAME)) {
|
} else if (User.Fields.USERNAME.match(currentFieldName)) {
|
||||||
if (token == Token.VALUE_STRING) {
|
if (token == Token.VALUE_STRING) {
|
||||||
if (username.equals(parser.text()) == false) {
|
if (username.equals(parser.text()) == false) {
|
||||||
throw new IllegalArgumentException("[username] in source does not match the username provided [" +
|
throw new IllegalArgumentException("[username] in source does not match the username provided [" +
|
||||||
|
|
|
@ -190,13 +190,13 @@ public class RoleDescriptor implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.INDICES)) {
|
} else if (Fields.INDICES.match(currentFieldName)) {
|
||||||
indicesPrivileges = parseIndices(name, parser, allow2xFormat);
|
indicesPrivileges = parseIndices(name, parser, allow2xFormat);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.RUN_AS)) {
|
} else if (Fields.RUN_AS.match(currentFieldName)) {
|
||||||
runAsUsers = readStringArray(name, parser, true);
|
runAsUsers = readStringArray(name, parser, true);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.CLUSTER)) {
|
} else if (Fields.CLUSTER.match(currentFieldName)) {
|
||||||
clusterPrivileges = readStringArray(name, parser, true);
|
clusterPrivileges = readStringArray(name, parser, true);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.METADATA)) {
|
} else if (Fields.METADATA.match(currentFieldName)) {
|
||||||
if (token != XContentParser.Token.START_OBJECT) {
|
if (token != XContentParser.Token.START_OBJECT) {
|
||||||
throw new ElasticsearchParseException(
|
throw new ElasticsearchParseException(
|
||||||
"expected field [{}] to be of type object, but found [{}] instead", currentFieldName, token);
|
"expected field [{}] to be of type object, but found [{}] instead", currentFieldName, token);
|
||||||
|
@ -247,7 +247,7 @@ public class RoleDescriptor implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.NAMES)) {
|
} else if (Fields.NAMES.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
names = new String[] { parser.text() };
|
names = new String[] { parser.text() };
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
|
@ -260,7 +260,7 @@ public class RoleDescriptor implements ToXContent {
|
||||||
throw new ElasticsearchParseException("failed to parse indices privileges for role [{}]. expected field [{}] " +
|
throw new ElasticsearchParseException("failed to parse indices privileges for role [{}]. expected field [{}] " +
|
||||||
"value to be a string or an array of strings, but found [{}] instead", roleName, currentFieldName, token);
|
"value to be a string or an array of strings, but found [{}] instead", roleName, currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.QUERY)) {
|
} else if (Fields.QUERY.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
XContentBuilder builder = JsonXContent.contentBuilder();
|
||||||
XContentHelper.copyCurrentStructure(builder.generator(), parser);
|
XContentHelper.copyCurrentStructure(builder.generator(), parser);
|
||||||
|
@ -275,20 +275,20 @@ public class RoleDescriptor implements ToXContent {
|
||||||
"value to be null, a string, an array, or an object, but found [{}] instead", roleName, currentFieldName,
|
"value to be null, a string, an array, or an object, but found [{}] instead", roleName, currentFieldName,
|
||||||
token);
|
token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.FIELD_PERMISSIONS)) {
|
} else if (Fields.FIELD_PERMISSIONS.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
token = parser.nextToken();
|
token = parser.nextToken();
|
||||||
do {
|
do {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.GRANT_FIELDS)) {
|
if (Fields.GRANT_FIELDS.match(currentFieldName)) {
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
grantedFields = readStringArray(roleName, parser, true);
|
grantedFields = readStringArray(roleName, parser, true);
|
||||||
if (grantedFields == null) {
|
if (grantedFields == null) {
|
||||||
throw new ElasticsearchParseException("failed to parse indices privileges for role [{}]. {} must not " +
|
throw new ElasticsearchParseException("failed to parse indices privileges for role [{}]. {} must not " +
|
||||||
"be null.", roleName, Fields.GRANT_FIELDS);
|
"be null.", roleName, Fields.GRANT_FIELDS);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.EXCEPT_FIELDS)) {
|
} else if (Fields.EXCEPT_FIELDS.match(currentFieldName)) {
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
deniedFields = readStringArray(roleName, parser, true);
|
deniedFields = readStringArray(roleName, parser, true);
|
||||||
if (deniedFields == null) {
|
if (deniedFields == null) {
|
||||||
|
@ -317,9 +317,9 @@ public class RoleDescriptor implements ToXContent {
|
||||||
" in \"{}\".", roleName, XContentParser.Token.START_OBJECT,
|
" in \"{}\".", roleName, XContentParser.Token.START_OBJECT,
|
||||||
XContentParser.Token.START_ARRAY, token, Fields.FIELD_PERMISSIONS);
|
XContentParser.Token.START_ARRAY, token, Fields.FIELD_PERMISSIONS);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.PRIVILEGES)) {
|
} else if (Fields.PRIVILEGES.match(currentFieldName)) {
|
||||||
privileges = readStringArray(roleName, parser, true);
|
privileges = readStringArray(roleName, parser, true);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Fields.FIELD_PERMISSIONS_2X)) {
|
} else if (Fields.FIELD_PERMISSIONS_2X.match(currentFieldName)) {
|
||||||
if (allow2xFormat) {
|
if (allow2xFormat) {
|
||||||
grantedFields = readStringArray(roleName, parser, true);
|
grantedFields = readStringArray(roleName, parser, true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class WatcherMetaData extends AbstractNamedDiffable<MetaData.Custom> impl
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
break;
|
break;
|
||||||
case VALUE_BOOLEAN:
|
case VALUE_BOOLEAN:
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.MANUALLY_STOPPED)) {
|
if (Field.MANUALLY_STOPPED.match(currentFieldName)) {
|
||||||
manuallyStopped = parser.booleanValue();
|
manuallyStopped = parser.booleanValue();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.watcher.actions;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
@ -167,13 +166,13 @@ public class ActionStatus implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACK_STATUS)) {
|
} else if (Field.ACK_STATUS.match(currentFieldName)) {
|
||||||
ackStatus = AckStatus.parse(watchId, actionId, parser);
|
ackStatus = AckStatus.parse(watchId, actionId, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.LAST_EXECUTION)) {
|
} else if (Field.LAST_EXECUTION.match(currentFieldName)) {
|
||||||
lastExecution = Execution.parse(watchId, actionId, parser);
|
lastExecution = Execution.parse(watchId, actionId, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.LAST_SUCCESSFUL_EXECUTION)) {
|
} else if (Field.LAST_SUCCESSFUL_EXECUTION.match(currentFieldName)) {
|
||||||
lastSuccessfulExecution = Execution.parse(watchId, actionId, parser);
|
lastSuccessfulExecution = Execution.parse(watchId, actionId, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.LAST_THROTTLE)) {
|
} else if (Field.LAST_THROTTLE.match(currentFieldName)) {
|
||||||
lastThrottle = Throttle.parse(watchId, actionId, parser);
|
lastThrottle = Throttle.parse(watchId, actionId, parser);
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse action status for [{}/{}]. unexpected field [{}]", watchId,
|
throw new ElasticsearchParseException("could not parse action status for [{}/{}]. unexpected field [{}]", watchId,
|
||||||
|
@ -259,9 +258,9 @@ public class ActionStatus implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMESTAMP)) {
|
} else if (Field.TIMESTAMP.match(currentFieldName)) {
|
||||||
timestamp = dateTimeFormatter.parser().parseDateTime(parser.text());
|
timestamp = dateTimeFormatter.parser().parseDateTime(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACK_STATUS_STATE)) {
|
} else if (Field.ACK_STATUS_STATE.match(currentFieldName)) {
|
||||||
state = State.valueOf(parser.text().toUpperCase(Locale.ROOT));
|
state = State.valueOf(parser.text().toUpperCase(Locale.ROOT));
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse action status for [{}/{}]. unexpected field [{}.{}]", watchId,
|
throw new ElasticsearchParseException("could not parse action status for [{}/{}]. unexpected field [{}.{}]", watchId,
|
||||||
|
@ -365,11 +364,11 @@ public class ActionStatus implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMESTAMP)) {
|
} else if (Field.TIMESTAMP.match(currentFieldName)) {
|
||||||
timestamp = dateTimeFormatter.parser().parseDateTime(parser.text());
|
timestamp = dateTimeFormatter.parser().parseDateTime(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.EXECUTION_SUCCESSFUL)) {
|
} else if (Field.EXECUTION_SUCCESSFUL.match(currentFieldName)) {
|
||||||
successful = parser.booleanValue();
|
successful = parser.booleanValue();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REASON)) {
|
} else if (Field.REASON.match(currentFieldName)) {
|
||||||
reason = parser.text();
|
reason = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse action status for [{}/{}]. unexpected field [{}.{}]", watchId,
|
throw new ElasticsearchParseException("could not parse action status for [{}/{}]. unexpected field [{}.{}]", watchId,
|
||||||
|
@ -465,9 +464,9 @@ public class ActionStatus implements ToXContent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMESTAMP)) {
|
} else if (Field.TIMESTAMP.match(currentFieldName)) {
|
||||||
timestamp = dateTimeFormatter.parser().parseDateTime(parser.text());
|
timestamp = dateTimeFormatter.parser().parseDateTime(parser.text());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REASON)) {
|
} else if (Field.REASON.match(currentFieldName)) {
|
||||||
reason = parser.text();
|
reason = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse action status for [{}/{}]. unexpected field [{}.{}]", watchId,
|
throw new ElasticsearchParseException("could not parse action status for [{}/{}]. unexpected field [{}.{}]", watchId,
|
||||||
|
|
|
@ -209,13 +209,13 @@ public class ActionWrapper implements ToXContent {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else {
|
} else {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Watch.Field.CONDITION)) {
|
if (Watch.Field.CONDITION.match(currentFieldName)) {
|
||||||
condition = actionRegistry.getConditionRegistry().parseExecutable(watchId, parser);
|
condition = actionRegistry.getConditionRegistry().parseExecutable(watchId, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Transform.Field.TRANSFORM)) {
|
} else if (Transform.Field.TRANSFORM.match(currentFieldName)) {
|
||||||
transform = actionRegistry.getTransformRegistry().parse(watchId, parser);
|
transform = actionRegistry.getTransformRegistry().parse(watchId, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Throttler.Field.THROTTLE_PERIOD)) {
|
} else if (Throttler.Field.THROTTLE_PERIOD.match(currentFieldName)) {
|
||||||
throttlePeriod = timeValueMillis(parser.longValue());
|
throttlePeriod = timeValueMillis(parser.longValue());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Throttler.Field.THROTTLE_PERIOD_HUMAN)) {
|
} else if (Throttler.Field.THROTTLE_PERIOD_HUMAN.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
throttlePeriod = WatcherDateTimeUtils.parseTimeValue(parser, Throttler.Field.THROTTLE_PERIOD_HUMAN.toString());
|
throttlePeriod = WatcherDateTimeUtils.parseTimeValue(parser, Throttler.Field.THROTTLE_PERIOD_HUMAN.toString());
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
|
|
@ -137,24 +137,24 @@ public class EmailAction implements Action {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ATTACH_DATA)) {
|
} else if (Field.ATTACH_DATA.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
dataAttachment = DataAttachment.parse(parser);
|
dataAttachment = DataAttachment.parse(parser);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] action [{}/{}]. failed to parse data attachment field " +
|
throw new ElasticsearchParseException("could not parse [{}] action [{}/{}]. failed to parse data attachment field " +
|
||||||
"[{}]", ioe, TYPE, watchId, actionId, currentFieldName);
|
"[{}]", ioe, TYPE, watchId, actionId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ATTACHMENTS)) {
|
} else if (Field.ATTACHMENTS.match(currentFieldName)) {
|
||||||
attachments = emailAttachmentsParser.parse(parser);
|
attachments = emailAttachmentsParser.parse(parser);
|
||||||
} else if (!emailParser.handle(currentFieldName, parser)) {
|
} else if (!emailParser.handle(currentFieldName, parser)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACCOUNT)) {
|
if (Field.ACCOUNT.match(currentFieldName)) {
|
||||||
account = parser.text();
|
account = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.USER)) {
|
} else if (Field.USER.match(currentFieldName)) {
|
||||||
user = parser.text();
|
user = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PASSWORD)) {
|
} else if (Field.PASSWORD.match(currentFieldName)) {
|
||||||
password = WatcherXContentParser.secretOrNull(parser);
|
password = WatcherXContentParser.secretOrNull(parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PROFILE)) {
|
} else if (Field.PROFILE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
profile = Profile.resolve(parser.text());
|
profile = Profile.resolve(parser.text());
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
|
|
|
@ -80,16 +80,16 @@ public class HipChatAction implements Action {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACCOUNT)) {
|
} else if (Field.ACCOUNT.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
account = parser.text();
|
account = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("failed to parse [{}] action [{}/{}]. expected [{}] to be of type string, but " +
|
throw new ElasticsearchParseException("failed to parse [{}] action [{}/{}]. expected [{}] to be of type string, but " +
|
||||||
"found [{}] instead", TYPE, watchId, actionId, Field.ACCOUNT.getPreferredName(), token);
|
"found [{}] instead", TYPE, watchId, actionId, Field.ACCOUNT.getPreferredName(), token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PROXY)) {
|
} else if (Field.PROXY.match(currentFieldName)) {
|
||||||
proxy = HttpProxy.parse(parser);
|
proxy = HttpProxy.parse(parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.MESSAGE)) {
|
} else if (Field.MESSAGE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
message = HipChatMessage.Template.parse(parser);
|
message = HipChatMessage.Template.parse(parser);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class IndexAction implements Action {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.INDEX)) {
|
} else if (Field.INDEX.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
index = parser.text();
|
index = parser.text();
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
@ -117,21 +117,21 @@ public class IndexAction implements Action {
|
||||||
"field [{}]", pe, TYPE, watchId, actionId, currentFieldName);
|
"field [{}]", pe, TYPE, watchId, actionId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMEOUT)) {
|
if (Field.TIMEOUT.match(currentFieldName)) {
|
||||||
timeout = timeValueMillis(parser.longValue());
|
timeout = timeValueMillis(parser.longValue());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] action [{}/{}]. unexpected number field [{}]", TYPE,
|
throw new ElasticsearchParseException("could not parse [{}] action [{}/{}]. unexpected number field [{}]", TYPE,
|
||||||
watchId, actionId, currentFieldName);
|
watchId, actionId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.DOC_TYPE)) {
|
if (Field.DOC_TYPE.match(currentFieldName)) {
|
||||||
docType = parser.text();
|
docType = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.EXECUTION_TIME_FIELD)) {
|
} else if (Field.EXECUTION_TIME_FIELD.match(currentFieldName)) {
|
||||||
executionTimeField = parser.text();
|
executionTimeField = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMEOUT_HUMAN)) {
|
} else if (Field.TIMEOUT_HUMAN.match(currentFieldName)) {
|
||||||
// Parser for human specified timeouts and 2.x compatibility
|
// Parser for human specified timeouts and 2.x compatibility
|
||||||
timeout = WatcherDateTimeUtils.parseTimeValue(parser, Field.TIMEOUT_HUMAN.toString());
|
timeout = WatcherDateTimeUtils.parseTimeValue(parser, Field.TIMEOUT_HUMAN.toString());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.DYNAMIC_NAME_TIMEZONE)) {
|
} else if (Field.DYNAMIC_NAME_TIMEZONE.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
dynamicNameTimeZone = DateTimeZone.forID(parser.text());
|
dynamicNameTimeZone = DateTimeZone.forID(parser.text());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -83,16 +83,16 @@ public class JiraAction implements Action {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACCOUNT)) {
|
} else if (Field.ACCOUNT.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
account = parser.text();
|
account = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("failed to parse [{}] action [{}/{}]. expected [{}] to be of type string, but " +
|
throw new ElasticsearchParseException("failed to parse [{}] action [{}/{}]. expected [{}] to be of type string, but " +
|
||||||
"found [{}] instead", TYPE, watchId, actionId, Field.ACCOUNT.getPreferredName(), token);
|
"found [{}] instead", TYPE, watchId, actionId, Field.ACCOUNT.getPreferredName(), token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PROXY)) {
|
} else if (Field.PROXY.match(currentFieldName)) {
|
||||||
proxy = HttpProxy.parse(parser);
|
proxy = HttpProxy.parse(parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.FIELDS)) {
|
} else if (Field.FIELDS.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
fields = parser.map();
|
fields = parser.map();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class LoggingAction implements Action {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TEXT)) {
|
} else if (Field.TEXT.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
text = TextTemplate.parse(parser);
|
text = TextTemplate.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
@ -85,9 +85,9 @@ public class LoggingAction implements Action {
|
||||||
watchId, actionId, Field.TEXT.getPreferredName());
|
watchId, actionId, Field.TEXT.getPreferredName());
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.CATEGORY)) {
|
if (Field.CATEGORY.match(currentFieldName)) {
|
||||||
category = parser.text();
|
category = parser.text();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.LEVEL)) {
|
} else if (Field.LEVEL.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
level = LoggingLevel.valueOf(parser.text().toUpperCase(Locale.ROOT));
|
level = LoggingLevel.valueOf(parser.text().toUpperCase(Locale.ROOT));
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
|
|
|
@ -79,16 +79,16 @@ public class SlackAction implements Action {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACCOUNT)) {
|
} else if (Field.ACCOUNT.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
account = parser.text();
|
account = parser.text();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("failed to parse [{}] action [{}/{}]. expected [{}] to be of type string, but " +
|
throw new ElasticsearchParseException("failed to parse [{}] action [{}/{}]. expected [{}] to be of type string, but " +
|
||||||
"found [{}] instead", TYPE, watchId, actionId, Field.ACCOUNT.getPreferredName(), token);
|
"found [{}] instead", TYPE, watchId, actionId, Field.ACCOUNT.getPreferredName(), token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PROXY)) {
|
} else if (Field.PROXY.match(currentFieldName)) {
|
||||||
proxy = HttpProxy.parse(parser);
|
proxy = HttpProxy.parse(parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.MESSAGE)) {
|
} else if (Field.MESSAGE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
message = SlackMessage.Template.parse(parser);
|
message = SlackMessage.Template.parse(parser);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class TriggeredWatch implements ToXContent {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TRIGGER_EVENT)) {
|
if (Field.TRIGGER_EVENT.match(currentFieldName)) {
|
||||||
triggerEvent = triggerService.parseTriggerEvent(wid.watchId(), id, parser);
|
triggerEvent = triggerService.parseTriggerEvent(wid.watchId(), id, parser);
|
||||||
} else {
|
} else {
|
||||||
parser.skipChildren();
|
parser.skipChildren();
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class HttpInput implements Input {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REQUEST)) {
|
} else if (Field.REQUEST.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
request = requestParser.parse(parser);
|
request = requestParser.parse(parser);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
@ -104,7 +104,7 @@ public class HttpInput implements Input {
|
||||||
watchId, currentFieldName);
|
watchId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.RESPONSE_CONTENT_TYPE)) {
|
if (Field.RESPONSE_CONTENT_TYPE.match(currentFieldName)) {
|
||||||
expectedResponseBodyType = HttpContentType.resolve(parser.text());
|
expectedResponseBodyType = HttpContentType.resolve(parser.text());
|
||||||
if (expectedResponseBodyType == null) {
|
if (expectedResponseBodyType == null) {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] input for watch [{}]. unknown content type [{}]",
|
throw new ElasticsearchParseException("could not parse [{}] input for watch [{}]. unknown content type [{}]",
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class SearchInput implements Input {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REQUEST)) {
|
} else if (Field.REQUEST.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
request = WatcherSearchTemplateRequest.fromXContent(inputLogger, parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE,
|
request = WatcherSearchTemplateRequest.fromXContent(inputLogger, parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE,
|
||||||
parseFieldMatcher, searchRequestParsers);
|
parseFieldMatcher, searchRequestParsers);
|
||||||
|
@ -130,7 +130,7 @@ public class SearchInput implements Input {
|
||||||
watchId, currentFieldName);
|
watchId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.EXTRACT)) {
|
if (Field.EXTRACT.match(currentFieldName)) {
|
||||||
extract = new HashSet<>();
|
extract = new HashSet<>();
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
|
@ -144,12 +144,12 @@ public class SearchInput implements Input {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] input for watch [{}]. unexpected array field [{}]", TYPE,
|
throw new ElasticsearchParseException("could not parse [{}] input for watch [{}]. unexpected array field [{}]", TYPE,
|
||||||
watchId, currentFieldName);
|
watchId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMEOUT)) {
|
} else if (Field.TIMEOUT.match(currentFieldName)) {
|
||||||
timeout = timeValueMillis(parser.longValue());
|
timeout = timeValueMillis(parser.longValue());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMEOUT_HUMAN)) {
|
} else if (Field.TIMEOUT_HUMAN.match(currentFieldName)) {
|
||||||
// Parser for human specified timeouts and 2.x compatibility
|
// Parser for human specified timeouts and 2.x compatibility
|
||||||
timeout = WatcherDateTimeUtils.parseTimeValue(parser, Field.TIMEOUT_HUMAN.toString());
|
timeout = WatcherDateTimeUtils.parseTimeValue(parser, Field.TIMEOUT_HUMAN.toString());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.DYNAMIC_NAME_TIMEZONE)) {
|
} else if (Field.DYNAMIC_NAME_TIMEZONE.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
dynamicNameTimeZone = DateTimeZone.forID(parser.text());
|
dynamicNameTimeZone = DateTimeZone.forID(parser.text());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -93,24 +93,24 @@ public class RestExecuteWatchAction extends WatcherRestHandler {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, IGNORE_CONDITION)) {
|
if (IGNORE_CONDITION.match(currentFieldName)) {
|
||||||
builder.setIgnoreCondition(parser.booleanValue());
|
builder.setIgnoreCondition(parser.booleanValue());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, RECORD_EXECUTION)) {
|
} else if (RECORD_EXECUTION.match(currentFieldName)) {
|
||||||
builder.setRecordExecution(parser.booleanValue());
|
builder.setRecordExecution(parser.booleanValue());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse watch execution request. unexpected boolean field [{}]",
|
throw new ElasticsearchParseException("could not parse watch execution request. unexpected boolean field [{}]",
|
||||||
currentFieldName);
|
currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ALTERNATIVE_INPUT)) {
|
if (Field.ALTERNATIVE_INPUT.match(currentFieldName)) {
|
||||||
builder.setAlternativeInput(parser.map());
|
builder.setAlternativeInput(parser.map());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TRIGGER_DATA)) {
|
} else if (Field.TRIGGER_DATA.match(currentFieldName)) {
|
||||||
builder.setTriggerData(parser.map());
|
builder.setTriggerData(parser.map());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.WATCH)) {
|
} else if (Field.WATCH.match(currentFieldName)) {
|
||||||
XContentBuilder watcherSource = XContentBuilder.builder(parser.contentType().xContent());
|
XContentBuilder watcherSource = XContentBuilder.builder(parser.contentType().xContent());
|
||||||
XContentHelper.copyCurrentStructure(watcherSource.generator(), parser);
|
XContentHelper.copyCurrentStructure(watcherSource.generator(), parser);
|
||||||
builder.setWatchSource(watcherSource.bytes());
|
builder.setWatchSource(watcherSource.bytes());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACTION_MODES)) {
|
} else if (Field.ACTION_MODES.match(currentFieldName)) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class WatcherSearchTemplateRequest implements ToXContent {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, INDICES_FIELD)) {
|
if (INDICES_FIELD.match(currentFieldName)) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
indices.add(parser.textOrNull());
|
indices.add(parser.textOrNull());
|
||||||
|
@ -190,7 +190,7 @@ public class WatcherSearchTemplateRequest implements ToXContent {
|
||||||
currentFieldName + "] field, but instead found [" + token + "]");
|
currentFieldName + "] field, but instead found [" + token + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, TYPES_FIELD)) {
|
} else if (TYPES_FIELD.match(currentFieldName)) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
types.add(parser.textOrNull());
|
types.add(parser.textOrNull());
|
||||||
|
@ -204,12 +204,12 @@ public class WatcherSearchTemplateRequest implements ToXContent {
|
||||||
currentFieldName + "]");
|
currentFieldName + "]");
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, BODY_FIELD)) {
|
if (BODY_FIELD.match(currentFieldName)) {
|
||||||
try (XContentBuilder builder = XContentBuilder.builder(parser.contentType().xContent())) {
|
try (XContentBuilder builder = XContentBuilder.builder(parser.contentType().xContent())) {
|
||||||
builder.copyCurrentStructure(parser);
|
builder.copyCurrentStructure(parser);
|
||||||
searchSource = builder.bytes();
|
searchSource = builder.bytes();
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, INDICES_OPTIONS_FIELD)) {
|
} else if (INDICES_OPTIONS_FIELD.match(currentFieldName)) {
|
||||||
boolean expandOpen = DEFAULT_INDICES_OPTIONS.expandWildcardsOpen();
|
boolean expandOpen = DEFAULT_INDICES_OPTIONS.expandWildcardsOpen();
|
||||||
boolean expandClosed = DEFAULT_INDICES_OPTIONS.expandWildcardsClosed();
|
boolean expandClosed = DEFAULT_INDICES_OPTIONS.expandWildcardsClosed();
|
||||||
boolean allowNoIndices = DEFAULT_INDICES_OPTIONS.allowNoIndices();
|
boolean allowNoIndices = DEFAULT_INDICES_OPTIONS.allowNoIndices();
|
||||||
|
@ -218,7 +218,7 @@ public class WatcherSearchTemplateRequest implements ToXContent {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token.isValue()) {
|
} else if (token.isValue()) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, EXPAND_WILDCARDS_FIELD)) {
|
if (EXPAND_WILDCARDS_FIELD.match(currentFieldName)) {
|
||||||
switch (parser.text()) {
|
switch (parser.text()) {
|
||||||
case "all":
|
case "all":
|
||||||
expandOpen = true;
|
expandOpen = true;
|
||||||
|
@ -240,9 +240,9 @@ public class WatcherSearchTemplateRequest implements ToXContent {
|
||||||
throw new ElasticsearchParseException("could not read search request. unknown value [" +
|
throw new ElasticsearchParseException("could not read search request. unknown value [" +
|
||||||
parser.text() + "] for [" + currentFieldName + "] field ");
|
parser.text() + "] for [" + currentFieldName + "] field ");
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, IGNORE_UNAVAILABLE_FIELD)) {
|
} else if (IGNORE_UNAVAILABLE_FIELD.match(currentFieldName)) {
|
||||||
ignoreUnavailable = parser.booleanValue();
|
ignoreUnavailable = parser.booleanValue();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, ALLOW_NO_INDICES_FIELD)) {
|
} else if (ALLOW_NO_INDICES_FIELD.match(currentFieldName)) {
|
||||||
allowNoIndices = parser.booleanValue();
|
allowNoIndices = parser.booleanValue();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not read search request. unexpected index option [" +
|
throw new ElasticsearchParseException("could not read search request. unexpected index option [" +
|
||||||
|
@ -255,20 +255,20 @@ public class WatcherSearchTemplateRequest implements ToXContent {
|
||||||
}
|
}
|
||||||
indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, allowNoIndices, expandOpen, expandClosed,
|
indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, allowNoIndices, expandOpen, expandClosed,
|
||||||
DEFAULT_INDICES_OPTIONS);
|
DEFAULT_INDICES_OPTIONS);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, TEMPLATE_FIELD)) {
|
} else if (TEMPLATE_FIELD.match(currentFieldName)) {
|
||||||
template = Script.parse(parser, ParseFieldMatcher.STRICT, Script.DEFAULT_TEMPLATE_LANG);
|
template = Script.parse(parser, ParseFieldMatcher.STRICT, Script.DEFAULT_TEMPLATE_LANG);
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not read search request. unexpected object field [" +
|
throw new ElasticsearchParseException("could not read search request. unexpected object field [" +
|
||||||
currentFieldName + "]");
|
currentFieldName + "]");
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, INDICES_FIELD)) {
|
if (INDICES_FIELD.match(currentFieldName)) {
|
||||||
String indicesStr = parser.text();
|
String indicesStr = parser.text();
|
||||||
indices.addAll(Arrays.asList(Strings.delimitedListToStringArray(indicesStr, ",", " \t")));
|
indices.addAll(Arrays.asList(Strings.delimitedListToStringArray(indicesStr, ",", " \t")));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, TYPES_FIELD)) {
|
} else if (TYPES_FIELD.match(currentFieldName)) {
|
||||||
String typesStr = parser.text();
|
String typesStr = parser.text();
|
||||||
types.addAll(Arrays.asList(Strings.delimitedListToStringArray(typesStr, ",", " \t")));
|
types.addAll(Arrays.asList(Strings.delimitedListToStringArray(typesStr, ",", " \t")));
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, SEARCH_TYPE_FIELD)) {
|
} else if (SEARCH_TYPE_FIELD.match(currentFieldName)) {
|
||||||
searchType = SearchType.fromString(parser.text().toLowerCase(Locale.ROOT), ParseFieldMatcher.EMPTY);
|
searchType = SearchType.fromString(parser.text().toLowerCase(Locale.ROOT), ParseFieldMatcher.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not read search request. unexpected string field [" +
|
throw new ElasticsearchParseException("could not read search request. unexpected string field [" +
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class SearchTransform implements Transform {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REQUEST)) {
|
} else if (Field.REQUEST.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
request = WatcherSearchTemplateRequest.fromXContent(transformLogger, parser,
|
request = WatcherSearchTemplateRequest.fromXContent(transformLogger, parser,
|
||||||
ExecutableSearchTransform.DEFAULT_SEARCH_TYPE, parseFieldMatcher, searchRequestParsers);
|
ExecutableSearchTransform.DEFAULT_SEARCH_TYPE, parseFieldMatcher, searchRequestParsers);
|
||||||
|
@ -112,12 +112,12 @@ public class SearchTransform implements Transform {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] transform for watch [{}]. failed to parse [{}]", srpe,
|
throw new ElasticsearchParseException("could not parse [{}] transform for watch [{}]. failed to parse [{}]", srpe,
|
||||||
TYPE, watchId, currentFieldName);
|
TYPE, watchId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMEOUT)) {
|
} else if (Field.TIMEOUT.match(currentFieldName)) {
|
||||||
timeout = timeValueMillis(parser.longValue());
|
timeout = timeValueMillis(parser.longValue());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMEOUT_HUMAN)) {
|
} else if (Field.TIMEOUT_HUMAN.match(currentFieldName)) {
|
||||||
// Parser for human specified timeouts and 2.x compatibility
|
// Parser for human specified timeouts and 2.x compatibility
|
||||||
timeout = WatcherDateTimeUtils.parseTimeValue(parser, Field.TIMEOUT_HUMAN.toString());
|
timeout = WatcherDateTimeUtils.parseTimeValue(parser, Field.TIMEOUT_HUMAN.toString());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.DYNAMIC_NAME_TIMEZONE)) {
|
} else if (Field.DYNAMIC_NAME_TIMEZONE.match(currentFieldName)) {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
dynamicNameTimeZone = DateTimeZone.forID(parser.text());
|
dynamicNameTimeZone = DateTimeZone.forID(parser.text());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class DailySchedule extends CronnableSchedule {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, AT_FIELD)) {
|
} else if (AT_FIELD.match(currentFieldName)) {
|
||||||
if (token != XContentParser.Token.START_ARRAY) {
|
if (token != XContentParser.Token.START_ARRAY) {
|
||||||
try {
|
try {
|
||||||
times.add(DayTimes.parse(parser, token));
|
times.add(DayTimes.parse(parser, token));
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class HourlySchedule extends CronnableSchedule {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (currentFieldName == null) {
|
} else if (currentFieldName == null) {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] schedule. unexpected token [{}]", TYPE, token);
|
throw new ElasticsearchParseException("could not parse [{}] schedule. unexpected token [{}]", TYPE, token);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, MINUTE_FIELD)) {
|
} else if (MINUTE_FIELD.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
try {
|
try {
|
||||||
minutes.add(DayTimes.parseMinuteValue(parser, token));
|
minutes.add(DayTimes.parseMinuteValue(parser, token));
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class ScheduleTriggerEvent extends TriggerEvent {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TRIGGERED_TIME)) {
|
} else if (Field.TRIGGERED_TIME.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
triggeredTime = WatcherDateTimeUtils.parseDateMath(currentFieldName, parser, DateTimeZone.UTC, clock);
|
triggeredTime = WatcherDateTimeUtils.parseDateMath(currentFieldName, parser, DateTimeZone.UTC, clock);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
@ -73,7 +73,7 @@ public class ScheduleTriggerEvent extends TriggerEvent {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] trigger event for [{}] for watch [{}]. failed to parse " +
|
throw new ElasticsearchParseException("could not parse [{}] trigger event for [{}] for watch [{}]. failed to parse " +
|
||||||
"date field [{}]", pe, ScheduleTriggerEngine.TYPE, context, watchId, currentFieldName);
|
"date field [{}]", pe, ScheduleTriggerEngine.TYPE, context, watchId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.SCHEDULED_TIME)) {
|
} else if (Field.SCHEDULED_TIME.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
scheduledTime = WatcherDateTimeUtils.parseDateMath(currentFieldName, parser, DateTimeZone.UTC, clock);
|
scheduledTime = WatcherDateTimeUtils.parseDateMath(currentFieldName, parser, DateTimeZone.UTC, clock);
|
||||||
} catch (ElasticsearchParseException pe) {
|
} catch (ElasticsearchParseException pe) {
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class DayTimes implements Times {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HOUR_FIELD)) {
|
} else if (HOUR_FIELD.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
hours.add(parseHourValue(parser, token));
|
hours.add(parseHourValue(parser, token));
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
|
@ -208,7 +208,7 @@ public class DayTimes implements Times {
|
||||||
throw new ElasticsearchParseException("invalid time hour value. expected string/number value or an array of " +
|
throw new ElasticsearchParseException("invalid time hour value. expected string/number value or an array of " +
|
||||||
"string/number values, but found [{}]", token);
|
"string/number values, but found [{}]", token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, MINUTE_FIELD)) {
|
} else if (MINUTE_FIELD.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
minutes.add(parseMinuteValue(parser, token));
|
minutes.add(parseMinuteValue(parser, token));
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class MonthTimes implements Times {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, DAY_FIELD)) {
|
} else if (DAY_FIELD.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
daysSet.add(parseDayValue(parser, token));
|
daysSet.add(parseDayValue(parser, token));
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
|
@ -166,7 +166,7 @@ public class MonthTimes implements Times {
|
||||||
throw new ElasticsearchParseException("invalid month day value for [{}] field. expected string/number value or an " +
|
throw new ElasticsearchParseException("invalid month day value for [{}] field. expected string/number value or an " +
|
||||||
"array of string/number values, but found [{}]", currentFieldName, token);
|
"array of string/number values, but found [{}]", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, TIME_FIELD)) {
|
} else if (TIME_FIELD.match(currentFieldName)) {
|
||||||
if (token != XContentParser.Token.START_ARRAY) {
|
if (token != XContentParser.Token.START_ARRAY) {
|
||||||
try {
|
try {
|
||||||
timesSet.add(DayTimes.parse(parser, token));
|
timesSet.add(DayTimes.parse(parser, token));
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class WeekTimes implements Times {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, DAY_FIELD)) {
|
} else if (DAY_FIELD.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
daysSet.add(parseDayValue(parser, token));
|
daysSet.add(parseDayValue(parser, token));
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
|
@ -123,7 +123,7 @@ public class WeekTimes implements Times {
|
||||||
throw new ElasticsearchParseException("invalid week day value for [{}] field. expected string/number value or an " +
|
throw new ElasticsearchParseException("invalid week day value for [{}] field. expected string/number value or an " +
|
||||||
"array of string/number values, but found [{}]", currentFieldName, token);
|
"array of string/number values, but found [{}]", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, TIME_FIELD)) {
|
} else if (TIME_FIELD.match(currentFieldName)) {
|
||||||
if (token != XContentParser.Token.START_ARRAY) {
|
if (token != XContentParser.Token.START_ARRAY) {
|
||||||
try {
|
try {
|
||||||
timesSet.add(DayTimes.parse(parser, token));
|
timesSet.add(DayTimes.parse(parser, token));
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class YearTimes implements Times {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, MONTH_FIELD)) {
|
} else if (MONTH_FIELD.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
monthsSet.add(parseMonthValue(parser, token));
|
monthsSet.add(parseMonthValue(parser, token));
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
|
@ -156,7 +156,7 @@ public class YearTimes implements Times {
|
||||||
throw new ElasticsearchParseException("invalid year month value for [{}] field. expected string/number value or an " +
|
throw new ElasticsearchParseException("invalid year month value for [{}] field. expected string/number value or an " +
|
||||||
"array of string/number values, but found [{}]", currentFieldName, token);
|
"array of string/number values, but found [{}]", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, DAY_FIELD)) {
|
} else if (DAY_FIELD.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
daysSet.add(MonthTimes.parseDayValue(parser, token));
|
daysSet.add(MonthTimes.parseDayValue(parser, token));
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
|
@ -167,7 +167,7 @@ public class YearTimes implements Times {
|
||||||
throw new ElasticsearchParseException("invalid year day value for [{}] field. expected string/number value or an " +
|
throw new ElasticsearchParseException("invalid year day value for [{}] field. expected string/number value or an " +
|
||||||
"array of string/number values, but found [{}]", currentFieldName, token);
|
"array of string/number values, but found [{}]", currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, TIME_FIELD)) {
|
} else if (TIME_FIELD.match(currentFieldName)) {
|
||||||
if (token != XContentParser.Token.START_ARRAY) {
|
if (token != XContentParser.Token.START_ARRAY) {
|
||||||
try {
|
try {
|
||||||
timesSet.add(DayTimes.parse(parser, token));
|
timesSet.add(DayTimes.parse(parser, token));
|
||||||
|
|
|
@ -291,17 +291,17 @@ public class Watch implements TriggerEngine.Job, ToXContent {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == null || currentFieldName == null) {
|
} else if (token == null || currentFieldName == null) {
|
||||||
throw new ElasticsearchParseException("could not parse watch [{}], unexpected token [{}]", id, token);
|
throw new ElasticsearchParseException("could not parse watch [{}], unexpected token [{}]", id, token);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TRIGGER)) {
|
} else if (Field.TRIGGER.match(currentFieldName)) {
|
||||||
trigger = triggerService.parseTrigger(id, parser);
|
trigger = triggerService.parseTrigger(id, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.INPUT)) {
|
} else if (Field.INPUT.match(currentFieldName)) {
|
||||||
input = inputRegistry.parse(id, parser);
|
input = inputRegistry.parse(id, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.CONDITION)) {
|
} else if (Field.CONDITION.match(currentFieldName)) {
|
||||||
condition = actionRegistry.getConditionRegistry().parseExecutable(id, parser);
|
condition = actionRegistry.getConditionRegistry().parseExecutable(id, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TRANSFORM)) {
|
} else if (Field.TRANSFORM.match(currentFieldName)) {
|
||||||
transform = actionRegistry.getTransformRegistry().parse(id, parser);
|
transform = actionRegistry.getTransformRegistry().parse(id, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.THROTTLE_PERIOD)) {
|
} else if (Field.THROTTLE_PERIOD.match(currentFieldName)) {
|
||||||
throttlePeriod = timeValueMillis(parser.longValue());
|
throttlePeriod = timeValueMillis(parser.longValue());
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.THROTTLE_PERIOD_HUMAN)) {
|
} else if (Field.THROTTLE_PERIOD_HUMAN.match(currentFieldName)) {
|
||||||
// Parser for human specified and 2.x backwards compatible throttle period
|
// Parser for human specified and 2.x backwards compatible throttle period
|
||||||
try {
|
try {
|
||||||
throttlePeriod = WatcherDateTimeUtils.parseTimeValue(parser, Field.THROTTLE_PERIOD_HUMAN.toString());
|
throttlePeriod = WatcherDateTimeUtils.parseTimeValue(parser, Field.THROTTLE_PERIOD_HUMAN.toString());
|
||||||
|
@ -309,11 +309,11 @@ public class Watch implements TriggerEngine.Job, ToXContent {
|
||||||
throw new ElasticsearchParseException("could not parse watch [{}]. failed to parse time value for field [{}]",
|
throw new ElasticsearchParseException("could not parse watch [{}]. failed to parse time value for field [{}]",
|
||||||
pe, id, currentFieldName);
|
pe, id, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACTIONS)) {
|
} else if (Field.ACTIONS.match(currentFieldName)) {
|
||||||
actions = actionRegistry.parseActions(id, parser);
|
actions = actionRegistry.parseActions(id, parser);
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.METADATA)) {
|
} else if (Field.METADATA.match(currentFieldName)) {
|
||||||
metatdata = parser.map();
|
metatdata = parser.map();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.STATUS)) {
|
} else if (Field.STATUS.match(currentFieldName)) {
|
||||||
if (includeStatus) {
|
if (includeStatus) {
|
||||||
status = WatchStatus.parse(id, parser, clock);
|
status = WatchStatus.parse(id, parser, clock);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -235,35 +235,35 @@ public class WatchStatus implements ToXContent, Streamable {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.STATE)) {
|
} else if (Field.STATE.match(currentFieldName)) {
|
||||||
try {
|
try {
|
||||||
state = State.parse(parser, clock);
|
state = State.parse(parser, clock);
|
||||||
} catch (ElasticsearchParseException e) {
|
} catch (ElasticsearchParseException e) {
|
||||||
throw new ElasticsearchParseException("could not parse watch status for [{}]. failed to parse field [{}]",
|
throw new ElasticsearchParseException("could not parse watch status for [{}]. failed to parse field [{}]",
|
||||||
e, watchId, currentFieldName);
|
e, watchId, currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.VERSION)) {
|
} else if (Field.VERSION.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
version = parser.longValue();
|
version = parser.longValue();
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse watch status for [{}]. expecting field [{}] to hold a long " +
|
throw new ElasticsearchParseException("could not parse watch status for [{}]. expecting field [{}] to hold a long " +
|
||||||
"value, found [{}] instead", watchId, currentFieldName, token);
|
"value, found [{}] instead", watchId, currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.LAST_CHECKED)) {
|
} else if (Field.LAST_CHECKED.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
lastChecked = parseDate(currentFieldName, parser, UTC);
|
lastChecked = parseDate(currentFieldName, parser, UTC);
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse watch status for [{}]. expecting field [{}] to hold a date " +
|
throw new ElasticsearchParseException("could not parse watch status for [{}]. expecting field [{}] to hold a date " +
|
||||||
"value, found [{}] instead", watchId, currentFieldName, token);
|
"value, found [{}] instead", watchId, currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.LAST_MET_CONDITION)) {
|
} else if (Field.LAST_MET_CONDITION.match(currentFieldName)) {
|
||||||
if (token.isValue()) {
|
if (token.isValue()) {
|
||||||
lastMetCondition = parseDate(currentFieldName, parser, UTC);
|
lastMetCondition = parseDate(currentFieldName, parser, UTC);
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchParseException("could not parse watch status for [{}]. expecting field [{}] to hold a date " +
|
throw new ElasticsearchParseException("could not parse watch status for [{}]. expecting field [{}] to hold a date " +
|
||||||
"value, found [{}] instead", watchId, currentFieldName, token);
|
"value, found [{}] instead", watchId, currentFieldName, token);
|
||||||
}
|
}
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACTIONS)) {
|
} else if (Field.ACTIONS.match(currentFieldName)) {
|
||||||
actions = new HashMap<>();
|
actions = new HashMap<>();
|
||||||
if (token == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
|
@ -329,9 +329,9 @@ public class WatchStatus implements ToXContent, Streamable {
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.ACTIVE)) {
|
} else if (Field.ACTIVE.match(currentFieldName)) {
|
||||||
active = parser.booleanValue();
|
active = parser.booleanValue();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.TIMESTAMP)) {
|
} else if (Field.TIMESTAMP.match(currentFieldName)) {
|
||||||
timestamp = parseDate(currentFieldName, parser, UTC);
|
timestamp = parseDate(currentFieldName, parser, UTC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue