Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
<dependency>
<groupId>org.spdx</groupId>
<artifactId>spdx-java-core</artifactId>
<version>1.0.0-RC1</version>
<version>1.0.0-RC2</version>
</dependency>
<dependency>
<groupId>org.spdx</groupId>
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/spdx/library/LicenseInfoFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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<DictionaryEntry> customIdToUri) throws InvalidLicenseStringException, DefaultStoreNotInitialized {
@Nullable List<DictionaryEntry> customIdToUri) throws InvalidLicenseStringException, DefaultStoreNotInitializedException {
if (Objects.isNull(store)) {
store = DefaultModelStore.getDefaultModelStore();
}
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/spdx/library/ListedLicenses.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/spdx/library/ModelCopyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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");
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/spdx/storage/simple/InMemSpdxStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -414,10 +414,10 @@ public void leaveCriticalSection(IModelStoreLock lock) {
}

@Override
public Optional<String> getCaseSensisitiveId(String nameSpace, String caseInsensisitiveId) {
public Optional<String> 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();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/spdx/storage/simple/StoredTypedItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/spdx/library/LicenseInfoFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/spdx/library/LicenseInfoFactoryTestV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<CustomLicense> customLicenses = new ArrayList<>();
Expand Down Expand Up @@ -684,7 +681,7 @@ public void testConvertAndStoreExternalDocRef() throws InvalidSPDXAnalysisExcept
Collection<ExternalMap> docImports = new ArrayList<>();
NamespaceMap result = converter.convertAndStore(externalDocRef, docImports);
assertEquals(externalDocumentId, result.getPrefix());
assertEquals(externalDocumentUri, result.getNamespace());
assertEquals(externalDocumentUri + "#", result.getNamespace());
}

List<Relationship> findRelationship(List<Relationship> relationships, @Nullable RelationshipType relationshipType,
Expand Down