Created
March 29, 2011 18:28
-
-
Save weissjeffm/892938 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public static JSONObject getOwnerOfConsumerId(String server, String port, String prefix, String authenticator, String authenticatorPassword, String consumerId) throws JSONException, Exception { | |
| JSONObject jsonOwner = null; | |
| JSONObject jsonConsumer = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(server, port, prefix, authenticator, authenticatorPassword,"/consumers/"+consumerId)); | |
| JSONObject jsonOwner_ = (JSONObject) jsonConsumer.getJSONObject("owner"); | |
| // Warning: this authenticator, authenticatorPassword needs to be superAdmin | |
| jsonOwner = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(server, port, prefix, authenticator, authenticatorPassword,jsonOwner_.getString("href"))); | |
| return jsonOwner; | |
| } | |
| static public String getResourceUsingRESTfulAPI(String server, String port, String prefix, String authenticator, String password, String path) throws Exception { | |
| GetMethod get = new GetMethod("https://"+server+":"+port+prefix+path); | |
| String credentials = authenticator.equals("")? "":"-u "+authenticator+":"+password; | |
| log.info("SSH alternative to HTTP request: curl -k "+credentials+" --request GET https://"+server+":"+port+prefix+path); | |
| return getHTTPResponseAsString(client, get, authenticator, password); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment