diff --git a/pom.xml b/pom.xml index cab54b93..d8046645 100644 --- a/pom.xml +++ b/pom.xml @@ -153,7 +153,7 @@ org.spdx spdx-java-core - 1.0.0-RC1 + 1.0.0-RC2 org.spdx diff --git a/src/main/java/org/spdx/library/LicenseInfoFactory.java b/src/main/java/org/spdx/library/LicenseInfoFactory.java index 4b8d31f2..e0bc96a9 100644 --- a/src/main/java/org/spdx/library/LicenseInfoFactory.java +++ b/src/main/java/org/spdx/library/LicenseInfoFactory.java @@ -26,7 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spdx.core.DefaultModelStore; -import org.spdx.core.DefaultStoreNotInitialized; +import org.spdx.core.DefaultStoreNotInitializedException; import org.spdx.core.IModelCopyManager; import org.spdx.core.InvalidSPDXAnalysisException; import org.spdx.library.model.v2.license.InvalidLicenseStringException; @@ -92,10 +92,10 @@ public static SpdxListedLicense getListedLicenseByIdCompatV2(String licenseId)th * @param copyManager allows for copying of any properties set which use other model stores or document URI's. If null, the default will be used. * @return an SPDXLicenseInfo created from the string * @throws InvalidLicenseStringException if the license string is not valid - * @throws DefaultStoreNotInitialized if the default model store is not initialized + * @throws DefaultStoreNotInitializedException if the default model store is not initialized */ public static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseStringCompatV2(String licenseString, @Nullable IModelStore store, - @Nullable String documentUri, @Nullable IModelCopyManager copyManager) throws InvalidLicenseStringException, DefaultStoreNotInitialized { + @Nullable String documentUri, @Nullable IModelCopyManager copyManager) throws InvalidLicenseStringException, DefaultStoreNotInitializedException { if (Objects.isNull(store)) { store = DefaultModelStore.getDefaultModelStore(); } @@ -136,11 +136,11 @@ public static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseS * @param customIdToUri Mapping of the id prefixes used in the license expression to the namespace preceding the external ID * @return an SPDXLicenseInfo created from the string * @throws InvalidLicenseStringException if the license string is not valid - * @throws DefaultStoreNotInitialized if the default model store is not initialized + * @throws DefaultStoreNotInitializedException if the default model store is not initialized */ public static AnyLicenseInfo parseSPDXLicenseString(String licenseString, @Nullable IModelStore store, @Nullable String customLicensePrefix, @Nullable IModelCopyManager copyManager, - @Nullable List customIdToUri) throws InvalidLicenseStringException, DefaultStoreNotInitialized { + @Nullable List customIdToUri) throws InvalidLicenseStringException, DefaultStoreNotInitializedException { if (Objects.isNull(store)) { store = DefaultModelStore.getDefaultModelStore(); } @@ -175,9 +175,9 @@ public static AnyLicenseInfo parseSPDXLicenseString(String licenseString, @Nulla * @param licenseString String conforming to the syntax * @return an SPDXLicenseInfo created from the string * @throws InvalidLicenseStringException if the license string is not valid - * @throws DefaultStoreNotInitialized if the default model store is not initialized + * @throws DefaultStoreNotInitializedException if the default model store is not initialized */ - public static AnyLicenseInfo parseSPDXLicenseString(String licenseString) throws InvalidLicenseStringException, DefaultStoreNotInitialized { + public static AnyLicenseInfo parseSPDXLicenseString(String licenseString) throws InvalidLicenseStringException, DefaultStoreNotInitializedException { return parseSPDXLicenseString(licenseString, null, null, null, null); } @@ -196,9 +196,9 @@ public static AnyLicenseInfo parseSPDXLicenseString(String licenseString) throws * @param licenseString String conforming to the syntax * @return an SPDXLicenseInfo created from the string * @throws InvalidLicenseStringException On invalid license expression - * @throws DefaultStoreNotInitialized On the model store not being initialized - see DefaultModelStore in SPDX core package + * @throws DefaultStoreNotInitializedException On the model store not being initialized - see DefaultModelStore in SPDX core package */ - public static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseStringCompatV2(String licenseString) throws InvalidLicenseStringException, DefaultStoreNotInitialized { + public static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseStringCompatV2(String licenseString) throws InvalidLicenseStringException, DefaultStoreNotInitializedException { return parseSPDXLicenseStringCompatV2(licenseString, null, null, null); } diff --git a/src/main/java/org/spdx/library/ListedLicenses.java b/src/main/java/org/spdx/library/ListedLicenses.java index 5935e95f..a85819f8 100644 --- a/src/main/java/org/spdx/library/ListedLicenses.java +++ b/src/main/java/org/spdx/library/ListedLicenses.java @@ -26,11 +26,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spdx.core.InvalidSPDXAnalysisException; -import org.spdx.core.SpdxIdNotFoundException; import org.spdx.library.model.v2.SpdxConstantsCompatV2; import org.spdx.library.model.v2.SpdxModelFactoryCompatV2; import org.spdx.library.model.v2.license.SpdxListedLicense; -import org.spdx.library.model.v2.license.SpdxListedLicenseException; import org.spdx.library.model.v3_0_1.core.CreationInfo; import org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense; import org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException; diff --git a/src/main/java/org/spdx/library/ModelCopyManager.java b/src/main/java/org/spdx/library/ModelCopyManager.java index 3cc10a8a..cff1fbe4 100644 --- a/src/main/java/org/spdx/library/ModelCopyManager.java +++ b/src/main/java/org/spdx/library/ModelCopyManager.java @@ -351,7 +351,7 @@ private void copyIndividualProperty(IModelStore toStore, String toObjectUri, IMo } /** - * Copies a property which is is a collection + * Copies a property which is a collection * @param toStore Model Store to copy to * @param toObjectUri URI to copy to * @param fromStore Model Store containing the source item @@ -460,7 +460,7 @@ private String sourceUriToObjectUri(String sourceUri, IdType idType, IModelStore case SpdxId: return toNamespace + toStore.getNextId(IdType.SpdxId); case ListedLicense: return sourceUri; case Anonymous: - case Unkown: + case Unknown: default: return toStore.getNextId(IdType.Anonymous); } } @@ -476,8 +476,9 @@ private String sourceUriToObjectUri(String sourceUri, IdType idType, IModelStore */ private String sourceUriToObjectUriV2Compat(String sourceUri, IdType idType, IModelStore toStore, String toNamespace, boolean isExternalDocRef) throws InvalidSPDXAnalysisException { - if ((isExternalDocRef || !(IdType.Anonymous.equals(idType) || - IdType.ListedLicense.equals(idType) || IdType.Unkown.equals(idType))) + //noinspection deprecation + if ((isExternalDocRef || !(IdType.Anonymous.equals(idType) || IdType.ListedLicense.equals(idType) || + IdType.Unknown.equals(idType) || IdType.Unkown.equals(idType))) && (Objects.isNull(toNamespace) || toNamespace.isEmpty())) { throw new InvalidSPDXAnalysisException("A to namespace or document URI must be provided to copy SPDX element for SPDX spec version 2"); } @@ -510,7 +511,7 @@ private String sourceUriToObjectUriV2Compat(String sourceUri, IdType idType, toNamespace + toStore.getNextId(IdType.SpdxId); case ListedLicense: return sourceUri; case Anonymous: - case Unkown: + case Unknown: default: return toStore.getNextId(IdType.Anonymous); } } diff --git a/src/main/java/org/spdx/library/conversion/Spdx2to3Converter.java b/src/main/java/org/spdx/library/conversion/Spdx2to3Converter.java index c0b0739f..98cc4f66 100644 --- a/src/main/java/org/spdx/library/conversion/Spdx2to3Converter.java +++ b/src/main/java/org/spdx/library/conversion/Spdx2to3Converter.java @@ -726,7 +726,7 @@ public NamespaceMap convertAndStore(org.spdx.library.model.v2.ExternalDocumentRe NamespaceMap toNamespaceMap = (NamespaceMap)SpdxModelClassFactoryV3.getModelObject(toModelStore, toObjectUri, SpdxConstantsV3.CORE_NAMESPACE_MAP, copyManager, true, defaultUriPrefix); toNamespaceMap.setPrefix(externalDocRef.getId()); - toNamespaceMap.setNamespace(externalDocRef.getSpdxDocumentNamespace()); + toNamespaceMap.setNamespace(externalDocRef.getSpdxDocumentNamespace() + "#"); return toNamespaceMap; } diff --git a/src/main/java/org/spdx/storage/listedlicense/SpdxListedLicenseModelStore.java b/src/main/java/org/spdx/storage/listedlicense/SpdxListedLicenseModelStore.java index bd86dbf5..d3392e3d 100644 --- a/src/main/java/org/spdx/storage/listedlicense/SpdxListedLicenseModelStore.java +++ b/src/main/java/org/spdx/storage/listedlicense/SpdxListedLicenseModelStore.java @@ -180,8 +180,10 @@ private void loadIds() throws InvalidSPDXAnalysisException { ExceptionJsonTOC exceptionToc = gson.fromJson(tocJsonStr.toString(), ExceptionJsonTOC.class); exceptionIds = exceptionToc.getExceptionIds(); } catch (MalformedURLException e) { + logger.error("License TOC URL invalid", e); throw new SpdxListedLicenseException("License TOC URL invalid", e) ; } catch (IOException e) { + logger.error("I/O error reading license TOC", e); throw new SpdxListedLicenseException("I/O error reading license TOC", e); } finally { if (reader != null) { @@ -1196,7 +1198,7 @@ public IdType getIdType(String objectUri) { } else if (objectUri.startsWith(LicenseCreatorAgent.OBJECT_URI_PREFIX)) { return IdType.SpdxId; } else { - return IdType.Unkown; + return IdType.Unknown; } } diff --git a/src/main/java/org/spdx/storage/simple/InMemSpdxStore.java b/src/main/java/org/spdx/storage/simple/InMemSpdxStore.java index 0ac2a50e..39033b50 100644 --- a/src/main/java/org/spdx/storage/simple/InMemSpdxStore.java +++ b/src/main/java/org/spdx/storage/simple/InMemSpdxStore.java @@ -393,7 +393,7 @@ public IdType getIdType(String objectUri) { if (objectUri.contains("://spdx.org/licenses/") || LicenseInfoFactory.isSpdxListedLicenseId(objectUri) || LicenseInfoFactory.isSpdxListedExceptionId(objectUri)) { return IdType.ListedLicense; } else { - return IdType.Unkown; + return IdType.Unknown; } } @@ -414,10 +414,10 @@ public void leaveCriticalSection(IModelStoreLock lock) { } @Override - public Optional getCaseSensisitiveId(String nameSpace, String caseInsensisitiveId) { + public Optional getCaseSensitiveId(String nameSpace, String caseInsensitiveId) { Objects.requireNonNull(nameSpace, "Namespace can not be null"); - Objects.requireNonNull(caseInsensisitiveId, "CaseInsensisitiveId can not be null"); - String objectUri = nameSpace + "#" + caseInsensisitiveId; + Objects.requireNonNull(caseInsensitiveId, "CaseInsensitiveId can not be null"); + String objectUri = nameSpace + "#" + caseInsensitiveId; StoredTypedItem item = typedValueMap.get(objectUri.toLowerCase()); if (Objects.isNull(item)) { return Optional.empty(); diff --git a/src/main/java/org/spdx/storage/simple/StoredTypedItem.java b/src/main/java/org/spdx/storage/simple/StoredTypedItem.java index 43687135..a16c7e0e 100644 --- a/src/main/java/org/spdx/storage/simple/StoredTypedItem.java +++ b/src/main/java/org/spdx/storage/simple/StoredTypedItem.java @@ -137,6 +137,8 @@ public void setValue(PropertyDescriptor propertyDescriptor, Object value) throws !String.class.isAssignableFrom(value.getClass()) && !Boolean.class.isAssignableFrom(value.getClass()) && !Integer.class.isAssignableFrom(value.getClass()) && + !Double.class.isAssignableFrom(value.getClass()) && + !Float.class.isAssignableFrom((value.getClass())) && !TypedValue.class.isAssignableFrom(value.getClass()) && !(value instanceof IndividualUriValue)) { throw new SpdxInvalidTypeException(value.getClass() +" is not a supported class to be stored."); diff --git a/src/test/java/org/spdx/library/LicenseInfoFactoryTest.java b/src/test/java/org/spdx/library/LicenseInfoFactoryTest.java index b7e5c7c2..5a03d903 100644 --- a/src/test/java/org/spdx/library/LicenseInfoFactoryTest.java +++ b/src/test/java/org/spdx/library/LicenseInfoFactoryTest.java @@ -21,7 +21,7 @@ import java.util.List; import org.spdx.core.DefaultModelStore; -import org.spdx.core.DefaultStoreNotInitialized; +import org.spdx.core.DefaultStoreNotInitializedException; import org.spdx.core.InvalidSPDXAnalysisException; import org.spdx.library.model.v2.SpdxConstantsCompatV2; import org.spdx.library.model.v2.license.InvalidLicenseStringException; @@ -133,7 +133,7 @@ protected void tearDown() throws Exception { DefaultModelStore.initialize(new InMemSpdxStore(), "https://default/prefix", new ModelCopyManager()); } - public void testParseSPDXLicenseString() throws InvalidLicenseStringException, DefaultStoreNotInitialized { + public void testParseSPDXLicenseString() throws InvalidLicenseStringException, DefaultStoreNotInitializedException { String parseString = COMPLEX_LICENSE.toString(); AnyLicenseInfo li = LicenseInfoFactory.parseSPDXLicenseString(parseString); if (!li.equals(COMPLEX_LICENSE)) { diff --git a/src/test/java/org/spdx/library/LicenseInfoFactoryTestV2.java b/src/test/java/org/spdx/library/LicenseInfoFactoryTestV2.java index d556ab9f..07a8c803 100644 --- a/src/test/java/org/spdx/library/LicenseInfoFactoryTestV2.java +++ b/src/test/java/org/spdx/library/LicenseInfoFactoryTestV2.java @@ -21,7 +21,7 @@ import java.util.List; import org.spdx.core.DefaultModelStore; -import org.spdx.core.DefaultStoreNotInitialized; +import org.spdx.core.DefaultStoreNotInitializedException; import org.spdx.core.InvalidSPDXAnalysisException; import org.spdx.library.model.v2.GenericModelObject; import org.spdx.library.model.v2.SpdxConstantsCompatV2; @@ -117,7 +117,7 @@ protected void tearDown() throws Exception { DefaultModelStore.initialize(new InMemSpdxStore(), "https://default/prefix", new ModelCopyManager()); } - public void testParseSPDXLicenseString() throws InvalidLicenseStringException, DefaultStoreNotInitialized { + public void testParseSPDXLicenseString() throws InvalidLicenseStringException, DefaultStoreNotInitializedException { String parseString = COMPLEX_LICENSE.toString(); AnyLicenseInfo li = LicenseInfoFactory.parseSPDXLicenseStringCompatV2(parseString); if (!li.equals(COMPLEX_LICENSE)) { diff --git a/src/test/java/org/spdx/library/conversion/Spdx2to3ConverterTest.java b/src/test/java/org/spdx/library/conversion/Spdx2to3ConverterTest.java index 3efa681e..265cc822 100644 --- a/src/test/java/org/spdx/library/conversion/Spdx2to3ConverterTest.java +++ b/src/test/java/org/spdx/library/conversion/Spdx2to3ConverterTest.java @@ -178,9 +178,6 @@ public void testConvertCreationInfo() throws InvalidSPDXAnalysisException { assertTrue(verify.isEmpty()); } - /** - * Test method for {@link org.spdx.library.conversion.Spdx2to3Converter#Spdx2to3Converter(org.spdx.storage.IModelStore, org.spdx.library.ModelCopyManager, org.spdx.library.model.v3_0_1.core.CreationInfo, java.lang.String, java.lang.String)}. - */ @Test public void testSpdx2to3Converter() { Spdx2to3Converter result = new Spdx2to3Converter(toModelStore, copyManager, defaultCreationInfo, @@ -625,7 +622,7 @@ public void testConvertAndStoreSpdxDocument() throws InvalidSPDXAnalysisExceptio NamespaceMap[] namespaceMaps = result.getNamespaceMaps().toArray(new NamespaceMap[result.getNamespaceMaps().size()]); assertEquals(1, namespaceMaps.length); - assertEquals(externalDocumentUri, namespaceMaps[0].getNamespace()); + assertEquals(externalDocumentUri + "#", namespaceMaps[0].getNamespace()); assertEquals(externalDocumentId, namespaceMaps[0].getPrefix()); List customLicenses = new ArrayList<>(); @@ -684,7 +681,7 @@ public void testConvertAndStoreExternalDocRef() throws InvalidSPDXAnalysisExcept Collection docImports = new ArrayList<>(); NamespaceMap result = converter.convertAndStore(externalDocRef, docImports); assertEquals(externalDocumentId, result.getPrefix()); - assertEquals(externalDocumentUri, result.getNamespace()); + assertEquals(externalDocumentUri + "#", result.getNamespace()); } List findRelationship(List relationships, @Nullable RelationshipType relationshipType,