Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix(importCDX): Resolved unnecessary update of component fields" #2482

Merged
Merged
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 @@ -510,11 +510,14 @@ private Map<String, String> importAllComponentsAsReleases(Map<String, List<org.c

// update components specific fields
comp = componentDatabaseHandler.getComponent(compAddSummary.getId(), user);
if (AddDocumentRequestStatus.SUCCESS.equals(compAddSummary.getRequestStatus()) && (null != bomComp.getType() && null == comp.getCdxComponentType())) {
if (null != bomComp.getType() && null == comp.getCdxComponentType()) {
comp.setCdxComponentType(getCdxComponentType(bomComp.getType()));
}
if (AddDocumentRequestStatus.SUCCESS.equals(compAddSummary.getRequestStatus()) && (CommonUtils.isNullEmptyOrWhitespace(comp.getDescription()) && CommonUtils.isNotNullEmptyOrWhitespace(bomComp.getDescription()))) {
comp.setDescription(bomComp.getDescription().trim());
StringBuilder description = new StringBuilder();
if (CommonUtils.isNullEmptyOrWhitespace(comp.getDescription()) && CommonUtils.isNotNullEmptyOrWhitespace(bomComp.getDescription())) {
description.append(bomComp.getDescription().trim());
} else if (CommonUtils.isNotNullEmptyOrWhitespace(bomComp.getDescription())) {
description.append(" || ").append(bomComp.getDescription().trim());
}
if (CommonUtils.isNotEmpty(comp.getMainLicenseIds())) {
comp.getMainLicenseIds().addAll(licenses);
Expand All @@ -530,7 +533,7 @@ private Map<String, String> importAllComponentsAsReleases(Map<String, List<org.c
comp.setWiki(CommonUtils.nullToEmptyString(extRef.getUrl()));
}
}

comp.setDescription(description.toString());
RequestStatus updateStatus = componentDatabaseHandler.updateComponent(comp, user, true);
if (RequestStatus.SUCCESS.equals(updateStatus)) {
log.info("updating component successfull: " + comp.getName());
Expand Down Expand Up @@ -580,6 +583,7 @@ private Map<String, String> importAllComponentsAsPackages(Map<String, List<org.c

Release release = new Release();
String relName = "";
StringBuilder description = new StringBuilder();
AddDocumentRequestSummary compAddSummary;
try {
Component dupCompByName = componentDatabaseHandler.getComponentByName(comp.getName());
Expand Down Expand Up @@ -635,11 +639,13 @@ private Map<String, String> importAllComponentsAsPackages(Map<String, List<org.c

// update components specific fields
comp = componentDatabaseHandler.getComponent(compAddSummary.getId(), user);
if (AddDocumentRequestStatus.SUCCESS.equals(compAddSummary.getRequestStatus()) && (null != bomComp.getType() && null == comp.getCdxComponentType())) {
if (null != bomComp.getType() && null == comp.getCdxComponentType()) {
comp.setCdxComponentType(getCdxComponentType(bomComp.getType()));
}
if (AddDocumentRequestStatus.SUCCESS.equals(compAddSummary.getRequestStatus()) && (CommonUtils.isNullEmptyOrWhitespace(comp.getDescription()) && CommonUtils.isNotNullEmptyOrWhitespace(bomComp.getDescription()))) {
comp.setDescription(bomComp.getDescription().trim());
if (CommonUtils.isNullEmptyOrWhitespace(comp.getDescription()) && CommonUtils.isNotNullEmptyOrWhitespace(bomComp.getDescription())) {
description.append(bomComp.getDescription().trim());
} else if (CommonUtils.isNotNullEmptyOrWhitespace(bomComp.getDescription())) {
description.append(" || ").append(bomComp.getDescription().trim());
}
if (CommonUtils.isNotEmpty(comp.getMainLicenseIds())) {
comp.getMainLicenseIds().addAll(licenses);
Expand All @@ -658,6 +664,7 @@ private Map<String, String> importAllComponentsAsPackages(Map<String, List<org.c
}
}

comp.setDescription(description.toString());
RequestStatus updateStatus = componentDatabaseHandler.updateComponent(comp, user, true);
if (RequestStatus.SUCCESS.equals(updateStatus)) {
log.info("updating component successfull: " + comp.getName());
Expand Down
Loading