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;
}
}
}
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());
}
Aggregations