Examples of XContentRestResponse


Examples of org.elasticsearch.rest.XContentRestResponse

                searchScrollRequest.operationThreading(operationThreading);
            }
        } catch (Exception e) {
            try {
                XContentBuilder builder = restContentBuilder(request);
                channel.sendResponse(new XContentRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
            } catch (IOException e1) {
                logger.error("Failed to send failure response", e1);
            }
            return;
        }

        client.searchScroll(searchScrollRequest, new ActionListener<SearchResponse>() {
            @Override public void onResponse(SearchResponse response) {
                try {
                    XContentBuilder builder = restContentBuilder(request);
                    builder.startObject();
                    response.toXContent(builder, request);
                    builder.endObject();
                    channel.sendResponse(new XContentRestResponse(request, response.status(), builder));
                } catch (Exception e) {
                    onFailure(e);
                }
            }
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

            countRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE));
            countRequest.types(splitTypes(request.param("type")));
        } catch (Exception e) {
            try {
                XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
                channel.sendResponse(new XContentRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
            } catch (IOException e1) {
                logger.error("Failed to send failure response", e1);
            }
            return;
        }

        client.count(countRequest, new ActionListener<CountResponse>() {
            @Override public void onResponse(CountResponse response) {
                try {
                    XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
                    builder.startObject();
                    builder.field("count", response.count());

                    buildBroadcastShardsHeader(builder, response);

                    builder.endObject();
                    channel.sendResponse(new XContentRestResponse(request, OK, builder));
                } catch (Exception e) {
                    onFailure(e);
                }
            }
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

            if (logger.isDebugEnabled()) {
                logger.debug("failed to parse search request parameters", e);
            }
            try {
                XContentBuilder builder = restContentBuilder(request);
                channel.sendResponse(new XContentRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
            } catch (IOException e1) {
                logger.error("Failed to send failure response", e1);
            }
            return;
        }
        client.search(searchRequest, new ActionListener<SearchResponse>() {
            @Override public void onResponse(SearchResponse response) {
                try {
                    XContentBuilder builder = restContentBuilder(request);
                    builder.startObject();
                    response.toXContent(builder, request);
                    builder.endObject();
                    channel.sendResponse(new XContentRestResponse(request, response.status(), builder));
                } catch (Exception e) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("failed to execute search (building response)", e);
                    }
                    onFailure(e);
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

                deleteByQueryRequest.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
            }
        } catch (Exception e) {
            try {
                XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
                channel.sendResponse(new XContentRestResponse(request, PRECONDITION_FAILED, builder.startObject().field("error", e.getMessage()).endObject()));
            } catch (IOException e1) {
                logger.error("Failed to send failure response", e1);
            }
            return;
        }
        client.deleteByQuery(deleteByQueryRequest, new ActionListener<DeleteByQueryResponse>() {
            @Override public void onResponse(DeleteByQueryResponse result) {
                try {
                    XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
                    builder.startObject().field("ok", true);

                    builder.startObject("_indices");
                    for (IndexDeleteByQueryResponse indexDeleteByQueryResponse : result.indices().values()) {
                        builder.startObject(indexDeleteByQueryResponse.index());

                        builder.startObject("_shards");
                        builder.field("total", indexDeleteByQueryResponse.totalShards());
                        builder.field("successful", indexDeleteByQueryResponse.successfulShards());
                        builder.field("failed", indexDeleteByQueryResponse.failedShards());
                        builder.endObject();

                        builder.endObject();
                    }
                    builder.endObject();

                    builder.endObject();
                    channel.sendResponse(new XContentRestResponse(request, OK, builder));
                } catch (Exception e) {
                    onFailure(e);
                }
            }
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

                }
            }
        } catch (Exception e) {
            try {
                XContentBuilder builder = restContentBuilder(request);
                channel.sendResponse(new XContentRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
            } catch (IOException e1) {
                logger.error("Failed to send failure response", e1);
            }
            return;
        }

        client.moreLikeThis(mltRequest, new ActionListener<SearchResponse>() {
            @Override public void onResponse(SearchResponse response) {
                try {
                    XContentBuilder builder = restContentBuilder(request);
                    builder.startObject();
                    response.toXContent(builder, request);
                    builder.endObject();
                    channel.sendResponse(new XContentRestResponse(request, OK, builder));
                } catch (Exception e) {
                    onFailure(e);
                }
            }
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

        try {
            multiGetRequest.add(request.param("index"), request.param("type"), request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength());
        } catch (Exception e) {
            try {
                XContentBuilder builder = restContentBuilder(request);
                channel.sendResponse(new XContentRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
            } catch (IOException e1) {
                logger.error("Failed to send failure response", e1);
            }
            return;
        }

        client.multiGet(multiGetRequest, new ActionListener<MultiGetResponse>() {
            @Override public void onResponse(MultiGetResponse response) {
                try {
                    XContentBuilder builder = restContentBuilder(request);
                    response.toXContent(builder, request);
                    channel.sendResponse(new XContentRestResponse(request, OK, builder));
                } catch (Exception e) {
                    onFailure(e);
                }
            }
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

              XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
              builder.startObject();
              builder.field("jira_river_names", allRivers);
              builder.endObject();
              restChannel.sendResponse(new XContentRestResponse(restRequest, RestStatus.OK, builder));
            } catch (Exception e) {
              onFailure(e);
            }
          }
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

            new JRMgmBaseActionListener<JRLifecycleRequest, JRLifecycleResponse, NodeJRLifecycleResponse>(
                actionRequest, restRequest, restChannel) {

              @Override
              protected void handleJiraRiverResponse(NodeJRLifecycleResponse nodeInfo) throws Exception {
                restChannel.sendResponse(new XContentRestResponse(restRequest, OK, buildMessageDocument(restRequest,
                    "Command successful")));
              }

            });
  }
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

                restRequest, restChannel) {

              @Override
              protected void handleJiraRiverResponse(NodeFullUpdateResponse nodeInfo) throws Exception {
                if (actionRequest.isProjectKeyRequest() && !nodeInfo.projectFound) {
                  restChannel.sendResponse(new XContentRestResponse(restRequest, RestStatus.NOT_FOUND,
                      buildMessageDocument(restRequest, "Project '" + projectKey
                          + "' is not indexed by JiraRiver with name: " + riverName)));
                } else {
                  restChannel.sendResponse(new XContentRestResponse(restRequest, OK, buildMessageDocument(restRequest,
                      "Scheduled full reindex for JIRA projects: " + nodeInfo.reindexedProjectNames)));
                }
              }

            });
View Full Code Here

Examples of org.elasticsearch.rest.XContentRestResponse

  @Override
  public void onResponse(Response response) {
    try {
      NodeResponse nodeInfo = response.getSuccessNodeResponse();
      if (nodeInfo == null) {
        restChannel.sendResponse(new XContentRestResponse(restRequest, RestStatus.NOT_FOUND, buildMessageDocument(
            restRequest, "No JiraRiver found for name: " + actionRequest.getRiverName())));
      } else {
        handleJiraRiverResponse(nodeInfo);
      }
    } catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.