use of org.jboss.pnc.buildagent.client.BuildAgentClientException in project pnc by project-ncl.
the class DefaultClientFactory method createHttpBuildAgentClient.
@Override
public BuildAgentClient createHttpBuildAgentClient(String terminalUrl, String executionId, Map<String, String> callbackHeaders, List<Request.Header> requestHeaders) throws BuildAgentClientException {
List<Request.Header> headers = callbackHeaders.entrySet().stream().map(e -> new Request.Header(e.getKey(), e.getValue())).collect(Collectors.toList());
HttpClientConfiguration configuration = null;
try {
URL callbackUrl = new URL(StringUtils.stripEndingSlash(pncBaseUrl) + "/build-execution/" + executionId + "/completed");
Request callback = new Request(Request.Method.POST, callbackUrl.toURI(), headers);
configuration = HttpClientConfiguration.newBuilder().termBaseUrl(terminalUrl).callback(callback).livenessResponseTimeout(30000L).retryConfig(retryConfig).requestHeaders(requestHeaders).build();
} catch (MalformedURLException | URISyntaxException e) {
new BuildAgentClientException("Invalid callback URL.", e);
}
return new BuildAgentHttpClient(httpClient, configuration);
}
Aggregations