Search in sources :

Example 1 with CodeLocationService

use of com.blackducksoftware.integration.hub.service.CodeLocationService in project hub-docker-inspector by blackducksoftware.

the class HubClient method uploadBdioToHub.

public void uploadBdioToHub(final File bdioFile) throws IntegrationException {
    final RestConnection restConnection = createRestConnection();
    final HubServicesFactory hubServicesFactory = new HubServicesFactory(restConnection);
    final CodeLocationService bomImportRequestService = hubServicesFactory.createCodeLocationService();
    bomImportRequestService.importBomFile(bdioFile);
    logger.info(String.format("Uploaded bdio file %s to %s", bdioFile.getName(), config.getHubUrl()));
}
Also used : CodeLocationService(com.blackducksoftware.integration.hub.service.CodeLocationService) RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory)

Example 2 with CodeLocationService

use of com.blackducksoftware.integration.hub.service.CodeLocationService in project hub-detect by blackducksoftware.

the class HubManager method updateHubProjectVersion.

public ProjectVersionView updateHubProjectVersion(final DetectProject detectProject, final List<File> createdBdioFiles) throws IntegrationException {
    final ProjectService projectService = hubServiceWrapper.createProjectService();
    ProjectVersionView projectVersionView = ensureProjectVersionExists(detectProject, projectService);
    if (null != createdBdioFiles && !createdBdioFiles.isEmpty()) {
        final HubServerConfig hubServerConfig = hubServiceWrapper.getHubServerConfig();
        final CodeLocationService codeLocationService = hubServiceWrapper.createCodeLocationService();
        bdioUploader.uploadBdioFiles(hubServerConfig, codeLocationService, detectProject, createdBdioFiles);
    } else {
        logger.debug("Did not create any bdio files.");
    }
    if (!detectConfiguration.getHubSignatureScannerDisabled()) {
        final HubServerConfig hubServerConfig = hubServiceWrapper.getHubServerConfig();
        final SignatureScannerService signatureScannerService = hubServiceWrapper.createSignatureScannerService();
        final ProjectVersionView scanProject = hubSignatureScanner.scanPaths(hubServerConfig, signatureScannerService, detectProject);
        if (null == projectVersionView) {
            projectVersionView = scanProject;
        }
    }
    return projectVersionView;
}
Also used : CodeLocationService(com.blackducksoftware.integration.hub.service.CodeLocationService) SignatureScannerService(com.blackducksoftware.integration.hub.service.SignatureScannerService) HubServerConfig(com.blackducksoftware.integration.hub.configuration.HubServerConfig) ProjectVersionView(com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView) ProjectService(com.blackducksoftware.integration.hub.service.ProjectService)

Example 3 with CodeLocationService

use of com.blackducksoftware.integration.hub.service.CodeLocationService in project hub-detect by blackducksoftware.

the class HubManager method manageExistingCodeLocations.

public void manageExistingCodeLocations(final List<String> codeLocationNames) {
    if (!detectConfiguration.getHubOfflineMode()) {
        final CodeLocationService codeLocationService = hubServiceWrapper.createCodeLocationService();
        for (final String codeLocationName : codeLocationNames) {
            try {
                final CodeLocationView codeLocationView = codeLocationService.getCodeLocationByName(codeLocationName);
                if (detectConfiguration.getProjectCodeLocationDeleteOldNames()) {
                    try {
                        codeLocationService.deleteCodeLocation(codeLocationView);
                        logger.info(String.format("Deleted code location '%s'", codeLocationName));
                    } catch (final IntegrationException e) {
                        logger.error(String.format("Not able to delete the code location '%s': %s", codeLocationName, e.getMessage()));
                    }
                } else {
                    logger.warn(String.format("Found a code location with a naming pattern that is no longer supported: %s. This code location may need to be removed to avoid duplicate entries in the Bill of Materials. You can run with --detect.project.codelocation.delete.old.names=true which will automatically delete these code locations, but please USE CAUTION.", codeLocationName));
                }
            } catch (final DoesNotExistException e) {
                logger.debug(String.format("Didn't find the code location %s - this is a good thing!", codeLocationName));
            } catch (final IntegrationException e) {
                logger.error(String.format("Error finding the code location name %s: %s", codeLocationName, e.getMessage()));
            }
        }
    }
}
Also used : CodeLocationService(com.blackducksoftware.integration.hub.service.CodeLocationService) CodeLocationView(com.blackducksoftware.integration.hub.api.generated.view.CodeLocationView) DoesNotExistException(com.blackducksoftware.integration.hub.exception.DoesNotExistException) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException)

Aggregations

CodeLocationService (com.blackducksoftware.integration.hub.service.CodeLocationService)3 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 CodeLocationView (com.blackducksoftware.integration.hub.api.generated.view.CodeLocationView)1 ProjectVersionView (com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView)1 HubServerConfig (com.blackducksoftware.integration.hub.configuration.HubServerConfig)1 DoesNotExistException (com.blackducksoftware.integration.hub.exception.DoesNotExistException)1 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)1 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)1 ProjectService (com.blackducksoftware.integration.hub.service.ProjectService)1 SignatureScannerService (com.blackducksoftware.integration.hub.service.SignatureScannerService)1