Search in sources :

Example 1 with OperationSystem

use of com.synopsys.integration.detect.workflow.status.OperationSystem in project synopsys-detect by blackducksoftware.

the class SingletonFactory method createUtilitySingletons.

public UtilitySingletons createUtilitySingletons(EventSingletons eventSingletons) throws DetectUserFriendlyException {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    ConnectionDetails connectionDetails = detectConfigurationFactory.createConnectionDetails();
    ConnectionFactory connectionFactory = new ConnectionFactory(connectionDetails);
    ArtifactResolver artifactResolver = new ArtifactResolver(connectionFactory, gson);
    ArtifactoryZipInstaller artifactoryZipInstaller = new ArtifactoryZipInstaller(artifactResolver);
    AirGapPathFinder airGapPathFinder = new AirGapPathFinder();
    BdioOptions bdioOptions = detectConfigurationFactory.createBdioOptions();
    CodeLocationNameGenerator codeLocationNameGenerator = detectConfigurationFactory.createCodeLocationOverride().map(CodeLocationNameGenerator::withOverride).orElse(CodeLocationNameGenerator.withPrefixSuffix(bdioOptions.getProjectCodeLocationPrefix().orElse(null), bdioOptions.getProjectCodeLocationSuffix().orElse(null)));
    CodeLocationNameManager codeLocationNameManager = new CodeLocationNameManager(codeLocationNameGenerator);
    AirGapInspectorPaths airGapInspectorPaths = new AirGapInspectorPaths(airGapPathFinder);
    DetectExecutableRunner executableRunner = DetectExecutableRunner.newDebug(eventSystem);
    DirectoryExecutableFinder directoryExecutableFinder = DirectoryExecutableFinder.forCurrentOperatingSystem(fileFinder);
    SystemPathExecutableFinder systemExecutableFinder = new SystemPathExecutableFinder(directoryExecutableFinder);
    DetectExecutableResolver detectExecutableResolver = new DetectExecutableResolver(directoryExecutableFinder, systemExecutableFinder, detectConfigurationFactory.createDetectExecutableOptions());
    OperationSystem operationSystem = new OperationSystem(eventSingletons.getStatusEventPublisher());
    OperationWrapper operationWrapper = new OperationWrapper();
    return new UtilitySingletons(externalIdFactory, connectionDetails, artifactResolver, codeLocationNameManager, airGapInspectorPaths, executableRunner, detectExecutableResolver, operationSystem, operationWrapper, artifactoryZipInstaller);
}
Also used : AirGapInspectorPaths(com.synopsys.integration.detect.workflow.airgap.AirGapInspectorPaths) DirectoryExecutableFinder(com.synopsys.integration.detect.tool.detector.executable.DirectoryExecutableFinder) CodeLocationNameManager(com.synopsys.integration.detect.workflow.codelocation.CodeLocationNameManager) ArtifactoryZipInstaller(com.synopsys.integration.detect.tool.detector.inspectors.ArtifactoryZipInstaller) OperationWrapper(com.synopsys.integration.detect.lifecycle.run.step.utility.OperationWrapper) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ConnectionDetails(com.synopsys.integration.detect.configuration.connection.ConnectionDetails) OperationSystem(com.synopsys.integration.detect.workflow.status.OperationSystem) ArtifactResolver(com.synopsys.integration.detect.workflow.ArtifactResolver) SystemPathExecutableFinder(com.synopsys.integration.detect.tool.detector.executable.SystemPathExecutableFinder) BdioOptions(com.synopsys.integration.detect.workflow.bdio.BdioOptions) ConnectionFactory(com.synopsys.integration.detect.configuration.connection.ConnectionFactory) DetectExecutableResolver(com.synopsys.integration.detect.tool.detector.executable.DetectExecutableResolver) AirGapPathFinder(com.synopsys.integration.detect.workflow.airgap.AirGapPathFinder) CodeLocationNameGenerator(com.synopsys.integration.detect.workflow.codelocation.CodeLocationNameGenerator) DetectExecutableRunner(com.synopsys.integration.detect.tool.detector.executable.DetectExecutableRunner)

Example 2 with OperationSystem

use of com.synopsys.integration.detect.workflow.status.OperationSystem in project synopsys-detect by blackducksoftware.

the class DetectRun method run.

public void run(BootSingletons bootSingletons) {
    Optional<OperationSystem> operationSystem = Optional.empty();
    try {
        SingletonFactory singletonFactory = new SingletonFactory(bootSingletons);
        EventSingletons eventSingletons = singletonFactory.createEventSingletons();
        UtilitySingletons utilitySingletons = singletonFactory.createUtilitySingletons(eventSingletons);
        operationSystem = Optional.of(utilitySingletons.getOperationSystem());
        // TODO: Remove run data from boot singletons
        ProductRunData productRunData = bootSingletons.getProductRunData();
        OperationFactory operationFactory = createOperationFactory(bootSingletons, utilitySingletons, eventSingletons);
        StepHelper stepHelper = new StepHelper(utilitySingletons.getOperationSystem(), utilitySingletons.getOperationWrapper(), productRunData.getDetectToolFilter());
        // Product independent tools
        UniversalStepRunner stepRunner = new UniversalStepRunner(operationFactory, stepHelper);
        UniversalToolsResult universalToolsResult = stepRunner.runUniversalTools();
        // combine: processProjectInformation() -> ProjectResult (nameversion, bdio)
        NameVersion nameVersion = stepRunner.determineProjectInformation(universalToolsResult);
        operationFactory.publishProjectNameVersionChosen(nameVersion);
        BdioResult bdio = stepRunner.generateBdio(universalToolsResult, nameVersion);
        if (productRunData.shouldUseBlackDuckProduct()) {
            BlackDuckRunData blackDuckRunData = productRunData.getBlackDuckRunData();
            if (blackDuckRunData.isRapid() && blackDuckRunData.isOnline()) {
                RapidModeStepRunner rapidModeSteps = new RapidModeStepRunner(operationFactory);
                rapidModeSteps.runOnline(blackDuckRunData, nameVersion, bdio);
            } else if (blackDuckRunData.isRapid()) {
                logger.info("Rapid Scan is offline, nothing to do.");
            } else if (blackDuckRunData.isOnline()) {
                IntelligentModeStepRunner intelligentModeSteps = new IntelligentModeStepRunner(operationFactory, stepHelper);
                intelligentModeSteps.runOnline(blackDuckRunData, bdio, nameVersion, productRunData.getDetectToolFilter(), universalToolsResult.getDockerTargetData());
            } else {
                IntelligentModeStepRunner intelligentModeSteps = new IntelligentModeStepRunner(operationFactory, stepHelper);
                intelligentModeSteps.runOffline(nameVersion, universalToolsResult.getDockerTargetData());
            }
        }
    } catch (Exception e) {
        logger.error(ReportConstants.RUN_SEPARATOR);
        logger.error("Detect run failed.");
        exceptionUtility.logException(e);
        logger.debug("An exception was thrown during the detect run.", e);
        logger.error(ReportConstants.RUN_SEPARATOR);
        exitCodeManager.requestExitCode(e);
        checkForInterruptedException(e);
    } finally {
        operationSystem.ifPresent(OperationSystem::publishOperations);
    }
}
Also used : NameVersion(com.synopsys.integration.util.NameVersion) BlackDuckRunData(com.synopsys.integration.detect.lifecycle.run.data.BlackDuckRunData) BdioResult(com.synopsys.integration.detect.workflow.bdio.BdioResult) OperationSystem(com.synopsys.integration.detect.workflow.status.OperationSystem) SingletonFactory(com.synopsys.integration.detect.lifecycle.run.singleton.SingletonFactory) UtilitySingletons(com.synopsys.integration.detect.lifecycle.run.singleton.UtilitySingletons) ProductRunData(com.synopsys.integration.detect.lifecycle.run.data.ProductRunData) DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) IntelligentModeStepRunner(com.synopsys.integration.detect.lifecycle.run.step.IntelligentModeStepRunner) UniversalToolsResult(com.synopsys.integration.detect.tool.UniversalToolsResult) RapidModeStepRunner(com.synopsys.integration.detect.lifecycle.run.step.RapidModeStepRunner) EventSingletons(com.synopsys.integration.detect.lifecycle.run.singleton.EventSingletons) StepHelper(com.synopsys.integration.detect.lifecycle.run.step.utility.StepHelper) UniversalStepRunner(com.synopsys.integration.detect.lifecycle.run.step.UniversalStepRunner) OperationFactory(com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory)

Aggregations

OperationSystem (com.synopsys.integration.detect.workflow.status.OperationSystem)2 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1 ConnectionDetails (com.synopsys.integration.detect.configuration.connection.ConnectionDetails)1 ConnectionFactory (com.synopsys.integration.detect.configuration.connection.ConnectionFactory)1 BlackDuckRunData (com.synopsys.integration.detect.lifecycle.run.data.BlackDuckRunData)1 ProductRunData (com.synopsys.integration.detect.lifecycle.run.data.ProductRunData)1 OperationFactory (com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory)1 EventSingletons (com.synopsys.integration.detect.lifecycle.run.singleton.EventSingletons)1 SingletonFactory (com.synopsys.integration.detect.lifecycle.run.singleton.SingletonFactory)1 UtilitySingletons (com.synopsys.integration.detect.lifecycle.run.singleton.UtilitySingletons)1 IntelligentModeStepRunner (com.synopsys.integration.detect.lifecycle.run.step.IntelligentModeStepRunner)1 RapidModeStepRunner (com.synopsys.integration.detect.lifecycle.run.step.RapidModeStepRunner)1 UniversalStepRunner (com.synopsys.integration.detect.lifecycle.run.step.UniversalStepRunner)1 OperationWrapper (com.synopsys.integration.detect.lifecycle.run.step.utility.OperationWrapper)1 StepHelper (com.synopsys.integration.detect.lifecycle.run.step.utility.StepHelper)1 UniversalToolsResult (com.synopsys.integration.detect.tool.UniversalToolsResult)1 DetectExecutableResolver (com.synopsys.integration.detect.tool.detector.executable.DetectExecutableResolver)1 DetectExecutableRunner (com.synopsys.integration.detect.tool.detector.executable.DetectExecutableRunner)1 DirectoryExecutableFinder (com.synopsys.integration.detect.tool.detector.executable.DirectoryExecutableFinder)1