mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 18:35:25 +00:00
Fix compilation from upstream XContentType changes
This commit fixes a compilation issue that arose from upstream changes in core where some method names on XContentType were changed. Closes elastic/elasticsearch#1463 Original commit: elastic/x-pack-elasticsearch@0a3763dbb5
This commit is contained in:
parent
cc8ae273c9
commit
166e8786ea
@ -169,7 +169,7 @@ public class HttpExporter extends Exporter {
|
||||
if (bulkTimeout != null) {
|
||||
queryString = "?master_timeout=" + bulkTimeout;
|
||||
}
|
||||
HttpURLConnection conn = openAndValidateConnection("POST", "/_bulk" + queryString, XContentType.SMILE.restContentType());
|
||||
HttpURLConnection conn = openAndValidateConnection("POST", "/_bulk" + queryString, XContentType.SMILE.mediaType());
|
||||
if (conn != null && (keepAliveThread == null || !keepAliveThread.isAlive())) {
|
||||
// start keep alive upon successful connection if not there.
|
||||
initKeepAliveThread();
|
||||
@ -450,7 +450,7 @@ public class HttpExporter extends Exporter {
|
||||
logger.debug("http exporter [{}] - installing template [{}]", name(), template);
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
connection = openConnection(host, "PUT", "_template/" + template, XContentType.JSON.restContentType());
|
||||
connection = openConnection(host, "PUT", "_template/" + template, XContentType.JSON.mediaType());
|
||||
if (connection == null) {
|
||||
logger.debug("http exporter [{}] - no available connection to update marvel template [{}]", name(), template);
|
||||
return false;
|
||||
|
@ -29,7 +29,7 @@ public enum DataAttachment implements ToXContent {
|
||||
YAML() {
|
||||
@Override
|
||||
public String contentType() {
|
||||
return XContentType.YAML.restContentType();
|
||||
return XContentType.YAML.mediaType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,7 +46,7 @@ public enum DataAttachment implements ToXContent {
|
||||
JSON() {
|
||||
@Override
|
||||
public String contentType() {
|
||||
return XContentType.JSON.restContentType();
|
||||
return XContentType.JSON.mediaType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -409,7 +409,7 @@ public class HttpRequest implements ToXContent {
|
||||
|
||||
public Builder jsonBody(ToXContent xContent) {
|
||||
return body(XContentHelper.toString(xContent))
|
||||
.setHeader("Content-Type", XContentType.JSON.restContentType());
|
||||
.setHeader("Content-Type", XContentType.JSON.mediaType());
|
||||
}
|
||||
|
||||
public Builder connectionTimeout(TimeValue timeout) {
|
||||
|
@ -132,12 +132,12 @@ public class HttpRequestTemplate implements ToXContent {
|
||||
request.setParams(mapBuilder.map());
|
||||
}
|
||||
if ((headers == null || headers.isEmpty()) && body != null && body.getContentType() != null) {
|
||||
request.setHeaders(singletonMap(HttpHeaders.Names.CONTENT_TYPE, body.getContentType().restContentType()));
|
||||
request.setHeaders(singletonMap(HttpHeaders.Names.CONTENT_TYPE, body.getContentType().mediaType()));
|
||||
} else if (headers != null && !headers.isEmpty()) {
|
||||
MapBuilder<String, String> mapBuilder = MapBuilder.newMapBuilder();
|
||||
if (body != null && body.getContentType() != null) {
|
||||
// putting the content type first, so it can be overridden by custom headers
|
||||
mapBuilder.put(HttpHeaders.Names.CONTENT_TYPE, body.getContentType().restContentType());
|
||||
mapBuilder.put(HttpHeaders.Names.CONTENT_TYPE, body.getContentType().mediaType());
|
||||
}
|
||||
for (Map.Entry<String, TextTemplate> entry : headers.entrySet()) {
|
||||
mapBuilder.put(entry.getKey(), engine.render(entry.getValue(), model));
|
||||
|
@ -92,7 +92,7 @@ public class HttpResponse implements ToXContent {
|
||||
if (values == null || values.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return XContentType.fromRestContentType(values[0]);
|
||||
return XContentType.fromMediaTypeOrFormat(values[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,7 +65,7 @@ public class DefaultTextTemplateEngine extends AbstractComponent implements Text
|
||||
if (template.startsWith("__")) {
|
||||
int endOfContentName = template.indexOf("__::", 3); //There must be a __<content_type__:: prefix so the minimum length before detecting '__::' is 3
|
||||
if (endOfContentName != -1) {
|
||||
return XContentType.fromRestContentType(template.substring(2, endOfContentName));
|
||||
return XContentType.fromMediaTypeOrFormat(template.substring(2, endOfContentName));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -99,11 +99,11 @@ public class HttpInputTests extends ESTestCase {
|
||||
httpInput = InputBuilders.httpInput(request.build()).expectedResponseXContentType(HttpContentType.YAML).build();
|
||||
break;
|
||||
case 3:
|
||||
response = new HttpResponse(123, "{\"key\" : \"value\"}".getBytes(StandardCharsets.UTF_8), singletonMap(HttpHeaders.Names.CONTENT_TYPE, new String[] { XContentType.JSON.restContentType() }));
|
||||
response = new HttpResponse(123, "{\"key\" : \"value\"}".getBytes(StandardCharsets.UTF_8), singletonMap(HttpHeaders.Names.CONTENT_TYPE, new String[] { XContentType.JSON.mediaType() }));
|
||||
httpInput = InputBuilders.httpInput(request.build()).build();
|
||||
break;
|
||||
case 4:
|
||||
response = new HttpResponse(123, "key: value".getBytes(StandardCharsets.UTF_8), singletonMap(HttpHeaders.Names.CONTENT_TYPE, new String[] { XContentType.YAML.restContentType() }));
|
||||
response = new HttpResponse(123, "key: value".getBytes(StandardCharsets.UTF_8), singletonMap(HttpHeaders.Names.CONTENT_TYPE, new String[] { XContentType.YAML.mediaType() }));
|
||||
httpInput = InputBuilders.httpInput(request.build()).build();
|
||||
break;
|
||||
case 5:
|
||||
|
@ -41,7 +41,7 @@ public class HttpRequestTemplateTests extends ESTestCase {
|
||||
.body(XContentBuilder.builder(type.xContent()).startObject().endObject())
|
||||
.build();
|
||||
HttpRequest request = template.render(new MockTextTemplateEngine(), emptyMap());
|
||||
assertThat(request.headers, hasEntry(HttpHeaders.Names.CONTENT_TYPE, type.restContentType()));
|
||||
assertThat(request.headers, hasEntry(HttpHeaders.Names.CONTENT_TYPE, type.mediaType()));
|
||||
}
|
||||
|
||||
public void testBody() throws Exception {
|
||||
|
Loading…
x
Reference in New Issue
Block a user