// Path: src/main/java/org/xbib/elasticsearch/helper/client/http/HttpAction.java
// public abstract class HttpAction<Request extends ActionRequest, Response extends ActionResponse> extends AbstractComponent {
// 
//     protected final String actionName;
//     protected final ParseFieldMatcher parseFieldMatcher;
// 
//     protected HttpAction(Settings settings, String actionName) {
//         super(settings);
//         this.actionName = actionName;
//         this.parseFieldMatcher = new ParseFieldMatcher(settings);
//     }
// 
//     public final ActionFuture<Response> execute(HttpInvocationContext<Request,Response> httpInvocationContext, Request request) {
//         PlainActionFuture<Response> future = newFuture();
//         execute(httpInvocationContext, future);
//         return future;
//     }
// 
//     public final void execute(HttpInvocationContext<Request,Response> httpInvocationContext, ActionListener<Response> listener) {
//         ActionRequestValidationException validationException = httpInvocationContext.getRequest().validate();
//         if (validationException != null) {
//             listener.onFailure(validationException);
//             return;
//         }
//         httpInvocationContext.setListener(listener);
//         httpInvocationContext.setMillis(System.currentTimeMillis());
//         try {
//             doExecute(httpInvocationContext);
//         } catch(Throwable t) {
//             logger.error("exception during http action execution", t);
//             listener.onFailure(t);
//         }
//     }
// 
//     protected HttpRequest newGetRequest(URL url, String path) {
//         return newGetRequest(url, path, null);
//     }
// 
//     protected HttpRequest newGetRequest(URL url, String path, CharSequence content) {
//         return newRequest(HttpMethod.GET, url, path, content);
//     }
// 
//     protected HttpRequest newPostRequest(URL url, String path, CharSequence content) {
//         return newRequest(HttpMethod.POST, url, path, content);
//     }
// 
//     protected HttpRequest newRequest(HttpMethod method, URL url, String path, CharSequence content) {
//         return newRequest(method, url, path, content != null ? ChannelBuffers.copiedBuffer(content, CharsetUtil.UTF_8) : null);
//     }
// 
//     protected HttpRequest newRequest(HttpMethod method, URL url, String path, BytesReference content) {
//         return newRequest(method, url, path, content != null ? ChannelBuffers.copiedBuffer(content.toBytes()) : null);
//     }
// 
//     protected HttpRequest newRequest(HttpMethod method, URL url, String path, ChannelBuffer buffer) {
//         HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, path);
//         request.headers().add(HttpHeaders.Names.HOST, url.getHost());
//         request.headers().add(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
//         request.headers().add(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP);
//         if (buffer != null) {
//             request.setContent(buffer);
//             int length = request.getContent().readableBytes();
//             request.headers().add(HttpHeaders.Names.CONTENT_TYPE, "application/json");
//             request.headers().add(HttpHeaders.Names.CONTENT_LENGTH, length);
//         }
//         return request;
//     }
// 
//     protected void doExecute(final HttpInvocationContext<Request,Response> httpInvocationContext) {
//         httpInvocationContext.getChannel().write(httpInvocationContext.getHttpRequest());
//     }
// 
//     protected abstract HttpRequest createHttpRequest(URL base, Request request) throws IOException;
// 
//     protected abstract Response createResponse(HttpInvocationContext<Request,Response> httpInvocationContext) throws IOException;
// 
// }
// 
// Path: src/main/java/org/xbib/elasticsearch/helper/client/http/HttpInvocationContext.java
// public class HttpInvocationContext<Request extends ActionRequest, Response extends ActionResponse> {
// 
//     private final HttpAction httpAction;
// 
//     private ActionListener<Response> listener;
// 
//     private final Request request;
// 
//     private final List<HttpChunk> chunks;
// 
//     private Channel channel;
// 
//     HttpRequest httpRequest;
// 
//     HttpResponse httpResponse;
// 
//     private long millis;
// 
//     HttpInvocationContext(HttpAction httpAction, ActionListener<Response> listener, List<HttpChunk> chunks, Request request) {
//         this.httpAction = httpAction;
//         this.listener = listener;
//         this.chunks = chunks;
//         this.request = request;
//     }
// 
//     public Request getRequest() {
//         return request;
//     }
// 
//     public HttpAction getHttpAction() {
//         return httpAction;
//     }
// 
//     public void setListener(ActionListener<Response> listener) {
//         this.listener = listener;
//     }
// 
//     public ActionListener<Response> getListener() {
//         return listener;
//     }
// 
//     public void setChannel(Channel channel) {
//         this.channel = channel;
//     }
// 
//     public Channel getChannel() {
//         return channel;
//     }
// 
//     public HttpRequest getHttpRequest() {
//         return httpRequest;
//     }
// 
//     public HttpResponse getHttpResponse() {
//         return httpResponse;
//     }
// 
//     public void setMillis(long millis) {
//         this.millis = millis;
//     }
// 
// }


import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.bytes.ChannelBufferBytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.xbib.elasticsearch.helper.client.http.HttpAction;
import org.xbib.elasticsearch.helper.client.http.HttpInvocationContext;
import java.io.IOException;
import java.net.URL;
import java.util.Map;

package org.elasticsearch.action.admin.indices.create;



public class HttpCreateIndexAction extends HttpAction<CreateIndexRequest, CreateIndexResponse> {

    public HttpCreateIndexAction(Settings settings) {
        super(settings, CreateIndexAction.NAME);
    }

    @Override
    protected HttpRequest createHttpRequest(URL url, CreateIndexRequest request) {
        return newPostRequest(url, "/" + request.index(), null);
    }

    @Override
// Path: src/main/java/org/xbib/elasticsearch/helper/client/http/HttpAction.java
// public abstract class HttpAction<Request extends ActionRequest, Response extends ActionResponse> extends AbstractComponent {
// 
//     protected final String actionName;
//     protected final ParseFieldMatcher parseFieldMatcher;
// 
//     protected HttpAction(Settings settings, String actionName) {
//         super(settings);
//         this.actionName = actionName;
//         this.parseFieldMatcher = new ParseFieldMatcher(settings);
//     }
// 
//     public final ActionFuture<Response> execute(HttpInvocationContext<Request,Response> httpInvocationContext, Request request) {
//         PlainActionFuture<Response> future = newFuture();
//         execute(httpInvocationContext, future);
//         return future;
//     }
// 
//     public final void execute(HttpInvocationContext<Request,Response> httpInvocationContext, ActionListener<Response> listener) {
//         ActionRequestValidationException validationException = httpInvocationContext.getRequest().validate();
//         if (validationException != null) {
//             listener.onFailure(validationException);
//             return;
//         }
//         httpInvocationContext.setListener(listener);
//         httpInvocationContext.setMillis(System.currentTimeMillis());
//         try {
//             doExecute(httpInvocationContext);
//         } catch(Throwable t) {
//             logger.error("exception during http action execution", t);
//             listener.onFailure(t);
//         }
//     }
// 
//     protected HttpRequest newGetRequest(URL url, String path) {
//         return newGetRequest(url, path, null);
//     }
// 
//     protected HttpRequest newGetRequest(URL url, String path, CharSequence content) {
//         return newRequest(HttpMethod.GET, url, path, content);
//     }
// 
//     protected HttpRequest newPostRequest(URL url, String path, CharSequence content) {
//         return newRequest(HttpMethod.POST, url, path, content);
//     }
// 
//     protected HttpRequest newRequest(HttpMethod method, URL url, String path, CharSequence content) {
//         return newRequest(method, url, path, content != null ? ChannelBuffers.copiedBuffer(content, CharsetUtil.UTF_8) : null);
//     }
// 
//     protected HttpRequest newRequest(HttpMethod method, URL url, String path, BytesReference content) {
//         return newRequest(method, url, path, content != null ? ChannelBuffers.copiedBuffer(content.toBytes()) : null);
//     }
// 
//     protected HttpRequest newRequest(HttpMethod method, URL url, String path, ChannelBuffer buffer) {
//         HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, path);
//         request.headers().add(HttpHeaders.Names.HOST, url.getHost());
//         request.headers().add(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
//         request.headers().add(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP);
//         if (buffer != null) {
//             request.setContent(buffer);
//             int length = request.getContent().readableBytes();
//             request.headers().add(HttpHeaders.Names.CONTENT_TYPE, "application/json");
//             request.headers().add(HttpHeaders.Names.CONTENT_LENGTH, length);
//         }
//         return request;
//     }
// 
//     protected void doExecute(final HttpInvocationContext<Request,Response> httpInvocationContext) {
//         httpInvocationContext.getChannel().write(httpInvocationContext.getHttpRequest());
//     }
// 
//     protected abstract HttpRequest createHttpRequest(URL base, Request request) throws IOException;
// 
//     protected abstract Response createResponse(HttpInvocationContext<Request,Response> httpInvocationContext) throws IOException;
// 
// }
// 
// Path: src/main/java/org/xbib/elasticsearch/helper/client/http/HttpInvocationContext.java
// public class HttpInvocationContext<Request extends ActionRequest, Response extends ActionResponse> {
// 
//     private final HttpAction httpAction;
// 
//     private ActionListener<Response> listener;
// 
//     private final Request request;
// 
//     private final List<HttpChunk> chunks;
// 
//     private Channel channel;
// 
//     HttpRequest httpRequest;
// 
//     HttpResponse httpResponse;
// 
//     private long millis;
// 
//     HttpInvocationContext(HttpAction httpAction, ActionListener<Response> listener, List<HttpChunk> chunks, Request request) {
//         this.httpAction = httpAction;
//         this.listener = listener;
//         this.chunks = chunks;
//         this.request = request;
//     }
// 
//     public Request getRequest() {
//         return request;
//     }
// 
//     public HttpAction getHttpAction() {
//         return httpAction;
//     }
// 
//     public void setListener(ActionListener<Response> listener) {
//         this.listener = listener;
//     }
// 
//     public ActionListener<Response> getListener() {
//         return listener;
//     }
// 
//     public void setChannel(Channel channel) {
//         this.channel = channel;
//     }
// 
//     public Channel getChannel() {
//         return channel;
//     }
// 
//     public HttpRequest getHttpRequest() {
//         return httpRequest;
//     }
// 
//     public HttpResponse getHttpResponse() {
//         return httpResponse;
//     }
// 
//     public void setMillis(long millis) {
//         this.millis = millis;
//     }
// 
// }


// Path: src/main/java/org/elasticsearch/action/admin/indices/create/HttpCreateIndexAction.java
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.bytes.ChannelBufferBytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.xbib.elasticsearch.helper.client.http.HttpAction;
import org.xbib.elasticsearch.helper.client.http.HttpInvocationContext;
import java.io.IOException;
import java.net.URL;
import java.util.Map;


package org.elasticsearch.action.admin.indices.create;



public class HttpCreateIndexAction extends HttpAction<CreateIndexRequest, CreateIndexResponse> {

    public HttpCreateIndexAction(Settings settings) {
        super(settings, CreateIndexAction.NAME);
    }

    @Override
    protected HttpRequest createHttpRequest(URL url, CreateIndexRequest request) {
        return newPostRequest(url, "/" + request.index(), null);
    }

    @Override
    protected CreateIndexResponse createResponse(HttpInvocationContext<CreateIndexRequest,CreateIndexResponse> httpInvocationContext) {