Updating the code location name override handling
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Component;
import com.blackducksoftware.integration.hub.detect.DetectConfiguration;
import com.blackducksoftware.integration.hub.detect.codelocation.BomCodeLocationNameService;
+import com.blackducksoftware.integration.hub.detect.codelocation.CodeLocationType;
import com.blackducksoftware.integration.hub.detect.codelocation.DockerCodeLocationNameService;
import com.blackducksoftware.integration.hub.detect.codelocation.ScanCodeLocationNameService;
import com.blackducksoftware.integration.hub.detect.model.BomToolType;
@@ -51,7 +52,7 @@ public class CodeLocationNameManager {
private int givenCodeLocationOverrideCount = 0;
- public boolean useCodeLocationOverride() {
+ private boolean useCodeLocationOverride() {
if (StringUtils.isNotBlank(detectConfiguration.getCodeLocationNameOverride())) {
return true;
} else {
@@ -59,9 +60,9 @@ public class CodeLocationNameManager {
}
}
- public String getNextCodeLocationOverrideName() { //returns "override", then "override 2", then "override 3", etc
+ private String getNextCodeLocationOverrideName(CodeLocationType codeLocationType) { //returns "override", then "override 2", then "override 3", etc
givenCodeLocationOverrideCount++;
- final String base = detectConfiguration.getCodeLocationNameOverride();
+ final String base = detectConfiguration.getCodeLocationNameOverride() + " " + codeLocationType.name();
if (givenCodeLocationOverrideCount == 1) {
return base;
} else {
@@ -72,7 +73,8 @@ public class CodeLocationNameManager {
public String createAggregateCodeLocationName() {
if (useCodeLocationOverride()) {
- return getNextCodeLocationOverrideName();
+ //The aggregate is exclusively used for the bdio and not the scans
+ return getNextCodeLocationOverrideName(CodeLocationType.BOM);
} else {
return ""; //it is overridden in bdio creation later.
}
@@ -82,7 +84,11 @@ public class CodeLocationNameManager {
final String prefix, final String suffix) {
if (useCodeLocationOverride()) {
- return getNextCodeLocationOverrideName();
+ if (BomToolType.DOCKER == detectCodeLocation.getBomToolType()) {
+ return getNextCodeLocationOverrideName(CodeLocationType.DOCKER);
+ } else {
+ return getNextCodeLocationOverrideName(CodeLocationType.BOM);
+ }
} else if (BomToolType.DOCKER == detectCodeLocation.getBomToolType()) {
return dockerCodeLocationNameService.createCodeLocationName(detectCodeLocation.getSourcePath(), projectName, projectVersionName, detectCodeLocation.getDockerImage(), detectCodeLocation.getBomToolType(), prefix, suffix);
} else {
@@ -92,7 +98,7 @@ public class CodeLocationNameManager {
public String createScanCodeLocationName(final String sourcePath, final String scanTargetPath, final String projectName, final String projectVersionName, final String prefix, final String suffix) {
if (useCodeLocationOverride()) {
- return getNextCodeLocationOverrideName();
+ return getNextCodeLocationOverrideName(CodeLocationType.SCAN);
} else {
return scanCodeLocationNameService.createCodeLocationName(sourcePath, scanTargetPath, projectName, projectVersionName, prefix, suffix);
}
