From c12bc0b5b056fa0e1deeca5a49e25a9c8cfb8011 Mon Sep 17 00:00:00 2001 From: Bharathwaj G Date: Thu, 3 Aug 2023 10:17:14 +0530 Subject: [PATCH] more fixes Signed-off-by: Bharathwaj G --- .../AsynchronousSearchManagementService.java | 2 +- .../plugin/AsynchronousSearchPlugin.java | 2 +- .../response/AsynchronousSearchResponse.java | 4 ++-- .../AsynchronousSearchPersistenceService.java | 4 ++-- .../service/AsynchronousSearchService.java | 2 +- .../asynchronous/SecurityEnabledRestTestCase.java | 4 ++-- .../restIT/AsynchronousSearchRestTestCase.java | 12 ++++++------ .../AsynchronousSearchServiceUpdateContextTests.java | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/opensearch/search/asynchronous/management/AsynchronousSearchManagementService.java b/src/main/java/org/opensearch/search/asynchronous/management/AsynchronousSearchManagementService.java index e0568a0d..02e2aa47 100644 --- a/src/main/java/org/opensearch/search/asynchronous/management/AsynchronousSearchManagementService.java +++ b/src/main/java/org/opensearch/search/asynchronous/management/AsynchronousSearchManagementService.java @@ -23,7 +23,7 @@ import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.Randomness; -import org.opensearch.common.component.AbstractLifecycleComponent; +import org.opensearch.common.lifecycle.AbstractLifecycleComponent; import org.opensearch.common.inject.Inject; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/src/main/java/org/opensearch/search/asynchronous/plugin/AsynchronousSearchPlugin.java b/src/main/java/org/opensearch/search/asynchronous/plugin/AsynchronousSearchPlugin.java index 4b675007..a457fa6e 100644 --- a/src/main/java/org/opensearch/search/asynchronous/plugin/AsynchronousSearchPlugin.java +++ b/src/main/java/org/opensearch/search/asynchronous/plugin/AsynchronousSearchPlugin.java @@ -29,7 +29,7 @@ import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.component.LifecycleComponent; +import org.opensearch.common.lifecycle.LifecycleComponent; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.IndexScopedSettings; diff --git a/src/main/java/org/opensearch/search/asynchronous/response/AsynchronousSearchResponse.java b/src/main/java/org/opensearch/search/asynchronous/response/AsynchronousSearchResponse.java index d312c7c8..d63031e1 100644 --- a/src/main/java/org/opensearch/search/asynchronous/response/AsynchronousSearchResponse.java +++ b/src/main/java/org/opensearch/search/asynchronous/response/AsynchronousSearchResponse.java @@ -6,7 +6,6 @@ package org.opensearch.search.asynchronous.response; import org.opensearch.common.xcontent.StatusToXContentObject; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; @@ -23,6 +22,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.rest.RestStatus; @@ -204,7 +204,7 @@ public boolean equals(Object o) { private Map getErrorAsMap(OpenSearchException exception) throws IOException { if (exception != null) { BytesReference error; - try (XContentBuilder builder = XContentFactory.contentBuilder(Requests.INDEX_CONTENT_TYPE)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(Requests.INDEX_CONTENT_TYPE)) { builder.startObject(); OpenSearchException.generateThrowableXContent(builder, ToXContent.EMPTY_PARAMS, exception); builder.endObject(); diff --git a/src/main/java/org/opensearch/search/asynchronous/service/AsynchronousSearchPersistenceService.java b/src/main/java/org/opensearch/search/asynchronous/service/AsynchronousSearchPersistenceService.java index 3cf9b500..a069e288 100644 --- a/src/main/java/org/opensearch/search/asynchronous/service/AsynchronousSearchPersistenceService.java +++ b/src/main/java/org/opensearch/search/asynchronous/service/AsynchronousSearchPersistenceService.java @@ -5,7 +5,6 @@ package org.opensearch.search.asynchronous.service; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.commons.authuser.User; import org.opensearch.search.asynchronous.context.persistence.AsynchronousSearchPersistenceModel; @@ -33,6 +32,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.engine.DocumentMissingException; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.reindex.DeleteByQueryAction; @@ -391,7 +391,7 @@ private Settings indexSettings() { private XContentBuilder mapping() { try { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); builder.startObject() .startObject("properties") .startObject(START_TIME_MILLIS) diff --git a/src/main/java/org/opensearch/search/asynchronous/service/AsynchronousSearchService.java b/src/main/java/org/opensearch/search/asynchronous/service/AsynchronousSearchService.java index 1a3dabc9..7092e1a8 100644 --- a/src/main/java/org/opensearch/search/asynchronous/service/AsynchronousSearchService.java +++ b/src/main/java/org/opensearch/search/asynchronous/service/AsynchronousSearchService.java @@ -23,7 +23,7 @@ import org.opensearch.cluster.ClusterStateListener; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.UUIDs; -import org.opensearch.common.component.AbstractLifecycleComponent; +import org.opensearch.common.lifecycle.AbstractLifecycleComponent; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.lease.Releasable; import org.opensearch.common.settings.Setting; diff --git a/src/test/java/org/opensearch/search/asynchronous/SecurityEnabledRestTestCase.java b/src/test/java/org/opensearch/search/asynchronous/SecurityEnabledRestTestCase.java index 93a28141..066a516c 100644 --- a/src/test/java/org/opensearch/search/asynchronous/SecurityEnabledRestTestCase.java +++ b/src/test/java/org/opensearch/search/asynchronous/SecurityEnabledRestTestCase.java @@ -23,10 +23,10 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.commons.rest.SecureRestClientBuilder; import org.opensearch.test.rest.OpenSearchRestTestCase; @@ -114,7 +114,7 @@ protected RestClient buildClient(Settings settings, HttpHost[] hosts) throws IOE @After protected void wipeAllOSIndices() throws IOException { Response response = adminClient().performRequest(new Request("GET", "/_cat/indices?format=json&expand_wildcards=all")); - XContentType xContentType = XContentType.fromMediaType(response.getEntity().getContentType().getValue()); + MediaType xContentType = MediaType.fromMediaType(response.getEntity().getContentType().getValue()); try ( XContentParser parser = xContentType .xContent() diff --git a/src/test/java/org/opensearch/search/asynchronous/restIT/AsynchronousSearchRestTestCase.java b/src/test/java/org/opensearch/search/asynchronous/restIT/AsynchronousSearchRestTestCase.java index 85b5caaf..b19bf785 100644 --- a/src/test/java/org/opensearch/search/asynchronous/restIT/AsynchronousSearchRestTestCase.java +++ b/src/test/java/org/opensearch/search/asynchronous/restIT/AsynchronousSearchRestTestCase.java @@ -6,7 +6,11 @@ package org.opensearch.search.asynchronous.restIT; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.NamedXContentRegistry; +import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentParser; import org.opensearch.search.asynchronous.SecurityEnabledRestTestCase; import org.opensearch.search.asynchronous.request.DeleteAsynchronousSearchRequest; import org.opensearch.search.asynchronous.request.GetAsynchronousSearchRequest; @@ -27,10 +31,6 @@ import org.opensearch.common.Nullable; import org.opensearch.core.common.Strings; import org.opensearch.common.settings.Settings; -import org.opensearch.core.xcontent.DeprecationHandler; -import org.opensearch.core.xcontent.NamedXContentRegistry; -import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.rest.RestStatus; import org.opensearch.search.SearchModule; @@ -166,7 +166,7 @@ protected final Resp parseEntity(final HttpEntity entity, if (entity.getContentType() == null) { throw new IllegalStateException("Elasticsearch didn't return the [Content-Type] header, unable to parse response body"); } - XContentType xContentType = XContentType.fromMediaType(entity.getContentType().getValue()); + MediaType xContentType = MediaType.fromMediaType(entity.getContentType().getValue()); if (xContentType == null) { throw new IllegalStateException("Unsupported Content-Type: " + entity.getContentType().getValue()); } diff --git a/src/test/java/org/opensearch/search/asynchronous/service/AsynchronousSearchServiceUpdateContextTests.java b/src/test/java/org/opensearch/search/asynchronous/service/AsynchronousSearchServiceUpdateContextTests.java index cc47dbb3..b7783c13 100644 --- a/src/test/java/org/opensearch/search/asynchronous/service/AsynchronousSearchServiceUpdateContextTests.java +++ b/src/test/java/org/opensearch/search/asynchronous/service/AsynchronousSearchServiceUpdateContextTests.java @@ -5,7 +5,6 @@ package org.opensearch.search.asynchronous.service; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.commons.authuser.User; import org.apache.lucene.search.TotalHits; @@ -39,6 +38,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.OpenSearchExecutors; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.index.Index; import org.opensearch.index.get.GetResult; import org.opensearch.core.index.shard.ShardId; @@ -586,7 +586,7 @@ protected void Map sourceMap = new HashMap<>(); sourceMap.put(EXPIRATION_TIME_MILLIS, randomNonNegativeLong()); sourceMap.put(START_TIME_MILLIS, randomNonNegativeLong()); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); builder.map(sourceMap); BytesReference source = BytesReference.bytes(builder); updateResponse.setGetResult(new GetResult(ASYNC_SEARCH_RESPONSE_INDEX,