Update all of the tools provided with OpenDS to ensure that they are easier
to invoke programmatically. This includes:
- Providing an alternate static method that returns an integer value and
doesn't use System.exit
- Making sure that method provides the ability to control whether the server
should be initialized (not necessary for all types of tools)
- Making sure that method provides the ability to specify alternate output and
error streams.
OpenDS Issue Number: 987
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintWriter; |
| | | |
| | | /** |
| | |
| | | return stream.written; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A TextWriter implementation which writes to a given output stream. |
| | | */ |
| | | public class STREAM implements TextWriter |
| | | { |
| | | private MeteredStream stream; |
| | | private PrintWriter writer; |
| | | |
| | | /** |
| | | * Creates a new text writer that will write to the provided output stream. |
| | | * |
| | | * @param outputStream The output stream to which |
| | | */ |
| | | public STREAM(OutputStream outputStream) |
| | | { |
| | | stream = new MeteredStream(outputStream, 0); |
| | | writer = new PrintWriter(stream, true); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void writeRecord(String record) |
| | | { |
| | | writer.println(record); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void flush() |
| | | { |
| | | writer.flush(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void shutdown() |
| | | { |
| | | // Should never close the system error stream. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public long getBytesWritten() |
| | | { |
| | | return stream.written; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | | import org.opends.server.util.args.BooleanArgument; |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainBackUpDB(args); |
| | | int retCode = mainBackUpDB(args, true, System.out, System.err); |
| | | |
| | | if(errorLogPublisher != null) |
| | | { |
| | |
| | | */ |
| | | public static int mainBackUpDB(String[] args) |
| | | { |
| | | return mainBackUpDB(args, true); |
| | | return mainBackUpDB(args, true, System.out, System.err); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | public static int mainBackUpDB(String[] args, boolean initializeServer) |
| | | public static int mainBackUpDB(String[] args, boolean initializeServer, |
| | | OutputStream outStream, OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | // Define the command-line arguments that may be used with this program. |
| | | BooleanArgument backUpAll = null; |
| | | BooleanArgument compress = null; |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID; |
| | | String message = getMessage(msgID, backUpAll.getLongIdentifier(), |
| | | backendID.getLongIdentifier()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | int msgID = MSGID_BACKUPDB_NEED_BACKUP_ALL_OR_BACKEND_ID; |
| | | String message = getMessage(msgID, backUpAll.getLongIdentifier(), |
| | | backendID.getLongIdentifier()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | incrementalBaseID.getLongIdentifier(), |
| | | incremental.getLongIdentifier()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_BACKUPDB_SIGN_REQUIRES_HASH; |
| | | String message = getMessage(msgID, signHash.getLongIdentifier(), |
| | | hash.getLongIdentifier()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_BACKUPDB_CANNOT_CREATE_BACKUP_DIR; |
| | | String message = getMessage(msgID, backupDirectory.getValue(), |
| | | getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | errorLogPublisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | new TextWriter.STREAM(out)); |
| | | ErrorLogger.addErrorLogPublisher(errorLogPublisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainExportLDIF(args); |
| | | int retCode = mainExportLDIF(args, true, System.out, System.err); |
| | | |
| | | if(errorLogPublisher != null) |
| | | { |
| | |
| | | */ |
| | | public static int mainExportLDIF(String[] args) |
| | | { |
| | | return mainExportLDIF(args, true); |
| | | return mainExportLDIF(args, true, System.out, System.err); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | public static int mainExportLDIF(String[] args, boolean initializeServer) |
| | | public static int mainExportLDIF(String[] args, boolean initializeServer, |
| | | OutputStream outStream, |
| | | OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | // Define the command-line arguments that may be used with this program. |
| | | BooleanArgument appendToLDIF = null; |
| | | BooleanArgument compressLDIF = null; |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | errorLogPublisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | new TextWriter.STREAM(out)); |
| | | ErrorLogger.addErrorLogPublisher(errorLogPublisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.LDIFImportResult; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainImportLDIF(args); |
| | | int retCode = mainImportLDIF(args, true, System.out, System.err); |
| | | |
| | | if(errorLogPublisher != null) |
| | | { |
| | |
| | | */ |
| | | public static int mainImportLDIF(String[] args) |
| | | { |
| | | return mainImportLDIF(args, true); |
| | | return mainImportLDIF(args, true, System.out, System.err); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | public static int mainImportLDIF(String[] args, boolean initializeServer) |
| | | public static int mainImportLDIF(String[] args, boolean initializeServer, |
| | | OutputStream outStream, |
| | | OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | // FIXME -- Need to add a mechanism for verifying the file signature. |
| | | |
| | | // Define the command-line arguments that may be used with this program. |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_LDIFIMPORT_CONFLICTING_OPTIONS; |
| | | String message = getMessage(msgID, ldifFiles.getLongIdentifier(), |
| | | templateFile.getLongIdentifier()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | int msgID = MSGID_LDIFIMPORT_MISSING_REQUIRED_ARGUMENT; |
| | | String message = getMessage(msgID, ldifFiles.getLongIdentifier(), |
| | | templateFile.getLongIdentifier()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | errorLogPublisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | new TextWriter.STREAM(out)); |
| | | ErrorLogger.addErrorLogPublisher(errorLogPublisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ModificationType; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int exitCode = mainDiff(args, false); |
| | | int exitCode = mainDiff(args, false, System.out, System.err); |
| | | if (exitCode != 0) |
| | | { |
| | | System.exit(filterExitCode(exitCode)); |
| | |
| | | * @param serverInitialized Indicates whether the Directory Server has |
| | | * already been initialized (and therefore should |
| | | * not be initialized a second time). |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return The return code for this operation. A value of zero indicates |
| | | * that all processing completed successfully. A nonzero value |
| | | * indicates that some problem occurred during processing. |
| | | */ |
| | | public static int mainDiff(String[] args, boolean serverInitialized) |
| | | public static int mainDiff(String[] args, boolean serverInitialized, |
| | | OutputStream outStream, OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | BooleanArgument overwriteExisting; |
| | | BooleanArgument showUsage; |
| | | BooleanArgument singleValueChanges; |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(message); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | int msgID = MSGID_LDIFDIFF_CANNOT_OPEN_SOURCE_LDIF; |
| | | String message = getMessage(msgID, sourceLDIF.getValue(), |
| | | String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_LDIFDIFF_ERROR_READING_SOURCE_LDIF; |
| | | String message = getMessage(msgID, sourceLDIF.getValue(), |
| | | String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | int msgID = MSGID_LDIFDIFF_CANNOT_OPEN_TARGET_LDIF; |
| | | String message = getMessage(msgID, targetLDIF.getValue(), |
| | | String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_LDIFDIFF_ERROR_READING_TARGET_LDIF; |
| | | String message = getMessage(msgID, targetLDIF.getValue(), |
| | | String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | } |
| | | else |
| | | { |
| | | exportConfig = new LDIFExportConfig(System.out); |
| | | exportConfig = new LDIFExportConfig(out); |
| | | } |
| | | |
| | | writer = new LDIFWriter(exportConfig); |
| | |
| | | { |
| | | int msgID = MSGID_LDIFDIFF_CANNOT_OPEN_OUTPUT; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFDIFF_ERROR_WRITING_OUTPUT; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedList; |
| | |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.util.AddChangeRecordEntry; |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int returnCode = ldifModifyMain(args, false); |
| | | int returnCode = ldifModifyMain(args, false, System.out, System.err); |
| | | if (returnCode != 0) |
| | | { |
| | | System.exit(filterExitCode(returnCode)); |
| | |
| | | * @param serverInitialized Indicates whether the Directory Server has |
| | | * already been initialized (and therefore should |
| | | * not be initialized a second time). |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return A value of zero if everything completed properly, or nonzero if |
| | | * any problem(s) occurred. |
| | | */ |
| | | public static int ldifModifyMain(String[] args, boolean serverInitialized) |
| | | public static int ldifModifyMain(String[] args, boolean serverInitialized, |
| | | OutputStream outStream, |
| | | OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | // Prepare the argument parser. |
| | | BooleanArgument showUsage; |
| | | StringArgument changesFile; |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(message); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_LDIFMODIFY_SOURCE_DOES_NOT_EXIST; |
| | | String message = getMessage(msgID, sourceFile.getValue()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_LDIFMODIFY_CANNOT_OPEN_SOURCE; |
| | | String message = getMessage(msgID, sourceFile.getValue(), |
| | | String.valueOf(ioe)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFMODIFY_CHANGES_DOES_NOT_EXIST; |
| | | String message = getMessage(msgID, changesFile.getValue()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFMODIFY_CANNOT_OPEN_CHANGES; |
| | | String message = getMessage(msgID, sourceFile.getValue()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFMODIFY_CANNOT_OPEN_TARGET; |
| | | String message = getMessage(msgID, sourceFile.getValue()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFMODIFY_ERROR_PROCESSING_LDIF; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | |
| | | successful = false; |
| | | } |
| | |
| | | |
| | | for (String s : errorList) |
| | | { |
| | | System.err.println(s); |
| | | err.println(s); |
| | | } |
| | | return (successful ? 0 : 1); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchScope; |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int exitCode = mainSearch(args, true); |
| | | int exitCode = mainSearch(args, true, System.out, System.err); |
| | | if (exitCode != 0) |
| | | { |
| | | System.exit(filterExitCode(exitCode)); |
| | |
| | | * Parses the provided command line arguments and performs the appropriate |
| | | * search operation. |
| | | * |
| | | * @param args The command line arguments provided to this program. |
| | | * |
| | | * @param initializeServer True if server initialization should be done. |
| | | * @param args The command line arguments provided to this |
| | | * program. |
| | | * @param initializeServer True if server initialization should be done. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return The return code for this operation. A value of zero indicates |
| | | * that all processing completed successfully. A nonzero value |
| | | * indicates that some problem occurred during processing. |
| | | */ |
| | | public static int mainSearch(String[] args, boolean initializeServer) |
| | | public static int mainSearch(String[] args, boolean initializeServer, |
| | | OutputStream outStream, OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | LinkedHashSet<String> scopeStrings = new LinkedHashSet<String>(4); |
| | | scopeStrings.add(SCOPE_STRING_BASE); |
| | | scopeStrings.add(SCOPE_STRING_ONE); |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(message); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_NO_FILTER; |
| | | String message = getMessage(msgID); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | else |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | String message = getMessage(msgID, |
| | | String.valueOf(configFile.getValue()), |
| | | e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_CANNOT_PARSE_FILTER; |
| | | String message = getMessage(msgID, filterString, e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_CANNOT_PARSE_BASE_DN; |
| | | String message = getMessage(msgID, dnString, e.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_CANNOT_PARSE_TIME_LIMIT; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_CANNOT_PARSE_SIZE_LIMIT; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | exportConfig = new LDIFExportConfig(System.out); |
| | | exportConfig = new LDIFExportConfig(out); |
| | | } |
| | | |
| | | exportConfig.setIncludeObjectClasses(includeObjectclassAttrs); |
| | |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_CANNOT_CREATE_READER; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | int msgID = MSGID_LDIFSEARCH_CANNOT_CREATE_WRITER; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | int msgID = MSGID_LDIFSEARCH_TIME_LIMIT_EXCEEDED; |
| | | String message = getMessage(msgID); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | break; |
| | | } |
| | | |
| | |
| | | |
| | | int msgID = MSGID_LDIFSEARCH_SIZE_LIMIT_EXCEEDED; |
| | | String message = getMessage(msgID); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | break; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_CANNOT_READ_ENTRY_RECOVERABLE; |
| | | String message = getMessage(msgID, le.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_CANNOT_READ_ENTRY_FATAL; |
| | | String message = getMessage(msgID, le.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | resultCode = LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | break; |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_LDIFSEARCH_ERROR_DURING_PROCESSING; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | resultCode = LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.backends.jeb.RebuildConfig; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainRebuildIndex(args); |
| | | int retCode = mainRebuildIndex(args, true, System.out, System.err); |
| | | |
| | | if(errorLogPublisher != null) |
| | | { |
| | |
| | | /** |
| | | * Processes the command-line arguments and invokes the rebuild process. |
| | | * |
| | | * @param args The command-line arguments provided to this program. |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | public static int mainRebuildIndex(String[] args) |
| | | public static int mainRebuildIndex(String[] args, boolean initializeServer, |
| | | OutputStream outStream, |
| | | OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | // Define the command-line arguments that may be used with this program. |
| | | StringArgument configClass = null; |
| | | StringArgument configFile = null; |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int numArgs = args.length; |
| | | if (numArgs == 0) |
| | | { |
| | | System.out.println(argParser.getUsage()); |
| | | out.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_REBUILDINDEX_REQUIRES_AT_LEAST_ONE_INDEX; |
| | | String message = getMessage(msgID); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.out.println(argParser.getUsage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | out.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // configuration. |
| | | DirectoryServer directoryServer = DirectoryServer.getInstance(); |
| | | |
| | | try |
| | | if (initializeServer) |
| | | { |
| | | DirectoryServer.bootstrapClient(); |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | try |
| | | { |
| | | DirectoryServer.bootstrapClient(); |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | try |
| | | { |
| | | directoryServer.initializeConfiguration(configClass.getValue(), |
| | | configFile.getValue()); |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | try |
| | | { |
| | | directoryServer.initializeConfiguration(configClass.getValue(), |
| | | configFile.getValue()); |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | |
| | | // Initialize the Directory Server schema elements. |
| | | try |
| | | { |
| | | directoryServer.initializeSchema(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | // Initialize the Directory Server schema elements. |
| | | try |
| | | { |
| | | directoryServer.initializeSchema(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // Initialize the Directory Server core configuration. |
| | | try |
| | | { |
| | | CoreConfigManager coreConfigManager = new CoreConfigManager(); |
| | | coreConfigManager.initializeCoreConfig(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | // Initialize the Directory Server core configuration. |
| | | try |
| | | { |
| | | CoreConfigManager coreConfigManager = new CoreConfigManager(); |
| | | coreConfigManager.initializeCoreConfig(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // Initialize the Directory Server crypto manager. |
| | | try |
| | | { |
| | | directoryServer.initializeCryptoManager(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | // Initialize the Directory Server crypto manager. |
| | | try |
| | | { |
| | | directoryServer.initializeCryptoManager(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the verify process. |
| | | try |
| | | { |
| | | errorLogPublisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(errorLogPublisher); |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the verify process. |
| | | try |
| | | { |
| | | errorLogPublisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STREAM(out)); |
| | | ErrorLogger.addErrorLogPublisher(errorLogPublisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | | // Decode the base DN provided by the user. |
| | |
| | | |
| | | |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.RestoreConfig; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainRestoreDB(args); |
| | | int retCode = mainRestoreDB(args, true, System.out, System.err); |
| | | |
| | | if(errorLogPublisher != null) |
| | | { |
| | |
| | | */ |
| | | public static int mainRestoreDB(String[] args) |
| | | { |
| | | return mainRestoreDB(args, true); |
| | | return mainRestoreDB(args, true, System.out, System.err); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | public static int mainRestoreDB(String[] args, boolean initializeServer) |
| | | public static int mainRestoreDB(String[] args, boolean initializeServer, |
| | | OutputStream outStream, |
| | | OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | // Define the command-line arguments that may be used with this program. |
| | | BooleanArgument displayUsage = null; |
| | | BooleanArgument listBackups = null; |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | errorLogPublisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | new TextWriter.STREAM(out)); |
| | | ErrorLogger.addErrorLogPublisher(errorLogPublisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_RESTOREDB_LIST_BACKUP_ID; |
| | | String message = getMessage(msgID, backupInfo.getBackupID()); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | |
| | | msgID = MSGID_RESTOREDB_LIST_BACKUP_DATE; |
| | | message = getMessage(msgID, |
| | | dateFormat.format(backupInfo.getBackupDate())); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | |
| | | msgID = MSGID_RESTOREDB_LIST_INCREMENTAL; |
| | | message = getMessage(msgID, String.valueOf(backupInfo.isIncremental())); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | |
| | | msgID = MSGID_RESTOREDB_LIST_COMPRESSED; |
| | | message = getMessage(msgID, String.valueOf(backupInfo.isCompressed())); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | |
| | | msgID = MSGID_RESTOREDB_LIST_ENCRYPTED; |
| | | message = getMessage(msgID, String.valueOf(backupInfo.isEncrypted())); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | |
| | | byte[] hash = backupInfo.getUnsignedHash(); |
| | | msgID = MSGID_RESTOREDB_LIST_HASHED; |
| | | message = getMessage(msgID, String.valueOf(hash != null)); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | |
| | | byte[] signature = backupInfo.getSignedHash(); |
| | | msgID = MSGID_RESTOREDB_LIST_SIGNED; |
| | | message = getMessage(msgID, String.valueOf(signature != null)); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | |
| | | StringBuilder dependencyList = new StringBuilder(); |
| | | HashSet<String> dependencyIDs = backupInfo.getDependencies(); |
| | |
| | | |
| | | msgID = MSGID_RESTOREDB_LIST_DEPENDENCIES; |
| | | message = getMessage(msgID, dependencyList.toString()); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | |
| | | System.out.println(); |
| | | out.println(); |
| | | } |
| | | |
| | | return 1; |
| | |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | | import org.opends.server.util.args.BooleanArgument; |
| | | import org.opends.server.util.args.StringArgument; |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainVerifyIndex(args); |
| | | int retCode = mainVerifyIndex(args, true, System.out, System.err); |
| | | |
| | | if(errorLogPublisher != null) |
| | | { |
| | |
| | | /** |
| | | * Processes the command-line arguments and invokes the verify process. |
| | | * |
| | | * @param args The command-line arguments provided to this program. |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * {@code null} if standard error is not needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | public static int mainVerifyIndex(String[] args) |
| | | public static int mainVerifyIndex(String[] args, boolean initializeServer, |
| | | OutputStream outStream, |
| | | OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | // Define the command-line arguments that may be used with this program. |
| | | StringArgument configClass = null; |
| | | StringArgument configFile = null; |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int numArgs = args.length; |
| | | if (numArgs == 0) |
| | | { |
| | | System.out.println(argParser.getUsage()); |
| | | out.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_VERIFYINDEX_VERIFY_CLEAN_REQUIRES_SINGLE_INDEX; |
| | | String message = getMessage(msgID); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.out.println(argParser.getUsage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | out.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // configuration. |
| | | DirectoryServer directoryServer = DirectoryServer.getInstance(); |
| | | |
| | | try |
| | | if (initializeServer) |
| | | { |
| | | DirectoryServer.bootstrapClient(); |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | try |
| | | { |
| | | DirectoryServer.bootstrapClient(); |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | try |
| | | { |
| | | directoryServer.initializeConfiguration(configClass.getValue(), |
| | | configFile.getValue()); |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | try |
| | | { |
| | | directoryServer.initializeConfiguration(configClass.getValue(), |
| | | configFile.getValue()); |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | |
| | | // Initialize the Directory Server schema elements. |
| | | try |
| | | { |
| | | directoryServer.initializeSchema(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | // Initialize the Directory Server schema elements. |
| | | try |
| | | { |
| | | directoryServer.initializeSchema(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // Initialize the Directory Server core configuration. |
| | | try |
| | | { |
| | | CoreConfigManager coreConfigManager = new CoreConfigManager(); |
| | | coreConfigManager.initializeCoreConfig(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | // Initialize the Directory Server core configuration. |
| | | try |
| | | { |
| | | CoreConfigManager coreConfigManager = new CoreConfigManager(); |
| | | coreConfigManager.initializeCoreConfig(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // Initialize the Directory Server crypto manager. |
| | | try |
| | | { |
| | | directoryServer.initializeCryptoManager(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | // Initialize the Directory Server crypto manager. |
| | | try |
| | | { |
| | | directoryServer.initializeCryptoManager(); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the verify process. |
| | | try |
| | | { |
| | | errorLogPublisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(errorLogPublisher); |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the verify process. |
| | | try |
| | | { |
| | | errorLogPublisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STREAM(out)); |
| | | ErrorLogger.addErrorLogPublisher(errorLogPublisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | err.println("Error installing the custom error logger: " + |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | "--outputLDIF", diffLdifFile.getAbsolutePath() |
| | | }; |
| | | |
| | | int retVal = LDIFDiff.mainDiff(args, true); |
| | | int retVal = LDIFDiff.mainDiff(args, true, System.out, System.err); |
| | | assertEquals(retVal, 0, "LDIFDiff failed"); |
| | | |
| | | if (diffLdifFile.exists()) { |
| | |
| | | "-n", beID, |
| | | "-i", "+" |
| | | }; |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false), 0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | //Expecting a non-empty reject file. |
| | | assertRejectedFile(reject,false); |
| | | } |
| | |
| | | "-n", beID, |
| | | "-i", "*" |
| | | }; |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false), 0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | //Expecting an empty reject file. |
| | | assertRejectedFile(reject,true); |
| | | |
| | |
| | | "-n", beID, |
| | | "-R", rejectFilePath |
| | | }; |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false),0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | //Reject file should be empty. |
| | | assertRejectedFile(reject,true); |
| | | //check the presence of some random attributes. |
| | |
| | | "-e", "description" |
| | | }; |
| | | |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false), 0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | assertRejectedFile(reject,true); |
| | | Attribute[] attr = |
| | | { |
| | |
| | | "-e", "*" |
| | | }; |
| | | |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false), 0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | assertRejectedFile(reject,false); |
| | | } |
| | | |
| | |
| | | "-R",rejectFilePath, |
| | | "-e", "+" |
| | | }; |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false), 0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | assertRejectedFile(reject,true); |
| | | Attribute[] attrs = { |
| | | new Attribute ("creatorsname", "cn=Import") , |
| | |
| | | "-i", "*", |
| | | "-i","creatorsname" |
| | | }; |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false), 0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | assertRejectedFile(reject,true); |
| | | Attribute[] attrs = { |
| | | new Attribute ("creatorsname", "cn=Import") |
| | |
| | | "-i", "sn", |
| | | "-i","creatorsname" |
| | | }; |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false), 0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | assertRejectedFile(reject,true); |
| | | Attribute[] attrsPr = { |
| | | new Attribute ("creatorsname", "cn=Import") |
| | |
| | | "-e", "givenName", |
| | | "-e","creatorsname" |
| | | }; |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false), 0); |
| | | assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0); |
| | | assertRejectedFile(reject,true); |
| | | Attribute[] attrsPr = { |
| | | new Attribute ("modifiersname", "cn=Import"), |
| | |
| | | public void testUsage() |
| | | { |
| | | String[] args = { "--help" }; |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | |
| | | args = new String[] { "-H" }; |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | |
| | | args = new String[] { "-?" }; |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "--invalid" |
| | | }; |
| | | |
| | | assertFalse(LDIFDiff.mainDiff(args, true) == 0); |
| | | assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | if (normalDiffFile == null) |
| | | { |
| | | // We expect this to fail, so just make sure that it does. |
| | | assertFalse(LDIFDiff.mainDiff(args, true) == 0); |
| | | assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0); |
| | | outputFile.delete(); |
| | | return; |
| | | } |
| | | |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | |
| | | long outputChecksum = 0L; |
| | | BufferedReader reader = new BufferedReader(new FileReader(outputFile)); |
| | |
| | | if (singleValueDiffFile == null) |
| | | { |
| | | // We expect this to fail, so just make sure that it does. |
| | | assertFalse(LDIFDiff.mainDiff(args, true) == 0); |
| | | assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0); |
| | | outputFile.delete(); |
| | | return; |
| | | } |
| | | |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | |
| | | long outputChecksum = 0L; |
| | | BufferedReader reader = new BufferedReader(new FileReader(outputFile)); |
| | |
| | | "-o", diffOutputFile.getAbsolutePath() |
| | | }; |
| | | |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | |
| | | |
| | | // Use LDIFModify to generate a new target file. |
| | |
| | | "-t", newTargetFile.getAbsolutePath() |
| | | }; |
| | | |
| | | assertEquals(LDIFModify.ldifModifyMain(args, true), 0); |
| | | assertEquals(LDIFModify.ldifModifyMain(args, true, System.out, System.err), |
| | | 0); |
| | | |
| | | |
| | | // Use LDIFDiff again to verify that there are effectively no differences |
| | |
| | | "-o", newDiffFile.getAbsolutePath() |
| | | }; |
| | | |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | |
| | | |
| | | // Read the contents of the new diff file and make sure it matches the |
| | |
| | | "-S" |
| | | }; |
| | | |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | |
| | | |
| | | // Use LDIFModify to generate a new target file. |
| | |
| | | "-t", newTargetFile.getAbsolutePath() |
| | | }; |
| | | |
| | | assertEquals(LDIFModify.ldifModifyMain(args, true), 0); |
| | | assertEquals(LDIFModify.ldifModifyMain(args, true, System.out, System.err), |
| | | 0); |
| | | |
| | | |
| | | // Use LDIFDiff again to verify that there are effectively no differences |
| | |
| | | "-o", newDiffFile.getAbsolutePath() |
| | | }; |
| | | |
| | | assertEquals(LDIFDiff.mainDiff(args, true), 0); |
| | | assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0); |
| | | |
| | | |
| | | // Read the contents of the new diff file and make sure it matches the |
| | |
| | | "(objectclass=*)", |
| | | "*", "+" |
| | | }; |
| | | assertEquals(LDIFSearch.mainSearch(args, false), 0); |
| | | assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | |
| | | "(objectclass=*)", |
| | | "+" |
| | | }; |
| | | assertEquals(LDIFSearch.mainSearch(args, false), 0); |
| | | assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | |
| | | "(objectclass=*)", |
| | | "+", "mail", "uid" |
| | | }; |
| | | assertEquals(LDIFSearch.mainSearch(args, false), 0); |
| | | assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | |
| | | "(objectclass=*)", |
| | | "mail", "uid" |
| | | }; |
| | | assertEquals(LDIFSearch.mainSearch(args, false), 0); |
| | | assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |