Skip to content

Commit d4bf741

Browse files
authored
Merge pull request #206 from pmonks/master
Rename configuration properties to be inline with the separate DownloadCache class
2 parents 150b5e2 + b171418 commit d4bf741

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ There are a couple of static classes that help common usage scenarios:
4040
`Spdx-Java-Library` can be configured using either Java system properties or a Java properties file located in the runtime CLASSPATH at `/resources/spdx-java-library.properties`.
4141

4242
The library has these configuration options:
43-
1. `SPDXParser.OnlyUseLocalLicenses` - a boolean that controls whether the (potentially out of date) listed license information bundled inside the JAR is used (true), vs the library downloading the latest files from the SPDX website (false). Default is false (always download the latest files from the SPDX website).
44-
2. `org.spdx.storage.listedlicense.enableCache` - a boolean that enables or disables a local cache for downloaded listed license information. Defaults to `false` (the cache is disabled). The cache location is determined as per the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) (i.e. `${XDG_CACHE_HOME}/Spdx-Java-Library` or `${HOME}/.cache/Spdx-Java-Library`).
45-
3. `org.spdx.storage.listedlicense.cacheCheckIntervalSecs` - a long that controls how often each cache entry is rechecked for staleness, in units of seconds. Defaults to 86,400 seconds (24 hours). Set to 0 (zero) to have each cache entry checked every time (note: this will result in a lot more network I/O and negatively impact performance, albeit there is still a substantial performance saving vs not using the cache at all).
43+
1. `org.spdx.useJARLicenseInfoOnly` - a boolean that controls whether the (potentially out of date) listed license information bundled inside the JAR is used (true), vs the library downloading the latest files from the SPDX website (false). Default is false (always download the latest files from the SPDX website).
44+
2. `org.spdx.downloadCacheEnabled` - a boolean that enables or disables the download cache. Defaults to `false` (the cache is disabled). The cache location is determined as per the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) (i.e. `${XDG_CACHE_HOME}/Spdx-Java-Library` or `${HOME}/.cache/Spdx-Java-Library`).
45+
3. `org.spdx.downloadCacheCheckIntervalSecs` - a long that controls how often each cache entry is rechecked for staleness, in units of seconds. Defaults to 86,400 seconds (24 hours). Set to 0 (zero) to have each cache entry checked every time (note: this will result in a lot more network I/O and negatively impact performance, albeit there is still a substantial performance saving vs not using the cache at all).
4646

4747
Note that these configuration options can only be modified prior to first use of Spdx-Java-Library. Once the library is initialized, subsequent changes will have no effect.
4848

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# if true, use licenses from stored set of licenses rather than from the spdx.org/licenses website
2-
SPDXParser.OnlyUseLocalLicenses=false
1+
# if true, only use license information stored within the JAR file at release time, rather than downloading the latest
2+
# versions from the SPDX website
3+
org.spdx.useJARLicenseInfoOnly=false
34

4-
# if true, enable a local download cache for listed license files downloaded from the SPDX website
5-
org.spdx.storage.listedlicense.enableCache=false
5+
# if true, enable the download cache
6+
org.spdx.downloadCacheEnabled=false
67

78
# local download cache re-check interval, in seconds
8-
org.spdx.storage.listedlicense.cacheCheckIntervalSecs=86400
9+
org.spdx.downloadCacheCheckIntervalSecs=86400

src/main/java/org/spdx/library/model/license/ListedLicenses.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ public class ListedLicenses {
5959
* This constructor should only be called by the getListedLicenses method
6060
*/
6161
private ListedLicenses() {
62-
// Note: this code confusingly uses different property values depending on the source (Java system property vs properties file),
63-
// so we have to check both names in order to not break downstream consumers' legacy configurations. This is _NOT_ recommended for
64-
// any new code that leverages the Configuration class.
65-
onlyUseLocalLicenses = Boolean.parseBoolean(Configuration.getInstance().getProperty("SPDXParser.OnlyUseLocalLicenses",
66-
Configuration.getInstance().getProperty("OnlyUseLocalLicenses", "false")));
62+
// Note: this code is confusing as this property changed names several times over time, and we want to preserve
63+
// backwards compatibility for those downstream library users who are using the old/deprecated names
64+
onlyUseLocalLicenses = Boolean.parseBoolean(Configuration.getInstance().getProperty("org.spdx.useJARLicenseInfoOnly",
65+
Configuration.getInstance().getProperty("SPDXParser.OnlyUseLocalLicenses",
66+
Configuration.getInstance().getProperty("OnlyUseLocalLicenses", "false"))));
6767
initializeLicenseModelStore();
6868
}
6969

src/main/java/org/spdx/utility/DownloadCache.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public final class DownloadCache {
8989
System.getenv("XDG_CACHE_HOME")) +
9090
File.separator + "Spdx-Java-Library";
9191

92-
private final String CONFIG_PROPERTY_CACHE_ENABLED = "org.spdx.storage.listedlicense.enableCache";
93-
private final String CONFIG_PROPERTY_CACHE_CHECK_INTERVAL_SECS = "org.spdx.storage.listedlicense.cacheCheckIntervalSecs";
92+
private final String CONFIG_PROPERTY_CACHE_ENABLED = "org.spdx.downloadCacheEnabled";
93+
private final String CONFIG_PROPERTY_CACHE_CHECK_INTERVAL_SECS = "org.spdx.downloadCacheCheckIntervalSecs";
9494
private final boolean cacheEnabled;
9595
private final long cacheCheckIntervalSecs;
9696

0 commit comments

Comments
 (0)