Skip to content

Commit ded5906

Browse files
committed
refactor XContent.type to XContent.mediaType
Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
1 parent 199dde6 commit ded5906

10 files changed

Lines changed: 15 additions & 15 deletions

File tree

client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static Request multiSearch(MultiSearchRequest multiSearchRequest) throws IOExcep
520520
XContent xContent = REQUEST_BODY_CONTENT_TYPE.xContent();
521521
byte[] source = MultiSearchRequest.writeMultiLineFormat(multiSearchRequest, xContent);
522522
request.addParameters(params.asMap());
523-
request.setEntity(new ByteArrayEntity(source, createContentType(xContent.type())));
523+
request.setEntity(new ByteArrayEntity(source, createContentType(xContent.mediaType())));
524524
return request;
525525
}
526526

@@ -555,7 +555,7 @@ static Request multiSearchTemplate(MultiSearchTemplateRequest multiSearchTemplat
555555

556556
XContent xContent = REQUEST_BODY_CONTENT_TYPE.xContent();
557557
byte[] source = MultiSearchTemplateRequest.writeMultiLineFormat(multiSearchTemplateRequest, xContent);
558-
request.setEntity(new ByteArrayEntity(source, createContentType(xContent.type())));
558+
request.setEntity(new ByteArrayEntity(source, createContentType(xContent.mediaType())));
559559
return request;
560560
}
561561

libs/x-content/src/main/java/org/opensearch/common/xcontent/XContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public interface XContent {
4646
/**
4747
* The type this content handles and produces.
4848
*/
49-
MediaType type();
49+
MediaType mediaType();
5050

5151
byte streamSeparator();
5252

libs/x-content/src/main/java/org/opensearch/common/xcontent/cbor/CborXContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7676
private CborXContent() {}
7777

7878
@Override
79-
public MediaType type() {
79+
public MediaType mediaType() {
8080
return XContentType.CBOR;
8181
}
8282

libs/x-content/src/main/java/org/opensearch/common/xcontent/json/JsonXContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7878
private JsonXContent() {}
7979

8080
@Override
81-
public MediaType type() {
81+
public MediaType mediaType() {
8282
return XContentType.JSON;
8383
}
8484

libs/x-content/src/main/java/org/opensearch/common/xcontent/smile/SmileXContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7878
private SmileXContent() {}
7979

8080
@Override
81-
public MediaType type() {
81+
public MediaType mediaType() {
8282
return XContentType.SMILE;
8383
}
8484

libs/x-content/src/main/java/org/opensearch/common/xcontent/yaml/YamlXContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7171
private YamlXContent() {}
7272

7373
@Override
74-
public MediaType type() {
74+
public MediaType mediaType() {
7575
return XContentType.YAML;
7676
}
7777

server/src/main/java/org/opensearch/index/reindex/ReindexRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
308308
builder.startObject("source");
309309
if (remoteInfo != null) {
310310
builder.field("remote", remoteInfo);
311-
builder.rawField("query", remoteInfo.getQuery().streamInput(), (XContentType) RemoteInfo.QUERY_CONTENT_TYPE.type());
311+
builder.rawField("query", remoteInfo.getQuery().streamInput(), (XContentType) RemoteInfo.QUERY_CONTENT_TYPE.mediaType());
312312
}
313313
builder.array("index", getSearchRequest().indices());
314314
getSearchRequest().source().innerToXContent(builder, params);

server/src/test/java/org/opensearch/OpenSearchExceptionTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ public void testThrowableToAndFromXContent() throws IOException {
742742
BytesReference throwableBytes = toShuffledXContent((builder, params) -> {
743743
OpenSearchException.generateThrowableXContent(builder, params, throwable);
744744
return builder;
745-
}, xContent.type(), ToXContent.EMPTY_PARAMS, randomBoolean());
745+
}, xContent.mediaType(), ToXContent.EMPTY_PARAMS, randomBoolean());
746746

747747
OpenSearchException parsedException;
748748
try (XContentParser parser = createParser(xContent, throwableBytes)) {
@@ -774,7 +774,7 @@ public void testUnknownFailureToAndFromXContent() throws IOException {
774774
// Prints a null failure using generateFailureXContent()
775775
OpenSearchException.generateFailureXContent(builder, params, null, randomBoolean());
776776
return builder;
777-
}, xContent.type(), ToXContent.EMPTY_PARAMS, randomBoolean());
777+
}, xContent.mediaType(), ToXContent.EMPTY_PARAMS, randomBoolean());
778778

779779
OpenSearchException parsedFailure;
780780
try (XContentParser parser = createParser(xContent, failureBytes)) {
@@ -798,7 +798,7 @@ public void testFailureToAndFromXContentWithNoDetails() throws IOException {
798798
BytesReference failureBytes = toShuffledXContent((builder, params) -> {
799799
OpenSearchException.generateFailureXContent(builder, params, failure, false);
800800
return builder;
801-
}, xContent.type(), ToXContent.EMPTY_PARAMS, randomBoolean());
801+
}, xContent.mediaType(), ToXContent.EMPTY_PARAMS, randomBoolean());
802802

803803
try (XContentParser parser = createParser(xContent, failureBytes)) {
804804
failureBytes = BytesReference.bytes(shuffleXContent(parser, randomBoolean()));
@@ -952,7 +952,7 @@ public void testFailureToAndFromXContentWithDetails() throws IOException {
952952
BytesReference failureBytes = toShuffledXContent((builder, params) -> {
953953
OpenSearchException.generateFailureXContent(builder, params, finalFailure, true);
954954
return builder;
955-
}, xContent.type(), ToXContent.EMPTY_PARAMS, randomBoolean());
955+
}, xContent.mediaType(), ToXContent.EMPTY_PARAMS, randomBoolean());
956956

957957
try (XContentParser parser = createParser(xContent, failureBytes)) {
958958
failureBytes = BytesReference.bytes(shuffleXContent(parser, randomBoolean()));

server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void testToAndFromXContent() throws IOException {
134134
final String phase = randomFrom("query", "search", "other");
135135
SearchPhaseExecutionException actual = new SearchPhaseExecutionException(phase, "unexpected failures", shardSearchFailures);
136136

137-
BytesReference exceptionBytes = toShuffledXContent(actual, xContent.type(), ToXContent.EMPTY_PARAMS, randomBoolean());
137+
BytesReference exceptionBytes = toShuffledXContent(actual, xContent.mediaType(), ToXContent.EMPTY_PARAMS, randomBoolean());
138138

139139
OpenSearchException parsedException;
140140
try (XContentParser parser = createParser(xContent, exceptionBytes)) {

server/src/test/java/org/opensearch/common/xcontent/BaseXContentTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ void doTestRawValue(XContent source) throws Exception {
941941

942942
os = new ByteArrayOutputStream();
943943
try (XContentGenerator generator = xcontentType().xContent().createGenerator(os)) {
944-
generator.writeRawValue(new BytesArray(rawData).streamInput(), source.type());
944+
generator.writeRawValue(new BytesArray(rawData).streamInput(), source.mediaType());
945945
}
946946

947947
try (
@@ -966,7 +966,7 @@ public void close() {
966966
try (XContentGenerator generator = xcontentType().xContent().createGenerator(os)) {
967967
generator.writeStartObject();
968968
generator.writeFieldName("test");
969-
generator.writeRawValue(new BytesArray(rawData).streamInput(), source.type());
969+
generator.writeRawValue(new BytesArray(rawData).streamInput(), source.mediaType());
970970
assertFalse("Generator should not have closed the output stream", closed.get());
971971
generator.writeEndObject();
972972
}

0 commit comments

Comments
 (0)