diff --git a/src/main/java/org/spdx/tools/MatchingStandardLicenses.java b/src/main/java/org/spdx/tools/MatchingStandardLicenses.java index d47742d..9d0ddc2 100644 --- a/src/main/java/org/spdx/tools/MatchingStandardLicenses.java +++ b/src/main/java/org/spdx/tools/MatchingStandardLicenses.java @@ -53,6 +53,7 @@ public static void main(String[] args) { usage(); System.exit(ERROR_STATUS); } + @SuppressWarnings("null") File textFile = new File(args[0]); if (!textFile.exists()) { diff --git a/src/main/java/org/spdx/tools/Verify.java b/src/main/java/org/spdx/tools/Verify.java index 33d03ae..84b9a59 100644 --- a/src/main/java/org/spdx/tools/Verify.java +++ b/src/main/java/org/spdx/tools/Verify.java @@ -86,7 +86,6 @@ public static void main(String[] args) { fileType = SpdxToolsHelper.fileToFileType(new File(args[0])); } verify = verify(args[0], fileType); - } catch (SpdxVerificationException e) { System.out.println(e.getMessage()); System.exit(ERROR_STATUS); @@ -97,7 +96,7 @@ public static void main(String[] args) { // separate out the warning from errors List warnings = new ArrayList<>(); List errors = new ArrayList<>(); - for (String verifyMsg:verify) { + for (String verifyMsg : verify) { if (verifyMsg.contains(" is deprecated.")) { warnings.add(verifyMsg); } else { diff --git a/src/main/java/org/spdx/tools/compare/CreatorSheet.java b/src/main/java/org/spdx/tools/compare/CreatorSheet.java index d67783c..882760b 100644 --- a/src/main/java/org/spdx/tools/compare/CreatorSheet.java +++ b/src/main/java/org/spdx/tools/compare/CreatorSheet.java @@ -26,6 +26,7 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.spdx.core.InvalidSPDXAnalysisException; +import org.spdx.library.model.v2.SpdxCreatorInformation; import org.spdx.utility.compare.SpdxCompareException; import org.spdx.utility.compare.SpdxComparer; @@ -90,17 +91,20 @@ public void importCompareResults(SpdxComparer comparer, List docNames) t for (int i = 0; i < comparer.getNumSpdxDocs(); i++) { Cell headerCell = header.getCell(i); headerCell.setCellValue(docNames.get(i)); - String[] creators = comparer.getSpdxDoc(i).getCreationInfo().getCreators().toArray(new String[comparer.getSpdxDoc(i).getCreationInfo().getCreators().size()]); - Arrays.sort(creators); - for (int j = 0; j < creators.length; j++) { - Cell creatorCell = null; - while (j+1 > this.getNumDataRows()) { - this.addRow(); + SpdxCreatorInformation creationInfo = comparer.getSpdxDoc(i).getCreationInfo(); + if (creationInfo != null) { + String[] creators = creationInfo.getCreators().toArray(new String[creationInfo.getCreators().size()]); + Arrays.sort(creators); + for (int j = 0; j < creators.length; j++) { + Cell creatorCell = null; + while (j+1 > this.getNumDataRows()) { + this.addRow(); + } + creatorCell = sheet.getRow(j+1).createCell(i); + creatorCell.setCellValue(creators[j]); } - creatorCell = sheet.getRow(j+1).createCell(i); - creatorCell.setCellValue(creators[j]); } } } -} \ No newline at end of file +} diff --git a/src/main/java/org/spdx/tools/compare/DocumentSheet.java b/src/main/java/org/spdx/tools/compare/DocumentSheet.java index 8dc0e09..bcbb8d2 100644 --- a/src/main/java/org/spdx/tools/compare/DocumentSheet.java +++ b/src/main/java/org/spdx/tools/compare/DocumentSheet.java @@ -26,11 +26,12 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.spdx.core.InvalidSPDXAnalysisException; +import org.spdx.library.model.v2.SpdxCreatorInformation; import org.spdx.utility.compare.SpdxCompareException; import org.spdx.utility.compare.SpdxComparer; /** - * Sheet to hold compare information at the docment level: + * Sheet to hold compare information at the document level: * Created, Data License, Document Comment * The first row summarizes which fields are different, the subsequent rows are the * specific date from each result @@ -254,9 +255,12 @@ private void importLicenseListVersions(SpdxComparer comparer) throws SpdxCompare // data rows for (int i = 0; i < comparer.getNumSpdxDocs(); i++) { cell = sheet.getRow(getFirstDataRow()+i+1).createCell(LICENSE_LIST_VERSION_COL); - Optional licenseListVersion = comparer.getSpdxDoc(i).getCreationInfo().getLicenseListVersion(); - if (licenseListVersion.isPresent()) { - cell.setCellValue(licenseListVersion.get()); + SpdxCreatorInformation creationInfo = comparer.getSpdxDoc(i).getCreationInfo(); + if (creationInfo != null) { + Optional licenseListVersion = creationInfo.getLicenseListVersion(); + if (licenseListVersion.isPresent()) { + cell.setCellValue(licenseListVersion.get()); + } } } } @@ -340,11 +344,13 @@ private void importCreatorComment(SpdxComparer comparer) throws InvalidSPDXAnaly // data rows for (int i = 0; i < comparer.getNumSpdxDocs(); i++) { cell = sheet.getRow(getFirstDataRow()+i+1).createCell(CREATOR_COMMENT_COL); - Optional creatorComment = comparer.getSpdxDoc(i).getCreationInfo().getComment(); - if (creatorComment.isPresent()) { - cell.setCellValue(creatorComment.get()); + SpdxCreatorInformation creationInfo = comparer.getSpdxDoc(i).getCreationInfo(); + if (creationInfo != null) { + Optional creatorComment = creationInfo.getComment(); + if (creatorComment.isPresent()) { + cell.setCellValue(creatorComment.get()); + } } - } } @@ -364,7 +370,10 @@ private void importCreationDate(SpdxComparer comparer) throws InvalidSPDXAnalysi // data rows for (int i = 0; i < comparer.getNumSpdxDocs(); i++) { cell = sheet.getRow(getFirstDataRow()+i+1).createCell(CREATION_DATE_COL); - cell.setCellValue(comparer.getSpdxDoc(i).getCreationInfo().getCreated()); + SpdxCreatorInformation creationInfo = comparer.getSpdxDoc(i).getCreationInfo(); + if (creationInfo != null) { + cell.setCellValue(creationInfo.getCreated()); + } } } diff --git a/src/main/java/org/spdx/tools/compare/PackageSheet.java b/src/main/java/org/spdx/tools/compare/PackageSheet.java index 1fcdfb8..e0ac331 100644 --- a/src/main/java/org/spdx/tools/compare/PackageSheet.java +++ b/src/main/java/org/spdx/tools/compare/PackageSheet.java @@ -35,6 +35,7 @@ import org.spdx.library.model.v2.SpdxDocument; import org.spdx.library.model.v2.SpdxPackage; import org.spdx.library.model.v2.SpdxPackageVerificationCode; +import org.spdx.library.model.v2.license.AnyLicenseInfo; import org.spdx.utility.compare.SpdxCompareException; import org.spdx.utility.compare.SpdxComparer; import org.spdx.utility.compare.SpdxPackageComparer; @@ -404,7 +405,10 @@ private void addPackageToSheet(SpdxPackageComparer comparer, } concludedLicenseRow.createCell(FIRST_DOC_COL+i).setCellValue(pkg.getLicenseConcluded().toString()); licenseInfosFromFilesRow.createCell(FIRST_DOC_COL+i).setCellValue(CompareHelper.licenseInfosToString(pkg.getLicenseInfoFromFiles())); - declaredLicenseRow.createCell(FIRST_DOC_COL+i).setCellValue(pkg.getLicenseDeclared().toString()); + AnyLicenseInfo licenseDeclared = pkg.getLicenseDeclared(); + if (licenseDeclared != null) { + declaredLicenseRow.createCell(FIRST_DOC_COL+i).setCellValue(licenseDeclared.toString()); + } Optional licenseComments = pkg.getLicenseComments(); if (licenseComments.isPresent()) { licenseCommentRow.createCell(FIRST_DOC_COL+i).setCellValue(licenseComments.get()); diff --git a/testResources/sourcefiles/DocumentSheet.java b/testResources/sourcefiles/DocumentSheet.java index defc8e1..0b9f378 100644 --- a/testResources/sourcefiles/DocumentSheet.java +++ b/testResources/sourcefiles/DocumentSheet.java @@ -29,7 +29,7 @@ import org.spdx.utility.compare.SpdxComparer; /** - * Sheet to hold compare information at the docment level: + * Sheet to hold compare information at the document level: * Created, Data License, Document Comment * The first row summarizes which fields are different, the subsequent rows are the * specific date from each result