wt.inf.container
Class MigrateContainerHelper

java.lang.Object
  extended bywt.inf.container.MigrateContainerHelper

public final class MigrateContainerHelper
extends Object

Provides utility methods to access cached instances of the exchange and default org container's domains and cabinets, as well as some general utility methods.

WARNING: A call to initialize must precede any other uses of the APIs in this class, otherwise a runtime exception will occur.


Nested Class Summary
private static interface MigrateContainerHelper.Logger
          Assigned in initialize()
 
Field Summary
private static Connection connection
          Connection used to create statements.
private static OrgContainer defaultOrg
           
private static Cabinet defaultOrgDefaultCabinet
           
private static AdministrativeDomain defaultOrgDefaultDomain
           
private static AdministrativeDomain defaultOrgPrivateDomain
           
private static Cabinet defaultOrgSystemCabinet
           
private static AdministrativeDomain defaultOrgSystemDomain
           
private static ExchangeContainer exchange
           
private static Cabinet exchangeDefaultCabinet
           
private static AdministrativeDomain exchangeDefaultDomain
           
private static Cabinet exchangeSystemCabinet
           
private static AdministrativeDomain exchangeSystemDomain
           
private static MigrateContainerHelper.Logger logger
           
private static PersistentObjectManager pom
          Used for queries.
 
Constructor Summary
MigrateContainerHelper()
           
 
Method Summary
private static void checkState()
          Validates that the helper is initialized
static void cleanup()
          Nulls the cached resources on the helper
static ObjectIdentifier createTemplate(String name, String description, Class container_class, ObjectIdentifier container_id, ObjectIdentifier domain_id)
          Creates a container template and template master with the given properties.
static ObjectIdentifier getAdministrator()
          Get the oid of the WTUser with name AdministrativeDomainHelper.ADMINISTRATOR_NAME.
static Cabinet getCabinet(String cabinet_name)
          Get the cabinet with the given name.
static WTContainer getDefaultOrg()
          Get a cached instance of the default org container
static Cabinet getDefaultOrgCabinet()
          Get a cached instance of the default org container's default cabinet
static AdministrativeDomain getDefaultOrgDomain()
          Get a cached instance of the default org container's default domain
static AdminDomainRef getDefaultOrgDomainRef()
          Get a cached reference to the default org container's default domain.
static WTContainerRef getDefaultOrgRef()
          Get a reference to a cached instance of the default org container.
static AdministrativeDomain getDomain(String domain_name)
          Get the domain with the given name.
static WTContainer getExchange()
          Get a cached instance of the exchange container
static WTContainerRef getExchangeRef()
          Get a reference to a cached instance of the exchange container.
static long getId(Object obj)
          Get the long version of the oid for the given object.
static Persistable getObject(ObjectReference ref)
          Gets the object that the given reference refers to
static ObjectIdentifier getOid(Object obj)
          Get the ObjectIdentifier for the given object.
static AdministrativeDomain getPrivateOrgDomain()
          Get a cached instance of the default org container's private domain
static AdminDomainRef getPrivateOrgDomainRef()
          Get a cached reference to the default org container's private domain.
static Cabinet getSystemOrgCabinet()
          Get a cached instance of the default org container's system cabinet
static AdministrativeDomain getSystemOrgDomain()
          Get a cached instance of the default org container's system domain
static ObjectIdentifier getTemplate(String name, Class container_class, ObjectIdentifier container_id)
          Finds the latest iteration of the container template with the given properties.
static Cabinet getXDefaultCabinet()
          Get a cached instance of the exchange container's default cabinet
static AdministrativeDomain getXDefaultDomain()
          Get a cached instance of the exchange container's default domain
static AdminDomainRef getXDefaultDomainRef()
          Get a cached reference to the exchange container's default domain.
static Cabinet getXSysCabinet()
          Get a cached instance of the exchange container's system cabinet
static AdministrativeDomain getXSysDomain()
          Get a cached instance of the exchange container's system domain
static AdminDomainRef getXSysDomainRef()
          Get a cached reference to the exchange container's system domain.
static void initialize(Connection a_Connection, PersistentObjectManager a_Pom, PrintWriter a_Log)
          Initializes the helper's resources.
static void initialize(DirectiveServices ds)
          Initializes the helper's resources.
static QueryResult query(QuerySpec qs)
          Performs the query
private static void safeClose(ResultSet rs)
          If the Statement is not null, try to close it, catching and smothering any SQLException that results.
private static void safeClose(Statement stmt)
          If the Statement is not null, try to close it, catching and smothering any SQLException that results.
static Persistable save(Persistable obj)
          Inserts the object if it isn't persisted, updates the object if it is.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

private static Connection connection
Connection used to create statements. Assigned in initialize()


pom

private static PersistentObjectManager pom
Used for queries. Assigned in initialize()


logger

private static MigrateContainerHelper.Logger logger

exchange

private static ExchangeContainer exchange

exchangeSystemCabinet

private static Cabinet exchangeSystemCabinet

exchangeDefaultCabinet

private static Cabinet exchangeDefaultCabinet

exchangeSystemDomain

private static AdministrativeDomain exchangeSystemDomain

exchangeDefaultDomain

private static AdministrativeDomain exchangeDefaultDomain

defaultOrg

private static OrgContainer defaultOrg

defaultOrgSystemCabinet

private static Cabinet defaultOrgSystemCabinet

defaultOrgDefaultCabinet

private static Cabinet defaultOrgDefaultCabinet

defaultOrgSystemDomain

private static AdministrativeDomain defaultOrgSystemDomain

defaultOrgDefaultDomain

private static AdministrativeDomain defaultOrgDefaultDomain

defaultOrgPrivateDomain

private static AdministrativeDomain defaultOrgPrivateDomain
Constructor Detail

MigrateContainerHelper

public MigrateContainerHelper()
Method Detail

initialize

public static void initialize(Connection a_Connection,
                              PersistentObjectManager a_Pom,
                              PrintWriter a_Log)
Initializes the helper's resources. Note that these resources are stored until cleanup() is called or for the duration of the virtual machine

Parameters:
a_Connection - The database connection
a_Pom - The POM
a_Log - The log

initialize

public static void initialize(DirectiveServices ds)
                       throws Exception
Initializes the helper's resources. Note that these resources are stored until cleanup() is called or for the duration of the virtual machine

Parameters:
ds - Migration resources
Throws:
Exception

cleanup

public static void cleanup()
Nulls the cached resources on the helper


checkState

private static void checkState()
Validates that the helper is initialized

Throws:
WTRuntimeException - If the resources assigned in initialize are null

query

public static QueryResult query(QuerySpec qs)
                         throws WTException
Performs the query

Parameters:
qs -
Returns:
The result of the query
Throws:
WTException

save

public static Persistable save(Persistable obj)
                        throws WTException
Inserts the object if it isn't persisted, updates the object if it is.

Parameters:
obj - The object to update
Returns:
The updated object. Note that this is redundant since the object is modified in place.
Throws:
WTException

getObject

public static Persistable getObject(ObjectReference ref)
                             throws WTException
Gets the object that the given reference refers to

Parameters:
ref - The reference to find an object for
Returns:
The inflated object
Throws:
WTException

getOid

public static ObjectIdentifier getOid(Object obj)
Get the ObjectIdentifier for the given object.

Returns:
The oid for the object

getId

public static long getId(Object obj)
Get the long version of the oid for the given object.

Parameters:
obj - The object to get an oid for
Returns:
The oid
Throws:
WTException - If getOid(obj) returns null

getDomain

public static AdministrativeDomain getDomain(String domain_name)
                                      throws WTException
Get the domain with the given name.

Parameters:
domain_name - The name of the domain to look for
Returns:
The domain with the given name, or null if no matches were found
Throws:
WTException - If more than one domain is found with the given name

getCabinet

public static Cabinet getCabinet(String cabinet_name)
                          throws WTException
Get the cabinet with the given name.

Parameters:
cabinet_name - The name of the domain to look for
Returns:
The cabinet with the given name, or null if no matches were found
Throws:
WTException - If more than one cabinet is found with the given name

getExchange

public static WTContainer getExchange()
                               throws WTException
Get a cached instance of the exchange container

Returns:
The exchange container
Throws:
WTException

getExchangeRef

public static WTContainerRef getExchangeRef()
                                     throws WTException
Get a reference to a cached instance of the exchange container. The reference is inflated.

Returns:
The inflated reference
Throws:
WTException

getXSysCabinet

public static Cabinet getXSysCabinet()
                              throws WTException
Get a cached instance of the exchange container's system cabinet

Returns:
The exchange system cabinet
Throws:
WTException

getXDefaultCabinet

public static Cabinet getXDefaultCabinet()
                                  throws WTException
Get a cached instance of the exchange container's default cabinet

Returns:
The exchange default cabinet
Throws:
WTException

getXSysDomainRef

public static AdminDomainRef getXSysDomainRef()
                                       throws WTException
Get a cached reference to the exchange container's system domain. The reference is inflated.

Returns:
The inflated reference
Throws:
WTException

getXDefaultDomainRef

public static AdminDomainRef getXDefaultDomainRef()
                                           throws WTException
Get a cached reference to the exchange container's default domain. The reference is inflated

Returns:
The inflated reference
Throws:
WTException

getXSysDomain

public static AdministrativeDomain getXSysDomain()
                                          throws WTException
Get a cached instance of the exchange container's system domain

Returns:
The exchange system domain
Throws:
WTException

getXDefaultDomain

public static AdministrativeDomain getXDefaultDomain()
                                              throws WTException
Get a cached instance of the exchange container's default domain

Returns:
The exchange default domain
Throws:
WTException

getDefaultOrg

public static WTContainer getDefaultOrg()
                                 throws WTException
Get a cached instance of the default org container

Returns:
The default org container
Throws:
WTException

getDefaultOrgRef

public static WTContainerRef getDefaultOrgRef()
                                       throws WTException
Get a reference to a cached instance of the default org container. The reference is inflated.

Returns:
The inflated reference
Throws:
WTException

getDefaultOrgCabinet

public static Cabinet getDefaultOrgCabinet()
                                    throws WTException
Get a cached instance of the default org container's default cabinet

Returns:
The default org's default cabinet
Throws:
WTException

getSystemOrgCabinet

public static Cabinet getSystemOrgCabinet()
                                   throws WTException
Get a cached instance of the default org container's system cabinet

Returns:
The default org's system cabinet
Throws:
WTException

getSystemOrgDomain

public static AdministrativeDomain getSystemOrgDomain()
                                               throws WTException
Get a cached instance of the default org container's system domain

Returns:
The default org's system domain
Throws:
WTException

getDefaultOrgDomainRef

public static AdminDomainRef getDefaultOrgDomainRef()
                                             throws WTException
Get a cached reference to the default org container's default domain. The reference is inflated.

Returns:
The inflated reference
Throws:
WTException

getDefaultOrgDomain

public static AdministrativeDomain getDefaultOrgDomain()
                                                throws WTException
Get a cached instance of the default org container's default domain

Returns:
The default org's default domain
Throws:
WTException

getPrivateOrgDomain

public static AdministrativeDomain getPrivateOrgDomain()
                                                throws WTException
Get a cached instance of the default org container's private domain

Returns:
The default org's private domain
Throws:
WTException

getPrivateOrgDomainRef

public static AdminDomainRef getPrivateOrgDomainRef()
                                             throws WTException
Get a cached reference to the default org container's private domain. The reference is inflated.

Returns:
The inflated reference
Throws:
WTException

getTemplate

public static ObjectIdentifier getTemplate(String name,
                                           Class container_class,
                                           ObjectIdentifier container_id)
                                    throws Exception
Finds the latest iteration of the container template with the given properties. The search is done for templates with the "ALL" locale (the default).

Parameters:
name - The name of the template to look for
container_class - The container class the template is for
container_id - The id of the template's container reference
Returns:
The matching DefaultWTContainerTemplate's oid, or null if there isn't a match
Throws:
Exception

createTemplate

public static ObjectIdentifier createTemplate(String name,
                                              String description,
                                              Class container_class,
                                              ObjectIdentifier container_id,
                                              ObjectIdentifier domain_id)
                                       throws Exception
Creates a container template and template master with the given properties. The template is created in the "ALL" locale (the default)

Parameters:
name - The name of the new template
description - The description for the new template
container_class - The container class for the new template
container_id - The id for the template's container reference
domain_id - The id for the template's administrative domain reference
Returns:
The oid of the new DefaultWTContainerTemplate.
Throws:
Exception

getAdministrator

public static ObjectIdentifier getAdministrator()
                                         throws Exception
Get the oid of the WTUser with name AdministrativeDomainHelper.ADMINISTRATOR_NAME.

Returns:
The oid of the site administrator
Throws:
WTExeption - If the administrator can't be found
Exception

safeClose

private static 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