update rest status

This commit is contained in:
Tal Levy 2015-11-05 16:23:30 -08:00
parent bce7f6c7ad
commit 1f29fa4fe9
3 changed files with 10 additions and 5 deletions

View File

@ -39,7 +39,6 @@ public class IngestModule extends AbstractModule {
protected void configure() { protected void configure() {
binder().bind(IngestRestFilter.class).asEagerSingleton(); binder().bind(IngestRestFilter.class).asEagerSingleton();
binder().bind(PipelineExecutionService.class).asEagerSingleton(); binder().bind(PipelineExecutionService.class).asEagerSingleton();
// TODO(talevy): write it! binder().bind(PipelineSimulateService.class).asEagerSingleton();
binder().bind(PipelineStore.class).asEagerSingleton(); binder().bind(PipelineStore.class).asEagerSingleton();
binder().bind(PipelineStoreClient.class).asEagerSingleton(); binder().bind(PipelineStoreClient.class).asEagerSingleton();

View File

@ -23,10 +23,7 @@ import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.StatusToXContent; import org.elasticsearch.common.xcontent.StatusToXContent;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.ingest.Data;
import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.RestStatus;
import java.io.IOException; import java.io.IOException;
@ -91,6 +88,11 @@ public class SimulatePipelineResponse extends ActionResponse implements StatusTo
@Override @Override
public RestStatus status() { public RestStatus status() {
for (SimulatedItemResponse response : responses) {
if (response.failed()) {
return response.status();
}
}
return RestStatus.OK; return RestStatus.OK;
} }
} }

View File

@ -102,7 +102,11 @@ public class SimulatedItemResponse implements Streamable, StatusToXContent {
@Override @Override
public RestStatus status() { public RestStatus status() {
return null; if (failed()) {
return RestStatus.BAD_REQUEST;
} else {
return RestStatus.OK;
}
} }
@Override @Override