Skip to content

Commit

Permalink
Merge pull request eclipse-sw360#2221 from Siemens-Healthineers/fix/d…
Browse files Browse the repository at this point in the history
…uplicate-releases-getting-created-with-different-name

fix(importCDX): Resolve duplicate release creation during SBOM import

Reviewed by: [email protected]
Test by: [email protected]
  • Loading branch information
ag4ums authored Apr 15, 2024
2 parents 770f097 + ecbb8ed commit 867bd85
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ private Map<String, String> importAllComponentsAsPackages(Map<String, List<org.c

if (CommonUtils.isNotNullEmptyOrWhitespace(compAddSummary.getId())) {
comp.setId(compAddSummary.getId());
String existingCompName = getComponetNameById(comp.getId(), user);
comp.setName(existingCompName);
} else {
// in case of more than 1 duplicate found, then continue and show error message in UI.
log.warn("found multiple components: " + comp.getName());
Expand Down Expand Up @@ -964,4 +966,9 @@ private Package createPackage(org.cyclonedx.model.Component componentFromBom, Re
}
return pckg;
}

public String getComponetNameById(String id, User user) throws SW360Exception {
Component comp = componentDatabaseHandler.getComponent(id, user);
return comp.getName();
}
}

0 comments on commit 867bd85

Please sign in to comment.