wt.inf.container
Class OrganizationReferenceMigrator

java.lang.Object
  extended bywt.inf.container.OrganizationReferenceMigrator
All Implemented Interfaces:
JavaMigrator

public final class OrganizationReferenceMigrator
extends Object
implements JavaMigrator

Assigns all concrete OrganizationOwnedImpl, WTContained objects with null organization ownership to the organization of their parent container. In addition, sets the organization id to 0 for all org-owned SemanticKeys that have a null organization id.

This migrator assumes the site organization has already been created by MigrateDomainAccess.

Note: As of the 7.0 release, there are no classes that implement OrganizationOwnedImpl that do not also implement WTContained, so this class migrates all known OrganizationOwnedImpl subclasses.


Field Summary
private  DirectiveServices ds
           
private static int PAGE_SIZE
           
private  ObjectIdentifier siteOrg
           
 
Constructor Summary
OrganizationReferenceMigrator()
           
 
Method Summary
private  void initSiteOrg()
          Finds the site organization.
private  void migrateDefaultOrg()
          Ensure the default org points to the site organization, if the default org exists.
private  void migrateExchange()
          Ensure the exchange container points to the site organization
private  void migrateOrgOwnership()
          Ensures all OrganizationOwnedImpl objects that are also WTContained have non-null organization references.
private  void migrateOrgOwnership(ClassInfo[] container_infos, ClassInfo[] contained_infos)
          Assigns all the contained objects with null organization references to their parent container's organization, if their parent is in the given list of container types
private  void migrateOrgOwnership(WTContainer container, ClassInfo[] contained_infos)
          Assigns all objects in the given container that have null organization references to the container's organization.
private  void migrateSemanticKeys()
          Assigns the organization namespace id to 0 for all semantic keys that have it set to null
 boolean runMigration(DirectiveServices directive_services)
          Implemented from the JavaMigrator interface
private static void safeClose(ResultSet rs)
          If the Statement is not null, try to close it, catching and smothering any SQLException that results.
private  void safeClose(Statement stmt)
          If the Statement is not null, try to close it, catching and smothering any SQLException that results.
private  void validateOrgContainers()
          Ensures that all org containers have non-null organization refernces
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAGE_SIZE

private static final int PAGE_SIZE
See Also:
Constant Field Values

ds

private DirectiveServices ds

siteOrg

private ObjectIdentifier siteOrg
Constructor Detail

OrganizationReferenceMigrator

public OrganizationReferenceMigrator()
Method Detail

runMigration

public boolean runMigration(DirectiveServices directive_services)
                     throws Throwable
Implemented from the JavaMigrator interface

Specified by:
runMigration in interface JavaMigrator
Parameters:
directive_services - Contains migration resources
Returns:
true
Throws:
Throwable - declared so that migrators can let exceptions contibuting to failure pass out of the method. The migrator runner will handle these by logging them.

migrateExchange

private void migrateExchange()
                      throws Exception
Ensure the exchange container points to the site organization

Throws:
Exception

migrateDefaultOrg

private void migrateDefaultOrg()
                        throws Exception
Ensure the default org points to the site organization, if the default org exists.

Throws:
Exception

validateOrgContainers

private void validateOrgContainers()
                            throws Exception
Ensures that all org containers have non-null organization refernces

Throws:
WTException - If there is an org container with a null organization reference
Exception

migrateOrgOwnership

private void migrateOrgOwnership()
                          throws Exception
Ensures all OrganizationOwnedImpl objects that are also WTContained have non-null organization references.

If an object has a null organization reference, it is assigned to its parent container's organization.

Throws:
Exception

migrateOrgOwnership

private void migrateOrgOwnership(ClassInfo[] container_infos,
                                 ClassInfo[] contained_infos)
                          throws Exception
Assigns all the contained objects with null organization references to their parent container's organization, if their parent is in the given list of container types

Parameters:
container_infos - The types of parent containers to search in
contained_infos - The types of contained children to look for
Throws:
Exception

migrateOrgOwnership

private void migrateOrgOwnership(WTContainer container,
                                 ClassInfo[] contained_infos)
                          throws Exception
Assigns all objects in the given container that have null organization references to the container's organization.

Parameters:
container - The container table to look for parents in
contained_infos - The contained tables to look for children in
Throws:
Exception

migrateSemanticKeys

private void migrateSemanticKeys()
                          throws Exception
Assigns the organization namespace id to 0 for all semantic keys that have it set to null

Throws:
Exception

initSiteOrg

private void initSiteOrg()
                  throws Exception
Finds the site organization.

Throws:
WTException - If the site org can't be found, or if more than one organization matches the site org name.
Exception

safeClose

private void safeClose(Statement stmt)
If the Statement is not null, try to close it, catching and smothering any SQLException that results.

Parameters:
stmt - The Statement to close

safeClose

private static void safeClose(ResultSet rs)
If the Statement is not null, try to close it, catching and smothering any SQLException that results.

Parameters:
rs - The ResultSet to close