Fix 1. compatibility

Original commit: elastic/x-pack-elasticsearch@e409f99754
This commit is contained in:
uboness 2015-06-08 09:31:18 +02:00
parent c491e4db16
commit e684194c23
1 changed files with 0 additions and 24 deletions

View File

@ -11,7 +11,6 @@ import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.compress.CompressedStreamInput;
import org.elasticsearch.common.compress.Compressor;
import org.elasticsearch.common.compress.CompressorFactory;
import org.elasticsearch.common.io.stream.BytesStreamInput;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
@ -29,9 +28,6 @@ public class WatcherXContentUtils {
}
public static Tuple<XContentType, Object> convertToObject(BytesReference bytes) throws ElasticsearchParseException {
if (bytes.hasArray()) {
return convertToObject(bytes.array(), bytes.arrayOffset(), bytes.length());
}
try {
XContentParser parser;
XContentType contentType;
@ -51,26 +47,6 @@ public class WatcherXContentUtils {
}
}
public static Tuple<XContentType, Object> convertToObject(byte[] data, int offset, int length) throws ElasticsearchParseException {
try {
XContentParser parser;
XContentType contentType;
Compressor compressor = CompressorFactory.compressor(data, offset, length);
if (compressor != null) {
CompressedStreamInput compressedStreamInput = compressor.streamInput(new BytesStreamInput(data, offset, length, false));
contentType = XContentFactory.xContentType(compressedStreamInput);
compressedStreamInput.resetToBufferStart();
parser = XContentFactory.xContent(contentType).createParser(compressedStreamInput);
} else {
contentType = XContentFactory.xContentType(data, offset, length);
parser = XContentFactory.xContent(contentType).createParser(data, offset, length);
}
return Tuple.tuple(contentType, readValue(parser, parser.nextToken()));
} catch (IOException e) {
throw new ElasticsearchParseException("Failed to parse content to map", e);
}
}
// TODO open this up in core
public static List<Object> readList(XContentParser parser, XContentParser.Token token) throws IOException {
List<Object> list = new ArrayList<>();