wt.org
Class WTUserToProxyUserMigrator

java.lang.Object
  extended bywt.org.WTUserToProxyUserMigrator
All Implemented Interfaces:
Migrator

public class WTUserToProxyUserMigrator
extends Object
implements Migrator

A Federated ProxyUser needs the following information at minimum in order to be able to refresh itself. - source object id (the distinguished name of the user in the directory) - servicenameserviceid (the name of the directory service) - classnameserviceid ("FederatedDirectoryService") - sourceurl - service id ("FederatedDirectoryService:") The migration strategy is to populate the above necessary columns in the new ProxyUser table entries, and then to set the expiration time and refresh time to trigger an immediate refresh of the ProxyUser. The assumption is that because pre-R5 LDAP users are restricted to one location in the LDAP directory, then the migrated ProxyUsers will all share the same federated directory service. Along with the columns above, the following columns are NOT NULL in the ProxyUser table and must be populated as well: - name - authenticationName - attributes - ida2a2 The name authenticationName, and ida2a2 will be moved over from the pre-R5 user. The attributes will be initialized to be an empty blob.


Field Summary
private  Hashtable attributeTable
           
private  PrintWriter debugLog
           
private  String hostName
           
private static String KEY_CLASSNAME
           
private static String KEY_ID
           
private static int MAX_IN_CLAUSE_SIZE
           
private  Hashtable objectMappablesWithRefs
           
private  Vector oidLists_
           
private static String providerURL
           
private  String searchBase
           
private  String serviceClass
           
private  String serviceName
           
private  Statement statement_
           
private static String URLproperty
           
 
Constructor Summary
WTUserToProxyUserMigrator()
           
 
Method Summary
private  void breakOidListIntoManageableSets(Vector user_oid_list)
          Ugly method to cope with the fact that Oracle can only handle so many elements in a SQL IN(...) list.
private  void buildObjectMappablesList()
          Build a list of ObjectMappable classes with reference properties that may contain a WTPrincipalReference.
private  void findOidsOfUsersToTurnIntoProxyUsers(Connection connection)
          Find oids of all the users that have to be turned into ProxyUsers.
private  void listReferenceProperties(ClassInfo class_info, EnumeratorVector vect, String property_name)
           
private  void moveWtUsersToProxyUsers(Connection connection)
          For each pre-R5 LDAP user: 1.
 boolean runMigration(Connection connection, PersistentObjectManager pom, PrintWriter logWriter)
          Run the migration.
private  void setFederatedServiceName(Connection connection)
          Find the name of the federated directory service with our search base.
private  void setSearchBaseAndHostname()
          Get the search base and hostname of the LDAP server from the provider URL.
private  void updateReferencesThatAreProperties(ClassInfo class_info)
           
private  void updateReferencesThatArePropertiesOnPersistables()
           
private  void updateReferenceToUser(BaseTableInfo bti, ColumnDescriptor cls_name_col, ColumnDescriptor id_name_col)
          Change the classname for migrated users from WTUser to ProxyUser, for references with the specified table and pair of reference columns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URLproperty

private static final String URLproperty
See Also:
Constant Field Values

providerURL

private static String providerURL

MAX_IN_CLAUSE_SIZE

private static final int MAX_IN_CLAUSE_SIZE
See Also:
Constant Field Values

KEY_CLASSNAME

private static final String KEY_CLASSNAME
See Also:
Constant Field Values

KEY_ID

private static final String KEY_ID
See Also:
Constant Field Values

debugLog

private PrintWriter debugLog

oidLists_

private Vector oidLists_

statement_

private Statement statement_

searchBase

private String searchBase

hostName

private String hostName

serviceName

private String serviceName

serviceClass

private String serviceClass

attributeTable

private Hashtable attributeTable

objectMappablesWithRefs

private Hashtable objectMappablesWithRefs
Constructor Detail

WTUserToProxyUserMigrator

public WTUserToProxyUserMigrator()
Method Detail

runMigration

public boolean runMigration(Connection connection,
                            PersistentObjectManager pom,
                            PrintWriter logWriter)
                     throws SQLException,
                            WTIntrospectionException,
                            DatastoreException,
                            IOException,
                            ClassNotFoundException,
                            WTException
Description copied from interface: Migrator
Run the migration.

Migrators should log all output to the given PrintWriter. This is the log that is created by RunMigrators. It is an autoflush writer.

Migrators should return true if they successfully completed migration and false otherwise. It is the migrator's responsibility to log failure reasons to the log.

Migrators should not concern themselves with committing the work on the connection. The MigratorRunner will commit the connection work after running each Migrator.

Specified by:
runMigration in interface Migrator
Parameters:
connection - an open connection to the Windchill database
pom - a persistent object manager against the Windchill database
logWriter - an autoflush printwriter for logging any and all output
Throws:
SQLException
WTIntrospectionException
DatastoreException
IOException
ClassNotFoundException
WTException

findOidsOfUsersToTurnIntoProxyUsers

private void findOidsOfUsersToTurnIntoProxyUsers(Connection connection)
                                          throws SQLException,
                                                 IOException,
                                                 ClassNotFoundException,
                                                 DatastoreException
Find oids of all the users that have to be turned into ProxyUsers. We don't need to renumber them because oids are unique across all classes.

Throws:
SQLException
IOException
ClassNotFoundException
DatastoreException

breakOidListIntoManageableSets

private void breakOidListIntoManageableSets(Vector user_oid_list)
Ugly method to cope with the fact that Oracle can only handle so many elements in a SQL IN(...) list. It breaks the oid list into chuncks of MAX_IN_CLAUSE_SIZE oids and prepares them as a string formatted like
(oid1,oid2, ...,oidn)
Each of these strings is added to the returned list. The list will be stored as the member field oidLists_


buildObjectMappablesList

private void buildObjectMappablesList()
                               throws SQLException,
                                      WTIntrospectionException
Build a list of ObjectMappable classes with reference properties that may contain a WTPrincipalReference. The class name is the hash key and the value is an EnumeratorVector containing the names of the reference properties.

Throws:
SQLException
WTIntrospectionException

listReferenceProperties

private void listReferenceProperties(ClassInfo class_info,
                                     EnumeratorVector vect,
                                     String property_name)
                              throws SQLException,
                                     WTIntrospectionException
Throws:
SQLException
WTIntrospectionException

updateReferenceToUser

private void updateReferenceToUser(BaseTableInfo bti,
                                   ColumnDescriptor cls_name_col,
                                   ColumnDescriptor id_name_col)
                            throws SQLException
Change the classname for migrated users from WTUser to ProxyUser, for references with the specified table and pair of reference columns.

Throws:
SQLException

updateReferencesThatArePropertiesOnPersistables

private void updateReferencesThatArePropertiesOnPersistables()
                                                      throws SQLException,
                                                             WTIntrospectionException
Throws:
SQLException
WTIntrospectionException

updateReferencesThatAreProperties

private void updateReferencesThatAreProperties(ClassInfo class_info)
                                        throws SQLException,
                                               WTIntrospectionException
Throws:
SQLException
WTIntrospectionException

moveWtUsersToProxyUsers

private void moveWtUsersToProxyUsers(Connection connection)
                              throws WTException,
                                     SQLException
For each pre-R5 LDAP user: 1. Get the user's name and authentication name 2. Get the distinguished name base from the global attribute hash 3. Update new proxy user columns - set name - set authenticationname - set ida2a2 - domain ref - set disabled = 0 - set sourceObjectID (the DN mentioned above) - set service name - set service class - set the sourceurl ("ldap://" + + "/" + ) - set attributes blob to an empty blob - set the proxy's refresh and expiration time to the current time. This will trigger an immediate refresh of the proxy user. 4. Remove the old user 5. Populate the update count and various timestamps

Throws:
WTException
SQLException

setSearchBaseAndHostname

private void setSearchBaseAndHostname()
                               throws WTException
Get the search base and hostname of the LDAP server from the provider URL. Assumes the provider URL is in a format like this: ldap://ldap.windchill.com/o=Windchill Technology,c=US

Throws:
WTException

setFederatedServiceName

private void setFederatedServiceName(Connection connection)
                              throws WTException,
                                     SQLException
Find the name of the federated directory service with our search base.

Throws:
WTException
SQLException