Search in sources :

Example 1 with BlackDuckConfigFactory

use of com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory in project synopsys-detect by blackducksoftware.

the class BlackDuckConnectionDecisionBranch method traverse.

@Override
public void traverse(InteractivePropertySourceBuilder propertySourceBuilder, InteractiveWriter writer) {
    boolean shouldReconfigureServer = true;
    BlackDuckConnectivityResult blackDuckConnectivityResult = BlackDuckConnectivityResult.failure("Connection has yet to be attempted.");
    BlackDuckServerDecisionBranch blackDuckServerDecisionBranch = new BlackDuckServerDecisionBranch();
    while (!blackDuckConnectivityResult.isSuccessfullyConnected() && shouldReconfigureServer) {
        blackDuckServerDecisionBranch.traverse(propertySourceBuilder, writer);
        Boolean testConnection = writer.askYesOrNo(SHOULD_TEST_CONNECTION);
        if (testConnection) {
            try {
                MapPropertySource interactivePropertySource = propertySourceBuilder.build();
                List<PropertySource> propertySources = new ArrayList<>(this.existingPropertySources);
                propertySources.add(0, interactivePropertySource);
                PropertyConfiguration propertyConfiguration = new PropertyConfiguration(propertySources);
                DetectPropertyConfiguration detectConfiguration = new DetectPropertyConfiguration(propertyConfiguration, new SimplePathResolver());
                DetectConfigurationFactory detectConfigurationFactory = new DetectConfigurationFactory(detectConfiguration, gson);
                BlackDuckConfigFactory blackDuckConfigFactory = new BlackDuckConfigFactory(detectInfo, detectConfigurationFactory.createBlackDuckConnectionDetails());
                BlackDuckServerConfig blackDuckServerConfig = blackDuckConfigFactory.createServerConfig(new SilentIntLogger());
                blackDuckConnectivityResult = blackDuckConnectivityChecker.determineConnectivity(blackDuckServerConfig);
            } catch (Exception e) {
                blackDuckConnectivityResult = BlackDuckConnectivityResult.failure("Failed to test connection. " + System.lineSeparator() + e);
            }
            if (!blackDuckConnectivityResult.isSuccessfullyConnected()) {
                writer.println(blackDuckConnectivityResult.getFailureReason());
                shouldReconfigureServer = writer.askYesOrNo(SHOULD_RETRY_CONNECTION);
            }
        } else {
            shouldReconfigureServer = false;
        }
    }
}
Also used : BlackDuckConnectivityResult(com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult) ArrayList(java.util.ArrayList) SimplePathResolver(com.synopsys.integration.configuration.property.types.path.SimplePathResolver) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource) BlackDuckServerConfig(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig) SilentIntLogger(com.synopsys.integration.log.SilentIntLogger) DetectPropertyConfiguration(com.synopsys.integration.detect.configuration.DetectPropertyConfiguration) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) DetectConfigurationFactory(com.synopsys.integration.detect.configuration.DetectConfigurationFactory) DetectPropertyConfiguration(com.synopsys.integration.detect.configuration.DetectPropertyConfiguration) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) BlackDuckConfigFactory(com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory)

Example 2 with BlackDuckConfigFactory

use of com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory in project synopsys-detect by blackducksoftware.

the class ProductBootFactory method createBlackDuckServerConfig.

public BlackDuckServerConfig createBlackDuckServerConfig() throws DetectUserFriendlyException {
    BlackDuckConnectionDetails connectionDetails = detectConfigurationFactory.createBlackDuckConnectionDetails();
    BlackDuckConfigFactory blackDuckConfigFactory = new BlackDuckConfigFactory(detectInfo, connectionDetails);
    return blackDuckConfigFactory.createServerConfig(new SilentIntLogger());
}
Also used : SilentIntLogger(com.synopsys.integration.log.SilentIntLogger) BlackDuckConnectionDetails(com.synopsys.integration.detect.configuration.connection.BlackDuckConnectionDetails) BlackDuckConfigFactory(com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory)

Aggregations

BlackDuckConfigFactory (com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory)2 SilentIntLogger (com.synopsys.integration.log.SilentIntLogger)2 BlackDuckServerConfig (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig)1 PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)1 SimplePathResolver (com.synopsys.integration.configuration.property.types.path.SimplePathResolver)1 MapPropertySource (com.synopsys.integration.configuration.source.MapPropertySource)1 PropertySource (com.synopsys.integration.configuration.source.PropertySource)1 DetectConfigurationFactory (com.synopsys.integration.detect.configuration.DetectConfigurationFactory)1 DetectPropertyConfiguration (com.synopsys.integration.detect.configuration.DetectPropertyConfiguration)1 BlackDuckConnectionDetails (com.synopsys.integration.detect.configuration.connection.BlackDuckConnectionDetails)1 BlackDuckConnectivityResult (com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult)1 ArrayList (java.util.ArrayList)1