Centralize Google API key

This commit is contained in:
Tom Morris 2013-03-12 17:34:06 -04:00
parent 054ea643c3
commit 757c3e32ff
2 changed files with 305 additions and 289 deletions

View File

@ -35,12 +35,13 @@ package com.google.refine.freebase.model.recon;
import org.json.JSONObject; import org.json.JSONObject;
import com.google.refine.freebase.util.FreebaseUtils;
import com.google.refine.model.Recon; import com.google.refine.model.Recon;
import com.google.refine.model.Recon.Judgment; import com.google.refine.model.Recon.Judgment;
import com.google.refine.model.recon.ReconConfig; import com.google.refine.model.recon.ReconConfig;
abstract public class StrictReconConfig extends ReconConfig { abstract public class StrictReconConfig extends ReconConfig {
final static protected String s_mqlreadService = "https://www.googleapis.com/freebase/v1/mqlread?key=AIzaSyBAZ_EjMPKlOzyyZXv6JKXPPwJFISVji3M&"; final static protected String s_mqlreadService = "https://www.googleapis.com/freebase/v1/mqlread?key=" + FreebaseUtils.API_KEY + "&";
static public ReconConfig reconstruct(JSONObject obj) throws Exception { static public ReconConfig reconstruct(JSONObject obj) throws Exception {
String match = obj.getString("match"); String match = obj.getString("match");

View File

@ -80,15 +80,30 @@ public class FreebaseUtils {
static final private int SAMPLE_SIZE = 300; static final private int SAMPLE_SIZE = 300;
static final private int JUDGES = 4; static final private int JUDGES = 4;
public static final String API_KEY = "AIzaSyBAZ_EjMPKlOzyyZXv6JKXPPwJFISVji3M";
private static String getUserInfoURL(String host) { private static String getUserInfoURL(String host) {
// TODO: Needs to be upgraded to new APIs sandbox-freebase.com as host becomes v1sandbox as version
return "http://api." + host + "/api/service/user_info"; return "http://api." + host + "/api/service/user_info";
} }
private static String getMQLWriteURL(String host) { private static String getMQLWriteURL(String host) {
// TODO: Needs to be upgraded to new APIs
// String version = "v1";
// if (host != null && host.contains("sandbox")) {
// version += "sandbox";
// }
// return "https://www.googleapis.com/freebase/"+version+"/mqlwrite?key=" + API_KEY + "&";
return "http://api." + host + "/api/service/mqlwrite"; return "http://api." + host + "/api/service/mqlwrite";
} }
private static String getMQLReadURL(String host) { private static String getMQLReadURL(String host) {
// TODO: Needs to be upgraded to new APIs
// String version = "v1";
// if (host != null && host.contains("sandbox")) {
// version += "sandbox";
// }
// return "https://www.googleapis.com/freebase/"+version+"/mqlread?key=" + API_KEY + "&";
return "http://api." + host + "/api/service/mqlread"; return "http://api." + host + "/api/service/mqlread";
} }