Package org.xbib.elasticsearch.rest

Examples of org.xbib.elasticsearch.rest.XContentThrowableRestResponse


    @Override
    public void handleRequest(final RestRequest request, final RestChannel channel, Client client) {
        String subscriberId = request.hasParam("subscriber") ? request.param("subscriber") : null;
        if (subscriberId == null) {
            try {
                channel.sendResponse(new XContentThrowableRestResponse(request, new IllegalArgumentException("no subscriber")));
            } catch (IOException e) {
                logger.error("error while sending failure response", e);
            }
            return;
        }
        try {
            client.prepareDelete(pubSubIndexName, "subscribe", subscriberId)
                    .execute(new ActionListener<DeleteResponse>() {
                        @Override
                        public void onResponse(DeleteResponse response) {
                            try {
                                XContentBuilder builder = restContentBuilder(request);
                                builder.startObject().field("ok", true).field("id", response.getId()).endObject();
                                channel.sendResponse(new XContentRestResponse(request, OK, builder));
                            } catch (Exception e) {
                                onFailure(e);
                            }
                        }

                        @Override
                        public void onFailure(Throwable e) {
                            try {
                                logger.error("error while processing unsubscribe request", e);
                                channel.sendResponse(new XContentThrowableRestResponse(request, e));
                            } catch (IOException e1) {
                                logger.error("error while sending error response", e1);
                            }
                        }
                    });
View Full Code Here


                        @Override
                        public void onFailure(Throwable e) {
                            try {
                                logger.error("Error processing publish request", e);
                                channel.sendResponse(new XContentThrowableRestResponse(request, e));
                            } catch (IOException e1) {
                                logger.error("Failed to send failure response", e1);
                            }
                        }
                    });
View Full Code Here

TOP

Related Classes of org.xbib.elasticsearch.rest.XContentThrowableRestResponse

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.