Author: vhalbert(a)redhat.com
Date: 2009-04-11 21:10:21 -0400 (Sat, 11 Apr 2009)
New Revision: 757
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/ConfigurationImportExport.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfigurationImportExportUtility.java
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java
Log:
Teiid 323 - refactured the xml configuration classes to simplify importing/exporting and
to clean up the removal of psc, resourcepool and product type related info
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/ConfigurationImportExport.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/ConfigurationImportExport.java 2009-04-12
00:31:57 UTC (rev 756)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/ConfigurationImportExport.java 2009-04-12
01:10:21 UTC (rev 757)
@@ -513,96 +513,7 @@
return null;
}
-
- /**
- * <p>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.</p>
- *
- * <p>This method also allows you to rename the imported ServiceComponentDefn
object
- * possibly to avoid name conflicts with other objects already in the
server.</p>
- *
- * <p>If the name parameter submitted is null, the name of the confiuguration
- * object as it exists in the DirectoryEntry will be used.</p>
- *
- * <p>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:</p>
- *
- * <pre>
- * ConfigurationImportExport.COMPONENT_TYPE_INDEX
- * ConfigurationImportExport.SERVICE_COMPONENT_DEFN_INDEX
- * </pre>
- *
- * <p>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.</p>
- *
- * <p>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</p>
- *
- * @param editor the ConfigurationObjectEditor to use to create the Configuration
- * objects in the DirectoryEntry resource.
- * @param stream the input stream to read the configuration object
- * representation from
- * @param name the name for the ServiceComponentDefn and ComponentType
- * object to be created.
- * @return 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.
- * @throws IOException if there is an error reading from the DirectoryEntry
- * @throws 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.
- */
- public Object[] importServiceComponentDefn(InputStream stream,
- Configuration config, ConfigurationObjectEditor editor,
- String[] name)throws IOException,
- ConfigObjectsNotResolvableException,
- InvalidConfigurationElementException {
- Assertion.isNotNull(stream);
- Assertion.isNotNull(editor);
-
- Document doc = null;
-
-
- try {
- doc = getXMLReaderWriter().readDocument(stream);
- }catch(JDOMException e) {
- e.printStackTrace();
- throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0006));
- }
-
-
- Element root = doc.getRootElement();
-
- ComponentType type = createComponentType(root, editor,
name[ConfigurationImportExport.COMPONENT_TYPES_INDEX]);
-
- Element serviceComponentDefnsElement =
root.getChild(XMLConfig_ElementNames.Configuration.Services.ELEMENT);
-
- if (serviceComponentDefnsElement == null) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0008,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0008,
XMLConfig_ElementNames.Configuration.Services.ELEMENT));
- }
-
-
- Element serviceComponentDefnElement =
serviceComponentDefnsElement.getChild(XMLConfig_ElementNames.Configuration.Services.Service.ELEMENT);
-
- ComponentDefn cd = xmlHelper.createServiceComponentDefn(serviceComponentDefnElement,
config, editor, name[ConfigurationImportExport.SERVICE_COMPONENT_DEFNS_INDEX]);
- Object[] object = {type, cd};
-
-
- return object;
- }
-
-
protected ComponentType createComponentType(Element root, ConfigurationObjectEditor
editor, String name) throws InvalidConfigurationElementException{
Element componentTypesElement =
root.getChild(XMLConfig_ElementNames.ComponentTypes.ELEMENT);
@@ -773,7 +684,7 @@
* @param root
* @since 4.2
*/
- public void exportConnectorBindings(ConnectorBinding[] bindings,
+ private void exportConnectorBindings(ConnectorBinding[] bindings,
ComponentType[] types,
Element root) {
int s = bindings.length;
@@ -1184,9 +1095,13 @@
String typeName = null;
String bindingName = null;
- if (newName != null) {
- typeName = newName[ConfigurationImportExport.COMPONENT_TYPES_INDEX];
- bindingName = newName[ConfigurationImportExport.SERVICE_COMPONENT_DEFNS_INDEX];
+ if (newName != null && newName.length > 0) {
+ if (newName[0] != null) {
+ typeName = newName[0];
+ }
+ if (newName[1] != null) {
+ bindingName = newName[1];
+ }
}
Element root = doc.getRootElement();
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfigurationImportExportUtility.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfigurationImportExportUtility.java 2009-04-12
00:31:57 UTC (rev 756)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfigurationImportExportUtility.java 2009-04-12
01:10:21 UTC (rev 757)
@@ -609,14 +609,14 @@
}
- public void exportConnectorBindings(ConnectorBinding[] bindings,
- ComponentType[] types,
- Element root) {
- ConfigurationImportExport util = new ConfigurationImportExport();
-
- util.exportConnectorBindings(bindings, types, root);
-
- }
+// public void exportConnectorBindings(ConnectorBinding[] bindings,
+// ComponentType[] types,
+// Element root) {
+// ConfigurationImportExport util = new ConfigurationImportExport();
+//
+// util.exportConnectorBindings(bindings, types, root);
+//
+// }
/**
* <p>This method will generally be used to create a file representation of
Modified:
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java
===================================================================
---
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java 2009-04-12
00:31:57 UTC (rev 756)
+++
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java 2009-04-12
01:10:21 UTC (rev 757)
@@ -347,7 +347,7 @@
InputStream in = new FileInputStream(filename);
- Object[] bandt = utility.importConnectorBindingAndType(in, editor, null);
+ Object[] bandt = utility.importConnectorBindingAndType(in, editor, new
String[]{});
if (bandt == null || bandt.length != 2) {
fail("didnt import both, binding and type");