use of cz.metacentrum.perun.rpc.deserializer.JsonDeserializer in project perun by CESNET.
the class ExtSourcePerun method call.
private Deserializer call(String managerName, String methodName, String query) throws PerunException {
//Prepare sending message
HttpResponse response;
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// just like cookie-policy: ignore cookies
httpClientBuilder.disableCookieManagement();
HttpClient httpClient = httpClientBuilder.build();
String commandUrl = perunUrl + format + "/" + managerName + "/" + methodName;
if (query != null)
commandUrl += "?" + query;
HttpGet get = new HttpGet(commandUrl);
get.setHeader("Content-Type", "application/json");
get.setHeader("charset", "utf-8");
get.setHeader("Connection", "Close");
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
get.addHeader(BasicScheme.authenticate(credentials, "utf-8", false));
//post.setParams(params);
InputStream rpcServerAnswer = null;
try {
response = httpClient.execute(get);
rpcServerAnswer = response.getEntity().getContent();
} catch (IOException ex) {
this.processIOException(ex);
}
JsonDeserializer des = null;
try {
des = new JsonDeserializer(rpcServerAnswer);
} catch (IOException ex) {
this.processIOException(ex);
}
return des;
}
Aggregations