Rest: Remove 'case' parameter from rest apis
The current api allows for choosing which "case" response json keys are written in. This has the options of camelCase or underscore. camelCase is going to be deprecated from the query apis. However, with the case api, it is not necessary to deprecate, as users who were using it in 2.x can transition completely on 2.x before upgrading by simply using the underscore option. This change removes the 'case' option from rest apis. see #8988
This commit is contained in:
parent
f35cfc3715
commit
88dd6ba430
|
@ -305,7 +305,7 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
|
||||||
if (outputIndices) {
|
if (outputIndices) {
|
||||||
builder.startObject(Fields.INDICES);
|
builder.startObject(Fields.INDICES);
|
||||||
for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) {
|
for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) {
|
||||||
builder.startObject(indexHealth.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexHealth.getIndex());
|
||||||
indexHealth.toXContent(builder, params);
|
indexHealth.toXContent(builder, params);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,23 +64,23 @@ public class NodesInfoResponse extends BaseNodesResponse<NodeInfo> implements To
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.field("cluster_name", getClusterName().value(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("cluster_name", getClusterName().value());
|
||||||
|
|
||||||
builder.startObject("nodes");
|
builder.startObject("nodes");
|
||||||
for (NodeInfo nodeInfo : this) {
|
for (NodeInfo nodeInfo : this) {
|
||||||
builder.startObject(nodeInfo.getNode().getId(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(nodeInfo.getNode().getId());
|
||||||
|
|
||||||
builder.field("name", nodeInfo.getNode().getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("name", nodeInfo.getNode().getName());
|
||||||
builder.field("transport_address", nodeInfo.getNode().getAddress().toString());
|
builder.field("transport_address", nodeInfo.getNode().getAddress().toString());
|
||||||
builder.field("host", nodeInfo.getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("host", nodeInfo.getNode().getHostName());
|
||||||
builder.field("ip", nodeInfo.getNode().getHostAddress(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("ip", nodeInfo.getNode().getHostAddress());
|
||||||
|
|
||||||
builder.field("version", nodeInfo.getVersion());
|
builder.field("version", nodeInfo.getVersion());
|
||||||
builder.field("build_hash", nodeInfo.getBuild().shortHash());
|
builder.field("build_hash", nodeInfo.getBuild().shortHash());
|
||||||
|
|
||||||
if (nodeInfo.getServiceAttributes() != null) {
|
if (nodeInfo.getServiceAttributes() != null) {
|
||||||
for (Map.Entry<String, String> nodeAttribute : nodeInfo.getServiceAttributes().entrySet()) {
|
for (Map.Entry<String, String> nodeAttribute : nodeInfo.getServiceAttributes().entrySet()) {
|
||||||
builder.field(nodeAttribute.getKey(), nodeAttribute.getValue(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(nodeAttribute.getKey(), nodeAttribute.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class NodesInfoResponse extends BaseNodesResponse<NodeInfo> implements To
|
||||||
if (!nodeInfo.getNode().getAttributes().isEmpty()) {
|
if (!nodeInfo.getNode().getAttributes().isEmpty()) {
|
||||||
builder.startObject("attributes");
|
builder.startObject("attributes");
|
||||||
for (Map.Entry<String, String> entry : nodeInfo.getNode().getAttributes().entrySet()) {
|
for (Map.Entry<String, String> entry : nodeInfo.getNode().getAttributes().entrySet()) {
|
||||||
builder.field(entry.getKey(), entry.getValue(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,10 +299,10 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
if (!params.param("node_info_format", "default").equals("none")) {
|
if (!params.param("node_info_format", "default").equals("none")) {
|
||||||
builder.field("name", getNode().getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("name", getNode().getName());
|
||||||
builder.field("transport_address", getNode().getAddress().toString(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("transport_address", getNode().getAddress().toString());
|
||||||
builder.field("host", getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("host", getNode().getHostName());
|
||||||
builder.field("ip", getNode().getAddress(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field("ip", getNode().getAddress());
|
||||||
|
|
||||||
builder.startArray("roles");
|
builder.startArray("roles");
|
||||||
for (DiscoveryNode.Role role : getNode().getRoles()) {
|
for (DiscoveryNode.Role role : getNode().getRoles()) {
|
||||||
|
@ -313,7 +313,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
||||||
if (!getNode().getAttributes().isEmpty()) {
|
if (!getNode().getAttributes().isEmpty()) {
|
||||||
builder.startObject("attributes");
|
builder.startObject("attributes");
|
||||||
for (Map.Entry<String, String> attrEntry : getNode().getAttributes().entrySet()) {
|
for (Map.Entry<String, String> attrEntry : getNode().getAttributes().entrySet()) {
|
||||||
builder.field(attrEntry.getKey(), attrEntry.getValue(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(attrEntry.getKey(), attrEntry.getValue());
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class NodesStatsResponse extends BaseNodesResponse<NodeStats> implements
|
||||||
|
|
||||||
builder.startObject("nodes");
|
builder.startObject("nodes");
|
||||||
for (NodeStats nodeStats : this) {
|
for (NodeStats nodeStats : this) {
|
||||||
builder.startObject(nodeStats.getNode().getId(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(nodeStats.getNode().getId());
|
||||||
builder.field("timestamp", nodeStats.getTimestamp());
|
builder.field("timestamp", nodeStats.getTimestamp());
|
||||||
nodeStats.toXContent(builder, params);
|
nodeStats.toXContent(builder, params);
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent {
|
||||||
builder.startObject("nodes");
|
builder.startObject("nodes");
|
||||||
for (Map.Entry<DiscoveryNode, List<TaskInfo>> entry : getPerNodeTasks().entrySet()) {
|
for (Map.Entry<DiscoveryNode, List<TaskInfo>> entry : getPerNodeTasks().entrySet()) {
|
||||||
DiscoveryNode node = entry.getKey();
|
DiscoveryNode node = entry.getKey();
|
||||||
builder.startObject(node.getId(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(node.getId());
|
||||||
builder.field("name", node.getName());
|
builder.field("name", node.getName());
|
||||||
builder.field("transport_address", node.getAddress().toString());
|
builder.field("transport_address", node.getAddress().toString());
|
||||||
builder.field("host", node.getHostName());
|
builder.field("host", node.getHostName());
|
||||||
|
@ -178,13 +178,13 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent {
|
||||||
if (!node.getAttributes().isEmpty()) {
|
if (!node.getAttributes().isEmpty()) {
|
||||||
builder.startObject("attributes");
|
builder.startObject("attributes");
|
||||||
for (Map.Entry<String, String> attrEntry : node.getAttributes().entrySet()) {
|
for (Map.Entry<String, String> attrEntry : node.getAttributes().entrySet()) {
|
||||||
builder.field(attrEntry.getKey(), attrEntry.getValue(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(attrEntry.getKey(), attrEntry.getValue());
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
builder.startObject("tasks");
|
builder.startObject("tasks");
|
||||||
for(TaskInfo task : entry.getValue()) {
|
for(TaskInfo task : entry.getValue()) {
|
||||||
builder.startObject(task.getTaskId().toString(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(task.getTaskId().toString());
|
||||||
task.toXContent(builder, params);
|
task.toXContent(builder, params);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent {
|
||||||
} else if ("parents".equals(groupBy)) {
|
} else if ("parents".equals(groupBy)) {
|
||||||
builder.startObject("tasks");
|
builder.startObject("tasks");
|
||||||
for (TaskGroup group : getTaskGroups()) {
|
for (TaskGroup group : getTaskGroups()) {
|
||||||
builder.startObject(group.getTaskInfo().getTaskId().toString(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(group.getTaskInfo().getTaskId().toString());
|
||||||
group.toXContent(builder, params);
|
group.toXContent(builder, params);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,8 +86,8 @@ public class VerifyRepositoryResponse extends ActionResponse implements ToXConte
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(Fields.NODES);
|
builder.startObject(Fields.NODES);
|
||||||
for (DiscoveryNode node : nodes) {
|
for (DiscoveryNode node : nodes) {
|
||||||
builder.startObject(node.getId(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(node.getId());
|
||||||
builder.field(Fields.NAME, node.getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(Fields.NAME, node.getName());
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class SnapshotIndexStatus implements Iterable<SnapshotIndexShardStatus>,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(getIndex(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(getIndex());
|
||||||
shardsStats.toXContent(builder, params);
|
shardsStats.toXContent(builder, params);
|
||||||
stats.toXContent(builder, params);
|
stats.toXContent(builder, params);
|
||||||
builder.startObject(Fields.SHARDS);
|
builder.startObject(Fields.SHARDS);
|
||||||
|
|
|
@ -74,10 +74,10 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
for (Map.Entry<String, Map<String, Map<String, FieldMappingMetaData>>> indexEntry : mappings.entrySet()) {
|
for (Map.Entry<String, Map<String, Map<String, FieldMappingMetaData>>> indexEntry : mappings.entrySet()) {
|
||||||
builder.startObject(indexEntry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexEntry.getKey());
|
||||||
builder.startObject("mappings");
|
builder.startObject("mappings");
|
||||||
for (Map.Entry<String, Map<String, FieldMappingMetaData>> typeEntry : indexEntry.getValue().entrySet()) {
|
for (Map.Entry<String, Map<String, FieldMappingMetaData>> typeEntry : indexEntry.getValue().entrySet()) {
|
||||||
builder.startObject(typeEntry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(typeEntry.getKey());
|
||||||
for (Map.Entry<String, FieldMappingMetaData> fieldEntry : typeEntry.getValue().entrySet()) {
|
for (Map.Entry<String, FieldMappingMetaData> fieldEntry : typeEntry.getValue().entrySet()) {
|
||||||
builder.startObject(fieldEntry.getKey());
|
builder.startObject(fieldEntry.getKey());
|
||||||
fieldEntry.getValue().toXContent(builder, params);
|
fieldEntry.getValue().toXContent(builder, params);
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class IndicesSegmentResponse extends BroadcastResponse implements ToXCont
|
||||||
builder.startObject(Fields.INDICES);
|
builder.startObject(Fields.INDICES);
|
||||||
|
|
||||||
for (IndexSegments indexSegments : getIndices().values()) {
|
for (IndexSegments indexSegments : getIndices().values()) {
|
||||||
builder.startObject(indexSegments.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexSegments.getIndex());
|
||||||
|
|
||||||
builder.startObject(Fields.SHARDS);
|
builder.startObject(Fields.SHARDS);
|
||||||
for (IndexShardSegments indexSegment : indexSegments) {
|
for (IndexShardSegments indexSegment : indexSegments) {
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class IndicesStatsResponse extends BroadcastResponse implements ToXConten
|
||||||
if ("indices".equalsIgnoreCase(level) || "shards".equalsIgnoreCase(level)) {
|
if ("indices".equalsIgnoreCase(level) || "shards".equalsIgnoreCase(level)) {
|
||||||
builder.startObject(Fields.INDICES);
|
builder.startObject(Fields.INDICES);
|
||||||
for (IndexStats indexStats : getIndices().values()) {
|
for (IndexStats indexStats : getIndices().values()) {
|
||||||
builder.startObject(indexStats.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexStats.getIndex());
|
||||||
|
|
||||||
builder.startObject("primaries");
|
builder.startObject("primaries");
|
||||||
indexStats.getPrimaries().toXContent(builder, params);
|
indexStats.getPrimaries().toXContent(builder, params);
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class UpgradeStatusResponse extends BroadcastResponse implements ToXConte
|
||||||
if (outputIndices) {
|
if (outputIndices) {
|
||||||
builder.startObject(Fields.INDICES);
|
builder.startObject(Fields.INDICES);
|
||||||
for (IndexUpgradeStatus indexUpgradeStatus : getIndices().values()) {
|
for (IndexUpgradeStatus indexUpgradeStatus : getIndices().values()) {
|
||||||
builder.startObject(indexUpgradeStatus.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexUpgradeStatus.getIndex());
|
||||||
|
|
||||||
builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, indexUpgradeStatus.getTotalBytes());
|
builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, indexUpgradeStatus.getTotalBytes());
|
||||||
builder.byteSizeField(Fields.SIZE_TO_UPGRADE_IN_BYTES, Fields.SIZE_TO_UPGRADE, indexUpgradeStatus.getToUpgradeBytes());
|
builder.byteSizeField(Fields.SIZE_TO_UPGRADE_IN_BYTES, Fields.SIZE_TO_UPGRADE, indexUpgradeStatus.getToUpgradeBytes());
|
||||||
|
|
|
@ -427,7 +427,7 @@ public class ClusterState implements ToXContent, Diffable<ClusterState> {
|
||||||
builder.startObject("templates");
|
builder.startObject("templates");
|
||||||
for (ObjectCursor<IndexTemplateMetaData> cursor : metaData().templates().values()) {
|
for (ObjectCursor<IndexTemplateMetaData> cursor : metaData().templates().values()) {
|
||||||
IndexTemplateMetaData templateMetaData = cursor.value;
|
IndexTemplateMetaData templateMetaData = cursor.value;
|
||||||
builder.startObject(templateMetaData.name(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(templateMetaData.name());
|
||||||
|
|
||||||
builder.field("template", templateMetaData.template());
|
builder.field("template", templateMetaData.template());
|
||||||
builder.field("order", templateMetaData.order());
|
builder.field("order", templateMetaData.order());
|
||||||
|
@ -458,7 +458,7 @@ public class ClusterState implements ToXContent, Diffable<ClusterState> {
|
||||||
|
|
||||||
builder.startObject("indices");
|
builder.startObject("indices");
|
||||||
for (IndexMetaData indexMetaData : metaData()) {
|
for (IndexMetaData indexMetaData : metaData()) {
|
||||||
builder.startObject(indexMetaData.getIndex().getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexMetaData.getIndex().getName());
|
||||||
|
|
||||||
builder.field("state", indexMetaData.getState().toString().toLowerCase(Locale.ENGLISH));
|
builder.field("state", indexMetaData.getState().toString().toLowerCase(Locale.ENGLISH));
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ public class ClusterState implements ToXContent, Diffable<ClusterState> {
|
||||||
builder.startObject("routing_table");
|
builder.startObject("routing_table");
|
||||||
builder.startObject("indices");
|
builder.startObject("indices");
|
||||||
for (IndexRoutingTable indexRoutingTable : routingTable()) {
|
for (IndexRoutingTable indexRoutingTable : routingTable()) {
|
||||||
builder.startObject(indexRoutingTable.getIndex().getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexRoutingTable.getIndex().getName());
|
||||||
builder.startObject("shards");
|
builder.startObject("shards");
|
||||||
for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
|
for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
|
||||||
builder.startArray(Integer.toString(indexShardRoutingTable.shardId().id()));
|
builder.startArray(Integer.toString(indexShardRoutingTable.shardId().id()));
|
||||||
|
@ -549,7 +549,7 @@ public class ClusterState implements ToXContent, Diffable<ClusterState> {
|
||||||
|
|
||||||
builder.startObject("nodes");
|
builder.startObject("nodes");
|
||||||
for (RoutingNode routingNode : getRoutingNodes()) {
|
for (RoutingNode routingNode : getRoutingNodes()) {
|
||||||
builder.startArray(routingNode.nodeId() == null ? "null" : routingNode.nodeId(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startArray(routingNode.nodeId() == null ? "null" : routingNode.nodeId());
|
||||||
for (ShardRouting shardRouting : routingNode) {
|
for (ShardRouting shardRouting : routingNode) {
|
||||||
shardRouting.toXContent(builder, params);
|
shardRouting.toXContent(builder, params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,7 +281,7 @@ public class AliasMetaData extends AbstractDiffable<AliasMetaData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toXContent(AliasMetaData aliasMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
public static void toXContent(AliasMetaData aliasMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
||||||
builder.startObject(aliasMetaData.alias(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(aliasMetaData.alias());
|
||||||
|
|
||||||
boolean binary = params.paramAsBoolean("binary", false);
|
boolean binary = params.paramAsBoolean("binary", false);
|
||||||
|
|
||||||
|
|
|
@ -908,7 +908,7 @@ public class IndexMetaData implements Diffable<IndexMetaData>, FromXContentBuild
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toXContent(IndexMetaData indexMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
public static void toXContent(IndexMetaData indexMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
||||||
builder.startObject(indexMetaData.getIndex().getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexMetaData.getIndex().getName());
|
||||||
|
|
||||||
builder.field(KEY_VERSION, indexMetaData.getVersion());
|
builder.field(KEY_VERSION, indexMetaData.getVersion());
|
||||||
builder.field(KEY_STATE, indexMetaData.getState().toString().toLowerCase(Locale.ENGLISH));
|
builder.field(KEY_STATE, indexMetaData.getState().toString().toLowerCase(Locale.ENGLISH));
|
||||||
|
@ -936,7 +936,7 @@ public class IndexMetaData implements Diffable<IndexMetaData>, FromXContentBuild
|
||||||
builder.endArray();
|
builder.endArray();
|
||||||
|
|
||||||
for (ObjectObjectCursor<String, Custom> cursor : indexMetaData.getCustoms()) {
|
for (ObjectObjectCursor<String, Custom> cursor : indexMetaData.getCustoms()) {
|
||||||
builder.startObject(cursor.key, XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(cursor.key);
|
||||||
cursor.value.toXContent(builder, params);
|
cursor.value.toXContent(builder, params);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,7 +316,7 @@ public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaDat
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void toXContent(IndexTemplateMetaData indexTemplateMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
public static void toXContent(IndexTemplateMetaData indexTemplateMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
||||||
builder.startObject(indexTemplateMetaData.name(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexTemplateMetaData.name());
|
||||||
|
|
||||||
builder.field("order", indexTemplateMetaData.order());
|
builder.field("order", indexTemplateMetaData.order());
|
||||||
builder.field("template", indexTemplateMetaData.template());
|
builder.field("template", indexTemplateMetaData.template());
|
||||||
|
@ -352,7 +352,7 @@ public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaDat
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ObjectObjectCursor<String, IndexMetaData.Custom> cursor : indexTemplateMetaData.customs()) {
|
for (ObjectObjectCursor<String, IndexMetaData.Custom> cursor : indexTemplateMetaData.customs()) {
|
||||||
builder.startObject(cursor.key, XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(cursor.key);
|
||||||
cursor.value.toXContent(builder, params);
|
cursor.value.toXContent(builder, params);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class RepositoriesMetaData extends AbstractDiffable<Custom> implements Me
|
||||||
* @param params serialization parameters
|
* @param params serialization parameters
|
||||||
*/
|
*/
|
||||||
public static void toXContent(RepositoryMetaData repository, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
public static void toXContent(RepositoryMetaData repository, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
||||||
builder.startObject(repository.name(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(repository.name());
|
||||||
builder.field("type", repository.type());
|
builder.field("type", repository.type());
|
||||||
builder.startObject("settings");
|
builder.startObject("settings");
|
||||||
repository.settings().toXContent(builder, params);
|
repository.settings().toXContent(builder, params);
|
||||||
|
|
|
@ -335,7 +335,7 @@ public class DiscoveryNode implements Writeable<DiscoveryNode>, ToXContent {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(getId(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(getId());
|
||||||
builder.field("name", getName());
|
builder.field("name", getName());
|
||||||
builder.field("transport_address", getAddress().toString());
|
builder.field("transport_address", getAddress().toString());
|
||||||
|
|
||||||
|
|
|
@ -751,7 +751,7 @@ public final class Settings implements ToXContent {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
|
for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
|
||||||
builder.field(entry.getKey(), entry.getValue(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final class Fuzziness implements ToXContent, Writeable<Fuzziness> {
|
||||||
public static final Fuzziness ONE = new Fuzziness(1);
|
public static final Fuzziness ONE = new Fuzziness(1);
|
||||||
public static final Fuzziness TWO = new Fuzziness(2);
|
public static final Fuzziness TWO = new Fuzziness(2);
|
||||||
public static final Fuzziness AUTO = new Fuzziness("AUTO");
|
public static final Fuzziness AUTO = new Fuzziness("AUTO");
|
||||||
public static final ParseField FIELD = new ParseField(X_FIELD_NAME.camelCase().getValue());
|
public static final ParseField FIELD = new ParseField(X_FIELD_NAME.value());
|
||||||
|
|
||||||
private final String fuzziness;
|
private final String fuzziness;
|
||||||
|
|
||||||
|
|
|
@ -51,33 +51,12 @@ import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* A utility to build XContent (ie json).
|
||||||
*/
|
*/
|
||||||
public final class XContentBuilder implements BytesStream, Releasable {
|
public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
|
|
||||||
public enum FieldCaseConversion {
|
|
||||||
/**
|
|
||||||
* No conversion will occur.
|
|
||||||
*/
|
|
||||||
NONE,
|
|
||||||
/**
|
|
||||||
* Camel Case will be converted to Underscore casing.
|
|
||||||
*/
|
|
||||||
UNDERSCORE,
|
|
||||||
/**
|
|
||||||
* Underscore will be converted to Camel case.
|
|
||||||
*/
|
|
||||||
CAMELCASE
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static DateTimeFormatter defaultDatePrinter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
|
public final static DateTimeFormatter defaultDatePrinter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
|
||||||
|
|
||||||
protected static FieldCaseConversion globalFieldCaseConversion = FieldCaseConversion.NONE;
|
|
||||||
|
|
||||||
public static void globalFieldCaseConversion(FieldCaseConversion globalFieldCaseConversion) {
|
|
||||||
XContentBuilder.globalFieldCaseConversion = globalFieldCaseConversion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static XContentBuilder builder(XContent xContent) throws IOException {
|
public static XContentBuilder builder(XContent xContent) throws IOException {
|
||||||
return new XContentBuilder(xContent, new BytesStreamOutput());
|
return new XContentBuilder(xContent, new BytesStreamOutput());
|
||||||
}
|
}
|
||||||
|
@ -94,10 +73,6 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
|
|
||||||
private final OutputStream bos;
|
private final OutputStream bos;
|
||||||
|
|
||||||
private FieldCaseConversion fieldCaseConversion = globalFieldCaseConversion;
|
|
||||||
|
|
||||||
private StringBuilder cachedStringBuilder;
|
|
||||||
|
|
||||||
private boolean humanReadable = false;
|
private boolean humanReadable = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,11 +105,6 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
this.generator = xContent.createGenerator(bos, filters, inclusive);
|
this.generator = xContent.createGenerator(bos, filters, inclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentBuilder fieldCaseConversion(FieldCaseConversion fieldCaseConversion) {
|
|
||||||
this.fieldCaseConversion = fieldCaseConversion;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XContentType contentType() {
|
public XContentType contentType() {
|
||||||
return generator.contentType();
|
return generator.contentType();
|
||||||
}
|
}
|
||||||
|
@ -176,24 +146,12 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentBuilder startObject(String name, FieldCaseConversion conversion) throws IOException {
|
|
||||||
field(name, conversion);
|
|
||||||
startObject();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XContentBuilder startObject(XContentBuilderString name) throws IOException {
|
public XContentBuilder startObject(XContentBuilderString name) throws IOException {
|
||||||
field(name);
|
field(name);
|
||||||
startObject();
|
startObject();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentBuilder startObject(XContentBuilderString name, FieldCaseConversion conversion) throws IOException {
|
|
||||||
field(name, conversion);
|
|
||||||
startObject();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XContentBuilder startObject() throws IOException {
|
public XContentBuilder startObject() throws IOException {
|
||||||
generator.writeStartObject();
|
generator.writeStartObject();
|
||||||
return this;
|
return this;
|
||||||
|
@ -240,12 +198,6 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentBuilder startArray(String name, FieldCaseConversion conversion) throws IOException {
|
|
||||||
field(name, conversion);
|
|
||||||
startArray();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XContentBuilder startArray(String name) throws IOException {
|
public XContentBuilder startArray(String name) throws IOException {
|
||||||
field(name);
|
field(name);
|
||||||
startArray();
|
startArray();
|
||||||
|
@ -269,39 +221,13 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentBuilder field(XContentBuilderString name) throws IOException {
|
public XContentBuilder field(XContentBuilderString name) throws IOException {
|
||||||
return field(name, fieldCaseConversion);
|
return field(name.value());
|
||||||
}
|
|
||||||
|
|
||||||
public XContentBuilder field(XContentBuilderString name, FieldCaseConversion conversion) throws IOException {
|
|
||||||
if (conversion == FieldCaseConversion.UNDERSCORE) {
|
|
||||||
generator.writeFieldName(name.underscore());
|
|
||||||
} else if (conversion == FieldCaseConversion.CAMELCASE) {
|
|
||||||
generator.writeFieldName(name.camelCase());
|
|
||||||
} else {
|
|
||||||
generator.writeFieldName(name.underscore());
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentBuilder field(String name) throws IOException {
|
public XContentBuilder field(String name) throws IOException {
|
||||||
return field(name, fieldCaseConversion);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XContentBuilder field(String name, FieldCaseConversion conversion) throws IOException {
|
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw new IllegalArgumentException("field name cannot be null");
|
throw new IllegalArgumentException("field name cannot be null");
|
||||||
}
|
}
|
||||||
if (conversion == FieldCaseConversion.UNDERSCORE) {
|
|
||||||
if (cachedStringBuilder == null) {
|
|
||||||
cachedStringBuilder = new StringBuilder();
|
|
||||||
}
|
|
||||||
name = Strings.toUnderscoreCase(name, cachedStringBuilder);
|
|
||||||
} else if (conversion == FieldCaseConversion.CAMELCASE) {
|
|
||||||
if (cachedStringBuilder == null) {
|
|
||||||
cachedStringBuilder = new StringBuilder();
|
|
||||||
}
|
|
||||||
name = Strings.toCamelCase(name, cachedStringBuilder);
|
|
||||||
}
|
|
||||||
generator.writeFieldName(name);
|
generator.writeFieldName(name);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -336,16 +262,6 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentBuilder field(String name, String value, FieldCaseConversion conversion) throws IOException {
|
|
||||||
field(name, conversion);
|
|
||||||
if (value == null) {
|
|
||||||
generator.writeNull();
|
|
||||||
} else {
|
|
||||||
generator.writeString(value);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XContentBuilder field(XContentBuilderString name, String value) throws IOException {
|
public XContentBuilder field(XContentBuilderString name, String value) throws IOException {
|
||||||
field(name);
|
field(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -356,16 +272,6 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentBuilder field(XContentBuilderString name, String value, FieldCaseConversion conversion) throws IOException {
|
|
||||||
field(name, conversion);
|
|
||||||
if (value == null) {
|
|
||||||
generator.writeNull();
|
|
||||||
} else {
|
|
||||||
generator.writeString(value);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XContentBuilder field(String name, Integer value) throws IOException {
|
public XContentBuilder field(String name, Integer value) throws IOException {
|
||||||
field(name);
|
field(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
|
@ -19,27 +19,18 @@
|
||||||
|
|
||||||
package org.elasticsearch.common.xcontent;
|
package org.elasticsearch.common.xcontent;
|
||||||
|
|
||||||
import org.elasticsearch.common.Strings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* TODO: remove this, it is just a wrapper that is no longer needed
|
||||||
*/
|
*/
|
||||||
public class XContentBuilderString {
|
public class XContentBuilderString {
|
||||||
|
|
||||||
private final XContentString underscore;
|
private final String value;
|
||||||
|
|
||||||
private final XContentString camelCase;
|
|
||||||
|
|
||||||
public XContentBuilderString(String value) {
|
public XContentBuilderString(String value) {
|
||||||
underscore = new XContentString(Strings.toUnderscoreCase(value));
|
this.value = value;
|
||||||
camelCase = new XContentString(Strings.toCamelCase(value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public XContentString underscore() {
|
public String value() {
|
||||||
return underscore;
|
return value;
|
||||||
}
|
|
||||||
|
|
||||||
public XContentString camelCase() {
|
|
||||||
return camelCase;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class FieldDataStats implements Streamable, ToXContent {
|
||||||
final long[] values = fields.values;
|
final long[] values = fields.values;
|
||||||
for (int i = 0; i < keys.length; i++) {
|
for (int i = 0; i < keys.length; i++) {
|
||||||
if (keys[i] != null) {
|
if (keys[i] != null) {
|
||||||
builder.startObject((String) keys[i], XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject((String) keys[i]);
|
||||||
builder.byteSizeField(Fields.MEMORY_SIZE_IN_BYTES, Fields.MEMORY_SIZE, values[i]);
|
builder.byteSizeField(Fields.MEMORY_SIZE_IN_BYTES, Fields.MEMORY_SIZE, values[i]);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ public class SearchStats implements Streamable, ToXContent {
|
||||||
if (groupStats != null && !groupStats.isEmpty()) {
|
if (groupStats != null && !groupStats.isEmpty()) {
|
||||||
builder.startObject(Fields.GROUPS);
|
builder.startObject(Fields.GROUPS);
|
||||||
for (Map.Entry<String, Stats> entry : groupStats.entrySet()) {
|
for (Map.Entry<String, Stats> entry : groupStats.entrySet()) {
|
||||||
builder.startObject(entry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(entry.getKey());
|
||||||
entry.getValue().toXContent(builder, params);
|
entry.getValue().toXContent(builder, params);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ public class IndexingStats implements Streamable, ToXContent {
|
||||||
if (typeStats != null && !typeStats.isEmpty()) {
|
if (typeStats != null && !typeStats.isEmpty()) {
|
||||||
builder.startObject(Fields.TYPES);
|
builder.startObject(Fields.TYPES);
|
||||||
for (Map.Entry<String, Stats> entry : typeStats.entrySet()) {
|
for (Map.Entry<String, Stats> entry : typeStats.entrySet()) {
|
||||||
builder.startObject(entry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(entry.getKey());
|
||||||
entry.getValue().toXContent(builder, params);
|
entry.getValue().toXContent(builder, params);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
|
||||||
// Then we list all snapshots with list of all blobs that are used by the snapshot
|
// Then we list all snapshots with list of all blobs that are used by the snapshot
|
||||||
builder.startObject(Fields.SNAPSHOTS);
|
builder.startObject(Fields.SNAPSHOTS);
|
||||||
for (SnapshotFiles snapshot : shardSnapshots) {
|
for (SnapshotFiles snapshot : shardSnapshots) {
|
||||||
builder.startObject(snapshot.snapshot(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(snapshot.snapshot());
|
||||||
builder.startArray(Fields.FILES);
|
builder.startArray(Fields.FILES);
|
||||||
for (FileInfo fileInfo : snapshot.indexFiles()) {
|
for (FileInfo fileInfo : snapshot.indexFiles()) {
|
||||||
builder.value(fileInfo.name());
|
builder.value(fileInfo.name());
|
||||||
|
|
|
@ -166,13 +166,13 @@ public class FsInfo implements Iterable<FsInfo.Path>, Streamable, ToXContent {
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
builder.field(Fields.PATH, path, XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(Fields.PATH, path);
|
||||||
}
|
}
|
||||||
if (mount != null) {
|
if (mount != null) {
|
||||||
builder.field(Fields.MOUNT, mount, XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(Fields.MOUNT, mount);
|
||||||
}
|
}
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
builder.field(Fields.TYPE, type, XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(Fields.TYPE, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total != -1) {
|
if (total != -1) {
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class JvmStats implements Streamable, ToXContent {
|
||||||
|
|
||||||
builder.startObject(Fields.POOLS);
|
builder.startObject(Fields.POOLS);
|
||||||
for (MemoryPool pool : mem) {
|
for (MemoryPool pool : mem) {
|
||||||
builder.startObject(pool.getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(pool.getName());
|
||||||
builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, pool.used);
|
builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, pool.used);
|
||||||
builder.byteSizeField(Fields.MAX_IN_BYTES, Fields.MAX, pool.max);
|
builder.byteSizeField(Fields.MAX_IN_BYTES, Fields.MAX, pool.max);
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ public class JvmStats implements Streamable, ToXContent {
|
||||||
|
|
||||||
builder.startObject(Fields.COLLECTORS);
|
builder.startObject(Fields.COLLECTORS);
|
||||||
for (GarbageCollector collector : gc) {
|
for (GarbageCollector collector : gc) {
|
||||||
builder.startObject(collector.getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(collector.getName());
|
||||||
builder.field(Fields.COLLECTION_COUNT, collector.getCollectionCount());
|
builder.field(Fields.COLLECTION_COUNT, collector.getCollectionCount());
|
||||||
builder.timeValueField(Fields.COLLECTION_TIME_IN_MILLIS, Fields.COLLECTION_TIME, collector.collectionTime);
|
builder.timeValueField(Fields.COLLECTION_TIME_IN_MILLIS, Fields.COLLECTION_TIME, collector.collectionTime);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
@ -232,7 +232,7 @@ public class JvmStats implements Streamable, ToXContent {
|
||||||
if (bufferPools != null) {
|
if (bufferPools != null) {
|
||||||
builder.startObject(Fields.BUFFER_POOLS);
|
builder.startObject(Fields.BUFFER_POOLS);
|
||||||
for (BufferPool bufferPool : bufferPools) {
|
for (BufferPool bufferPool : bufferPools) {
|
||||||
builder.startObject(bufferPool.getName(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(bufferPool.getName());
|
||||||
builder.field(Fields.COUNT, bufferPool.getCount());
|
builder.field(Fields.COUNT, bufferPool.getCount());
|
||||||
builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, bufferPool.used);
|
builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, bufferPool.used);
|
||||||
builder.byteSizeField(Fields.TOTAL_CAPACITY_IN_BYTES, Fields.TOTAL_CAPACITY, bufferPool.totalCapacity);
|
builder.byteSizeField(Fields.TOTAL_CAPACITY_IN_BYTES, Fields.TOTAL_CAPACITY, bufferPool.totalCapacity);
|
||||||
|
|
|
@ -71,15 +71,6 @@ public abstract class AbstractRestChannel implements RestChannel {
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.humanReadable(request.paramAsBoolean("human", builder.humanReadable()));
|
builder.humanReadable(request.paramAsBoolean("human", builder.humanReadable()));
|
||||||
|
|
||||||
String casing = request.param("case");
|
|
||||||
if (casing != null && "camelCase".equals(casing)) {
|
|
||||||
builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
|
|
||||||
} else {
|
|
||||||
// we expect all REST interfaces to write results in underscore casing, so
|
|
||||||
// no need for double casing
|
|
||||||
builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.NONE);
|
|
||||||
}
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class RestGetAliasesAction extends BaseRestHandler {
|
||||||
|
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
for (ObjectObjectCursor<String, List<AliasMetaData>> entry : response.getAliases()) {
|
for (ObjectObjectCursor<String, List<AliasMetaData>> entry : response.getAliases()) {
|
||||||
builder.startObject(entry.key, XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(entry.key);
|
||||||
builder.startObject(Fields.ALIASES);
|
builder.startObject(Fields.ALIASES);
|
||||||
for (AliasMetaData alias : entry.value) {
|
for (AliasMetaData alias : entry.value) {
|
||||||
AliasMetaData.Builder.toXContent(alias, builder, ToXContent.EMPTY_PARAMS);
|
AliasMetaData.Builder.toXContent(alias, builder, ToXContent.EMPTY_PARAMS);
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class RestGetMappingAction extends BaseRestHandler {
|
||||||
if (indexEntry.value.isEmpty()) {
|
if (indexEntry.value.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
builder.startObject(indexEntry.key, XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexEntry.key);
|
||||||
builder.startObject(Fields.MAPPINGS);
|
builder.startObject(Fields.MAPPINGS);
|
||||||
for (ObjectObjectCursor<String, MappingMetaData> typeEntry : indexEntry.value) {
|
for (ObjectObjectCursor<String, MappingMetaData> typeEntry : indexEntry.value) {
|
||||||
builder.field(typeEntry.key);
|
builder.field(typeEntry.key);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class RestGetSettingsAction extends BaseRestHandler {
|
||||||
if (cursor.value.getAsMap().isEmpty()) {
|
if (cursor.value.getAsMap().isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
builder.startObject(cursor.key, XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(cursor.key);
|
||||||
builder.startObject("settings");
|
builder.startObject("settings");
|
||||||
cursor.value.toXContent(builder, request);
|
cursor.value.toXContent(builder, request);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class RestUpgradeAction extends BaseRestHandler {
|
||||||
buildBroadcastShardsHeader(builder, request, response);
|
buildBroadcastShardsHeader(builder, request, response);
|
||||||
builder.startObject("upgraded_indices");
|
builder.startObject("upgraded_indices");
|
||||||
for (Map.Entry<String, Tuple<Version, String>> entry : response.versions().entrySet()) {
|
for (Map.Entry<String, Tuple<Version, String>> entry : response.versions().entrySet()) {
|
||||||
builder.startObject(entry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(entry.getKey());
|
||||||
builder.field("upgrade_version", entry.getValue().v1());
|
builder.field("upgrade_version", entry.getValue().v1());
|
||||||
builder.field("oldest_lucene_segment_version", entry.getValue().v2());
|
builder.field("oldest_lucene_segment_version", entry.getValue().v2());
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class RestValidateQueryAction extends BaseRestHandler {
|
||||||
for (QueryExplanation explanation : response.getQueryExplanation()) {
|
for (QueryExplanation explanation : response.getQueryExplanation()) {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
if (explanation.getIndex() != null) {
|
if (explanation.getIndex() != null) {
|
||||||
builder.field(INDEX_FIELD, explanation.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.field(INDEX_FIELD, explanation.getIndex());
|
||||||
}
|
}
|
||||||
builder.field(VALID_FIELD, explanation.isValid());
|
builder.field(VALID_FIELD, explanation.isValid());
|
||||||
if (explanation.getError() != null) {
|
if (explanation.getError() != null) {
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class CompletionStats implements Streamable, ToXContent {
|
||||||
final long[] values = fields.values;
|
final long[] values = fields.values;
|
||||||
for (int i = 0; i < keys.length; i++) {
|
for (int i = 0; i < keys.length; i++) {
|
||||||
if (keys[i] != null) {
|
if (keys[i] != null) {
|
||||||
builder.startObject((String) keys[i], XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject((String) keys[i]);
|
||||||
builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, values[i]);
|
builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, values[i]);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -889,7 +889,7 @@ public class ThreadPool extends AbstractComponent implements Closeable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(name, XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(name);
|
||||||
builder.field(Fields.TYPE, type.getType());
|
builder.field(Fields.TYPE, type.getType());
|
||||||
if (min != -1) {
|
if (min != -1) {
|
||||||
builder.field(Fields.MIN, min);
|
builder.field(Fields.MIN, min);
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(name, XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(name);
|
||||||
if (threads != -1) {
|
if (threads != -1) {
|
||||||
builder.field(Fields.THREADS, threads);
|
builder.field(Fields.THREADS, threads);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,6 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentBuilder.FieldCaseConversion.CAMELCASE;
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentBuilder.FieldCaseConversion.UNDERSCORE;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class XContentBuilderTests extends ESTestCase {
|
public class XContentBuilderTests extends ESTestCase {
|
||||||
|
@ -169,16 +167,6 @@ public class XContentBuilderTests extends ESTestCase {
|
||||||
assertThat(sData, equalTo("{\"name\":\"something\", source : { test : \"value\" },\"name2\":\"something2\"}"));
|
assertThat(sData, equalTo("{\"name\":\"something\", source : { test : \"value\" },\"name2\":\"something2\"}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFieldCaseConversion() throws Exception {
|
|
||||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).fieldCaseConversion(CAMELCASE);
|
|
||||||
builder.startObject().field("test_name", "value").endObject();
|
|
||||||
assertThat(builder.string(), equalTo("{\"testName\":\"value\"}"));
|
|
||||||
|
|
||||||
builder = XContentFactory.contentBuilder(XContentType.JSON).fieldCaseConversion(UNDERSCORE);
|
|
||||||
builder.startObject().field("testName", "value").endObject();
|
|
||||||
assertThat(builder.string(), equalTo("{\"test_name\":\"value\"}"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testByteConversion() throws Exception {
|
public void testByteConversion() throws Exception {
|
||||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||||
builder.startObject().field("test_name", (Byte)(byte)120).endObject();
|
builder.startObject().field("test_name", (Byte)(byte)120).endObject();
|
||||||
|
|
Loading…
Reference in New Issue