use of org.spdx.rdfparser.model.SpdxItem in project sw360portal by sw360.
the class SPDXParserTools method getLicenseInfoFromSpdx.
protected static LicenseInfoParsingResult getLicenseInfoFromSpdx(AttachmentContent attachmentContent, SpdxDocument doc) {
LicenseInfo licenseInfo = new LicenseInfo().setFilenames(Arrays.asList(attachmentContent.getFilename()));
licenseInfo.setLicenseNamesWithTexts(new HashSet<>());
licenseInfo.setCopyrights(new HashSet<>());
try {
for (SpdxItem spdxItem : doc.getDocumentDescribes()) {
licenseInfo.getLicenseNamesWithTexts().addAll(getAllLicenseTexts(spdxItem, true).collect(Collectors.toSet()));
licenseInfo.getCopyrights().addAll(getAllCopyrights(spdxItem).collect(Collectors.toSet()));
}
} catch (UncheckedInvalidSPDXAnalysisException e) {
return new LicenseInfoParsingResult().setStatus(LicenseInfoRequestStatus.FAILURE).setMessage(e.getInvalidSPDXAnalysisExceptionCause().getMessage());
} catch (InvalidSPDXAnalysisException e) {
return new LicenseInfoParsingResult().setStatus(LicenseInfoRequestStatus.FAILURE).setMessage(e.getMessage());
}
return new LicenseInfoParsingResult().setLicenseInfo(licenseInfo).setStatus(LicenseInfoRequestStatus.SUCCESS);
}
Aggregations