Skip to content

Commit def1024

Browse files
martijnvgjbaiera
authored andcommitted
Move the policy class to xpack core module. (#41311)
This allows the transport client use this class in enrich APIs. Relates to #40997
1 parent 7ea14fd commit def1024

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicy.java renamed to x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichPolicy.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
package org.elasticsearch.xpack.enrich;
6+
package org.elasticsearch.xpack.core.enrich;
77

88
import org.elasticsearch.common.ParseField;
99
import org.elasticsearch.common.Strings;
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.common.xcontent.ToXContentFragment;
1616
import org.elasticsearch.common.xcontent.XContentBuilder;
1717
import org.elasticsearch.common.xcontent.XContentHelper;
18+
import org.elasticsearch.common.xcontent.XContentParser;
1819
import org.elasticsearch.common.xcontent.XContentType;
1920

2021
import java.io.IOException;
@@ -28,7 +29,7 @@
2829
public final class EnrichPolicy implements Writeable, ToXContentFragment {
2930

3031
static final String EXACT_MATCH_TYPE = "exact_match";
31-
static final String[] SUPPORTED_POLICY_TYPES = new String[]{EXACT_MATCH_TYPE};
32+
public static final String[] SUPPORTED_POLICY_TYPES = new String[]{EXACT_MATCH_TYPE};
3233

3334
static final ParseField TYPE = new ParseField("type");
3435
static final ParseField QUERY = new ParseField("query");
@@ -64,6 +65,10 @@ public final class EnrichPolicy implements Writeable, ToXContentFragment {
6465
PARSER.declareString(ConstructingObjectParser.constructorArg(), SCHEDULE);
6566
}
6667

68+
public static EnrichPolicy fromXContent(XContentParser parser) throws IOException {
69+
return PARSER.parse(parser, null);
70+
}
71+
6772
private final String type;
6873
private final QuerySource query;
6974
private final String indexPattern;

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.common.xcontent.XContentBuilder;
1717
import org.elasticsearch.common.xcontent.XContentParser;
1818
import org.elasticsearch.xpack.core.XPackPlugin;
19+
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;
1920

2021
import java.io.IOException;
2122
import java.util.Collections;
@@ -47,7 +48,7 @@ public final class EnrichMetadata extends AbstractNamedDiffable<MetaData.Custom>
4748
if (token == XContentParser.Token.FIELD_NAME) {
4849
fieldName = p.currentName();
4950
} else if (token == XContentParser.Token.START_OBJECT) {
50-
patterns.put(fieldName, EnrichPolicy.PARSER.parse(p, c));
51+
patterns.put(fieldName, EnrichPolicy.fromXContent(p));
5152
} else {
5253
throw new ElasticsearchParseException("unexpected token [" + token + "]");
5354
}

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichStore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.elasticsearch.cluster.ClusterStateUpdateTask;
1010
import org.elasticsearch.cluster.metadata.MetaData;
1111
import org.elasticsearch.cluster.service.ClusterService;
12+
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;
1213

1314
import java.util.HashMap;
1415
import java.util.Map;

x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichMetadataTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.elasticsearch.common.xcontent.XContentParser;
1010
import org.elasticsearch.common.xcontent.XContentType;
1111
import org.elasticsearch.test.AbstractSerializingTestCase;
12+
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;
1213

1314
import java.io.IOException;
1415
import java.util.HashMap;

x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.index.query.QueryBuilder;
1717
import org.elasticsearch.index.query.TermQueryBuilder;
1818
import org.elasticsearch.test.AbstractSerializingTestCase;
19+
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;
1920

2021
import java.io.ByteArrayOutputStream;
2122
import java.io.IOException;
@@ -29,7 +30,7 @@ public class EnrichPolicyTests extends AbstractSerializingTestCase<EnrichPolicy>
2930

3031
@Override
3132
protected EnrichPolicy doParseInstance(XContentParser parser) throws IOException {
32-
return EnrichPolicy.PARSER.parse(parser, null);
33+
return EnrichPolicy.fromXContent(parser);
3334
}
3435

3536
@Override

x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichStoreTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.elasticsearch.cluster.service.ClusterService;
99
import org.elasticsearch.common.xcontent.XContentType;
1010
import org.elasticsearch.test.ESSingleNodeTestCase;
11+
import org.elasticsearch.xpack.core.enrich.EnrichPolicy;
1112

1213
import java.util.concurrent.CountDownLatch;
1314
import java.util.concurrent.atomic.AtomicReference;

0 commit comments

Comments
 (0)