Updating offline logic to flow better.
@@ -36,17 +36,15 @@ public class ConnectivityChecker {
Slf4jIntLogger blackduckLogger = new Slf4jIntLogger(logger);
BlackDuckServerConfig blackDuckServerConfig = detectOptionManager.createBlackduckServerConfig();
- boolean connected;
logger.info("Attempting connection to the Black Duck server");
- if (blackDuckServerConfig.canConnect(blackduckLogger)) {
- logger.info("Connection to the Black Duck server was successful");//TODO: Get a detailed reason of why canConnect failed.
- connected = true;
- } else {
+
+ if (!blackDuckServerConfig.canConnect(blackduckLogger)) {
logger.error("Failed to connect to the Black Duck server");
- connected = false;
+ return ConnectivityResult.failure("Could not reach the Black Duck server or the credentials were invalid.");
}
- if (connected) {
+ logger.info("Connection to the Black Duck server was successful");//TODO: Get a detailed reason of why canConnect failed.
+
BlackDuckServicesFactory blackDuckServicesFactory = blackDuckServerConfig.createBlackDuckServicesFactory(gson, objectMapper, blackduckLogger);
try {
@@ -63,8 +61,5 @@ public class ConnectivityChecker {
PhoneHomeManager phoneHomeManager = new OnlinePhoneHomeManager(additionalMetaData, detectInfo, gson, eventSystem, blackDuckPhoneHomeHelper);
return ConnectivityResult.success(blackDuckServicesFactory, phoneHomeManager, blackDuckServerConfig);
- } else {
- return ConnectivityResult.failure("Could not reach the Black Duck server or the credentials were invalid.");
- }
}
}
