Created
October 17, 2014 15:23
-
-
Save jsloyer/5178f69fbf3b519ad6fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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