Search in sources :

Example 1 with OperationFactory

use of com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory in project synopsys-detect by blackducksoftware.

the class DetectRun method createOperationFactory.

private OperationFactory createOperationFactory(BootSingletons bootSingletons, UtilitySingletons utilitySingletons, EventSingletons eventSingletons) throws DetectUserFriendlyException {
    DetectorFactory detectorFactory = new DetectorFactory(bootSingletons, utilitySingletons);
    DetectFontLoaderFactory detectFontLoaderFactory = new DetectFontLoaderFactory(bootSingletons, utilitySingletons);
    return new OperationFactory(detectorFactory.detectDetectableFactory(), detectFontLoaderFactory, bootSingletons, utilitySingletons, eventSingletons, exitCodeManager);
}
Also used : DetectorFactory(com.synopsys.integration.detect.tool.detector.factory.DetectorFactory) OperationFactory(com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory)

Example 2 with OperationFactory

use of com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory 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)

Example 3 with OperationFactory

use of com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory in project synopsys-detect by blackducksoftware.

the class BinaryUploadOperationTest method testShouldFailOnDirectory.

@Test
public void testShouldFailOnDirectory() throws OperationException {
    BinaryScanOptions binaryScanOptions = new BinaryScanOptions(Paths.get("."), null, 0, false);
    OperationFactory operationFactory = Mockito.mock(OperationFactory.class);
    Mockito.when(operationFactory.calculateBinaryScanOptions()).thenReturn(binaryScanOptions);
    BinaryScanStepRunner binaryScanStepRunner = new BinaryScanStepRunner(operationFactory);
    Optional<File> result = binaryScanStepRunner.determineBinaryScanFileTarget(DockerTargetData.NO_DOCKER_TARGET);
    Mockito.verify(operationFactory).publishBinaryFailure(Mockito.anyString());
    Assertions.assertFalse(result.isPresent());
}
Also used : BinaryScanStepRunner(com.synopsys.integration.detect.lifecycle.run.step.BinaryScanStepRunner) File(java.io.File) OperationFactory(com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory) Test(org.junit.jupiter.api.Test)

Aggregations

OperationFactory (com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory)3 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1 BlackDuckRunData (com.synopsys.integration.detect.lifecycle.run.data.BlackDuckRunData)1 ProductRunData (com.synopsys.integration.detect.lifecycle.run.data.ProductRunData)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 BinaryScanStepRunner (com.synopsys.integration.detect.lifecycle.run.step.BinaryScanStepRunner)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 StepHelper (com.synopsys.integration.detect.lifecycle.run.step.utility.StepHelper)1 UniversalToolsResult (com.synopsys.integration.detect.tool.UniversalToolsResult)1 DetectorFactory (com.synopsys.integration.detect.tool.detector.factory.DetectorFactory)1 BdioResult (com.synopsys.integration.detect.workflow.bdio.BdioResult)1 OperationSystem (com.synopsys.integration.detect.workflow.status.OperationSystem)1 NameVersion (com.synopsys.integration.util.NameVersion)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1