// 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/context/elasticsearch/bean/GeoLocation.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class GeoLocation {
// 
// 	private double latitude;
// 	private double longitude;
// 	private long responseTime;
// 	private String type;
// 	private  String transactionId;
// 
// 	// =====================
// 	// Getters and Setters
// 	// =====================
// 
// 	public String getType() {
// 		return type;
// 	}
// 
// 	public void setType(String type) {
// 		this.type = type;
// 	}
// 
// 	public double getLatitude() {
// 		return latitude;
// 	}
// 
// 	public void setLatitude(double latitude) {
// 		this.latitude = latitude;
// 	}
// 
// 	public double getLongitude() {
// 		return longitude;
// 	}
// 
// 	public void setLongitude(double longitude) {
// 		this.longitude = longitude;
// 	}
// 
// 	public long getResponseTime() {
// 		return responseTime;
// 	}
// 
// 	public void setResponseTime(long responseTime) {
// 		this.responseTime = responseTime;
// 	}
// 
// 	public String getClientlocation() {
// 		return latitude + "," + longitude;
// 	}
// 	
// 	public  String getTransactionId() {
// 		return transactionId;
// 	}
// 
// 	public  void setTransactionId(String transactionId) {
// 		this.transactionId = transactionId;
// 	}
// 
// 
// }
// 
// Path: src/main/java/org/nudge/elasticstack/service/GeoLocationService.java
// public interface GeoLocationService {
//     public GeoLocation requestGeoLocationFromIp(String ip) throws NudgeESConnectorException;
// }


import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.log4j.Logger;
import org.nudge.elasticstack.exception.NudgeESConnectorException;
import org.nudge.elasticstack.context.elasticsearch.bean.GeoLocation;
import org.nudge.elasticstack.service.GeoLocationService;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
package org.nudge.elasticstack.service.impl;



/**
 * @author Sarah Bourgeois
 * @author Frederic Massart
 */
public class GeoFreeGeoIpImpl implements GeoLocationService {

	private static final Logger LOG = Logger.getLogger(GeoFreeGeoIpImpl.class);
	private static final String FINAL_URL = "http://freegeoip.net/json/";

	@Override
// 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/context/elasticsearch/bean/GeoLocation.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class GeoLocation {
// 
// 	private double latitude;
// 	private double longitude;
// 	private long responseTime;
// 	private String type;
// 	private  String transactionId;
// 
// 	// =====================
// 	// Getters and Setters
// 	// =====================
// 
// 	public String getType() {
// 		return type;
// 	}
// 
// 	public void setType(String type) {
// 		this.type = type;
// 	}
// 
// 	public double getLatitude() {
// 		return latitude;
// 	}
// 
// 	public void setLatitude(double latitude) {
// 		this.latitude = latitude;
// 	}
// 
// 	public double getLongitude() {
// 		return longitude;
// 	}
// 
// 	public void setLongitude(double longitude) {
// 		this.longitude = longitude;
// 	}
// 
// 	public long getResponseTime() {
// 		return responseTime;
// 	}
// 
// 	public void setResponseTime(long responseTime) {
// 		this.responseTime = responseTime;
// 	}
// 
// 	public String getClientlocation() {
// 		return latitude + "," + longitude;
// 	}
// 	
// 	public  String getTransactionId() {
// 		return transactionId;
// 	}
// 
// 	public  void setTransactionId(String transactionId) {
// 		this.transactionId = transactionId;
// 	}
// 
// 
// }
// 
// Path: src/main/java/org/nudge/elasticstack/service/GeoLocationService.java
// public interface GeoLocationService {
//     public GeoLocation requestGeoLocationFromIp(String ip) throws NudgeESConnectorException;
// }


// Path: src/main/java/org/nudge/elasticstack/service/impl/GeoFreeGeoIpImpl.java
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.log4j.Logger;
import org.nudge.elasticstack.exception.NudgeESConnectorException;
import org.nudge.elasticstack.context.elasticsearch.bean.GeoLocation;
import org.nudge.elasticstack.service.GeoLocationService;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

package org.nudge.elasticstack.service.impl;



/**
 * @author Sarah Bourgeois
 * @author Frederic Massart
 */
public class GeoFreeGeoIpImpl implements GeoLocationService {

	private static final Logger LOG = Logger.getLogger(GeoFreeGeoIpImpl.class);
	private static final String FINAL_URL = "http://freegeoip.net/json/";

	@Override
	public GeoLocation requestGeoLocationFromIp(String ip) throws NudgeESConnectorException {