com.infoengine.util
Class LDAPImport

java.lang.Object
  extended bycom.infoengine.util.LDAPImport

public class LDAPImport
extends Object

This class will perform an LDAP Import from a valid LDIF file. The LDAP instance is determined by the installed Windchill properties. During import, the string "<base>" is replaced with the fully qualified base dn of the import point. By default existing entries will be overwritten, and any non existing entries will be added. Existing entries can be skipped by setting the overwrite option to false (only available if used in java code as a bean).

Parameters required are:

[dir] The home of Windchill installation (ex. c:\ptc\Windchill )
The value is not used if "ldapurl" is specified.

[ldiffile] A path relative to codebase or and absolute path of a list
of LDIF files to import

[ldapurl] An ldap provider url speifying where to import the ldif file.
This parameter is optional, if not specified, ie.properties
in "dir" is be used. Example:
ldap://cn=Manager:admin@jdmeyer03d.ptcnet.ptc.com/cn=myhost,cn=Application Services,o=ptc The elements defined by the dn "cn=myhost,cn=Application Services,o=ptc" must exist.

Dependancies: Additional dependant jar files

ie.jar
servlet.jar

The command line calling sequence is:
java -cp v:\Windchill\codebase;v:\Windchill\codebase\WEB-INF\lib\ie.jar;v:\Windchill\lib\servlet.jar com.infoengine.util.LDAPImport -dir (windchill install dir) -ldiffile file


Field Summary
private static String IEPROPS
           
private  Vector ivImportList
          list of import files
private  String ivInstallDir
          Installation directory
private  String ivLdapUrl
          LDAP url
private  boolean ivOverwrite
          Overrwrite flag
 
Constructor Summary
LDAPImport()
           
 
Method Summary
private  int doEntriesExist(DirectoryService service, Group entries, Url u)
          Give an LDAP service and a group of entries check whether they exist In the file.
private  String getIEProperties(String wcHome)
          Helper method to get the provider url from the Info*Engine install.
 Vector getImportList()
          Get the current ldif import list.
 String getInstallDir()
          Get the file path to current installation directory.
 String getLdapUrl()
          Return the current ldap url
private  String getProvider(String wcHome)
          Helper method to get the provider url from the Info*Engine install.
 boolean isOverwrite()
          Test the current setting of the overwrite option.
static void main(String[] args)
          Main entry point.
private  void process(String[] args)
          Process the arguments.
 void runAction()
          May be called by java code to execute this action in a stand alone java environment.
 void setImportList(Vector vals)
          Set the relative or absolute paths to the ldif files to import.
 void setInstallDir(String val)
          Set the file path to the installation directory.
 void setLdapUrl(String val)
          Set the LDAP url
 void setOverwrite(boolean val)
          Set an option to overwrite any existing entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IEPROPS

private static final String IEPROPS
See Also:
Constant Field Values

ivInstallDir

private String ivInstallDir
Installation directory


ivImportList

private Vector ivImportList
list of import files


ivOverwrite

private boolean ivOverwrite
Overrwrite flag


ivLdapUrl

private String ivLdapUrl
LDAP url

Constructor Detail

LDAPImport

public LDAPImport()
Method Detail

setInstallDir

public void setInstallDir(String val)
Set the file path to the installation directory.

Parameters:
val - Fully qualified path of a valid Windchill installation directory.

getInstallDir

public String getInstallDir()
Get the file path to current installation directory.

Returns:
The relative path to the current install directory

setImportList

public void setImportList(Vector vals)
Set the relative or absolute paths to the ldif files to import. A relative path is to the Windchill installation directory codebase.

Parameters:
vals - An array of relative or absolute path strings.

getImportList

public Vector getImportList()
Get the current ldif import list.

Returns:
An array of the relative paths of the ldif files to import

setOverwrite

public void setOverwrite(boolean val)
Set an option to overwrite any existing entries.

Parameters:
val - Specifies if existing entries are to be overwritten. Default is false.

isOverwrite

public boolean isOverwrite()
Test the current setting of the overwrite option.

Returns:
True if overwrite is enabled, false otherwise.

setLdapUrl

public void setLdapUrl(String val)
Set the LDAP url

Parameters:
val - Specifies a valid string form of an LDAP url.

getLdapUrl

public String getLdapUrl()
Return the current ldap url

Returns:
String representation of the current LDAP Url.

process

private void process(String[] args)
              throws IEException,
                     IOException
Process the arguments.

Throws:
Exception - If an unexpected exception occurs.
IEException
IOException

runAction

public void runAction()
               throws IEException,
                      IOException
May be called by java code to execute this action in a stand alone java environment. Required properties must be set correctly before execution.

Throws:
IEException - If a variable setting is unacceptable
IOException - If an IO error occurs when reading the ldif files.

doEntriesExist

private int doEntriesExist(DirectoryService service,
                           Group entries,
                           Url u)
                    throws Exception
Give an LDAP service and a group of entries check whether they exist In the file.

Parameters:
service - The directory service
entries - The LDAP entries to check
u - The Url for to check against.
Returns:
The number of existing entries
Throws:
Exception - If an unexpected exception occurs when adding the LDAP entries.

getProvider

private String getProvider(String wcHome)
                    throws IOException
Helper method to get the provider url from the Info*Engine install. It will first look at the ie.properties located in /codebase/WEB-INF/ie.properties and attempt to determine the provider from there.

Parameters:
wcHome - Install path to the Windchill installation.
Returns:
The provider url
Throws:
IOException - If an unexpected exception occurs.

getIEProperties

private String getIEProperties(String wcHome)
Helper method to get the provider url from the Info*Engine install. It will first look at the ie.properties located in /codebase/WEB-INF/ie.properties and attempt to determine the provider from there.

Parameters:
wcHome - Install path to the Windchill installation.
Returns:
The provider url
Throws:
IOException - If an unexpected exception occurs.

main

public static void main(String[] args)
Main entry point.

Throws:
IOException - If an unexpected exception occurs.