cleaning up Application
@@ -179,32 +179,47 @@ public class Application implements ApplicationRunner {
phoneHomeManager.startPhoneHome();
}
+ runDetect();
+
+ exitCodeType = getExitCodeFromCompletedRun();
+ } catch (final Exception e) {
+ exitCodeType = getExitCodeFromExceptionDetails(e);
+ } finally {
+ cleanupRun();
+ }
+
+ endRun(startTime);
+ }
+
+ private void runDetect() throws DetectUserFriendlyException, IntegrationException, InterruptedException {
final DetectProject detectProject = detectProjectManager.createDetectProject();
logger.info("Project Name: " + detectProject.getProjectName());
logger.info("Project Version Name: " + detectProject.getProjectVersion());
- if (!detectConfigWrapper.getBooleanProperty(DetectProperty.BLACKDUCK_HUB_OFFLINE_MODE)) {
+ if (detectConfigWrapper.getBooleanProperty(DetectProperty.BLACKDUCK_HUB_OFFLINE_MODE)) {
+ if (!detectConfigWrapper.getBooleanProperty(DetectProperty.DETECT_HUB_SIGNATURE_SCANNER_DISABLED)) {
+ hubSignatureScanner.scanPathsOffline(detectProject);
+ }
+ } else {
final ProjectVersionView projectVersionView = hubManager.updateHubProjectVersion(detectProject);
hubManager.performPostHubActions(detectProject, projectVersionView);
- } else if (!detectConfigWrapper.getBooleanProperty(DetectProperty.DETECT_HUB_SIGNATURE_SCANNER_DISABLED)) {
- hubSignatureScanner.scanPathsOffline(detectProject);
}
+ }
+
+ private ExitCodeType getExitCodeFromCompletedRun() {
+ ExitCodeType exitCodeType = this.exitCodeType;
for (final ExitCodeReporter exitCodeReporter : exitCodeReporters) {
exitCodeType = ExitCodeType.getWinningExitCodeType(exitCodeType, exitCodeReporter.getExitCodeType());
}
- } catch (final Exception e) {
- populateExitCodeFromExceptionDetails(e);
- } finally {
- cleanupRun();
+ return exitCodeType;
}
- endRun(startTime);
- }
+ private ExitCodeType getExitCodeFromExceptionDetails(final Exception e) {
+ final ExitCodeType exitCodeType;
- private void populateExitCodeFromExceptionDetails(final Exception e) {
if (e instanceof DetectUserFriendlyException) {
if (e.getCause() != null) {
logger.debug(e.getCause().getMessage(), e.getCause());
@@ -221,6 +236,8 @@ public class Application implements ApplicationRunner {
exitCodeType = ExitCodeType.FAILURE_UNKNOWN_ERROR;
}
logger.error(e.getMessage());
+
+ return exitCodeType;
}
private void cleanupRun() {
