diff --git a/README-V3-UPGRADE.md b/README-V3-UPGRADE.md index a5c91c2b..f8ef13d1 100644 --- a/README-V3-UPGRADE.md +++ b/README-V3-UPGRADE.md @@ -16,6 +16,11 @@ Notes: - Step #1 is optional; if not provided, a default ModelStore and CopyManager will be automatically created and configured by `SpdxModelFactory.init()`. - Once initialized (via Step #2), further calls to `DefaultModelStore.initialize(...)` will be ignored. +## Deprecated configuration for using online licenses from Jar file removed + +The configuration properties `OnlyUseLocalLicenses` and `SPDXParser.OnlyUseLocalLicenses` will no longer force the +library to use the licenses distributed with the Jar file. The supported property `org.spdx.useJARLicenseInfoOnly` should be used. + ## Classes and Methods moved to SPDX Java Core library The SPDX Java Core Library is in a separate repository and jar file. diff --git a/src/main/java/org/spdx/library/ListedLicenses.java b/src/main/java/org/spdx/library/ListedLicenses.java index a85819f8..04e8bb82 100644 --- a/src/main/java/org/spdx/library/ListedLicenses.java +++ b/src/main/java/org/spdx/library/ListedLicenses.java @@ -17,14 +17,13 @@ */ package org.spdx.library; -import java.io.IOException; -import java.io.InputStream; import java.util.*; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.spdx.Configuration; import org.spdx.core.InvalidSPDXAnalysisException; import org.spdx.library.model.v2.SpdxConstantsCompatV2; import org.spdx.library.model.v2.SpdxModelFactoryCompatV2; @@ -49,8 +48,6 @@ public class ListedLicenses { static final Logger logger = LoggerFactory.getLogger(ListedLicenses.class.getName()); - private static final String PROPERTIES_DIR = "resources"; - private static final String LISTED_LICENSE_PROPERTIES_FILENAME = PROPERTIES_DIR + "/" + "licenses.properties"; Properties licenseProperties; boolean onlyUseLocalLicenses; @@ -72,46 +69,11 @@ public class ListedLicenses { * This constructor should only be called by the getListedLicenses method */ private ListedLicenses() { - licenseProperties = loadLicenseProperties(); - onlyUseLocalLicenses = Boolean.parseBoolean( - System.getProperty("SPDXParser.OnlyUseLocalLicenses", licenseProperties.getProperty("OnlyUseLocalLicenses", "false"))); + onlyUseLocalLicenses = Boolean.parseBoolean(Configuration.getInstance().getProperty("org.spdx.useJARLicenseInfoOnly", + "false")); initializeLicenseModelStore(); } - /** - * Tries to load properties from LISTED_LICENSE_PROPERTIES_FILENAME, ignoring errors - * encountered during the process (e.g., the properties file doesn't exist, etc.). - * - * @return a (possibly empty) set of properties - */ - private static Properties loadLicenseProperties() { - listedLicenseModificationLock.writeLock().lock(); - try { - Properties licenseProperties = new Properties(); - InputStream in = null; - try { - in = ListedLicenses.class.getResourceAsStream("/" + LISTED_LICENSE_PROPERTIES_FILENAME); - if (in != null) { - licenseProperties.load(in); - } - } catch (IOException e) { - // Ignore it and fall through - logger.warn("IO Exception reading listed license properties file: {}", e.getMessage()); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - logger.warn("Unable to close listed license properties file: {}", e.getMessage()); - } - } - } - return licenseProperties; - } finally { - listedLicenseModificationLock.writeLock().unlock(); - } - } - private void initializeLicenseModelStore() { listedLicenseModificationLock.writeLock().lock(); try {