Skip to content

Commit

Permalink
Remove use of a Fields class in snapshot responses that contains
Browse files Browse the repository at this point in the history
x-content keys, in favor of declaring/using the keys directly.

Closes #18497
  • Loading branch information
Ali Beyad committed May 20, 2016
1 parent 35e7058 commit 923d90d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
Expand Up @@ -81,18 +81,13 @@ public RestStatus status() {
return snapshotInfo.status();
}

static final class Fields {
static final String SNAPSHOT = "snapshot";
static final String ACCEPTED = "accepted";
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (snapshotInfo != null) {
builder.field(Fields.SNAPSHOT);
builder.field("snapshot");
snapshotInfo.toExternalXContent(builder, params);
} else {
builder.field(Fields.ACCEPTED, true);
builder.field("accepted", true);
}
return builder;
}
Expand Down
Expand Up @@ -74,13 +74,9 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

static final class Fields {
static final String SNAPSHOTS = "snapshots";
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.startArray(Fields.SNAPSHOTS);
builder.startArray("snapshots");
for (SnapshotInfo snapshotInfo : snapshots) {
snapshotInfo.toExternalXContent(builder, params);
}
Expand Down
Expand Up @@ -73,18 +73,13 @@ public RestStatus status() {
return restoreInfo.status();
}

static final class Fields {
static final String SNAPSHOT = "snapshot";
static final String ACCEPTED = "accepted";
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
if (restoreInfo != null) {
builder.field(Fields.SNAPSHOT);
builder.field("snapshot");
restoreInfo.toXContent(builder, params);
} else {
builder.field(Fields.ACCEPTED, true);
builder.field("accepted", true);
}
return builder;
}
Expand Down
Expand Up @@ -73,13 +73,9 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

static final class Fields {
static final String SNAPSHOTS = "snapshots";
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startArray(Fields.SNAPSHOTS);
builder.startArray("snapshots");
for (SnapshotStatus snapshot : snapshots) {
snapshot.toXContent(builder, params);
}
Expand Down

0 comments on commit 923d90d

Please sign in to comment.