diff --git a/README.md b/README.md index 947ffb20..6c04d983 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ There are a couple of static classes that help common usage scenarios: `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`. The library has these configuration options: -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). -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`). -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). +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). +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`). +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). 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. diff --git a/resources/spdx-java-library.properties.sample b/resources/spdx-java-library.properties.sample index 1694b328..b641ffeb 100644 --- a/resources/spdx-java-library.properties.sample +++ b/resources/spdx-java-library.properties.sample @@ -1,8 +1,9 @@ -# if true, use licenses from stored set of licenses rather than from the spdx.org/licenses website -SPDXParser.OnlyUseLocalLicenses=false +# if true, only use license information stored within the JAR file at release time, rather than downloading the latest +# versions from the SPDX website +org.spdx.useJARLicenseInfoOnly=false -# if true, enable a local download cache for listed license files downloaded from the SPDX website -org.spdx.storage.listedlicense.enableCache=false +# if true, enable the download cache +org.spdx.downloadCacheEnabled=false # local download cache re-check interval, in seconds -org.spdx.storage.listedlicense.cacheCheckIntervalSecs=86400 +org.spdx.downloadCacheCheckIntervalSecs=86400 diff --git a/src/main/java/org/spdx/library/model/license/ListedLicenses.java b/src/main/java/org/spdx/library/model/license/ListedLicenses.java index 7ea38cb0..f390fbf2 100644 --- a/src/main/java/org/spdx/library/model/license/ListedLicenses.java +++ b/src/main/java/org/spdx/library/model/license/ListedLicenses.java @@ -59,11 +59,11 @@ public class ListedLicenses { * This constructor should only be called by the getListedLicenses method */ private ListedLicenses() { - // Note: this code confusingly uses different property values depending on the source (Java system property vs properties file), - // so we have to check both names in order to not break downstream consumers' legacy configurations. This is _NOT_ recommended for - // any new code that leverages the Configuration class. - onlyUseLocalLicenses = Boolean.parseBoolean(Configuration.getInstance().getProperty("SPDXParser.OnlyUseLocalLicenses", - Configuration.getInstance().getProperty("OnlyUseLocalLicenses", "false"))); + // Note: this code is confusing as this property changed names several times over time, and we want to preserve + // backwards compatibility for those downstream library users who are using the old/deprecated names + onlyUseLocalLicenses = Boolean.parseBoolean(Configuration.getInstance().getProperty("org.spdx.useJARLicenseInfoOnly", + Configuration.getInstance().getProperty("SPDXParser.OnlyUseLocalLicenses", + Configuration.getInstance().getProperty("OnlyUseLocalLicenses", "false")))); initializeLicenseModelStore(); } diff --git a/src/main/java/org/spdx/utility/DownloadCache.java b/src/main/java/org/spdx/utility/DownloadCache.java index 8b733bb7..9cced00a 100644 --- a/src/main/java/org/spdx/utility/DownloadCache.java +++ b/src/main/java/org/spdx/utility/DownloadCache.java @@ -89,8 +89,8 @@ public final class DownloadCache { System.getenv("XDG_CACHE_HOME")) + File.separator + "Spdx-Java-Library"; - private final String CONFIG_PROPERTY_CACHE_ENABLED = "org.spdx.storage.listedlicense.enableCache"; - private final String CONFIG_PROPERTY_CACHE_CHECK_INTERVAL_SECS = "org.spdx.storage.listedlicense.cacheCheckIntervalSecs"; + private final String CONFIG_PROPERTY_CACHE_ENABLED = "org.spdx.downloadCacheEnabled"; + private final String CONFIG_PROPERTY_CACHE_CHECK_INTERVAL_SECS = "org.spdx.downloadCacheCheckIntervalSecs"; private final boolean cacheEnabled; private final long cacheCheckIntervalSecs;