Skip to content

Commit ecbf952

Browse files
Merge pull request #14 from scanoss/SP-1331
SP-1331-Add-Default-Base-URL
2 parents 8598c47 + 681507e commit ecbf952

File tree

7 files changed

+28
-19
lines changed

7 files changed

+28
-19
lines changed

.github/workflows/java-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
build_and_test:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616

1717
- name: Setup Java
18-
uses: actions/[email protected].3
18+
uses: actions/[email protected].4
1919
with:
2020
java-version: 11
2121

.github/workflows/java-native-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
build_and_test:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919

2020
- name: Setup Java
21-
uses: actions/[email protected].3
21+
uses: actions/[email protected].4
2222
with:
2323
java-version: 11
2424

@@ -34,7 +34,7 @@ jobs:
3434
name: Build native on ${{ github.event.inputs.build_env }}
3535
runs-on: ${{ github.event.inputs.build_env }}
3636
steps:
37-
- uses: actions/checkout@v3
37+
- uses: actions/checkout@v4
3838
- uses: graalvm/setup-graalvm@v1
3939
with:
4040
java-version: '17'

.github/workflows/publish.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
name: Build and test java code
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616

1717
- name: Setup Java
18-
uses: actions/[email protected].3
18+
uses: actions/[email protected].4
1919
with:
2020
java-version: 11
2121

@@ -31,10 +31,10 @@ jobs:
3131
name: Package and upload package to Maven Central
3232
runs-on: ubuntu-latest
3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
3535

3636
- name: Setup Java
37-
uses: actions/[email protected].3
37+
uses: actions/[email protected].4
3838
with:
3939
java-version: 11
4040
server-id: ossrh
@@ -79,7 +79,7 @@ jobs:
7979
matrix:
8080
os: [ubuntu-latest, macos-11, windows-latest]
8181
steps:
82-
- uses: actions/checkout@v3
82+
- uses: actions/checkout@v4
8383

8484
- uses: graalvm/setup-graalvm@v1
8585
with:
@@ -155,7 +155,7 @@ jobs:
155155
name: Create Release
156156
runs-on: ubuntu-latest
157157
steps:
158-
- uses: actions/checkout@v3
158+
- uses: actions/checkout@v4
159159

160160
- name: Download Cached artifacts
161161
uses: actions/download-artifact@v3

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Upcoming changes...
1313

14+
## [0.7.3] - 2024-09-12
15+
### Added
16+
- Added variables `DEFAULT_BASE_URL` and `DEFAULT_BASE_URL2` to separate the scan URL from the scan path
17+
1418
## [0.7.2] - 2024-04-17
1519
### Added
1620
- Added [tagging workflow](.github/workflows/version-tag.yml) to aid release generation
@@ -90,4 +94,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9094
[0.6.1]: https://github.com/scanoss/scanoss.java/compare/v0.6.0...v0.6.1
9195
[0.7.0]: https://github.com/scanoss/scanoss.java/compare/v0.6.1...v0.7.0
9296
[0.7.1]: https://github.com/scanoss/scanoss.java/compare/v0.7.0...v0.7.1
93-
[0.7.2]: https://github.com/scanoss/scanoss.java/compare/v0.7.1...v0.7.2
97+
[0.7.2]: https://github.com/scanoss/scanoss.java/compare/v0.7.1...v0.7.2
98+
[0.7.3]: https://github.com/scanoss/scanoss.java/compare/v0.7.2...v0.7.3

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.scanoss</groupId>
88
<artifactId>scanoss</artifactId>
9-
<version>0.7.2</version>
9+
<version>0.7.3</version>
1010
<packaging>jar</packaging>
1111
<name>scanoss.java</name>
1212
<url>https://github.com/scanoss/scanoss.java</url>

src/main/java/com/scanoss/rest/ScanApi.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ public class ScanApi {
6969
private Map<String, String> headers; // custom REST client headers
7070
private String customCert; // Custom certificate
7171
private Proxy proxy; // Proxy configuration
72+
private String baseUrl; // SCANOSS base API URI (to used instead of url)
7273

7374
@SuppressWarnings("unused")
7475
private ScanApi(String scanType, Duration timeout, Integer retryLimit, String url, String apiKey, String flags,
7576
String sbomType, String sbom,
7677
OkHttpClient okHttpClient, Map<String, String> headers, String customCert,
77-
Proxy proxy) {
78+
Proxy proxy, String baseUrl) {
7879
this.scanType = scanType;
7980
this.timeout = timeout;
8081
this.retryLimit = retryLimit;
@@ -85,7 +86,9 @@ private ScanApi(String scanType, Duration timeout, Integer retryLimit, String ur
8586
this.sbom = sbom;
8687
this.customCert = customCert;
8788
this.proxy = proxy;
88-
if (this.apiKey != null && !this.apiKey.isEmpty() && (url == null || url.isEmpty())) {
89+
if ((url == null || url.isEmpty()) && (baseUrl != null && ! baseUrl.isEmpty())) {
90+
this.url = String.format( "%s/%s", baseUrl, DEFAULT_SCAN_URL);
91+
} else if (this.apiKey != null && !this.apiKey.isEmpty() && (this.url == null || this.url.isEmpty())) {
8992
this.url = DEFAULT_SCAN_URL2; // Default premium SCANOSS endpoint
9093
} else if (url == null || url.isEmpty()) {
9194
this.url = DEFAULT_SCAN_URL; // Default free SCANOSS endpoint
@@ -235,7 +238,9 @@ private RequestBody multipartData(Map<String, String> data, String uuid) {
235238
}
236239

237240
private static final int RETRY_FAIL_SLEEP_TIME = 5; // Time to sleep between failed scan requests
238-
static final String DEFAULT_SCAN_URL = "https://api.osskb.org/scan/direct"; // Free OSS OSSKB URL
239-
static final String DEFAULT_SCAN_URL2 = "https://api.scanoss.com/scan/direct"; // Standard SCANOSS Premium URL
240-
// static final String SCANOSS_SCAN_URL = System.getenv("SCANOSS_SCAN_URL");
241+
public static final String DEFAULT_BASE_URL = "https://api.osskb.org";
242+
public static final String DEFAULT_BASE_URL2 = "https://api.scanoss.com";
243+
static final String DEFAULT_SCAN_PATH = "scan/direct";
244+
static final String DEFAULT_SCAN_URL = String.format( "%s/%s", DEFAULT_BASE_URL, DEFAULT_SCAN_PATH ); // Free OSS OSSKB URL
245+
static final String DEFAULT_SCAN_URL2 = String.format( "%s/%s", DEFAULT_BASE_URL2, DEFAULT_SCAN_PATH ); // Standard SCANOSS Premium URL
241246
}

0 commit comments

Comments
 (0)