// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
// 	
// 	private static Set<String> protocolsWithHost = new HashSet<String>( 
// 		      Arrays.asList( new String[]{ "file", "ftp", "http", "https" } ) 
// 		  );
// 	
// 	public static URL[] stringToURL(String... urls) throws Exception {
// 		URL[] urlArray = new URL[urls.length];
// 		for(int i=0; i < urls.length; i++) {
// 			urlArray[i]  = new URL(urls[i]);
// 		}
// 		return urlArray;
// 	}
// 	
// 	public static boolean checkStatus(URL url, int code) throws IOException {
// 		URLConnection conn = url.openConnection();
// 		if(conn instanceof HttpURLConnection) {
// 			HttpURLConnection huc =  (HttpURLConnection) conn;
// 			huc.setRequestMethod("HEAD");
// 			conn.connect();
// 			return huc.getResponseCode() == code;
// 		}
// 		return false;
// 	}
// 	
// 	public static URL[] fileToURL(File... files) throws MalformedURLException {
// 		URL[] urls = new URL[files.length];
// 		int i = 0;
// 		for(File file : files) {
// 			urls[i] = file.toURI().toURL();
// 			i++;
// 		}		
// 		return urls;
// 	}
// 	
// 	public static long getContentLength(URL url) throws IOException {
//         URLConnection conn = url.openConnection();
//         Long contentLength = conn.getContentLengthLong();
//         if(contentLength != null && contentLength >= 0) {
//         	return contentLength;
//         }
// 		String contentLengthValue = conn.getHeaderField("content-length");
// 		if(contentLengthValue != null) {
// 			return Long.valueOf(contentLengthValue);
// 		}
// 		return -1;
// 	}
// 	
// 	public static URL getURLForward(URL url) throws Exception {
// 		URLConnection con = url.openConnection();
// 		String location = con.getHeaderField("Location");
// 		if(location != null) {
// 			return new URL(location);
// 		}
// 		return url;
// 	}
// 	
// 	public static boolean hasValidURLHost(URI uri) {
// 		return protocolsWithHost.contains(uri.getScheme());
// 	}
// 	
// 	public static String getContentType(URL url) throws Exception {
// 		URL forwardURL = getURLForward(url);
// 		HttpURLConnection connection = (HttpURLConnection)  forwardURL.openConnection();
// 		connection.setRequestMethod("HEAD");
// 		connection.connect();
// 		return connection.getContentType();
// 	}
// }


import java.io.File;
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.aksw.kbox.utils.URLUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
					JSONObject jsonSource = (JSONObject) jsonMirror.get(s);
					String install = (String) jsonSource.keySet().toArray()[0];
					JSONArray jsonSources = (JSONArray) jsonSource.values().toArray()[0];
					if(jsonSources != null) {
						for(int i= 0; i < jsonSources.size(); i++) {
							JSONObject jsonSourceEntry = (JSONObject)jsonSources.get(i);
							String url = (String)jsonSourceEntry.get(KN.URL);
							JSONObject jsonChecksum = (JSONObject) jsonSourceEntry.get(KN.CHECKSUM);
							Map<String, String> checksum = new HashMap<String, String>();
							if(jsonChecksum != null) {
								for(int c = 0; c < jsonChecksum.keySet().size(); c++) {
									String key = (String) jsonChecksum.keySet().toArray()[c];
									String value = (String) jsonChecksum.values().toArray()[c];
									checksum.put(key, value);
								}
							}
							JSONObject jsonDataId = (JSONObject) jsonSourceEntry.get(KN.DATAID);
							Map<String, String> dataId = new HashMap<String, String>();
							if(jsonDataId != null) {
								for(int di = 0; di < jsonDataId.keySet().size(); di++) {
									String key = (String) jsonDataId.keySet().toArray()[di];
									String value = (String) jsonDataId.values().toArray()[di];
									dataId.put(key, value);
								}
							}
							Source source = new Source();
							source.setInstall(install);
							source.setChecksum(checksum);
							URI uri = new URI(url);
							URL knName = null;
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
// 	
// 	private static Set<String> protocolsWithHost = new HashSet<String>( 
// 		      Arrays.asList( new String[]{ "file", "ftp", "http", "https" } ) 
// 		  );
// 	
// 	public static URL[] stringToURL(String... urls) throws Exception {
// 		URL[] urlArray = new URL[urls.length];
// 		for(int i=0; i < urls.length; i++) {
// 			urlArray[i]  = new URL(urls[i]);
// 		}
// 		return urlArray;
// 	}
// 	
// 	public static boolean checkStatus(URL url, int code) throws IOException {
// 		URLConnection conn = url.openConnection();
// 		if(conn instanceof HttpURLConnection) {
// 			HttpURLConnection huc =  (HttpURLConnection) conn;
// 			huc.setRequestMethod("HEAD");
// 			conn.connect();
// 			return huc.getResponseCode() == code;
// 		}
// 		return false;
// 	}
// 	
// 	public static URL[] fileToURL(File... files) throws MalformedURLException {
// 		URL[] urls = new URL[files.length];
// 		int i = 0;
// 		for(File file : files) {
// 			urls[i] = file.toURI().toURL();
// 			i++;
// 		}		
// 		return urls;
// 	}
// 	
// 	public static long getContentLength(URL url) throws IOException {
//         URLConnection conn = url.openConnection();
//         Long contentLength = conn.getContentLengthLong();
//         if(contentLength != null && contentLength >= 0) {
//         	return contentLength;
//         }
// 		String contentLengthValue = conn.getHeaderField("content-length");
// 		if(contentLengthValue != null) {
// 			return Long.valueOf(contentLengthValue);
// 		}
// 		return -1;
// 	}
// 	
// 	public static URL getURLForward(URL url) throws Exception {
// 		URLConnection con = url.openConnection();
// 		String location = con.getHeaderField("Location");
// 		if(location != null) {
// 			return new URL(location);
// 		}
// 		return url;
// 	}
// 	
// 	public static boolean hasValidURLHost(URI uri) {
// 		return protocolsWithHost.contains(uri.getScheme());
// 	}
// 	
// 	public static String getContentType(URL url) throws Exception {
// 		URL forwardURL = getURLForward(url);
// 		HttpURLConnection connection = (HttpURLConnection)  forwardURL.openConnection();
// 		connection.setRequestMethod("HEAD");
// 		connection.connect();
// 		return connection.getContentType();
// 	}
// }


// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/Source.java
import java.io.File;
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.aksw.kbox.utils.URLUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

					JSONObject jsonSource = (JSONObject) jsonMirror.get(s);
					String install = (String) jsonSource.keySet().toArray()[0];
					JSONArray jsonSources = (JSONArray) jsonSource.values().toArray()[0];
					if(jsonSources != null) {
						for(int i= 0; i < jsonSources.size(); i++) {
							JSONObject jsonSourceEntry = (JSONObject)jsonSources.get(i);
							String url = (String)jsonSourceEntry.get(KN.URL);
							JSONObject jsonChecksum = (JSONObject) jsonSourceEntry.get(KN.CHECKSUM);
							Map<String, String> checksum = new HashMap<String, String>();
							if(jsonChecksum != null) {
								for(int c = 0; c < jsonChecksum.keySet().size(); c++) {
									String key = (String) jsonChecksum.keySet().toArray()[c];
									String value = (String) jsonChecksum.values().toArray()[c];
									checksum.put(key, value);
								}
							}
							JSONObject jsonDataId = (JSONObject) jsonSourceEntry.get(KN.DATAID);
							Map<String, String> dataId = new HashMap<String, String>();
							if(jsonDataId != null) {
								for(int di = 0; di < jsonDataId.keySet().size(); di++) {
									String key = (String) jsonDataId.keySet().toArray()[di];
									String value = (String) jsonDataId.values().toArray()[di];
									dataId.put(key, value);
								}
							}
							Source source = new Source();
							source.setInstall(install);
							source.setChecksum(checksum);
							URI uri = new URI(url);
							URL knName = null;
							if(uri.isAbsolute() && URLUtils.hasValidURLHost(uri)) {