Skip to content

Commit

Permalink
Merge pull request #14 from scanoss/SP-1331
Browse files Browse the repository at this point in the history
SP-1331-Add-Default-Base-URL
  • Loading branch information
ortizjeronimo authored Sep 13, 2024
2 parents 8598c47 + 681507e commit ecbf952
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/java-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Java
uses: actions/[email protected].3
uses: actions/[email protected].4
with:
java-version: 11

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/java-native-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Java
uses: actions/[email protected].3
uses: actions/[email protected].4
with:
java-version: 11

Expand All @@ -34,7 +34,7 @@ jobs:
name: Build native on ${{ github.event.inputs.build_env }}
runs-on: ${{ github.event.inputs.build_env }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
name: Build and test java code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Java
uses: actions/[email protected].3
uses: actions/[email protected].4
with:
java-version: 11

Expand All @@ -31,10 +31,10 @@ jobs:
name: Package and upload package to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Java
uses: actions/[email protected].3
uses: actions/[email protected].4
with:
java-version: 11
server-id: ossrh
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: graalvm/setup-graalvm@v1
with:
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Download Cached artifacts
uses: actions/download-artifact@v3
Expand Down
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Upcoming changes...

## [0.7.3] - 2024-09-12
### Added
- 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
- Added [tagging workflow](.github/workflows/version-tag.yml) to aid release generation
Expand Down Expand Up @@ -90,4 +94,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.6.1]: https://github.com/scanoss/scanoss.java/compare/v0.6.0...v0.6.1
[0.7.0]: https://github.com/scanoss/scanoss.java/compare/v0.6.1...v0.7.0
[0.7.1]: https://github.com/scanoss/scanoss.java/compare/v0.7.0...v0.7.1
[0.7.2]: https://github.com/scanoss/scanoss.java/compare/v0.7.1...v0.7.2
[0.7.2]: https://github.com/scanoss/scanoss.java/compare/v0.7.1...v0.7.2
[0.7.3]: https://github.com/scanoss/scanoss.java/compare/v0.7.2...v0.7.3
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.scanoss</groupId>
<artifactId>scanoss</artifactId>
<version>0.7.2</version>
<version>0.7.3</version>
<packaging>jar</packaging>
<name>scanoss.java</name>
<url>https://github.com/scanoss/scanoss.java</url>
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/com/scanoss/rest/ScanApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ public class ScanApi {
private Map<String, String> 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<String, String> headers, String customCert,
Proxy proxy) {
Proxy proxy, String baseUrl) {
this.scanType = scanType;
this.timeout = timeout;
this.retryLimit = retryLimit;
Expand All @@ -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
Expand Down Expand Up @@ -235,7 +238,9 @@ private RequestBody multipartData(Map<String, String> 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
}

0 comments on commit ecbf952

Please sign in to comment.