oracle.ldap.util
Class LDIFMigration

java.lang.Object
  |
  +--oracle.ldap.util.LDIFMigration

public class LDIFMigration
extends java.lang.Object

This class provides methods to migrate the user information present in the component specific repositories to OID. The input to this migration process is an intermediate LDIF file which contains the substitution variables that needs to be replaced. The output of this process is an LDIF file which could be used to upload the data using any one of the existing tools.


Constructor Summary
LDIFMigration()
          Creats an instance of LDIFMigration with the log initialized.
LDIFMigration(java.io.File inpF, java.util.Vector subsVect, java.io.File outF)
          This method constructs an object to read the LDIF entry from the specified File object, do the substitution and write the LDIF entries to the specified File object.
LDIFMigration(java.io.InputStream inpS, java.util.Vector subsVect, java.io.OutputStream outS)
          This method constructs an object to read the LDIF entries from the specified input stream, do the substitution and write the LDIF entries to the specified output stream.
LDIFMigration(java.lang.String inputFile, java.util.Vector subsVect, java.lang.String outFile)
          This method constructs an object to read the LDIF file, do the substitution and write the LDIF entries to a file.
 
Method Summary
 void cleanup()
          Closes the ldif reader and writer streams.
static void main(java.lang.String[] args)
          LDIFMigrationTool.
 int migrate()
          Call this method to read the intermediate LDIF file and do the substitution and write a new LDIF output file.
 int migrate(Subscriber subscriber)
          Call this method to read the intermediate LDIF file and do the substitution and write a new LDIF output file.
 Subscriber processCmdLineInput(java.lang.String[] args)
          Use this method to specify the input to the migration process.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDIFMigration

public LDIFMigration()
              throws MigrationException
Creats an instance of LDIFMigration with the log initialized.

LDIFMigration

public LDIFMigration(java.lang.String inputFile,
                     java.util.Vector subsVect,
                     java.lang.String outFile)
              throws MigrationException
This method constructs an object to read the LDIF file, do the substitution and write the LDIF entries to a file.
Parameters:
inputFile - Name of the input file
subsVect - The vector containing the substitution variables and the values alternatively.
outFile - Name of the output file.
Throws:
MigrationException - A migration error could occur due to an I/O error or invalid input parameters. The error code and the the error message of this exception object describes the contexts.

LDIFMigration

public LDIFMigration(java.io.File inpF,
                     java.util.Vector subsVect,
                     java.io.File outF)
              throws MigrationException
This method constructs an object to read the LDIF entry from the specified File object, do the substitution and write the LDIF entries to the specified File object.
Parameters:
inpF - The input File Object
subsVect - The vector containing the substitution variables and the values alternatively.
outF - The output File Object
Throws:
MigrationException - A migration error could occur due to an I/O error or invalid input parameters. The error code and the the error message of this exception object describes the contexts.

LDIFMigration

public LDIFMigration(java.io.InputStream inpS,
                     java.util.Vector subsVect,
                     java.io.OutputStream outS)
              throws MigrationException
This method constructs an object to read the LDIF entries from the specified input stream, do the substitution and write the LDIF entries to the specified output stream.
Parameters:
inpS - The input stream from which provides the LDIF entries
subsVect - The vector containing the substitution variables and the values alternatively.
outS - The output stream to which the LDIF entries are written
Throws:
MigrationException - A migration error could occur due to an I/O error or invalid input parameters. The error code and the the error message of this exception object describes the contexts.
Method Detail

processCmdLineInput

public Subscriber processCmdLineInput(java.lang.String[] args)
                               throws MigrationException
Use this method to specify the input to the migration process.
Parameters:
args[] - command line parameter args[] - a string array with values of the form paramName=value
Returns:
Subscriber object if -lookup option is specified. if subscriber parameter not is specifed then it returns the Subscriber object for the defauld subscriber. When -lookup is not specified then null is returned
Throws:
MigrationException - if an error occurrs while parsing input parameters.

migrate

public int migrate()
            throws MigrationException
Call this method to read the intermediate LDIF file and do the substitution and write a new LDIF output file.
Returns:
int number of entries successfully written.
Throws:
MigrationException - if an error occur while reading from or writing to an LDIF file

migrate

public int migrate(Subscriber subscriber)
            throws MigrationException
Call this method to read the intermediate LDIF file and do the substitution and write a new LDIF output file. The sustitution variables will be automatically figured out by connecting to the directory server. Following is the list of substitution variables which will be determined from a given ldap host.
                s_SubscriberDN
                s_UserContainerDN
                s_GroupContainerDN
                s_SubscriberOracleContextDN
                s_RootOracleContextDN
                s_UserNicknameAttribute
Parameters:
subscriber - the subscriber for which the substitution variables needs to be figured out.
Returns:
int number of entries successfully written.
Throws:
MigrationException - if error occur while reading from or writing to an LDIF file or a NamingException occur while performing a directory operation.

cleanup

public void cleanup()
             throws MigrationException
Closes the ldif reader and writer streams.
Throws:
MigrationException - if an I/O error occurs while closing the reader or writer streams.

main

public static void main(java.lang.String[] args)
LDIFMigrationTool. To migrate the user information that is present in the component specific repositories to the OID. The components will output the data in to an intermediate file. This intermediate file is the input to this tool. The input file contains a set of substituion variables which needs to be replaced with the values provided. The input file, the substitution variables and its values and the output file can be passed as the command line parameters.

    java LDIFMigration "input_file=my_users.txt"
    "output_file=my_users.ldif" "s_UserContainerDN=dc=oracle,dc=com"
    "s_UserNicknameAttribute=uid" [-lookup "host=directoryName" 
    ["port=portnumber"] ["dn=bindDn"] ["password=password"]
    [subscriber=subscribername]
 

Altenatively you may construct an object of this class and call migrate and cleanup methods. You can create an object of this class as

    .......
    .......
    LDIFMigration ldifMig = null;
    try {
          ldifMig = new LDIFMigration("InputFile.ldif",substituteVar,
                                      "OutputFile.ldif");
    catch(MigrationException me) {
    }

 the substituteVar is a vector object containing the substitution 
 variables.
 for example the vector contains elements in this form.

    |------------------------|
    | s_subscriber_user_base | --- Substitution variable
    |------------------------|
    |  dc=oracle,dc=com      | --- Substitution value for the above value
    |------------------------|
    |  s_nickname_attr       | --- Substitution variable 
    |------------------------|
    |        uid             | --- Substitution value
    |------------------------|