| | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.io.Reader; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.TimeZone; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.PasswordReader; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | protected final static int CONFIRMATION_MAX_TRIES = 5; |
| | | |
| | | private static final String COMMENT_SHELL_UNIX = "# "; |
| | | private static final String COMMENT_BATCH_WINDOWS = "rem "; |
| | | |
| | | /** |
| | | * The String used to write comments in a shell (or batch) script. |
| | | */ |
| | | protected static final String SHELL_COMMENT_SEPARATOR = |
| | | SetupUtils.isWindows() ? |
| | | COMMENT_BATCH_WINDOWS : COMMENT_SHELL_UNIX; |
| | | |
| | | /** |
| | | * Creates a new console application instance. |
| | | * |
| | |
| | | } |
| | | return ctx; |
| | | } |
| | | |
| | | /** |
| | | * Returns the message to be displayed in the file with the equivalent |
| | | * command-line with information about the current time. |
| | | * @return the message to be displayed in the file with the equivalent |
| | | * command-line with information about the current time. |
| | | */ |
| | | protected String getCurrentOperationDateMessage() |
| | | { |
| | | String date = formatDateTimeStringForEquivalentCommand(new Date()); |
| | | return INFO_OPERATION_START_TIME_MESSAGE.get(date). |
| | | toString(); |
| | | } |
| | | |
| | | /** |
| | | * Formats a Date to String representation in "dd/MMM/yyyy:HH:mm:ss Z". |
| | | * |
| | | * @param date to format; null if <code>date</code> is null |
| | | * @return string representation of the date |
| | | */ |
| | | protected String formatDateTimeStringForEquivalentCommand(Date date) |
| | | { |
| | | String timeStr = null; |
| | | if (date != null) |
| | | { |
| | | SimpleDateFormat dateFormat = |
| | | new SimpleDateFormat(DATE_FORMAT_LOCAL_TIME); |
| | | dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
| | | timeStr = dateFormat.format(date); |
| | | } |
| | | return timeStr; |
| | | } |
| | | } |