From bf62357be61e24b5df6275b5fc2e1364c6cca734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicklas=20K=C3=B6rtge?= Date: Tue, 7 Jan 2025 09:53:09 +0100 Subject: [PATCH] fix hhtpclient dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicklas Körtge --- pom.xml | 5 +++++ .../api/v1/scanning/ScanRequest.java | 2 +- .../services/depsdev/DepsDevService.java | 19 +++++++++---------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index de4eb783e..8b410ac9f 100644 --- a/pom.xml +++ b/pom.xml @@ -109,6 +109,11 @@ org.eclipse.jgit org.eclipse.jgit + + org.apache.httpcomponents.client5 + httpclient5 + 5.4.1 + diff --git a/src/main/java/com/ibm/presentation/api/v1/scanning/ScanRequest.java b/src/main/java/com/ibm/presentation/api/v1/scanning/ScanRequest.java index f02c8df07..53f4e3c2a 100644 --- a/src/main/java/com/ibm/presentation/api/v1/scanning/ScanRequest.java +++ b/src/main/java/com/ibm/presentation/api/v1/scanning/ScanRequest.java @@ -24,7 +24,7 @@ import jakarta.annotation.Nullable; public class ScanRequest { - private String scanUrl; + private @Nonnull String scanUrl; private @Nullable String branch; private @Nullable String subfolder; private @Nullable Credentials credentials; diff --git a/src/main/java/com/ibm/usecases/scanning/services/depsdev/DepsDevService.java b/src/main/java/com/ibm/usecases/scanning/services/depsdev/DepsDevService.java index 2c4b63dee..7f0745475 100644 --- a/src/main/java/com/ibm/usecases/scanning/services/depsdev/DepsDevService.java +++ b/src/main/java/com/ibm/usecases/scanning/services/depsdev/DepsDevService.java @@ -28,15 +28,15 @@ import java.io.InputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import org.apache.http.StatusLine; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.jboss.logging.Logger; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DepsDevService { - private static final Logger LOGGER = Logger.getLogger(DepsDevService.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DepsDevService.class); private static final String DEPS_DEV_URI = "https://api.deps.dev/v3alpha/purl/"; private static final String SOURCE_REPO = "SOURCE_REPO"; @@ -48,10 +48,9 @@ public String fetch(@Nonnull String purl) throws NoDataAvailableInDepsDevForPurl try (final CloseableHttpClient httpClient = HttpClientBuilder.create().build(); final CloseableHttpResponse response = httpClient.execute(request); ) { - final StatusLine status = response.getStatusLine(); - if (status.getStatusCode() != 200) { + if (response.getCode() != 200) { throw new NoDataAvailableInDepsDevForPurl( - purl, "bad status code: " + status.getStatusCode()); + purl, "bad status code: " + response.getCode()); } final InputStream in = response.getEntity().getContent(); return extractSourceRepo(in);