com.metamatrix.common.config.xml
Class XMLConfig_Base_ImportExportUtility

java.lang.Object
  extended by com.metamatrix.common.config.xml.XMLConfig_Base_ImportExportUtility
All Implemented Interfaces:
ConfigurationPropertyNames
Direct Known Subclasses:
XMLConfig_42_ImportExportUtility

public abstract class XMLConfig_Base_ImportExportUtility
extends java.lang.Object
implements ConfigurationPropertyNames

This implementation is used to import/export configuration objects to/from XML files. The structure of the XML file(s) that can be generated/read in is defined in the XMLElementNames class. ************************************************************************************** * * * * * * * W A R N I N G * * * * * * * ************************************************************************************** The importer process cannot have any calls to I18NLogManager or LogManager because the bootstrapping of CurrentConfiguration uses this class and the CurrentConfiguration has to come up before logging is available.


Field Summary
static java.lang.String DEFAULT_USER_CREATED_BY
          These static variables define the constants that will be used to create the header for every document that is produced using this concrete utility.
 
Fields inherited from interface com.metamatrix.common.config.util.ConfigurationPropertyNames
APPLICATION_CREATED_BY, APPLICATION_VERSION_CREATED_BY, CONFIGURATION_VERSION, MEMBERSHIP_ADMIN_PASSWORD, MEMBERSHIP_ADMIN_USERNAME, MEMBERSHIP_DOMAIN_ORDER, MEMBERSHIP_SECURITY_ENABLED, METAMATRIX_SYSTEM_VERSION, MM_CONFIG_3_0_VERSION, MM_CONFIG_4_2_VERSION, MM_LATEST_CONFIG_VERSION, TIME, USER_CREATED_BY
 
Constructor Summary
XMLConfig_Base_ImportExportUtility()
           
 
Method Summary
protected  ComponentType createComponentType(org.jdom.Element root, ConfigurationObjectEditor editor, java.lang.String name)
           
protected  ConnectorBinding createConnectorBinding(ConfigurationID configurationID, org.jdom.Element root, ConfigurationObjectEditor editor, java.lang.String name, boolean isImportConfig)
           
protected  java.util.Collection createConnectorBindings(ConfigurationID configurationID, org.jdom.Element root, ConfigurationObjectEditor editor, boolean importExistingBinding)
           
 void exportComponentType(java.io.OutputStream stream, ComponentType type, java.util.Properties props)
          This method will write to the passed in DirectoryEntry instance a complete representation of the Collection of Configuration objects that are passed into it.
 void exportComponentTypes(java.io.OutputStream stream, ComponentType[] types, java.util.Properties props)
           
 void exportConnector(java.io.OutputStream stream, ComponentType type, java.util.Properties props)
          This method will generally be used to create a file representation of a Connector.
 void exportConnectorBinding(java.io.OutputStream stream, ConnectorBinding defn, ComponentType type, java.util.Properties props)
          This method will generally be used to create a file representation of a Connector Binding.
 void exportConnectorBindings(ConnectorBinding[] bindings, ComponentType[] types, org.jdom.Element root)
          Add connector bindings and component types (connector types) under a common root element.
 void exportConnectorBindings(java.io.OutputStream stream, ConnectorBinding[] bindings, ComponentType[] types, java.util.Properties props)
           
 void exportServiceComponentDefn(java.io.OutputStream stream, ServiceComponentDefn defn, ComponentType type, java.util.Properties props)
          This method will generally be used to create a file representation of a Connector Binding.
protected abstract  XMLHelper getXMLHelper()
           
protected  XMLReaderWriter getXMLReaderWriter()
           
 ConnectorBinding importConnectorBinding(java.io.InputStream stream, ConfigurationObjectEditor editor, java.lang.String newName)
           
 java.lang.Object[] importConnectorBindingAndType(java.io.InputStream stream, ConfigurationObjectEditor editor, java.lang.String[] newName)
           
 java.util.Collection importConnectorBindings(org.jdom.Element root, ConfigurationObjectEditor editor, boolean importExistingBinding)
           
 java.util.Collection importConnectorBindings(java.io.InputStream stream, ConfigurationObjectEditor editor, boolean importExistingBinding)
           
 java.lang.Object[] importServiceComponentDefn(java.io.InputStream stream, Configuration config, ConfigurationObjectEditor editor, java.lang.String[] name)
          This method will be used to import a ServiceComponentDefn Object given a Directory entry instance.
 void resolveConfigurationObjects(java.util.Collection collection)
          This method will resolve that none of the configuration objects in the collection of configuration objects refers to a configuration object that is not in the collection.
protected  void resolveConfigurationObjects(java.util.List[] lists)
           
protected  java.util.List[] segregateConfigurationObjects(java.util.Collection collection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_USER_CREATED_BY

public static final java.lang.String DEFAULT_USER_CREATED_BY
These static variables define the constants that will be used to create the header for every document that is produced using this concrete utility.

See Also:
Constant Field Values
Constructor Detail

XMLConfig_Base_ImportExportUtility

public XMLConfig_Base_ImportExportUtility()
Method Detail

exportComponentType

public void exportComponentType(java.io.OutputStream stream,
                                ComponentType type,
                                java.util.Properties props)
                         throws java.io.IOException

This method will write to the passed in DirectoryEntry instance a complete representation of the Collection of Configuration objects that are passed into it. The failsafe way to build this Collection of objects is to call the getConfigurationAndDependents() method on the AdminAPI of the MetaMatrix Server. This method will retreive the Configuration and all of its dependent objects in their entirety.

In order to export an entire Configuration, the Collection passed into this method should have all of the following object references to be able to resolve the relationships between all objects referenced by a Configuration object.

 1. Configuration object
 2. all ComponentTypes that ComponentObjects reference in the
 Configuration object including the Configuration object's Component Type.
 (this includes ProductTypes)
 3. all ProductTypes that ProductServiceConfig objects reference in the
 Configuration object
 4. all Host objects that are referenced by DeployedComponents in the
 Configuration object
 

All of the above object references must be in the collection passed into this method.

The properties object that is passed into this method may contain the following properties as defined by the ConfigurationPropertyNames class. These properties will define the values for the header of the output of this method.

 ConfigurationPropertyNames.APPLICATION_CREATED_BY
 ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
 ConfigurationPropertyNames.USER_CREATED_BY
 

 

Any of these properties that are not included in the properties object will not be included in the header Element.

Parameters:
stream - the output stream to write the Configuration Object representation to
configurationObjects - a Collection of configuration objects that represents an entire logical Configuration.
props - the properties object that contains the values for the Header
Throws:
java.io.IOException - if there is an error writing to the DirectoryEntry
ConfigObjectsNotResolvableException - if there are references to configuration objects not included in the Collection of configuration objects that cannot be resolved to other configuration objects in the passed in Collection

exportComponentTypes

public void exportComponentTypes(java.io.OutputStream stream,
                                 ComponentType[] types,
                                 java.util.Properties props)
                          throws java.io.IOException
Throws:
java.io.IOException

exportServiceComponentDefn

public void exportServiceComponentDefn(java.io.OutputStream stream,
                                       ServiceComponentDefn defn,
                                       ComponentType type,
                                       java.util.Properties props)
                                throws java.io.IOException,
                                       ConfigObjectsNotResolvableException

This method will generally be used to create a file representation of a Connector Binding. It will write to the DirectoryEntry the representation of the ServiceComponentDefn object that is passed in.

Multiple ServiceComponentDefns can be written to the same DirectoryEntry by passing the same DirectoryEntry instance to this method multiple times.

The properties object that is passed into this method may contain the following properties as defined by the ConfigurationPropertyNames class.

 ConfigurationPropertyNames.APPLICATION_CREATED_BY
 ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
 ConfigurationPropertyNames.USER_CREATED_BY
 

 

Any of these properties that are not included in the properties object will not be included in the header Element.

Parameters:
stream - the output stream to write the Configuration Object representation to
type - the ComponentType of the ServiceComponentDefn to be written to the DirectoryEntry resource.
defn - the ServiceComponentDefn instance to write to the DirectoryEntry.
props - the properties object that contains the values for the Header
Throws:
java.io.IOException - if there is an error writing to the DirectoryEntry
ConfigObjectsNotResolvableException - if the passed in ComponentType is not the type referenced by the passed in ServiceComponentDefn.

createConnectorBindings

protected java.util.Collection createConnectorBindings(ConfigurationID configurationID,
                                                       org.jdom.Element root,
                                                       ConfigurationObjectEditor editor,
                                                       boolean importExistingBinding)
                                                throws java.io.IOException,
                                                       ConfigObjectsNotResolvableException,
                                                       InvalidConfigurationElementException
Throws:
java.io.IOException
ConfigObjectsNotResolvableException
InvalidConfigurationElementException

createConnectorBinding

protected ConnectorBinding createConnectorBinding(ConfigurationID configurationID,
                                                  org.jdom.Element root,
                                                  ConfigurationObjectEditor editor,
                                                  java.lang.String name,
                                                  boolean isImportConfig)
                                           throws java.io.IOException,
                                                  ConfigObjectsNotResolvableException,
                                                  InvalidConfigurationElementException
Throws:
java.io.IOException
ConfigObjectsNotResolvableException
InvalidConfigurationElementException

importServiceComponentDefn

public java.lang.Object[] importServiceComponentDefn(java.io.InputStream stream,
                                                     Configuration config,
                                                     ConfigurationObjectEditor editor,
                                                     java.lang.String[] name)
                                              throws java.io.IOException,
                                                     ConfigObjectsNotResolvableException,
                                                     InvalidConfigurationElementException

This method will be used to import a ServiceComponentDefn Object given a Directory entry instance. If the DirectoryEntry resource does not contain enough data to recombine a complete ServiceComponentDefn, then a ConfigurationObjectsNotResolvableException will be thrown.

This method also allows you to rename the imported ServiceComponentDefn object possibly to avoid name conflicts with other objects already in the server.

If the name parameter submitted is null, the name of the confiuguration object as it exists in the DirectoryEntry will be used.

This method returns an array of objects which represent a ServiceComponentDefn and its corresponding ComponentType. The index of each is defined by the following static variables:

 ConfigurationImportExportUtility.COMPONENT_TYPE_INDEX
 ConfigurationImportExportUtility.SERVICE_COMPONENT_DEFN_INDEX
 

These array indices are also used to override the ComponentType name and ServiceComponentDefn name with the passed in name[] String array. If either or both of these String names are null, the name of the returned configuration object will be as it exists in the DirectoryEntry resource.

The user of this method must either commit the ComponentType of this ServiceComponentDefn or make sure that it already exists in the server configuration database before attempting to commit the ServiceComponentDefn object. This is because every ServiceComponentDefn has a reference to a corresponding ComponentType

Parameters:
editor - the ConfigurationObjectEditor to use to create the Configuration objects in the DirectoryEntry resource.
stream - the input stream to read the configuration object representation from
name - the name for the ServiceComponentDefn and ComponentType object to be created.
Returns:
the configuration objects that are represented as data in the DirectoryEntry resource. see javadoc heading for details.
Throws:
ConfigObjectsNotResolvableException - if the ServiceComponentDefn does not have a reference to a ComponentType object for which there is data to recombine in the DirectoryEntry resource.
java.io.IOException - if there is an error reading from the DirectoryEntry
InvalidConfigurationElementException - if there is a problem with the representation of the configuration element as it exists in the DirectoryEntry resource, usually some type of formatting problem.

createComponentType

protected ComponentType createComponentType(org.jdom.Element root,
                                            ConfigurationObjectEditor editor,
                                            java.lang.String name)
                                     throws InvalidConfigurationElementException
Throws:
InvalidConfigurationElementException

exportConnector

public void exportConnector(java.io.OutputStream stream,
                            ComponentType type,
                            java.util.Properties props)
                     throws java.io.IOException

This method will generally be used to create a file representation of a Connector. It will write to the InputStream the representation of the ComponentType that is passed in.

We have made the assumption here that the Super and Parent Component types of Connector ComponentType objects will already be loaded in the configuration of the server. Thus we do not require that the Super and Parent ComponentType be written to the resource. This will always be the case as of the 2.0 server.

The properties object that is passed into this method may contain the following properties as defined by the ConfigurationPropertyNames class.

 ConfigurationPropertyNames.APPLICATION_CREATED_BY
 ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
 ConfigurationPropertyNames.USER_CREATED_BY
 

 

Any of these properties that are not included in the properties object will not be included in the header Element.

Parameters:
stream - the output stream to write the Configuration Object representation to
type - the ComponentType to be written to the InputStream
props - the properties object that contains the values for the Header
Throws:
java.io.IOException - if there is an error writing to the InputStream

exportConnectorBinding

public void exportConnectorBinding(java.io.OutputStream stream,
                                   ConnectorBinding defn,
                                   ComponentType type,
                                   java.util.Properties props)
                            throws java.io.IOException,
                                   ConfigObjectsNotResolvableException

This method will generally be used to create a file representation of a Connector Binding. It will write to the InputStream the representation of the ServiceComponentDefn object that is passed in.

The properties object that is passed into this method may contain the following properties as defined by the ConfigurationPropertyNames class.

 ConfigurationPropertyNames.APPLICATION_CREATED_BY
 ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
 ConfigurationPropertyNames.USER_CREATED_BY
 

 

Any of these properties that are not included in the properties object will not be included in the header Element.

Parameters:
stream - the output stream to write the Configuration Object representation to
type - the ComponentType of the ServiceComponentDefn to be written to the InputStream resource.
defn - the ServiceComponentDefn instance to write to the InputStream.
props - the properties object that contains the values for the Header
Throws:
java.io.IOException - if there is an error writing to the InputStream
ConfigObjectsNotResolvableException - if the passed in ComponentType is not the type referenced by the passed in ServiceComponentDefn.

exportConnectorBindings

public void exportConnectorBindings(java.io.OutputStream stream,
                                    ConnectorBinding[] bindings,
                                    ComponentType[] types,
                                    java.util.Properties props)
                             throws java.io.IOException,
                                    ConfigObjectsNotResolvableException
Throws:
java.io.IOException
ConfigObjectsNotResolvableException

exportConnectorBindings

public void exportConnectorBindings(ConnectorBinding[] bindings,
                                    ComponentType[] types,
                                    org.jdom.Element root)
Add connector bindings and component types (connector types) under a common root element.

Parameters:
bindings -
types -
helper -
root -
Since:
4.2

importConnectorBinding

public ConnectorBinding importConnectorBinding(java.io.InputStream stream,
                                               ConfigurationObjectEditor editor,
                                               java.lang.String newName)
                                        throws java.io.IOException,
                                               ConfigObjectsNotResolvableException,
                                               InvalidConfigurationElementException
Throws:
java.io.IOException
ConfigObjectsNotResolvableException
InvalidConfigurationElementException

importConnectorBindings

public java.util.Collection importConnectorBindings(org.jdom.Element root,
                                                    ConfigurationObjectEditor editor,
                                                    boolean importExistingBinding)
                                             throws java.io.IOException,
                                                    ConfigObjectsNotResolvableException,
                                                    InvalidConfigurationElementException
Throws:
java.io.IOException
ConfigObjectsNotResolvableException
InvalidConfigurationElementException

importConnectorBindings

public java.util.Collection importConnectorBindings(java.io.InputStream stream,
                                                    ConfigurationObjectEditor editor,
                                                    boolean importExistingBinding)
                                             throws java.io.IOException,
                                                    ConfigObjectsNotResolvableException,
                                                    InvalidConfigurationElementException
Throws:
java.io.IOException
ConfigObjectsNotResolvableException
InvalidConfigurationElementException

importConnectorBindingAndType

public java.lang.Object[] importConnectorBindingAndType(java.io.InputStream stream,
                                                        ConfigurationObjectEditor editor,
                                                        java.lang.String[] newName)
                                                 throws java.io.IOException,
                                                        ConfigObjectsNotResolvableException,
                                                        InvalidConfigurationElementException
Throws:
java.io.IOException
ConfigObjectsNotResolvableException
InvalidConfigurationElementException

resolveConfigurationObjects

public void resolveConfigurationObjects(java.util.Collection collection)
                                 throws ConfigObjectsNotResolvableException

This method will resolve that none of the configuration objects in the collection of configuration objects refers to a configuration object that is not in the collection. Any set of configuration obejcts can be passed to this method.

Any number of actual Configuration object instances may be passed in in the Collection.

Parameters:
collection - the collection of configuration objects to be resolved
Throws:
ConfigObjectsNotResolvableException - if the collection of objects passed in are not self containing.

resolveConfigurationObjects

protected void resolveConfigurationObjects(java.util.List[] lists)
                                    throws ConfigObjectsNotResolvableException
Throws:
ConfigObjectsNotResolvableException

segregateConfigurationObjects

protected java.util.List[] segregateConfigurationObjects(java.util.Collection collection)

getXMLReaderWriter

protected XMLReaderWriter getXMLReaderWriter()

getXMLHelper

protected abstract XMLHelper getXMLHelper()


Copyright © 2009. All Rights Reserved.