// Path: src/main/java/org/nudge/elasticstack/context/elasticsearch/ESVersion.java
// public enum ESVersion {
// 	ES2, ES5, ES6
// }
// 
// Path: src/main/java/org/nudge/elasticstack/exception/NudgeESConnectorException.java
// @SuppressWarnings("serial")
// public class NudgeESConnectorException extends Exception {
// 
// 	public NudgeESConnectorException(String m) {
// 		super(m);
// 	}
// 
// 	public NudgeESConnectorException(String m, Throwable t) {
// 		super(m, t);
// 	}
// }
// 
// Path: src/main/java/org/nudge/elasticstack/exception/UnsupportedElasticStackException.java
// @SuppressWarnings("serial")
// public class UnsupportedElasticStackException extends RuntimeException {
// 
// 	public UnsupportedElasticStackException(String message) {
// 		super(message);
// 	}
// 
// 	public UnsupportedElasticStackException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }


import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.log4j.Logger;
import org.nudge.elasticstack.context.elasticsearch.ESVersion;
import org.nudge.elasticstack.exception.NudgeESConnectorException;
import org.nudge.elasticstack.exception.UnsupportedElasticStackException;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
	private void checkAndLog(HttpMethod httpMethod, String resource, String body) {
		if (httpMethod == null || resource == null) {
			throw new IllegalArgumentException("Cannot request elasticsearch, HttpMethod and resource URL must be provided");
		}

		if (!LOG.isDebugEnabled()) {
			return;
		}

		String requestLog = httpMethod.toString() + " " + resource;
		if (body != null) {
			requestLog = requestLog + " with body : \n" + body;
		}
		LOG.debug(requestLog);
	}


	public void createAndUseIndex(String esIndex) {
		esHostIndexURL = elasticHost + esIndex + "/";
		try {
			put("", null);
		} catch (NudgeESConnectorException e) {
			LOG.info("Index \"" + esIndex + "\" already exists");
		}
	}

	public ESVersion getEsVersion() {
		return esVersion;
	}

// Path: src/main/java/org/nudge/elasticstack/context/elasticsearch/ESVersion.java
// public enum ESVersion {
// 	ES2, ES5, ES6
// }
// 
// Path: src/main/java/org/nudge/elasticstack/exception/NudgeESConnectorException.java
// @SuppressWarnings("serial")
// public class NudgeESConnectorException extends Exception {
// 
// 	public NudgeESConnectorException(String m) {
// 		super(m);
// 	}
// 
// 	public NudgeESConnectorException(String m, Throwable t) {
// 		super(m, t);
// 	}
// }
// 
// Path: src/main/java/org/nudge/elasticstack/exception/UnsupportedElasticStackException.java
// @SuppressWarnings("serial")
// public class UnsupportedElasticStackException extends RuntimeException {
// 
// 	public UnsupportedElasticStackException(String message) {
// 		super(message);
// 	}
// 
// 	public UnsupportedElasticStackException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }


// Path: src/main/java/org/nudge/elasticstack/connection/ElasticConnection.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.log4j.Logger;
import org.nudge.elasticstack.context.elasticsearch.ESVersion;
import org.nudge.elasticstack.exception.NudgeESConnectorException;
import org.nudge.elasticstack.exception.UnsupportedElasticStackException;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;

	private void checkAndLog(HttpMethod httpMethod, String resource, String body) {
		if (httpMethod == null || resource == null) {
			throw new IllegalArgumentException("Cannot request elasticsearch, HttpMethod and resource URL must be provided");
		}

		if (!LOG.isDebugEnabled()) {
			return;
		}

		String requestLog = httpMethod.toString() + " " + resource;
		if (body != null) {
			requestLog = requestLog + " with body : \n" + body;
		}
		LOG.debug(requestLog);
	}


	public void createAndUseIndex(String esIndex) {
		esHostIndexURL = elasticHost + esIndex + "/";
		try {
			put("", null);
		} catch (NudgeESConnectorException e) {
			LOG.info("Index \"" + esIndex + "\" already exists");
		}
	}

	public ESVersion getEsVersion() {
		return esVersion;
	}

	private ESVersion determineESVersion(Metadata metadata) throws UnsupportedElasticStackException {