Issue 729: import LDIF tool returns successful exit code on failure.
Return an exit code of 1 on failure of import LDIF. Change setup tool to print an error message when the import fails.
| | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used to indicate that the |
| | | * LDIF import was unsuccessful. This does not take any arguments. |
| | | */ |
| | | public static final int MSGID_INSTALLDS_IMPORT_UNSUCCESSFUL = |
| | | CATEGORY_MASK_TOOLS | SEVERITY_MASK_SEVERE_ERROR | 672; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Associates a set of generic messages with the message IDs defined in this |
| | | * class. |
| | | */ |
| | |
| | | "database...."); |
| | | registerMessage(MSGID_INSTALLDS_IMPORT_SUCCESSFUL, |
| | | "Import complete."); |
| | | registerMessage(MSGID_INSTALLDS_IMPORT_UNSUCCESSFUL, |
| | | "Import failed."); |
| | | registerMessage(MSGID_INSTALLDS_STATUS_SUCCESS, |
| | | "The " + SHORT_NAME + " setup process has completed " + |
| | | "successfully."); |
| | |
| | | |
| | | try |
| | | { |
| | | directoryServer.bootstrapClient(); |
| | | directoryServer.initializeJMX(); |
| | | DirectoryServer.bootstrapClient(); |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | String.valueOf(failureReason)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return 0; |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | stackTraceToSingleLineString(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return 0; |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // Launch the import. |
| | | int retCode = 0; |
| | | try |
| | | { |
| | | backend.importLDIF(configEntry, baseDNs, importConfig); |
| | |
| | | String message = getMessage(msgID, de.getErrorMessage()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | retCode = 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | retCode = 1; |
| | | } |
| | | |
| | | |
| | |
| | | String.valueOf(failureReason)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_WARNING, |
| | | message, msgID); |
| | | retCode = 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | stackTraceToSingleLineString(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_WARNING, |
| | | message, msgID); |
| | | retCode = 1; |
| | | } |
| | | |
| | | |
| | | // Clean up after the import by closing the import config. |
| | | importConfig.close(); |
| | | return 0; |
| | | return retCode; |
| | | } |
| | | |
| | | |
| | |
| | | returnValue = ImportLDIF.mainImportLDIF(importLDIFArguments); |
| | | if (returnValue != 0) |
| | | { |
| | | String message = getMessage(MSGID_INSTALLDS_IMPORT_UNSUCCESSFUL); |
| | | System.out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return returnValue; |
| | | } |
| | | else |