use of org.openkilda.exception.RestCallFailedException in project open-kilda by telstra.
the class OAuthService method getHttpResponse.
private HttpResponse getHttpResponse(UrlDto request, AuthConfigDto authDto) {
try {
String accessToken = getToken((OauthTwoConfigDto) authDto);
if (request.getHeader() != null) {
request.setHeader(request.getHeader() + "\nAuthorization:" + accessToken);
} else {
request.setHeader("Authorization:" + accessToken);
}
HttpMethod httpMethod = null;
if (("POST").equalsIgnoreCase(request.getMethodType())) {
httpMethod = HttpMethod.POST;
} else if (("PUT").equalsIgnoreCase(request.getMethodType())) {
httpMethod = HttpMethod.PUT;
} else if (("DELETE").equalsIgnoreCase(request.getMethodType())) {
httpMethod = HttpMethod.DELETE;
} else {
httpMethod = HttpMethod.GET;
}
ApiRequestDto apiRequestDto = new ApiRequestDto(request.getUrl(), httpMethod, request.getHeader(), request.getBody());
if (request.getParams() != null) {
prepareRequest.preprocessApiRequest(apiRequestDto, request.getParams());
}
return restClientManager.invoke(apiRequestDto);
} catch (RestCallFailedException | AuthenticationException e) {
e.printStackTrace();
}
return null;
}
Aggregations