Fixes for Freeq
git-svn-id: http://google-refine.googlecode.com/svn/trunk@552 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
fece6187bf
commit
e6012bc14a
@ -30,9 +30,10 @@ public class UploadDataCommand extends Command {
|
||||
StringWriter triples = new StringWriter(1024 * 10);
|
||||
exporter.export(project, new Properties(), engine, triples);
|
||||
|
||||
String info = request.getParameter("info");
|
||||
String source_name = request.getParameter("source_name");
|
||||
String source_id = request.getParameter("source_id");
|
||||
|
||||
String result = FreebaseUtils.uploadTriples(request, info, triples.toString());
|
||||
String result = FreebaseUtils.uploadTriples(request, source_name, source_id, triples.toString());
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
@ -67,21 +67,27 @@ public class FreebaseUtils {
|
||||
return EntityUtils.toString(httpResponse.getEntity());
|
||||
}
|
||||
|
||||
public static String uploadTriples(HttpServletRequest request, String info, String triples)
|
||||
public static String uploadTriples(HttpServletRequest request, String source_name, String source_id, String triples)
|
||||
throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException, ClientProtocolException, JSONException, IOException {
|
||||
|
||||
Provider provider = OAuthUtilities.getProvider(FREEBASE_HOST);
|
||||
|
||||
Credentials credentials = Credentials.getCredentials(request, provider, Credentials.Type.ACCESS);
|
||||
|
||||
JSONObject mdo_info = new JSONObject();
|
||||
mdo_info.put("name", source_name);
|
||||
if (source_id != null) {
|
||||
mdo_info.put("info_source",source_id);
|
||||
}
|
||||
|
||||
JSONObject user_info = new JSONObject(getUserInfo(credentials, provider));
|
||||
if (user_info.has("username")) {
|
||||
|
||||
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
|
||||
formparams.add(new BasicNameValuePair("user", user_info.getString("username")));
|
||||
formparams.add(new BasicNameValuePair("user", user_info.getString("id")));
|
||||
formparams.add(new BasicNameValuePair("action_type", "LOAD_TRIPLE"));
|
||||
formparams.add(new BasicNameValuePair("operator", GRIDWORKS_ID));
|
||||
formparams.add(new BasicNameValuePair("mdo_info", info));
|
||||
formparams.add(new BasicNameValuePair("mdo_info", mdo_info.toString()));
|
||||
formparams.add(new BasicNameValuePair("graphport", provider.getHost().equals(FREEBASE_HOST) ? "otg" : "sandbox"));
|
||||
formparams.add(new BasicNameValuePair("payload", triples));
|
||||
formparams.add(new BasicNameValuePair("check_params", "false"));
|
||||
|
Loading…
Reference in New Issue
Block a user