From 3d532cf90dac6f8c61ecfe527229f781cfc7493c Mon Sep 17 00:00:00 2001 From: Eric Kerwin Date: Wed, 20 Dec 2017 08:27:20 -0500 Subject: [PATCH] upgrading to latest hub common --- build.gradle | 4 +- .../integration/hub/detect/Application.groovy | 8 ++- .../hub/detect/DetectProjectManager.groovy | 6 +- .../hub/detect/bomtool/DockerBomTool.groovy | 2 +- .../hub/detect/bomtool/GoDepBomTool.groovy | 3 +- .../detect/bomtool/go/GopkgLockParser.groovy | 4 +- .../bomtool/go/godep/GoGodepsParser.groovy | 4 +- .../detect/bomtool/go/vndr/VndrParser.groovy | 4 +- .../hub/detect/hub/BdioUploader.groovy | 6 +- .../hub/detect/hub/HubManager.groovy | 62 +++++++++---------- .../hub/detect/hub/HubServiceWrapper.groovy | 40 ++++++------ .../hub/detect/hub/OfflineScanner.groovy | 14 ++--- 12 files changed, 81 insertions(+), 76 deletions(-) diff --git a/build.gradle b/build.gradle index 6a05559eb..2113c4b17 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ tasks.withType(GroovyCompile) { options.encoding = 'UTF-8' } group = 'com.blackducksoftware.integration' -version = '2.4.0-SNAPSHOT' +version = '2.5.0-SNAPSHOT' final def versionFile = new File("${projectDir}/src/main/resources/version.txt") versionFile.delete() @@ -86,7 +86,7 @@ artifactory { } dependencies { - compile 'com.blackducksoftware.integration:hub-common:21.0.0' + compile 'com.blackducksoftware.integration:hub-common:24.0.0' compile 'org.springframework.boot:spring-boot-starter' compile 'org.apache.maven.shared:maven-invoker:3.0.0' compile 'com.esotericsoftware.yamlbeans:yamlbeans:1.11' diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/Application.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/Application.groovy index 0fc6eee54..95e2b3c57 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/Application.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/Application.groovy @@ -35,8 +35,11 @@ import org.springframework.boot.builder.SpringApplicationBuilder import org.springframework.context.annotation.Bean import com.blackducksoftware.integration.exception.IntegrationException +import com.blackducksoftware.integration.hub.bdio.BdioNodeFactory +import com.blackducksoftware.integration.hub.bdio.BdioPropertyHelper import com.blackducksoftware.integration.hub.bdio.BdioTransformer import com.blackducksoftware.integration.hub.bdio.SimpleBdioFactory +import com.blackducksoftware.integration.hub.bdio.graph.DependencyGraphTransformer import com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalIdFactory import com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException import com.blackducksoftware.integration.hub.detect.exitcode.ExitCodeReporter @@ -240,7 +243,10 @@ class Application { @Bean SimpleBdioFactory simpleBdioFactory() { - new SimpleBdioFactory() + BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper(); + BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper); + DependencyGraphTransformer dependencyGraphTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory); + new SimpleBdioFactory(bdioPropertyHelper, bdioNodeFactory, dependencyGraphTransformer, externalIdFactory(), gson()); } @Bean diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/DetectProjectManager.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/DetectProjectManager.groovy index 6ed0cea50..022d68416 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/DetectProjectManager.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/DetectProjectManager.groovy @@ -170,7 +170,7 @@ class DetectProjectManager implements SummaryResultReporter, ExitCodeReporter { if (outputFile.exists()) { outputFile.delete() } - simpleBdioFactory.writeSimpleBdioDocumentToFile(outputFile, gson, simpleBdioDocument) + simpleBdioFactory.writeSimpleBdioDocumentToFile(outputFile, simpleBdioDocument) bdioFiles.add(outputFile) logger.info("BDIO Generated: " + outputFile.getAbsolutePath()) } @@ -183,7 +183,7 @@ class DetectProjectManager implements SummaryResultReporter, ExitCodeReporter { if (aggregateBdioFile.exists()) { aggregateBdioFile.delete() } - simpleBdioFactory.writeSimpleBdioDocumentToFile(aggregateBdioFile, gson, aggregateBdioDocument) + simpleBdioFactory.writeSimpleBdioDocumentToFile(aggregateBdioFile, aggregateBdioDocument) logger.info("BDIO Generated: " + aggregateBdioFile.getAbsolutePath()) } @@ -247,7 +247,7 @@ class DetectProjectManager implements SummaryResultReporter, ExitCodeReporter { final String codeLocationName = '' final String projectName = detectProject.getProjectName() final String projectVersionName = detectProject.projectVersionName - final ExternalId projectExternalId = simpleBdioFactory.createNameVersionExternalId(new Forge('', '/'), projectName, projectVersionName) + final ExternalId projectExternalId = simpleBdioFactory.createNameVersionExternalId(new Forge('/', '/', ''), projectName, projectVersionName) createSimpleBdioDocument(codeLocationName, projectName, projectVersionName, projectExternalId, dependencyGraph) } diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/DockerBomTool.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/DockerBomTool.groovy index 8cda79789..4504fdeab 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/DockerBomTool.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/DockerBomTool.groovy @@ -178,7 +178,7 @@ class DockerBomTool extends BomTool { String projectName = simpleBdioDocument.project.name String projectVersionName = simpleBdioDocument.project.version - Forge dockerForge = new Forge(simpleBdioDocument.project.bdioExternalIdentifier.forge, ExternalId.BDIO_ID_SEPARATOR) + Forge dockerForge = new Forge(ExternalId.BDIO_ID_SEPARATOR, ExternalId.BDIO_ID_SEPARATOR, simpleBdioDocument.project.bdioExternalIdentifier.forge) String externalIdPath = simpleBdioDocument.project.bdioExternalIdentifier.externalId ExternalId projectExternalId = externalIdFactory.createPathExternalId(dockerForge, externalIdPath) diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/GoDepBomTool.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/GoDepBomTool.groovy index 7201c6ff1..391d03dd0 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/GoDepBomTool.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/GoDepBomTool.groovy @@ -47,7 +47,6 @@ class GoDepBomTool extends BomTool { public static final String GOPKG_LOCK_FILENAME= 'Gopkg.lock' public static final String GOFILE_FILENAME_PATTERN= '*.go' - public static final Forge GOLANG = new Forge("golang",":") @Autowired GoGodepsBomTool goGodepsBomTool @@ -97,7 +96,7 @@ class GoDepBomTool extends BomTool { String goDepExecutable = findGoDepExecutable() DependencyGraph graph = goPackager.makeDependencyGraph(sourcePath, goDepExecutable) - ExternalId externalId = externalIdFactory.createPathExternalId(GOLANG, sourcePath) + ExternalId externalId = externalIdFactory.createPathExternalId(Forge.GOLANG, sourcePath) DetectCodeLocation detectCodeLocation = new DetectCodeLocation(getBomToolType(), sourcePath, externalId, graph) [detectCodeLocation] diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/GopkgLockParser.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/GopkgLockParser.groovy index dd1eade3b..76c126c5c 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/GopkgLockParser.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/GopkgLockParser.groovy @@ -25,10 +25,10 @@ package com.blackducksoftware.integration.hub.detect.bomtool.go import com.blackducksoftware.integration.hub.bdio.graph.DependencyGraph import com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph import com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph +import com.blackducksoftware.integration.hub.bdio.model.Forge import com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency import com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId import com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalIdFactory -import com.blackducksoftware.integration.hub.detect.bomtool.GoDepBomTool import com.moandjiezana.toml.Toml import groovy.transform.TypeChecked @@ -60,7 +60,7 @@ class GopkgLockParser { if (packageName.startsWith('golang.org/x/')) { packageName = packageName.replaceAll('golang.org/x/', '') } - final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(GoDepBomTool.GOLANG, packageName, version) + final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, packageName, version) final Dependency dependency = new Dependency(packageName, version, dependencyExternalId) graph.addChildToRoot(dependency) } diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/godep/GoGodepsParser.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/godep/GoGodepsParser.groovy index c95e3e6dc..f1bbfde55 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/godep/GoGodepsParser.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/godep/GoGodepsParser.groovy @@ -25,10 +25,10 @@ package com.blackducksoftware.integration.hub.detect.bomtool.go.godep import com.blackducksoftware.integration.hub.bdio.graph.DependencyGraph import com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph import com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph +import com.blackducksoftware.integration.hub.bdio.model.Forge import com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency import com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId import com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalIdFactory -import com.blackducksoftware.integration.hub.detect.bomtool.GoDepBomTool import com.google.gson.Gson import groovy.transform.TypeChecked @@ -58,7 +58,7 @@ class GoGodepsParser { } else { version = dep.rev.trim() } - final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(GoDepBomTool.GOLANG, dep.importPath, version) + final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, dep.importPath, version) final Dependency dependency = new Dependency(dep.importPath, version, dependencyExternalId) graph.addChildToRoot(dependency); } diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/vndr/VndrParser.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/vndr/VndrParser.groovy index e179bc788..cd9ad3b18 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/vndr/VndrParser.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/bomtool/go/vndr/VndrParser.groovy @@ -25,10 +25,10 @@ package com.blackducksoftware.integration.hub.detect.bomtool.go.vndr import com.blackducksoftware.integration.hub.bdio.graph.DependencyGraph import com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph import com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph +import com.blackducksoftware.integration.hub.bdio.model.Forge import com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency import com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId import com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalIdFactory -import com.blackducksoftware.integration.hub.detect.bomtool.GoDepBomTool import groovy.transform.TypeChecked @@ -47,7 +47,7 @@ class VndrParser { if (line?.trim() && !line.startsWith('#')) { def parts = line.split(' ') - final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(GoDepBomTool.GOLANG, parts[0], parts[1]) + final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, parts[0], parts[1]) final Dependency dependency = new Dependency(parts[0], parts[1], dependencyExternalId) graph.addChildToRoot(dependency) } diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/BdioUploader.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/BdioUploader.groovy index 8866f633f..5bf976b30 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/BdioUploader.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/BdioUploader.groovy @@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component -import com.blackducksoftware.integration.hub.api.bom.BomImportRequestService +import com.blackducksoftware.integration.hub.api.bom.BomImportService import com.blackducksoftware.integration.hub.dataservice.phonehome.PhoneHomeDataService import com.blackducksoftware.integration.hub.detect.DetectConfiguration import com.blackducksoftware.integration.hub.detect.DetectInfo @@ -56,10 +56,10 @@ class BdioUploader { @Autowired DetectPhoneHomeManager detectPhoneHomeManager - void uploadBdioFiles(HubServerConfig hubServerConfig, BomImportRequestService bomImportRequestService, PhoneHomeDataService phoneHomeDataService, DetectProject detectProject, List createdBdioFiles) { + void uploadBdioFiles(HubServerConfig hubServerConfig, BomImportService bomImportService, PhoneHomeDataService phoneHomeDataService, DetectProject detectProject, List createdBdioFiles) { createdBdioFiles.each { file -> logger.info("uploading ${file.name} to ${detectConfiguration.getHubUrl()}") - bomImportRequestService.importBomFile(file) + bomImportService.importBomFile(file) if (detectConfiguration.getCleanupBdioFiles()) { file.delete() } diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/HubManager.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/HubManager.groovy index 1dc8cac9a..01e0beaf9 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/HubManager.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/HubManager.groovy @@ -28,12 +28,12 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component import com.blackducksoftware.integration.exception.IntegrationException -import com.blackducksoftware.integration.hub.api.bom.BomImportRequestService -import com.blackducksoftware.integration.hub.api.codelocation.CodeLocationRequestService -import com.blackducksoftware.integration.hub.api.item.MetaService -import com.blackducksoftware.integration.hub.api.project.ProjectRequestService -import com.blackducksoftware.integration.hub.api.project.version.ProjectVersionRequestService -import com.blackducksoftware.integration.hub.api.scan.ScanSummaryRequestService +import com.blackducksoftware.integration.hub.api.bom.BomImportService +import com.blackducksoftware.integration.hub.api.codelocation.CodeLocationService +import com.blackducksoftware.integration.hub.api.project.ProjectService +import com.blackducksoftware.integration.hub.api.project.version.ProjectVersionService +import com.blackducksoftware.integration.hub.api.scan.ScanSummaryService +import com.blackducksoftware.integration.hub.api.view.MetaHandler import com.blackducksoftware.integration.hub.dataservice.cli.CLIDataService import com.blackducksoftware.integration.hub.dataservice.phonehome.PhoneHomeDataService import com.blackducksoftware.integration.hub.dataservice.policystatus.PolicyStatusDataService @@ -55,6 +55,7 @@ import com.blackducksoftware.integration.hub.model.view.ProjectVersionView import com.blackducksoftware.integration.hub.model.view.ProjectView import com.blackducksoftware.integration.hub.model.view.ScanSummaryView import com.blackducksoftware.integration.hub.request.builder.ProjectRequestBuilder +import com.blackducksoftware.integration.hub.service.HubService import groovy.transform.TypeChecked @@ -81,14 +82,14 @@ class HubManager implements ExitCodeReporter { private ExitCodeType exitCodeType = ExitCodeType.SUCCESS; public ProjectVersionView updateHubProjectVersion(DetectProject detectProject, List createdBdioFiles) { - ProjectRequestService projectRequestService = hubServiceWrapper.createProjectRequestService() - ProjectVersionRequestService projectVersionRequestService = hubServiceWrapper.createProjectVersionRequestService() - ProjectVersionView projectVersionView = ensureProjectVersionExists(detectProject, projectRequestService, projectVersionRequestService) + ProjectService projectService = hubServiceWrapper.createProjectService() + ProjectVersionService projectVersionService = hubServiceWrapper.createProjectVersionService() + ProjectVersionView projectVersionView = ensureProjectVersionExists(detectProject, projectService, projectVersionService) if (createdBdioFiles) { HubServerConfig hubServerConfig = hubServiceWrapper.hubServerConfig - BomImportRequestService bomImportRequestService = hubServiceWrapper.createBomImportRequestService() + BomImportService bomImportService = hubServiceWrapper.createBomImportService() PhoneHomeDataService phoneHomeDataService = hubServiceWrapper.createPhoneHomeDataService() - bdioUploader.uploadBdioFiles(hubServerConfig, bomImportRequestService, phoneHomeDataService, detectProject, createdBdioFiles) + bdioUploader.uploadBdioFiles(hubServerConfig, bomImportService, phoneHomeDataService, detectProject, createdBdioFiles) } else { logger.debug('Did not create any bdio files.') } @@ -108,12 +109,11 @@ class HubManager implements ExitCodeReporter { try { if (detectConfiguration.getPolicyCheck() || detectConfiguration.getRiskReportPdf() || detectConfiguration.getNoticesReport()) { ProjectDataService projectDataService = hubServiceWrapper.createProjectDataService() - CodeLocationRequestService codeLocationRequestService = hubServiceWrapper.createCodeLocationRequestService() - MetaService metaService = hubServiceWrapper.createMetaService() - ScanSummaryRequestService scanSummaryRequestService = hubServiceWrapper.createScanSummaryRequestService() + CodeLocationService codeLocationService = hubServiceWrapper.createCodeLocationService() + ScanSummaryService scanSummaryService = hubServiceWrapper.createScanSummaryService() ScanStatusDataService scanStatusDataService = hubServiceWrapper.createScanStatusDataService() - waitForBomUpdate(projectDataService, codeLocationRequestService, metaService, scanSummaryRequestService, scanStatusDataService, projectVersionView) + waitForBomUpdate(projectDataService, codeLocationService, scanSummaryService, scanStatusDataService, projectVersionView) if (detectConfiguration.getPolicyCheck()) { PolicyStatusDataService policyStatusDataService = hubServiceWrapper.createPolicyStatusDataService() @@ -144,9 +144,9 @@ class HubManager implements ExitCodeReporter { if (detectProject.getDetectCodeLocations() && !detectConfiguration.getHubSignatureScannerDisabled()) { // only log BOM URL if we have updated it in some way ProjectDataService projectDataService = hubServiceWrapper.createProjectDataService() + HubService hubService = hubServiceWrapper.createHubService() ProjectVersionWrapper projectVersionWrapper = projectDataService.getProjectVersion(detectProject.getProjectName(), detectProject.getProjectVersionName()) - MetaService metaService = hubServiceWrapper.createMetaService() - String componentsLink = metaService.getFirstLinkSafely(projectVersionWrapper.getProjectVersionView(), MetaService.COMPONENTS_LINK) + String componentsLink = hubService.getFirstLinkSafely(projectVersionWrapper.getProjectVersionView(), MetaHandler.COMPONENTS_LINK) logger.info("To see your results, follow the URL: ${componentsLink}") } else { logger.debug('Found no code locations and did not run a scan.') @@ -158,12 +158,12 @@ class HubManager implements ExitCodeReporter { } } - public void waitForBomUpdate(ProjectDataService projectDataService, CodeLocationRequestService codeLocationRequestService, MetaService metaService, ScanSummaryRequestService scanSummaryRequestService, ScanStatusDataService scanStatusDataService, ProjectVersionView version) { - List allCodeLocations = codeLocationRequestService.getAllCodeLocationsForProjectVersion(version) + public void waitForBomUpdate(ProjectDataService projectDataService, CodeLocationService codeLocationService, ScanSummaryService scanSummaryService, ScanStatusDataService scanStatusDataService, ProjectVersionView version) { + List allCodeLocations = codeLocationService.getAllCodeLocationsForProjectVersion(version) List scanSummaryViews = [] allCodeLocations.each { - String scansLink = metaService.getFirstLinkSafely(it, MetaService.SCANS_LINK) - List codeLocationScanSummaryViews = scanSummaryRequestService.getAllScanSummaryItems(scansLink) + String scansLink = codeLocationService.getFirstLinkSafely(it, MetaHandler.SCANS_LINK) + List codeLocationScanSummaryViews = scanSummaryService.getAllScanSummaryItems(scansLink) scanSummaryViews.addAll(codeLocationScanSummaryViews) } logger.info("Waiting for the BOM to be updated") @@ -171,7 +171,7 @@ class HubManager implements ExitCodeReporter { logger.info("The BOM has been updated") } - public ProjectVersionView ensureProjectVersionExists(DetectProject detectProject, ProjectRequestService projectRequestService, ProjectVersionRequestService projectVersionRequestService) { + public ProjectVersionView ensureProjectVersionExists(DetectProject detectProject, ProjectService projectService, ProjectVersionService projectVersionService) { ProjectRequestBuilder builder = new ProjectRequestBuilder() builder.setProjectName(detectProject.getProjectName()) builder.setVersionName(detectProject.getProjectVersionName()) @@ -181,29 +181,29 @@ class HubManager implements ExitCodeReporter { ProjectRequest projectRequest = builder.build() ProjectView project = null try { - project = projectRequestService.getProjectByName(projectRequest.getName()) + project = projectService.getProjectByName(projectRequest.getName()) } catch (final DoesNotExistException e) { - final String projectURL = projectRequestService.createHubProject(projectRequest) - project = projectRequestService.getItem(projectURL, ProjectView.class) + final String projectURL = projectService.createHubProject(projectRequest) + project = projectService.getView(projectURL, ProjectView.class) } ProjectVersionView projectVersionView = null try { - projectVersionView = projectVersionRequestService.getProjectVersion(project, projectRequest.getVersionRequest().getVersionName()) + projectVersionView = projectVersionService.getProjectVersion(project, projectRequest.getVersionRequest().getVersionName()) } catch (final DoesNotExistException e) { - final String versionURL = projectVersionRequestService.createHubVersion(project, projectRequest.getVersionRequest()) - projectVersionView = projectVersionRequestService.getItem(versionURL, ProjectVersionView.class) + final String versionURL = projectVersionService.createHubVersion(project, projectRequest.getVersionRequest()) + projectVersionView = projectVersionService.getView(versionURL, ProjectVersionView.class) } } public void manageExistingCodeLocations(List codeLocationNames) { if (!detectConfiguration.hubOfflineMode) { - CodeLocationRequestService codeLocationRequestService = hubServiceWrapper.createCodeLocationRequestService() + CodeLocationService codeLocationService = hubServiceWrapper.createCodeLocationService() for (String codeLocationName : codeLocationNames) { try { - CodeLocationView codeLocationView = codeLocationRequestService.getCodeLocationByName(codeLocationName) + CodeLocationView codeLocationView = codeLocationService.getCodeLocationByName(codeLocationName) if (detectConfiguration.projectCodeLocationDeleteOldNames) { try { - codeLocationRequestService.deleteCodeLocation(codeLocationView); + codeLocationService.deleteCodeLocation(codeLocationView); logger.info("Deleted code location '${codeLocationName}'") } catch (IntegrationException e) { logger.error("Not able to delete the code location '${codeLocationName}': ${e.message}") diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/HubServiceWrapper.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/HubServiceWrapper.groovy index dc0641dfa..0bbcd4b01 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/HubServiceWrapper.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/HubServiceWrapper.groovy @@ -29,12 +29,11 @@ import org.springframework.stereotype.Component import com.blackducksoftware.integration.exception.EncryptionException import com.blackducksoftware.integration.exception.IntegrationException -import com.blackducksoftware.integration.hub.api.bom.BomImportRequestService -import com.blackducksoftware.integration.hub.api.codelocation.CodeLocationRequestService -import com.blackducksoftware.integration.hub.api.item.MetaService -import com.blackducksoftware.integration.hub.api.project.ProjectRequestService -import com.blackducksoftware.integration.hub.api.project.version.ProjectVersionRequestService -import com.blackducksoftware.integration.hub.api.scan.ScanSummaryRequestService +import com.blackducksoftware.integration.hub.api.bom.BomImportService +import com.blackducksoftware.integration.hub.api.codelocation.CodeLocationService +import com.blackducksoftware.integration.hub.api.project.ProjectService +import com.blackducksoftware.integration.hub.api.project.version.ProjectVersionService +import com.blackducksoftware.integration.hub.api.scan.ScanSummaryService import com.blackducksoftware.integration.hub.builder.HubServerConfigBuilder import com.blackducksoftware.integration.hub.dataservice.cli.CLIDataService import com.blackducksoftware.integration.hub.dataservice.phonehome.PhoneHomeDataService @@ -47,6 +46,7 @@ import com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendly import com.blackducksoftware.integration.hub.detect.exitcode.ExitCodeType import com.blackducksoftware.integration.hub.global.HubServerConfig import com.blackducksoftware.integration.hub.rest.RestConnection +import com.blackducksoftware.integration.hub.service.HubService import com.blackducksoftware.integration.hub.service.HubServicesFactory import com.blackducksoftware.integration.log.IntLogger import com.blackducksoftware.integration.log.Slf4jIntLogger @@ -106,16 +106,20 @@ class HubServiceWrapper { return false; } - ProjectRequestService createProjectRequestService() { - hubServicesFactory.createProjectRequestService() + HubService createHubService() { + hubServicesFactory.createHubService() } - ProjectVersionRequestService createProjectVersionRequestService() { - hubServicesFactory.createProjectVersionRequestService() + ProjectService createProjectService() { + hubServicesFactory.createProjectService() } - BomImportRequestService createBomImportRequestService() { - hubServicesFactory.createBomImportRequestService() + ProjectVersionService createProjectVersionService() { + hubServicesFactory.createProjectVersionService() + } + + BomImportService createBomImportService() { + hubServicesFactory.createBomImportService() } PhoneHomeDataService createPhoneHomeDataService() { @@ -126,16 +130,12 @@ class HubServiceWrapper { hubServicesFactory.createProjectDataService() } - CodeLocationRequestService createCodeLocationRequestService() { - hubServicesFactory.createCodeLocationRequestService() - } - - MetaService createMetaService() { - hubServicesFactory.createMetaService() + CodeLocationService createCodeLocationService() { + hubServicesFactory.createCodeLocationService() } - ScanSummaryRequestService createScanSummaryRequestService() { - hubServicesFactory.createScanSummaryRequestService() + ScanSummaryService createScanSummaryService() { + hubServicesFactory.createScanSummaryService() } ScanStatusDataService createScanStatusDataService() { diff --git a/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/OfflineScanner.groovy b/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/OfflineScanner.groovy index 393daca3b..1298d1db0 100644 --- a/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/OfflineScanner.groovy +++ b/src/main/groovy/com/blackducksoftware/integration/hub/detect/hub/OfflineScanner.groovy @@ -28,10 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component import com.blackducksoftware.integration.hub.HubSupportHelper -import com.blackducksoftware.integration.hub.cli.CLIDownloadService +import com.blackducksoftware.integration.hub.cli.CLIDownloadUtility import com.blackducksoftware.integration.hub.cli.CLILocation import com.blackducksoftware.integration.hub.cli.OfflineCLILocation -import com.blackducksoftware.integration.hub.cli.SimpleScanService +import com.blackducksoftware.integration.hub.cli.SimpleScanUtility import com.blackducksoftware.integration.hub.detect.DetectConfiguration import com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException import com.blackducksoftware.integration.hub.detect.exitcode.ExitCodeType @@ -72,7 +72,7 @@ class OfflineScanner { def silentLogger = new SilentLogger() - def simpleScanService = new SimpleScanService(intLogger, gson, hubServerConfig, hubSupportHelper, ciEnvironmentVariables, hubScanConfig, detectProject.projectName, detectProject.projectVersionName) + def simpleScanUtility = new SimpleScanUtility(intLogger, gson, hubServerConfig, hubSupportHelper, ciEnvironmentVariables, hubScanConfig, detectProject.projectName, detectProject.projectVersionName) final CLILocation cliLocation = new CLILocation(silentLogger, hubScanConfig.getToolsDir()) if (hubSignatureScannerOfflineLocalPath) { cliLocation = new OfflineCLILocation(silentLogger, new File(hubSignatureScannerOfflineLocalPath)) @@ -89,8 +89,8 @@ class OfflineScanner { } else if (!cliInstalledOkay) { logger.warn("The signature scanner is not correctly installed at ${hubScanConfig.getToolsDir()}") } else { - simpleScanService.setupAndExecuteScan(cliLocation) - logger.info("The scan dry run files can be found in : ${simpleScanService.getDataDirectory()}") + simpleScanUtility.setupAndExecuteScan(cliLocation) + logger.info("The scan dry run files can be found in : ${simpleScanUtility.getDataDirectory()}") } } @@ -103,8 +103,8 @@ class OfflineScanner { restConnectionBuilder.applyProxyInfo(detectConfiguration.getHubProxyInfo()) restConnectionBuilder.setLogger(intLogger) RestConnection restConnection = restConnectionBuilder.build() - CLIDownloadService cliDownloadService = new CLIDownloadService(intLogger, restConnection) - cliDownloadService.performInstallation(hubScanConfig.getToolsDir(), ciEnvironmentVariables, detectConfiguration.hubSignatureScannerHostUrl, 'unknown', 'hub-detect') + CLIDownloadUtility cliDownloadUtility = new CLIDownloadUtility(intLogger, restConnection) + cliDownloadUtility.performInstallation(hubScanConfig.getToolsDir(), ciEnvironmentVariables, detectConfiguration.hubSignatureScannerHostUrl, 'unknown', 'hub-detect') } catch (Exception e) { throw new DetectUserFriendlyException("There was a problem downloading the signature scanner from ${detectConfiguration.hubSignatureScannerHostUrl}: ${e.message}", e, ExitCodeType.FAILURE_GENERAL_ERROR) }