Package org.elasticsearch.rest

Examples of org.elasticsearch.rest.BytesRestResponse


                    }
                    builder.endObject();
                }
                builder.endArray();
                builder.endObject();
                return new BytesRestResponse(RestStatus.OK, builder);
            }
        });
    }
View Full Code Here


        if (log) {
          logRequest(request);
        }
        // allow health check even without authorization
        if (healthCheck(request)) {
            channel.sendResponse(new BytesRestResponse(OK, "{\"OK\":{}}"));
        } else if (authorized(request)) {
            super.internalDispatchRequest(request, channel);
        } else {
          logUnAuthorizedRequest(request);
          BytesRestResponse response = new BytesRestResponse(UNAUTHORIZED, "Authentication Required");
          response.addHeader("WWW-Authenticate", "Basic realm=\"Restricted\"");
          channel.sendResponse(response);
        }
    }
View Full Code Here

    } catch (IOException e) {
      logger.error("Error writing JavaBin response", e);
    }

    // send the response
    channel.sendResponse(new BytesRestResponse(bo.toByteArray(), contentTypeOctet));
  }
View Full Code Here

    } catch (IOException e) {
      logger.error("Error writing XML response", e);
    }

    // send the response
    channel.sendResponse(new BytesRestResponse(writer.toString().getBytes(), contentTypeXml));
  }
View Full Code Here

    private void list(RestRequest request, RestChannel channel, Client esClient) {
        try {
            Map<String, Object> rivers = getRivers(request.paramAsInt("page", 1), request.paramAsInt("count", 10), esClient);
            XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
            builder.value(rivers);
            channel.sendResponse(new BytesRestResponse(RestStatus.OK, builder));
        } catch (Throwable e) {
            errorResponse(request, channel, e);
        }
    }
View Full Code Here

        try {
            XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
            builder.startObject();
            builder.field("success", true);
            builder.endObject();
            channel.sendResponse(new BytesRestResponse(status, builder));
        } catch (IOException e) {
            errorResponse(request, channel, e);
        }
    }
View Full Code Here

            XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
            builder.startObject();
            builder.field("success", false);
            builder.field("error", error);
            builder.endObject();
            channel.sendResponse(new BytesRestResponse(status, builder));
        } catch (IOException e) {
            errorResponse(request, channel, e);
        }
    }
View Full Code Here

                    builder.byteSizeField(SIZE_TO_UPGRADE_IN_BYTES, SIZE_TO_UPGRADE, summary.v2());
                    builder.endObject();
                }
               
                builder.endObject();
                return new BytesRestResponse(OK, builder);
            }
        });
    }
View Full Code Here

            @Override
            public RestResponse buildResponse(OptimizeResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
                buildBroadcastShardsHeader(builder, response);
                builder.endObject();
                return new BytesRestResponse(OK, builder);
            }
        });
    }
View Full Code Here

    protected abstract void processResponse(Response response) throws Exception;

    @Override
    public final void onFailure(Throwable e) {
        try {
            channel.sendResponse(new BytesRestResponse(channel, e));
        } catch (Throwable e1) {
            logger.error("failed to send failure response", e1);
        }
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.rest.BytesRestResponse

Copyright © 2018 www.massapicom. 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.