| | |
| | | import org.opends.quicksetup.util.PlainTextProgressMessageFormatter; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.loggers.ErrorLogPublisher; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.loggers.TextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.tasks.PurgeConflictsHistoricalTask; |
| | | import org.opends.server.tools.dsreplication.EnableReplicationUserData.EnableReplicationServerData; |
| | | import org.opends.server.tools.dsreplication.ReplicationCliArgumentParser.ServerArgs; |
| | |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainCLI(args, true, System.out, System.err); |
| | | System.exit(retCode); |
| | | JDKLogging.enableLoggingForOpenDJTool(System.err); |
| | | final ErrorLogPublisher errorLogPublisher = |
| | | TextErrorLogPublisher.getToolStartupTextErrorPublisher(new TextWriter.STREAM(System.err)); |
| | | ErrorLogger.getInstance().addLogPublisher(errorLogPublisher); |
| | | |
| | | ReplicationCliMain replicationCli = new ReplicationCliMain(System.out, System.err); |
| | | System.exit(replicationCli.execute(args, true).getReturnCode()); |
| | | } |
| | | |
| | | /** |
| | |
| | | sourceServerCI = new LDAPConnectionConsoleInteraction(this, argParser.getSecureArgsList()); |
| | | sourceServerCI.setDisplayLdapIfSecureParameters(false); |
| | | |
| | | ReplicationCliReturnCode returnValue = SUCCESSFUL_NOP; |
| | | String subCommand = null; |
| | | final SubcommandChoice subcommandChoice = getSubcommandChoice(argParser.getSubCommand()); |
| | | if (subcommandChoice != null) |
| | | { |
| | | subCommand = subcommandChoice.getName(); |
| | | returnValue = execute(subcommandChoice); |
| | | return execute(subcommandChoice); |
| | | } |
| | | else if (argParser.isInteractive()) |
| | | if (argParser.isInteractive()) |
| | | { |
| | | final SubcommandChoice subCommandChoice = promptForSubcommand(); |
| | | if (subCommandChoice == null || SubcommandChoice.CANCEL.equals(subCommandChoice)) |
| | |
| | | return USER_CANCELLED; |
| | | } |
| | | |
| | | subCommand = subCommandChoice.getName(); |
| | | final String subCommand = subCommandChoice.getName(); |
| | | if (subCommand != null) |
| | | { |
| | | String[] newArgs = new String[args.length + 1]; |
| | |
| | | // The server (if requested) has already been initialized. |
| | | return execute(newArgs, false); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | errPrintln(ERR_REPLICATION_VALID_SUBCOMMAND_NOT_FOUND.get("--" + OPTION_LONG_NO_PROMPT)); |
| | | errPrintln(LocalizableMessage.raw(argParser.getUsage())); |
| | | return ERROR_USER_DATA; |
| | | return SUCCESSFUL_NOP; |
| | | } |
| | | |
| | | // Display the log file only if the operation is successful (when there |
| | | // is a critical error this is already displayed). |
| | | if (returnValue == SUCCESSFUL && displayLogFileAtEnd(subCommand)) |
| | | { |
| | | File logFile = ControlPanelLog.getLogFile(); |
| | | if (logFile != null) |
| | | { |
| | | println(); |
| | | println(INFO_GENERAL_SEE_FOR_DETAILS.get(logFile.getPath())); |
| | | println(); |
| | | } |
| | | } |
| | | |
| | | return returnValue; |
| | | errPrintln(ERR_REPLICATION_VALID_SUBCOMMAND_NOT_FOUND.get("--" + OPTION_LONG_NO_PROMPT)); |
| | | errPrintln(LocalizableMessage.raw(argParser.getUsage())); |
| | | return ERROR_USER_DATA; |
| | | } |
| | | |
| | | private SubcommandChoice getSubcommandChoice(SubCommand subCommand) |
| | |
| | | return results; |
| | | } |
| | | |
| | | private boolean displayLogFileAtEnd(String subCommand) |
| | | { |
| | | final List<String> subCommands = Arrays.asList(ENABLE_REPLICATION_SUBCMD_NAME, DISABLE_REPLICATION_SUBCMD_NAME, |
| | | INITIALIZE_ALL_REPLICATION_SUBCMD_NAME, INITIALIZE_REPLICATION_SUBCMD_NAME, RESET_CHANGE_NUMBER_SUBCMD_NAME); |
| | | return subCommands.contains(subCommand); |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. The method |
| | | * must be called after parsing the arguments. |