Skip to content

Commit

Permalink
fix(importCDX): Resolve incorrect package/release count in import sum…
Browse files Browse the repository at this point in the history
…mary

Signed-off-by: sameed.ahmad <[email protected]>
  • Loading branch information
sameed20 committed Apr 30, 2024
1 parent 42ed65e commit 219792b
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,17 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a
componentsWithoutVcs.add(fullName);

if (CommonUtils.isNotNullEmptyOrWhitespace(pkgAddSummary.getId())) {
project.addToPackageIds(pkgAddSummary.getId());
pkg.setId(pkgAddSummary.getId());
if (AddDocumentRequestStatus.DUPLICATE.equals(pkgAddSummary.getRequestStatus())) {
pkgReuseCount++;
if(!CommonUtils.nullToEmptySet(project.getPackageIds()).contains(pkgAddSummary.getId())){
pkgReuseCount++;
}
Package dupPkg = packageDatabaseHandler.getPackageById(pkgAddSummary.getId());
if (CommonUtils.isNotNullEmptyOrWhitespace(dupPkg.getReleaseId())) {
if (!CommonUtils.nullToEmptyMap(project.getReleaseIdToUsage()).containsKey(dupPkg.getReleaseId())) {
project.putToReleaseIdToUsage(dupPkg.getReleaseId(), getDefaultRelation());
relReuseCount++;
}
relReuseCount++;
}
} else {
pkgCreationCount++;
Expand All @@ -274,11 +275,11 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a
duplicatePackages.add(fullName);
continue;
}
project.addToPackageIds(pkgAddSummary.getId());
} catch (SW360Exception e) {
log.error("An error occured while creating/adding package from SBOM: " + e.getMessage());
continue;
}

}
}
RequestStatus updateStatus = projectDatabaseHandler.updateProject(project, user);
Expand Down Expand Up @@ -651,7 +652,9 @@ private Map<String, String> importAllComponentsAsPackages(Map<String, List<org.c
dupPkg.setReleaseId(release.getId());
packageDatabaseHandler.updatePackage(dupPkg, user);
}
pkgReuseCount++;
if(!CommonUtils.nullToEmptySet(project.getPackageIds()).contains(pkg.getId())){
pkgReuseCount++;
}
} else {
pkgCreationCount++;
}
Expand Down

0 comments on commit 219792b

Please sign in to comment.