0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License, Version 1.0 only 0N/A * (the "License"). You may not use this file except in compliance 0N/A * See the License for the specific language governing permissions 0N/A * and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 6983N/A * If applicable, add the following below this CDDL HEADER, with the 6983N/A * fields enclosed by brackets "[]" replaced with your own identifying 0N/A * Portions Copyright [yyyy] [name of copyright owner] 4361N/A * Copyright 2006-2009 Sun Microsystems, Inc. 6059N/A * Portions Copyright 2013 ForgeRock AS. 0N/A * This class provides a program that may be used to determine the differences 0N/A * between two LDIF files, generating the output in LDIF change format. There 0N/A * are several things to note about the operation of this program: 0N/A * <LI>This program is only designed for cases in which both LDIF files to be 0N/A * compared will fit entirely in memory at the same time.</LI> 0N/A * <LI>This program will only compare live data in the LDIF files and will 0N/A * ignore comments and other elements that do not have any real impact on 0N/A * the way that the data is interpreted.</LI> 0N/A * <LI>The differences will be generated in such a way as to provide the 0N/A * maximum amount of information, so that there will be enough information 0N/A * for the changes to be reversed (i.e., it will not use the "replace" 0N/A * modification type but only the "add" and "delete" types, and contents 0N/A * of deleted entries will be included as comments).</LI> 0N/A * that this is only an option for cases in which both LDIF files can fit in 0N/A * memory. Also note that this will only compare live data in the LDIF files 0N/A * and will ignore comments and other elements that do not have any real impact 0N/A * on the way that the data is interpreted. 868N/A * The fully-qualified name of this class. 0N/A * Provides the command line arguments to the <CODE>mainDiff</CODE> method 0N/A * so that they can be processed. 0N/A * @param args The command line arguments provided to this program. 0N/A * Parses the provided command line arguments and performs the appropriate 0N/A * LDIF diff operation. 781N/A * @param args The command line arguments provided to this 781N/A * @param serverInitialized Indicates whether the Directory Server has 781N/A * already been initialized (and therefore should 781N/A * not be initialized a second time). 1795N/A * @param outStream The output stream to use for standard output, or 1795N/A * {@code null} if standard output is not needed. 1795N/A * @param errStream The output stream to use for standard error, or 1795N/A * {@code null} if standard error is not needed. 0N/A * @return The return code for this operation. A value of zero indicates 0N/A * that all processing completed successfully. A nonzero value 0N/A * indicates that some problem occurred during processing. 2086N/A "sourceldif",
's',
"sourceLDIF",
true,
2086N/A "targetldif",
't',
"targetLDIF",
true,
2086N/A "outputldif",
'o',
"outputLDIF",
false,
3758N/A "ignoreattrs",
'a',
"ignoreAttrs",
false,
3758N/A "ignoreentries",
'e',
"ignoreEntries",
false,
2086N/A "singlevaluechanges",
'S',
"singleValueChanges",
0N/A // Parse the command-line arguments provided to the program. 1340N/A // If we should just display usage or version information, 781N/A // Bootstrap the Directory Server configuration for use as a client. 781N/A // If we're to use the configuration then initialize it, along with the 3758N/A // Read in ignored entries and attributes if any 0N/A // Open the source LDIF file and read it into a tree map. 0N/A // Open the target LDIF file and read it into a tree map. 0N/A // Open the output writer that we'll use to write the differences. 0N/A // Check to see if either or both of the source and target maps are empty. 0N/A // They're both empty, so there are no differences. 0N/A // The target isn't empty, so they're all adds. 0N/A // The source isn't empty, so they're all deletes. 0N/A // Iterate through all the entries in the source and target maps and 0N/A // identify the differences. 509N/A // Compare the DNs to determine the relative order of the 0N/A // The source entry should be before the target entry, which means 0N/A // that the source entry has been deleted. 781N/A // There are no more source entries, so if there are more target 781N/A // entries then they're all adds. 0N/A // The target entry should be before the source entry, which means 0N/A // that the target entry has been added. 781N/A // There are no more target entries so all of the remaining source 781N/A // entries are deletes. 0N/A // The DNs are the same, so check to see if the entries are the 0N/A // same or have been modified. 0N/A // There are no more source entries, so if there are more target 0N/A // entries then they're all adds. 0N/A // There are no more target entries so all of the remaining source 0N/A // entries are deletes. 0N/A // If we've gotten to this point, then everything was successful. 0N/A * Writes an add change record to the LDIF writer. 0N/A * @param writer The writer to which the add record should be written. 0N/A * @param entry The entry that has been added. 0N/A * @throws IOException If a problem occurs while attempting to write the add 0N/A * Writes a delete change record to the LDIF writer, including a comment 0N/A * with the contents of the deleted entry. 0N/A * @param writer The writer to which the delete record should be written. 0N/A * @param entry The entry that has been deleted. 0N/A * @throws IOException If a problem occurs while attempting to write the 0N/A * Writes a modify change record to the LDIF writer. Note that this will 0N/A * handle all the necessary logic for determining if the entries are actually 0N/A * different, and if they are the same then no output will be generated. Also 0N/A * note that this will only look at differences between the objectclasses and 0N/A * user attributes. It will ignore differences in the DN and operational 779N/A * @param writer The writer to which the modify record should be 779N/A * @param sourceEntry The source form of the entry. 779N/A * @param targetEntry The target form of the entry. 3758N/A * @param ignoreAttrs Attributes that are ignored while calculating 779N/A * @param singleValueChanges Indicates whether each attribute-level change 779N/A * should be written in a separate modification 0N/A * @return <CODE>true</CODE> if there were any differences found between the 0N/A * source and target entries, or <CODE>false</CODE> if not. 0N/A * @throws IOException If a problem occurs while attempting to write the 0N/A // Create a list to hold the modifications that are found. 0N/A // Look at the set of objectclasses for the entries. 0N/A // Whatever is left must have been deleted. 0N/A // Whatever is left must have been added. 0N/A // Look at the user attributes for the entries. 0N/A // The target entry doesn't have this attribute type, so it must have 0N/A // been deleted. In order to make the delete reversible, delete each 0N/A // value individually. 0N/A // Check the attributes for differences. We'll ignore differences in 0N/A // the order of the values since that isn't significant. 0N/A // The attribute doesn't exist in the target list, so it has been 0N/A // Any remaining target attributes have been added. 0N/A // Any remaining target attribute types have been added. 3758N/A // Remove ignored attributes 0N/A // Write the modification change record.