From 43a11e5ed595418788fce58db2aa25080bd81e5d Mon Sep 17 00:00:00 2001 From: Jeronimo Ortiz Date: Thu, 5 Sep 2024 14:25:44 -0300 Subject: [PATCH 1/6] SP-1331 --- src/main/java/com/scanoss/rest/ScanApi.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/scanoss/rest/ScanApi.java b/src/main/java/com/scanoss/rest/ScanApi.java index efad2f0..a843763 100644 --- a/src/main/java/com/scanoss/rest/ScanApi.java +++ b/src/main/java/com/scanoss/rest/ScanApi.java @@ -69,12 +69,13 @@ public class ScanApi { private Map headers; // custom REST client headers private String customCert; // Custom certificate private Proxy proxy; // Proxy configuration + private String baseUrl; // SCANOSS base API URI (to used instead of url) @SuppressWarnings("unused") private ScanApi(String scanType, Duration timeout, Integer retryLimit, String url, String apiKey, String flags, String sbomType, String sbom, OkHttpClient okHttpClient, Map headers, String customCert, - Proxy proxy) { + Proxy proxy, String baseUrl) { this.scanType = scanType; this.timeout = timeout; this.retryLimit = retryLimit; @@ -85,7 +86,9 @@ private ScanApi(String scanType, Duration timeout, Integer retryLimit, String ur this.sbom = sbom; this.customCert = customCert; this.proxy = proxy; - if (this.apiKey != null && !this.apiKey.isEmpty() && (url == null || url.isEmpty())) { + if ((url == null || url.isEmpty()) && (baseUrl != null && ! baseUrl.isEmpty())) { + this.url = String.format( "%s/%s", baseUrl, DEFAULT_SCAN_URL); + } else if (this.apiKey != null && !this.apiKey.isEmpty() && (this.url == null || this.url.isEmpty())) { this.url = DEFAULT_SCAN_URL2; // Default premium SCANOSS endpoint } else if (url == null || url.isEmpty()) { this.url = DEFAULT_SCAN_URL; // Default free SCANOSS endpoint @@ -235,7 +238,9 @@ private RequestBody multipartData(Map data, String uuid) { } private static final int RETRY_FAIL_SLEEP_TIME = 5; // Time to sleep between failed scan requests - static final String DEFAULT_SCAN_URL = "https://api.osskb.org/scan/direct"; // Free OSS OSSKB URL - static final String DEFAULT_SCAN_URL2 = "https://api.scanoss.com/scan/direct"; // Standard SCANOSS Premium URL -// static final String SCANOSS_SCAN_URL = System.getenv("SCANOSS_SCAN_URL"); + public static final String DEFAULT_BASE_URL = "https://api.osskb.org"; + public static final String DEFAULT_BASE_URL2 = "https://api.scanoss.com"; + static final String DEFAULT_SCAN_PATH = "scan/direct"; + static final String DEFAULT_SCAN_URL = String.format( "%s/%s", DEFAULT_BASE_URL, DEFAULT_SCAN_PATH ); // Free OSS OSSKB URL + static final String DEFAULT_SCAN_URL2 = String.format( "%s/%s", DEFAULT_BASE_URL2, DEFAULT_SCAN_PATH ); // Standard SCANOSS Premium URL } From 1881c1be05fc60bdadb2dfd3ace52df4eb2d0ab5 Mon Sep 17 00:00:00 2001 From: Jeronimo Ortiz Date: Thu, 12 Sep 2024 09:36:19 -0300 Subject: [PATCH 2/6] SP-1331 --- .idea/misc.xml | 3 +-- CHANGELOG.md | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 563484c..5992d23 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,9 +25,8 @@ - - + \ No newline at end of file From 681507e76b76fe967aad535ca1e9e5a2b5ff0d7f Mon Sep 17 00:00:00 2001 From: Jeronimo Ortiz <166400360+scanossjeronimo@users.noreply.github.com> Date: Fri, 13 Sep 2024 11:10:25 -0300 Subject: [PATCH 6/6] updated changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2cd338..da11f4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.7.3] - 2024-09-12 ### Added -- Added variables `DEFAULT_SCAN_URL` and `DEFAULT_SCAN_URL2` to separate the scan URL from the scan path +- Added variables `DEFAULT_BASE_URL` and `DEFAULT_BASE_URL2` to separate the scan URL from the scan path ## [0.7.2] - 2024-04-17 ### Added