use of org.opensearch.action.admin.indices.close.CloseIndexResponse.ShardResult in project fesen-httpclient by codelibs.
the class HttpCloseIndexAction method parseIndexResult.
protected IndexResult parseIndexResult(final XContentParser parser, final String index) throws IOException {
boolean closed = false;
OpenSearchException eex = null;
final List<ShardResult> shardResults = new ArrayList<>();
String fieldName = null;
XContentParser.Token token;
while ((token = parser.currentToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
fieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
if ("exception".equals(fieldName)) {
parser.nextToken();
eex = OpenSearchException.fromXContent(parser);
} else if ("failedShards".equals(fieldName)) {
parser.nextToken();
shardResults.addAll(parseShardResults(parser));
}
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
if ("closed".equals(fieldName)) {
closed = parser.booleanValue();
}
}
parser.nextToken();
}
final Index idx = new Index(index, "unknown");
if (closed) {
return new IndexResult(idx);
}
if (eex != null) {
return new IndexResult(idx, eex);
}
if (!shardResults.isEmpty()) {
return new IndexResult(idx, shardResults.toArray(new ShardResult[shardResults.size()]));
}
return new IndexResult(idx);
}
Aggregations