Skip to content

Instantly share code, notes, and snippets.

@jsloyer
Created October 17, 2014 15:23
Show Gist options
  • Save jsloyer/5178f69fbf3b519ad6fc to your computer and use it in GitHub Desktop.
Save jsloyer/5178f69fbf3b519ad6fc to your computer and use it in GitHub Desktop.
private static JSONArray watson;
private static JSONObject watsonInstance;
private static JSONObject watsonCredentials;
private Executor executor;
public WatsonUserModeller()
{
try {
String VCAP_SERVICES = System.getenv("VCAP_SERVICES");
JSONObject vcap;
vcap = (JSONObject) JSONObject.parse(VCAP_SERVICES);
watson = (JSONArray) vcap.get("user_modeling");
watsonInstance = (JSONObject) watson.get(0);
watsonCredentials = (JSONObject) watsonInstance.get("credentials");
} catch (IOException e) {
e.printStackTrace();
}
this.username = (String) watsonCredentials.get("username");
this.password = (String) watsonCredentials.get("password");
this.base_url = (String) watsonCredentials.get("url");
this.profile_api = Config.WATSON_PROF_API;
this.visual_api = Config.WATSON_VIZ_API;
this.executor = Executor.newInstance().auth(username, password);
if (this.executor == null)
{
System.err.println("Authentication failed in WatsonUserModeller.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment