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
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected List<String> _verify(Set<String> verifiedIds, String specVersion) {
if (SpdxConstantsCompatV2.LICENSE_LIST_VERSION_PATTERN.matcher(version).matches()) {
return null;
} else {
return "License list version does not match the pattern M.N";
return "License list version does not match the pattern M.N or M.N.P";
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/org/spdx/library/model/v2/SpdxDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public SpdxDocument setDocumentDescribes(List<SpdxItem> documentDescribes) {
}
return (SpdxCreatorInformation)retval.get();
} else {
logger.warn("No creation info for document "+getName());
return null;
}
}
Expand Down Expand Up @@ -322,13 +321,10 @@ protected List<String> _verify(Set<String> verifiedIds, String verifySpecVersion
// documentDescribes relationships
try {
if (getDocumentDescribes().size() == 0) {
retval.add("Document must have at least one relationship of type DOCUMENT_DESCRIBES");
// Note - relationships are verified in the superclass. This should also recursively
// verify any other important objects.
} else {
for (SpdxElement element:getDocumentDescribes()) {
retval.addAll(element.verify(verifiedIds, specVersion));
if (getModelStore().getAllItems(getDocumentUri(), SpdxConstantsCompatV2.CLASS_SPDX_PACKAGE).count() != 1) {
retval.add("Document must have at least one relationship of type DOCUMENT_DESCRIBES or contain only a single SpdxPackage");
}
// Note - relationships are verified in the superclass which includes the documentDescribes relationship
}
} catch (InvalidSPDXAnalysisException e) {
retval.add("Error getting document describes: "+e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,5 +678,25 @@ public void testRemoveDescribes() throws InvalidSPDXAnalysisException {
doc.getDocumentDescribes().remove(describedElement);
modelStore.delete(CompatibleModelStoreWrapper.documentUriIdToUri(docUri, describedElementId, false));
}

// Test for issue 3 - zero document describes with a single package should pass validation
public void testSinglePackage() throws InvalidSPDXAnalysisException {
IModelStore modelStore = new MockModelStore();
String docUri = "https://some.doc.uri";
IModelCopyManager copyManager = new MockCopyManager();
SpdxDocument doc = new SpdxDocument(modelStore, docUri, copyManager, true);
doc.setCreationInfo(doc.createCreationInfo(Arrays.asList(CREATORS1), DATE1));
doc.setDataLicense(new SpdxListedLicense(modelStore, docUri, "CC0-1.0", copyManager, true));
doc.setName(DOC_NAME1);
doc.createPackage(doc.getModelStore().getNextId(IdType.SpdxId),
"Package 1", LICENSE1, "Pkg Copyright1", LICENSE2)
.setDownloadLocation("hg+https://hg.myproject.org/MyProject#src/somefile.c")
.setLicenseComments("Pkg License Comment 1")
.setFilesAnalyzed(false)
.setVersionInfo("version1")
.build();
List<String> verify = doc.verify();
assertTrue(verify.isEmpty());
}

}