Search in sources :

Example 1 with CodeLocationView

use of com.blackducksoftware.integration.hub.api.generated.view.CodeLocationView in project hub-detect by blackducksoftware.

the class HubManager method waitForBomUpdate.

public void waitForBomUpdate(final HubService hubService, final ScanStatusService scanStatusService, final ProjectVersionView version) throws IntegrationException, InterruptedException {
    final List<CodeLocationView> allCodeLocations = hubService.getAllResponses(version, ProjectVersionView.CODELOCATIONS_LINK_RESPONSE);
    final List<ScanSummaryView> scanSummaryViews = new ArrayList<>();
    for (final CodeLocationView codeLocationView : allCodeLocations) {
        final String scansLink = hubService.getFirstLinkSafely(codeLocationView, CodeLocationView.SCANS_LINK);
        if (StringUtils.isNotBlank(scansLink)) {
            final List<ScanSummaryView> codeLocationScanSummaryViews = hubService.getResponses(scansLink, ScanSummaryView.class, true);
            scanSummaryViews.addAll(codeLocationScanSummaryViews);
        }
    }
    logger.info("Waiting for the BOM to be updated");
    scanStatusService.assertScansFinished(scanSummaryViews);
    logger.info("The BOM has been updated");
}
Also used : CodeLocationView(com.blackducksoftware.integration.hub.api.generated.view.CodeLocationView) ArrayList(java.util.ArrayList) ScanSummaryView(com.blackducksoftware.integration.hub.api.view.ScanSummaryView)

Example 2 with CodeLocationView

use of com.blackducksoftware.integration.hub.api.generated.view.CodeLocationView 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

CodeLocationView (com.blackducksoftware.integration.hub.api.generated.view.CodeLocationView)2 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 ScanSummaryView (com.blackducksoftware.integration.hub.api.view.ScanSummaryView)1 DoesNotExistException (com.blackducksoftware.integration.hub.exception.DoesNotExistException)1 CodeLocationService (com.blackducksoftware.integration.hub.service.CodeLocationService)1 ArrayList (java.util.ArrayList)1