Author: vhalbert(a)redhat.com
Date: 2009-04-10 22:42:44 -0400 (Fri, 10 Apr 2009)
New Revision: 752
Added:
branches/remove_psc/common-internal/XMLElementNames.java
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/XMLConfig_ElementNames.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
Removed:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ElementNames.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ImportExportUtility.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_Visitor.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_Base_ImportExportUtility.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLElementNames.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelper.java
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/api/SharedResource.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfiguration.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicUtil.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/util/ConfigurationImportExportUtility.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/util/ConfigurationPropertyNames.java
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/XMLHelperUtil.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/vdb/api/DEFReaderWriter.java
branches/remove_psc/common-internal/src/test/resources/config-original.xml
branches/remove_psc/common-internal/src/test/resources/config.xml
branches/remove_psc/common-internal/src/test/resources/example.def
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
Added: branches/remove_psc/common-internal/XMLElementNames.java
===================================================================
--- branches/remove_psc/common-internal/XMLElementNames.java (rev
0)
+++ branches/remove_psc/common-internal/XMLElementNames.java 2009-04-11 02:42:44 UTC (rev
752)
@@ -0,0 +1,746 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.config.xml;
+
+import com.metamatrix.common.config.util.ConfigurationPropertyNames;
+
+/**
+* This class structure mimics the structure of a Configuration XML
+* document and defines all of the element and attribute names for that
+* document type.
+*/
+public interface XMLElementNames {
+
+ /**
+ * This is used as the delimiter of all XML element names.
+ */
+ public static final String DELIMITER = "."; //$NON-NLS-1$
+
+ /**
+ * This should be the root Element name for all Configuration XML Documents.
+ */
+ // public static final String ELEMENT = "ConfigurationDocument";
//$NON-NLS-1$
+
+ /**
+ * This is the class that represents the Configurations Element which contains
+ * all of the XML elements that represent Configuration objects.
+ */
+
+ /**
+ * This is the class that represents the Configuration Element which contains
+ * all of the XML elements that represent a Configuration object.
+ */
+ public static class Configuration {
+
+ /**
+ * This is the name of the Configurations Element.
+ */
+ public static final String ELEMENT = "Configuration"; //$NON-NLS-1$
+ /**
+ * This is the class that represents the ServiceComponentDefns Element which
contains
+ * all of the XML elements that represent a ServiceComponentDefns object.
+ */
+ public static class ServiceComponentDefns {
+
+ /**
+ * This is the name of the ServiceComponentDefns Element.
+ */
+ public static final String ELEMENT = Configuration.ELEMENT + DELIMITER +
"ServiceComponentDefns"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the ServiceComponentDefn Element
which contains
+ * all of the XML elements that represent a ServiceComponentDefn object.
+ */
+ public static class ServiceComponentDefn {
+
+ /**
+ * This is the name of the ServiceComponentDefn Element.
+ */
+ public static final String ELEMENT =
"ServiceComponentDefn"; //$NON-NLS-1$
+
+ public static class Attributes extends ComponentObject.Attributes{
+ public static final String ROUTING_UUID =
"routingUUID"; //$NON-NLS-1$
+ }
+ }
+ }
+
+
+ /**
+ * This is the class that represents the VMComponentDefns Element which
contains
+ * all of the XML elements that represent a VMComponentDefns object.
+ */
+ public static class VMComponentDefns {
+
+ /**
+ * This is the name of the VMComponentDefns Element.
+ */
+ public static final String ELEMENT = Configuration.ELEMENT + DELIMITER
+"VMComponentDefns"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the VMComponentDefn Element which
contains
+ * all of the XML elements that represent a VMComponentDefn object.
+ */
+ public static class VMComponentDefn {
+
+ /**
+ * This is the name of the VMComponentDefn Element.
+ */
+ public static final String ELEMENT = "VMComponentDefn";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ComponentObject.Attributes{
+ }
+ }
+ }
+
+
+
+ /**
+ * This is the class that represents the DeployedComponents Element which
contains
+ * all of the XML elements that represent a DeployedComponents object.
+ */
+ public static class DeployedComponents {
+
+ /**
+ * This is the name of the DeployedComponents Element.
+ */
+ public static final String ELEMENT = Configuration.ELEMENT + DELIMITER +
"DeployedComponents"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the DeployedComponent Element which
contains
+ * all of the XML elements that represent a DeployedComponent object.
+ */
+ public static class DeployedComponent {
+
+ /**
+ * This is the name of the DeployedComponent Element.
+ */
+ public static final String ELEMENT = "DeployedComponent";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ComponentObject.Attributes{
+ public static final String HOST_ID = "HostID";
//$NON-NLS-1$
+// public static final String PRODUCT_SERVICE_CONFIG_ID =
"ProductServiceConfigID"; //$NON-NLS-1$
+ public static final String SERVICE_COMPONENT_DEFN_ID =
"ServiceComponentDefnID"; //$NON-NLS-1$
+ public static final String VM_COMPONENT_DEFN_ID =
"VMComponentDefnID"; //$NON-NLS-1$
+ }
+ }
+ }
+
+
+ /**
+ * This is the class that represents the ComponentDefnID Element which
contains
+ * all of the XML elements that represent a ComponentDefnID object.
+ */
+ public static final class ComponentDefnID{
+
+ /**
+ * This is the name of the ComponentDefnID Element.
+ */
+ public static final String ELEMENT = "ComponentDefnID";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+ }
+
+ /**
+ * This is the class that represents the DeployedComponentID Element which
contains
+ * all of the XML elements that represent a DeployedComponentID object.
+ */
+ public static final class DeployedComponentID{
+
+ /**
+ * This is the name of the DeployedComponentID Element.
+ */
+ public static final String ELEMENT = "DeployedComponentID";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+ }
+
+ /**
+ * This is the class that represents the ProductServiceConfigID Element which
contains
+ * all of the XML elements that represent a ProductServiceConfigID object.
+ */
+// public static final class ProductServiceConfigID{
+//
+// /**
+// * This is the name of the ProductServiceConfigID Element.
+// */
+// public static final String ELEMENT =
"ProductServiceConfigID"; //$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
+
+ /**
+ * This is the class that represents the VMComponentDefnID Element which
contains
+ * all of the XML elements that represent a VMComponentDefnID object.
+ */
+ public static final class VMComponentDefnID{
+
+ /**
+ * This is the name of the VMComponentDefnID Element.
+ */
+ public static final String ELEMENT = "VMComponentDefnID";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+ }
+
+ /**
+ * This is the class that represents the VMComponentDefnID Element which
contains
+ * all of the XML elements that represent a VMComponentDefnID object.
+ */
+ public static final class ServiceComponentDefnID{
+
+ /**
+ * This is the name of the ServiceComponentDefnID Element.
+ */
+ public static final String ELEMENT = "ServiceComponentDefnID";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+ }
+
+ /**
+ * This is the class that represents the ConfigurationInfo Element which
contains
+ * all of the XML elements that represent a ConfigurationInfo object.
+ */
+ public static class ConfigurationInfo {
+
+ /**
+ * This is the name of the ServiceComponentDefnID Element.
+ */
+ public static final String ELEMENT = "ConfigurationInfo";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String LAST_CHANGED_DATE =
"LastChangedDate"; //$NON-NLS-1$
+ public static final String CREATION_DATE = "CreationDate";
//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This is the class that represents the LogConfiguration Element which
contains
+ * all of the XML elements that represent a LogConfiguration object.
+ */
+ public static class LogConfiguration {
+
+ /**
+ * This is the name of the LogConfiguration Element.
+ */
+ public static final String ELEMENT = "LogConfiguration";
//$NON-NLS-1$
+
+ }
+
+ }
+ // }
+
+ /**
+ * This is the class that represents the ComponentObject Element which contains
+ * all of the XML elements that represent a ComponentObject object.
+ */
+ public static class ComponentObject {
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ public static final String COMPONENT_TYPE = "ComponentType";
//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This is the class that represents the Properties Element which contains
+ * all of the XML elements that represent a Properties object.
+ */
+ public static class Properties {
+
+ /**
+ * This is the name of the Properties Element.
+ */
+ public static final String ELEMENT = "Properties"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the Property Element which contains
+ * all of the XML elements that represent a Property object.
+ */
+ public static class Property {
+
+ /**
+ * This is the name of the Property Element.
+ */
+ public static final String ELEMENT = "Property"; //$NON-NLS-1$
+
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ }
+
+ }
+ }
+
+ /**
+ * This is the class that represents the ChangeHistory Properties Element which
contains
+ * all of the XML elements that represent the change information for the object.
+ */
+ public static class ChangeHistory {
+
+ /**
+ * This is the name of the ChangeHistory Element.
+ */
+ public static final String ELEMENT = "ChangeHistory"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the Property Element which contains
+ * all of the XML elements that represent a Property object.
+ */
+ public static class Property {
+
+ /**
+ * This is the name of the Property Element.
+ */
+ public static final String ELEMENT = "Property"; //$NON-NLS-1$
+
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ }
+
+ public static class NAMES {
+ public static final String LAST_CHANGED_DATE = "LastChangedDate";
//$NON-NLS-1$
+ public static final String LAST_CHANGED_BY = "LastChangedBy";
//$NON-NLS-1$
+ public static final String CREATION_DATE = "CreationDate";
//$NON-NLS-1$
+ public static final String CREATED_BY = "CreatedBy";
//$NON-NLS-1$
+
+ }
+ }
+ }
+
+
+ /**
+ * This is the class that represents the ID Element which contains
+ * all of the XML elements that represent a ID object.
+ */
+ public static class ID {
+ // these are the shared attributes of all ID Elements
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ }
+ }
+
+
+ /**
+ * This is the class that represents the HostID Element which contains
+ * all of the XML elements that represent a HostID object.
+ */
+ public static final class HostID {
+
+ /**
+ * This is the name of the HostID Element.
+ */
+ public static final String ELEMENT = "HostID"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+ }
+
+
+
+
+
+ /**
+ * This is the class that represents the Hosts Element which contains
+ * all of the XML elements that represent a Hosts object.
+ */
+// public static class Hosts {
+//
+// /**
+// * This is the name of the Hosts Element.
+// */
+// public static final String ELEMENT = "Hosts"; //$NON-NLS-1$
+//
+// /**
+// * This is the class that represents the Host Element which contains
+// * all of the XML elements that represent a Host object.
+// */
+// public static class Host {
+//
+// /**
+// * This is the name of the Host Element.
+// */
+// public static final String ELEMENT = "Host"; //$NON-NLS-1$
+//
+// }
+// }
+
+ /**
+ * This is the class that represents the Resources Element which contains
+ * all of the XML elements that represent a Resource object.
+ */
+ public static class Resources {
+
+ /**
+ * This is the name of the Hosts Element.
+ */
+ public static final String ELEMENT = "Resources"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the Resource Element which contains
+ * all of the XML elements that represent a Resource object.
+ */
+ public static class Resource {
+
+ /**
+ * This is the name of the Resource Element.
+ */
+ public static final String ELEMENT = "Resource"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ComponentObject.Attributes{
+ }
+
+
+ }
+ }
+
+ /**
+ * This is the class that represents the ServiceComponentDefns Element which
contains
+ * all of the XML elements that represent a ServiceComponentDefns object.
+ */
+ public static class ConnectorComponents {
+
+ /**
+ * This is the name of the ServiceComponentDefns Element.
+ */
+ public static final String ELEMENT = "ConnectorBindings";
//$NON-NLS-1$
+
+ /**
+ * This is the class that represents the ConnectorBinding Element which
contains
+ * all of the XML elements that represent a ConnectorBinding object.
+ */
+ public static class ConnectorComponent {
+
+ /**
+ * This is the name of the ConnectorBinding Element.
+ */
+ public static final String ELEMENT = "Connector";
//$NON-NLS-1$
+
+ public static class Attributes extends ComponentObject.Attributes{
+ public static final String QUEUED_SERVICE =
"QueuedService"; //$NON-NLS-1$
+// public static final String IS_ENABLED = "IsEnabled";
+ public static final String ROUTING_UUID =
"routingUUID"; //$NON-NLS-1$
+ }
+ }
+ }
+
+
+
+ /**
+ * This is the class that represents the ComponentTypeID Element which contains
+ * all of the XML elements that represent a ComponentTypeID object.
+ */
+ public static class ComponentTypeID {
+
+ /**
+ * This is the name of the ComponentTypeID Element.
+ */
+ public static final String ELEMENT = "ComponentTypeID"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+
+ }
+
+ /**
+ * This is the class that represents the ComponentTypes Element which contains
+ * all of the XML elements that represent a ComponentTypes object.
+ */
+ public static class ComponentTypes {
+
+ /**
+ * This is the name of the ComponentTypes Element.
+ */
+ public static final String ELEMENT = "ComponentTypes"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the ComponentType Element which contains
+ * all of the XML elements that represent a ComponentType object.
+ */
+ public static class ComponentType {
+
+ /**
+ * This is the name of the ComponentType Element.
+ */
+ public static final String ELEMENT = "ComponentType";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ public static final String PARENT_COMPONENT_TYPE =
"ParentComponentType"; //$NON-NLS-1$
+ public static final String SUPER_COMPONENT_TYPE =
"SuperComponentType"; //$NON-NLS-1$
+ public static final String COMPONENT_TYPE_CODE =
"ComponentTypeCode"; //$NON-NLS-1$
+ public static final String DEPLOYABLE = "Deployable";
//$NON-NLS-1$
+ public static final String DEPRECATED = "Deprecated";
//$NON-NLS-1$
+ public static final String MONITORABLE = "Monitorable";
//$NON-NLS-1$
+ }
+
+
+ /**
+ * This is the class that represents the ComponentTypeDefn Element which
contains
+ * all of the XML elements that represent a ComponentTypeDefn object.
+ */
+ public static class ComponentTypeDefn {
+
+ /**
+ * This is the name of the ComponentTypeDefn Element.
+ */
+ public static final String ELEMENT = "ComponentTypeDefn";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String DEPRECATED = "Deprecated";
//$NON-NLS-1$
+ }
+
+ /**
+ * This is the class that represents the PropertyDefinition Element which
contains
+ * all of the XML elements that represent a PropertyDefinition object.
+ */
+ public static class PropertyDefinition {
+
+ /**
+ * This is the name of the PropertyDefinition Element.
+ */
+ public static final String ELEMENT = "PropertyDefinition";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name";
//$NON-NLS-1$
+ public static final String DISPLAY_NAME =
"DisplayName"; //$NON-NLS-1$
+ public static final String SHORT_DESCRIPTION
="ShortDescription"; //$NON-NLS-1$
+ public static final String DEFAULT_VALUE =
"DefaultValue"; //$NON-NLS-1$
+ public static final String MULTIPLICITY =
"Multiplicity"; //$NON-NLS-1$
+ public static final String PROPERTY_TYPE =
"PropertyType"; //$NON-NLS-1$
+ public static final String VALUE_DELIMITER =
"ValueDelimiter"; //$NON-NLS-1$
+ public static final String IS_CONSTRAINED_TO_ALLOWED_VALUES =
"IsConstrainedToAllowedValues"; //$NON-NLS-1$
+ public static final String IS_EXPERT = "IsExpert";
//$NON-NLS-1$
+ public static final String IS_HIDDEN = "IsHidden";
//$NON-NLS-1$
+ public static final String IS_MASKED = "IsMasked";
//$NON-NLS-1$
+ public static final String IS_MODIFIABLE =
"IsModifiable"; //$NON-NLS-1$
+ public static final String IS_PREFERRED =
"IsPreferred"; //$NON-NLS-1$
+ }
+
+ /**
+ * This is the class that represents the AllowedValue Element which
contains
+ * all of the XML elements that represent a AllowedValue object.
+ */
+ public static class AllowedValue {
+
+ /**
+ * This is the name of the AllowedValue Element.
+ */
+ public static final String ELEMENT = "AllowedValue";
//$NON-NLS-1$
+ }
+
+ }
+
+ }
+ }
+ }
+
+ /**
+ * This is the class that represents the ProductTypes Element which contains
+ * all of the XML elements that represent a ProductType object.
+ */
+// public static class ProductTypes {
+// public static final String ELEMENT = "ProductTypes"; //$NON-NLS-1$
+//
+// /**
+// * This is the class that represents the ProductType Element which contains
+// * all of the XML elements that represent a ProductType object.
+// * Note that it extends teh ComponentType element definition.
+// */
+// public static class ProductType extends ComponentTypes.ComponentType{
+// public static final String ELEMENT = "ProductType";
//$NON-NLS-1$
+// }
+// }
+
+
+
+
+ /**
+ * This is the class that represents the Header Element which contains
+ * all of the XML elements that represent a Header object.
+ */
+ public static class Header {
+
+ /**
+ * This is the name of the Header Element.
+ */
+ public static final String ELEMENT = "Header"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the UserName Element which contains
+ * all of the XML elements that represent a UserName object.
+ */
+ public static class UserCreatedBy {
+
+ /**
+ * This is the name of the UserName Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.USER_CREATED_BY;
+ }
+
+ /**
+ * This is the class that represents the ApplicationCreatedDate Element which
contains
+ * all of the XML elements that represent a ApplicationCreatedDate object.
+ */
+ public static class ApplicationCreatedBy {
+
+ /**
+ * This is the name of the ApplicationCreatedDate Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.APPLICATION_CREATED_BY;
+ }
+
+ /**
+ * This is the class that represents the ApplicationVersionCreatedBy Element which
contains
+ * all of the XML elements that represent a ApplicationVersionCreatedBy object.
+ */
+ public static class ApplicationVersionCreatedBy {
+
+ /**
+ * This is the name of the ApplicationVersionCreatedBy Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY;
+ }
+
+ /**
+ * This is the class that represents the Time Element which contains
+ * all of the XML elements that represent a Time object.
+ */
+ public static class Time {
+
+ /**
+ * This is the name of the Time Element.
+ */
+ public static final String ELEMENT = ConfigurationPropertyNames.TIME;
+ }
+
+ /**
+ * This is the class that represents the DocumentTypeVersion Element which
contains
+ * all of the XML elements that represent a DocumentTypeVersion object.
+ */
+ public static class ConfigurationVersion {
+
+ /**
+ * This is the name of the DocumentTypeVersion Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.CONFIGURATION_VERSION;
+ }
+
+ /**
+ * This is the class that represents the MetaMatrixServerVersion Element which
contains
+ * all of the XML elements that represent a ProductServiceConfigs object.
+ */
+ public static class MetaMatrixSystemVersion {
+
+ /**
+ * This is the name of the MetaMatrixServerVersion Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.METAMATRIX_SYSTEM_VERSION;
+ }
+ }
+
+
+}
Property changes on: branches/remove_psc/common-internal/XMLElementNames.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/api/SharedResource.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/api/SharedResource.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/api/SharedResource.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -41,27 +41,27 @@
* The JDBC_RESOURCE_TYPE resource is the generic resource used for
* majority of the internal resources
*/
- public static final String JDBC_COMPONENT_TYPE_NAME = "JDBC Resource Type";
//$NON-NLS-1$
+// public static final String JDBC_COMPONENT_TYPE_NAME = "JDBC Resource
Type"; //$NON-NLS-1$
- public static final ComponentTypeID JDBC_COMPONENT_TYPE_ID = new
ComponentTypeID(JDBC_COMPONENT_TYPE_NAME);
+// public static final ComponentTypeID JDBC_COMPONENT_TYPE_ID = new
ComponentTypeID(JDBC_COMPONENT_TYPE_NAME);
/** The JMS_RESOURCE_TYPE resource is used to define jms resources. */
- public static final String JMS_COMPONENT_TYPE_NAME = "JMS Resource Type";
//$NON-NLS-1$
+ // public static final String JMS_COMPONENT_TYPE_NAME = "JMS Resource Type";
//$NON-NLS-1$
- public static final ComponentTypeID JMS_COMPONENT_TYPE_ID = new
ComponentTypeID(JMS_COMPONENT_TYPE_NAME);
+// public static final ComponentTypeID JMS_COMPONENT_TYPE_ID = new
ComponentTypeID(JMS_COMPONENT_TYPE_NAME);
/** The MISC_RESOURCE_TYPE resource is used to define resources that need any specific
type association. */
public static final String MISC_COMPONENT_TYPE_NAME = "Miscellaneous Resource
Type"; //$NON-NLS-1$
- public static final ComponentTypeID MISC_COMPONENT_TYPE_ID = new
ComponentTypeID(MISC_COMPONENT_TYPE_NAME);
+// public static final ComponentTypeID MISC_COMPONENT_TYPE_ID = new
ComponentTypeID(MISC_COMPONENT_TYPE_NAME);
/** The SEARCHBASE_RESOURCE_TYPE resource is used to define external searchbase
resources. */
- public static final String SEARCHBASE_COMPONENT_TYPE_NAME = "Searchbase Resource
Type"; //$NON-NLS-1$
+ // public static final String SEARCHBASE_COMPONENT_TYPE_NAME = "Searchbase
Resource Type"; //$NON-NLS-1$
- public static final ComponentTypeID SEARCHBASE_COMPONENT_TYPE_ID = new
ComponentTypeID(SEARCHBASE_COMPONENT_TYPE_NAME);
+// public static final ComponentTypeID SEARCHBASE_COMPONENT_TYPE_ID = new
ComponentTypeID(SEARCHBASE_COMPONENT_TYPE_NAME);
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfiguration.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfiguration.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfiguration.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -757,17 +757,15 @@
Collection comps = new ArrayList(dcs.size());
DeployedComponent dc;
-// ComponentDefn comp;
for (Iterator it = dcs.iterator(); it.hasNext(); ) {
dc = (DeployedComponent) it.next();
- // if component is a ServiceComponent and the VM id matches
- if (dc.isDeployedConnector() || dc.isDeployedService()) {
-// comp = dc.getDeployedComponentDefn(this);
+ // if deployed component is a ServiceComponent and the VM id matches
+ if (dc.getServiceComponentDefnID() != null) {
if (dc.getVMComponentDefnID().equals(vmComponentID) &&
dc.getHostID().equals(hostID)) {
comps.add(dc);
}
- }
+ }
}
return comps;
}
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicUtil.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicUtil.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicUtil.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -84,13 +84,13 @@
public static final BasicComponentDefn createComponentDefn(int defnTypeCode,
ConfigurationID configID, ComponentTypeID typeID, String defnName) {
BasicComponentDefn defn = null;
-
- if (defnTypeCode == ComponentDefn.RESOURCE_DESCRIPTOR_COMPONENT_CODE) {
- ResourceDescriptorID descriptorID = new
ResourceDescriptorID(configID,defnName);
- defn = new BasicResourceDescriptor(configID, descriptorID, typeID);
-
+//
+// if (defnTypeCode == ComponentDefn.RESOURCE_DESCRIPTOR_COMPONENT_CODE) {
+// ResourceDescriptorID descriptorID = new
ResourceDescriptorID(configID,defnName);
+// defn = new BasicResourceDescriptor(configID, descriptorID, typeID);
+//
- } else if (defnTypeCode == ComponentDefn.CONNECTOR_COMPONENT_CODE) {
+ if (defnTypeCode == ComponentDefn.CONNECTOR_COMPONENT_CODE) {
ConnectorBindingID conID = new ConnectorBindingID(configID, defnName);
defn = new BasicConnectorBinding(configID, conID, typeID);
@@ -315,8 +315,8 @@
return ComponentDefn.VM_COMPONENT_CODE;
}else if(defn instanceof ConnectorBinding) {
return ComponentDefn.CONNECTOR_COMPONENT_CODE;
- }else if(defn instanceof ResourceDescriptor) {
- return ComponentDefn.RESOURCE_DESCRIPTOR_COMPONENT_CODE;
+// }else if(defn instanceof ResourceDescriptor) {
+// return ComponentDefn.RESOURCE_DESCRIPTOR_COMPONENT_CODE;
}else if(defn instanceof ServiceComponentDefn) {
return ComponentDefn.SERVICE_COMPONENT_CODE;
}else if(defn instanceof AuthenticationProvider) {
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/util/ConfigurationImportExportUtility.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/util/ConfigurationImportExportUtility.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/util/ConfigurationImportExportUtility.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -39,9 +39,6 @@
*/
public interface ConfigurationImportExportUtility {
-
- public static final int COMPONENT_TYPE_INDEX = 0;
- public static final int SERVICE_COMPONENT_DEFN_INDEX = 1;
/**
* <p>This method will write to the passed in InputStream instance a
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/util/ConfigurationPropertyNames.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/util/ConfigurationPropertyNames.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/util/ConfigurationPropertyNames.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -28,18 +28,13 @@
static final String APPLICATION_VERSION_CREATED_BY = "ApplicationVersion";
//$NON-NLS-1$
static final String USER_CREATED_BY = "UserCreatedBy"; //$NON-NLS-1$
static final String CONFIGURATION_VERSION = "ConfigurationVersion";
//$NON-NLS-1$
- static final String METAMATRIX_SYSTEM_VERSION = "MetaMatrixSystemVersion";
//$NON-NLS-1$
- static final String TIME = "Time"; //$NON-NLS-1$
-
- // at 4.2 is where the configuration format changes, so anything prior
- // to this version will use the old (3.0) import/export utility
- static final String MM_CONFIG_4_2_VERSION = "4.2"; //$NON-NLS-1$
- static final String MM_CONFIG_3_0_VERSION = "3.0"; //$NON-NLS-1$
+ static final String SYSTEM_VERSION = "SystemVersion"; //$NON-NLS-1$
+ static final String TIME = "Time"; //$NON-NLS-1$
-
// NOTE: if the latest config version is changed, then the
com.metamatrix.vdb.internal.def.VDBDefPropertyNames
// needs to be change, which will impact the importing of .DEF files.
- static final double MM_LATEST_CONFIG_VERSION = 4.2;
+ static final double CONFIG_CURR_VERSION_DBL = 6.0;
+ static final String CONFIG_CURR_VERSION = "6.0";
public static final String MEMBERSHIP_ADMIN_PASSWORD =
"security.membership.admin.password"; //$NON-NLS-1$
Copied:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/ConfigurationImportExport.java
(from rev 745,
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_Base_ImportExportUtility.java)
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/ConfigurationImportExport.java
(rev 0)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/ConfigurationImportExport.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -0,0 +1,1542 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.config.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+
+import com.metamatrix.common.CommonPlugin;
+import com.metamatrix.common.config.api.AuthenticationProvider;
+import com.metamatrix.common.config.api.ComponentDefn;
+import com.metamatrix.common.config.api.ComponentObject;
+import com.metamatrix.common.config.api.ComponentType;
+import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.config.api.ConfigurationID;
+import com.metamatrix.common.config.api.ConfigurationModelContainer;
+import com.metamatrix.common.config.api.ConfigurationObjectEditor;
+import com.metamatrix.common.config.api.ConnectorBinding;
+import com.metamatrix.common.config.api.DeployedComponent;
+import com.metamatrix.common.config.api.Host;
+import com.metamatrix.common.config.api.HostID;
+import com.metamatrix.common.config.api.ResourceDescriptor;
+import com.metamatrix.common.config.api.ServiceComponentDefn;
+import com.metamatrix.common.config.api.SharedResource;
+import com.metamatrix.common.config.api.VMComponentDefn;
+import com.metamatrix.common.config.api.VMComponentDefnID;
+import com.metamatrix.common.config.model.ConfigurationModelContainerImpl;
+import com.metamatrix.common.config.util.ConfigObjectsNotResolvableException;
+import com.metamatrix.common.config.util.ConfigurationPropertyNames;
+import com.metamatrix.common.config.util.InvalidConfigurationElementException;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.namedobject.BaseObject;
+import com.metamatrix.common.util.ErrorMessageKeys;
+import com.metamatrix.common.util.LogCommonConstants;
+import com.metamatrix.common.xml.XMLReaderWriter;
+import com.metamatrix.common.xml.XMLReaderWriterImpl;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.core.util.ReflectionHelper;
+
+/**
+* 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.
+*
+*/
+class ConfigurationImportExport implements ConfigurationPropertyNames {
+ private static final String CONFIG_MODEL_CLASS =
ConfigurationModelContainerImpl.class.getName();
+ private XMLHelperImpl xmlHelper = null;
+
+
+ private XMLReaderWriter readerWriter;
+// private XMLHelper helper = null;
+
+ /**
+ * These static variables define the constants that will be used to
+ * create the header for every document that is produced using this concrete
+ * utility.
+ */
+ public static final String DEFAULT_USER_CREATED_BY = "Unknown";
//$NON-NLS-1$
+
+ /**
+ * These indices are the indices used to retreive the Lists from the array
+ * of lists from the segregateConfigurationObjects method.
+ */
+ static final int CONFIGURATIONS_INDEX = 0;
+ static final int HOSTS_INDEX = 2;
+ static final int DEPLOYED_COMPONENTS_INDEX = 3;
+ static final int SERVICE_COMPONENT_DEFNS_INDEX = 4;
+ static final int VM_COMPONENT_DEFNS_INDEX = 5;
+ static final int COMPONENT_TYPES_INDEX = 6;
+ static final int CONNECTION_POOL_CONFIGS_INDEX = 16;
+ static final int RESOURCES_INDEX = 18;
+ static final int CONNECTORS_INDEX = 19;
+
+
+ static final int CONFIGURATION_IDS_INDEX = 8;
+ static final int HOST_IDS_INDEX = 10;
+ static final int DEPLOYED_COMPONENT_IDS_INDEX = 11;
+ static final int SERVICE_COMPONENT_DEFN_IDS_INDEX = 12;
+ static final int VM_COMPONENT_DEFN_IDS_INDEX = 13;
+ static final int COMPONENT_TYPE_IDS_INDEX = 14;
+ static final int CONNECTORS_IDS_INDEX = 20;
+
+
+ static final int NUMBER_OF_LISTS = 21;
+
+ public ConfigurationImportExport() {
+ getXMLHelper();
+ }
+
+ public void exportComponentType(OutputStream stream, ComponentType type,
+ Properties props) throws IOException {
+
+
+ Assertion.isNotNull(type);
+ Assertion.isNotNull(stream);
+
+ Element root = xmlHelper.createRootConfigurationDocumentElement();
+
+ // create a new Document with a root element
+ Document doc = new Document(root);
+
+ // add the header element
+ root = XMLHelperUtil.addHeaderElement(root, props);
+
+ Element componentTypesElement = xmlHelper.createComponentTypesElement();
+ root.addContent(componentTypesElement);
+ componentTypesElement.addContent(xmlHelper.createComponentTypeElement(type));
+
+ getXMLReaderWriter().writeDocument(doc, stream);
+ }
+
+ public void exportComponentTypes(OutputStream stream, ComponentType[] types,
+ Properties props) throws IOException {
+
+
+ Assertion.isNotNull(types);
+ Assertion.isNotNull(stream);
+
+
+ Element root = xmlHelper.createRootConfigurationDocumentElement();
+
+ // create a new Document with a root element
+ Document doc = new Document(root);
+
+ // add the header element
+ root = XMLHelperUtil.addHeaderElement(root, props);
+
+ Element componentTypesElement = xmlHelper.createComponentTypesElement();
+ root.addContent(componentTypesElement);
+
+ int s = types.length;
+
+ for (int i = 0; i<s; i++) {
+ ComponentType type = types[i];
+
+
componentTypesElement.addContent(xmlHelper.createComponentTypeElement(type));
+
+ }
+
+ getXMLReaderWriter().writeDocument(doc, stream);
+ }
+
+ /**
+ * <p>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.</p>
+ *
+ * <p>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.</p>
+ *
+ * <pre>
+ * 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
+ * </pre>
+ *
+ *
+ * <p> All of the above object references must be in the collection passed
+ * into this method.</p>
+ *
+ * <p> 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.</p>
+ *
+ * <pre>
+ * ConfigurationPropertyNames.APPLICATION_CREATED_BY
+ * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
+ * ConfigurationPropertyNames.USER_CREATED_BY
+ * <pre>
+ *
+ * <p>Any of these properties that are not included in the properties object
+ * will not be included in the header Element.
+ *
+ * @param stream the output stream to write the Configuration Object
+ * representation to
+ * @param configurationObjects a Collection of configuration objects that
+ * represents an entire logical Configuration.
+ * @param props the properties object that contains the values for the Header
+ * @throws IOException if there is an error writing to the DirectoryEntry
+ * @throws 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
+ */
+ public void exportConfiguration(OutputStream stream,
+ Collection configurationObjects, Properties props)
+ throws IOException, ConfigObjectsNotResolvableException {
+
+
+ Assertion.isNotNull(configurationObjects);
+ Assertion.isNotNull(stream);
+
+
+ // this will divide the configuration objects by their type
+ // so that we can create an XML doc and put the objects in their proper
+ // categories.
+ List[] lists = segregateConfigurationObjects(configurationObjects);
+
+ // this will throw ConfigObjectsNotResolvableException if the collection
+ // of configuration objects are not self containing.
+ resolveConfigurationObjects(lists);
+
+ ConfigurationModelContainer cmc=null;
+ try {
+ Collection parms = new ArrayList(1);
+ parms.add(configurationObjects);
+ cmc = (ConfigurationModelContainer)
ReflectionHelper.create(CONFIG_MODEL_CLASS, parms, this.getClass().getClassLoader());
+ } catch (MetaMatrixCoreException err) {
+ throw new IOException(err.getMessage());
+ }
+
+
+ Element root = xmlHelper.createRootConfigurationDocumentElement();
+
+ // create a new Document with a root element
+ final Document doc = new Document(root);
+
+ // add the header element
+ root = XMLHelperUtil.addHeaderElement(root, props);
+
+ final Configuration config = cmc.getConfiguration();
+ Element configElement = xmlHelper.createConfigurationElement(config);
+
+ root.addContent(configElement);
+
+ try {
+ Iterator hostIt=cmc.getHosts().iterator();
+ while(hostIt.hasNext()) {
+ Host h = (Host) hostIt.next();
+ final Element hostElement = xmlHelper.createHostElement(h);
+ configElement.addContent(hostElement);
+
+ Iterator vmsIt=cmc.getConfiguration().getVMsForHost((HostID)
h.getID()).iterator();
+// getDeployedVMsForHost((HostID) h.getID()).iterator();
+ while(vmsIt.hasNext()) {
+ VMComponentDefn vm = (VMComponentDefn) vmsIt.next();
+ final Element vmElement = xmlHelper.createProcessElement(vm);
+ hostElement.addContent(vmElement);
+
+ Map pscSvcMap = new HashMap(10);
+ Collection depsvcs =
cmc.getConfiguration().getDeployedServicesForVM(vm);
+ Iterator svcIt = depsvcs.iterator();
+ while(svcIt.hasNext()) {
+ DeployedComponent dc = (DeployedComponent) svcIt.next();
+ final Element svcElement =
xmlHelper.createDeployedServiceElement(dc);
+ vmElement.addContent(svcElement);
+ }
+
+
+ } // end of vms
+
+ } // end of host
+ } catch(Exception e) {
+ throw new ConfigObjectsNotResolvableException(e, "Error exporting
configuration"); //$NON-NLS-1$
+ }
+
+ Element providersElement = xmlHelper.createAuthenticationProviderElement();
+ root.addContent(providersElement);
+
+ Collection providers = cmc.getConfiguration().getAuthenticationProviders();
+ if (providers != null && providers.size() > 0) {
+ Iterator iterator = providers.iterator();
+ while (iterator.hasNext()) {
+ AuthenticationProvider provider = (AuthenticationProvider)iterator.next();
+// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ProductType named: " + type + " in list of configuration objects to
export.");
+ Element resourceElement =
xmlHelper.createAuthenticationProviderElement(provider);
+ providersElement.addContent(resourceElement);
+ }
+ }
+
+
+ Element connectorsElement = xmlHelper.createConnectorBindingsElement();
+ root.addContent(connectorsElement);
+
+
+ Collection bindings = cmc.getConfiguration().getConnectorBindings();
+ if (bindings != null && bindings.size() > 0) {
+ Iterator iterator = bindings.iterator();
+
+ while (iterator.hasNext()) {
+ ConnectorBinding connector = (ConnectorBinding)iterator.next();
+ Element connElement =
xmlHelper.createConnectorBindingElement(connector, true);
+ connectorsElement.addContent(connElement);
+ }
+
+ }
+
+ Element servicessElement = xmlHelper.createServiceComponentDefnsElement();
+ root.addContent(servicessElement);
+
+
+ Collection svcdefns = cmc.getConfiguration().getServiceComponentDefns();
+ if (svcdefns != null && svcdefns.size() > 0) {
+ Iterator iterator = svcdefns.iterator();
+
+ while (iterator.hasNext()) {
+ ServiceComponentDefn svc = (ServiceComponentDefn)iterator.next();
+ Element svcElement =
xmlHelper.createServiceComponentDefnElement(svc);
+ servicessElement.addContent(svcElement);
+ }
+
+ }
+
+ Element resourcesElement = xmlHelper.createSharedResourcesElement();
+ root.addContent(resourcesElement);
+
+ Collection sharedResources = cmc.getResources();
+ if (sharedResources != null && sharedResources.size() > 0) {
+
+ Iterator iterator = sharedResources.iterator();
+ while (iterator.hasNext()) {
+ SharedResource resource = (SharedResource)iterator.next();
+ Element resourceElement =
xmlHelper.createSharedResourceElement(resource);
+ resourcesElement.addContent(resourceElement);
+ }
+ }
+
+
+ Element componentTypesElement = xmlHelper.createComponentTypesElement();
+ root.addContent(componentTypesElement);
+
+ Map compTypes = cmc.getComponentTypes();
+ if (compTypes != null && compTypes.size() > 0) {
+
+ Iterator iterator = compTypes.values().iterator();
+
+ while (iterator.hasNext()) {
+ ComponentType componentType = (ComponentType)iterator.next();
+ Element componentTypeElement =
xmlHelper.createComponentTypeElement(componentType);
+ // LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ComponentType named: " + componentType + " in list of configuration objects to
export.");
+
+ componentTypesElement.addContent(componentTypeElement);
+ }
+ }
+
+
+ getXMLReaderWriter().writeDocument(doc, stream);
+ stream.close();
+
+ LogManager.logInfo(LogCommonConstants.CTX_CONFIG,
CommonPlugin.Util.getString("MSG.003.001.0003",
cmc.getConfigurationID().getFullName())); //$NON-NLS-1$
+ }
+
+
+
+
+ /**
+ * <p>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.</p>
+ *
+ * <p>Multiple ServiceComponentDefns can be written to the same DirectoryEntry
+ * by passing the same DirectoryEntry instance to this method multiple
times.</p>
+ *
+ * <p> The properties object that is passed into this method may contain
+ * the following properties as defined by the ConfigurationPropertyNames
class.</p>
+ *
+ * <pre>
+ * ConfigurationPropertyNames.APPLICATION_CREATED_BY
+ * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
+ * ConfigurationPropertyNames.USER_CREATED_BY
+ * <pre>
+ *
+ * <p>Any of these properties that are not included in the properties object
+ * will not be included in the header Element.
+ *
+ * @param stream the output stream to write the Configuration Object
+ * representation to
+ * @param type the ComponentType of the ServiceComponentDefn to be written
+ * to the DirectoryEntry resource.
+ * @param defn the ServiceComponentDefn instance to write to the DirectoryEntry.
+ * @param props the properties object that contains the values for the Header
+ * @throws IOException if there is an error writing to the DirectoryEntry
+ * @throws ConfigObjectsNotResolvableException if the passed in
+ * ComponentType is not the type referenced by the passed in ServiceComponentDefn.
+ */
+// public void exportServiceComponentDefn(OutputStream stream,
+// ServiceComponentDefn defn, ComponentType type, Properties props)
+// throws IOException, ConfigObjectsNotResolvableException {
+// Assertion.isNotNull(defn);
+// Assertion.isNotNull(type);
+// Assertion.isNotNull(stream);
+//
+//
+// List configurationObjects = new ArrayList(2);
+//
+// configurationObjects.add(defn);
+// configurationObjects.add(type);
+//
+// // here we need to make sure that the serviceComponentDefn references
+// // the passed in ComponentType instance. If not, this will throw
+// // the ConfigObjectsNotResolvableException
+// resolveConfigurationObjects(configurationObjects);
+// XMLHelper helper = getXMLHelper();
+//
+// Element root = helper.createRootConfigurationDocumentElement();
+//
+// // create a new Document with a root element
+// Document doc = new Document(root);
+//
+// root = XMLHelperUtil.addHeaderElement(root, props);
+//
+// Element componentTypesElement = helper.createComponentTypesElement();
+// root.addContent(componentTypesElement);
+// componentTypesElement.addContent(helper.createComponentTypeElement(type));
+//
+// Element serviceComponentDefnsElement =
helper.createServiceComponentDefnsElement();
+// root.addContent(serviceComponentDefnsElement);
+//
serviceComponentDefnsElement.addContent(helper.createServiceComponentDefnElement(defn));
+//
+// getXMLReaderWriter().writeDocument(doc, stream);
+// }
+
+
+ protected Collection createConnectorBindings(ConfigurationID configurationID, Element
root, ConfigurationObjectEditor editor, boolean importExistingBinding)
+ throws IOException, ConfigObjectsNotResolvableException,
+ InvalidConfigurationElementException {
+ Element connectorsElement =
root.getChild(XMLConfig_ElementNames.Configuration.ConnectorComponents.ELEMENT);
+ if (connectorsElement == null) {
+ return Collections.EMPTY_LIST;
+ }
+
+ List connectorBindings =
connectorsElement.getChildren(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.ELEMENT);
+
+ List connObjects = new ArrayList(connectorBindings.size());
+ if (connectorBindings != null) {
+ Iterator iterator = connectorBindings.iterator();
+ while (iterator.hasNext()) {
+ Element connElement = (Element)iterator.next();
+ ConnectorBinding conn =
getXMLHelper().createConnectorBinding(configurationID, connElement, editor, null,
importExistingBinding);
+ connObjects.add(conn);
+ }
+ }
+
+ return connObjects;
+ }
+
+ protected ConnectorBinding createConnectorBinding(ConfigurationID configurationID,
Element root, ConfigurationObjectEditor editor, String name, boolean isImportConfig)
+ throws IOException, ConfigObjectsNotResolvableException,
+ InvalidConfigurationElementException {
+ Element connectorsElement =
root.getChild(XMLConfig_ElementNames.Configuration.ConnectorComponents.ELEMENT);
+ if (connectorsElement == null) {
+ return null;
+ }
+
+ List connectorBindings =
connectorsElement.getChildren(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.ELEMENT);
+
+ // return the first binding to be created because only one
+ // binding is created in this method
+ if (connectorBindings != null) {
+ Iterator iterator = connectorBindings.iterator();
+ while (iterator.hasNext()) {
+ Element connElement = (Element)iterator.next();
+ ConnectorBinding conn =
getXMLHelper().createConnectorBinding(configurationID, connElement, editor, name,
isImportConfig);
+ return conn;
+ }
+ }
+
+ 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);
+
+ if (componentTypesElement == null) {
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0008,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0008,XMLConfig_ElementNames.ComponentTypes.ELEMENT));
+ }
+
+ Element componentTypeElement =
componentTypesElement.getChild(XMLConfig_ElementNames.ComponentTypes.ComponentType.ELEMENT);
+
+ if (componentTypeElement == null) {
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0008,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0008,XMLConfig_ElementNames.ComponentTypes.ComponentType.ELEMENT));
+ }
+
+ return xmlHelper.createComponentType(componentTypeElement, editor, name, true);
+ }
+
+
+ protected Collection createComponentTypes(Element root, ConfigurationObjectEditor
editor) throws InvalidConfigurationElementException{
+
+ Element componentTypesElement =
root.getChild(XMLConfig_ElementNames.ComponentTypes.ELEMENT);
+
+ if (componentTypesElement == null) {
+ return Collections.EMPTY_LIST;
+ }
+
+
+ // Make a copy of the lists that we intend to change so that we don't affect
JDOM's list (which changes the underlying structure)
+ List componentTypes = new
ArrayList(componentTypesElement.getChildren(XMLConfig_ElementNames.ComponentTypes.ComponentType.ELEMENT));
+
+ List connObjects = null;
+
+ if (componentTypes != null) {
+ connObjects = new ArrayList(componentTypes.size());
+
+ getXMLHelper().orderComponentTypeElementList(componentTypes);
+ Iterator iterator = componentTypes.iterator();
+ while (iterator.hasNext()) {
+ Element connElement = (Element)iterator.next();
+ ComponentType type = getXMLHelper().createComponentType(connElement,
editor, null, true);
+ connObjects.add(type);
+
+ }
+ } else {
+ return Collections.EMPTY_LIST;
+ }
+
+ return connObjects;
+ }
+
+
+
+ /**
+ * <p>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.</p>
+ *
+ * <p>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.</p>
+ *
+ * <p> The properties object that is passed into this method may contain
+ * the following properties as defined by the ConfigurationPropertyNames
class.</p>
+ *
+ * <pre>
+ * ConfigurationPropertyNames.APPLICATION_CREATED_BY
+ * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
+ * ConfigurationPropertyNames.USER_CREATED_BY
+ * <pre>
+ *
+ * <p>Any of these properties that are not included in the properties object
+ * will not be included in the header Element.
+ *
+ * @param stream the output stream to write the Configuration Object
+ * representation to
+ * @param type the ComponentType to be written to the InputStream
+ * @param props the properties object that contains the values for the Header
+ * @throws IOException if there is an error writing to the InputStream
+ */
+ public void exportConnector(OutputStream stream, ComponentType type, Properties
props) throws IOException {
+ // no resolving issues with this implementation...
+ exportComponentType(stream, type, props);
+ }
+
+ /**
+ * <p>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.</p>
+ *
+ * <p> The properties object that is passed into this method may contain
+ * the following properties as defined by the ConfigurationPropertyNames
class.</p>
+ *
+ * <pre>
+ * ConfigurationPropertyNames.APPLICATION_CREATED_BY
+ * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
+ * ConfigurationPropertyNames.USER_CREATED_BY
+ * <pre>
+ *
+ * <p>Any of these properties that are not included in the properties object
+ * will not be included in the header Element.
+ *
+ * @param stream the output stream to write the Configuration Object
+ * representation to
+ * @param type the ComponentType of the ServiceComponentDefn to be written
+ * to the InputStream resource.
+ * @param defn the ServiceComponentDefn instance to write to the InputStream.
+ * @param props the properties object that contains the values for the Header
+ * @throws IOException if there is an error writing to the InputStream
+ * @throws ConfigObjectsNotResolvableException if the passed in
+ * ComponentType is not the type referenced by the passed in ServiceComponentDefn.
+ */
+ public void exportConnectorBinding(OutputStream stream, ConnectorBinding defn,
ComponentType type, Properties props) throws IOException,
ConfigObjectsNotResolvableException {
+ Assertion.isNotNull(defn);
+ Assertion.isNotNull(type);
+ Assertion.isNotNull(stream);
+
+ // here we ensure that this is a Connector and that the given component
+ // type resolves to the given ServiceComponentDefn.
+ resolveConnector(type, defn);
+
+ Element root = xmlHelper.createRootConfigurationDocumentElement();
+
+ // create a new Document with a root element
+ Document doc = new Document(root);
+
+ root = XMLHelperUtil.addHeaderElement(root, props);
+
+ Element componentTypesElement = xmlHelper.createComponentTypesElement();
+ root.addContent(componentTypesElement);
+ componentTypesElement.addContent(xmlHelper.createComponentTypeElement(type));
+
+ Element connectorsElement = xmlHelper.createConnectorBindingsElement();
+ root.addContent(connectorsElement);
+ Element connElement = xmlHelper.createConnectorBindingElement(defn, false );
+ connectorsElement.addContent(connElement);
+
+ getXMLReaderWriter().writeDocument(doc, stream);
+ }
+
+
+ public void exportConnectorBindings(OutputStream stream, ConnectorBinding[] bindings,
ComponentType[] types, Properties props) throws IOException,
ConfigObjectsNotResolvableException {
+ Assertion.isNotNull(bindings);
+ Assertion.isNotNull(types);
+ Assertion.isNotNull(stream);
+
+
+ Element root = xmlHelper.createRootConfigurationDocumentElement();
+
+ // create a new Document with a root element
+ Document doc = new Document(root);
+
+ root = XMLHelperUtil.addHeaderElement(root, props);
+
+ exportConnectorBindings(bindings, types, root);
+
+ getXMLReaderWriter().writeDocument(doc, stream);
+
+ }
+
+ /**
+ * Add connector bindings and component types (connector types) under
+ * a common root element.
+ * @param bindings
+ * @param types
+ * @param helper
+ * @param root
+ * @since 4.2
+ */
+ public void exportConnectorBindings(ConnectorBinding[] bindings,
+ ComponentType[] types,
+ Element root) {
+ int s = bindings.length;
+ List ts = new ArrayList(s);
+
+ Element componentTypesElement = xmlHelper.createComponentTypesElement();
+ root.addContent(componentTypesElement);
+
+
+ Element connectorsElement = xmlHelper.createConnectorBindingsElement();
+ root.addContent(connectorsElement);
+
+ if (bindings == null || bindings.length == 0) {
+ return;
+ }
+
+ int tsize = types.length;
+ Map typeMap = new HashMap(tsize);
+
+ for (int i = 0; i<tsize; i++) {
+ ComponentType type = types[i];
+ if (type != null) {
+ typeMap.put(type.getID(), type);
+ }
+ }
+
+
+
+ for (int i = 0; i<s; i++) {
+
+ ConnectorBinding cb = bindings[i];
+ if (cb == null) {
+ continue;
+ }
+ ComponentType type = (ComponentType) typeMap.get(cb.getComponentTypeID());
+
+ if (type != null && !ts.contains(type.getFullName())) {
+
componentTypesElement.addContent(xmlHelper.createComponentTypeElement(type));
+ ts.add(type.getFullName());
+ }
+
+ Element connElement = xmlHelper.createConnectorBindingElement(cb, false );
+ connectorsElement.addContent(connElement);
+
+ }
+ }
+
+
+ /**
+ * <p>This method will be used to import a Collection of Configuration objects
+ * given an InputStream. If the InputStream resource does not contain enough
+ * data to recombine all of the configuration objects in the Input Stream,
+ * then a ConfigurationObjectsNotResolvableException
+ * will be thrown.</p>
+ *
+ * <p>This method also allows you to rename the imported Configuration object
+ * possibly to avoid name conflicts with other Configurations already in the
server.</p>
+ *
+ * <p>If the name parameter submitted is null, the name of the configuration
+ * object as it exists in the InputStream will be used as the name
+ * of the resulting Configuration object in the returned collection of
+ * configuration objects.</p>
+ *
+ *
+ * @param editor the ConfigurationObjectEditor to use to create the Configuration
+ * objects in the InputStream resource.
+ * @param stream the input stream to read the configuration object
+ * representations from
+ * @param name the name for the Configuration object to be created. Can
+ * be null if the name specified in the input stream is to be used.
+ * @return the configuration objects that were represented as data in the
+ * InputStream resource
+ * @throws ConfigObjectsNotResolvableException if the data representing
+ * the Configuration to be imported is incomplete.
+ * @throws IOException if there is an error reading from the InputStream
+ * @throws InvalidConfigurationElementException if there is a problem with
+ * the representation of the configuration element as it exists in the
+ * InputStream resource, usually some type of formatting problem.
+ */
+ public Collection importConfigurationObjects(Element root,
+ ConfigurationObjectEditor editor, String name)
+ throws IOException, ConfigObjectsNotResolvableException,
+ InvalidConfigurationElementException {
+ Assertion.isNotNull(root);
+ Assertion.isNotNull(editor);
+
+ ArrayList configurationObjects = new ArrayList();
+
+ // get the first configuration element from the document
+ Element configurationElement =
root.getChild(XMLConfig_ElementNames.Configuration.ELEMENT);
+
+ // if there is no configuration element under the Configurations element
+ // then we do not know how to import one.
+ if (configurationElement == null) {
+ throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0004,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0004));
+ }
+
+
+
+ // NOTE the ordering of the following iterations is very important
+ // as the actions to create the configuration objects are being created
+ // within the ConfigurationObjectEditor. If these are created out of
+ // order, a Configuration object that references another configuration
+ // object may be created before the configuration object that it references.
+ // This will work fine until the actions are committed.
+ Configuration config = xmlHelper.createConfiguration(configurationElement,
editor, name);
+
+ ConfigurationID configID = (ConfigurationID) config.getID();
+ configurationObjects.add(config);
+
+ xmlHelper.addProperties(configurationElement, config, editor);
+
+
+
+
+ Collection componentTypes = createComponentTypes(root, editor);
+ Map componentTypeMap = new HashMap();
+ if (componentTypes != null) {
+ for (Iterator it=componentTypes.iterator(); it.hasNext();) {
+ ComponentType type = (ComponentType) it.next();
+ componentTypeMap.put(type.getID(), type);
+ configurationObjects.add(type);
+
+ }
+ }
+
+
+
+ Element resourcesElement =
root.getChild(XMLConfig_ElementNames.Configuration.Resources.ELEMENT);
+
+ List resources = null;
+ if (resourcesElement != null) {
+ resources =
resourcesElement.getChildren(XMLConfig_ElementNames.Configuration.Resources.Resource.ELEMENT);
+ } else {
+ resources = Collections.EMPTY_LIST;
+ }
+
+ Iterator iterator = resources.iterator();
+ while (iterator.hasNext()) {
+ Element resourceElement = (Element)iterator.next();
+ SharedResource resource = xmlHelper.createSharedResource(resourceElement,
editor);
+ configurationObjects.add(resource);
+ }
+
+ Element authprovidersElement =
+
root.getChild(XMLConfig_ElementNames.Configuration.AuthenticationProviders.ELEMENT);
+ if (authprovidersElement!=null) {
+ Collection authproviderElements =
+
authprovidersElement.getChildren(XMLConfig_ElementNames.Configuration.AuthenticationProviders.Provider.ELEMENT);
+
+ iterator = authproviderElements.iterator();
+ while (iterator.hasNext()) {
+ Element resourcePoolElement = (Element)iterator.next();
+ AuthenticationProvider provider =
+ xmlHelper.createAuthenticationProvider(resourcePoolElement,
configID, editor);
+ configurationObjects.add(provider);
+
+ }
+ }
+
+
+
+ Collection bindings = createConnectorBindings(configID, root, editor, true);
+
+
+ Map serviceComponentDefnMap = new HashMap();
+
+ for (Iterator itb=bindings.iterator(); itb.hasNext();) {
+ ComponentDefn defn = (ComponentDefn) itb.next();
+ serviceComponentDefnMap.put(defn.getID(), defn);
+ }
+
+ // this list of servicecomponent defns will be used in the creation
+ // of deployed components, we need the actual reference to the
+ // servicecomponentdefn to create a deployed version of it...
+ Element serviceComponentDefnsElement =
+ root.getChild(XMLConfig_ElementNames.Configuration.Services.ELEMENT);
+ if (serviceComponentDefnsElement!=null) {
+ Collection serviceComponentDefnElements =
+
serviceComponentDefnsElement.getChildren(XMLConfig_ElementNames.Configuration.Services.Service.ELEMENT);
+
+ iterator = serviceComponentDefnElements.iterator() ;
+ while (iterator.hasNext()) {
+ Element serviceComponentDefnElement = (Element)iterator.next();
+ ComponentDefn defn =
+ xmlHelper.createServiceComponentDefn(serviceComponentDefnElement,
config, editor, null);
+ serviceComponentDefnMap.put(defn.getID(), defn);
+ configurationObjects.add(defn);
+
+ }
+ }
+
+ // add the bindings to the map that is used by deployment
+ configurationObjects.addAll(bindings);
+
+ // retreive the host elements from the document.
+ List hostElements =
configurationElement.getChildren(XMLConfig_ElementNames.Configuration.Host.ELEMENT);
+ Iterator hostiterator = hostElements.iterator();
+ Host host = null;
+ HostID hostID = null;
+ while (hostiterator.hasNext()) {
+ Element hostElement = (Element)hostiterator.next();
+
+ host = xmlHelper.createHost(hostElement,configID, editor, null);
+ hostID = (HostID) host.getID();
+ configurationObjects.add(host);
+
+
+ List vmElements =
hostElement.getChildren(XMLConfig_ElementNames.Configuration.Process.ELEMENT);
+ Iterator vmIt = vmElements.iterator();
+ while (vmIt.hasNext()) {
+ Element vmElement = (Element)vmIt.next();
+
+ VMComponentDefn vm = xmlHelper.createProcess(vmElement, configID,
hostID, editor, null);
+
+// DeployedComponent vmdc =
xmlHelper.createDeployedVMComponentDefn(vmElement, configID, hostID,
vm.getComponentTypeID(), editor);
+ VMComponentDefnID vmID = (VMComponentDefnID) vm.getID();
+
+ configurationObjects.add(vm);
+
+ List svcElements =
vmElement.getChildren(XMLConfig_ElementNames.Configuration.DeployedService.ELEMENT);
+
+ Iterator svcIt = svcElements.iterator();
+ while (svcIt.hasNext()) {
+ Element svcElement = (Element)svcIt.next();
+ // create this only for use to create the deployed service
+ DeployedComponent dc =
xmlHelper.createDeployedServiceComponent(svcElement, configID, hostID, vmID,
componentTypeMap, editor);
+ configurationObjects.add(dc);
+
+ } // end services
+ } // end vm
+
+ } // end host
+
+
+
+// Map vmComponentDefnMap = new HashMap();
+// Element vmComponentDefnsElement =
configurationElement.getChild(XMLConfig_ElementNames.Configurations.Configuration.VMComponentDefns.ELEMENT);
+// if (vmComponentDefnsElement!=null) {
+// Collection vmComponentDefnElements =
+//
vmComponentDefnsElement.getChildren(XMLConfig_ElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.ELEMENT);
+//
+// iterator = vmComponentDefnElements.iterator();
+// while (iterator.hasNext()) {
+// Element vmComponentDefnElement = (Element)iterator.next();
+// VMComponentDefn vmComponentDefn =
+// xmlHelper.createVMComponentDefn(vmComponentDefnElement,
(ConfigurationID) config.getID() , editor, null);
+//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
VMComponentDefn named: " + vmComponentDefn + " in XML file VMComponentDefns
element.");
+// vmComponentDefnMap.put(vmComponentDefn.getID(), vmComponentDefn);
+// configurationObjects.add(vmComponentDefn);
+//
+// }
+// }
+// Element deployedComponentsElement =
+//
configurationElement.getChild(XMLConfig_ElementNames.Configurations.Configuration.DeployedComponents.ELEMENT);
+// if (deployedComponentsElement!=null) {
+// Collection deployedComponentElements =
+//
deployedComponentsElement.getChildren(XMLConfig_ElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.ELEMENT);
+//
+// iterator = deployedComponentElements.iterator();
+// while (iterator.hasNext()) {
+// Element deployedComponentElement = (Element)iterator.next();
+// DeployedComponent deployedComponent =
+// xmlHelper.createDeployedComponent(deployedComponentElement,
config, editor, serviceComponentDefnMap, vmComponentDefnMap, componentTypeMap, null);
+//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
DeployedComponent named: " + deployedComponent + " in XML file
DeployedComponents element.");
+// configurationObjects.add(deployedComponent);
+// }
+// }
+ // this will ensure that the actions that exist in the editor are
+ // self contained....that there are no references to configuration objects
+ // in the configuration objects that are not also contained in the Collection
+ resolveConfigurationObjects(configurationObjects);
+
+// *** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0006);
+
+ return configurationObjects;
+ }
+
+
+ public ConnectorBinding importConnectorBinding(InputStream stream,
ConfigurationObjectEditor editor, String newName)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
+ Assertion.isNotNull(stream);
+ Assertion.isNotNull(editor);
+
+ Document doc = null;
+
+ try {
+ doc = getXMLReaderWriter().readDocument(stream);
+ } catch(JDOMException e) {
+ throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0010));
+ }
+
+ Element root = doc.getRootElement();
+
+
+ ConnectorBinding binding = createConnectorBinding(Configuration.NEXT_STARTUP_ID,
root, editor, newName, false) ;
+
+ if (binding == null) {
+ throw new ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0011,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0011));
+ }
+
+ return binding;
+
+}
+
+ public Collection importConnectorBindings(Element root, ConfigurationObjectEditor
editor, boolean importExistingBinding)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
+ Assertion.isNotNull(root);
+ Assertion.isNotNull(editor);
+
+
+ Collection connectorBindings =
createConnectorBindings(Configuration.NEXT_STARTUP_ID, root, editor,
importExistingBinding) ;
+
+ return connectorBindings;
+ }
+
+ /**
+ * <p>This method will be used to import a ComponentType Object</p>
+ *
+ * <p>This method also allows you to rename the imported ComponentType 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 configuration
+ * object as it exists in the DirectoryEntry will be used.</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
+ * @return the configuration object that was represented as data in the
+ * DirectoryEntry resource
+ * @param name the name for the ComponentType object to be created.
+ * @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 ComponentType importComponentType(Element root,
+ //InputStream stream,
+ ConfigurationObjectEditor editor, String name)
+ throws IOException, InvalidConfigurationElementException {
+
+ Assertion.isNotNull(editor);
+
+
+ ComponentType t = createComponentType(root, editor, name);
+
+ return t;
+ }
+
+ /**
+ * <p>This method will be used to import 1 or more a ComponentType
Objects.</p>
+ *
+ * @param editor the ConfigurationObjectEditor to use to create the Configuration
+ * objects.
+ * @param stream the input stream to read the configuration object
+ * representation from
+ * @return Collection of objects of type <code>ComponentType</code>
+ * @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 Collection importComponentTypes(Element root,
+ //InputStream stream,
+ ConfigurationObjectEditor editor)
+ throws IOException, InvalidConfigurationElementException {
+// Assertion.isNotNull(stream);
+ Assertion.isNotNull(editor);
+
+
+ Collection connectorTypes = createComponentTypes(root, editor) ;
+
+ return connectorTypes;
+
+ }
+
+
+ public Collection importConnectorBindings(InputStream stream,
ConfigurationObjectEditor editor, boolean importExistingBinding)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
+ Assertion.isNotNull(stream);
+ Assertion.isNotNull(editor);
+
+ Document doc = null;
+
+ try {
+ doc = getXMLReaderWriter().readDocument(stream);
+ } catch(JDOMException e) {
+ throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0010));
+
+ }
+
+ Element root = doc.getRootElement();
+
+ return importConnectorBindings(root, editor, importExistingBinding);
+ }
+
+ public Object[] importConnectorBindingAndType(InputStream stream,
ConfigurationObjectEditor editor, String[] newName)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
+
+ Assertion.isNotNull(stream);
+ Assertion.isNotNull(editor);
+
+ Document doc = null;
+
+ try {
+ doc = getXMLReaderWriter().readDocument(stream);
+ } catch(JDOMException e) {
+ throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0012));
+ }
+
+ String typeName = null;
+ String bindingName = null;
+ if (newName != null) {
+ typeName = newName[ConfigurationImportExport.COMPONENT_TYPES_INDEX];
+ bindingName = newName[ConfigurationImportExport.SERVICE_COMPONENT_DEFNS_INDEX];
+ }
+ Element root = doc.getRootElement();
+
+ ComponentType type = createComponentType(root, editor, typeName);
+
+ if (type == null) {
+ throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0013,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0013));
+ }
+
+
+ ConnectorBinding binding = createConnectorBinding(Configuration.NEXT_STARTUP_ID,
root, editor, bindingName, false) ;
+
+
+ if (binding == null) {
+ throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0014,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0014));
+ }
+
+ // here we ensure that this is a Connector and that the given component
+ // type resolves to the given ServiceComponentDefn.
+ resolveConnector(type, binding);
+
+ Object[] object = {type, binding
+ };
+
+ return object;
+
+ }
+
+
+ /**
+ * This method is used specifically to resolve Connector Binding
+ * ServiceComponentDefns to their respective Connector ComponentTypes.
+ */
+ private void resolveConnector(ComponentType type, ComponentDefn defn) throws
ConfigObjectsNotResolvableException {
+
+ // check to be sure that the passed in ComponentType is the correct one for
+ // this ServiceComponentDefn.
+ if (type == null) {
+ String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0015,
new Object[] {defn.getID(), defn.getComponentTypeID()} );
+
+ System.err.print(msg);
+
+ throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0015, msg);
+
+ } else if (!(defn.getComponentTypeID().equals(type.getID()))) {
+ String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0015,
new Object[] {defn.getID(), type.getID()} );
+
+ System.err.print(msg);
+
+ throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0015, msg);
+ }
+
+ if (!type.isOfTypeConnector()) {
+ throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0017,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0017,
type.getSuperComponentTypeID().getName()));
+ }
+ }
+
+ /**
+ * <p>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. </p>
+ *
+ * <p>Any number of actual Configuration object instances may be passed in
+ * in the Collection.</p>
+ *
+ * @param collection the collection of configuration objects to be resolved
+ * @throws ConfigObjectsNotResolvableException if the collection of objects
+ * passed in are not self containing.
+ */
+ public void resolveConfigurationObjects(Collection collection) throws
ConfigObjectsNotResolvableException{
+
+ List[] lists = segregateConfigurationObjects(collection);
+
+ resolveConfigurationObjects(lists);
+ }
+
+
+
+ protected void resolveConfigurationObjects(List[] lists) throws
ConfigObjectsNotResolvableException{
+
+ List configurations = lists[CONFIGURATIONS_INDEX];
+
+ List hosts = lists[HOSTS_INDEX];
+ List deployedComponents = lists[DEPLOYED_COMPONENTS_INDEX];
+ List serviceComponentDefns = lists[SERVICE_COMPONENT_DEFNS_INDEX];
+ List vmComponentDefns = lists[VM_COMPONENT_DEFNS_INDEX];
+ List componentTypes = lists[COMPONENT_TYPES_INDEX];
+
+ List connectionPools = lists[CONNECTION_POOL_CONFIGS_INDEX];
+
+ List resources = lists[RESOURCES_INDEX];
+
+ List connectorBindings = lists[CONNECTORS_INDEX];
+
+ List configurationIDs = lists[CONFIGURATION_IDS_INDEX];
+ List hostIDs = lists[HOST_IDS_INDEX];
+ List serviceComponentDefnIDs = lists[SERVICE_COMPONENT_DEFN_IDS_INDEX];
+ List vmComponentDefnIDs = lists[VM_COMPONENT_DEFN_IDS_INDEX];
+ List componentTypeIDs = lists[COMPONENT_TYPE_IDS_INDEX];
+
+ List connectorBindingsIDs = lists[CONNECTORS_IDS_INDEX];
+
+
+ // we do this because a DeployedComponent can have a null ServiceComponentDefnID
+ // and a null ProductServiceComponentID and still be viable. This will
+ // allow the contains methods called on these Lists later in this method
+ // to return true if the ID is null instead of throwing a bogus exception
+ serviceComponentDefnIDs.add(null);
+ connectorBindingsIDs.add(null);
+ componentTypeIDs.add(null);
+
+ // now we must iterate through each object type, pull out any references
+ // to other configuration objects and ensure that those objects were
+ // in the collection of objects passed into the method.
+ Iterator iterator = deployedComponents.iterator();
+ while (iterator.hasNext()) {
+ DeployedComponent deployedComponent = (DeployedComponent) iterator.next();
+ if(!vmComponentDefnIDs.contains(deployedComponent.getVMComponentDefnID())){
+
+ throwObjectsNotResolvable(deployedComponent,
deployedComponent.getVMComponentDefnID(), "vm component"); //$NON-NLS-1$
+ }
+
+ if
(!serviceComponentDefnIDs.contains(deployedComponent.getServiceComponentDefnID())
&&
+
!connectorBindingsIDs.contains(deployedComponent.getServiceComponentDefnID()) ) {
+
+ throwObjectsNotResolvable(deployedComponent,
deployedComponent.getServiceComponentDefnID(), "service component");
//$NON-NLS-1$
+ }
+
+ if (!hostIDs.contains(deployedComponent.getHostID())) {
+ throwObjectsNotResolvable(deployedComponent,
deployedComponent.getHostID(), "host"); //$NON-NLS-1$
+ }
+
+ checkComponentTypeID(deployedComponent, componentTypeIDs);
+ }
+
+ iterator = resources.iterator();
+ while (iterator.hasNext()) {
+ SharedResource defn = (SharedResource)iterator.next();
+ checkComponentTypeID(defn, componentTypeIDs);
+ }
+
+
+ iterator = connectionPools.iterator();
+ while (iterator.hasNext()) {
+ ResourceDescriptor defn = (ResourceDescriptor)iterator.next();
+ checkComponentTypeID(defn, componentTypeIDs);
+ checkConfigurationID(defn, configurationIDs);
+ }
+
+ iterator = connectorBindings.iterator();
+ while (iterator.hasNext()) {
+ ConnectorBinding defn = (ConnectorBinding)iterator.next();
+ checkComponentTypeID(defn, componentTypeIDs);
+ }
+
+
+
+ iterator = serviceComponentDefns.iterator();
+ while (iterator.hasNext()) {
+ ServiceComponentDefn defn = (ServiceComponentDefn)iterator.next();
+ checkComponentTypeID(defn, componentTypeIDs);
+ checkConfigurationID(defn, configurationIDs);
+ }
+
+ iterator = vmComponentDefns.iterator();
+ while (iterator.hasNext()) {
+ VMComponentDefn defn = (VMComponentDefn)iterator.next();
+ checkComponentTypeID(defn, componentTypeIDs);
+ checkConfigurationID(defn, configurationIDs);
+
+
+ }
+
+
+ iterator = configurations.iterator();
+ while (iterator.hasNext()) {
+ Configuration config = (Configuration)iterator.next();
+ checkComponentTypeID(config, componentTypeIDs);
+ }
+
+ iterator = hosts.iterator();
+ while (iterator.hasNext()) {
+ Host host = (Host)iterator.next();
+ checkComponentTypeID(host, componentTypeIDs);
+ }
+
+ }
+
+ private void throwObjectsNotResolvable(Object referencingObject, Object
referencedObject, String type) throws ConfigObjectsNotResolvableException{
+
+ String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0018, new
Object[]
+ {referencingObject, type, referencedObject} );
+ ConfigObjectsNotResolvableException e = new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0018, msg,
referencingObject);
+
+ throw e;
+ }
+
+ private void throwObjectsNotResolvable(Object referencingObject, String type) throws
ConfigObjectsNotResolvableException{
+ String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0019, new
Object[]
+ {referencingObject, type} );
+
+
+ ConfigObjectsNotResolvableException e = new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0019, msg,
referencingObject);
+
+ throw e;
+ }
+
+ private void checkConfigurationID(ComponentDefn defn, List configurationIDs) throws
ConfigObjectsNotResolvableException {
+ if (!configurationIDs.contains(defn.getConfigurationID())) {
+ throwObjectsNotResolvable(defn, defn.getConfigurationID(), "configuration
object"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Used when product types ids are not part of validation - i.e.,
ResourceDescriptors
+ */
+ private void checkComponentTypeID(ComponentObject object, List componentTypeIDs)
throws ConfigObjectsNotResolvableException{
+ if (!(componentTypeIDs.contains(object.getComponentTypeID()) )) {
+ throwObjectsNotResolvable(object, object.getComponentTypeID(), "component
type"); //$NON-NLS-1$
+ }
+ }
+
+
+
+// private void checkForComponentTypeID(ComponentTypeID id, List componentTypeIDs)
throws ConfigObjectsNotResolvableException{
+//
+// if (id!=null) {
+// if (!(componentTypeIDs.contains(id))) {
+// throwObjectsNotResolvable(id, "component"); //$NON-NLS-1$
+//
+//// throwConfigObjectsNotResolvableException(id, id);
+// }
+//
+// }
+//
+// }
+
+
+ protected List[] segregateConfigurationObjects(Collection collection) {
+
+
+ List[] lists = new ArrayList[NUMBER_OF_LISTS];
+
+ Assertion.isNotNull(collection);
+ ArrayList componentTypes = new ArrayList();
+ ArrayList hosts = new ArrayList();
+ ArrayList deployedComponents = new ArrayList();
+ ArrayList serviceComponentDefns = new ArrayList();
+ ArrayList vmComponentDefns = new ArrayList();
+ ArrayList configurations = new ArrayList();
+ ArrayList connPools = new ArrayList();
+ ArrayList resources = new ArrayList();
+ ArrayList bindings = new ArrayList();
+
+
+ ArrayList componentTypeIDs = new ArrayList();
+ ArrayList hostIDs = new ArrayList();
+ ArrayList deployedComponentIDs = new ArrayList();
+ ArrayList serviceComponentDefnIDs = new ArrayList();
+ ArrayList vmComponentDefnIDs = new ArrayList();
+ ArrayList configurationIDs = new ArrayList();
+
+ ArrayList bindingIDs = new ArrayList();
+
+
+ // here we segregate the configuration objects by type so that we can
+ // determine what references they may have to other configuration objects
+ // we also set up lists of ID's as a convenience so that we can use
+ // contains() to check to see if an id is resolvable within the collection
+ Iterator iterator = collection.iterator();
+ while (iterator.hasNext()) {
+ Object obj = iterator.next();
+
+ // product types need to go before component type
+
+ if (obj instanceof ComponentType) {
+
+ componentTypes.add(obj);
+ componentTypeIDs.add(((BaseObject)obj).getID());
+ }else if(obj instanceof ComponentObject) {
+ if (obj instanceof Host) {
+ hosts.add(obj);
+ hostIDs.add(((BaseObject)obj).getID());
+ }else if(obj instanceof DeployedComponent) {
+ deployedComponents.add(obj);
+ deployedComponentIDs.add(((BaseObject)obj).getID());
+ }else if(obj instanceof Configuration) {
+ configurations.add(obj);
+ configurationIDs.add(((BaseObject)obj).getID());
+
+ }else if(obj instanceof SharedResource) {
+ resources.add(obj);
+ }else if(obj instanceof ConnectorBinding) {
+ bindings.add(obj);
+ bindingIDs.add(((BaseObject)obj).getID());
+
+ }else if(obj instanceof ComponentDefn) {
+ if(obj instanceof ServiceComponentDefn) {
+ serviceComponentDefns.add(obj);
+ serviceComponentDefnIDs.add(((BaseObject)obj).getID());
+ }else if(obj instanceof VMComponentDefn) {
+ vmComponentDefns.add(obj);
+ vmComponentDefnIDs.add(((BaseObject)obj).getID());
+ }else if(obj instanceof ResourceDescriptor) {
+ connPools.add(obj);
+
+ }
+ }
+ }
+ }
+
+
+ lists[CONFIGURATIONS_INDEX] = configurations;
+ lists[HOSTS_INDEX] = hosts;
+ lists[DEPLOYED_COMPONENTS_INDEX] = deployedComponents;
+ lists[SERVICE_COMPONENT_DEFNS_INDEX] = serviceComponentDefns;
+ lists[VM_COMPONENT_DEFNS_INDEX] = vmComponentDefns;
+ lists[COMPONENT_TYPES_INDEX] = componentTypes;
+
+ lists[CONFIGURATION_IDS_INDEX] = configurationIDs;
+ lists[HOST_IDS_INDEX] = hostIDs;
+ lists[DEPLOYED_COMPONENT_IDS_INDEX] = deployedComponentIDs;
+ lists[SERVICE_COMPONENT_DEFN_IDS_INDEX] = serviceComponentDefnIDs;
+ lists[VM_COMPONENT_DEFN_IDS_INDEX] = vmComponentDefnIDs;
+ lists[COMPONENT_TYPE_IDS_INDEX] = componentTypeIDs;
+
+ lists[CONNECTION_POOL_CONFIGS_INDEX] = connPools;
+
+ lists[RESOURCES_INDEX] = resources;
+ lists[CONNECTORS_INDEX] = bindings;
+ lists[CONNECTORS_IDS_INDEX] = bindingIDs;
+
+
+ return lists;
+ }
+
+ protected XMLReaderWriter getXMLReaderWriter() {
+ if (readerWriter == null) {
+ readerWriter = new XMLReaderWriterImpl();
+ }
+ return readerWriter;
+ }
+
+ protected XMLHelperImpl getXMLHelper() {
+ if (xmlHelper == null) {
+ xmlHelper = new XMLHelperImpl();
+
+ }
+ return xmlHelper;
+
+ }
+}
Deleted:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ElementNames.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ElementNames.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ElementNames.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -1,817 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.xml;
-
-//import com.metamatrix.common.config.api.ComponentObject;
-import com.metamatrix.common.config.util.ConfigurationPropertyNames;
-//import com.metamatrix.common.config.xml.XMLElementNames.Configurations.Configuration;
-
-/**
-* This class structure mimics the structure of a Configuration XML
-* document and defines all of the element and attribute names for that
-* document type.
-*/
-public interface XMLConfig_42_ElementNames {
-
- /**
- * This is used as the delimiter of all XML element names.
- */
- public static final String DELIMITER = "."; //$NON-NLS-1$
-
- /**
- * This should be the root Element name for all Configuration XML Documents.
- */
- public static final String ELEMENT = "ConfigurationDocument";
//$NON-NLS-1$
-
-
-
- /**
- * This is the class that represents the Configuration Element which contains
- * all of the XML elements that represent a Configuration object.
- */
- public static class Configuration {
-
- /**
- * This is the name of the Configurations Element.
- */
- public static final String ELEMENT = "Configuration";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- }
-
-
-
- /**
- * This is the class that represents the ProductServiceConfig Element which
contains
- * all of the XML elements that represent a ProductServiceConfig object.
- */
-// public static class ProductServiceConfig {
-//
-// /**
-// * This is the name of the ProductServiceConfig Element.
-// */
-// public static final String ELEMENT = "PSC"; //$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ComponentObject.Attributes{
-// }
-// }
-
-
- /**
- * This is the class that represents the Host Element which contains
- * all of the XML elements that represent a Host object.
- */
- public static class Host {
-
- /**
- * This is the name of the Host Element.
- */
- public static final String ELEMENT = "Host"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends Configuration.Attributes {
- }
- }
-
-
-
-
- /**
- * This is the class that represents the VMComponentDefns Element which
contains
- * all of the XML elements that represent a VMComponentDefns object.
- */
- public static class Process {
-
- /**
- * This is the name of the VMComponentDefns Element.
- */
- public static final String ELEMENT = "Process"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- }
-
- }
-
-
-
-
- /**
- * This is the class that represents the DeployedComponent Element which
contains
- * all of the XML elements that represent a DeployedComponent object.
- */
- public static class xDeployedComponent {
-
- /**
- * This is the name of the DeployedComponent Element.
- */
- public static final String ELEMENT = "DeployedService";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- public static final String HOST_ID = "HostID";
//$NON-NLS-1$
- // public static final String PRODUCT_SERVICE_CONFIG_ID =
"ProductServiceConfigID"; //$NON-NLS-1$
- public static final String SERVICE_COMPONENT_DEFN_ID =
"ServiceComponentDefnID"; //$NON-NLS-1$
- public static final String VM_COMPONENT_DEFN_ID =
"VMComponentDefnID"; //$NON-NLS-1$
- }
- }
-
-
- public static class DeployedService {
-
- /**
- * This is the name of the ServiceComponentDefn Element.
- */
- public static final String ELEMENT = "Service";
//$NON-NLS-1$
-
- public static class Attributes extends ComponentObject.Attributes{
- public static final String ROUTING_UUID =
"routingUUID"; //$NON-NLS-1$
- }
-
-
-
- }
-
-
- /**
- * This is the class that represents the ComponentDefnID Element which
contains
- * all of the XML elements that represent a ComponentDefnID object.
- */
-// public static final class ComponentDefnID{
-//
-// /**
-// * This is the name of the ComponentDefnID Element.
-// */
-// public static final String ELEMENT = "ComponentDefnID";
//$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ID.Attributes {
-// }
-// }
-
- /**
- * This is the class that represents the DeployedComponentID Element which
contains
- * all of the XML elements that represent a DeployedComponentID object.
- */
-// public static final class DeployedComponentID{
-//
-// /**
-// * This is the name of the DeployedComponentID Element.
-// */
-// public static final String ELEMENT = "DeployedComponentID";
//$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ID.Attributes {
-// }
-// }
-
- /**
- * This is the class that represents the ProductServiceConfigID Element which
contains
- * all of the XML elements that represent a ProductServiceConfigID object.
- */
-// public static final class ProductServiceConfigID{
-//
-// /**
-// * This is the name of the ProductServiceConfigID Element.
-// */
-// public static final String ELEMENT =
"ProductServiceConfigID"; //$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ID.Attributes {
-// }
-// }
-
- /**
- * This is the class that represents the VMComponentDefnID Element which
contains
- * all of the XML elements that represent a VMComponentDefnID object.
- */
-// public static final class VMComponentDefnID{
-//
-// /**
-// * This is the name of the VMComponentDefnID Element.
-// */
-// public static final String ELEMENT = "VMComponentDefnID";
//$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ID.Attributes {
-// }
-// }
-
- /**
- * This is the class that represents the VMComponentDefnID Element which
contains
- * all of the XML elements that represent a VMComponentDefnID object.
- */
-// public static final class ServiceComponentDefnID{
-//
-// /**
-// * This is the name of the ServiceComponentDefnID Element.
-// */
-// public static final String ELEMENT =
"ServiceComponentDefnID"; //$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ID.Attributes {
-// }
-// }
-
-
-
- }
-
- /**
- * This is the class that represents the ComponentObject Element which contains
- * all of the XML elements that represent a ComponentObject object.
- */
- public static class ComponentObject {
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- public static final String COMPONENT_TYPE = "ComponentType";
//$NON-NLS-1$
- }
- }
-
- /**
- * This is the class that represents the Properties Element which contains
- * all of the XML elements that represent a Properties object.
- */
- public static class Properties {
-
- /**
- * This is the name of the Properties Element.
- */
- public static final String ELEMENT = "Properties"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the Property Element which contains
- * all of the XML elements that represent a Property object.
- */
- public static class Property {
-
- /**
- * This is the name of the Property Element.
- */
- public static final String ELEMENT = "Property"; //$NON-NLS-1$
-
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- }
-
- }
- }
-
- /**
- * This is the class that represents the ChangeHistory Properties Element which
contains
- * all of the XML elements that represent the change information for the object.
- */
- public static class ChangeHistory {
-
- /**
- * This is the name of the ChangeHistory Element.
- */
- public static final String ELEMENT = "ChangeHistory"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the Property Element which contains
- * all of the XML elements that represent a Property object.
- */
- public static class Property {
-
- /**
- * This is the name of the Property Element.
- */
- public static final String ELEMENT = "Property"; //$NON-NLS-1$
-
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- }
-
- public static class NAMES {
- public static final String LAST_CHANGED_DATE = "LastChangedDate";
//$NON-NLS-1$
- public static final String LAST_CHANGED_BY = "LastChangedBy";
//$NON-NLS-1$
- public static final String CREATION_DATE = "CreationDate";
//$NON-NLS-1$
- public static final String CREATED_BY = "CreatedBy";
//$NON-NLS-1$
-
- }
- }
- }
-
-
- /**
- * This is the class that represents the ID Element which contains
- * all of the XML elements that represent a ID object.
- */
- public static class ID {
- // these are the shared attributes of all ID Elements
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- }
- }
-
-
- /**
- * This is the class that represents the ProductServiceConfigs Element which
contains
- * all of the XML elements that represent a ProductServiceConfigs object.
- */
-// public static class ProductServiceConfigs {
-//
-// /**
-// * This is the name of the ProductServiceConfigs Element.
-// */
-// public static final String ELEMENT = "ProductServiceConfigs";
//$NON-NLS-1$
-//
-//
-// /**
-// * This is the class that represents the ProductServiceConfig Element which
contains
-// * all of the XML elements that represent a ProductServiceConfig object.
-// */
-// public static class ProductServiceConfig {
-//
-//
-// /**
-// * This is the name of the ProductServiceConfig Element.
-// */
-// public static final String ELEMENT = "PSC"; //$NON-NLS-1$
-//
-// public static class Attributes extends ComponentObject.Attributes{
-// }
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-//
-// public static class Service {
-//
-// /**
-// * This is the name of the ServiceComponentDefn Element.
-// */
-// public static final String ELEMENT = "Service";
//$NON-NLS-1$
-//
-// public static class Attributes extends
ComponentObject.Attributes{
-// public static final String IS_ENABLED =
"IsEnabled"; //$NON-NLS-1$
-// }
-// }
-//
-// }
-// }
-//
-
- /**
- * This is the class that represents the ProductServiceConfigs Element which
contains
- * all of the XML elements that represent a ProductServiceConfigs object.
- */
- public static class ResourcePools {
-
- /**
- * This is the name of the ProductServiceConfigs Element.
- */
- public static final String ELEMENT = "ConnectionPools";
//$NON-NLS-1$
-
- /**
- * This is the class that represents the ProductServiceConfig Element which
contains
- * all of the XML elements that represent a ProductServiceConfig object.
- */
- public static class ResourcePool {
-
- /**
- * This is the name of the ProductServiceConfig Element.
- */
- public static final String ELEMENT = "ConnectionPool";
//$NON-NLS-1$
-
- public static class Attributes extends ComponentObject.Attributes{
-
- }
-
- }
- }
-
- /**
- * This is the class that represents the ProductServiceConfigs Element which
contains
- * all of the XML elements that represent a ProductServiceConfigs object.
- */
- public static class AuthenticationProviders {
-
- /**
- * This is the name of the ProductServiceConfigs Element.
- */
- public static final String ELEMENT = "AuthenticationProviders";
//$NON-NLS-1$
-
- /**
- * This is the class that represents the ProductServiceConfig Element which
contains
- * all of the XML elements that represent a ProductServiceConfig object.
- */
- public static class Provider {
-
- /**
- * This is the name of the ProductServiceConfig Element.
- */
- public static final String ELEMENT = "Provider"; //$NON-NLS-1$
-
- public static class Attributes extends ComponentObject.Attributes{
-
- }
-
- }
- }
-
-
- /**
- * This is the class that represents the Resources Element which contains
- * all of the XML elements that represent a Resource object.
- */
- public static class Resources {
-
- /**
- * This is the name of the Hosts Element.
- */
- public static final String ELEMENT = "SharedResources"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the Resource Element which contains
- * all of the XML elements that represent a Resource object.
- */
- public static class Resource {
-
- /**
- * This is the name of the Resource Element.
- */
- public static final String ELEMENT = "Resource"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- }
-
-
- }
- }
-
- /**
- * This is the class that represents the ServiceComponentDefns Element which contains
- * all of the XML elements that represent a ServiceComponentDefns object.
- */
- public static class ConnectorComponents {
-
- /**
- * This is the name of the ServiceComponentDefns Element.
- */
- public static final String ELEMENT = "ConnectorBindings";
//$NON-NLS-1$
-
- /**
- * This is the class that represents the ConnectorBinding Element which contains
- * all of the XML elements that represent a ConnectorBinding object.
- */
- public static class ConnectorComponent {
-
- /**
- * This is the name of the ConnectorBinding Element.
- */
- public static final String ELEMENT = "Connector"; //$NON-NLS-1$
-
- public static class Attributes extends ComponentObject.Attributes{
- public static final String QUEUED_SERVICE = "QueuedService";
//$NON-NLS-1$
-// public static final String IS_ENABLED = "IsEnabled";
- public static final String ROUTING_UUID = "routingUUID";
//$NON-NLS-1$
- }
- }
- }
-
-
-
- /**
- * This is the class that represents the ComponentTypeID Element which contains
- * all of the XML elements that represent a ComponentTypeID object.
- */
- public static class ComponentTypeID {
-
- /**
- * This is the name of the ComponentTypeID Element.
- */
- public static final String ELEMENT = "ComponentTypeID"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
-
- }
-
- /**
- * This is the class that represents the ComponentTypes Element which contains
- * all of the XML elements that represent a ComponentTypes object.
- */
- public static class ComponentTypes {
-
- /**
- * This is the name of the ComponentTypes Element.
- */
- public static final String ELEMENT = "ComponentTypes"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the ComponentType Element which contains
- * all of the XML elements that represent a ComponentType object.
- */
- public static class ComponentType {
-
- /**
- * This is the name of the ComponentType Element.
- */
- public static final String ELEMENT = "ComponentType";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- public static final String PARENT_COMPONENT_TYPE =
"ParentComponentType"; //$NON-NLS-1$
- public static final String SUPER_COMPONENT_TYPE =
"SuperComponentType"; //$NON-NLS-1$
- public static final String COMPONENT_TYPE_CODE =
"ComponentTypeCode"; //$NON-NLS-1$
- public static final String DEPLOYABLE = "Deployable";
//$NON-NLS-1$
- public static final String DEPRECATED = "Deprecated";
//$NON-NLS-1$
- public static final String MONITORABLE = "Monitorable";
//$NON-NLS-1$
- public static final String DESCRIPTION = "Description";
//$NON-NLS-1$
- }
-
-
- /**
- * This is the class that represents the ComponentTypeDefn Element which
contains
- * all of the XML elements that represent a ComponentTypeDefn object.
- */
- public static class ComponentTypeDefn {
-
- /**
- * This is the name of the ComponentTypeDefn Element.
- */
- public static final String ELEMENT = "ComponentTypeDefn";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String DEPRECATED = "Deprecated";
//$NON-NLS-1$
- }
-
- /**
- * This is the class that represents the PropertyDefinition Element which
contains
- * all of the XML elements that represent a PropertyDefinition object.
- */
- public static class PropertyDefinition {
-
- /**
- * This is the name of the PropertyDefinition Element.
- */
- public static final String ELEMENT = "PropertyDefinition";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name";
//$NON-NLS-1$
- public static final String DISPLAY_NAME =
"DisplayName"; //$NON-NLS-1$
- public static final String SHORT_DESCRIPTION
="ShortDescription"; //$NON-NLS-1$
- public static final String DEFAULT_VALUE =
"DefaultValue"; //$NON-NLS-1$
- public static final String MULTIPLICITY =
"Multiplicity"; //$NON-NLS-1$
- public static final String PROPERTY_TYPE =
"PropertyType"; //$NON-NLS-1$
- public static final String VALUE_DELIMITER =
"ValueDelimiter"; //$NON-NLS-1$
- public static final String IS_CONSTRAINED_TO_ALLOWED_VALUES =
"IsConstrainedToAllowedValues"; //$NON-NLS-1$
- public static final String IS_EXPERT = "IsExpert";
//$NON-NLS-1$
- public static final String IS_HIDDEN = "IsHidden";
//$NON-NLS-1$
- public static final String IS_MASKED = "IsMasked";
//$NON-NLS-1$
- public static final String IS_MODIFIABLE =
"IsModifiable"; //$NON-NLS-1$
- public static final String IS_PREFERRED =
"IsPreferred"; //$NON-NLS-1$
- public static final String REQUIRES_RESTART =
"RequiresRestart"; //$NON-NLS-1$
- }
-
- /**
- * This is the class that represents the AllowedValue Element which
contains
- * all of the XML elements that represent a AllowedValue object.
- */
- public static class AllowedValue {
-
- /**
- * This is the name of the AllowedValue Element.
- */
- public static final String ELEMENT = "AllowedValue";
//$NON-NLS-1$
- }
-
- }
-
- }
- }
- }
-
- /**
- * This is the class that represents the ProductTypes Element which contains
- * all of the XML elements that represent a ProductType object.
- */
-// public static class ProductTypes {
-// public static final String ELEMENT = "ProductTypes"; //$NON-NLS-1$
-//
-// /**
-// * This is the class that represents the ProductType Element which contains
-// * all of the XML elements that represent a ProductType object.
-// * Note that it extends teh ComponentType element definition.
-// */
-// public static class ProductType extends ComponentTypes.ComponentType{
-// public static final String ELEMENT = "ProductType";
//$NON-NLS-1$
-// }
-// }
-
-
- /**
- * This is the class that represents the ServiceComponentDefns Element which
contains
- * all of the XML elements that represent a ServiceComponentDefns object.
- */
- public static class ServiceComponentDefns {
-
- /**
- * This is the name of the ServiceComponentDefns Element.
- */
- public static final String ELEMENT = "Services"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the ServiceComponentDefn Element which
contains
- * all of the XML elements that represent a ServiceComponentDefn object.
- */
- public static class ServiceComponentDefn {
-
- /**
- * This is the name of the ServiceComponentDefn Element.
- */
- public static final String ELEMENT = "Service"; //$NON-NLS-1$
-
- public static class Attributes extends ComponentObject.Attributes{
- public static final String QUEUED_SERVICE = "QueuedService";
//$NON-NLS-1$
- public static final String ROUTING_UUID = "routingUUID";
//$NON-NLS-1$
- }
- }
- }
-
-
-
- public static class Header {
-
- /**
- * This is the name of the Header Element.
- */
- public static final String ELEMENT = "Header"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the UserName Element which contains
- * all of the XML elements that represent a UserName object.
- */
- public static class UserCreatedBy {
-
- /**
- * This is the name of the UserName Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.USER_CREATED_BY;
- }
-
- /**
- * This is the class that represents the ApplicationCreatedDate Element which
contains
- * all of the XML elements that represent a ApplicationCreatedDate object.
- */
- public static class ApplicationCreatedBy {
-
- /**
- * This is the name of the ApplicationCreatedDate Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.APPLICATION_CREATED_BY;
- }
-
- /**
- * This is the class that represents the ApplicationVersionCreatedBy Element
which contains
- * all of the XML elements that represent a ApplicationVersionCreatedBy
object.
- */
- public static class ApplicationVersionCreatedBy {
-
- /**
- * This is the name of the ApplicationVersionCreatedBy Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY;
- }
-
- /**
- * This is the class that represents the Time Element which contains
- * all of the XML elements that represent a Time object.
- */
- public static class Time {
-
- /**
- * This is the name of the Time Element.
- */
- public static final String ELEMENT = ConfigurationPropertyNames.TIME;
- }
-
- /**
- * This is the class that represents the DocumentTypeVersion Element which
contains
- * all of the XML elements that represent a DocumentTypeVersion object.
- */
- public static class ConfigurationVersion {
-
- /**
- * This is the name of the DocumentTypeVersion Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.CONFIGURATION_VERSION;
- }
-
- /**
- * This is the class that represents the MetaMatrixServerVersion Element
which contains
- * all of the XML elements that represent a ProductServiceConfigs object.
- */
- public static class MetaMatrixSystemVersion {
-
- /**
- * This is the name of the MetaMatrixServerVersion Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.METAMATRIX_SYSTEM_VERSION;
- }
- }
-
-
-}
Deleted:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -1,2525 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.xml;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jdom.Element;
-
-import com.metamatrix.admin.api.objects.PropertyDefinition.RestartType;
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.config.api.AuthenticationProvider;
-import com.metamatrix.common.config.api.ComponentDefn;
-import com.metamatrix.common.config.api.ComponentObject;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeDefn;
-import com.metamatrix.common.config.api.ComponentTypeID;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConfigurationInfo;
-import com.metamatrix.common.config.api.ConfigurationObjectEditor;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.ConnectorBindingID;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.config.api.Host;
-import com.metamatrix.common.config.api.HostID;
-import com.metamatrix.common.config.api.ResourceDescriptor;
-import com.metamatrix.common.config.api.ServiceComponentDefn;
-import com.metamatrix.common.config.api.ServiceComponentDefnID;
-import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.config.api.VMComponentDefn;
-import com.metamatrix.common.config.api.VMComponentDefnID;
-import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
-import com.metamatrix.common.config.model.BasicComponentObject;
-import com.metamatrix.common.config.model.BasicComponentType;
-import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
-import com.metamatrix.common.config.model.BasicUtil;
-import com.metamatrix.common.config.model.BasicVMComponentDefn;
-import com.metamatrix.common.config.util.ConfigurationPropertyNames;
-import com.metamatrix.common.config.util.InvalidConfigurationElementException;
-import com.metamatrix.common.log.LogConfiguration;
-import com.metamatrix.common.namedobject.BaseID;
-import com.metamatrix.common.object.Multiplicity;
-import com.metamatrix.common.object.MultiplicityExpressionException;
-import com.metamatrix.common.object.PropertyDefinition;
-import com.metamatrix.common.object.PropertyDefinitionImpl;
-import com.metamatrix.common.object.PropertyType;
-import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.DateUtil;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.MetaMatrixProductVersion;
-//import com.metamatrix.common.util.LogCommonConstants;
-/**
-* This helper class is used to create JDOM XML Elements from configuration objects
-* and to create Configuration objects from JDOM XML Elements.
-*
-*
-* NOTE - The helper cannot have any calls to LogManager because the bootstrapping of
-* the CurrentConfiguration
-* uses this class and the CurrentConfiguration has to come up before
-* logging is available.
-*
-*/
-public class XMLConfig_42_HelperImpl implements XMLHelper, ConfigurationPropertyNames
{
-
-
-
- /**
- * @see
com.metamatrix.common.config.xml.XMLHelper#createDeployedComponent(org.jdom.Element,
com.metamatrix.common.config.api.ConfigurationID, com.metamatrix.common.config.api.HostID,
com.metamatrix.common.config.api.VMComponentDefnID,
com.metamatrix.common.config.api.ProductServiceConfigID, java.util.Map,
com.metamatrix.common.config.api.ConfigurationObjectEditor)
- * @since 4.1
- */
-// public DeployedComponent createDeployedComponent(Element element,
-// ConfigurationID configID,
-// HostID hostID,
-// VMComponentDefnID vmID,
-// Map componentTypeMap,
-// ConfigurationObjectEditor editor)
throws InvalidConfigurationElementException {
-// return null;
-// }
- /**
- * This method is used to create a Configuration JDOM Element from a
- * Configuration object.
- *
- * @param configuration the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createConfigurationElement(Configuration configuration) {
- // first we set up the organizational structure of a configuration
- Assertion.isNotNull(configuration);
-// Element productServiceConfigsElement = new
Element(XMLConfig_42__ElementNames.Configuration.ProductServiceConfigs.ELEMENT);
-// Element serviceDefnsElement = createServiceComponentDefnsElement();
-// Element deployedComponentsElement = new
Element(XMLConfig_42__ElementNames.Configuration.DeployedComponents.ELEMENT);
-// Element vmComponentDefnsElement = new
Element(XMLConfig_42__ElementNames.Configuration.VMComponentDefns.ELEMENT);
-// Element resourcePoolsElement = new
Element(XMLConfig_42__ElementNames.Configuration.ResourcePools.ELEMENT);
-
-
- Element configElement =
createComponentObjectElement(XMLConfig_42_ElementNames.Configuration.ELEMENT,
configuration);
-
-// Element logConfigurationElement =
createLogConfigurationElement(configuration.getLogConfiguration());
-
-// configElement.addContent(productServiceConfigsElement);
-// configElement.addContent(serviceDefnsElement);
-// configElement.addContent(deployedComponentsElement);
-// configElement.addContent(vmComponentDefnsElement);
-// configElement.addContent(logConfigurationElement);
-// configElement.addContent(resourcePoolsElement);
-
- return configElement;
- }
-
- /**
- * This method is used to create a LogConfiguration JDOM Element from a
- * LogConfiguration object.
- *
- * @param info the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createLogConfigurationElement(LogConfiguration logConfiguration) {
- throw new UnsupportedOperationException("Method
createLogConfigurationElement is unsupported in 4.2"); //$NON-NLS-1$
-
-// Assertion.isNotNull(logConfiguration);
-//
-// Element logConfigurationElement = new
Element(XMLConfig_42__ElementNames.Configuration.LogConfiguration.ELEMENT);
-// Element propertiesElement = null;
-// try {
-// propertiesElement =
createPropertiesElement(BasicLogConfiguration.getLogConfigurationProperties(logConfiguration));
-// logConfigurationElement.addContent(propertiesElement);
-//
-// }catch(LogConfigurationException e) {
-// String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0031);
-// System.out.println(msg);
-// }
-//
-//
-// return logConfigurationElement;
- }
-
-
- /**
- * This method is used to create a ConfigurationInfo JDOM Element from a
- * ConfigurationInfo object.
- *
- * @param info the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createConfigurationInfoElement(ConfigurationInfo info) {
- throw new UnsupportedOperationException("Method
createConfigurationInfoElement is unsupported in 4.2"); //$NON-NLS-1$
-
-// Assertion.isNotNull(info);
-//
-// Element configurationInfoElement = new
Element(XMLConfig_42__ElementNames.Configuration.ConfigurationInfo.ELEMENT);
-//
-// Date date = info.getLastChangedDate();
-// if (date != null) {
-//
configurationInfoElement.setAttribute(XMLConfig_42__ElementNames.Configuration.ConfigurationInfo.Attributes.LAST_CHANGED_DATE,
date.toString());
-// }
-//
-// date = info.getCreationDate();
-// if (date !=null) {
-//
configurationInfoElement.setAttribute(XMLConfig_42__ElementNames.Configuration.ConfigurationInfo.Attributes.CREATION_DATE,
date.toString());
-// }
-// return configurationInfoElement;
- }
-
- /**
- * This method is used to create a DeployedComponent JDOM Element from a
- * DeployedComponent object.
- *
- * @param deployedComponent the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createDeployedComponentElement(DeployedComponent deployedComponent) {
- Assertion.isNotNull(deployedComponent);
-
-// String vmComponentName = null;
-// String productConfigName = null;
-
- Element deployedComponentElement =
createComponentObjectElement(XMLConfig_42_ElementNames.Configuration.DeployedService.ELEMENT,
deployedComponent);
-
-
-// VMComponentDefnID vmComponentID = deployedComponent.getVMComponentDefnID();
-// ProductServiceConfigID productConfigID =
deployedComponent.getProductServiceConfigID();
-
-
-// // we treat these IDs specially because they are optional for Deployed
-// // Components that are VM's
-// if (vmComponentID!=null) {
-// vmComponentName = vmComponentID.getName();
-//
deployedComponentElement.setAttribute(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.VM_COMPONENT_DEFN_ID,
vmComponentName);
-// }
-//
-// if (productConfigID!=null) {
-// productConfigName = productConfigID.getName();
-//
deployedComponentElement.setAttribute(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.PRODUCT_SERVICE_CONFIG_ID,
productConfigName);
-// }
-
-// BaseID id = deployedComponent.getServiceComponentDefnID();
-// if (id!=null) {
-//
deployedComponentElement.setAttribute(XMLConfig_42_ElementNames.Configuration.DeployedService.Attributes.SERVICE_COMPONENT_DEFN_ID,
id.getName());
-// }
-
-
-
-// id = deployedComponent.getHostID();
-// if (id!=null) {
-//
deployedComponentElement.setAttribute(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.HOST_ID,
id.getName());
-// }
-
- return deployedComponentElement;
- }
-
- /**
- * This method is used to create a VMComponentDefn JDOM Element from a
- * VMComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createVMComponentDefnElement(VMComponentDefn defn) {
- Assertion.isNotNull(defn);
-
- Element vmComponentDefnElement =
createComponentObjectElement(XMLConfig_42_ElementNames.Configuration.Process.ELEMENT,
defn);
- return vmComponentDefnElement;
- }
-
- public Element createDeployedServiceComponentDefnElement(ServiceComponentDefn defn)
{
- Assertion.isNotNull(defn);
-
- Element serviceComponentDefnElement =
createComponentObjectElement(XMLConfig_42_ElementNames.Configuration.DeployedService.ELEMENT,
defn);
-
serviceComponentDefnElement.setAttribute(XMLConfig_42_ElementNames.Configuration.DeployedService.Attributes.ROUTING_UUID,
defn.getRoutingUUID());
- return serviceComponentDefnElement;
- }
-
- /**
- * This method is used to create a ServiceComponentDefn JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createServiceComponentDefnElement(ServiceComponentDefn defn) {
- Assertion.isNotNull(defn);
-
- Element serviceComponentDefnElement =
createComponentObjectElement(XMLConfig_42_ElementNames.ServiceComponentDefns.ServiceComponentDefn.ELEMENT,
defn);
-
serviceComponentDefnElement.setAttribute(XMLConfig_42_ElementNames.ServiceComponentDefns.ServiceComponentDefn.Attributes.ROUTING_UUID,
defn.getRoutingUUID());
- return serviceComponentDefnElement;
- }
-
-
- /**
- * This method is used to create a ServiceComponentDefn JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createAuthenticationProviderElement(AuthenticationProvider defn) {
- Assertion.isNotNull(defn);
-
- Element serviceComponentDefnElement =
createComponentObjectElement(XMLConfig_42_ElementNames.AuthenticationProviders.Provider.ELEMENT,
defn);
- return serviceComponentDefnElement;
- }
- /**
- * This method is used to create a ServiceComponentDefn JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-// public Element createServiceComponentDefnElement(ResourceDescriptor defn) {
-// Assertion.isNotNull(defn);
-//
-// Element serviceComponentDefnElement =
createComponentObjectElement(XMLConfig_42_ElementNames.ServiceComponentDefns.ServiceComponentDefn.ELEMENT,
defn);
-// return serviceComponentDefnElement;
-// }
-
-// public Element createDeployedProductServiceConfigElement(ProductServiceConfig
config) {
-// Assertion.isNotNull(config);
-//
-// Element productServiceConfigElement =
createComponentObjectElement(XMLConfig_42_ElementNames.Configuration.ProductServiceConfig.ELEMENT,
config);
-//
-// return productServiceConfigElement;
-// }
-//
-// public Element createProductServiceConfigsElement() {
-// return new Element(XMLConfig_42_ElementNames.ProductServiceConfigs.ELEMENT);
-//
-// }
-
-
-
-
- /**
- * This method is used to create a ProductServiceConfig JDOM Element from a
- * ProductServiceConfig object.
- *
- * @param config the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-// public Element createProductServiceConfigElement(ProductServiceConfig config) {
-// Assertion.isNotNull(config);
-//
-// Element productServiceConfigElement =
createComponentObjectElement(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.ELEMENT,
config);
-//
-// Iterator iterator = config.getServiceComponentDefnIDs().iterator();
-// while (iterator.hasNext()) {
-// ServiceComponentDefnID id = (ServiceComponentDefnID)iterator.next();
-// boolean isEnabled = config.isServiceEnabled(id);
-//
-// Element idElement =
createIDElement(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.ELEMENT,
id.getName());
-//
-// idElement.setAttribute(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.Attributes.IS_ENABLED,
(Boolean.valueOf(isEnabled)).toString());
-//
-// productServiceConfigElement.addContent(idElement);
-// }
-// return productServiceConfigElement;
-// }
-
- /**
- * This method is used to create a ComponentType JDOM Element from a
- * ComponentType object.
- *
- * @param type the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createComponentTypeElement(ComponentType type) {
- Assertion.isNotNull(type);
-
- Element componentTypeElement = new
Element(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ELEMENT);
- Iterator iterator = type.getComponentTypeDefinitions().iterator();
- while (iterator.hasNext()) {
- ComponentTypeDefn defn = (ComponentTypeDefn)iterator.next();
-// Element componentTypeDefnElement = createComponentTypeDefnElement(defn);
- Element propertyDefinitionElement =
createPropertyDefinitionElement(defn.getPropertyDefinition());
-// componentTypeDefnElement.addContent(propertyDefinitionElement);
- componentTypeElement.addContent(propertyDefinitionElement);
- }
-
componentTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.NAME,
type.getName());
-
- if (type.getDescription() != null) {
-
componentTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.DESCRIPTION,
type.getDescription());
- }
-
-
componentTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE,
new Integer(type.getComponentTypeCode()).toString());
-
componentTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE,
(Boolean.valueOf(type.isDeployable())).toString());
-
componentTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.DEPRECATED,
(Boolean.valueOf(type.isDeprecated())).toString());
-
componentTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE,
(Boolean.valueOf(type.isMonitored())).toString());
- // we only add these if they are not null
- BaseID superID = type.getSuperComponentTypeID();
- String superIDString;
- if (superID != null) {
- superIDString = superID.getName();
-
componentTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE,
superIDString);
-
- }
-
- BaseID parentID = type.getParentComponentTypeID();
- String parentIDString;
- if (parentID!=null) {
- parentIDString = parentID.getName();
-
componentTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.PARENT_COMPONENT_TYPE,
parentIDString);
-
- }
-
- addChangeHistoryElement(type, componentTypeElement);
-// componentTypeElement.addContent(chgHistoryElement);
-
-
- return componentTypeElement;
- }
-
- /**
- * This method is used to create a PropertyDefinition JDOM Element from a
- * PropertyDefinition object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createPropertyDefinitionElement(PropertyDefinition defn) {
- Assertion.isNotNull(defn);
-
-
- Element element = new
Element(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT);
-
- String name = defn.getName();
-
element.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.NAME,
name);
-
- String displayName = defn.getDisplayName();
-
element.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DISPLAY_NAME,displayName);
-
-
- setAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.SHORT_DESCRIPTION,
- defn.getShortDescription(),
PropertyDefinitionImpl.DEFAULT_SHORT_DESCRIPTION);
-
- Object value = defn.getDefaultValue();
- if (value!=null) {
- setAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DEFAULT_VALUE,
- value.toString(),
PropertyDefinitionImpl.DEFAULT_DEFAULT_VALUE);
- }
-
- Multiplicity mult = defn.getMultiplicity();
- if (mult!=null) {
- setAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.MULTIPLICITY,
- mult.toString(),
PropertyDefinitionImpl.DEFAULT_MULTIPLICITY);
- }
-
- PropertyType type = defn.getPropertyType();
- if (type != null) {
- setAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.PROPERTY_TYPE,
- type.getDisplayName(),
PropertyDefinitionImpl.DEFAULT_TYPE.getDisplayName());
- }
-
-
- setAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.VALUE_DELIMITER,
- defn.getValueDelimiter(),
PropertyDefinitionImpl.DEFAULT_DELIMITER);
-
- setAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_CONSTRAINED_TO_ALLOWED_VALUES,
- defn.isConstrainedToAllowedValues(),
PropertyDefinitionImpl.DEFAULT_IS_CONSTRAINED);
-
- setAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_EXPERT,
- defn.isExpert(), PropertyDefinitionImpl.DEFAULT_IS_EXPERT);
-
- setAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_HIDDEN,
- defn.isHidden(), PropertyDefinitionImpl.DEFAULT_IS_HIDDEN);
-
- setAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MASKED,
- defn.isMasked(), PropertyDefinitionImpl.DEFAULT_IS_MASKED);
-
- setAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MODIFIABLE,
- defn.isModifiable(),
PropertyDefinitionImpl.DEFAULT_IS_MODIFIABLE);
-
- setAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_PREFERRED,
- defn.isPreferred(),
PropertyDefinitionImpl.DEFAULT_IS_PREFERRED);
-
- setAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.REQUIRES_RESTART,
- defn.getRequiresRestart().toString(),
PropertyDefinitionImpl.DEFAULT_REQUIRES_RESTART.toString());
-
-
- List allowedValues = defn.getAllowedValues();
- Iterator iterator = allowedValues.iterator();
- while (iterator.hasNext()) {
- Element allowedValueElement = new
Element(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.AllowedValue.ELEMENT);
- allowedValueElement.addContent((iterator.next()).toString());
- element.addContent(allowedValueElement);
- }
-
- return element;
-
- }
-
-
-
- /**
- * Set the specified attribute on the on the specified element, only if it's not
the default value.
- * @param element Element to modify
- * @param attributeName name of Attribute to set
- * @param value Value to set
- * @param defaultValue If value==default value, don't set anything.
- * @since 4.3
- */
- private static void setAttributeString(Element element, String attributeName, String
value, String defaultValue) {
- if (value != null && ! EquivalenceUtil.areEqual(value, defaultValue)) {
- element.setAttribute(attributeName, value);
- }
- }
- /**
- * Set the specified attribute on the on the specified element, only if it's not
the default value.
- * @param element Element to modify
- * @param attributeName name of Attribute to set
- * @param value Value to set
- * @param defaultValue If value==default value, don't set anything.
- * @since 4.3
- */
- private static void setAttributeBoolean(Element element, String attributeName,
boolean value, boolean defaultValue) {
- if (! value == defaultValue) {
- String valueString = String.valueOf(value);
- element.setAttribute(attributeName, valueString);
- }
- }
-
-
- /**
- * This method is used to create a ComponentTypeDefn JDOM Element from a
- * ComponentTypeDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createComponentTypeDefnElement(ComponentTypeDefn defn) {
- Assertion.isNotNull(defn);
-
- Element componentTypeDefnElement = new
Element(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
-
componentTypeDefnElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.Attributes.DEPRECATED,
(Boolean.valueOf(defn.isDeprecated())).toString());
- return componentTypeDefnElement;
- }
-
- /**
- * This method is used to create a ProductType JDOM Element from a
- * ProductType object.
- *
- * @param type the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-// public Element createProductTypeElement(ProductType type) {
-// Assertion.isNotNull(type);
-//
-// Element productTypeElement = new
Element(XMLConfig_42_ElementNames.ProductTypes.ProductType.ELEMENT);
-//
-// Iterator iterator = type.getComponentTypeIDs().iterator();
-// while (iterator.hasNext()) {
-// ComponentTypeID id = (ComponentTypeID)iterator.next();
-// Element componentTypeIDElement =
createIDElement(XMLConfig_42_ElementNames.ComponentTypeID.ELEMENT, id.getName());
-// productTypeElement.addContent(componentTypeIDElement);
-// }
-//
-//
-//
productTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.NAME,
type.getName());
-//
productTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE,
new Integer(type.getComponentTypeCode()).toString());
-//
productTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE,
(Boolean.valueOf(type.isDeployable())).toString());
-//
productTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.DEPRECATED,
(Boolean.valueOf(type.isDeprecated())).toString());
-//
productTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE,
(Boolean.valueOf(type.isMonitored())).toString());
-//
-// // we only add these if they are not null
-// BaseID superID = type.getSuperComponentTypeID();
-// String superIDString;
-// if (superID != null) {
-// superIDString = superID.getName();
-//
productTypeElement.setAttribute(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE,
superIDString);
-//
-// }
-//
-// addChangeHistoryElement(type, productTypeElement);
-//
-//
-// return productTypeElement;
-//
-// }
-
- /**
- * This method is used to create a Host JDOM Element from a
- * Host object.
- *
- * @param host the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createDeployedHostElement(Host host) {
- Assertion.isNotNull(host);
-
- Element hostElement =
createComponentObjectElement(XMLConfig_42_ElementNames.Configuration.Host.ELEMENT, host);
- return hostElement;
- }
-
- public Element createDeployedVMElementx(DeployedComponent vm) {
- Assertion.isNotNull(vm);
-
- Element hostElement =
createComponentObjectElement(XMLConfig_42_ElementNames.Configuration.Host.ELEMENT, vm);
- return hostElement;
- }
-
- public final boolean is42ConfigurationCompatible(Element root) throws
InvalidConfigurationElementException{
- Element headerElement = root.getChild(XMLConfig_42_ElementNames.Header.ELEMENT);
- if (headerElement == null) {
- throw new InvalidConfigurationElementException("The header element is
not found in the configuration under element.", root.getName()); //$NON-NLS-1$
- }
-
- Properties props = getHeaderProperties(headerElement);
-
-
- String sVersion =
props.getProperty(XMLConfig_42_ElementNames.Header.ConfigurationVersion.ELEMENT);
-
- if (sVersion == null) {
- return false;
- }
- try {
- double sv = Double.parseDouble(sVersion);
- if (sv == ConfigurationPropertyNames.MM_LATEST_CONFIG_VERSION) {
- return true;
- }
- } catch (Throwable t) {
- return false;
- }
- return true;
- }
-
- public Properties getHeaderProperties(Element element) throws
InvalidConfigurationElementException{
- Properties props=new Properties();
-
- if (!element.getName().equals(XMLConfig_42_ElementNames.Header.ELEMENT)) {
- throw new InvalidConfigurationElementException("This is not the header
element: " + element.getName() + ".", element); //$NON-NLS-1$
//$NON-NLS-2$
- }
-
- List elements = element.getChildren();
- Iterator it = elements.iterator();
- while(it.hasNext()) {
- final Element e = (Element) it.next();
- props.setProperty(e.getName(), e.getText());
- }
-
-
- return props;
- }
-
-
- /**
- * <p>This method is used to create a Header JDOM Element from a
- * Properties object. The properties object can contain any of the
- * following properties that will be included in the header:<p>
- * <pre>
- * XMLConfig_42_ElementNames.Header.ApplicationCreatedDate.ELEMENT
- * XMLConfig_42_ElementNames.Header.ApplicationVersionCreatedBy.ELEMENT
- * XMLConfig_42_ElementNames.Header.UserName.ELEMENT
- * XMLConfig_42_ElementNames.Header.DocumentTypeVersion.ELEMENT
- * XMLConfig_42_ElementNames.Header.MetaMatrixServerVersion.ELEMENT
- * XMLConfig_42_ElementNames.Header.Time.ELEMENT
- * <pre>
- * <p>Any of these properties that are not included in the properties object
- * will not be included in the header Element that is returned.
- *
- * @param props the properties object that contains the values for the Header
- * @return a JDOM XML Element
- */
- public Element createHeaderElement(Properties props) {
- Assertion.isNotNull(props);
-
- Element headerElement = new Element(XMLConfig_42_ElementNames.Header.ELEMENT);
- String applicationCreatedByContent =
props.getProperty(XMLConfig_42_ElementNames.Header.ApplicationCreatedBy.ELEMENT);
- String applicationVersionCreatedByContent =
props.getProperty(XMLConfig_42_ElementNames.Header.ApplicationVersionCreatedBy.ELEMENT);
- String userNameContent =
props.getProperty(XMLConfig_42_ElementNames.Header.UserCreatedBy.ELEMENT);
- String configVersionContent =
props.getProperty(XMLConfig_42_ElementNames.Header.ConfigurationVersion.ELEMENT);
- String serverVersionContent =
props.getProperty(XMLConfig_42_ElementNames.Header.MetaMatrixSystemVersion.ELEMENT);
- String timeContent =
props.getProperty(XMLConfig_42_ElementNames.Header.Time.ELEMENT);
-
-
- if (configVersionContent !=null) {
- Element configurationVersion = new
Element(XMLConfig_42_ElementNames.Header.ConfigurationVersion.ELEMENT);
- configurationVersion.addContent(configVersionContent);
- headerElement.addContent(configurationVersion);
- }
-
- if (applicationCreatedByContent !=null) {
- Element applicationCreatedBy = new
Element(XMLConfig_42_ElementNames.Header.ApplicationCreatedBy.ELEMENT);
- applicationCreatedBy.addContent(applicationCreatedByContent);
- headerElement.addContent(applicationCreatedBy);
- }
-
- if (applicationVersionCreatedByContent != null) {
- Element applicationVersionCreatedBy = new
Element(XMLConfig_42_ElementNames.Header.ApplicationVersionCreatedBy.ELEMENT);
- applicationVersionCreatedBy.addContent(applicationVersionCreatedByContent);
- headerElement.addContent(applicationVersionCreatedBy);
- }
-
- if (userNameContent != null) {
- Element userName = new
Element(XMLConfig_42_ElementNames.Header.UserCreatedBy.ELEMENT);
- userName.addContent(userNameContent);
- headerElement.addContent(userName);
- }
-
- if (serverVersionContent != null) {
- Element serverVersion = new
Element(XMLConfig_42_ElementNames.Header.MetaMatrixSystemVersion.ELEMENT);
- serverVersion.addContent(serverVersionContent);
- headerElement.addContent(serverVersion);
- }
-
- if (timeContent != null) {
- Element time = new Element(XMLConfig_42_ElementNames.Header.Time.ELEMENT);
- time.addContent(timeContent);
- headerElement.addContent(time);
- }
- return headerElement;
-
- }
-
- private ComponentObject setDateHistory(ComponentObject defn, Element element,
ConfigurationObjectEditor editor) {
-
- String lastChangedBy=null;
- String lastChangedDate=null;
- String createdDate=null;
- String createdBy=null;
-
- Properties props = getChangeHistoryFromElement(element);
-
- if (props != null && props.size() > 0) {
- lastChangedBy =
props.getProperty(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
- lastChangedDate =
props.getProperty(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
- createdBy =
props.getProperty(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
- createdDate =
props.getProperty(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
- } else {
-
- lastChangedBy =
element.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
- lastChangedDate =
element.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
- createdBy =
element.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
- createdDate =
element.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
- }
-
- lastChangedBy = (lastChangedBy!=null?lastChangedBy:""); //$NON-NLS-1$
- lastChangedDate =
(lastChangedDate!=null?lastChangedDate:DateUtil.getCurrentDateAsString());
- createdBy = (createdBy!=null?createdBy:""); //$NON-NLS-1$
- createdDate = (createdDate!=null?createdDate:DateUtil.getCurrentDateAsString());
-
-
- defn = editor.setCreationChangedHistory(defn, createdBy, createdDate);
- defn = editor.setLastChangedHistory(defn, lastChangedBy, lastChangedDate);
-
- return defn;
-
- }
-
- private ComponentType setDateHistory(ComponentType type, Element element,
ConfigurationObjectEditor editor) {
- String lastChangedBy=null;
- String lastChangedDate=null;
- String createdDate=null;
- String createdBy=null;
-
- Properties props = getChangeHistoryFromElement(element);
-
- if (props != null && props.size() > 0) {
- lastChangedBy =
props.getProperty(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
- lastChangedDate =
props.getProperty(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
- createdBy =
props.getProperty(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
- createdDate =
props.getProperty(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
- } else {
-
- lastChangedBy =
element.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
- lastChangedDate =
element.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
- createdBy =
element.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
- createdDate =
element.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
- }
-
- lastChangedBy = (lastChangedBy!=null?lastChangedBy:""); //$NON-NLS-1$
- lastChangedDate =
(lastChangedDate!=null?lastChangedDate:DateUtil.getCurrentDateAsString());
- createdBy = (createdBy!=null?createdBy:""); //$NON-NLS-1$
- createdDate = (createdDate!=null?createdDate:DateUtil.getCurrentDateAsString());
-
- type = editor.setCreationChangedHistory(type, createdBy, createdDate);
- type = editor.setLastChangedHistory(type, lastChangedBy, lastChangedDate);
-
- return type;
-
- }
-
-
- private Properties getChangeHistoryFromElement(Element parentElement) {
-
- Element propertiesElement =
parentElement.getChild(XMLConfig_42_ElementNames.ChangeHistory.ELEMENT);
-
- if (propertiesElement == null ) {
- return new Properties();
- }
-
- Properties props = new Properties();
-
- List properties =
propertiesElement.getChildren(XMLConfig_42_ElementNames.ChangeHistory.Property.ELEMENT);
- if (properties == null) {
- return new Properties();
- }
- Iterator iterator = properties.iterator();
- while (iterator.hasNext()) {
- Element propertyElement = (Element)iterator.next();
- String propertyName =
propertyElement.getAttributeValue(XMLConfig_42_ElementNames.ChangeHistory.Property.Attributes.NAME);
- String propertyValue = propertyElement.getText();
-
- props.setProperty(propertyName,
(propertyValue!=null?propertyValue:"")); //$NON-NLS-1$
-
- }
- return props;
-
- }
-
-
-// private Element addChangeHistoryElementx(ComponentType obj) {
-//
-//// call to create the structure for the properties
-// Element changeHistoryElement = new
Element(XMLConfig_42_ElementNames.ChangeHistory.ELEMENT);
-//
-// String lastChangedBy=null;
-// String lastChangedDate=null;
-// String createdDate=null;
-// String createdBy=null;
-//
-// lastChangedBy = obj.getLastChangedBy();
-// lastChangedDate = ((BasicComponentType) obj).getLastChangedDateString();
-//
-// createdBy = obj.getCreatedBy();
-// createdDate = ((BasicComponentType) obj).getCreatedDateString();
-//
-//
-// if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
-//
-// } else {
-//
-// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY, lastChangedBy);
-// }
-//
-// if (lastChangedDate == null) {
-// } else {
-//
-// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE,
lastChangedDate);
-// }
-//
-// if (createdBy == null || createdBy.trim().length() == 0) {
-// } else {
-//
-// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY, createdBy);
-// }
-//
-// if (createdDate == null) {
-// } else {
-// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE,createdDate);
-// }
-//
-// return changeHistoryElement;
-//
-//
-// }
-
- private void addChangeHistoryElement(ComponentObject obj, Element element ) {
-
- String lastChangedBy=null;
- String lastChangedDate=null;
- String createdDate=null;
- String createdBy=null;
-
- lastChangedBy = obj.getLastChangedBy();
- lastChangedDate = ((BasicComponentObject) obj).getLastChangedDateString();
-
- createdBy = obj.getCreatedBy();
- createdDate = ((BasicComponentObject) obj).getCreatedDateString();
-
-
- if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
-
- } else {
-
element.setAttribute(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY,
lastChangedBy);
- }
-
- if (lastChangedDate == null) {
-
- } else {
-
element.setAttribute(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE,
lastChangedDate);
-
- }
-
- if (createdBy == null || createdBy.trim().length() == 0) {
- } else {
-
element.setAttribute(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY,
createdBy);
- }
-
- if (createdDate == null) {
- } else {
-
element.setAttribute(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE,
createdDate);
- }
-
- }
-
- private void addChangeHistoryElement(ComponentType obj, Element element ) {
-
-// call to create the structure for the properties
-
- String lastChangedBy=null;
- String lastChangedDate=null;
- String createdDate=null;
- String createdBy=null;
-
- lastChangedBy = obj.getLastChangedBy();
- lastChangedDate = ((BasicComponentType) obj).getLastChangedDateString();
-
- createdBy = obj.getCreatedBy();
- createdDate = ((BasicComponentType) obj).getCreatedDateString();
-
-
- if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
-
- } else {
-
element.setAttribute(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY,
lastChangedBy);
- }
-
- if (lastChangedDate == null) {
- lastChangedDate = DateUtil.getCurrentDateAsString();
- }
-
element.setAttribute(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE,
lastChangedDate);
-
-
-
- if (createdBy == null || createdBy.trim().length() == 0) {
- } else {
-
element.setAttribute(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY,
createdBy);
- }
-
- if (createdDate == null) {
- createdDate = DateUtil.getCurrentDateAsString();
- }
-
element.setAttribute(XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE,
createdDate);
-
- }
-
-
-
-// private Element addChangeHistoryElementx(ComponentObject obj) {
-//
-// Element changeHistoryElement = new
Element(XMLConfig_42_ElementNames.ChangeHistory.ELEMENT);
-//
-// String lastChangedBy=null;
-// String lastChangedDate=null;
-// String createdDate=null;
-// String createdBy=null;
-//
-// lastChangedBy = obj.getLastChangedBy();
-// lastChangedDate = ((BasicComponentObject) obj).getLastChangedDateString();
-//
-// createdBy = obj.getCreatedBy();
-// createdDate = ((BasicComponentObject) obj).getCreatedDateString();
-//
-//
-// if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
-//
-// } else {
-//
-// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY, lastChangedBy);
-// }
-//
-// if (lastChangedDate == null) {
-//
-// } else {
-//
-// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE,
lastChangedDate);
-//
-// }
-//
-// if (createdBy == null || createdBy.trim().length() == 0) {
-// } else {
-//
-// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY, createdBy);
-// }
-//
-// if (createdDate == null) {
-// } else {
-// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_42_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE, createdDate);
-// }
-//
-// return changeHistoryElement;
-// }
-
-
- /**
- * This method is used to create a Properties JDOM Element from a
- * Properties object.
- *
- * @param props the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createPropertiesElement(Properties props) {
- Assertion.isNotNull(props);
-
- Properties sortprops = PropertiesUtils.sort(props);
- Element propertiesElement = new
Element(XMLConfig_42_ElementNames.Properties.ELEMENT);
- Enumeration enumeration = sortprops.propertyNames();
- while (enumeration.hasMoreElements()) {
- String propName = (String)enumeration.nextElement();
- propertiesElement = addPropertyElement(propertiesElement, propName,
props.getProperty(propName));
- }
-
- return propertiesElement;
- }
-
-
- private Element addPropertyElement(Element propertiesElement, String propName, String
propValue) {
- Element property = new
Element(XMLConfig_42_ElementNames.Properties.Property.ELEMENT);
-
property.setAttribute(XMLConfig_42_ElementNames.Properties.Property.Attributes.NAME,
propName);
- property.addContent(propValue);
- propertiesElement.addContent(property);
- return propertiesElement;
-
- }
-
-
-
- /**
- * This method is used to create a Configuration ID JDOM Element from a
- * Configuration ID object.
- *
- * @param type the ID type to be created. @see
XMLConfig_42_ElementNames.Configuration.XXXID.ELEMENT for valid values
- * @param name the calue of the name attribute of the ID element to create.
- * @return a JDOM XML Element
- */
- public Element createIDElement(String type, String name) {
-
- Element idElement = new Element(type);
- idElement.setAttribute(XMLConfig_42_ElementNames.ID.Attributes.NAME, name);
- return idElement;
- }
-
- /**
- * This method is used to create a Configurations JDOM Element from a
- * Configuration ID object. This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createConfigurationsElement() {
- throw new UnsupportedOperationException("Method createConfigurationsElement
is unsupported in 4.2"); //$NON-NLS-1$
- }
-
- /**
- * This method is used to create a Hosts JDOM Element from a
- * Configuration ID object. This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createHostsElement() {
- throw new UnsupportedOperationException("Method createHostsElement is
unsupported in 4.2"); //$NON-NLS-1$
- }
-
- /**
- * This method is used to create a Host JDOM Element from a
- * Host object.
- *
- * @param host the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createHostElement(Host host) {
- Assertion.isNotNull(host);
-
- Element hostElement =
createComponentObjectElement(XMLElementNames.Hosts.Host.ELEMENT, host);
- return hostElement;
- }
-
- /**
- * This method is used to create a ServiceComponentDefns JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createServiceComponentDefnsElement() {
- return new Element(XMLConfig_42_ElementNames.ServiceComponentDefns.ELEMENT);
-
-// throw new UnsupportedOperationException("Method
createServiceComponentDefnsElement is unsupported in 4.2"); //$NON-NLS-1$
- }
-
- /**
- * This method is used to create a ComponentTypes JDOM Element from a
- * Configuration ID object. This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createComponentTypesElement() {
- return new Element(XMLConfig_42_ElementNames.ComponentTypes.ELEMENT);
- }
-
-// public Element createProductTypesElement() {
-// return new Element(XMLConfig_42_ElementNames.ProductTypes.ELEMENT);
-// }
-
- public Element createConnectorBindingsElement() {
- return new Element(XMLConfig_42_ElementNames.ConnectorComponents.ELEMENT);
- }
-
-
- /**
- * This method is used to create a root JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createRootConfigurationDocumentElement() {
- return new Element(XMLConfig_42_ElementNames.ELEMENT);
- }
-
-
- /**
- * This method is used to create a ComponentObject JDOM Element from a
- * ComponentObject object.
- *
- * @param type The subclass type of the configuration object to be created.
- * @see XMLConfig_42_ElementNames.Configuration.XXXX.ELEMENT
- * @param componentObject the object to create the Element for.
- * @return a JDOM XML Element
- */
- private Element createComponentObjectElement(String type, ComponentObject
componentObject) {
- Element componentObjectElement = new Element(type);
-
componentObjectElement.setAttribute(XMLConfig_42_ElementNames.ComponentObject.Attributes.NAME,
componentObject.getName());
- BaseID id = componentObject.getComponentTypeID();
- if (id !=null) {
-
componentObjectElement.setAttribute(XMLConfig_42_ElementNames.ComponentObject.Attributes.COMPONENT_TYPE,
id.getName());
- }
-
- // this will add the changed history information
- if (componentObject instanceof DeployedComponent) {
- // don't write the properties for the deployed component
- } else {
- Element properties = createPropertiesElement(
componentObject.getProperties());
- componentObjectElement.addContent(properties);
- }
-
- addChangeHistoryElement(componentObject, componentObjectElement);
-// componentObjectElement.addContent(chgHistoryElement);
-
-
- return componentObjectElement;
- }
-
-
-
-// ##############################################################################
-//
-// Configuration Object Creation Methods
-//
-// ##############################################################################
-
-
- /**
- * This method will create a Host configuration object from an XML element
- * that represents a Host.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the Host configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public Host createHost(Element element, ConfigurationID configID,
ConfigurationObjectEditor editor, String name) throws
InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.Configuration.Host.ELEMENT)) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0032,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0032, element.getName()),
element);
- }
- if (name == null) {
- name =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.Host.Attributes.NAME);
- }
-
- Host host = editor.createHost(configID, name);
-
-// Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
-
- host = (Host) setDateHistory(host, element, editor);
-
-// if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- host = (Host)addProperties(element, host, editor);
-
-// return host;
-// }
-
- return host;
- }
-
- //
- /**
- * This method is used to create a ResourceDescriptor JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createResourcePoolElement(ResourceDescriptor resource) {
- Assertion.isNotNull(resource);
-
- Element resourceElement =
createComponentObjectElement(XMLConfig_42_ElementNames.ResourcePools.ResourcePool.ELEMENT,
resource);
- return resourceElement;
- }
-
-
- public Element createResourcePoolsElement() {
- return new Element(XMLConfig_42_ElementNames.ResourcePools.ELEMENT);
- }
-
- public Element createAuthenticationProviderElement() {
- return new Element(XMLConfig_42_ElementNames.AuthenticationProviders.ELEMENT);
- }
-
-
-
- /**
- * This method will create a Resource configuration object from an XML element
- * that represents a Resource.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the SharedResource configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public ResourceDescriptor createResourcePool(Element element, ConfigurationID
configID, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.ResourcePools.ResourcePool.ELEMENT))
{
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0033,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0033, element.getName()),
element);
- }
-
- String name =
element.getAttributeValue(XMLConfig_42_ElementNames.ResourcePools.ResourcePool.Attributes.NAME);
-
- checkElementValue(name, null, ErrorMessageKeys.CONFIG_ERR_0053);
-
- String type =
element.getAttributeValue(XMLConfig_42_ElementNames.ResourcePools.ResourcePool.Attributes.COMPONENT_TYPE);
-
- checkElementValue(type, name, ErrorMessageKeys.CONFIG_ERR_0054);
-
- ComponentTypeID id = new ComponentTypeID(type);
-
- // create the descriptor used to get the resource
- ResourceDescriptor descriptor = editor.createResourceDescriptor(configID, id,
name);
-
- Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
-
- descriptor = (ResourceDescriptor) setDateHistory(descriptor, element, editor);
-
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- descriptor = (ResourceDescriptor)addProperties(propertiesElement, descriptor,
editor);
-
- }
-
-
- return descriptor;
- }
-
- /**
- * This method will create a Resource configuration object from an XML element
- * that represents a Resource.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the SharedResource configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public AuthenticationProvider createAuthenticationProvider(Element element,
ConfigurationID configID, ConfigurationObjectEditor editor) throws
InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.AuthenticationProviders.Provider.ELEMENT))
{
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0033,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0033, element.getName()),
element);
- }
-
- String name =
element.getAttributeValue(XMLConfig_42_ElementNames.AuthenticationProviders.Provider.Attributes.NAME);
-
- checkElementValue(name, null, ErrorMessageKeys.CONFIG_ERR_0053);
-
- String type =
element.getAttributeValue(XMLConfig_42_ElementNames.AuthenticationProviders.Provider.Attributes.COMPONENT_TYPE);
-
- checkElementValue(type, name, ErrorMessageKeys.CONFIG_ERR_0054);
-
- ComponentTypeID id = new ComponentTypeID(type);
-
- // create the descriptor used to get the resource
- AuthenticationProvider authProvider =
editor.createAuthenticationProviderComponent(configID, id, name);
-
- Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
-
- authProvider = (AuthenticationProvider) setDateHistory(authProvider, element,
editor);
-
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- authProvider = (AuthenticationProvider)addProperties(propertiesElement,
authProvider, editor);
-
- }
-
-
- return authProvider;
- }
-
-
- //
- /**
- * This method is used to create a ServiceComponentDefn JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createSharedResourceElement(SharedResource resource) {
- Assertion.isNotNull(resource);
-
- Element resourceElement =
createComponentObjectElement(XMLConfig_42_ElementNames.Resources.Resource.ELEMENT,
resource);
- return resourceElement;
- }
-
-
- /**
- * This method will create a Resource configuration object from an XML element
- * that represents a Resource.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the SharedResource configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public SharedResource createSharedResource(Element element, ConfigurationObjectEditor
editor) throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.Resources.Resource.ELEMENT)) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0034,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0034, element.getName()),
element);
- }
-
- String name =
element.getAttributeValue(XMLConfig_42_ElementNames.Resources.Resource.Attributes.NAME);
-
- checkElementValue(name, null, ErrorMessageKeys.CONFIG_ERR_0055);
-
- String type =
element.getAttributeValue(XMLConfig_42_ElementNames.Resources.Resource.Attributes.COMPONENT_TYPE);
-
- checkElementValue(type, name, ErrorMessageKeys.CONFIG_ERR_0056);
-
- ComponentTypeID id = new ComponentTypeID(type);
-
- // create the descriptor used to get the resource
- SharedResource descriptor = editor.createSharedResource(
- id,
- name);
-
-
- Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
-
- descriptor = (SharedResource) setDateHistory(descriptor, element, editor);
-
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- descriptor = (SharedResource)addProperties(propertiesElement, descriptor,
editor);
- }
-
- return descriptor;
- }
-
- public Element createSharedResourcesElement() {
- return new Element(XMLConfig_42_ElementNames.Resources.ELEMENT);
- }
-
- /**
- * This method will create a ComponentType configuration object from an XML element
- * that represents a ComponentType.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ComponentType configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public ComponentType createComponentType(Element element, ConfigurationObjectEditor
editor, String name, boolean maintainParentID) throws
InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ELEMENT))
{
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0035,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0035, element.getName()),
element);
- }
-
- // retreive the attributes of this ComponentType from the JDOM element
- String parentType =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.PARENT_COMPONENT_TYPE);
- String superType =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE);
- String componentTypeCode =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE);
- String deployable =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE);
- String monitorable =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE);
- String description =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.DESCRIPTION);
-
-
-
- // convert them into their proper data types
- int typeCode = Integer.parseInt(componentTypeCode);
-
- if (! BasicUtil.isValdComponentTypeCode(typeCode)) {
- throw new RuntimeException("File error2, invalid component type code "
+ componentTypeCode + " for " + name + " super " + superType);
- }
-
- // we will use the passed in name unless it is null...
- if (name == null) {
- name =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.NAME);
- }
-
- ComponentTypeID parentTypeID = null;
- ComponentTypeID superTypeID = null;
-
- if (parentType != null && parentType.length() > 0) {
- parentTypeID = new ComponentTypeID(parentType);
- }
-
- if (superType !=null && superType.length() > 0) {
- superTypeID = new ComponentTypeID(superType);
- }
-
-
- boolean isDeployable = (Boolean.valueOf(deployable)).booleanValue();
- boolean isMonitorable = (Boolean.valueOf(monitorable)).booleanValue();
-
- // create the ComponentTypeObject
- BasicComponentType type = (BasicComponentType)
editor.createComponentType(typeCode, name, parentTypeID, superTypeID, isDeployable,
isMonitorable);
-
-
- if (description != null && description.length() > 0) {
- type.setDescription(description);
- }
- ComponentType t = setDateHistory(type, element, editor);
-
-
- // get the ComponentTypeDefn sub-Elements of this ComponentType
- // and create them also.
- List componentTypeDefnElements =
element.getChildren(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
-
- if (componentTypeDefnElements == null || componentTypeDefnElements.size() == 0)
{
- componentTypeDefnElements =
element.getChildren(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT);
- return addPropertyDefns(componentTypeDefnElements, t, editor);
- }
-
- return addComponentTypeDefns(componentTypeDefnElements, t, editor);
-
- }
-
- public ComponentType loadComponentType(Element rootElement) throws
InvalidConfigurationElementException {
- return createComponentType(rootElement, new BasicConfigurationObjectEditor(), null,
true);
- }
-
- /**
- * This method will create a ProductType configuration object from an XML element
- * that represents a ProductType.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @param componentTypeMap this is a map of ComponentTypeID--->ComponentType
- * it must contain all of the Component types that the ProductType
- * that is represented by the passed in XML element references.
- * @return the ProductType configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
-// public ProductType createProductType(Element element, ConfigurationObjectEditor
editor, Map componentTypeMap, String name)throws InvalidConfigurationElementException{
-// Assertion.isNotNull(element);
-// Assertion.isNotNull(editor);
-//
-// if
(!element.getName().equals(XMLConfig_42_ElementNames.ProductTypes.ProductType.ELEMENT)) {
-// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0036,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0036, element.getName()),
element);
-// }
-//
-// // retreive the attributes of this ComponentType from the JDOM element
-// String deployable =
element.getAttributeValue(XMLConfig_42_ElementNames.ProductTypes.ProductType.Attributes.DEPLOYABLE);
-//// String monitorable =
element.getAttributeValue(XMLConfig_42_ElementNames.ProductTypes.ProductType.Attributes.MONITORABLE);
-//
-// // we will use the passed in name unless it is null...
-// if (name == null) {
-// name =
element.getAttributeValue(XMLConfig_42_ElementNames.ProductTypes.ProductType.Attributes.NAME);
-// }
-//
-// boolean isDeployable = (Boolean.valueOf(deployable)).booleanValue();
-// // boolean isMonitorable = (Boolean.valueOf(monitorable)).booleanValue();
-//
-// List componentTypeIDs =
element.getChildren(XMLConfig_42_ElementNames.ComponentTypeID.ELEMENT);
-// List componentTypes = new ArrayList();
-// Iterator iter = componentTypeIDs.iterator();
-// while (iter.hasNext()) {
-// Element componentTypeIDElement = (Element)iter.next();
-// String componentTypeIDName =
componentTypeIDElement.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypeID.Attributes.NAME);
-// ComponentTypeID componentTypeID = new
ComponentTypeID(componentTypeIDName);
-// ComponentType componentType =
(ComponentType)componentTypeMap.get(componentTypeID);
-// if (componentType == null) {
-// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0037,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0037, new Object[]
{componentTypeID, name}), element);
-// }
-// componentTypes.add(componentType);
-// }
-//
-// // create the ComponentTypeObject
-// ProductType type = editor.createProductType(name, componentTypes, isDeployable,
false);
-//
-// return type;
-//// // get the ComponentTypeDefn sub-Elements of this ComponentType
-//// // and create them also.
-//// Collection componentTypeDefnElements =
element.getChildren(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
-////
-//// type = (ProductType) setDateHistory(type, element, editor);
-////
-//// return (ProductType)addComponentTypeDefns(componentTypeDefnElements, type,
editor);
-// }
-
- /**
- * This method will create a Configuration configuration object from an XML element
- * that represents a Configuration.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the Configuration configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public Configuration createConfiguration(Element element, ConfigurationObjectEditor
editor, String name) throws InvalidConfigurationElementException{
-
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if (!element.getName().equals(XMLConfig_42_ElementNames.Configuration.ELEMENT))
{
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0038,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0038, element.getName()),
element);
- }
-
- if (name==null) {
- name =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.Attributes.NAME);
- }
-
- Configuration config = editor.createConfiguration(name);
-
- config = (Configuration) setDateHistory(config, element, editor);
-
- config = (Configuration)addProperties(element, config, editor);
-
- return config;
- }
-
- /**
- * This method will create a LogConfiguration configuration object from an XML
element
- * that represents a LogConfiguration.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the LogConfiguration configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
-// public LogConfiguration createLogConfiguration(Element element) throws
InvalidConfigurationElementException{
-// Assertion.isNotNull(element);
-//
-// if
(!element.getName().equals(XMLConfig_42_ElementNames.Configuration.LogConfiguration.ELEMENT))
{
-// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0039,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0039, element.getName()),
element);
-// }
-//
-// Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
-// Properties properties = new Properties();
-//
-//
-// List props =
propertiesElement.getChildren(XMLConfig_42_ElementNames.Properties.Property.ELEMENT);
-// Iterator iterator = props.iterator();
-// while (iterator.hasNext()) {
-// Element propertyElement = (Element)iterator.next();
-// String propertyName =
propertyElement.getAttributeValue(XMLConfig_42_ElementNames.Properties.Property.Attributes.NAME);
-// String propertyValue = propertyElement.getText();
-// properties.setProperty(propertyName, propertyValue);
-// }
-//
-// LogConfiguration config = null;
-//
-// try {
-// config = BasicLogConfiguration.createLogConfiguration(properties);
-// }catch(LogConfigurationException e) {
-// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0040,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0040,e.getMessage()), element);
-//
-// }
-//
-// return config;
-//
-// }
-
- public Element createConnectorBindingElement(ConnectorBinding connector, boolean
isExportConfig) {
-
- Assertion.isNotNull(connector);
-
- Element connectorElement =
createComponentObjectElement(XMLConfig_42_ElementNames.ConnectorComponents.ConnectorComponent.ELEMENT,
connector);
-
-
connectorElement.setAttribute(XMLConfig_42_ElementNames.ConnectorComponents.ConnectorComponent.Attributes.ROUTING_UUID,
connector.getRoutingUUID());
-
-
- return connectorElement;
-
- }
-
-
- public ConnectorBinding createConnectorBinding(ConfigurationID configurationID,
Element element, ConfigurationObjectEditor editor, String name, boolean
isImportConfig)throws InvalidConfigurationElementException {
-
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.ConnectorComponents.ConnectorComponent.ELEMENT))
{
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0041,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0041,element.getName()),
element);
- }
-
- if (name==null) {
- name =
element.getAttributeValue(XMLConfig_42_ElementNames.ConnectorComponents.ConnectorComponent.Attributes.NAME);
- }
-
- String componentType =
element.getAttributeValue(XMLConfig_42_ElementNames.ConnectorComponents.ConnectorComponent.Attributes.COMPONENT_TYPE);
-
- checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0057);
-
- ComponentTypeID id = new ComponentTypeID(componentType);
-
-//
element.getAttributeValue(XMLConfig_42_ElementNames.ConnectorComponents.ConnectorComponent.Attributes.QUEUED_SERVICE);
-
- String routingUUID = null;
- // vah - 09-24-2003
- // when importing a configuration use the routing uuid,
- // otherwise do not use it (which will cause the routingUUID to be regenerated)
- // This is done to help ensure there are no duplicate UUIDs
- if (isImportConfig) {
- routingUUID =
element.getAttributeValue(XMLConfig_42_ElementNames.ConnectorComponents.ConnectorComponent.Attributes.ROUTING_UUID);
- }
-
- ConnectorBinding defn = null;
- defn = editor.createConnectorComponent(configurationID, id, name, routingUUID);
-
- defn = (ConnectorBinding) setDateHistory(defn, element, editor);
-
- // add the properties to this ComponentObject...
- Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- return (ConnectorBinding)addProperties(propertiesElement, defn, editor);
- }
-
- return defn;
- }
-
- public ConnectorBinding loadConnectorBinding(Element rootElement) throws
InvalidConfigurationElementException {
- return createConnectorBinding(Configuration.NEXT_STARTUP_ID, rootElement, new
BasicConfigurationObjectEditor(), null, false);
- }
-
- /**
- * This method will create a ServiceComponentDefn configuration object from an XML
element
- * that represents a ServiceComponentDefn.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ServiceComponentDefn configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public ComponentDefn createServiceComponentDefn(Element element, Configuration
config, ConfigurationObjectEditor editor, String name) throws
InvalidConfigurationElementException{
- ConfigurationID configID = null;
- if (config != null) {
- configID = (ConfigurationID) config.getID();
- }
- return createServiceComponentDefn(element, configID, editor, name);
-
- }
-
- public ComponentDefn createServiceComponentDefn(Element element, ConfigurationID
configID, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException {
-
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
- Assertion.isNotNull(configID);
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.ServiceComponentDefns.ServiceComponentDefn.ELEMENT))
{
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0042,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0042,element.getName()),
element);
- }
-
- if (name==null) {
- name =
element.getAttributeValue(XMLConfig_42_ElementNames.ServiceComponentDefns.ServiceComponentDefn.Attributes.NAME);
- }
-
- String componentType =
element.getAttributeValue(XMLConfig_42_ElementNames.ServiceComponentDefns.ServiceComponentDefn.Attributes.COMPONENT_TYPE);
-
- checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0058);
-
- ComponentTypeID id = new ComponentTypeID(componentType);
-
-//
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.ServiceComponentDefns.ServiceComponentDefn.Attributes.QUEUED_SERVICE);
-
- String routingUUID =
element.getAttributeValue(XMLConfig_42_ElementNames.ServiceComponentDefns.ServiceComponentDefn.Attributes.ROUTING_UUID);
-
- ComponentDefn defn = null;
- boolean isResourcePool = isResourcePool(componentType);
-
- if (configID == null) {
-/*
- if (!isResourcePool) {
- if (routingUUID == null){
- //allow the object editor to generate a UUID
- defn = (ComponentDefn) editor.createServiceComponentDefn(id, name);
- } else {
- //use the UUID specified in the XML file
- defn = (ComponentDefn) editor.createServiceComponentDefn(id, name,
routingUUID);
- }
-
- editor.setEnabled((ServiceComponentDefn) defn, isEnabled);
- } else {
- defn = editor.createResourceDescriptor(id, name);
-
-
- }
-*/
- }else {
- if (!isResourcePool) {
-
- if (routingUUID == null){
- //allow the object editor to generate a UUID
- defn = editor.createServiceComponentDefn(configID, id, name);
- } else {
- //use the UUID specified in the XML file
- defn = editor.createServiceComponentDefn(configID, id, name,
routingUUID);
- }
-
- } else {
-
- defn = editor.createResourceDescriptor(configID, id, name);
-
- }
-
- }
-
- defn = (ComponentDefn) setDateHistory(defn, element, editor);
-
- // add the properties to this ComponentObject...
- Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- return (ComponentDefn)addProperties(propertiesElement, defn, editor);
- }
-
- return defn;
-
- }
-
- private boolean isResourcePool(String componentTypeName) {
- boolean result = false;
-
- if (componentTypeName.equals(SharedResource.JDBC_COMPONENT_TYPE_NAME) ||
- componentTypeName.equals(SharedResource.JMS_COMPONENT_TYPE_NAME) ||
- componentTypeName.equals(SharedResource.MISC_COMPONENT_TYPE_NAME) ||
- componentTypeName.equals(SharedResource.SEARCHBASE_COMPONENT_TYPE_NAME) ) {
- return true;
- }
-
-
- return result;
-
- }
-
- /**
- * This method will create a ProductServiceConfig configuration object from an XML
element
- * that represents a ProductServiceConfig.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ProductServiceConfig configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
-// public ProductServiceConfig createProductServiceConfig(Element element,
ConfigurationID configID, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException {
-// Assertion.isNotNull(element);
-// Assertion.isNotNull(editor);
-// Assertion.isNotNull(configID);
-//
-// if
(!element.getName().equals(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.ELEMENT))
{
-// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0043,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0043,element.getName()),
element);
-// }
-//
-// if (name==null) {
-// name =
element.getAttributeValue(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.Attributes.NAME);
-// }
-//
-// String componentType =
element.getAttributeValue(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.Attributes.COMPONENT_TYPE);
-// checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0059);
-//
-//
-// // ConfigurationID configID = (ConfigurationID)config.getID();
-// ProductTypeID id = new ProductTypeID(componentType);
-//
-//
-// // ConfigurationID configID = (ConfigurationID)config.getID();
-//
-// // this new editor is used only as a way to create a product service config
-// // the passed in editor is then used to add the PSC to the configuration
-// // as passed in.
-// // we dont want to add the actions again to the passed in editor.
-// ProductServiceConfig productServiceConfig =
editor.createProductServiceConfig(configID, id, name);
-//
-// Collection serviceComponentDefnIDs =
element.getChildren(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.ELEMENT);
-//
-// if
(id.getFullName().equals(MetaMatrixProductVersion.CONNECTOR_PRODUCT_TYPE_NAME)) {
-// Iterator iterator = serviceComponentDefnIDs.iterator();
-// while (iterator.hasNext()) {
-// Element serviceComponentDefnIDElement = (Element)iterator.next();
-// String serviceComponentDefnName =
serviceComponentDefnIDElement.getAttributeValue(XMLConfig_42_ElementNames.ID.Attributes.NAME);
-//
-// String enabled =
serviceComponentDefnIDElement.getAttributeValue(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.Attributes.IS_ENABLED);
-//
-// if (enabled == null) {
-// enabled = Boolean.TRUE.toString();
-// }
-//
-// ConnectorBindingID serviceComponentDefnID = new
ConnectorBindingID(configID, serviceComponentDefnName);
-// productServiceConfig =
editor.addServiceComponentDefn(productServiceConfig, serviceComponentDefnID);
-// editor.setEnabled(serviceComponentDefnID, productServiceConfig,
Boolean.valueOf(enabled).booleanValue());
-//
-// }
-//
-//
-// } else {
-//
-// Iterator iterator = serviceComponentDefnIDs.iterator();
-// while (iterator.hasNext()) {
-// Element serviceComponentDefnIDElement = (Element)iterator.next();
-// String serviceComponentDefnName =
serviceComponentDefnIDElement.getAttributeValue(XMLConfig_42_ElementNames.ID.Attributes.NAME);
-//
-// String enabled =
serviceComponentDefnIDElement.getAttributeValue(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.Attributes.IS_ENABLED);
-//
-// if (enabled == null) {
-// enabled = Boolean.TRUE.toString();
-// }
-//
-// ServiceComponentDefnID serviceComponentDefnID = new
ServiceComponentDefnID(configID, serviceComponentDefnName);
-// productServiceConfig =
editor.addServiceComponentDefn(productServiceConfig, serviceComponentDefnID);
-//
-// editor.setEnabled(serviceComponentDefnID, productServiceConfig,
Boolean.valueOf(enabled).booleanValue());
-//
-// }
-//
-// }
-//
-// productServiceConfig = (ProductServiceConfig)
setDateHistory(productServiceConfig, element, editor);
-//
-// // add the properties to this ComponentObject...
-// Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
-// if (propertiesElement != null) {
-// // now we add the system properties to the configuration object
-// productServiceConfig =
(ProductServiceConfig)addProperties(propertiesElement, productServiceConfig, editor);
-// return productServiceConfig;
-// }
-//
-// return productServiceConfig;
-// }
-
-
-
- public DeployedComponent createDeployedServiceComponent(Element element,
- ConfigurationID configID,
- HostID hostID,
- VMComponentDefnID vmID,
- Map componentTypeMap,
- ConfigurationObjectEditor editor)
- throws
InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
- Assertion.isNotNull(configID);
- Assertion.isNotNull(hostID);
- Assertion.isNotNull(vmID);
-
- DeployedComponent component;
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.Configuration.DeployedService.ELEMENT))
{
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()),
element);
- }
-
- String name =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedService.Attributes.NAME);
- checkElementValue(name, "NAME", ErrorMessageKeys.CONFIG_ERR_0048);
//$NON-NLS-1$
-
- String componentTypeIDString =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedService.Attributes.COMPONENT_TYPE);
-// String serviceComponentDefnIDString =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.SERVICE_COMPONENT_DEFN_ID);
-
- checkElementValue(componentTypeIDString, name,
ErrorMessageKeys.CONFIG_ERR_0049);
-// checkElementValue(serviceComponentDefnIDString, name,
ErrorMessageKeys.CONFIG_ERR_0049);
-
-
- ComponentType type = null;
- Iterator it = componentTypeMap.keySet().iterator();
- while (it.hasNext() ) {
- ComponentTypeID id = (ComponentTypeID) it.next();
- if (id.getFullName().equals(componentTypeIDString)) {
- type = (ComponentType) componentTypeMap.get(id);
- break;
- }
- }
-
- if (type == null) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[]
{componentTypeIDString, name} ), element);
- }
-
- ServiceComponentDefnID svcid = null;
- if (type.getComponentTypeCode() == ComponentType.CONNECTOR_COMPONENT_TYPE_CODE)
{
-
- svcid = new ConnectorBindingID(configID, name);
-
- } else {
-
-
- svcid = new ServiceComponentDefnID(configID, name);
-
- }
-
- component = editor.createDeployedServiceComponent(name, configID, hostID,vmID,
svcid, (ComponentTypeID) type.getID());
-
-
- component = (DeployedComponent) setDateHistory(component, element, editor);
-
-
- return component;
- }
-
-
-// public DeployedComponent createDeployedVMComponentDefnx(Element element,
-// ConfigurationID configID,
-// HostID hostID,
-// // VMComponentDefnID vmID,
-// // ProductServiceConfigID
pscID,
-// ComponentTypeID typeID,
-// ConfigurationObjectEditor
editor)
-// throws
InvalidConfigurationElementException{
-// Assertion.isNotNull(element);
-// Assertion.isNotNull(editor);
-// Assertion.isNotNull(configID);
-// Assertion.isNotNull(hostID);
-// // Assertion.isNotNull(vmID);
-//
-// DeployedComponent component=null;
-//
-// if
(!element.getName().equals(XMLConfig_42_ElementNames.Configuration.Process.ELEMENT)) {
-// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()),
element);
-// }
-//
-// String name =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.Process.Attributes.NAME);
-//// checkElementValue(name, "NAME",
ErrorMessageKeys.CONFIG_ERR_0048);
-//
-// String componentTypeIDString =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.Process.Attributes.COMPONENT_TYPE);
-//
-// checkElementValue(componentTypeIDString, name,
ErrorMessageKeys.CONFIG_ERR_0049);
-//
-//
-//// ComponentType type = null;
-//// Iterator it = componentTypeMap.keySet().iterator();
-//// while (it.hasNext() ) {
-//// ComponentTypeID id = (ComponentTypeID) it.next();
-//// if (id.getFullName().equals(componentTypeIDString)) {
-//// type = (ComponentType) componentTypeMap.get(id);
-//// break;
-//// }
-//// }
-//
-//// if (type == null) {
-//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[]
{componentTypeIDString, name} ), element);
-//// }
-//
-// // VMComponentDefnID vmID = new VMComponentDefnID(configID, hostID,
name);
-/////// component = editor.createDeployedVMComponent(name, configID,
hostID, vmID, typeID);
-// // createDeployedServiceComponent(name, configID, hostID,vmID, svcid,
pscID, (ComponentTypeID) type.getID());
-//
-//
-// return component;
-// }
-
-
-
- /**
- * This method will create a DeployedComponent configuration object from an XML
element
- * that represents a DeployedComponent.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @param serviceComponentDefnMap a map of
ServiceComponentDefnID-->ServiceComponentDefn
- * this map must contain at the very least the ServiceComponentDefn that
- * is the service definition of the deployed component that the XML element
- * references. This is used if the deployedComponent is a Service. Otherwise
- * it is ignored.
- * @param vmComponentDefnMap a map of vmComponentDefnID-->vmComponentDefn
- * this map must contain at the very least the vmComponentDefn that
- * is the VM definition of the deployed component that the XML element
- * references. This is used if the deployedComponent is a VM. Otherwise
- * it is ignored.
- * @return the DeployedComponent configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
-// public DeployedComponent createDeployedComponent(Element element,
-// Configuration config, ConfigurationObjectEditor editor,
-// Map serviceComponentDefnMap, Map vmComponentDefnMap, Map componentTypeMap,
String name)
-// throws InvalidConfigurationElementException{
-// throw new UnsupportedOperationException("Method createDeployedComponent is
unsupported in 4.2"); //$NON-NLS-1$
-//
-////
-//// Assertion.isNotNull(element);
-//// Assertion.isNotNull(editor);
-//// Assertion.isNotNull(config);
-////
-//// DeployedComponent component;
-////
-//// if
(!element.getName().equals(XMLConfig_42_ElementNames.Configuration.DeployedComponent.ELEMENT))
{
-//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()),
element);
-//// }
-////
-//// if (name == null) {
-//// name =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.NAME);
-//// }
-////
-//// String productServiceConfigIDString =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.PRODUCT_SERVICE_CONFIG_ID);
-//// String vmComponentDefnIDString =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.VM_COMPONENT_DEFN_ID);
-//// String serviceComponentDefnIDString =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.SERVICE_COMPONENT_DEFN_ID);
-//// String HostIDString =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.HOST_ID);
-////
-//// checkElementValue(vmComponentDefnIDString, name,
ErrorMessageKeys.CONFIG_ERR_0045);
-//// checkElementValue(HostIDString, name, ErrorMessageKeys.CONFIG_ERR_0046);
-////
-//// ConfigurationID configID = (ConfigurationID)config.getID();
-////
-//// HostID hostID = new HostID(HostIDString);
-//// VMComponentDefnID vmComponentDefnID = new VMComponentDefnID(configID,
vmComponentDefnIDString);
-////
-//// // this will check to see if this is actually a DeployedVMServiceComponent
-//// // these special deployed components dont have values for these ID's
-//// String componentTypeIDString =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.COMPONENT_TYPE);
-////
-//// if (serviceComponentDefnIDString == null &&
productServiceConfigIDString == null) {
-//// VMComponentDefn defn =
(VMComponentDefn)vmComponentDefnMap.get(vmComponentDefnID);
-//// if (defn==null) {
-//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0047,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0047, new Object[] {name,
vmComponentDefnID} ), element);
-////
-//// }
-//// component = editor.createDeployedVMComponent(name, config, hostID,
defn);
-////
-//// // else this element represents a normal ServiceComponentDefn object
-//// }else {
-//// checkElementValue(productServiceConfigIDString, name,
ErrorMessageKeys.CONFIG_ERR_0048);
-//// checkElementValue(serviceComponentDefnIDString, name,
ErrorMessageKeys.CONFIG_ERR_0049);
-////
-//// ComponentType type = null;
-//// Iterator it = componentTypeMap.keySet().iterator();
-//// while (it.hasNext() ) {
-//// ComponentTypeID id = (ComponentTypeID) it.next();
-//// if (id.getFullName().equals(componentTypeIDString)) {
-//// type = (ComponentType) componentTypeMap.get(id);
-//// break;
-//// }
-//// }
-////
-//// if (type == null) {
-//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[]
{componentTypeIDString, serviceComponentDefnIDString} ), element);
-//// }
-//// ProductServiceConfigID productServiceConfigID = null;
-//// if (type instanceof ConnectorBindingType) {
-////
-//// productServiceConfigID = new ProductServiceConfigID(configID,
productServiceConfigIDString);
-////
-//// ConnectorBindingID bindingID = new ConnectorBindingID(configID,
serviceComponentDefnIDString);
-//// ConnectorBinding bdefn =
(ConnectorBinding)serviceComponentDefnMap.get(bindingID);
-////
-//// if (bdefn==null) {
-//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0051,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0051, new Object[] {name,
serviceComponentDefnIDString} ), element);
-//// }
-//// component = editor.createDeployedServiceComponent(name, config, hostID,
vmComponentDefnID, bdefn, productServiceConfigID);
-////
-//// } else {
-////
-//// productServiceConfigID = new ProductServiceConfigID(configID,
productServiceConfigIDString);
-////
-//// ServiceComponentDefnID serviceComponentDefnID = new
ServiceComponentDefnID(configID, serviceComponentDefnIDString);
-//// ServiceComponentDefn defn =
(ServiceComponentDefn)serviceComponentDefnMap.get(serviceComponentDefnID);
-////
-//// if (defn==null) {
-//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0052,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0052, new Object[] {name,
serviceComponentDefnIDString} ), element);
-//// }
-//// component = editor.createDeployedServiceComponent(name, config, hostID,
vmComponentDefnID, defn, productServiceConfigID);
-////
-//// }
-////
-//// }
-////
-//// component = (DeployedComponent) setDateHistory(component, element, editor);
-////
-//// Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
-//// if (propertiesElement != null) {
-//// // now we add the system properties to the configuration object
-//// return (DeployedComponent)addProperties(propertiesElement, component,
editor);
-//// }
-////
-//// return component;
-// }
-
- /**
- * This method will create a VMComponentDefn configuration object from an XML element
- * that represents a VMComponentDefn.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the VMComponentDefn configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public BasicVMComponentDefn createVMComponentDefn(Element element, ConfigurationID
configID, HostID hostID, ConfigurationObjectEditor editor, String name) throws
InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
- Assertion.isNotNull(configID);
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.Configuration.Process.ELEMENT)) {
- throw new InvalidConfigurationElementException("A Configuration object
cannot be created from a JDOM Element type: " + element.getName() + ".",
element); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (name==null) {
- name =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.Process.Attributes.NAME);
- }
-
- String componentType =
element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.Process.Attributes.COMPONENT_TYPE);
-
- checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0060);
-
- ComponentTypeID id = new ComponentTypeID(componentType);
-
- VMComponentDefn defn = editor.createVMComponentDefn(configID, hostID, id, name);
-
- defn = (VMComponentDefn) setDateHistory(defn, element, editor);
-
- // add the properties to this ComponentObject...
- // Element propertiesElement =
element.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
- // if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- defn = (VMComponentDefn)addProperties(element, defn, editor);
- // }
-
- return (BasicVMComponentDefn) defn;
- }
-
- /**
- * This method is a helper method to create a PropertyDefinition object from
- * an XML element that represents same.
- *
- * @param element the XML element that represents a PropertyDefinition object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public PropertyDefinition createPropertyDefinition(Element element) throws
InvalidConfigurationElementException{
-
- if
(!element.getName().equals(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT))
{
- throw new InvalidConfigurationElementException("A Configuration object
cannot be created from a JDOM Element type: " + element.getName() + ".",
element); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- String nameString =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.NAME);
-
- String displayNameString =
element.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DISPLAY_NAME);
-
-
- String shortDescriptionString = getAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.SHORT_DESCRIPTION,
- PropertyDefinitionImpl.DEFAULT_SHORT_DESCRIPTION);
-
- String defaultValueString = getAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DEFAULT_VALUE,
- PropertyDefinitionImpl.DEFAULT_DEFAULT_VALUE);
-
- String valueDelimiterString = getAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.VALUE_DELIMITER,
- PropertyDefinitionImpl.DEFAULT_DELIMITER);
-
-
- String multiplicityString = getAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.MULTIPLICITY,
- PropertyDefinitionImpl.DEFAULT_MULTIPLICITY);
- Multiplicity mult = null;
- try {
- mult = Multiplicity.getInstance(multiplicityString);
- }catch(MultiplicityExpressionException e) {
- throw new InvalidConfigurationElementException(e, "The
PropertyDefinition object: " + nameString + " could not be created because the
multiplicity definition: '" + multiplicityString + " is not a valid
multiplicity definition.", element); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
-
- String propertyTypeString = getAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.PROPERTY_TYPE,
- PropertyDefinitionImpl.DEFAULT_TYPE.getDisplayName());
- PropertyType type = PropertyType.getInstance(propertyTypeString);
-
-
-
- boolean isConstrainedToAllowedValues = getAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_CONSTRAINED_TO_ALLOWED_VALUES,
- PropertyDefinitionImpl.DEFAULT_IS_CONSTRAINED);
-
- boolean isExpert = getAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_EXPERT,
- PropertyDefinitionImpl.DEFAULT_IS_EXPERT);
-
- boolean isHidden = getAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_HIDDEN,
- PropertyDefinitionImpl.DEFAULT_IS_HIDDEN);
-
- boolean isMasked = getAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MASKED,
- PropertyDefinitionImpl.DEFAULT_IS_MASKED);
-
- boolean isModifiable = getAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MODIFIABLE,
- PropertyDefinitionImpl.DEFAULT_IS_MODIFIABLE);
-
- boolean isPreferred = getAttributeBoolean(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_PREFERRED,
- PropertyDefinitionImpl.DEFAULT_IS_PREFERRED);
-
- String requiresRestart = getAttributeString(element,
-
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.REQUIRES_RESTART,
- PropertyDefinitionImpl.DEFAULT_REQUIRES_RESTART.toString());
-
- RestartType restartType = null;
-
- if ("true".equalsIgnoreCase(requiresRestart)) { //$NON-NLS-1$
- restartType = RestartType.PROCESS;
- } else {
- restartType = RestartType.valueOf(requiresRestart.toUpperCase());
- }
-
-
- // we must retrieve all of the allowed values from the PropertyDefinition
- // element
- Collection allowedValuesElements =
element.getChildren(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.AllowedValue.ELEMENT);
- ArrayList allowedValues = new ArrayList(allowedValuesElements.size());
-
- Iterator iterator = allowedValuesElements.iterator();
- while (iterator.hasNext()) {
- Element allowedValueElement = (Element)iterator.next();
- allowedValues.add(allowedValueElement.getText());
- }
-
- PropertyDefinitionImpl defn = new PropertyDefinitionImpl(nameString,
displayNameString, type,
- mult, shortDescriptionString, defaultValueString,
- allowedValues, valueDelimiterString,
- isHidden, isPreferred, isExpert, isModifiable);
-
- defn.setMasked(isMasked);
- defn.setConstrainedToAllowedValues(isConstrainedToAllowedValues);
- defn.setRequiresRestart(restartType);
- return defn;
-
- }
-
-
-
- /**
- * Get the value of the specified attribute from the on the specified element.
- * If null, get the the default value.
- * @param element
- * @param attributeName name of Attribute to get
- * @param defaultValue
- * @return the attribute value, or defaultValue if it is null.
- * @since 4.3
- */
- private static String getAttributeString(Element element, String attributeName,
String defaultValue) {
- String stringValue = element.getAttributeValue(attributeName);
- if (stringValue == null) {
- return defaultValue;
- }
-
- return stringValue;
- }
- /**
- * Get the value of the specified attribute from the on the specified element.
- * If null, get the the default value.
- * @param element
- * @param attributeName name of Attribute to get
- * @param defaultValue
- * @return the attribute value, or defaultValue if it is null.
- * @since 4.3
- */
- private static boolean getAttributeBoolean(Element element, String attributeName,
boolean defaultValue) {
- String stringValue = element.getAttributeValue(attributeName);
- if (stringValue == null) {
- return defaultValue;
- }
-
- return Boolean.valueOf(stringValue).booleanValue();
- }
-
-
-
- /**
- * This method will create a ComponentObject configuration object from an XML element
- * that represents a ComponentObject.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ComponentObject configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLConfig_42_ElementNames class.
- */
- public ComponentObject addProperties(Element propertiesElement, ComponentObject
object, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
-
- if
(!propertiesElement.getName().equals(XMLConfig_42_ElementNames.Properties.ELEMENT)) {
- propertiesElement =
propertiesElement.getChild(XMLConfig_42_ElementNames.Properties.ELEMENT);
- }
-
- Properties props = null;
- if (propertiesElement == null) {
- props = new Properties();
- }
- else {
- props = getProperties(propertiesElement);
- }
-
- object = editor.modifyProperties(object, props, ConfigurationObjectEditor.ADD);
- return object;
- }
-
-
- private Properties getProperties(Element propertiesElement) {
- Properties props = new Properties();
-
- List properties =
propertiesElement.getChildren(XMLConfig_42_ElementNames.Properties.Property.ELEMENT);
- Iterator iterator = properties.iterator();
- while (iterator.hasNext()) {
- Element propertyElement = (Element)iterator.next();
- String propertyName =
propertyElement.getAttributeValue(XMLConfig_42_ElementNames.Properties.Property.Attributes.NAME);
- String propertyValue = propertyElement.getText();
-
- props.setProperty(propertyName, propertyValue);
-
- }
- return props;
- }
-
- /**
- * This is a helper method for ProductTypes and ComponentTypes. this method
- * will add a list of Component Type Definitions to a ComponentType using
- * the passed in editor. The Collection of XML elements passed in are
- * translated into ComponentTypeDefn objects and then set on the passed in
- * ComponentType.
- *
- * @param componentTypeDefnElements a collection of JDOM elements that
- * each represent a ComponentTypeDefn object.
- * @param type the ComponentType object to add the ComponentTypeDefns to
- * @param editor the editor to use to both create the ComponentTypeDefns
- * and to set them on the passed in ComponentType.
- * @return the ComponentType reference that now has the CompoenentTypeDefns
- * set on it.
- * @throws InvalidConfigurationElementException if the ComponentTypeDefn
- * JDOM elements do not adhere to the proper XML structure as defined by the
- * XMLConfig_42_ElementNames class.
- */
- private ComponentType addComponentTypeDefns(Collection componentTypeDefnElements,
ComponentType type, ConfigurationObjectEditor editor) throws
InvalidConfigurationElementException{
- ArrayList componentTypeDefns = new ArrayList(componentTypeDefnElements.size());
-
- Iterator iterator = componentTypeDefnElements.iterator();
- while (iterator.hasNext()) {
- Element componentTypeDefnElement = (Element)iterator.next();
- Element propertyDefinitionElement =
componentTypeDefnElement.getChild(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT);
- PropertyDefinition propDefn =
createPropertyDefinition(propertyDefinitionElement);
- componentTypeDefns.add(editor.createComponentTypeDefn(type, propDefn,
false));
- }
- return editor.setComponentTypeDefinitions(type, componentTypeDefns);
- }
-
- private ComponentType addPropertyDefns(Collection propertyDefnElements, ComponentType
type, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
- ArrayList componentTypeDefns = new ArrayList(propertyDefnElements.size());
-
- Iterator iterator = propertyDefnElements.iterator();
- while (iterator.hasNext()) {
- Element propertyDefinitionElement = (Element)iterator.next();
- PropertyDefinition propDefn =
createPropertyDefinition(propertyDefinitionElement);
- componentTypeDefns.add(editor.createComponentTypeDefn(type, propDefn,
false));
- }
- return editor.setComponentTypeDefinitions(type, componentTypeDefns);
- }
-
- public void orderComponentTypeElementList(List componentTypeElements) {
- ComponentTypeElementComparator comparator = new
ComponentTypeElementComparator();
- Collections.sort(componentTypeElements, comparator);
- }
-
-
- class ComponentTypeElementComparator implements Comparator{
-
- /**
- * This compare to will determine whether the ComponentType element
- * represented by 'this' has a superComponentType that is the
- * passed in ComponentType element representation to be compared to. if so, the
'this' element
- * is considered to be greater than the passed in element. If it is
- * determined that 'this' is the superCompoentType of the passed in
- * object then 'greater than' will be returned. If it is determined
- * that the two ComponentTypeObjects are unrelated, then equals is
- * returned...Note that this is inconsistent with the equals() method.
- */
- public int compare(Object thisObject, Object thatObject) {
- if (thisObject instanceof Element) {
- Element thisElement = (Element)thisObject;
- if (thatObject instanceof Element) {
- Element thatElement = (Element)thatObject;
- String thatSuperID = getElementSuperID(thatElement);
- String thisSuperID = getElementSuperID(thisElement);
- String thatID = getElementID(thatElement);
- String thisID = getElementID(thisElement);
-
- if(thisSuperID!=null && thisSuperID.equals(thatID)) {
- return 1;
- }else if(thatSuperID!=null && thatSuperID.equals(thisID)) {
- return -1;
- }else {
- return 0;
- }
- }
- }
- return 0;
- }
-
-
- private String getElementSuperID(Element componentTypeElement) {
- return
componentTypeElement.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE);
- }
-
- private String getElementID(Element componentTypeElement) {
- return
componentTypeElement.getAttributeValue(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.Attributes.NAME);
- }
- }
-
- // helper class to check that an element is not null and length is greater than zero
- // this should be used instead of Assertion when checking that
- // component ID's exist
- private void checkElementValue(String value, String name, String errorKey) throws
InvalidConfigurationElementException {
- if (value == null || value.trim().length() > 0) {
- if (name != null) {
- if(value == null){
- Assertion.isNotNull(value, CommonPlugin.Util.getString(errorKey,
name));
- }
- } else {
- if(value == null){
- Assertion.isNotNull(value, CommonPlugin.Util.getString(errorKey));
- }
- }
-
- }
-
- }
-
-
-
-// private static final String NOT_ASSIGNED = "NotAssigned";
-
-}
Deleted:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ImportExportUtility.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ImportExportUtility.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ImportExportUtility.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -1,867 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.xml;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jdom.Document;
-import org.jdom.Element;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.config.api.AuthenticationProvider;
-import com.metamatrix.common.config.api.ComponentDefn;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.common.config.api.ConfigurationObjectEditor;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.config.api.Host;
-import com.metamatrix.common.config.api.HostID;
-import com.metamatrix.common.config.api.ResourceDescriptor;
-import com.metamatrix.common.config.api.ServiceComponentDefn;
-import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.config.api.VMComponentDefn;
-import com.metamatrix.common.config.api.VMComponentDefnID;
-import com.metamatrix.common.config.model.ConfigurationModelContainerImpl;
-import com.metamatrix.common.config.util.ConfigObjectsNotResolvableException;
-import com.metamatrix.common.config.util.InvalidConfigurationElementException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.common.util.LogCommonConstants;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.ReflectionHelper;
-
-/**
-* This version of the configuration import/exporter supports the configuration in 4.2.
-*/
-public class XMLConfig_42_ImportExportUtility extends XMLConfig_Base_ImportExportUtility
{
-
- private static final String CONFIG_MODEL_CLASS =
ConfigurationModelContainerImpl.class.getName();
- private XMLConfig_42_HelperImpl xmlHelper = null;
-
-
-
- /**
- * <p>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.</p>
- *
- * <p>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.</p>
- *
- * <pre>
- * 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
- * </pre>
- *
- *
- * <p> All of the above object references must be in the collection passed
- * into this method.</p>
- *
- * <p> 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.</p>
- *
- * <pre>
- * ConfigurationPropertyNames.APPLICATION_CREATED_BY
- * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
- * ConfigurationPropertyNames.USER_CREATED_BY
- * <pre>
- *
- * <p>Any of these properties that are not included in the properties object
- * will not be included in the header Element.
- *
- * @param stream the output stream to write the Configuration Object
- * representation to
- * @param configurationObjects a Collection of configuration objects that
- * represents an entire logical Configuration.
- * @param props the properties object that contains the values for the Header
- * @throws IOException if there is an error writing to the DirectoryEntry
- * @throws 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
- */
- public void exportConfiguration(OutputStream stream,
- Collection configurationObjects, Properties props)
- throws IOException, ConfigObjectsNotResolvableException {
-
-
- Assertion.isNotNull(configurationObjects);
- Assertion.isNotNull(stream);
-
-
- // this will divide the configuration objects by their type
- // so that we can create an XML doc and put the objects in their proper
- // categories.
- List[] lists = segregateConfigurationObjects(configurationObjects);
-
- // this will throw ConfigObjectsNotResolvableException if the collection
- // of configuration objects are not self containing.
- resolveConfigurationObjects(lists);
-
- ConfigurationModelContainer cmc=null;
- try {
- Collection parms = new ArrayList(1);
- parms.add(configurationObjects);
- cmc = (ConfigurationModelContainer)
ReflectionHelper.create(CONFIG_MODEL_CLASS, parms, this.getClass().getClassLoader());
- } catch (MetaMatrixCoreException err) {
- throw new IOException(err.getMessage());
- }
-
-
- // this xmlHelper class contains all of the code to convert configuration
- // objects into JDOM Elements
- getXMLHelper();
-
- // this visitor will visit all of the configuration objects in a
- // configuration collecting their state as JDOM XML Elements
- XMLConfig_42_Visitor visitor = new XMLConfig_42_Visitor(xmlHelper);
-
-
-
- Element root = xmlHelper.createRootConfigurationDocumentElement();
-
- // create a new Document with a root element
- final Document doc = new Document(root);
-
- // add the header element
- root = XMLHelperUtil.addHeaderElement(root, props);
- //
root.addContent(xmlHelper.createHeaderElement(createHeaderProperties(props)));
-
- final Configuration config = cmc.getConfiguration();
- Element configElement = visitor.visitComponent(config);
-
- root.addContent(configElement);
-
- try {
- Iterator hostIt=cmc.getHosts().iterator();
- while(hostIt.hasNext()) {
- Host h = (Host) hostIt.next();
- final Element hostElement = visitor.visitComponent(h);
- configElement.addContent(hostElement);
-
- Iterator vmsIt=cmc.getConfiguration().getVMsForHost((HostID)
h.getID()).iterator();
-// getDeployedVMsForHost((HostID) h.getID()).iterator();
- while(vmsIt.hasNext()) {
- VMComponentDefn vm = (VMComponentDefn) vmsIt.next();
-// VMComponentDefn vm =
cmc.getConfiguration().getVMComponentDefn(vmDC.getVMComponentDefnID());
- final Element vmElement = visitor.visitComponent(vm);
- hostElement.addContent(vmElement);
-
- Map pscSvcMap = new HashMap(10);
- Collection depsvcs =
cmc.getConfiguration().getDeployedServicesForVM(vm);
- Iterator svcIt = depsvcs.iterator();
- while(svcIt.hasNext()) {
- DeployedComponent dc = (DeployedComponent) svcIt.next();
-// ComponentDefn defn = null;
-// if (dc.isDeployedService()) {
-// defn =
cmc.getConfiguration().getServiceComponentDefn(dc.getServiceComponentDefnID());
-// } else {
-// defn =
cmc.getConfiguration().getConnectorBinding(dc.getServiceComponentDefnID());
-//
-// }
-// if (defn == null) {
-// throw new ConfigObjectsNotResolvableException(
"DeployedComponent " + dc.getID() + " could not find service " +
dc.getServiceComponentDefnID(), dc); //$NON-NLS-1$ //$NON-NLS-2$
-// }
- final Element svcElement = visitor.visitComponent(dc);
- vmElement.addContent(svcElement);
- }
- // group the deployed services by pc for adding to the vm element
-// while(depIt.hasNext()) {
-//
-// DeployedComponent dc = (DeployedComponent) depIt.next();
-// if (!pscSvcMap.containsKey(dc.getProductServiceConfigID())) {
-// svcs = new ArrayList();
-// pscSvcMap.put(dc.getProductServiceConfigID(),svcs);
-// } else {
-// svcs = (Collection)
pscSvcMap.get(dc.getProductServiceConfigID());
-// }
-//
-// svcs.add(dc);
-// }
-
-
-// Iterator pscIt = pscSvcMap.keySet().iterator();
-// while(pscIt.hasNext()) {
-// ProductServiceConfigID pscID = (ProductServiceConfigID)
pscIt.next();
-// ProductServiceConfig psc =
cmc.getConfiguration().getPSC(pscID);
-//
-// final Element pscElement =
getXMLHelper().createDeployedProductServiceConfigElement(psc);
-// vmElement.addContent(pscElement);
-//
-// Collection depsvcs = (Collection) pscSvcMap.get(pscID);
-//
-// Iterator svcIt = depsvcs.iterator();
-// while(svcIt.hasNext()) {
-// DeployedComponent dc = (DeployedComponent) svcIt.next();
-//// ComponentDefn defn = null;
-//// if (dc.isDeployedService()) {
-//// defn =
cmc.getConfiguration().getServiceComponentDefn(dc.getServiceComponentDefnID());
-//// } else {
-//// defn =
cmc.getConfiguration().getConnectorBinding(dc.getServiceComponentDefnID());
-////
-//// }
-//// if (defn == null) {
-//// throw new ConfigObjectsNotResolvableException(
"DeployedComponent " + dc.getID() + " could not find service " +
dc.getServiceComponentDefnID(), dc); //$NON-NLS-1$ //$NON-NLS-2$
-//// }
-// final Element svcElement = visitor.visitComponent(dc);
-// pscElement.addContent(svcElement);
-//
-//
-// } // end of svcs
-//
-// } // end of pscs
-
- // Iterator
svcIt=cmc.getConfiguration().getDeployedServicesForVM(vmDC.getVMComponentDefnID()).iterator();
- // while(svcIt.hasNext()) {
- // DeployedComponent svcDc=(DeployedComponent) svcIt.next();
- // ComponentDefn cd = null;
- // if (svcDc.isDeployedConnector()) {
- // cd =
cmc.getConfiguration().getConnectorBinding(svcDc.getServiceComponentDefnID());
- // } else {
- // cd =
cmc.getConfiguration().getServiceComponentDefn(svcDc.getServiceComponentDefnID());
- // }
- // final Element svcElement = visitor.visitComponent(cd);
- // vmElement.addContent(svcElement);
- // }
-
-
- } // end of vms
-
- } // end of host
- } catch(Exception e) {
- throw new ConfigObjectsNotResolvableException(e, "Error exporting
configuration"); //$NON-NLS-1$
- }
-
- // iterate through the psc objects, if there are any,
- // and create elements for them.
-
-// Element pscsElement = xmlHelper.createProductServiceConfigsElement();
-// root.addContent(pscsElement);
-//
-// Collection pscs = cmc.getConfiguration().getPSCs();
-// if (pscs != null && pscs.size() > 0) {
-// Iterator iterator = pscs.iterator();
-// while (iterator.hasNext()) {
-// ProductServiceConfig type = (ProductServiceConfig)iterator.next();
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ProductType named: " + type + " in list of configuration objects to
export.");
-// Element productTypeElement = visitor.visitComponent(type);
-// pscsElement.addContent(productTypeElement);
-// }
-// }
-
- // iterate through the product type objects, if there are any,
- // and create elements for them.
-
-// Element productTypesElement = xmlHelper.createProductTypesElement();
-// root.addContent(productTypesElement);
-//
-// Collection productTypes = cmc.getProductTypes();
-// if (productTypes != null && productTypes.size() > 0) {
-// Iterator iterator = productTypes.iterator();
-// while (iterator.hasNext()) {
-// ProductType type = (ProductType)iterator.next();
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ProductType named: " + type + " in list of configuration objects to
export.");
-// Element productTypeElement = visitor.visitComponent(type);
-// productTypesElement.addContent(productTypeElement);
-// }
-// }
-
- Element resourcePoolsElement = xmlHelper.createResourcePoolsElement();
- root.addContent(resourcePoolsElement);
-
- Collection pools = cmc.getConnectionPools();
- if (pools != null && pools.size() > 0) {
- Iterator iterator = pools.iterator();
- while (iterator.hasNext()) {
- ResourceDescriptor type = (ResourceDescriptor)iterator.next();
-// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ProductType named: " + type + " in list of configuration objects to
export.");
- Element resourceElement = visitor.visitComponent(type);
- resourcePoolsElement.addContent(resourceElement);
- }
- }
-
- Element providersElement = xmlHelper.createAuthenticationProviderElement();
- root.addContent(providersElement);
-
- Collection providers = cmc.getConfiguration().getAuthenticationProviders();
- if (providers != null && providers.size() > 0) {
- Iterator iterator = providers.iterator();
- while (iterator.hasNext()) {
- AuthenticationProvider provider = (AuthenticationProvider)iterator.next();
-// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ProductType named: " + type + " in list of configuration objects to
export.");
- Element resourceElement = visitor.visitComponent(provider);
- providersElement.addContent(resourceElement);
- }
- }
-
-
- Element connectorsElement = xmlHelper.createConnectorBindingsElement();
- root.addContent(connectorsElement);
-
-
- Collection bindings = cmc.getConfiguration().getConnectorBindings();
- if (bindings != null && bindings.size() > 0) {
- Iterator iterator = bindings.iterator();
-
- while (iterator.hasNext()) {
- ConnectorBinding connector = (ConnectorBinding)iterator.next();
- Element connElement =
visitor.visitConnectorBindingComponent(connector);
- connectorsElement.addContent(connElement);
- }
-
- }
-
- Element servicessElement = xmlHelper.createServiceComponentDefnsElement();
- root.addContent(servicessElement);
-
-
- Collection svcdefns = cmc.getConfiguration().getServiceComponentDefns();
- if (svcdefns != null && svcdefns.size() > 0) {
- Iterator iterator = svcdefns.iterator();
-
- while (iterator.hasNext()) {
- ServiceComponentDefn svc = (ServiceComponentDefn)iterator.next();
- Element svcElement = visitor.visitComponent(svc);
- servicessElement.addContent(svcElement);
- }
-
- }
-
- Element resourcesElement = xmlHelper.createSharedResourcesElement();
- root.addContent(resourcesElement);
-
- Collection sharedResources = cmc.getResources();
- if (sharedResources != null && sharedResources.size() > 0) {
-
- Iterator iterator = sharedResources.iterator();
- while (iterator.hasNext()) {
- SharedResource resource = (SharedResource)iterator.next();
- // LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
SharedResource named: " + resource + " in list of configuration objects to
export.");
- Element resourceElement = visitor.visitComponent(resource);
- resourcesElement.addContent(resourceElement);
- }
- }
-
-
- Element componentTypesElement = xmlHelper.createComponentTypesElement();
- root.addContent(componentTypesElement);
-
- Map compTypes = cmc.getComponentTypes();
- if (compTypes != null && compTypes.size() > 0) {
-
- Iterator iterator = compTypes.values().iterator();
-
- while (iterator.hasNext()) {
- ComponentType componentType = (ComponentType)iterator.next();
- Element componentTypeElement = visitor.visitComponent(componentType);
- // LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ComponentType named: " + componentType + " in list of configuration objects to
export.");
-
- componentTypesElement.addContent(componentTypeElement);
- }
- }
-
-
- getXMLReaderWriter().writeDocument(doc, stream);
- stream.close();
-
- LogManager.logInfo(LogCommonConstants.CTX_CONFIG,
CommonPlugin.Util.getString("MSG.003.001.0003",
cmc.getConfigurationID().getFullName())); //$NON-NLS-1$
- }
-
- /**
- * <p>This method will be used to import a Collection of Configuration
objects
- * given an InputStream. If the InputStream resource does not contain enough
- * data to recombine all of the configuration objects in the Input Stream,
- * then a ConfigurationObjectsNotResolvableException
- * will be thrown.</p>
- *
- * <p>This method also allows you to rename the imported Configuration object
- * possibly to avoid name conflicts with other Configurations already in the
server.</p>
- *
- * <p>If the name parameter submitted is null, the name of the configuration
- * object as it exists in the InputStream will be used as the name
- * of the resulting Configuration object in the returned collection of
- * configuration objects.</p>
- *
- *
- * @param editor the ConfigurationObjectEditor to use to create the Configuration
- * objects in the InputStream resource.
- * @param stream the input stream to read the configuration object
- * representations from
- * @param name the name for the Configuration object to be created. Can
- * be null if the name specified in the input stream is to be used.
- * @return the configuration objects that were represented as data in the
- * InputStream resource
- * @throws ConfigObjectsNotResolvableException if the data representing
- * the Configuration to be imported is incomplete.
- * @throws IOException if there is an error reading from the InputStream
- * @throws InvalidConfigurationElementException if there is a problem with
- * the representation of the configuration element as it exists in the
- * InputStream resource, usually some type of formatting problem.
- */
- public Collection importConfigurationObjects(Element root,
- ConfigurationObjectEditor editor, String name)
- throws IOException, ConfigObjectsNotResolvableException,
- InvalidConfigurationElementException {
- Assertion.isNotNull(root);
- Assertion.isNotNull(editor);
-
-// *** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Importing a
Configuration...");
-
-
- ArrayList configurationObjects = new ArrayList();
-
- getXMLHelper();
-
- // get the first configuration element from the document
- Element configurationElement =
root.getChild(XMLConfig_42_ElementNames.Configuration.ELEMENT);
-
- // if there is no configuration element under the Configurations element
- // then we do not know how to import one.
- if (configurationElement == null) {
- throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0004,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0004));
- }
-
-
-
- // NOTE the ordering of the following iterations is very important
- // as the actions to create the configuration objects are being created
- // within the ConfigurationObjectEditor. If these are created out of
- // order, a Configuration object that references another configuration
- // object may be created before the configuration object that it references.
- // This will work fine until the actions are committed.
- Configuration config = xmlHelper.createConfiguration(configurationElement,
editor, name);
-
- ConfigurationID configID = (ConfigurationID) config.getID();
- configurationObjects.add(config);
-
- xmlHelper.addProperties(configurationElement, config, editor);
-
-
-
-
- Collection componentTypes = createComponentTypes(root, editor);
- Map componentTypeMap = new HashMap();
- if (componentTypes != null) {
- for (Iterator it=componentTypes.iterator(); it.hasNext();) {
- ComponentType type = (ComponentType) it.next();
- componentTypeMap.put(type.getID(), type);
- configurationObjects.add(type);
-
- }
- }
-
-
-
- Element resourcesElement =
root.getChild(XMLConfig_42_ElementNames.Resources.ELEMENT);
-
- List resources = null;
- if (resourcesElement != null) {
- resources =
resourcesElement.getChildren(XMLConfig_42_ElementNames.Resources.Resource.ELEMENT);
- } else {
- resources = Collections.EMPTY_LIST;
- }
-
- Iterator iterator = resources.iterator();
- while (iterator.hasNext()) {
- Element resourceElement = (Element)iterator.next();
- SharedResource resource = xmlHelper.createSharedResource(resourceElement,
editor);
-// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found Host
named: " + host + " in XML file Hosts element.");
- configurationObjects.add(resource);
- }
-
-// Map pscMap = new HashMap(1);
-// Element productServiceConfigsElement =
-// root.getChild(XMLConfig_42_ElementNames.ProductServiceConfigs.ELEMENT);
-// if (productServiceConfigsElement!=null) {
-// Collection productServiceConfigElements =
-//
productServiceConfigsElement.getChildren(XMLConfig_42_ElementNames.ProductServiceConfigs.ProductServiceConfig.ELEMENT);
-// pscMap = new HashMap(productServiceConfigElements.size());
-// iterator = productServiceConfigElements.iterator();
-// while (iterator.hasNext()) {
-// Element productServiceConfigElement = (Element)iterator.next();
-// ProductServiceConfig productServiceConfig =
-// xmlHelper.createProductServiceConfig(productServiceConfigElement,
configID, editor, null);
-// configurationObjects.add(productServiceConfig);
-// pscMap.put(productServiceConfig.getName(), productServiceConfig);
-//
-// }
-// }
-
-// else {
-//
-// Assertion.assertTrue(false, "No ProductServiceConfigs defined in
the ConfigurationDocument"); //$NON-NLS-1$
-//
-// }
-
- Element resourcePoolsElement =
- root.getChild(XMLConfig_42_ElementNames.ResourcePools.ELEMENT);
- if (resourcePoolsElement!=null) {
- Collection resourcePoolsElements =
-
resourcePoolsElement.getChildren(XMLConfig_42_ElementNames.ResourcePools.ResourcePool.ELEMENT);
-
- iterator = resourcePoolsElements.iterator();
- while (iterator.hasNext()) {
- Element resourcePoolElement = (Element)iterator.next();
- ResourceDescriptor pool =
- xmlHelper.createResourcePool(resourcePoolElement, configID,
editor);
- configurationObjects.add(pool);
-
- }
- }
-
- Element authprovidersElement =
- root.getChild(XMLConfig_42_ElementNames.AuthenticationProviders.ELEMENT);
- if (authprovidersElement!=null) {
- Collection authproviderElements =
-
authprovidersElement.getChildren(XMLConfig_42_ElementNames.AuthenticationProviders.Provider.ELEMENT);
-
- iterator = authproviderElements.iterator();
- while (iterator.hasNext()) {
- Element resourcePoolElement = (Element)iterator.next();
- AuthenticationProvider provider =
- xmlHelper.createAuthenticationProvider(resourcePoolElement,
configID, editor);
- configurationObjects.add(provider);
-
- }
- }
-
-
-
- Collection bindings = createConnectorBindings(configID, root, editor, true);
-
-
- Map serviceComponentDefnMap = new HashMap();
-
- for (Iterator itb=bindings.iterator(); itb.hasNext();) {
- ComponentDefn defn = (ComponentDefn) itb.next();
- serviceComponentDefnMap.put(defn.getID(), defn);
- }
-
- // this list of servicecomponent defns will be used in the creation
- // of deployed components, we need the actual reference to the
- // servicecomponentdefn to create a deployed version of it...
- Element serviceComponentDefnsElement =
- root.getChild(XMLConfig_42_ElementNames.ServiceComponentDefns.ELEMENT);
- if (serviceComponentDefnsElement!=null) {
- Collection serviceComponentDefnElements =
-
serviceComponentDefnsElement.getChildren(XMLConfig_42_ElementNames.ServiceComponentDefns.ServiceComponentDefn.ELEMENT);
-
- iterator = serviceComponentDefnElements.iterator() ;
- while (iterator.hasNext()) {
- Element serviceComponentDefnElement = (Element)iterator.next();
- ComponentDefn defn =
- xmlHelper.createServiceComponentDefn(serviceComponentDefnElement,
config, editor, null);
- serviceComponentDefnMap.put(defn.getID(), defn);
- configurationObjects.add(defn);
-
- }
- }
-
- // add the bindings to the map that is used by deployment
- configurationObjects.addAll(bindings);
-
- // retreive the host elements from the document.
- List hostElements =
configurationElement.getChildren(XMLConfig_42_ElementNames.Configuration.Host.ELEMENT);
- Iterator hostiterator = hostElements.iterator();
- Host host = null;
- HostID hostID = null;
- while (hostiterator.hasNext()) {
- Element hostElement = (Element)hostiterator.next();
-
- host = xmlHelper.createHost(hostElement,configID, editor, null);
- hostID = (HostID) host.getID();
- configurationObjects.add(host);
-
-
- List vmElements =
hostElement.getChildren(XMLConfig_42_ElementNames.Configuration.Process.ELEMENT);
- Iterator vmIt = vmElements.iterator();
- while (vmIt.hasNext()) {
- Element vmElement = (Element)vmIt.next();
-
- VMComponentDefn vm = xmlHelper.createVMComponentDefn(vmElement,
configID, hostID, editor, null);
-
-// DeployedComponent vmdc =
xmlHelper.createDeployedVMComponentDefn(vmElement, configID, hostID,
vm.getComponentTypeID(), editor);
- VMComponentDefnID vmID = (VMComponentDefnID) vm.getID();
-
- configurationObjects.add(vm);
-
- List svcElements =
vmElement.getChildren(XMLConfig_42_ElementNames.Configuration.DeployedService.ELEMENT);
-
- Iterator svcIt = svcElements.iterator();
- while (svcIt.hasNext()) {
- Element svcElement = (Element)svcIt.next();
- // create this only for use to create the deployed service
- DeployedComponent dc =
xmlHelper.createDeployedServiceComponent(svcElement, configID, hostID, vmID,
componentTypeMap, editor);
- configurationObjects.add(dc);
-
- } // end services
- } // end vm
-
- } // end host
-
-
-
-// Map vmComponentDefnMap = new HashMap();
-// Element vmComponentDefnsElement =
configurationElement.getChild(XMLConfig_42_ElementNames.Configurations.Configuration.VMComponentDefns.ELEMENT);
-// if (vmComponentDefnsElement!=null) {
-// Collection vmComponentDefnElements =
-//
vmComponentDefnsElement.getChildren(XMLConfig_42_ElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.ELEMENT);
-//
-// iterator = vmComponentDefnElements.iterator();
-// while (iterator.hasNext()) {
-// Element vmComponentDefnElement = (Element)iterator.next();
-// VMComponentDefn vmComponentDefn =
-// xmlHelper.createVMComponentDefn(vmComponentDefnElement,
(ConfigurationID) config.getID() , editor, null);
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
VMComponentDefn named: " + vmComponentDefn + " in XML file VMComponentDefns
element.");
-// vmComponentDefnMap.put(vmComponentDefn.getID(), vmComponentDefn);
-// configurationObjects.add(vmComponentDefn);
-//
-// }
-// }
-// Element deployedComponentsElement =
-//
configurationElement.getChild(XMLConfig_42_ElementNames.Configurations.Configuration.DeployedComponents.ELEMENT);
-// if (deployedComponentsElement!=null) {
-// Collection deployedComponentElements =
-//
deployedComponentsElement.getChildren(XMLConfig_42_ElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.ELEMENT);
-//
-// iterator = deployedComponentElements.iterator();
-// while (iterator.hasNext()) {
-// Element deployedComponentElement = (Element)iterator.next();
-// DeployedComponent deployedComponent =
-// xmlHelper.createDeployedComponent(deployedComponentElement,
config, editor, serviceComponentDefnMap, vmComponentDefnMap, componentTypeMap, null);
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
DeployedComponent named: " + deployedComponent + " in XML file
DeployedComponents element.");
-// configurationObjects.add(deployedComponent);
-// }
-// }
- // this will ensure that the actions that exist in the editor are
- // self contained....that there are no references to configuration objects
- // in the configuration objects that are not also contained in the Collection
- resolveConfigurationObjects(configurationObjects);
-
-// *** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0006);
-
- return configurationObjects;
- }
-
-
-
- protected XMLHelper getXMLHelper() {
- if (xmlHelper == null) {
- xmlHelper = new XMLConfig_42_HelperImpl();
-
- }
- return xmlHelper;
-
- }
-
-// protected Properties createHeaderProperties(Properties props) {
-// Properties defaultProperties = new Properties();
-// defaultProperties.setProperty(ConfigurationPropertyNames.USER_CREATED_BY,
DEFAULT_USER_CREATED_BY);
-//
-// // the properties passed in by the user override those put in by this
-// // method.
-// if (props!=null) {
-// defaultProperties.putAll(props);
-// }
-//
defaultProperties.setProperty(ConfigurationPropertyNames.CONFIGURATION_VERSION,
ConfigurationPropertyNames.MM_CONFIG_4_2_VERSION);
-//
defaultProperties.setProperty(ConfigurationPropertyNames.METAMATRIX_SYSTEM_VERSION,
MetaMatrixProductNames.VERSION_NUMBER);
-// defaultProperties.setProperty(ConfigurationPropertyNames.TIME,
DateUtil.getCurrentDateAsString());
-//
-//
-// return defaultProperties;
-// }
-
- /**
- * <p>This method will be used to import a ComponentType Object</p>
- *
- * <p>This method also allows you to rename the imported ComponentType 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 configuration
- * object as it exists in the DirectoryEntry will be used.</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
- * @return the configuration object that was represented as data in the
- * DirectoryEntry resource
- * @param name the name for the ComponentType object to be created.
- * @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 ComponentType importComponentType(Element root,
- //InputStream stream,
- ConfigurationObjectEditor editor, String name)
- throws IOException, InvalidConfigurationElementException {
-
-// Assertion.isNotNull(stream);
- Assertion.isNotNull(editor);
-
-// *** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Importing a
ComponentType object...");
-
-// Document doc = null;
-//
-// try {
-// doc = getXMLReaderWriter().readDocument(stream);
-// }catch(JDOMException e) {
-// e.printStackTrace();
-// throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0005));
-// }
-// Element root = doc.getRootElement();
-
-
- ComponentType t = createComponentType(root, editor, name);
-
-// *** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0007, t.getName());
-
- return t;
- }
-
- /**
- * <p>This method will be used to import 1 or more a ComponentType
Objects.</p>
- *
- * @param editor the ConfigurationObjectEditor to use to create the Configuration
- * objects.
- * @param stream the input stream to read the configuration object
- * representation from
- * @return Collection of objects of type <code>ComponentType</code>
- * @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 Collection importComponentTypes(Element root,
- //InputStream stream,
- ConfigurationObjectEditor editor)
- throws IOException, InvalidConfigurationElementException {
-// Assertion.isNotNull(stream);
- Assertion.isNotNull(editor);
-
-
- Collection connectorTypes = createComponentTypes(root, editor) ;
-
- return connectorTypes;
-
- }
-
-
- protected ComponentType createComponentType(Element root, ConfigurationObjectEditor
editor, String name) throws InvalidConfigurationElementException{
- XMLHelper helper = getXMLHelper();
-
-// Element root = doc.getRootElement();
-
- Element componentTypesElement =
root.getChild(XMLElementNames.ComponentTypes.ELEMENT);
-
- if (componentTypesElement == null) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0008,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0008,XMLElementNames.ComponentTypes.ELEMENT));
- }
-
- Element componentTypeElement =
componentTypesElement.getChild(XMLElementNames.ComponentTypes.ComponentType.ELEMENT);
-
- if (componentTypeElement == null) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0008,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0008,XMLElementNames.ComponentTypes.ComponentType.ELEMENT));
- }
-
- return helper.createComponentType(componentTypeElement, editor, name, true);
- }
-
- protected Collection createComponentTypes(Element root, ConfigurationObjectEditor
editor) throws InvalidConfigurationElementException{
-
- Element componentTypesElement =
root.getChild(XMLElementNames.ComponentTypes.ELEMENT);
-
- if (componentTypesElement == null) {
- return Collections.EMPTY_LIST;
- }
-
-
- // Make a copy of the lists that we intend to change so that we don't
affect JDOM's list (which changes the underlying structure)
- List componentTypes = new
ArrayList(componentTypesElement.getChildren(XMLElementNames.ComponentTypes.ComponentType.ELEMENT));
-
- List connObjects = null;
-
- if (componentTypes != null) {
- connObjects = new ArrayList(componentTypes.size());
-
- getXMLHelper().orderComponentTypeElementList(componentTypes);
- Iterator iterator = componentTypes.iterator();
- while (iterator.hasNext()) {
- Element connElement = (Element)iterator.next();
- ComponentType type = getXMLHelper().createComponentType(connElement,
editor, null, true);
- connObjects.add(type);
-
- }
- } else {
- return Collections.EMPTY_LIST;
- }
-
-
-// List connObjects = null;
-// if (connectorTypes != null) {
-// connObjects = new ArrayList(connectorTypes.size());
-// Iterator iterator = connectorTypes.iterator();
-// while (iterator.hasNext()) {
-// Element connElement = (Element)iterator.next();
-// ComponentType type = helper.createComponentType(connElement, editor,
null, true);
-// connObjects.add(type);
-// }
-// } else {
-// return Collections.EMPTY_LIST;
-// }
-
- return connObjects;
- }
-
-
-
-
-}
Deleted:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_Visitor.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_Visitor.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_Visitor.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -1,146 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.xml;
-
-//note that this class is in the model directory so that the Configuration
-//object implementations can invoke the package level methods on it
-import org.jdom.Element;
-
-import com.metamatrix.common.config.api.AuthenticationProvider;
-import com.metamatrix.common.config.api.ComponentDefn;
-import com.metamatrix.common.config.api.ComponentObject;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationObjectEditor;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.config.api.Host;
-import com.metamatrix.common.config.api.ResourceDescriptor;
-import com.metamatrix.common.config.api.ServiceComponentDefn;
-import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.config.api.VMComponentDefn;
-import com.metamatrix.common.config.model.BasicUtil;
-import com.metamatrix.core.util.Assertion;
-
-/**
-* This class is used to create a Configuration XML element that will contain
-* all of the information related to a Configuration object. The pattern for
-* use of this class should be to ONLY pass this visitor to a Configuration object
-* throught its accept() method. DO NOT pass this visitor directly to any
-* configuration object other than a Configuration object. The algorithm will
-* fail.
-*
-*/
-public class XMLConfig_42_Visitor {
-
- private XMLConfig_42_HelperImpl helper;
- private ConfigurationObjectEditor editor;
-
- // these local variables are used to hold the current Element that all
- // subsequent Elments of that type are to be added to. When a new
- // configuration is visited, new category elements are created and put
- // into these references so that subsequent configuration objects will
- // be put in the category elements for that new configuration.
-// private Element systemPropertiesElement;
-// private Element productServiceConfigsElement;
-// private Element serviceDefnsElement;
-// private Element resourcePoolsElement;
-// private Element connectorsElement;
-// private Element deployedComponentsElement;
-// private Element vmComponentDefnsElement;
-// private Element hostsElement;
-// private Element compTypesElement;
-
- /**
- * This constructor does nothing.
- */
- public XMLConfig_42_Visitor(XMLConfig_42_HelperImpl impl) {
- helper = impl;
-
- }
-
- public XMLConfig_42_Visitor(XMLConfig_42_HelperImpl impl, ConfigurationObjectEditor
configEditor) {
- helper = impl;
- editor = configEditor;
- }
-
- public ConfigurationObjectEditor getEditor() {
- return editor;
- }
-
- Element visitComponent(ComponentType component) {
-// if (component instanceof ProductType) {
-// return helper.createProductTypeElement((ProductType) component);
-// }
- return helper.createComponentTypeElement(component);
-
- }
-
-
- Element visitComponent(ComponentObject component) {
- Assertion.isNotNull(component);
-
- switch(BasicUtil.getComponentDefnType(component)){
- case ComponentDefn.VM_COMPONENT_CODE:
- return helper.createVMComponentDefnElement((VMComponentDefn) component);
-// case ComponentDefn.PSC_COMPONENT_CODE:
-// return helper.createProductServiceConfigElement((ProductServiceConfig)
component);
- case ComponentDefn.CONNECTOR_COMPONENT_CODE:
- return helper.createServiceComponentDefnElement((ServiceComponentDefn)
component);
-
-
-// return helper.createConnectorBindingElement((ConnectorBinding) component,
true);
- case ComponentDefn.SERVICE_COMPONENT_CODE:
- return helper.createServiceComponentDefnElement((ServiceComponentDefn)
component);
- case ComponentDefn.AUTHPROVIDER_COMPONENT_CODE:
- return helper.createAuthenticationProviderElement((AuthenticationProvider)
component);
-
- case ComponentDefn.RESOURCE_DESCRIPTOR_COMPONENT_CODE:
- return helper.createResourcePoolElement((ResourceDescriptor) component);
- case ComponentDefn.HOST_COMPONENT_CODE:
- return helper.createDeployedHostElement((Host) component);
- case ComponentDefn.CONFIGURATION_COMPONENT_CODE:
- return helper.createConfigurationElement((Configuration) component);
- case ComponentDefn.DEPLOYED_COMPONENT_CODE:
- return helper.createDeployedComponentElement((DeployedComponent)
component);
- case ComponentDefn.SHARED_RESOURCE_COMPONENT_CODE:
- return helper.createSharedResourceElement((SharedResource) component);
-// case ComponentDefn.PRODUCT_COMPONENT_CODE:
-// return helper.createProductTypeElement((ProductType) component);
-
- }
- return null;
- }
-
- Element visitConnectorBindingComponent(ComponentObject component) {
- Assertion.isNotNull(component);
- return helper.createConnectorBindingElement((ConnectorBinding) component, true);
-
- }
-
-
-
-
-
-}
-
Deleted:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_Base_ImportExportUtility.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_Base_ImportExportUtility.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_Base_ImportExportUtility.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -1,1519 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.xml;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.config.api.ComponentDefn;
-import com.metamatrix.common.config.api.ComponentObject;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeID;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConfigurationObjectEditor;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.config.api.Host;
-import com.metamatrix.common.config.api.ResourceDescriptor;
-import com.metamatrix.common.config.api.ServiceComponentDefn;
-import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.config.api.VMComponentDefn;
-import com.metamatrix.common.config.util.ConfigObjectsNotResolvableException;
-import com.metamatrix.common.config.util.ConfigurationImportExportUtility;
-import com.metamatrix.common.config.util.ConfigurationPropertyNames;
-import com.metamatrix.common.config.util.InvalidConfigurationElementException;
-import com.metamatrix.common.namedobject.BaseObject;
-import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.common.xml.XMLReaderWriter;
-import com.metamatrix.common.xml.XMLReaderWriterImpl;
-import com.metamatrix.core.util.Assertion;
-
-/**
-* 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.
-*
-*/
-public abstract class XMLConfig_Base_ImportExportUtility implements
ConfigurationPropertyNames {
-
- private XMLReaderWriter readerWriter;
-// private XMLHelper helper = null;
-
- /**
- * These static variables define the constants that will be used to
- * create the header for every document that is produced using this concrete
- * utility.
- */
- public static final String DEFAULT_USER_CREATED_BY = "Unknown";
//$NON-NLS-1$
-
- /**
- * These indices are the indices used to retreive the Lists from the array
- * of lists from the segregateConfigurationObjects method.
- */
- static final int CONFIGURATIONS_INDEX = 0;
-// static final int PRODUCT_TYPES_INDEX = 1;
- static final int HOSTS_INDEX = 2;
- static final int DEPLOYED_COMPONENTS_INDEX = 3;
- static final int SERVICE_COMPONENT_DEFNS_INDEX = 4;
- static final int VM_COMPONENT_DEFNS_INDEX = 5;
- static final int COMPONENT_TYPES_INDEX = 6;
- // static final int PRODUCT_SERVICE_CONFIGS_INDEX = 7;
- static final int CONNECTION_POOL_CONFIGS_INDEX = 16;
- static final int RESOURCES_INDEX = 18;
- static final int CONNECTORS_INDEX = 19;
-
-
- static final int CONFIGURATION_IDS_INDEX = 8;
-// static final int PRODUCT_TYPE_IDS_INDEX = 9;
- static final int HOST_IDS_INDEX = 10;
- static final int DEPLOYED_COMPONENT_IDS_INDEX = 11;
- static final int SERVICE_COMPONENT_DEFN_IDS_INDEX = 12;
- static final int VM_COMPONENT_DEFN_IDS_INDEX = 13;
- static final int COMPONENT_TYPE_IDS_INDEX = 14;
-// static final int PRODUCT_SERVICE_CONFIG_IDS_INDEX = 15;
-// private static final int CONNECTION_POOL_CONFIG_IDS_INDEX = 17;
- static final int CONNECTORS_IDS_INDEX = 20;
-
-
- static final int NUMBER_OF_LISTS = 21;
-
- /**
- * <p>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.</p>
- *
- * <p>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.</p>
- *
- * <pre>
- * 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
- * </pre>
- *
- *
- * <p> All of the above object references must be in the collection passed
- * into this method.</p>
- *
- * <p> 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.</p>
- *
- * <pre>
- * ConfigurationPropertyNames.APPLICATION_CREATED_BY
- * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
- * ConfigurationPropertyNames.USER_CREATED_BY
- * <pre>
- *
- * <p>Any of these properties that are not included in the properties object
- * will not be included in the header Element.
- *
- * @param stream the output stream to write the Configuration Object
- * representation to
- * @param configurationObjects a Collection of configuration objects that
- * represents an entire logical Configuration.
- * @param props the properties object that contains the values for the Header
- * @throws IOException if there is an error writing to the DirectoryEntry
- * @throws 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
- */
-// public void exportConfiguration(OutputStream stream,
-// Collection configurationObjects, Properties props)
-// throws IOException, ConfigObjectsNotResolvableException {
-//
-//
-// Assertion.isNotNull(configurationObjects);
-// Assertion.isNotNull(stream);
-//
-// // this will throw ConfigObjectsNotResolvableException if the collection
-// // of configuration objects are not self containing.
-// resolveConfigurationObjects(configurationObjects);
-//
-// // this will divide the configuration objects by their type
-// // so that we can create an XML doc and put the objects in their proper
-// // categories.
-// List[] lists = segregateConfigurationObjects(configurationObjects);
-//
-// List configurations = lists[CONFIGURATIONS_INDEX];
-// List productTypes = lists[PRODUCT_TYPES_INDEX];
-// List hosts = lists[HOSTS_INDEX];
-// List componentTypes = lists[COMPONENT_TYPES_INDEX];
-// List resources = lists[RESOURCES_INDEX];
-// List connectors = lists[CONNECTORS_INDEX];
-//
-//
-//
-// // this helper class contains all of the code to convert configuration
-// // objects into JDOM Elements
-// XMLHelper helper = getXMLHelper();
-//
-// // this visitor will visit all of the configuration objects in a
-// // configuration collecting their state as JDOM XML Elements
-// XMLConfigurationVisitor visitor = new XMLConfigurationVisitor(helper);
-//
-//
-// Element root = helper.createRootConfigurationDocumentElement();
-//
-// // create a new Document with a root element
-// Document doc = new Document(root);
-//
-// // add the header element
-// root.addContent(helper.createHeaderElement(createHeaderProperties(props)));
-//
-//// String configName = "";
-// // iterate through the configuration objects, if there are any,
-// // and create elements for them.
-// Iterator iterator = configurations.iterator();
-// if (iterator.hasNext()) {
-// Element configurationsElement = helper.createConfigurationsElement();
-// root.addContent(configurationsElement);
-// while (iterator.hasNext()) {
-// Configuration config = (Configuration)iterator.next();
-//
-// // generally only one configuration is done at a time
-//// configName = config.getID().getFullName();
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
Configuration named: " + config + " in list of configuration objects to
export.");
-// // this will cause the visitor to visit and build XML for the
-// // Configuration object and all objects that the Configuration
-// // references directly.
-// config.accept(visitor);
-// configurationsElement.addContent(visitor.getConfigurationElement());
-// }
-// }
-//
-// iterator = connectors.iterator();
-// if (iterator.hasNext()) {
-// Element connectorsElement = helper.createConnectorBindingsElement();
-// root.addContent(connectorsElement);
-// while (iterator.hasNext()) {
-// ConnectorBinding connector = (ConnectorBinding)iterator.next();
-// Element connElement = helper.createConnectorBindingElement(connector,
true);
-// connectorsElement.addContent(connElement);
-// }
-// }
-//
-//
-// // iterate through the product type objects, if there are any,
-// // and create elements for them.
-// iterator = productTypes.iterator();
-// if (iterator.hasNext()) {
-// Element productTypesElement = helper.createProductTypesElement();
-// root.addContent(productTypesElement);
-// while (iterator.hasNext()) {
-// ProductType type = (ProductType)iterator.next();
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ProductType named: " + type + " in list of configuration objects to
export.");
-// Element productTypeElement = helper.createProductTypeElement(type);
-// productTypesElement.addContent(productTypeElement);
-// }
-// }
-//
-// iterator = hosts.iterator();
-// if (iterator.hasNext()) {
-// Element hostsElement = helper.createHostsElement();
-// root.addContent(hostsElement);
-// while (iterator.hasNext()) {
-// Host host = (Host)iterator.next();
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found Host
named: " + host + " in list of configuration objects to export.");
-// Element hostElement = helper.createHostElement(host);
-// hostsElement.addContent(hostElement);
-// }
-// }
-//
-// iterator = resources.iterator();
-// if (iterator.hasNext()) {
-// Element resourcesElement = helper.createSharedResourcesElement();
-// root.addContent(resourcesElement);
-// while (iterator.hasNext()) {
-// SharedResource resource = (SharedResource)iterator.next();
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
SharedResource named: " + resource + " in list of configuration objects to
export.");
-// Element resourceElement =
helper.createSharedResourceElement(resource);
-// resourcesElement.addContent(resourceElement);
-// }
-// }
-//
-//
-// iterator = componentTypes.iterator();
-// if (iterator.hasNext()) {
-// Element componentTypesElement = helper.createComponentTypesElement();
-// root.addContent(componentTypesElement);
-// while (iterator.hasNext()) {
-// ComponentType componentType = (ComponentType)iterator.next();
-// Element componentTypeElement =
helper.createComponentTypeElement(componentType);
-//// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found
ComponentType named: " + componentType + " in list of configuration objects to
export.");
-//
-// componentTypesElement.addContent(componentTypeElement);
-// }
-// }
-//
-//
-//
-// getXMLReaderWriter().writeDocument(doc, stream);
-// stream.close();
-//// I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0003, configName);
-// }
-//
-
- public void exportComponentType(OutputStream stream, ComponentType type,
- Properties props) throws IOException {
-
-
- Assertion.isNotNull(type);
- Assertion.isNotNull(stream);
-
-// LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Exporting a
ComponentType: "+ type.getName() + ".");
-
- XMLHelper helper = getXMLHelper();
-
- Element root = helper.createRootConfigurationDocumentElement();
-
- // create a new Document with a root element
- Document doc = new Document(root);
-
- // add the header element
- root = XMLHelperUtil.addHeaderElement(root, props);
-// root.addContent(helper.createHeaderElement(createHeaderProperties(props)));
-
- Element componentTypesElement = helper.createComponentTypesElement();
- root.addContent(componentTypesElement);
- componentTypesElement.addContent(helper.createComponentTypeElement(type));
-
- getXMLReaderWriter().writeDocument(doc, stream);
-// I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0004, type.getName());
- }
-
- public void exportComponentTypes(OutputStream stream, ComponentType[] types,
- Properties props) throws IOException {
-
-
- Assertion.isNotNull(types);
- Assertion.isNotNull(stream);
-
-// LogManager.logDetail(LogCommonConstants.CTX_CONFIG,
"Exporting a ComponentType: "+ type.getName() + ".");
-
- XMLHelper helper = getXMLHelper();
-
- Element root = helper.createRootConfigurationDocumentElement();
-
- // create a new Document with a root element
- Document doc = new Document(root);
-
- // add the header element
- root = XMLHelperUtil.addHeaderElement(root, props);
-// root.addContent(helper.createHeaderElement(createHeaderProperties(props)));
-
- Element componentTypesElement = helper.createComponentTypesElement();
- root.addContent(componentTypesElement);
-
- int s = types.length;
-
- for (int i = 0; i<s; i++) {
- ComponentType type = types[i];
-
-
componentTypesElement.addContent(helper.createComponentTypeElement(type));
-
- }
-
- getXMLReaderWriter().writeDocument(doc, stream);
-// I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0004, type.getName());
- }
-
-
-
- /**
- * <p>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.</p>
- *
- * <p>Multiple ServiceComponentDefns can be written to the same DirectoryEntry
- * by passing the same DirectoryEntry instance to this method multiple
times.</p>
- *
- * <p> The properties object that is passed into this method may contain
- * the following properties as defined by the ConfigurationPropertyNames
class.</p>
- *
- * <pre>
- * ConfigurationPropertyNames.APPLICATION_CREATED_BY
- * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
- * ConfigurationPropertyNames.USER_CREATED_BY
- * <pre>
- *
- * <p>Any of these properties that are not included in the properties object
- * will not be included in the header Element.
- *
- * @param stream the output stream to write the Configuration Object
- * representation to
- * @param type the ComponentType of the ServiceComponentDefn to be written
- * to the DirectoryEntry resource.
- * @param defn the ServiceComponentDefn instance to write to the DirectoryEntry.
- * @param props the properties object that contains the values for the Header
- * @throws IOException if there is an error writing to the DirectoryEntry
- * @throws ConfigObjectsNotResolvableException if the passed in
- * ComponentType is not the type referenced by the passed in ServiceComponentDefn.
- */
- public void exportServiceComponentDefn(OutputStream stream,
- ServiceComponentDefn defn, ComponentType type, Properties props)
- throws IOException, ConfigObjectsNotResolvableException {
- Assertion.isNotNull(defn);
- Assertion.isNotNull(type);
- Assertion.isNotNull(stream);
-
-// LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Exporting a
ServiceDefinition: " + defn.getName() + ".");
-
- List configurationObjects = new ArrayList(2);
-
- configurationObjects.add(defn);
- configurationObjects.add(type);
-
- // here we need to make sure that the serviceComponentDefn references
- // the passed in ComponentType instance. If not, this will throw
- // the ConfigObjectsNotResolvableException
- resolveConfigurationObjects(configurationObjects);
-// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Configuration objects
to export resolved properly.");
-
- XMLHelper helper = getXMLHelper();
-
- Element root = helper.createRootConfigurationDocumentElement();
-
- // create a new Document with a root element
- Document doc = new Document(root);
-
- root = XMLHelperUtil.addHeaderElement(root, props);
-
- // add the header element
-// root.addContent(helper.createHeaderElement(createHeaderProperties(props)));
-
- Element componentTypesElement = helper.createComponentTypesElement();
- root.addContent(componentTypesElement);
- componentTypesElement.addContent(helper.createComponentTypeElement(type));
-
- Element serviceComponentDefnsElement =
helper.createServiceComponentDefnsElement();
- root.addContent(serviceComponentDefnsElement);
-
serviceComponentDefnsElement.addContent(helper.createServiceComponentDefnElement(defn));
-
- getXMLReaderWriter().writeDocument(doc, stream);
-// I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0005, defn.getName());
- }
-
-
- protected Collection createConnectorBindings(ConfigurationID configurationID, Element
root, ConfigurationObjectEditor editor, boolean importExistingBinding)
- throws IOException, ConfigObjectsNotResolvableException,
- InvalidConfigurationElementException {
-// Element root = doc.getRootElement();
- Element connectorsElement =
root.getChild(XMLElementNames.ConnectorComponents.ELEMENT);
- if (connectorsElement == null) {
- return Collections.EMPTY_LIST;
- }
-
- List connectorBindings =
connectorsElement.getChildren(XMLElementNames.ConnectorComponents.ConnectorComponent.ELEMENT);
-
- List connObjects = new ArrayList(connectorBindings.size());
- if (connectorBindings != null) {
- Iterator iterator = connectorBindings.iterator();
- while (iterator.hasNext()) {
- Element connElement = (Element)iterator.next();
- ConnectorBinding conn =
getXMLHelper().createConnectorBinding(configurationID, connElement, editor, null,
importExistingBinding);
-// System.out.println("Created Connector Binding " + conn.getID());
- // LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Found Host named:
" + host + " in XML file Hosts element.");
- connObjects.add(conn);
- }
- }
-
- return connObjects;
- }
-
- protected ConnectorBinding createConnectorBinding(ConfigurationID configurationID,
Element root, ConfigurationObjectEditor editor, String name, boolean isImportConfig)
- throws IOException, ConfigObjectsNotResolvableException,
- InvalidConfigurationElementException {
-// Element root = doc.getRootElement();
- Element connectorsElement =
root.getChild(XMLElementNames.ConnectorComponents.ELEMENT);
- if (connectorsElement == null) {
- return null;
- }
-
- List connectorBindings =
connectorsElement.getChildren(XMLElementNames.ConnectorComponents.ConnectorComponent.ELEMENT);
-
- // return the first binding to be created because only one
- // binding is created in this method
- if (connectorBindings != null) {
- Iterator iterator = connectorBindings.iterator();
- while (iterator.hasNext()) {
- Element connElement = (Element)iterator.next();
- ConnectorBinding conn =
getXMLHelper().createConnectorBinding(configurationID, connElement, editor, name,
isImportConfig);
- return conn;
- }
- }
-
- return null;
- }
-
- /**
- * <p>This method will be used to import a ComponentType Object</p>
- *
- * <p>This method also allows you to rename the imported ComponentType 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 configuration
- * object as it exists in the DirectoryEntry will be used.</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
- * @return the configuration object that was represented as data in the
- * DirectoryEntry resource
- * @param name the name for the ComponentType object to be created.
- * @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 ComponentType importComponentType(Element root,
-// //InputStream stream,
-// ConfigurationObjectEditor editor, String name)
-// throws IOException, InvalidConfigurationElementException {
-//
-// // Assertion.isNotNull(stream);
-// Assertion.isNotNull(editor);
-//
-////*** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Importing a
ComponentType object...");
-//
-//// Document doc = null;
-////
-//// try {
-//// doc = getXMLReaderWriter().readDocument(stream);
-//// }catch(JDOMException e) {
-//// e.printStackTrace();
-//// throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0005));
-//// }
-//// Element root = doc.getRootElement();
-//
-//
-// ComponentType t = createComponentType(root, editor, name);
-//
-////*** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0007, t.getName());
-//
-// return t;
-// }
-// /**
-// * <p>This method will be used to import 1 or more a ComponentType
Objects.</p>
-// *
-// * @param editor the ConfigurationObjectEditor to use to create the Configuration
-// * objects.
-// * @param stream the input stream to read the configuration object
-// * representation from
-// * @return Collection of objects of type <code>ComponentType</code>
-// * @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 Collection importComponentTypes(InputStream stream,
-// ConfigurationObjectEditor editor)
-// throws IOException, 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_0005));
-// }
-//
-// Element root = doc.getRootElement();
-//
-//
-// Collection connectorTypes = createComponentTypes(root, editor) ;
-//
-// return connectorTypes;
-//
-// }
-
-
-
-
- /**
- * <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>
- * ConfigurationImportExportUtility.COMPONENT_TYPE_INDEX
- * ConfigurationImportExportUtility.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);
-
-//*** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Importing a
ServiceComponentDefn object.");
-
- Document doc = null;
-
-
- try {
- doc = getXMLReaderWriter().readDocument(stream);
- }catch(JDOMException e) {
- e.printStackTrace();
- throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0006));
- }
-
- XMLHelper helper = getXMLHelper();
-
- Element root = doc.getRootElement();
-
- ComponentType type = createComponentType(root, editor,
name[ConfigurationImportExportUtility.COMPONENT_TYPE_INDEX]);
-
- Element serviceComponentDefnsElement =
root.getChild(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ELEMENT);
-
- if (serviceComponentDefnsElement == null) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0008,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0008,
XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ELEMENT));
- }
-
-
- Element serviceComponentDefnElement =
serviceComponentDefnsElement.getChild(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.ELEMENT);
-
- ComponentDefn cd = helper.createServiceComponentDefn(serviceComponentDefnElement,
config, editor, name[ConfigurationImportExportUtility.SERVICE_COMPONENT_DEFN_INDEX]);
- Object[] object = {type, cd};
-
-
-//*** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0008, cd.getName());
-
- return object;
- }
-
-// protected Collection createComponentTypes(Element root, ConfigurationObjectEditor
editor) throws InvalidConfigurationElementException{
-//
-// Element componentTypesElement =
root.getChild(XMLElementNames.ComponentTypes.ELEMENT);
-//
-// if (componentTypesElement == null) {
-// return Collections.EMPTY_LIST;
-// }
-//
-//
-// List componentTypes =
componentTypesElement.getChildren(XMLElementNames.ComponentTypes.ComponentType.ELEMENT);
-//
-// List connObjects = null;
-//
-// if (componentTypes != null) {
-// connObjects = new ArrayList(componentTypes.size());
-//
-// getXMLHelper().orderComponentTypeElementList(componentTypes);
-// Iterator iterator = componentTypes.iterator();
-// while (iterator.hasNext()) {
-// Element connElement = (Element)iterator.next();
-// ComponentType type = getXMLHelper().createComponentType(connElement,
editor, null, true);
-// connObjects.add(type);
-//
-// }
-// } else {
-// return Collections.EMPTY_LIST;
-// }
-//
-//
-//// List connObjects = null;
-//// if (connectorTypes != null) {
-//// connObjects = new ArrayList(connectorTypes.size());
-//// Iterator iterator = connectorTypes.iterator();
-//// while (iterator.hasNext()) {
-//// Element connElement = (Element)iterator.next();
-//// ComponentType type = helper.createComponentType(connElement, editor,
null, true);
-//// connObjects.add(type);
-//// }
-//// } else {
-//// return Collections.EMPTY_LIST;
-//// }
-//
-// return connObjects;
-// }
-
-
- protected ComponentType createComponentType(Element root, ConfigurationObjectEditor
editor, String name) throws InvalidConfigurationElementException{
- XMLHelper helper = getXMLHelper();
-
-// Element root = doc.getRootElement();
-
- Element componentTypesElement =
root.getChild(XMLElementNames.ComponentTypes.ELEMENT);
-
- if (componentTypesElement == null) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0008,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0008,XMLElementNames.ComponentTypes.ELEMENT));
- }
-
- Element componentTypeElement =
componentTypesElement.getChild(XMLElementNames.ComponentTypes.ComponentType.ELEMENT);
-
- if (componentTypeElement == null) {
- throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0008,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0008,XMLElementNames.ComponentTypes.ComponentType.ELEMENT));
- }
-
- return helper.createComponentType(componentTypeElement, editor, name, true);
- }
-
- /**
- * <p>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.</p>
- *
- * <p>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.</p>
- *
- * <p> The properties object that is passed into this method may contain
- * the following properties as defined by the ConfigurationPropertyNames
class.</p>
- *
- * <pre>
- * ConfigurationPropertyNames.APPLICATION_CREATED_BY
- * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
- * ConfigurationPropertyNames.USER_CREATED_BY
- * <pre>
- *
- * <p>Any of these properties that are not included in the properties object
- * will not be included in the header Element.
- *
- * @param stream the output stream to write the Configuration Object
- * representation to
- * @param type the ComponentType to be written to the InputStream
- * @param props the properties object that contains the values for the Header
- * @throws IOException if there is an error writing to the InputStream
- */
- public void exportConnector(OutputStream stream, ComponentType type, Properties
props) throws IOException {
- // no resolving issues with this implementation...
- exportComponentType(stream, type, props);
- }
-
- /**
- * <p>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.</p>
- *
- * <p> The properties object that is passed into this method may contain
- * the following properties as defined by the ConfigurationPropertyNames
class.</p>
- *
- * <pre>
- * ConfigurationPropertyNames.APPLICATION_CREATED_BY
- * ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY
- * ConfigurationPropertyNames.USER_CREATED_BY
- * <pre>
- *
- * <p>Any of these properties that are not included in the properties object
- * will not be included in the header Element.
- *
- * @param stream the output stream to write the Configuration Object
- * representation to
- * @param type the ComponentType of the ServiceComponentDefn to be written
- * to the InputStream resource.
- * @param defn the ServiceComponentDefn instance to write to the InputStream.
- * @param props the properties object that contains the values for the Header
- * @throws IOException if there is an error writing to the InputStream
- * @throws ConfigObjectsNotResolvableException if the passed in
- * ComponentType is not the type referenced by the passed in ServiceComponentDefn.
- */
- public void exportConnectorBinding(OutputStream stream, ConnectorBinding defn,
ComponentType type, Properties props) throws IOException,
ConfigObjectsNotResolvableException {
- Assertion.isNotNull(defn);
- Assertion.isNotNull(type);
- Assertion.isNotNull(stream);
-
-//*** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Exporting
Connector Binding: " + defn.getName() + ".");
-
- // here we ensure that this is a Connector and that the given component
- // type resolves to the given ServiceComponentDefn.
- resolveConnector(type, defn);
-
-// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Connector binding
object to export resolved properly.");
-
- XMLHelper helper = getXMLHelper();
-
- Element root = helper.createRootConfigurationDocumentElement();
-
- // create a new Document with a root element
- Document doc = new Document(root);
-
- root = XMLHelperUtil.addHeaderElement(root, props);
- // add the header element
-// root.addContent(helper.createHeaderElement(createHeaderProperties(props)));
-
- Element componentTypesElement = helper.createComponentTypesElement();
- root.addContent(componentTypesElement);
- componentTypesElement.addContent(helper.createComponentTypeElement(type));
-
- Element connectorsElement = helper.createConnectorBindingsElement();
- root.addContent(connectorsElement);
- Element connElement = helper.createConnectorBindingElement(defn, false );
- connectorsElement.addContent(connElement);
-
- getXMLReaderWriter().writeDocument(doc, stream);
-//*** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0009, defn.getName());
- }
-
-
- public void exportConnectorBindings(OutputStream stream, ConnectorBinding[] bindings,
ComponentType[] types, Properties props) throws IOException,
ConfigObjectsNotResolvableException {
- Assertion.isNotNull(bindings);
- Assertion.isNotNull(types);
- Assertion.isNotNull(stream);
-
-
-// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Connector binding
object to export resolved properly.");
-
- XMLHelper helper = getXMLHelper();
-
- Element root = helper.createRootConfigurationDocumentElement();
-
- // create a new Document with a root element
- Document doc = new Document(root);
-
- root = XMLHelperUtil.addHeaderElement(root, props);
- // add the header element
-// root.addContent(helper.createHeaderElement(createHeaderProperties(props)));
-
- exportConnectorBindings(bindings, types, root);
-
- getXMLReaderWriter().writeDocument(doc, stream);
-
- }
-
-
-// public ComponentType importConnector(InputStream stream, ConfigurationObjectEditor
editor, String newName)throws IOException, InvalidConfigurationElementException {
-// // no special implementation changes needed to import Connectors
-// return importComponentType(stream, editor, newName);
-// }
-
-
- /**
- * Add connector bindings and component types (connector types) under
- * a common root element.
- * @param bindings
- * @param types
- * @param helper
- * @param root
- * @since 4.2
- */
- public void exportConnectorBindings(ConnectorBinding[] bindings,
- ComponentType[] types,
- Element root) {
- XMLHelper helper = getXMLHelper();
- int s = bindings.length;
- List ts = new ArrayList(s);
-
- Element componentTypesElement = helper.createComponentTypesElement();
- root.addContent(componentTypesElement);
-
-
- Element connectorsElement = helper.createConnectorBindingsElement();
- root.addContent(connectorsElement);
-
- if (bindings == null || bindings.length == 0) {
- return;
- }
-
- int tsize = types.length;
- Map typeMap = new HashMap(tsize);
-
- for (int i = 0; i<tsize; i++) {
- ComponentType type = types[i];
- if (type != null) {
- typeMap.put(type.getID(), type);
- }
- }
-
-
-
- for (int i = 0; i<s; i++) {
-
- ConnectorBinding cb = bindings[i];
- if (cb == null) {
- continue;
- }
- ComponentType type = (ComponentType) typeMap.get(cb.getComponentTypeID());
-
- // here we ensure that this is a Connector and that the given component
- // type resolves to the given ServiceComponentDefn.
-// try {
-// resolveConnector(type, cb);
-// } catch(ConfigObjectsNotResolvableException conr) {
-//
-// conr.printStackTrace(System.out);
-//
-// System.out.print(conr.getMessage());
-// continue;
-// }
-
- if (type != null && !ts.contains(type.getFullName())) {
-
componentTypesElement.addContent(helper.createComponentTypeElement(type));
- ts.add(type.getFullName());
- }
-
- Element connElement = helper.createConnectorBindingElement(cb, false );
- connectorsElement.addContent(connElement);
-
- }
- }
-
- public ConnectorBinding importConnectorBinding(InputStream stream,
ConfigurationObjectEditor editor, String newName)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
- Assertion.isNotNull(stream);
- Assertion.isNotNull(editor);
-
-//*** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Importing a
ConnectorBinding object.");
-
- Document doc = null;
-
- try {
- doc = getXMLReaderWriter().readDocument(stream);
- } catch(JDOMException e) {
- throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0010));
- }
-
- Element root = doc.getRootElement();
-
-
- ConnectorBinding binding = createConnectorBinding(Configuration.NEXT_STARTUP_ID,
root, editor, newName, false) ;
-
- if (binding == null) {
- throw new ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0011,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0011));
- }
-
-//*** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0010, binding.getName());
-
-
- return binding;
-
-}
-
- public Collection importConnectorBindings(Element root, ConfigurationObjectEditor
editor, boolean importExistingBinding)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
- Assertion.isNotNull(root);
- Assertion.isNotNull(editor);
-
-//*** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Importing 1 or
more ConnectorBinding objects.");
-
-
- Collection connectorBindings =
createConnectorBindings(Configuration.NEXT_STARTUP_ID, root, editor,
importExistingBinding) ;
-
-//*** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0011);
-
- return connectorBindings;
- }
-
-
-
- public Collection importConnectorBindings(InputStream stream,
ConfigurationObjectEditor editor, boolean importExistingBinding)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
- Assertion.isNotNull(stream);
- Assertion.isNotNull(editor);
-
-//*** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Importing 1 or
more ConnectorBinding objects.");
-
- Document doc = null;
-
- try {
- doc = getXMLReaderWriter().readDocument(stream);
- } catch(JDOMException e) {
- throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0010));
-
- }
-
- Element root = doc.getRootElement();
-
- return importConnectorBindings(root, editor, importExistingBinding);
- }
-
- public Object[] importConnectorBindingAndType(InputStream stream,
ConfigurationObjectEditor editor, String[] newName)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
-
- Assertion.isNotNull(stream);
- Assertion.isNotNull(editor);
-
-//*** LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Importing a
Connector Binding object and Connector Type.");
-
- Document doc = null;
-
- try {
- doc = getXMLReaderWriter().readDocument(stream);
- } catch(JDOMException e) {
- throw new
IOException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0012));
- }
-
- String typeName = null;
- String bindingName = null;
- if (newName != null) {
- typeName = newName[ConfigurationImportExportUtility.COMPONENT_TYPE_INDEX];
- bindingName = newName[ConfigurationImportExportUtility.SERVICE_COMPONENT_DEFN_INDEX];
- }
- Element root = doc.getRootElement();
-
- ComponentType type = createComponentType(root, editor, typeName);
-
- if (type == null) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0013,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0013));
- }
-
-
- ConnectorBinding binding = createConnectorBinding(Configuration.NEXT_STARTUP_ID,
root, editor, bindingName, false) ;
-
-
- if (binding == null) {
- throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0014,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0014));
- }
-
- // here we ensure that this is a Connector and that the given component
- // type resolves to the given ServiceComponentDefn.
- resolveConnector(type, binding);
-
- Object[] object = {type, binding
- };
-
-//*** I18nLogManager.logInfo(LogCommonConstants.CTX_CONFIG,
LogMessageKeys.CONFIG_MSG_0012, new Object[] {type.getName(), binding.getName()});
-
- return object;
-
- }
-
-
- /**
- * This method is used specifically to resolve Connector Binding
- * ServiceComponentDefns to their respective Connector ComponentTypes.
- */
- private void resolveConnector(ComponentType type, ComponentDefn defn) throws
ConfigObjectsNotResolvableException {
-
- // check to be sure that the passed in ComponentType is the correct one for
- // this ServiceComponentDefn.
- if (type == null) {
- String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0015,
new Object[] {defn.getID(), defn.getComponentTypeID()} );
-
- System.err.print(msg);
-
- throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0015, msg);
-
- } else if (!(defn.getComponentTypeID().equals(type.getID()))) {
- String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0015,
new Object[] {defn.getID(), type.getID()} );
-
- System.err.print(msg);
-
- throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0015, msg);
- }
- // the super and parent ComponentTypeID's of all Connectors are
- // always the same as defined by the static finals in the config objects.
-// if
(!(type.getParentComponentTypeID().getName().equals(ProductType.CONNECTOR_PRODUCT_TYPE_NAME)))
{
-// throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0016,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0016,
type.getParentComponentTypeID().getName()));
-// }
-
- if (!type.isOfTypeConnector()) {
- throw new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0017,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0017,
type.getSuperComponentTypeID().getName()));
- }
- }
-
- /**
- * <p>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. </p>
- *
- * <p>Any number of actual Configuration object instances may be passed in
- * in the Collection.</p>
- *
- * @param collection the collection of configuration objects to be resolved
- * @throws ConfigObjectsNotResolvableException if the collection of objects
- * passed in are not self containing.
- */
- public void resolveConfigurationObjects(Collection collection) throws
ConfigObjectsNotResolvableException{
-
- List[] lists = segregateConfigurationObjects(collection);
-
- resolveConfigurationObjects(lists);
- }
-
-
-
- protected void resolveConfigurationObjects(List[] lists) throws
ConfigObjectsNotResolvableException{
-
- List configurations = lists[CONFIGURATIONS_INDEX];
-// List productTypes = lists[PRODUCT_TYPES_INDEX];
-
- List hosts = lists[HOSTS_INDEX];
- List deployedComponents = lists[DEPLOYED_COMPONENTS_INDEX];
- List serviceComponentDefns = lists[SERVICE_COMPONENT_DEFNS_INDEX];
- List vmComponentDefns = lists[VM_COMPONENT_DEFNS_INDEX];
- List componentTypes = lists[COMPONENT_TYPES_INDEX];
- // List productServiceConfigs = lists[PRODUCT_SERVICE_CONFIGS_INDEX];
-
- List connectionPools = lists[CONNECTION_POOL_CONFIGS_INDEX];
-
- List resources = lists[RESOURCES_INDEX];
-
- List connectorBindings = lists[CONNECTORS_INDEX];
-
- List configurationIDs = lists[CONFIGURATION_IDS_INDEX];
- // List productTypeIDs = lists[PRODUCT_TYPE_IDS_INDEX];
- List hostIDs = lists[HOST_IDS_INDEX];
- List serviceComponentDefnIDs = lists[SERVICE_COMPONENT_DEFN_IDS_INDEX];
- List vmComponentDefnIDs = lists[VM_COMPONENT_DEFN_IDS_INDEX];
- List componentTypeIDs = lists[COMPONENT_TYPE_IDS_INDEX];
- // List productServiceConfigIDs = lists[PRODUCT_SERVICE_CONFIG_IDS_INDEX];
-
- List connectorBindingsIDs = lists[CONNECTORS_IDS_INDEX];
-
-
- // we do this because a DeployedComponent can have a null ServiceComponentDefnID
- // and a null ProductServiceComponentID and still be viable. This will
- // allow the contains methods called on these Lists later in this method
- // to return true if the ID is null instead of throwing a bogus exception
- serviceComponentDefnIDs.add(null);
- connectorBindingsIDs.add(null);
- // productServiceConfigIDs.add(null);
- // productTypeIDs.add(null);
- componentTypeIDs.add(null);
-
- // now we must iterate through each object type, pull out any references
- // to other configuration objects and ensure that those objects were
- // in the collection of objects passed into the method.
- Iterator iterator = deployedComponents.iterator();
- while (iterator.hasNext()) {
- DeployedComponent deployedComponent = (DeployedComponent) iterator.next();
- if(!vmComponentDefnIDs.contains(deployedComponent.getVMComponentDefnID())){
-// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "The
VMComponentDefnID " + deployedComponent.getVMComponentDefnID() + " was not found
in the list of VMCompoentDefnIDs: " + vmComponentDefnIDs);
-
- throwObjectsNotResolvable(deployedComponent,
deployedComponent.getVMComponentDefnID(), "vm component"); //$NON-NLS-1$
- }
-
- if
(!serviceComponentDefnIDs.contains(deployedComponent.getServiceComponentDefnID())
&&
-
!connectorBindingsIDs.contains(deployedComponent.getServiceComponentDefnID()) ) {
-
- throwObjectsNotResolvable(deployedComponent,
deployedComponent.getServiceComponentDefnID(), "service component");
//$NON-NLS-1$
- }
-
- if (!hostIDs.contains(deployedComponent.getHostID())) {
- throwObjectsNotResolvable(deployedComponent,
deployedComponent.getHostID(), "host"); //$NON-NLS-1$
- }
-
-// if
(!productServiceConfigIDs.contains(deployedComponent.getProductServiceConfigID())) {
-// throwObjectsNotResolvable(deployedComponent,
deployedComponent.getProductServiceConfigID(), "psc"); //$NON-NLS-1$
-// }
-
- checkComponentTypeID(deployedComponent, componentTypeIDs);
- }
-
- iterator = resources.iterator();
- while (iterator.hasNext()) {
- SharedResource defn = (SharedResource)iterator.next();
- checkComponentTypeID(defn, componentTypeIDs);
- }
-
-
- iterator = connectionPools.iterator();
- while (iterator.hasNext()) {
- ResourceDescriptor defn = (ResourceDescriptor)iterator.next();
- checkComponentTypeID(defn, componentTypeIDs);
- checkConfigurationID(defn, configurationIDs);
- }
-
- iterator = connectorBindings.iterator();
- while (iterator.hasNext()) {
- ConnectorBinding defn = (ConnectorBinding)iterator.next();
- checkComponentTypeID(defn, componentTypeIDs);
- }
-
-
-
- iterator = serviceComponentDefns.iterator();
- while (iterator.hasNext()) {
- ServiceComponentDefn defn = (ServiceComponentDefn)iterator.next();
- checkComponentTypeID(defn, componentTypeIDs);
- checkConfigurationID(defn, configurationIDs);
- }
-
- iterator = vmComponentDefns.iterator();
- while (iterator.hasNext()) {
- VMComponentDefn defn = (VMComponentDefn)iterator.next();
- checkComponentTypeID(defn, componentTypeIDs);
- checkConfigurationID(defn, configurationIDs);
-
-
- }
-
-
-// iterator = productServiceConfigs.iterator();
-// while (iterator.hasNext()) {
-// ProductServiceConfig config = (ProductServiceConfig)iterator.next();
-//
-// // psc's component types are based on products, not actual component
types
-//// checkPSCProductTypeID(config);
-//
-//// checkComponentTypeID(config, componentTypeIDs, productTypeIDs);
-// checkConfigurationID(config, configurationIDs);
-// Iterator iter = config.getServiceComponentDefnIDs().iterator();
-// while (iter.hasNext()) {
-// Object obj = iter.next();
-// // ComponentDefnID id = (ComponentDefnID) obj;
-//// System.out.println("PSC ID: " + id.getFullName() + " class
" + id.getClass().getName());
-//
-// if (serviceComponentDefnIDs.contains(obj) ||
-// connectorBindingsIDs.contains(obj) ) {
-// } else {
-// throwObjectsNotResolvable(obj, config, "service
component"); //$NON-NLS-1$
-// }
-// }
-// }
-//
-// iterator = componentTypes.iterator();
-// while (iterator.hasNext()) {
-// ComponentType type = (ComponentType)iterator.next();
-// // checkForComponentTypeID(type.getSuperComponentTypeID(),
componentTypeIDs);
-// // checkForProductTypeID(type, type.getParentComponentTypeID(),
productTypeIDs, componentTypeIDs);
-// }
-
-// iterator = productTypes.iterator();
-// while (iterator.hasNext()) {
-// ProductType type = (ProductType)iterator.next();
-//
-// checkForComponentTypeID(type.getSuperComponentTypeID(), componentTypeIDs,
productTypeIDs);
-// checkForComponentTypeID(type.getParentComponentTypeID(), componentTypeIDs,
productTypeIDs);
-// Iterator iter = type.getComponentTypeIDs().iterator();
-// while (iter.hasNext()) {
-// ComponentTypeID id = (ComponentTypeID)iter.next();
-// checkForComponentTypeID(id, componentTypeIDs, productTypeIDs);
-// }
-// }
-
- iterator = configurations.iterator();
- while (iterator.hasNext()) {
- Configuration config = (Configuration)iterator.next();
- checkComponentTypeID(config, componentTypeIDs);
- }
-
- iterator = hosts.iterator();
- while (iterator.hasNext()) {
- Host host = (Host)iterator.next();
- checkComponentTypeID(host, componentTypeIDs);
- }
-
-//*** LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "Configuration
objects resolved properly.");
-
- }
-
- private void throwObjectsNotResolvable(Object referencingObject, Object
referencedObject, String type) throws ConfigObjectsNotResolvableException{
-
- String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0018, new
Object[]
- {referencingObject, type, referencedObject} );
- ConfigObjectsNotResolvableException e = new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0018, msg,
referencingObject);
-
- throw e;
- }
-
- private void throwObjectsNotResolvable(Object referencingObject, String type) throws
ConfigObjectsNotResolvableException{
- String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0019, new
Object[]
- {referencingObject, type} );
-
-
- ConfigObjectsNotResolvableException e = new
ConfigObjectsNotResolvableException(ErrorMessageKeys.CONFIG_ERR_0019, msg,
referencingObject);
-
- throw e;
- }
-
-
-// private void throwConfigObjectsNotResolvableExceptionx(Object referencingObject,
Object referencedObject) throws ConfigObjectsNotResolvableException{
-// String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0020, new
Object[]
-// {referencingObject, referencedObject} );
-//
-//
-// ConfigObjectsNotResolvableException e = new
ConfigObjectsNotResolvableException(msg);
-//
-// throw e;
-// }
-
-// private void checkComponentTypeID(ComponentObject object, List componentTypeIDs)
throws ConfigObjectsNotResolvableException{
-// if (!(componentTypeIDs.contains(object.getComponentTypeID()))) {
-// // ||productTypeIDs.contains(object.getComponentTypeID()))) {
-// // LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "The
ComponentTypeID: " + object.getComponentTypeID() + " was not found in the list
of ComponentTypeIDs: " + componentTypeIDs + " or the list of Product TypeIDs:
" + productTypeIDs);
-// throwObjectsNotResolvable(object, object.getComponentTypeID(), "component
type"); //$NON-NLS-1$
-//// throwConfigObjectsNotResolvableException(object,
object.getComponentTypeID());
-// }
-// }
-
- private void checkConfigurationID(ComponentDefn defn, List configurationIDs) throws
ConfigObjectsNotResolvableException {
- if (!configurationIDs.contains(defn.getConfigurationID())) {
- throwObjectsNotResolvable(defn, defn.getConfigurationID(), "configuration
object"); //$NON-NLS-1$
-
-// throwConfigObjectsNotResolvableException(defn, defn.getConfigurationID());
- }
- }
-
- /**
- * Used when product types ids are not part of validation - i.e.,
ResourceDescriptors
- */
- private void checkComponentTypeID(ComponentObject object, List componentTypeIDs)
throws ConfigObjectsNotResolvableException{
- if (!(componentTypeIDs.contains(object.getComponentTypeID()) )) {
- //*** LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "The
ComponentTypeID: " + object.getComponentTypeID() + " was not found in the list
of ComponentTypeIDs: " + componentTypeIDs );
- throwObjectsNotResolvable(object, object.getComponentTypeID(), "component
type"); //$NON-NLS-1$
-
-// throwConfigObjectsNotResolvableException(object,
object.getComponentTypeID());
- }
- }
-
- /**
- * used to validate PSC's
- * @param object
- * @param productTypeIDs
- * @throws ConfigObjectsNotResolvableException
- * @since 4.2
- */
-// private void checkPSCProductTypeID(ProductServiceConfig object, List
productTypeIDs) throws ConfigObjectsNotResolvableException{
-// if (!(productTypeIDs.contains(object.getComponentTypeID()))) {
-// // LogManager.logTrace(LogCommonConstants.CTX_CONFIG, "The
ComponentTypeID: " + object.getComponentTypeID() + " was not found in the list
of ComponentTypeIDs: " + componentTypeIDs + " or the list of Product TypeIDs:
" + productTypeIDs);
-// throwObjectsNotResolvable(object, object.getComponentTypeID(), "component
type"); //$NON-NLS-1$
-//// throwConfigObjectsNotResolvableException(object,
object.getComponentTypeID());
-// }
-// }
-
-
- private void checkForComponentTypeID(ComponentTypeID id, List componentTypeIDs)
throws ConfigObjectsNotResolvableException{
-
- if (id!=null) {
- if (!(componentTypeIDs.contains(id))) {
- throwObjectsNotResolvable(id, "component"); //$NON-NLS-1$
-
-// throwConfigObjectsNotResolvableException(id, id);
- }
-
- }
-
- }
-
- private void checkForProductTypeID(ComponentType type, ComponentTypeID parentid, List
productTypeIDs, List componentTypeIDs) throws ConfigObjectsNotResolvableException{
-
- if (parentid!=null) {
- if (type.isOfTypeConnector()) {
- // if connector, must have a valid product type parent
- if (!(productTypeIDs.contains(parentid) )) {
- throwObjectsNotResolvable(parentid, "product type");
//$NON-NLS-1$
-
- // throwConfigObjectsNotResolvableException(id, id);
- }
- }
- }
-
- }
-
- protected List[] segregateConfigurationObjects(Collection collection) {
-
-
- List[] lists = new ArrayList[NUMBER_OF_LISTS];
-
- Assertion.isNotNull(collection);
- ArrayList componentTypes = new ArrayList();
- ArrayList hosts = new ArrayList();
- ArrayList deployedComponents = new ArrayList();
- ArrayList serviceComponentDefns = new ArrayList();
- ArrayList vmComponentDefns = new ArrayList();
- // ArrayList productServiceConfigs = new ArrayList();
- ArrayList configurations = new ArrayList();
-// ArrayList productTypes = new ArrayList();
- ArrayList connPools = new ArrayList();
- ArrayList resources = new ArrayList();
- ArrayList bindings = new ArrayList();
-
-
- ArrayList componentTypeIDs = new ArrayList();
- ArrayList hostIDs = new ArrayList();
- ArrayList deployedComponentIDs = new ArrayList();
- ArrayList serviceComponentDefnIDs = new ArrayList();
- ArrayList vmComponentDefnIDs = new ArrayList();
- // ArrayList productServiceConfigIDs = new ArrayList();
- ArrayList configurationIDs = new ArrayList();
- // ArrayList productTypeIDs = new ArrayList();
-
- ArrayList bindingIDs = new ArrayList();
-
-
- // here we segregate the configuration objects by type so that we can
- // determine what references they may have to other configuration objects
- // we also set up lists of ID's as a convenience so that we can use
- // contains() to check to see if an id is resolvable within the collection
- Iterator iterator = collection.iterator();
- while (iterator.hasNext()) {
- Object obj = iterator.next();
-
- // product types need to go before component type
-
- if (obj instanceof ComponentType) {
-
- componentTypes.add(obj);
- componentTypeIDs.add(((BaseObject)obj).getID());
- }else if(obj instanceof ComponentObject) {
- if (obj instanceof Host) {
- hosts.add(obj);
- hostIDs.add(((BaseObject)obj).getID());
- }else if(obj instanceof DeployedComponent) {
- deployedComponents.add(obj);
- deployedComponentIDs.add(((BaseObject)obj).getID());
- }else if(obj instanceof Configuration) {
- configurations.add(obj);
- configurationIDs.add(((BaseObject)obj).getID());
-
- }else if(obj instanceof SharedResource) {
- resources.add(obj);
- }else if(obj instanceof ConnectorBinding) {
- bindings.add(obj);
- bindingIDs.add(((BaseObject)obj).getID());
-
- }else if(obj instanceof ComponentDefn) {
-// if (obj instanceof ProductServiceConfig) {
-// productServiceConfigs.add(obj);
-// productServiceConfigIDs.add(((BaseObject)obj).getID());
-// }else
- if(obj instanceof ServiceComponentDefn) {
- serviceComponentDefns.add(obj);
- serviceComponentDefnIDs.add(((BaseObject)obj).getID());
- }else if(obj instanceof VMComponentDefn) {
- vmComponentDefns.add(obj);
- vmComponentDefnIDs.add(((BaseObject)obj).getID());
- }else if(obj instanceof ResourceDescriptor) {
- connPools.add(obj);
-// connPoolIDs.add(((BaseObject)obj).getID());
-
- } else {
-// ComponentDefn cd = (ComponentDefn) obj;
-//*** LogManager.logDetail(LogCommonConstants.CTX_CONFIG,
"The ComponentDefn: " + cd.getFullName() + " could not be categorized as a
Standard Configuration Object and will be ignored. Its class type is: " +
cd.getClass());
- }
- }
- }
- }
-
-
- lists[CONFIGURATIONS_INDEX] = configurations;
-// lists[PRODUCT_TYPES_INDEX] = productTypes;
- lists[HOSTS_INDEX] = hosts;
- lists[DEPLOYED_COMPONENTS_INDEX] = deployedComponents;
- lists[SERVICE_COMPONENT_DEFNS_INDEX] = serviceComponentDefns;
- lists[VM_COMPONENT_DEFNS_INDEX] = vmComponentDefns;
- lists[COMPONENT_TYPES_INDEX] = componentTypes;
-// lists[PRODUCT_SERVICE_CONFIGS_INDEX] = productServiceConfigs;
-
- lists[CONFIGURATION_IDS_INDEX] = configurationIDs;
-// lists[PRODUCT_TYPE_IDS_INDEX] = productTypeIDs;
- lists[HOST_IDS_INDEX] = hostIDs;
- lists[DEPLOYED_COMPONENT_IDS_INDEX] = deployedComponentIDs;
- lists[SERVICE_COMPONENT_DEFN_IDS_INDEX] = serviceComponentDefnIDs;
- lists[VM_COMPONENT_DEFN_IDS_INDEX] = vmComponentDefnIDs;
- lists[COMPONENT_TYPE_IDS_INDEX] = componentTypeIDs;
-// lists[PRODUCT_SERVICE_CONFIG_IDS_INDEX] = productServiceConfigIDs;
-
- lists[CONNECTION_POOL_CONFIGS_INDEX] = connPools;
-
- lists[RESOURCES_INDEX] = resources;
- lists[CONNECTORS_INDEX] = bindings;
- lists[CONNECTORS_IDS_INDEX] = bindingIDs;
-
-
- return lists;
- }
-
- protected XMLReaderWriter getXMLReaderWriter() {
- if (readerWriter == null) {
- readerWriter = new XMLReaderWriterImpl();
- }
- return readerWriter;
- }
-
- protected abstract XMLHelper getXMLHelper();
-
-}
Copied:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java
(from rev 747,
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_ElementNames.java)
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java
(rev 0)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -0,0 +1,894 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.config.xml;
+
+import com.metamatrix.common.config.util.ConfigurationPropertyNames;
+
+/**
+* This class structure mimics the structure of a Configuration XML
+* document and defines all of the element and attribute names for that
+* document type.
+*/
+public interface XMLConfig_ElementNames {
+
+ /**
+ * This is used as the delimiter of all XML element names.
+ */
+ public static final String DELIMITER = "."; //$NON-NLS-1$
+
+ /**
+ * This should be the root Element name for all Configuration XML Documents.
+ */
+ public static final String ELEMENT = "ConfigurationDocument";
//$NON-NLS-1$
+
+
+
+ /**
+ * This is the class that represents the Configuration Element which contains
+ * all of the XML elements that represent a Configuration object.
+ */
+ public static class Configuration {
+ /**
+ * This is the name of the Configurations Element.
+ */
+ public static final String ELEMENT = "Configuration";
//$NON-NLS-1$
+ public static class Attributes extends ComponentObject.Attributes{
+ }
+
+
+
+
+ /**
+ * This is the class that represents the Host Element which contains
+ * all of the XML elements that represent a Host object.
+ */
+ public static class Host {
+
+ /**
+ * This is the name of the Host Element.
+ */
+ public static final String ELEMENT = "Host"; //$NON-NLS-1$
+ public static class Attributes extends ComponentObject.Attributes{
+
+
+ }
+
+
+ /**
+ * This is the class that represents the ComponentDefnID Element which
contains
+ * all of the XML elements that represent a ComponentDefnID object.
+ */
+// public static final class ComponentDefnID{
+//
+// /**
+// * This is the name of the ComponentDefnID Element.
+// */
+// public static final String ELEMENT = "ComponentDefnID";
//$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
+
+ /**
+ * This is the class that represents the DeployedComponentID Element which
contains
+ * all of the XML elements that represent a DeployedComponentID object.
+ */
+// public static final class DeployedComponentID{
+//
+// /**
+// * This is the name of the DeployedComponentID Element.
+// */
+// public static final String ELEMENT = "DeployedComponentID";
//$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
+
+ /**
+ * This is the class that represents the ProductServiceConfigID Element which
contains
+ * all of the XML elements that represent a ProductServiceConfigID object.
+ */
+// public static final class ProductServiceConfigID{
+//
+// /**
+// * This is the name of the ProductServiceConfigID Element.
+// */
+// public static final String ELEMENT =
"ProductServiceConfigID"; //$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
+
+ /**
+ * This is the class that represents the VMComponentDefnID Element which
contains
+ * all of the XML elements that represent a VMComponentDefnID object.
+ */
+// public static final class VMComponentDefnID{
+//
+// /**
+// * This is the name of the VMComponentDefnID Element.
+// */
+// public static final String ELEMENT = "VMComponentDefnID";
//$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
+
+ /**
+ * This is the class that represents the VMComponentDefnID Element which
contains
+ * all of the XML elements that represent a VMComponentDefnID object.
+ */
+// public static final class ServiceComponentDefnID{
+//
+// /**
+// * This is the name of the ServiceComponentDefnID Element.
+// */
+// public static final String ELEMENT =
"ServiceComponentDefnID"; //$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
+
+
+
+ }
+
+ /**
+ * This is the class that represents the ProductServiceConfigs Element which
contains
+ * all of the XML elements that represent a ProductServiceConfigs object.
+ */
+ public static class AuthenticationProviders {
+
+ /**
+ * This is the name of the ProductServiceConfigs Element.
+ */
+ public static final String ELEMENT = "AuthenticationProviders";
//$NON-NLS-1$
+
+ /**
+ * This is the class that represents the ProductServiceConfig Element which
contains
+ * all of the XML elements that represent a ProductServiceConfig object.
+ */
+ public static class Provider {
+
+ /**
+ * This is the name of the ProductServiceConfig Element.
+ */
+ public static final String ELEMENT = "Provider"; //$NON-NLS-1$
+
+ public static class Attributes extends ComponentObject.Attributes{
+
+ }
+
+ }
+ }
+
+
+ /**
+ * This is the class that represents the Resources Element which contains
+ * all of the XML elements that represent a Resource object.
+ */
+ public static class Resources {
+
+ /**
+ * This is the name of the Hosts Element.
+ */
+ public static final String ELEMENT = "SharedResources"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the Resource Element which contains
+ * all of the XML elements that represent a Resource object.
+ */
+ public static class Resource {
+
+ /**
+ * This is the name of the Resource Element.
+ */
+ public static final String ELEMENT = "Resource"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ComponentObject.Attributes{
+ }
+
+
+ }
+ }
+
+ /**
+ * This is the class that represents the ServiceComponentDefns Element which contains
+ * all of the XML elements that represent a ServiceComponentDefns object.
+ */
+ public static class ConnectorComponents {
+
+ /**
+ * This is the name of the ServiceComponentDefns Element.
+ */
+ public static final String ELEMENT = "ConnectorBindings";
//$NON-NLS-1$
+
+ /**
+ * This is the class that represents the ConnectorBinding Element which contains
+ * all of the XML elements that represent a ConnectorBinding object.
+ */
+ public static class ConnectorComponent {
+
+ /**
+ * This is the name of the ConnectorBinding Element.
+ */
+ public static final String ELEMENT = "Connector"; //$NON-NLS-1$
+
+ public static class Attributes extends ComponentObject.Attributes{
+ public static final String ROUTING_UUID = "routingUUID";
//$NON-NLS-1$
+ }
+ }
+ }
+
+
+
+ /**
+ * This is the class that represents the ServiceComponentDefns Element which
contains
+ * all of the XML elements that represent a ServiceComponentDefns object.
+ */
+ public static class Services {
+
+ /**
+ * This is the name of the ServiceComponentDefns Element.
+ */
+ public static final String ELEMENT = "Services"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the ServiceComponentDefn Element which
contains
+ * all of the XML elements that represent a ServiceComponentDefn object.
+ */
+ public static class Service {
+
+ /**
+ * This is the name of the ServiceComponentDefn Element.
+ */
+ public static final String ELEMENT = "Service"; //$NON-NLS-1$
+
+ public static class Attributes extends ComponentObject.Attributes{
+ public static final String QUEUED_SERVICE = "QueuedService";
//$NON-NLS-1$
+ public static final String ROUTING_UUID = "routingUUID";
//$NON-NLS-1$
+ }
+ }
+ }
+
+
+
+ /**
+ * This is the class that represents the ConfigurationInfo Element which contains
+ * all of the XML elements that represent a ConfigurationInfo object.
+ */
+ public static class ConfigurationInfo {
+
+ /**
+ * This is the name of the ServiceComponentDefnID Element.
+ */
+ public static final String ELEMENT = "ConfigurationInfo"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String LAST_CHANGED_DATE = "LastChangedDate";
//$NON-NLS-1$
+ public static final String CREATION_DATE = "CreationDate";
//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This is the class that represents the LogConfiguration Element which contains
+ * all of the XML elements that represent a LogConfiguration object.
+ */
+ public static class LogConfiguration {
+
+ /**
+ * This is the name of the LogConfiguration Element.
+ */
+ public static final String ELEMENT = "LogConfiguration"; //$NON-NLS-1$
+
+ }
+
+ /**
+ * This is the class that represents the VMComponentDefns Element which contains
+ * all of the XML elements that represent a VMComponentDefns object.
+ */
+ public static class VMComponentDefns {
+
+ /**
+ * This is the name of the VMComponentDefns Element.
+ */
+ public static final String ELEMENT = Configuration.ELEMENT + DELIMITER
+"VMComponentDefns"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the VMComponentDefn Element which contains
+ * all of the XML elements that represent a VMComponentDefn object.
+ */
+ public static class VMComponentDefn {
+
+ /**
+ * This is the name of the VMComponentDefn Element.
+ */
+ public static final String ELEMENT = "VMComponentDefn"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ComponentObject.Attributes{
+ }
+ }
+ }
+
+ /**
+ * This is the class that represents the ProductServiceConfigID Element which
contains
+ * all of the XML elements that represent a ProductServiceConfigID object.
+ */
+ // public static final class ProductServiceConfigID{
+ //
+ // /**
+ // * This is the name of the ProductServiceConfigID Element.
+ // */
+ // public static final String ELEMENT =
"ProductServiceConfigID"; //$NON-NLS-1$
+ //
+ // /**
+ // * This class defines the Attributes of the Element class that
+ // * contains it. Note that this class just inherits its attributes
+ // * from its configuration object superclass.
+ // */
+ // public static class Attributes extends ID.Attributes {
+ // }
+ // }
+
+ /**
+ * This is the class that represents the VMComponentDefnID Element which
contains
+ * all of the XML elements that represent a VMComponentDefnID object.
+ */
+ public static final class VMComponentDefnID{
+
+ /**
+ * This is the name of the VMComponentDefnID Element.
+ */
+ public static final String ELEMENT = "VMComponentDefnID";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+ }
+
+ /**
+ * This is the class that represents the VMComponentDefnID Element which contains
+ * all of the XML elements that represent a VMComponentDefnID object.
+ */
+// public static final class ServiceComponentDefnID{
+//
+// /**
+// * This is the name of the ServiceComponentDefnID Element.
+// */
+// public static final String ELEMENT = "ServiceComponentDefnID";
//$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
+
+ /**
+ * This is the class that represents the DeployedComponents Element which
contains
+ * all of the XML elements that represent a DeployedComponents object.
+ */
+// public static class DeployedComponents {
+//
+// /**
+// * This is the name of the DeployedComponents Element.
+// */
+// public static final String ELEMENT = Configuration.ELEMENT +
DELIMITER + "DeployedComponents"; //$NON-NLS-1$
+//
+// /**
+// * This is the class that represents the DeployedComponent Element
which contains
+// * all of the XML elements that represent a DeployedComponent
object.
+// */
+// public static class DeployedComponent {
+//
+// /**
+// * This is the name of the DeployedComponent Element.
+// */
+// public static final String ELEMENT =
"DeployedComponent"; //$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its
attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends
ComponentObject.Attributes{
+// public static final String HOST_ID = "HostID";
//$NON-NLS-1$
+// // public static final String PRODUCT_SERVICE_CONFIG_ID =
"ProductServiceConfigID"; //$NON-NLS-1$
+// public static final String SERVICE_COMPONENT_DEFN_ID =
"ServiceComponentDefnID"; //$NON-NLS-1$
+// public static final String VM_COMPONENT_DEFN_ID =
"VMComponentDefnID"; //$NON-NLS-1$
+// }
+// }
+// }
+
+ /**
+ * This is the class that represents the DeployedComponentID Element which contains
+ * all of the XML elements that represent a DeployedComponentID object.
+ */
+// public static final class DeployedComponentID{
+//
+// /**
+// * This is the name of the DeployedComponentID Element.
+// */
+// public static final String ELEMENT = "DeployedComponentID";
//$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
+
+ /**
+ * This is the class that represents the HostID Element which contains
+ * all of the XML elements that represent a HostID object.
+ */
+ public static final class HostID {
+
+ /**
+ * This is the name of the HostID Element.
+ */
+ public static final String ELEMENT = "HostID"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+ }
+
+ public static class DeployedService {
+
+ /**
+ * This is the name of the ServiceComponentDefn Element.
+ */
+ public static final String ELEMENT = "DeployedService";
//$NON-NLS-1$
+
+ public static class Attributes extends ComponentObject.Attributes{
+ public static final String ROUTING_UUID = "routingUUID";
//$NON-NLS-1$
+ }
+
+
+
+ }
+
+ /**
+ * This is the class that represents the VMComponentDefns Element which contains
+ * all of the XML elements that represent a VMComponentDefns object.
+ */
+ public static class Process {
+
+ /**
+ * This is the name of the VMComponentDefns Element.
+ */
+ public static final String ELEMENT = "Process"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ComponentObject.Attributes{
+ }
+
+ }
+
+ /**
+ * This is the class that represents the DeployedComponent Element which
contains
+ * all of the XML elements that represent a DeployedComponent object.
+ */
+ public static class xDeployedComponent {
+
+ /**
+ * This is the name of the DeployedComponent Element.
+ */
+ public static final String ELEMENT = "DeployedService";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ComponentObject.Attributes{
+ public static final String HOST_ID = "HostID";
//$NON-NLS-1$
+ // public static final String PRODUCT_SERVICE_CONFIG_ID =
"ProductServiceConfigID"; //$NON-NLS-1$
+ public static final String SERVICE_COMPONENT_DEFN_ID =
"ServiceComponentDefnID"; //$NON-NLS-1$
+ public static final String VM_COMPONENT_DEFN_ID =
"VMComponentDefnID"; //$NON-NLS-1$
+ }
+ }
+
+
+}
+
+
+
+ /**
+ * This is the class that represents the ComponentTypeID Element which contains
+ * all of the XML elements that represent a ComponentTypeID object.
+ */
+ public static class ComponentTypeID {
+
+ /**
+ * This is the name of the ComponentTypeID Element.
+ */
+ public static final String ELEMENT = "ComponentTypeID"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it. Note that this class just inherits its attributes
+ * from its configuration object superclass.
+ */
+ public static class Attributes extends ID.Attributes {
+ }
+
+ }
+
+
+
+ /**
+ * This is the class that represents the ComponentTypes Element which contains
+ * all of the XML elements that represent a ComponentTypes object.
+ */
+ public static class ComponentTypes {
+
+ /**
+ * This is the name of the ComponentTypes Element.
+ */
+ public static final String ELEMENT = "ComponentTypes"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the ComponentType Element which contains
+ * all of the XML elements that represent a ComponentType object.
+ */
+ public static class ComponentType {
+
+ /**
+ * This is the name of the ComponentType Element.
+ */
+ public static final String ELEMENT = "ComponentType"; //$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ public static final String PARENT_COMPONENT_TYPE =
"ParentComponentType"; //$NON-NLS-1$
+ public static final String SUPER_COMPONENT_TYPE =
"SuperComponentType"; //$NON-NLS-1$
+ public static final String COMPONENT_TYPE_CODE =
"ComponentTypeCode"; //$NON-NLS-1$
+ public static final String DEPLOYABLE = "Deployable";
//$NON-NLS-1$
+ public static final String DEPRECATED = "Deprecated";
//$NON-NLS-1$
+ public static final String MONITORABLE = "Monitorable";
//$NON-NLS-1$
+ public static final String DESCRIPTION = "Description";
//$NON-NLS-1$
+ }
+
+
+ /**
+ * This is the class that represents the ComponentTypeDefn Element which
contains
+ * all of the XML elements that represent a ComponentTypeDefn object.
+ */
+ public static class ComponentTypeDefn {
+
+ /**
+ * This is the name of the ComponentTypeDefn Element.
+ */
+ public static final String ELEMENT = "ComponentTypeDefn";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String DEPRECATED = "Deprecated";
//$NON-NLS-1$
+ }
+
+ /**
+ * This is the class that represents the PropertyDefinition Element which
contains
+ * all of the XML elements that represent a PropertyDefinition object.
+ */
+ public static class PropertyDefinition {
+
+ /**
+ * This is the name of the PropertyDefinition Element.
+ */
+ public static final String ELEMENT = "PropertyDefinition";
//$NON-NLS-1$
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ public static final String DISPLAY_NAME = "DisplayName";
//$NON-NLS-1$
+ public static final String SHORT_DESCRIPTION
="ShortDescription"; //$NON-NLS-1$
+ public static final String DEFAULT_VALUE =
"DefaultValue"; //$NON-NLS-1$
+ public static final String MULTIPLICITY = "Multiplicity";
//$NON-NLS-1$
+ public static final String PROPERTY_TYPE =
"PropertyType"; //$NON-NLS-1$
+ public static final String VALUE_DELIMITER =
"ValueDelimiter"; //$NON-NLS-1$
+ public static final String IS_CONSTRAINED_TO_ALLOWED_VALUES =
"IsConstrainedToAllowedValues"; //$NON-NLS-1$
+ public static final String IS_EXPERT = "IsExpert";
//$NON-NLS-1$
+ public static final String IS_HIDDEN = "IsHidden";
//$NON-NLS-1$
+ public static final String IS_MASKED = "IsMasked";
//$NON-NLS-1$
+ public static final String IS_MODIFIABLE =
"IsModifiable"; //$NON-NLS-1$
+ public static final String IS_PREFERRED = "IsPreferred";
//$NON-NLS-1$
+ public static final String REQUIRES_RESTART =
"RequiresRestart"; //$NON-NLS-1$
+ }
+
+ /**
+ * This is the class that represents the AllowedValue Element which
contains
+ * all of the XML elements that represent a AllowedValue object.
+ */
+ public static class AllowedValue {
+
+ /**
+ * This is the name of the AllowedValue Element.
+ */
+ public static final String ELEMENT = "AllowedValue";
//$NON-NLS-1$
+ }
+
+ }
+
+ }
+ }
+ }
+
+
+
+ /**
+ * This is the class that represents the ComponentObject Element which contains
+ * all of the XML elements that represent a ComponentObject object.
+ */
+ public static class ComponentObject {
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ public static final String COMPONENT_TYPE = "ComponentType";
//$NON-NLS-1$
+ }
+ }
+
+
+
+ /**
+ * This is the class that represents the ChangeHistory Properties Element which
contains
+ * all of the XML elements that represent the change information for the object.
+ */
+ public static class ChangeHistory {
+
+ /**
+ * This is the name of the ChangeHistory Element.
+ */
+ public static final String ELEMENT = "ChangeHistory"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the Property Element which contains
+ * all of the XML elements that represent a Property object.
+ */
+ public static class Property {
+
+ /**
+ * This is the name of the Property Element.
+ */
+ public static final String ELEMENT = "Property"; //$NON-NLS-1$
+
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ }
+
+ public static class NAMES {
+ public static final String LAST_CHANGED_DATE = "LastChangedDate";
//$NON-NLS-1$
+ public static final String LAST_CHANGED_BY = "LastChangedBy";
//$NON-NLS-1$
+ public static final String CREATION_DATE = "CreationDate";
//$NON-NLS-1$
+ public static final String CREATED_BY = "CreatedBy";
//$NON-NLS-1$
+
+ }
+ }
+ }
+
+
+
+ public static class Header {
+
+ /**
+ * This is the name of the Header Element.
+ */
+ public static final String ELEMENT = "Header"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the UserName Element which contains
+ * all of the XML elements that represent a UserName object.
+ */
+ public static class UserCreatedBy {
+
+ /**
+ * This is the name of the UserName Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.USER_CREATED_BY;
+ }
+
+ /**
+ * This is the class that represents the ApplicationCreatedDate Element which
contains
+ * all of the XML elements that represent a ApplicationCreatedDate object.
+ */
+ public static class ApplicationCreatedBy {
+
+ /**
+ * This is the name of the ApplicationCreatedDate Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.APPLICATION_CREATED_BY;
+ }
+
+ /**
+ * This is the class that represents the ApplicationVersionCreatedBy Element which
contains
+ * all of the XML elements that represent a ApplicationVersionCreatedBy object.
+ */
+ public static class ApplicationVersionCreatedBy {
+
+ /**
+ * This is the name of the ApplicationVersionCreatedBy Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY;
+ }
+
+ /**
+ * This is the class that represents the Time Element which contains
+ * all of the XML elements that represent a Time object.
+ */
+ public static class Time {
+
+ /**
+ * This is the name of the Time Element.
+ */
+ public static final String ELEMENT = ConfigurationPropertyNames.TIME;
+ }
+
+ /**
+ * This is the class that represents the DocumentTypeVersion Element which
contains
+ * all of the XML elements that represent a DocumentTypeVersion object.
+ */
+ public static class ConfigurationVersion {
+
+ /**
+ * This is the name of the DocumentTypeVersion Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.CONFIGURATION_VERSION;
+ }
+
+ /**
+ * This is the class that represents the MetaMatrixServerVersion Element which
contains
+ * all of the XML elements that represent a ProductServiceConfigs object.
+ */
+ public static class MetaMatrixSystemVersion {
+
+ /**
+ * This is the name of the MetaMatrixServerVersion Element.
+ */
+ public static final String ELEMENT =
ConfigurationPropertyNames.SYSTEM_VERSION;
+ }
+ }
+
+
+
+ /**
+ * This is the class that represents the Properties Element which contains
+ * all of the XML elements that represent a Properties object.
+ */
+ public static class Properties {
+
+ /**
+ * This is the name of the Properties Element.
+ */
+ public static final String ELEMENT = "Properties"; //$NON-NLS-1$
+
+ /**
+ * This is the class that represents the Property Element which contains
+ * all of the XML elements that represent a Property object.
+ */
+ public static class Property {
+
+ /**
+ * This is the name of the Property Element.
+ */
+ public static final String ELEMENT = "Property"; //$NON-NLS-1$
+
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ }
+
+ }
+ }
+
+
+
+ /**
+ * This is the class that represents the ID Element which contains
+ * all of the XML elements that represent a ID object.
+ */
+ public static class ID {
+ // these are the shared attributes of all ID Elements
+
+ /**
+ * This class defines the Attributes of the Element class that
+ * contains it.
+ */
+ public static class Attributes {
+ public static final String NAME = "Name"; //$NON-NLS-1$
+ }
+ }
+}
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-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfigurationImportExportUtility.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -121,7 +121,7 @@
public void exportConfiguration(OutputStream stream,
Collection configurationObjects, Properties props)
throws IOException, ConfigObjectsNotResolvableException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
util.exportConfiguration(stream, configurationObjects, props);
}
@@ -159,7 +159,7 @@
Properties props) throws IOException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
util.exportComponentType(stream, type, props);
}
@@ -197,7 +197,7 @@
Properties props) throws IOException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
util.exportComponentTypes(stream, types, props);
}
@@ -326,7 +326,7 @@
Element root = doc.getRootElement();
- XMLConfig_42_ImportExportUtility util = new
XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
return util.importConfigurationObjects(root, editor, name);
}
@@ -382,12 +382,12 @@
//vah 7/22/04 the format of the configuration changed
// in version 4.2, any version prior to this will use
// the 3.0 version utility
- XMLConfig_42_ImportExportUtility util = new
XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
return util.importComponentType(root, editor, name);
-// XMLConfig_42_ImportExportUtility util = new
XMLConfig_42_ImportExportUtility();
+// ConfigurationImportExport util = new ConfigurationImportExport();
// return util.importComponentType(stream, editor, name);
}
/**
@@ -442,44 +442,12 @@
ConfigurationObjectEditor editor)
throws IOException, InvalidConfigurationElementException {
-
- boolean is42Compatible = XMLHelperUtil.is42ConfigurationCompatible(root);
+ ConfigurationImportExport util = new ConfigurationImportExport();
+ return util.importComponentTypes(root, editor);
- return importComponentTypes(root, editor, is42Compatible);
-
-
}
-
- /**
- * <p>This method will be used to import 1 or more a ComponentType
Objects.</p>
- * The ComponentTypes element must be a child of the root element passed in.
- *
- * @param editor the ConfigurationObjectEditor to use to create the Configuration
- * objects.
- * @param root Element contains the ComponentTypes to import
- * @param is42Compatible indicates backwards compatible.
- * @return Collection of objects of type <code>ComponentType</code>
- * @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 Collection importComponentTypes(Element root,
- ConfigurationObjectEditor editor, boolean is42Compatible)
- throws IOException, InvalidConfigurationElementException {
-
- //vah 7/22/04 the format of the configuration changed
- // in version 4.2, any version prior to this will use
- // the 3.0 version utility
- XMLConfig_42_ImportExportUtility util = new
XMLConfig_42_ImportExportUtility();
- return util.importComponentTypes(root, editor);
-
-
- }
-
-
+
/**
* <p>This method will be used to import a ServiceComponentDefn Object given a
Directory
* entry instance. If the DirectoryEntry resource does not contain enough
@@ -497,8 +465,8 @@
* each is defined by the following static variables:</p>
*
* <pre>
- * ConfigurationImportExportUtility.COMPONENT_TYPE_INDEX
- * ConfigurationImportExportUtility.SERVICE_COMPONENT_DEFN_INDEX
+ * ConfigurationImportExport.COMPONENT_TYPE_INDEX
+ * ConfigurationImportExport.SERVICE_COMPONENT_DEFN_INDEX
* </pre>
*
* <p>These array indices are also used to override the ComponentType name
@@ -635,7 +603,7 @@
* ComponentType is not the type referenced by the passed in ServiceComponentDefn.
*/
public void exportConnectorBinding(OutputStream stream, ConnectorBinding defn,
ComponentType type, Properties props) throws IOException,
ConfigObjectsNotResolvableException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
util.exportConnectorBinding(stream, defn, type, props);
}
@@ -644,7 +612,7 @@
public void exportConnectorBindings(ConnectorBinding[] bindings,
ComponentType[] types,
Element root) {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
util.exportConnectorBindings(bindings, types, root);
@@ -682,7 +650,7 @@
*/
public void exportConnectorBindings(OutputStream stream, ConnectorBinding[] bindings,
ComponentType[] types, Properties props) throws IOException,
ConfigObjectsNotResolvableException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
util.exportConnectorBindings(stream, bindings, types, props);
}
@@ -696,7 +664,7 @@
// public static ConnectorBinding importConnectorBinding(String fileName,
ConfigurationObjectEditor editor, String newName) throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
// // vah 7/22/04 bindings didnt change when the import/exporter utility was
changed
// // therefore, it doesn't matter which importer is used
-// ConfigurationImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+// ConfigurationImportExport util = new ConfigurationImportExport();
//
// File f = new File(fileName);
//
@@ -720,41 +688,41 @@
// }
public ConnectorBinding importConnectorBinding(InputStream stream,
ConfigurationObjectEditor editor, String newName)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
return util.importConnectorBinding(stream, editor, newName);
}
public Collection importExistingConnectorBindings(Element root,
ConfigurationObjectEditor editor, boolean importExistingBinding)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
return util.importConnectorBindings(root, editor, importExistingBinding);
}
public Collection importConnectorBindings(Element root, ConfigurationObjectEditor
editor)throws IOException, ConfigObjectsNotResolvableException,
InvalidConfigurationElementException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
return util.importConnectorBindings(root, editor, false);
}
public Collection importConnectorBindings(InputStream stream,
ConfigurationObjectEditor editor)throws IOException, ConfigObjectsNotResolvableException,
InvalidConfigurationElementException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
return util.importConnectorBindings(stream, editor, false);
}
public Collection importExistingConnectorBindings(InputStream stream,
ConfigurationObjectEditor editor, boolean useExistingBinding)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
return util.importConnectorBindings(stream, editor, useExistingBinding);
}
public Object[] importConnectorBindingAndType(InputStream stream,
ConfigurationObjectEditor editor, String[] newName)throws IOException,
ConfigObjectsNotResolvableException, InvalidConfigurationElementException {
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
return util.importConnectorBindingAndType(stream, editor, newName);
}
@@ -774,7 +742,7 @@
*/
public void resolveConfigurationObjects(Collection collection) throws
ConfigObjectsNotResolvableException{
- XMLConfig_42_ImportExportUtility util = new XMLConfig_42_ImportExportUtility();
+ ConfigurationImportExport util = new ConfigurationImportExport();
util.resolveConfigurationObjects(collection);
@@ -790,7 +758,7 @@
* extension1.jar
* extension2.jar
*
- * @see
com.metamatrix.common.config.util.ConfigurationImportExportUtility#importConnectorArchive(java.io.InputStream,
com.metamatrix.common.config.api.ConfigurationObjectEditor)
+ * @see
com.metamatrix.common.config.util.ConfigurationImportExport#importConnectorArchive(java.io.InputStream,
com.metamatrix.common.config.api.ConfigurationObjectEditor)
* @since 4.3.2
*/
public ConnectorArchive importConnectorArchive(InputStream stream,
ConfigurationObjectEditor editor)
Deleted:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLElementNames.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLElementNames.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLElementNames.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -1,832 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.xml;
-
-import com.metamatrix.common.config.util.ConfigurationPropertyNames;
-
-/**
-* This class structure mimics the structure of a Configuration XML
-* document and defines all of the element and attribute names for that
-* document type.
-*/
-public interface XMLElementNames {
-
- /**
- * This is used as the delimiter of all XML element names.
- */
- public static final String DELIMITER = "."; //$NON-NLS-1$
-
- /**
- * This should be the root Element name for all Configuration XML Documents.
- */
- public static final String ELEMENT = "ConfigurationDocument";
//$NON-NLS-1$
-
- /**
- * This is the class that represents the Configurations Element which contains
- * all of the XML elements that represent Configuration objects.
- */
- public static class Configurations {
-
- /**
- * This is the name of the Configurations Element.
- */
- public static final String ELEMENT = "Configurations"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the Configuration Element which contains
- * all of the XML elements that represent a Configuration object.
- */
- public static class Configuration {
-
- /**
- * This is the name of the Configurations Element.
- */
- public static final String ELEMENT = "Configuration";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- }
-
- /**
- * This is the class that represents the ProductServiceConfigs Element which
contains
- * all of the XML elements that represent a ProductServiceConfigs object.
- */
- public static class ResourcePools {
-
- /**
- * This is the name of the ProductServiceConfigs Element.
- */
- public static final String ELEMENT = Configuration.ELEMENT + DELIMITER +
"ResourcePools"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the ProductServiceConfig Element
which contains
- * all of the XML elements that represent a ProductServiceConfig object.
- */
- public static class ResourcePool {
-
- /**
- * This is the name of the ProductServiceConfig Element.
- */
- public static final String ELEMENT = "ResourcePool";
//$NON-NLS-1$
-
- public static class Attributes extends ComponentObject.Attributes{
-
- }
-
- }
- }
-
-
- /**
- * This is the class that represents the ProductServiceConfigs Element which
contains
- * all of the XML elements that represent a ProductServiceConfigs object.
- */
-// public static class ProductServiceConfigs {
-//
-// /**
-// * This is the name of the ProductServiceConfigs Element.
-// */
-// public static final String ELEMENT = Configuration.ELEMENT + DELIMITER
+ "ProductServiceConfigs"; //$NON-NLS-1$
-//
-// /**
-// * This is the class that represents the ProductServiceConfig Element
which contains
-// * all of the XML elements that represent a ProductServiceConfig
object.
-// */
-// public static class ProductServiceConfig {
-//
-// /**
-// * This is the name of the ProductServiceConfig Element.
-// */
-// public static final String ELEMENT =
"ProductServiceConfig"; //$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ComponentObject.Attributes{
-// public static final String IS_ENABLED = "IsEnabled";
//$NON-NLS-1$
-//
-// }
-// }
-// }
-
- /**
- * This is the class that represents the ServiceComponentDefns Element which
contains
- * all of the XML elements that represent a ServiceComponentDefns object.
- */
- public static class ServiceComponentDefns {
-
- /**
- * This is the name of the ServiceComponentDefns Element.
- */
- public static final String ELEMENT = Configuration.ELEMENT + DELIMITER +
"ServiceComponentDefns"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the ServiceComponentDefn Element
which contains
- * all of the XML elements that represent a ServiceComponentDefn object.
- */
- public static class ServiceComponentDefn {
-
- /**
- * This is the name of the ServiceComponentDefn Element.
- */
- public static final String ELEMENT =
"ServiceComponentDefn"; //$NON-NLS-1$
-
- public static class Attributes extends ComponentObject.Attributes{
- public static final String ROUTING_UUID =
"routingUUID"; //$NON-NLS-1$
- }
- }
- }
-
-
- /**
- * This is the class that represents the VMComponentDefns Element which
contains
- * all of the XML elements that represent a VMComponentDefns object.
- */
- public static class VMComponentDefns {
-
- /**
- * This is the name of the VMComponentDefns Element.
- */
- public static final String ELEMENT = Configuration.ELEMENT + DELIMITER
+"VMComponentDefns"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the VMComponentDefn Element which
contains
- * all of the XML elements that represent a VMComponentDefn object.
- */
- public static class VMComponentDefn {
-
- /**
- * This is the name of the VMComponentDefn Element.
- */
- public static final String ELEMENT = "VMComponentDefn";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- }
- }
- }
-
-
-
- /**
- * This is the class that represents the DeployedComponents Element which
contains
- * all of the XML elements that represent a DeployedComponents object.
- */
- public static class DeployedComponents {
-
- /**
- * This is the name of the DeployedComponents Element.
- */
- public static final String ELEMENT = Configuration.ELEMENT + DELIMITER +
"DeployedComponents"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the DeployedComponent Element which
contains
- * all of the XML elements that represent a DeployedComponent object.
- */
- public static class DeployedComponent {
-
- /**
- * This is the name of the DeployedComponent Element.
- */
- public static final String ELEMENT = "DeployedComponent";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- public static final String HOST_ID = "HostID";
//$NON-NLS-1$
-// public static final String PRODUCT_SERVICE_CONFIG_ID =
"ProductServiceConfigID"; //$NON-NLS-1$
- public static final String SERVICE_COMPONENT_DEFN_ID =
"ServiceComponentDefnID"; //$NON-NLS-1$
- public static final String VM_COMPONENT_DEFN_ID =
"VMComponentDefnID"; //$NON-NLS-1$
- }
- }
- }
-
-
- /**
- * This is the class that represents the ComponentDefnID Element which
contains
- * all of the XML elements that represent a ComponentDefnID object.
- */
- public static final class ComponentDefnID{
-
- /**
- * This is the name of the ComponentDefnID Element.
- */
- public static final String ELEMENT = "ComponentDefnID";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
-
- /**
- * This is the class that represents the DeployedComponentID Element which
contains
- * all of the XML elements that represent a DeployedComponentID object.
- */
- public static final class DeployedComponentID{
-
- /**
- * This is the name of the DeployedComponentID Element.
- */
- public static final String ELEMENT = "DeployedComponentID";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
-
- /**
- * This is the class that represents the ProductServiceConfigID Element which
contains
- * all of the XML elements that represent a ProductServiceConfigID object.
- */
-// public static final class ProductServiceConfigID{
-//
-// /**
-// * This is the name of the ProductServiceConfigID Element.
-// */
-// public static final String ELEMENT =
"ProductServiceConfigID"; //$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ID.Attributes {
-// }
-// }
-
- /**
- * This is the class that represents the VMComponentDefnID Element which
contains
- * all of the XML elements that represent a VMComponentDefnID object.
- */
- public static final class VMComponentDefnID{
-
- /**
- * This is the name of the VMComponentDefnID Element.
- */
- public static final String ELEMENT = "VMComponentDefnID";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
-
- /**
- * This is the class that represents the VMComponentDefnID Element which
contains
- * all of the XML elements that represent a VMComponentDefnID object.
- */
- public static final class ServiceComponentDefnID{
-
- /**
- * This is the name of the ServiceComponentDefnID Element.
- */
- public static final String ELEMENT = "ServiceComponentDefnID";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
-
- /**
- * This is the class that represents the ConfigurationInfo Element which
contains
- * all of the XML elements that represent a ConfigurationInfo object.
- */
- public static class ConfigurationInfo {
-
- /**
- * This is the name of the ServiceComponentDefnID Element.
- */
- public static final String ELEMENT = "ConfigurationInfo";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String LAST_CHANGED_DATE =
"LastChangedDate"; //$NON-NLS-1$
- public static final String CREATION_DATE = "CreationDate";
//$NON-NLS-1$
- }
- }
-
- /**
- * This is the class that represents the LogConfiguration Element which
contains
- * all of the XML elements that represent a LogConfiguration object.
- */
- public static class LogConfiguration {
-
- /**
- * This is the name of the LogConfiguration Element.
- */
- public static final String ELEMENT = "LogConfiguration";
//$NON-NLS-1$
-
- }
-
- }
- }
-
- /**
- * This is the class that represents the ComponentObject Element which contains
- * all of the XML elements that represent a ComponentObject object.
- */
- public static class ComponentObject {
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- public static final String COMPONENT_TYPE = "ComponentType";
//$NON-NLS-1$
- }
- }
-
- /**
- * This is the class that represents the Properties Element which contains
- * all of the XML elements that represent a Properties object.
- */
- public static class Properties {
-
- /**
- * This is the name of the Properties Element.
- */
- public static final String ELEMENT = "Properties"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the Property Element which contains
- * all of the XML elements that represent a Property object.
- */
- public static class Property {
-
- /**
- * This is the name of the Property Element.
- */
- public static final String ELEMENT = "Property"; //$NON-NLS-1$
-
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- }
-
- }
- }
-
- /**
- * This is the class that represents the ChangeHistory Properties Element which
contains
- * all of the XML elements that represent the change information for the object.
- */
- public static class ChangeHistory {
-
- /**
- * This is the name of the ChangeHistory Element.
- */
- public static final String ELEMENT = "ChangeHistory"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the Property Element which contains
- * all of the XML elements that represent a Property object.
- */
- public static class Property {
-
- /**
- * This is the name of the Property Element.
- */
- public static final String ELEMENT = "Property"; //$NON-NLS-1$
-
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- }
-
- public static class NAMES {
- public static final String LAST_CHANGED_DATE = "LastChangedDate";
//$NON-NLS-1$
- public static final String LAST_CHANGED_BY = "LastChangedBy";
//$NON-NLS-1$
- public static final String CREATION_DATE = "CreationDate";
//$NON-NLS-1$
- public static final String CREATED_BY = "CreatedBy";
//$NON-NLS-1$
-
- }
- }
- }
-
-
- /**
- * This is the class that represents the ID Element which contains
- * all of the XML elements that represent a ID object.
- */
- public static class ID {
- // these are the shared attributes of all ID Elements
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- }
- }
-
-
- /**
- * This is the class that represents the HostID Element which contains
- * all of the XML elements that represent a HostID object.
- */
- public static final class HostID {
-
- /**
- * This is the name of the HostID Element.
- */
- public static final String ELEMENT = "HostID"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
-
-
-
-
-
- /**
- * This is the class that represents the Hosts Element which contains
- * all of the XML elements that represent a Hosts object.
- */
- public static class Hosts {
-
- /**
- * This is the name of the Hosts Element.
- */
- public static final String ELEMENT = "Hosts"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the Host Element which contains
- * all of the XML elements that represent a Host object.
- */
- public static class Host {
-
- /**
- * This is the name of the Host Element.
- */
- public static final String ELEMENT = "Host"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends
Configurations.Configuration.Attributes {
- }
- }
- }
-
- /**
- * This is the class that represents the Resources Element which contains
- * all of the XML elements that represent a Resource object.
- */
- public static class Resources {
-
- /**
- * This is the name of the Hosts Element.
- */
- public static final String ELEMENT = "Resources"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the Resource Element which contains
- * all of the XML elements that represent a Resource object.
- */
- public static class Resource {
-
- /**
- * This is the name of the Resource Element.
- */
- public static final String ELEMENT = "Resource"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- }
-
-
- }
- }
-
- /**
- * This is the class that represents the ServiceComponentDefns Element which
contains
- * all of the XML elements that represent a ServiceComponentDefns object.
- */
- public static class ConnectorComponents {
-
- /**
- * This is the name of the ServiceComponentDefns Element.
- */
- public static final String ELEMENT = "ConnectorBindings";
//$NON-NLS-1$
-
- /**
- * This is the class that represents the ConnectorBinding Element which
contains
- * all of the XML elements that represent a ConnectorBinding object.
- */
- public static class ConnectorComponent {
-
- /**
- * This is the name of the ConnectorBinding Element.
- */
- public static final String ELEMENT = "Connector";
//$NON-NLS-1$
-
- public static class Attributes extends ComponentObject.Attributes{
- public static final String QUEUED_SERVICE =
"QueuedService"; //$NON-NLS-1$
-// public static final String IS_ENABLED = "IsEnabled";
- public static final String ROUTING_UUID =
"routingUUID"; //$NON-NLS-1$
- }
- }
- }
-
-
-
- /**
- * This is the class that represents the ComponentTypeID Element which contains
- * all of the XML elements that represent a ComponentTypeID object.
- */
- public static class ComponentTypeID {
-
- /**
- * This is the name of the ComponentTypeID Element.
- */
- public static final String ELEMENT = "ComponentTypeID"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
-
- }
-
- /**
- * This is the class that represents the ComponentTypes Element which contains
- * all of the XML elements that represent a ComponentTypes object.
- */
- public static class ComponentTypes {
-
- /**
- * This is the name of the ComponentTypes Element.
- */
- public static final String ELEMENT = "ComponentTypes"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the ComponentType Element which contains
- * all of the XML elements that represent a ComponentType object.
- */
- public static class ComponentType {
-
- /**
- * This is the name of the ComponentType Element.
- */
- public static final String ELEMENT = "ComponentType";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name"; //$NON-NLS-1$
- public static final String PARENT_COMPONENT_TYPE =
"ParentComponentType"; //$NON-NLS-1$
- public static final String SUPER_COMPONENT_TYPE =
"SuperComponentType"; //$NON-NLS-1$
- public static final String COMPONENT_TYPE_CODE =
"ComponentTypeCode"; //$NON-NLS-1$
- public static final String DEPLOYABLE = "Deployable";
//$NON-NLS-1$
- public static final String DEPRECATED = "Deprecated";
//$NON-NLS-1$
- public static final String MONITORABLE = "Monitorable";
//$NON-NLS-1$
- }
-
-
- /**
- * This is the class that represents the ComponentTypeDefn Element which
contains
- * all of the XML elements that represent a ComponentTypeDefn object.
- */
- public static class ComponentTypeDefn {
-
- /**
- * This is the name of the ComponentTypeDefn Element.
- */
- public static final String ELEMENT = "ComponentTypeDefn";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String DEPRECATED = "Deprecated";
//$NON-NLS-1$
- }
-
- /**
- * This is the class that represents the PropertyDefinition Element which
contains
- * all of the XML elements that represent a PropertyDefinition object.
- */
- public static class PropertyDefinition {
-
- /**
- * This is the name of the PropertyDefinition Element.
- */
- public static final String ELEMENT = "PropertyDefinition";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String NAME = "Name";
//$NON-NLS-1$
- public static final String DISPLAY_NAME =
"DisplayName"; //$NON-NLS-1$
- public static final String SHORT_DESCRIPTION
="ShortDescription"; //$NON-NLS-1$
- public static final String DEFAULT_VALUE =
"DefaultValue"; //$NON-NLS-1$
- public static final String MULTIPLICITY =
"Multiplicity"; //$NON-NLS-1$
- public static final String PROPERTY_TYPE =
"PropertyType"; //$NON-NLS-1$
- public static final String VALUE_DELIMITER =
"ValueDelimiter"; //$NON-NLS-1$
- public static final String IS_CONSTRAINED_TO_ALLOWED_VALUES =
"IsConstrainedToAllowedValues"; //$NON-NLS-1$
- public static final String IS_EXPERT = "IsExpert";
//$NON-NLS-1$
- public static final String IS_HIDDEN = "IsHidden";
//$NON-NLS-1$
- public static final String IS_MASKED = "IsMasked";
//$NON-NLS-1$
- public static final String IS_MODIFIABLE =
"IsModifiable"; //$NON-NLS-1$
- public static final String IS_PREFERRED =
"IsPreferred"; //$NON-NLS-1$
- }
-
- /**
- * This is the class that represents the AllowedValue Element which
contains
- * all of the XML elements that represent a AllowedValue object.
- */
- public static class AllowedValue {
-
- /**
- * This is the name of the AllowedValue Element.
- */
- public static final String ELEMENT = "AllowedValue";
//$NON-NLS-1$
- }
-
- }
-
- }
- }
- }
-
- /**
- * This is the class that represents the ProductTypes Element which contains
- * all of the XML elements that represent a ProductType object.
- */
-// public static class ProductTypes {
-// public static final String ELEMENT = "ProductTypes"; //$NON-NLS-1$
-//
-// /**
-// * This is the class that represents the ProductType Element which contains
-// * all of the XML elements that represent a ProductType object.
-// * Note that it extends teh ComponentType element definition.
-// */
-// public static class ProductType extends ComponentTypes.ComponentType{
-// public static final String ELEMENT = "ProductType";
//$NON-NLS-1$
-// }
-// }
-
-
-
-
- /**
- * This is the class that represents the Header Element which contains
- * all of the XML elements that represent a Header object.
- */
- public static class Header {
-
- /**
- * This is the name of the Header Element.
- */
- public static final String ELEMENT = "Header"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the UserName Element which contains
- * all of the XML elements that represent a UserName object.
- */
- public static class UserCreatedBy {
-
- /**
- * This is the name of the UserName Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.USER_CREATED_BY;
- }
-
- /**
- * This is the class that represents the ApplicationCreatedDate Element which
contains
- * all of the XML elements that represent a ApplicationCreatedDate object.
- */
- public static class ApplicationCreatedBy {
-
- /**
- * This is the name of the ApplicationCreatedDate Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.APPLICATION_CREATED_BY;
- }
-
- /**
- * This is the class that represents the ApplicationVersionCreatedBy Element which
contains
- * all of the XML elements that represent a ApplicationVersionCreatedBy object.
- */
- public static class ApplicationVersionCreatedBy {
-
- /**
- * This is the name of the ApplicationVersionCreatedBy Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.APPLICATION_VERSION_CREATED_BY;
- }
-
- /**
- * This is the class that represents the Time Element which contains
- * all of the XML elements that represent a Time object.
- */
- public static class Time {
-
- /**
- * This is the name of the Time Element.
- */
- public static final String ELEMENT = ConfigurationPropertyNames.TIME;
- }
-
- /**
- * This is the class that represents the DocumentTypeVersion Element which
contains
- * all of the XML elements that represent a DocumentTypeVersion object.
- */
- public static class ConfigurationVersion {
-
- /**
- * This is the name of the DocumentTypeVersion Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.CONFIGURATION_VERSION;
- }
-
- /**
- * This is the class that represents the MetaMatrixServerVersion Element which
contains
- * all of the XML elements that represent a ProductServiceConfigs object.
- */
- public static class MetaMatrixSystemVersion {
-
- /**
- * This is the name of the MetaMatrixServerVersion Element.
- */
- public static final String ELEMENT =
ConfigurationPropertyNames.METAMATRIX_SYSTEM_VERSION;
- }
- }
-
-
-}
Deleted:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelper.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelper.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelper.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -1,674 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.xml;
-
-
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jdom.Element;
-
-import com.metamatrix.common.config.api.ComponentDefn;
-import com.metamatrix.common.config.api.ComponentObject;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeDefn;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConfigurationInfo;
-import com.metamatrix.common.config.api.ConfigurationObjectEditor;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.config.api.Host;
-import com.metamatrix.common.config.api.HostID;
-import com.metamatrix.common.config.api.ResourceDescriptor;
-import com.metamatrix.common.config.api.ServiceComponentDefn;
-import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.config.api.VMComponentDefn;
-import com.metamatrix.common.config.api.VMComponentDefnID;
-import com.metamatrix.common.config.util.InvalidConfigurationElementException;
-import com.metamatrix.common.object.PropertyDefinition;
-
-/**
-* This helper class is used to create JDOM XML Elements from configuration objects.
-*/
-public interface XMLHelper {
-
- /**
- * This method is used to create a Configuration JDOM Element from a
- * Configuration object.
- *
- * @param configuration the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createConfigurationElement(Configuration configuration);
-
-
- /**
- * This method is used to create a ConfigurationInfo JDOM Element from a
- * ConfigurationInfo object.
- *
- * @param info the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createConfigurationInfoElement(ConfigurationInfo info);
-
- /**
- * This method is used to create a LogConfiguration JDOM Element from a
- * LogConfiguration object.
- *
- * @param info the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-// public Element createLogConfigurationElement(LogConfiguration logConfiguration) ;
-
-
- /**
- * This method is used to create a DeployedComponent JDOM Element from a
- * DeployedComponent object.
- *
- * @param deployedComponent the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-// public Element createDeployedComponentElement(DeployedComponent deployedComponent)
;
-
-// public DeployedComponent createDeployedVMComponentDefn(Element element,
-// ConfigurationID configID,
-// HostID hostID,
-// ComponentTypeID typeID,
-// ConfigurationObjectEditor
editor)
-// throws
InvalidConfigurationElementException;
-
-
- /**
- * This method is used to create a VMComponentDefn JDOM Element from a
- * VMComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createVMComponentDefnElement(VMComponentDefn defn) ;
-
- /**
- * This method is used to create a ServiceComponentDefn JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createServiceComponentDefnElement(ServiceComponentDefn defn);
-
- /**
- * This method is used to create a ResourceDescriptor JDOM Element from a
- * ResourceDescriptor object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-
-// public Element createServiceComponentDefnElement(ResourceDescriptor defn);
-
-
- /**
- * This method is used to create a ProductServiceConfig JDOM Element from a
- * ProductServiceConfig object.
- *
- * @param config the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- // public Element createProductServiceConfigElement(ProductServiceConfig config);
-
- /**
- * This method is used to create a ComponentType JDOM Element from a
- * ComponentType object.
- *
- * @param type the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createComponentTypeElement(ComponentType type) ;
-
- /**
- * This method is used to create a PropertyDefinition JDOM Element from a
- * PropertyDefinition object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createPropertyDefinitionElement(PropertyDefinition defn) ;
-
- /**
- * This method is used to create a ComponentTypeDefn JDOM Element from a
- * ComponentTypeDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createComponentTypeDefnElement(ComponentTypeDefn defn) ;
-
- /**
- * This method is used to create a ProductType JDOM Element from a
- * ProductType object.
- *
- * @param type the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- // public Element createProductTypesElement() ;
-
- /**
- * This method is used to create a ProductServiceConfig JDOM Element from a
- * ProductServiceConfig object.
- *
- * @param type the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- // public Element createProductServiceConfigsElement() ;
-
-
- /**
- * This method is used to create a ProductType JDOM Element from a
- * ProductType object.
- *
- * @param type the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- // public Element createProductTypeElement(ProductType type);
-
- /**
- * This method is used to create a Host JDOM Element from a
- * Host object.
- *
- * @param host the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createHostElement(Host host) ;
-
- /**
- * <p>This method is used to create a Header JDOM Element from a
- * Properties object. The properties object can contain any of the
- * following properties that will be included in the header:<p>
- * <pre>
- * XMLElementNames.Header.ApplicationCreatedDate.ELEMENT
- * XMLElementNames.Header.ApplicationVersionCreatedBy.ELEMENT
- * XMLElementNames.Header.UserName.ELEMENT
- * XMLElementNames.Header.DocumentTypeVersion.ELEMENT
- * XMLElementNames.Header.MetaMatrixServerVersion.ELEMENT
- * XMLElementNames.Header.Time.ELEMENT
- * <pre>
- * <p>Any of these properties that are not included in the properties object
- * will not be included in the header Element that is returned.
- *
- * @param props the properties object that contains the values for the Header
- * @return a JDOM XML Element
- */
- public Element createHeaderElement(Properties props) ;
-
-
- /**
- * Return the properties stored in the header section.
- * @param element
- * @return Properties containing the header information
- * @throws InvalidConfigurationElementException if the element passed in
- * is not the header element or its XML structure do not conform to the
- * XML structure specfied in the XMLElementNames class.
- *
- * @since 4.2
- */
- public Properties getHeaderProperties(Element element)throws
InvalidConfigurationElementException;
-
-
- /**
- * Returns true if the information in the element indicates
- * that it is compatible with the 4.2 configuration format.
- * Otherwise, it considered to be pre 4.2 compatible.
- * @param element
- * @return
- * @throws InvalidConfigurationElementException
- * @since 4.2
- */
- public boolean is42ConfigurationCompatible(Element element) throws
InvalidConfigurationElementException;
-
-
- /**
- * This method is used to create a Properties JDOM Element from a
- * Properties object.
- *
- * @param props the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createPropertiesElement(Properties props);
-
- /**
- * This method is used to create a Configuration ID JDOM Element from a
- * Configuration ID object.
- *
- * @param type the ID type to be created. @see
XMLElementNames.Configurations.Configuration.XXXID.ELEMENT for valid values
- * @param name the calue of the name attribute of the ID element to create.
- * @return a JDOM XML Element
- */
- public Element createIDElement(String type, String name);
-
- /**
- * This method is used to create a Configurations JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createConfigurationsElement();
-
- /**
- * This method is used to create a Hosts JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createHostsElement();
-
- /**
- * This method is used to create a ComponentTypes JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createComponentTypesElement();
-
- /**
- * This method is used to create a ServiceComponentDefns JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createServiceComponentDefnsElement();
-
- /**
- * This method is used to create a root JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createRootConfigurationDocumentElement();
-
- /**
- * This method will create a Host configuration object from an XML element
- * that represents a Host.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the Host configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public Host createHost(Element element, ConfigurationID configID,
ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException;
-
-
- /**
- * This method will create a SharedResource configuration object from an XML element
- * that represents a SharedResource.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @return the ResourceDescriptor configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public SharedResource createSharedResource(Element element, ConfigurationObjectEditor
editor) throws InvalidConfigurationElementException;
-
- /**
- * This method is used to create a Resources JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createSharedResourcesElement();
-
-
- /**
- * This method is used to create a Shared Resource JDOM Element from a
- * SharedResource object.
- *
- * @param host the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createSharedResourceElement(SharedResource resource) ;
-
-
- /**
- * This method will create a ComponentType configuration object from an XML element
- * that represents a ComponentType.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @param maintainIDs should be true if the created ComponentType
- * should use the Parent ID name that is defined within the element
- * otherwise their parentID will be null. This should only be true if
- * it is known that the configuration environment that this ComponentType
- * is to be commited to contains a valid ComponentType with the ParentID
- * matching that in the XML element (typically in the case of Connector
- * ComponentTypes).
- * @return the ComponentType configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ComponentType createComponentType(Element element, ConfigurationObjectEditor
editor, String name, boolean maintainParentID)throws
InvalidConfigurationElementException;
-
- /**
- * This method will create a ProductType configuration object from an XML element
- * that represents a ProductType.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @param componentTypeMap this is a map of ComponentTypeID--->ComponentType
- * it must contain all of the Component types that the ProductType
- * that is represented by the passed in XML element references.
- * @return the ProductType configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- // public ProductType createProductType(Element element, ConfigurationObjectEditor
editor,Map ComponentTypeMap, String name)throws InvalidConfigurationElementException;
-
-
- /**
- * This method will create a Configuration configuration object from an XML element
- * that represents a Configuration.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the Configuration configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public Configuration createConfiguration(Element element, ConfigurationObjectEditor
editor, String name)throws InvalidConfigurationElementException;
-
- /**
- * This method will create a LogConfiguration configuration object from an XML
element
- * that represents a LogConfiguration.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the LogConfiguration configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
-// public LogConfiguration createLogConfiguration(Element element)throws
InvalidConfigurationElementException;
-
-
- /**
- * This method will create a resource pool configuration object from an XML element
- * that represents a ResourceDescriptor.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @return the ResourceDescriptor configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ResourceDescriptor createResourcePool(Element element, ConfigurationID
configID, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException;
-
-
-
- /**
- * This method is used to create a ResourceDescriptor JDOM Element from a
- * ResourceDescriptor object.
- *
- * @param connector the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createResourcePoolElement(ResourceDescriptor resource);
-
- /**
- * This method is used to create a ResourceDescriptors JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
-
- public Element createResourcePoolsElement();
-
- /**
- * This method will create a ServiceComponentDefn configuration object from an XML
element
- * that represents a ServiceComponentDefn.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ServiceComponentDefn configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ComponentDefn createServiceComponentDefn(Element element, Configuration
config, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException;
-
- /**
- * This method will create a ServiceComponentDefn configuration object from an XML
element
- * that represents a ServiceComponentDefn.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ServiceComponentDefn configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
-
- public ComponentDefn createServiceComponentDefn(Element element, ConfigurationID
configID, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException;
-
-
-
- /**
- * This method is used to create a ConnectorBindings JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createConnectorBindingsElement();
-
- /**
- * This method is used to create a Connector Binding JDOM Element from a
- * ConnectorBinding object.
- *
- * @param connector the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createConnectorBindingElement(ConnectorBinding connector, boolean
isExportConfig) ;
-
-
- /**
- * This method will create a ConnectorBinding object from an XML element
- * that represents a ServiceComponentDefn.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ConnectorBinding configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
-
- public ConnectorBinding createConnectorBinding(ConfigurationID configurationID,
Element element, ConfigurationObjectEditor editor, String name, boolean
isImportConfig)throws InvalidConfigurationElementException;
-
- /**
- * This method will create a DeployedComponent configuration object from an XML
element
- * that represents a DeployedComponent.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @param serviceComponentDefnMap a map of
ServiceComponentDefnID-->ServiceComponentDefn
- * this map must contain at the very least the ServiceComponentDefn that
- * is the service definition of the deployed component that the XML element
- * references. This is used if the deployedComponent is a Service. Otherwise
- * it is ignored.
- * @param vmComponentDefnMap a map of vmComponentDefnID-->vmComponentDefn
- * this map must contain at the very least the vmComponentDefn that
- * is the VM definition of the deployed component that the XML element
- * references. This is used if the deployedComponent is a VM. Otherwise
- * it is ignored.
- * @return the DeployedComponent configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
-// public DeployedComponent createDeployedComponent(Element element, Configuration
config, ConfigurationObjectEditor editor, Map serviceComponentDefnMap, Map
vmComponentDefnMap, Map componentTypeMap, String name)throws
InvalidConfigurationElementException;
-
-
-// public DeployedComponent createDeployedComponent(Element element,
-// ConfigurationID configID,
-// HostID hostID,
-// VMComponentDefnID vmID,
-// Map componentTypeMap,
-// ConfigurationObjectEditor editor)
-// throws
InvalidConfigurationElementException;
-
-
- // public Element createDeployedProductServiceConfigElement(ProductServiceConfig
config);
-
- /**
- * This method will create a VMComponentDefn configuration object from an XML element
- * that represents a VMComponentDefn.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param configID is the configuration the vm will become a part of
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the VMComponentDefn configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public VMComponentDefn createVMComponentDefn(Element element, ConfigurationID
configID, HostID hostID, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException;
-
- /**
- *
- * @param element
- * @param configID
- * @param hostID
- * @param editor
- * @param name
- * @return
- * @throws InvalidConfigurationElementException
- * @since 4.1
- * @deprecated
- */
-
- // public VMComponentDefn createVMComponentDefn(Element element, ConfigurationID
configID, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException;
-
- /**
- * This method will create a ProductServiceConfig configuration object from an XML
element
- * that represents a ProductServiceConfig.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param configID is the configuration this PSC will become a part of
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ProductServiceConfig configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
-// public ProductServiceConfig createProductServiceConfig(Element element,
ConfigurationID configID, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException;
-
- /**
- * This method will create a ComponentObject configuration object from an XML element
- * that represents a ComponentObject.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ComponentObject configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ComponentObject addProperties(Element propertiesElement, ComponentObject
object, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException;
-
- /**
- * This helper method will order a List of XML JDOM elements that represent
- * ComponentTypes or ProductTypes so that types that are referenced by other
- * types in the list are in the returned list before the object that is
- * referencing it. This is necessary so that the object editor that is
- * used to create the ComponentTypes will contain viable actions.
- * a ComponentType object that references a super cannot be created prior to the
super
- * ComponentType object.
- *
- * @param List of ComponentType objects
- */
- public void orderComponentTypeElementList(List componentTypeElements);
-
-}
Copied:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
(from rev 747,
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java)
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
(rev 0)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -0,0 +1,2441 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.config.xml;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jdom.Element;
+
+import com.metamatrix.admin.api.objects.PropertyDefinition.RestartType;
+import com.metamatrix.common.CommonPlugin;
+import com.metamatrix.common.config.api.AuthenticationProvider;
+import com.metamatrix.common.config.api.ComponentDefn;
+import com.metamatrix.common.config.api.ComponentObject;
+import com.metamatrix.common.config.api.ComponentType;
+import com.metamatrix.common.config.api.ComponentTypeDefn;
+import com.metamatrix.common.config.api.ComponentTypeID;
+import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.config.api.ConfigurationID;
+import com.metamatrix.common.config.api.ConfigurationObjectEditor;
+import com.metamatrix.common.config.api.ConnectorBinding;
+import com.metamatrix.common.config.api.ConnectorBindingID;
+import com.metamatrix.common.config.api.DeployedComponent;
+import com.metamatrix.common.config.api.Host;
+import com.metamatrix.common.config.api.HostID;
+import com.metamatrix.common.config.api.ServiceComponentDefn;
+import com.metamatrix.common.config.api.ServiceComponentDefnID;
+import com.metamatrix.common.config.api.SharedResource;
+import com.metamatrix.common.config.api.VMComponentDefn;
+import com.metamatrix.common.config.api.VMComponentDefnID;
+import com.metamatrix.common.config.model.BasicComponentObject;
+import com.metamatrix.common.config.model.BasicComponentType;
+import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
+import com.metamatrix.common.config.model.BasicUtil;
+import com.metamatrix.common.config.model.BasicVMComponentDefn;
+import com.metamatrix.common.config.util.ConfigurationPropertyNames;
+import com.metamatrix.common.config.util.InvalidConfigurationElementException;
+import com.metamatrix.common.log.LogConfiguration;
+import com.metamatrix.common.namedobject.BaseID;
+import com.metamatrix.common.object.Multiplicity;
+import com.metamatrix.common.object.MultiplicityExpressionException;
+import com.metamatrix.common.object.PropertyDefinition;
+import com.metamatrix.common.object.PropertyDefinitionImpl;
+import com.metamatrix.common.object.PropertyType;
+import com.metamatrix.common.util.ErrorMessageKeys;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.core.util.DateUtil;
+import com.metamatrix.core.util.EquivalenceUtil;
+/**
+* This helper class is used to create JDOM XML Elements from configuration objects
+* and to create Configuration objects from JDOM XML Elements.
+*
+*
+* NOTE - The helper cannot have any calls to LogManager because the bootstrapping of
+* the CurrentConfiguration
+* uses this class and the CurrentConfiguration has to come up before
+* logging is available.
+*
+*/
+public class XMLHelperImpl implements ConfigurationPropertyNames {
+
+
+ /**
+ * @see
com.metamatrix.common.config.xml.XMLHelper#createDeployedComponent(org.jdom.Element,
com.metamatrix.common.config.api.ConfigurationID, com.metamatrix.common.config.api.HostID,
com.metamatrix.common.config.api.VMComponentDefnID,
com.metamatrix.common.config.api.ProductServiceConfigID, java.util.Map,
com.metamatrix.common.config.api.ConfigurationObjectEditor)
+ * @since 4.1
+ */
+// public DeployedComponent createDeployedComponent(Element element,
+// ConfigurationID configID,
+// HostID hostID,
+// VMComponentDefnID vmID,
+// Map componentTypeMap,
+// ConfigurationObjectEditor editor)
throws InvalidConfigurationElementException {
+// return null;
+// }
+ /**
+ * This method is used to create a Configuration JDOM Element from a
+ * Configuration object.
+ *
+ * @param configuration the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createConfigurationElement(Configuration configuration) {
+ // first we set up the organizational structure of a configuration
+ Assertion.isNotNull(configuration);
+
+ Element configElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.ELEMENT, configuration,
true);
+ return configElement;
+ }
+
+
+
+ /**
+ * This method is used to create a ConfigurationInfo JDOM Element from a
+ * ConfigurationInfo object.
+ *
+ * @param info the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+// public Element createConfigurationInfoElement(ConfigurationInfo info) {
+// throw new UnsupportedOperationException("Method
createConfigurationInfoElement is unsupported in 4.2"); //$NON-NLS-1$
+
+// Assertion.isNotNull(info);
+//
+// Element configurationInfoElement = new
Element(XMLConfig_42__ElementNames.Configuration.ConfigurationInfo.ELEMENT);
+//
+// Date date = info.getLastChangedDate();
+// if (date != null) {
+//
configurationInfoElement.setAttribute(XMLConfig_42__ElementNames.Configuration.ConfigurationInfo.Attributes.LAST_CHANGED_DATE,
date.toString());
+// }
+//
+// date = info.getCreationDate();
+// if (date !=null) {
+//
configurationInfoElement.setAttribute(XMLConfig_42__ElementNames.Configuration.ConfigurationInfo.Attributes.CREATION_DATE,
date.toString());
+// }
+// return configurationInfoElement;
+ // }
+
+ /**
+ * This method is used to create a DeployedComponent JDOM Element from a
+ * DeployedComponent object.
+ *
+ * @param deployedComponent the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createDeployedServiceElement(DeployedComponent deployedComponent) {
+ Assertion.isNotNull(deployedComponent);
+
+ Element deployedComponentElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.DeployedService.ELEMENT,
deployedComponent, true);
+
+ return deployedComponentElement;
+ }
+
+ /**
+ * This method is used to create a VMComponentDefn JDOM Element from a
+ * VMComponentDefn object.
+ *
+ * @param defn the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createProcessElement(VMComponentDefn defn) {
+ Assertion.isNotNull(defn);
+
+ Element vmComponentDefnElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.Process.ELEMENT, defn,
true);
+ return vmComponentDefnElement;
+ }
+//
+// public Element createDeployedServiceComponentDefnElement(ServiceComponentDefn defn)
{
+// Assertion.isNotNull(defn);
+//
+// Element serviceComponentDefnElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.DeployedService.ELEMENT,
defn);
+//
serviceComponentDefnElement.setAttribute(XMLConfig_ElementNames.Configuration.DeployedService.Attributes.ROUTING_UUID,
defn.getRoutingUUID());
+// return serviceComponentDefnElement;
+// }
+
+ /**
+ * This method is used to create a ServiceComponentDefn JDOM Element from a
+ * ServiceComponentDefn object.
+ *
+ * @param defn the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createServiceComponentDefnElement(ServiceComponentDefn defn) {
+ Assertion.isNotNull(defn);
+
+ Element serviceComponentDefnElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.Services.Service.ELEMENT,
defn, true);
+
serviceComponentDefnElement.setAttribute(XMLConfig_ElementNames.Configuration.Services.Service.Attributes.ROUTING_UUID,
defn.getRoutingUUID());
+ return serviceComponentDefnElement;
+ }
+
+
+ /**
+ * This method is used to create a ServiceComponentDefn JDOM Element from a
+ * ServiceComponentDefn object.
+ *
+ * @param defn the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createAuthenticationProviderElement(AuthenticationProvider defn) {
+ Assertion.isNotNull(defn);
+
+ Element serviceComponentDefnElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.AuthenticationProviders.Provider.ELEMENT,
defn, true);
+ return serviceComponentDefnElement;
+ }
+ /**
+ * This method is used to create a ServiceComponentDefn JDOM Element from a
+ * ServiceComponentDefn object.
+ *
+ * @param defn the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+// public Element createServiceComponentDefnElement(ResourceDescriptor defn) {
+// Assertion.isNotNull(defn);
+//
+// Element serviceComponentDefnElement =
createComponentObjectElement(XMLConfig_ElementNames.ServiceComponentDefns.ServiceComponentDefn.ELEMENT,
defn);
+// return serviceComponentDefnElement;
+// }
+
+// public Element createDeployedProductServiceConfigElement(ProductServiceConfig
config) {
+// Assertion.isNotNull(config);
+//
+// Element productServiceConfigElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.ProductServiceConfig.ELEMENT,
config);
+//
+// return productServiceConfigElement;
+// }
+//
+// public Element createProductServiceConfigsElement() {
+// return new Element(XMLConfig_ElementNames.ProductServiceConfigs.ELEMENT);
+//
+// }
+
+
+
+
+ /**
+ * This method is used to create a ProductServiceConfig JDOM Element from a
+ * ProductServiceConfig object.
+ *
+ * @param config the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+// public Element createProductServiceConfigElement(ProductServiceConfig config) {
+// Assertion.isNotNull(config);
+//
+// Element productServiceConfigElement =
createComponentObjectElement(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.ELEMENT,
config);
+//
+// Iterator iterator = config.getServiceComponentDefnIDs().iterator();
+// while (iterator.hasNext()) {
+// ServiceComponentDefnID id = (ServiceComponentDefnID)iterator.next();
+// boolean isEnabled = config.isServiceEnabled(id);
+//
+// Element idElement =
createIDElement(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.ELEMENT,
id.getName());
+//
+// idElement.setAttribute(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.Attributes.IS_ENABLED,
(Boolean.valueOf(isEnabled)).toString());
+//
+// productServiceConfigElement.addContent(idElement);
+// }
+// return productServiceConfigElement;
+// }
+
+ /**
+ * This method is used to create a ComponentType JDOM Element from a
+ * ComponentType object.
+ *
+ * @param type the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createComponentTypeElement(ComponentType type) {
+ Assertion.isNotNull(type);
+
+ Element componentTypeElement = new
Element(XMLConfig_ElementNames.ComponentTypes.ComponentType.ELEMENT);
+ Iterator iterator = type.getComponentTypeDefinitions().iterator();
+ while (iterator.hasNext()) {
+ ComponentTypeDefn defn = (ComponentTypeDefn)iterator.next();
+// Element componentTypeDefnElement = createComponentTypeDefnElement(defn);
+ Element propertyDefinitionElement =
createPropertyDefinitionElement(defn.getPropertyDefinition());
+// componentTypeDefnElement.addContent(propertyDefinitionElement);
+ componentTypeElement.addContent(propertyDefinitionElement);
+ }
+
componentTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.NAME,
type.getName());
+
+ if (type.getDescription() != null) {
+
componentTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.DESCRIPTION,
type.getDescription());
+ }
+
+
componentTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE,
new Integer(type.getComponentTypeCode()).toString());
+
componentTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE,
(Boolean.valueOf(type.isDeployable())).toString());
+
componentTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.DEPRECATED,
(Boolean.valueOf(type.isDeprecated())).toString());
+
componentTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE,
(Boolean.valueOf(type.isMonitored())).toString());
+ // we only add these if they are not null
+ BaseID superID = type.getSuperComponentTypeID();
+ String superIDString;
+ if (superID != null) {
+ superIDString = superID.getName();
+
componentTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE,
superIDString);
+
+ }
+
+ BaseID parentID = type.getParentComponentTypeID();
+ String parentIDString;
+ if (parentID!=null) {
+ parentIDString = parentID.getName();
+
componentTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.PARENT_COMPONENT_TYPE,
parentIDString);
+
+ }
+
+ addChangeHistoryElement(type, componentTypeElement);
+// componentTypeElement.addContent(chgHistoryElement);
+
+
+ return componentTypeElement;
+ }
+
+ /**
+ * This method is used to create a PropertyDefinition JDOM Element from a
+ * PropertyDefinition object.
+ *
+ * @param defn the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createPropertyDefinitionElement(PropertyDefinition defn) {
+ Assertion.isNotNull(defn);
+
+
+ Element element = new
Element(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT);
+
+ String name = defn.getName();
+
element.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.NAME,
name);
+
+ String displayName = defn.getDisplayName();
+
element.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DISPLAY_NAME,displayName);
+
+
+ setAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.SHORT_DESCRIPTION,
+ defn.getShortDescription(),
PropertyDefinitionImpl.DEFAULT_SHORT_DESCRIPTION);
+
+ Object value = defn.getDefaultValue();
+ if (value!=null) {
+ setAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DEFAULT_VALUE,
+ value.toString(),
PropertyDefinitionImpl.DEFAULT_DEFAULT_VALUE);
+ }
+
+ Multiplicity mult = defn.getMultiplicity();
+ if (mult!=null) {
+ setAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.MULTIPLICITY,
+ mult.toString(),
PropertyDefinitionImpl.DEFAULT_MULTIPLICITY);
+ }
+
+ PropertyType type = defn.getPropertyType();
+ if (type != null) {
+ setAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.PROPERTY_TYPE,
+ type.getDisplayName(),
PropertyDefinitionImpl.DEFAULT_TYPE.getDisplayName());
+ }
+
+
+ setAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.VALUE_DELIMITER,
+ defn.getValueDelimiter(),
PropertyDefinitionImpl.DEFAULT_DELIMITER);
+
+ setAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_CONSTRAINED_TO_ALLOWED_VALUES,
+ defn.isConstrainedToAllowedValues(),
PropertyDefinitionImpl.DEFAULT_IS_CONSTRAINED);
+
+ setAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_EXPERT,
+ defn.isExpert(), PropertyDefinitionImpl.DEFAULT_IS_EXPERT);
+
+ setAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_HIDDEN,
+ defn.isHidden(), PropertyDefinitionImpl.DEFAULT_IS_HIDDEN);
+
+ setAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MASKED,
+ defn.isMasked(), PropertyDefinitionImpl.DEFAULT_IS_MASKED);
+
+ setAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MODIFIABLE,
+ defn.isModifiable(),
PropertyDefinitionImpl.DEFAULT_IS_MODIFIABLE);
+
+ setAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_PREFERRED,
+ defn.isPreferred(),
PropertyDefinitionImpl.DEFAULT_IS_PREFERRED);
+
+ setAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.REQUIRES_RESTART,
+ defn.getRequiresRestart().toString(),
PropertyDefinitionImpl.DEFAULT_REQUIRES_RESTART.toString());
+
+
+ List allowedValues = defn.getAllowedValues();
+ Iterator iterator = allowedValues.iterator();
+ while (iterator.hasNext()) {
+ Element allowedValueElement = new
Element(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.AllowedValue.ELEMENT);
+ allowedValueElement.addContent((iterator.next()).toString());
+ element.addContent(allowedValueElement);
+ }
+
+ return element;
+
+ }
+
+
+
+ /**
+ * Set the specified attribute on the on the specified element, only if it's not
the default value.
+ * @param element Element to modify
+ * @param attributeName name of Attribute to set
+ * @param value Value to set
+ * @param defaultValue If value==default value, don't set anything.
+ * @since 4.3
+ */
+ private static void setAttributeString(Element element, String attributeName, String
value, String defaultValue) {
+ if (value != null && ! EquivalenceUtil.areEqual(value, defaultValue)) {
+ element.setAttribute(attributeName, value);
+ }
+ }
+ /**
+ * Set the specified attribute on the on the specified element, only if it's not
the default value.
+ * @param element Element to modify
+ * @param attributeName name of Attribute to set
+ * @param value Value to set
+ * @param defaultValue If value==default value, don't set anything.
+ * @since 4.3
+ */
+ private static void setAttributeBoolean(Element element, String attributeName,
boolean value, boolean defaultValue) {
+ if (! value == defaultValue) {
+ String valueString = String.valueOf(value);
+ element.setAttribute(attributeName, valueString);
+ }
+ }
+
+
+ /**
+ * This method is used to create a ComponentTypeDefn JDOM Element from a
+ * ComponentTypeDefn object.
+ *
+ * @param defn the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createComponentTypeDefnElement(ComponentTypeDefn defn) {
+ Assertion.isNotNull(defn);
+
+ Element componentTypeDefnElement = new
Element(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
+
componentTypeDefnElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.Attributes.DEPRECATED,
(Boolean.valueOf(defn.isDeprecated())).toString());
+ return componentTypeDefnElement;
+ }
+
+ /**
+ * This method is used to create a ProductType JDOM Element from a
+ * ProductType object.
+ *
+ * @param type the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+// public Element createProductTypeElement(ProductType type) {
+// Assertion.isNotNull(type);
+//
+// Element productTypeElement = new
Element(XMLConfig_ElementNames.ProductTypes.ProductType.ELEMENT);
+//
+// Iterator iterator = type.getComponentTypeIDs().iterator();
+// while (iterator.hasNext()) {
+// ComponentTypeID id = (ComponentTypeID)iterator.next();
+// Element componentTypeIDElement =
createIDElement(XMLConfig_ElementNames.ComponentTypeID.ELEMENT, id.getName());
+// productTypeElement.addContent(componentTypeIDElement);
+// }
+//
+//
+//
productTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.NAME,
type.getName());
+//
productTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE,
new Integer(type.getComponentTypeCode()).toString());
+//
productTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE,
(Boolean.valueOf(type.isDeployable())).toString());
+//
productTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.DEPRECATED,
(Boolean.valueOf(type.isDeprecated())).toString());
+//
productTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE,
(Boolean.valueOf(type.isMonitored())).toString());
+//
+// // we only add these if they are not null
+// BaseID superID = type.getSuperComponentTypeID();
+// String superIDString;
+// if (superID != null) {
+// superIDString = superID.getName();
+//
productTypeElement.setAttribute(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE,
superIDString);
+//
+// }
+//
+// addChangeHistoryElement(type, productTypeElement);
+//
+//
+// return productTypeElement;
+//
+// }
+
+ /**
+ * This method is used to create a Host JDOM Element from a
+ * Host object.
+ *
+ * @param host the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createHostElement(Host host) {
+ Assertion.isNotNull(host);
+
+ Element hostElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.Host.ELEMENT, host,
true);
+ return hostElement;
+ }
+
+ public Element createDeployedVMElementx(DeployedComponent vm) {
+ Assertion.isNotNull(vm);
+
+ Element hostElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.Host.ELEMENT, vm,
true);
+ return hostElement;
+ }
+
+// public final boolean is42ConfigurationCompatible(Element root) throws
InvalidConfigurationElementException{
+// Element headerElement = root.getChild(XMLConfig_ElementNames.Header.ELEMENT);
+// if (headerElement == null) {
+// throw new InvalidConfigurationElementException("The header element is
not found in the configuration under element.", root.getName()); //$NON-NLS-1$
+// }
+//
+// Properties props = getHeaderProperties(headerElement);
+//
+//
+// String sVersion =
props.getProperty(XMLConfig_ElementNames.Header.ConfigurationVersion.ELEMENT);
+//
+// if (sVersion == null) {
+// return false;
+// }
+// try {
+// double sv = Double.parseDouble(sVersion);
+// if (sv == ConfigurationPropertyNames.CONFIG_CURR_VERSION_DBL) {
+// return true;
+// }
+// } catch (Throwable t) {
+// return false;
+// }
+// return true;
+// }
+
+ public Properties getHeaderProperties(Element element) throws
InvalidConfigurationElementException{
+ Properties props=new Properties();
+
+ if (!element.getName().equals(XMLConfig_ElementNames.Header.ELEMENT)) {
+ throw new InvalidConfigurationElementException("This is not the header
element: " + element.getName() + ".", element); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ List elements = element.getChildren();
+ Iterator it = elements.iterator();
+ while(it.hasNext()) {
+ final Element e = (Element) it.next();
+ props.setProperty(e.getName(), e.getText());
+ }
+
+
+ return props;
+ }
+
+
+ /**
+ * <p>This method is used to create a Header JDOM Element from a
+ * Properties object. The properties object can contain any of the
+ * following properties that will be included in the header:<p>
+ * <pre>
+ * XMLConfig_ElementNames.Header.ApplicationCreatedDate.ELEMENT
+ * XMLConfig_ElementNames.Header.ApplicationVersionCreatedBy.ELEMENT
+ * XMLConfig_ElementNames.Header.UserName.ELEMENT
+ * XMLConfig_ElementNames.Header.DocumentTypeVersion.ELEMENT
+ * XMLConfig_ElementNames.Header.MetaMatrixServerVersion.ELEMENT
+ * XMLConfig_ElementNames.Header.Time.ELEMENT
+ * <pre>
+ * <p>Any of these properties that are not included in the properties object
+ * will not be included in the header Element that is returned.
+ *
+ * @param props the properties object that contains the values for the Header
+ * @return a JDOM XML Element
+ */
+ public Element createHeaderElement(Properties props) {
+ Assertion.isNotNull(props);
+
+ Element headerElement = new Element(XMLConfig_ElementNames.Header.ELEMENT);
+ String applicationCreatedByContent =
props.getProperty(XMLConfig_ElementNames.Header.ApplicationCreatedBy.ELEMENT);
+ String applicationVersionCreatedByContent =
props.getProperty(XMLConfig_ElementNames.Header.ApplicationVersionCreatedBy.ELEMENT);
+ String userNameContent =
props.getProperty(XMLConfig_ElementNames.Header.UserCreatedBy.ELEMENT);
+ String configVersionContent =
props.getProperty(XMLConfig_ElementNames.Header.ConfigurationVersion.ELEMENT);
+ String serverVersionContent =
props.getProperty(XMLConfig_ElementNames.Header.MetaMatrixSystemVersion.ELEMENT);
+ String timeContent =
props.getProperty(XMLConfig_ElementNames.Header.Time.ELEMENT);
+
+
+ if (configVersionContent !=null) {
+ Element configurationVersion = new
Element(XMLConfig_ElementNames.Header.ConfigurationVersion.ELEMENT);
+ configurationVersion.addContent(configVersionContent);
+ headerElement.addContent(configurationVersion);
+ }
+
+ if (applicationCreatedByContent !=null) {
+ Element applicationCreatedBy = new
Element(XMLConfig_ElementNames.Header.ApplicationCreatedBy.ELEMENT);
+ applicationCreatedBy.addContent(applicationCreatedByContent);
+ headerElement.addContent(applicationCreatedBy);
+ }
+
+ if (applicationVersionCreatedByContent != null) {
+ Element applicationVersionCreatedBy = new
Element(XMLConfig_ElementNames.Header.ApplicationVersionCreatedBy.ELEMENT);
+ applicationVersionCreatedBy.addContent(applicationVersionCreatedByContent);
+ headerElement.addContent(applicationVersionCreatedBy);
+ }
+
+ if (userNameContent != null) {
+ Element userName = new
Element(XMLConfig_ElementNames.Header.UserCreatedBy.ELEMENT);
+ userName.addContent(userNameContent);
+ headerElement.addContent(userName);
+ }
+
+ if (serverVersionContent != null) {
+ Element serverVersion = new
Element(XMLConfig_ElementNames.Header.MetaMatrixSystemVersion.ELEMENT);
+ serverVersion.addContent(serverVersionContent);
+ headerElement.addContent(serverVersion);
+ }
+
+ if (timeContent != null) {
+ Element time = new Element(XMLConfig_ElementNames.Header.Time.ELEMENT);
+ time.addContent(timeContent);
+ headerElement.addContent(time);
+ }
+ return headerElement;
+
+ }
+
+ private ComponentObject setDateHistory(ComponentObject defn, Element element,
ConfigurationObjectEditor editor) {
+
+ String lastChangedBy=null;
+ String lastChangedDate=null;
+ String createdDate=null;
+ String createdBy=null;
+
+ Properties props = getChangeHistoryFromElement(element);
+
+ if (props != null && props.size() > 0) {
+ lastChangedBy =
props.getProperty(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
+ lastChangedDate =
props.getProperty(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
+ createdBy =
props.getProperty(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
+ createdDate =
props.getProperty(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
+ } else {
+
+ lastChangedBy =
element.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
+ lastChangedDate =
element.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
+ createdBy =
element.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
+ createdDate =
element.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
+ }
+
+ lastChangedBy = (lastChangedBy!=null?lastChangedBy:""); //$NON-NLS-1$
+ lastChangedDate =
(lastChangedDate!=null?lastChangedDate:DateUtil.getCurrentDateAsString());
+ createdBy = (createdBy!=null?createdBy:""); //$NON-NLS-1$
+ createdDate = (createdDate!=null?createdDate:DateUtil.getCurrentDateAsString());
+
+
+ defn = editor.setCreationChangedHistory(defn, createdBy, createdDate);
+ defn = editor.setLastChangedHistory(defn, lastChangedBy, lastChangedDate);
+
+ return defn;
+
+ }
+
+ private ComponentType setDateHistory(ComponentType type, Element element,
ConfigurationObjectEditor editor) {
+ String lastChangedBy=null;
+ String lastChangedDate=null;
+ String createdDate=null;
+ String createdBy=null;
+
+ Properties props = getChangeHistoryFromElement(element);
+
+ if (props != null && props.size() > 0) {
+ lastChangedBy =
props.getProperty(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
+ lastChangedDate =
props.getProperty(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
+ createdBy =
props.getProperty(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
+ createdDate =
props.getProperty(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
+ } else {
+
+ lastChangedBy =
element.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
+ lastChangedDate =
element.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
+ createdBy =
element.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
+ createdDate =
element.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
+ }
+
+ lastChangedBy = (lastChangedBy!=null?lastChangedBy:""); //$NON-NLS-1$
+ lastChangedDate =
(lastChangedDate!=null?lastChangedDate:DateUtil.getCurrentDateAsString());
+ createdBy = (createdBy!=null?createdBy:""); //$NON-NLS-1$
+ createdDate = (createdDate!=null?createdDate:DateUtil.getCurrentDateAsString());
+
+ type = editor.setCreationChangedHistory(type, createdBy, createdDate);
+ type = editor.setLastChangedHistory(type, lastChangedBy, lastChangedDate);
+
+ return type;
+
+ }
+
+
+ private Properties getChangeHistoryFromElement(Element parentElement) {
+
+ Element propertiesElement =
parentElement.getChild(XMLConfig_ElementNames.ChangeHistory.ELEMENT);
+
+ if (propertiesElement == null ) {
+ return new Properties();
+ }
+
+ Properties props = new Properties();
+
+ List properties =
propertiesElement.getChildren(XMLConfig_ElementNames.ChangeHistory.Property.ELEMENT);
+ if (properties == null) {
+ return new Properties();
+ }
+ Iterator iterator = properties.iterator();
+ while (iterator.hasNext()) {
+ Element propertyElement = (Element)iterator.next();
+ String propertyName =
propertyElement.getAttributeValue(XMLConfig_ElementNames.ChangeHistory.Property.Attributes.NAME);
+ String propertyValue = propertyElement.getText();
+
+ props.setProperty(propertyName,
(propertyValue!=null?propertyValue:"")); //$NON-NLS-1$
+
+ }
+ return props;
+
+ }
+
+
+// private Element addChangeHistoryElementx(ComponentType obj) {
+//
+//// call to create the structure for the properties
+// Element changeHistoryElement = new
Element(XMLConfig_ElementNames.ChangeHistory.ELEMENT);
+//
+// String lastChangedBy=null;
+// String lastChangedDate=null;
+// String createdDate=null;
+// String createdBy=null;
+//
+// lastChangedBy = obj.getLastChangedBy();
+// lastChangedDate = ((BasicComponentType) obj).getLastChangedDateString();
+//
+// createdBy = obj.getCreatedBy();
+// createdDate = ((BasicComponentType) obj).getCreatedDateString();
+//
+//
+// if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
+//
+// } else {
+//
+// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY, lastChangedBy);
+// }
+//
+// if (lastChangedDate == null) {
+// } else {
+//
+// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE, lastChangedDate);
+// }
+//
+// if (createdBy == null || createdBy.trim().length() == 0) {
+// } else {
+//
+// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY, createdBy);
+// }
+//
+// if (createdDate == null) {
+// } else {
+// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE,createdDate);
+// }
+//
+// return changeHistoryElement;
+//
+//
+// }
+
+ private void addChangeHistoryElement(ComponentObject obj, Element element ) {
+
+ String lastChangedBy=null;
+ String lastChangedDate=null;
+ String createdDate=null;
+ String createdBy=null;
+
+ lastChangedBy = obj.getLastChangedBy();
+ lastChangedDate = ((BasicComponentObject) obj).getLastChangedDateString();
+
+ createdBy = obj.getCreatedBy();
+ createdDate = ((BasicComponentObject) obj).getCreatedDateString();
+
+
+ if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
+
+ } else {
+
element.setAttribute(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY,
lastChangedBy);
+ }
+
+ if (lastChangedDate == null) {
+
+ } else {
+
element.setAttribute(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE,
lastChangedDate);
+
+ }
+
+ if (createdBy == null || createdBy.trim().length() == 0) {
+ } else {
+
element.setAttribute(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY,
createdBy);
+ }
+
+ if (createdDate == null) {
+ } else {
+
element.setAttribute(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE,
createdDate);
+ }
+
+ }
+
+ private void addChangeHistoryElement(ComponentType obj, Element element ) {
+
+// call to create the structure for the properties
+
+ String lastChangedBy=null;
+ String lastChangedDate=null;
+ String createdDate=null;
+ String createdBy=null;
+
+ lastChangedBy = obj.getLastChangedBy();
+ lastChangedDate = ((BasicComponentType) obj).getLastChangedDateString();
+
+ createdBy = obj.getCreatedBy();
+ createdDate = ((BasicComponentType) obj).getCreatedDateString();
+
+
+ if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
+
+ } else {
+
element.setAttribute(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY,
lastChangedBy);
+ }
+
+ if (lastChangedDate == null) {
+ lastChangedDate = DateUtil.getCurrentDateAsString();
+ }
+
element.setAttribute(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE,
lastChangedDate);
+
+
+
+ if (createdBy == null || createdBy.trim().length() == 0) {
+ } else {
+
element.setAttribute(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY,
createdBy);
+ }
+
+ if (createdDate == null) {
+ createdDate = DateUtil.getCurrentDateAsString();
+ }
+
element.setAttribute(XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE,
createdDate);
+
+ }
+
+
+
+// private Element addChangeHistoryElementx(ComponentObject obj) {
+//
+// Element changeHistoryElement = new
Element(XMLConfig_ElementNames.ChangeHistory.ELEMENT);
+//
+// String lastChangedBy=null;
+// String lastChangedDate=null;
+// String createdDate=null;
+// String createdBy=null;
+//
+// lastChangedBy = obj.getLastChangedBy();
+// lastChangedDate = ((BasicComponentObject) obj).getLastChangedDateString();
+//
+// createdBy = obj.getCreatedBy();
+// createdDate = ((BasicComponentObject) obj).getCreatedDateString();
+//
+//
+// if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
+//
+// } else {
+//
+// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY, lastChangedBy);
+// }
+//
+// if (lastChangedDate == null) {
+//
+// } else {
+//
+// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_ElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE, lastChangedDate);
+//
+// }
+//
+// if (createdBy == null || createdBy.trim().length() == 0) {
+// } else {
+//
+// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATED_BY, createdBy);
+// }
+//
+// if (createdDate == null) {
+// } else {
+// changeHistoryElement = addPropertyElement(changeHistoryElement,
XMLConfig_ElementNames.ChangeHistory.Property.NAMES.CREATION_DATE, createdDate);
+// }
+//
+// return changeHistoryElement;
+// }
+
+
+ /**
+ * This method is used to create a Properties JDOM Element from a
+ * Properties object.
+ *
+ * @param props the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createPropertiesElement(Properties props) {
+ Assertion.isNotNull(props);
+
+ Properties sortprops = PropertiesUtils.sort(props);
+ Element propertiesElement = new
Element(XMLConfig_ElementNames.Properties.ELEMENT);
+ Enumeration enumeration = sortprops.propertyNames();
+ while (enumeration.hasMoreElements()) {
+ String propName = (String)enumeration.nextElement();
+ propertiesElement = addPropertyElement(propertiesElement, propName,
props.getProperty(propName));
+ }
+
+ return propertiesElement;
+ }
+
+
+ private Element addPropertyElement(Element propertiesElement, String propName, String
propValue) {
+ Element property = new
Element(XMLConfig_ElementNames.Properties.Property.ELEMENT);
+
property.setAttribute(XMLConfig_ElementNames.Properties.Property.Attributes.NAME,
propName);
+ property.addContent(propValue);
+ propertiesElement.addContent(property);
+ return propertiesElement;
+
+ }
+
+
+
+ /**
+ * This method is used to create a Configuration ID JDOM Element from a
+ * Configuration ID object.
+ *
+ * @param type the ID type to be created. @see
XMLConfig_ElementNames.Configuration.XXXID.ELEMENT for valid values
+ * @param name the calue of the name attribute of the ID element to create.
+ * @return a JDOM XML Element
+ */
+ public Element createIDElement(String type, String name) {
+
+ Element idElement = new Element(type);
+ idElement.setAttribute(XMLConfig_ElementNames.ID.Attributes.NAME, name);
+ return idElement;
+ }
+
+ /**
+ * This method is used to create a Configurations JDOM Element from a
+ * Configuration ID object. This element is for structural organization
+ * only and does not represent any real configuration object.
+ *
+ * @return a JDOM XML Element
+ */
+ public Element createConfigurationsElement() {
+ throw new UnsupportedOperationException("Method createConfigurationsElement
is unsupported in 4.2"); //$NON-NLS-1$
+ }
+
+ /**
+ * This method is used to create a Hosts JDOM Element from a
+ * Configuration ID object. This element is for structural organization
+ * only and does not represent any real configuration object.
+ *
+ * @return a JDOM XML Element
+ */
+// public Element createHostsElement() {
+// throw new UnsupportedOperationException("Method createHostsElement is
unsupported in 4.2"); //$NON-NLS-1$
+// }
+
+ /**
+ * This method is used to create a Host JDOM Element from a
+ * Host object.
+ *
+ * @param host the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+// public Element createHostElement(Host host) {
+// Assertion.isNotNull(host);
+//
+// Element hostElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.Host.ELEMENT, host);
+// return hostElement;
+// }
+
+ /**
+ * This method is used to create a ServiceComponentDefns JDOM Element.
+ * This element is for structural organization
+ * only and does not represent any real configuration object.
+ *
+ * @return a JDOM XML Element
+ */
+ public Element createServiceComponentDefnsElement() {
+ return new Element(XMLConfig_ElementNames.Configuration.Services.ELEMENT);
+ }
+
+ /**
+ * This method is used to create a ComponentTypes JDOM Element from a
+ * Configuration ID object. This element is for structural organization
+ * only and does not represent any real configuration object.
+ *
+ * @return a JDOM XML Element
+ */
+ public Element createComponentTypesElement() {
+ return new Element(XMLConfig_ElementNames.ComponentTypes.ELEMENT);
+ }
+
+// public Element createProductTypesElement() {
+// return new Element(XMLConfig_ElementNames.ProductTypes.ELEMENT);
+// }
+
+ public Element createConnectorBindingsElement() {
+ return new
Element(XMLConfig_ElementNames.Configuration.ConnectorComponents.ELEMENT);
+ }
+
+
+ /**
+ * This method is used to create a root JDOM Element.
+ * This element is for structural organization
+ * only and does not represent any real configuration object.
+ *
+ * @return a JDOM XML Element
+ */
+ public Element createRootConfigurationDocumentElement() {
+ return new Element(XMLConfig_ElementNames.ELEMENT);
+ }
+
+
+ /**
+ * This method is used to create a ComponentObject JDOM Element from a
+ * ComponentObject object.
+ *
+ * @param type The subclass type of the configuration object to be created.
+ * @see XMLConfig_ElementNames.Configuration.XXXX.ELEMENT
+ * @param componentObject the object to create the Element for.
+ * @return a JDOM XML Element
+ */
+ private Element createComponentObjectElement(String type, ComponentObject
componentObject, boolean addType) {
+ Element componentObjectElement = new Element(type);
+
componentObjectElement.setAttribute(XMLConfig_ElementNames.ComponentObject.Attributes.NAME,
componentObject.getName());
+ BaseID id = componentObject.getComponentTypeID();
+ if (id !=null && addType) {
+
componentObjectElement.setAttribute(XMLConfig_ElementNames.ComponentObject.Attributes.COMPONENT_TYPE,
id.getName());
+ }
+
+ // this will add the changed history information
+ if (componentObject instanceof DeployedComponent) {
+ // don't write the properties for the deployed component
+ } else {
+ Element properties = createPropertiesElement(
componentObject.getProperties());
+ componentObjectElement.addContent(properties);
+ }
+
+ addChangeHistoryElement(componentObject, componentObjectElement);
+// componentObjectElement.addContent(chgHistoryElement);
+
+
+ return componentObjectElement;
+ }
+
+
+
+// ##############################################################################
+//
+// Configuration Object Creation Methods
+//
+// ##############################################################################
+
+
+ /**
+ * This method will create a Host configuration object from an XML element
+ * that represents a Host.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the Host configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public Host createHost(Element element, ConfigurationID configID,
ConfigurationObjectEditor editor, String name) throws
InvalidConfigurationElementException{
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+
+ if (!element.getName().equals(XMLConfig_ElementNames.Configuration.Host.ELEMENT))
{
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0032,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0032, element.getName()),
element);
+ }
+ if (name == null) {
+ name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Host.Attributes.NAME);
+ }
+
+ Host host = editor.createHost(configID, name);
+
+// Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+
+ host = (Host) setDateHistory(host, element, editor);
+
+// if (propertiesElement != null) {
+ // now we add the system properties to the configuration object
+ host = (Host)addProperties(element, host, editor);
+
+// return host;
+// }
+
+ return host;
+ }
+
+ //
+ /**
+ * This method is used to create a ResourceDescriptor JDOM Element from a
+ * ServiceComponentDefn object.
+ *
+ * @param defn the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+// public Element createResourcePoolElement(ResourceDescriptor resource) {
+// Assertion.isNotNull(resource);
+//
+// Element resourceElement =
createComponentObjectElement(XMLConfig_ElementNames.ResourcePools.ResourcePool.ELEMENT,
resource);
+// return resourceElement;
+// }
+
+
+// public Element createResourcePoolsElement() {
+// return new Element(XMLConfig_ElementNames.ResourcePools.ELEMENT);
+// }
+
+ public Element createAuthenticationProviderElement() {
+ return new
Element(XMLConfig_ElementNames.Configuration.AuthenticationProviders.ELEMENT);
+ }
+
+
+
+ /**
+ * This method will create a Resource configuration object from an XML element
+ * that represents a Resource.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the SharedResource configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+// public ResourceDescriptor createResourcePool(Element element, ConfigurationID
configID, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
+// Assertion.isNotNull(element);
+// Assertion.isNotNull(editor);
+//
+// if
(!element.getName().equals(XMLConfig_ElementNames.ResourcePools.ResourcePool.ELEMENT)) {
+// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0033,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0033, element.getName()),
element);
+// }
+//
+// String name =
element.getAttributeValue(XMLConfig_ElementNames.ResourcePools.ResourcePool.Attributes.NAME);
+//
+// checkElementValue(name, null, ErrorMessageKeys.CONFIG_ERR_0053);
+//
+// String type =
element.getAttributeValue(XMLConfig_ElementNames.ResourcePools.ResourcePool.Attributes.COMPONENT_TYPE);
+//
+// checkElementValue(type, name, ErrorMessageKeys.CONFIG_ERR_0054);
+//
+// ComponentTypeID id = new ComponentTypeID(type);
+//
+// // create the descriptor used to get the resource
+// ResourceDescriptor descriptor = editor.createResourceDescriptor(configID, id,
name);
+//
+// Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+//
+// descriptor = (ResourceDescriptor) setDateHistory(descriptor, element, editor);
+//
+// if (propertiesElement != null) {
+// // now we add the system properties to the configuration object
+// descriptor = (ResourceDescriptor)addProperties(propertiesElement,
descriptor, editor);
+//
+// }
+//
+//
+// return descriptor;
+// }
+
+ /**
+ * This method will create a Resource configuration object from an XML element
+ * that represents a Resource.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the SharedResource configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public AuthenticationProvider createAuthenticationProvider(Element element,
ConfigurationID configID, ConfigurationObjectEditor editor) throws
InvalidConfigurationElementException{
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+
+ if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.AuthenticationProviders.Provider.ELEMENT))
{
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0033,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0033, element.getName()),
element);
+ }
+
+ String name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.AuthenticationProviders.Provider.Attributes.NAME);
+
+ checkElementValue(name, null, ErrorMessageKeys.CONFIG_ERR_0053);
+
+ String type =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.AuthenticationProviders.Provider.Attributes.COMPONENT_TYPE);
+
+ checkElementValue(type, name, ErrorMessageKeys.CONFIG_ERR_0054);
+
+ ComponentTypeID id = new ComponentTypeID(type);
+
+ // create the descriptor used to get the resource
+ AuthenticationProvider authProvider =
editor.createAuthenticationProviderComponent(configID, id, name);
+
+ Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+
+ authProvider = (AuthenticationProvider) setDateHistory(authProvider, element,
editor);
+
+ if (propertiesElement != null) {
+ // now we add the system properties to the configuration object
+ authProvider = (AuthenticationProvider)addProperties(propertiesElement,
authProvider, editor);
+
+ }
+
+
+ return authProvider;
+ }
+
+
+ //
+ /**
+ * This method is used to create a ServiceComponentDefn JDOM Element from a
+ * ServiceComponentDefn object.
+ *
+ * @param defn the Object to be converted to a JDOM XML Element
+ * @return a JDOM XML Element
+ */
+ public Element createSharedResourceElement(SharedResource resource) {
+ Assertion.isNotNull(resource);
+
+ Element resourceElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.Resources.Resource.ELEMENT,
resource, true);
+ return resourceElement;
+ }
+
+
+ /**
+ * This method will create a Resource configuration object from an XML element
+ * that represents a Resource.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the SharedResource configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public SharedResource createSharedResource(Element element, ConfigurationObjectEditor
editor) throws InvalidConfigurationElementException{
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+
+ if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.Resources.Resource.ELEMENT))
{
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0034,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0034, element.getName()),
element);
+ }
+
+ String name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Resources.Resource.Attributes.NAME);
+
+ checkElementValue(name, null, ErrorMessageKeys.CONFIG_ERR_0055);
+
+ String type =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Resources.Resource.Attributes.COMPONENT_TYPE);
+
+ checkElementValue(type, name, ErrorMessageKeys.CONFIG_ERR_0056);
+
+ ComponentTypeID id = new ComponentTypeID(type);
+
+ // create the descriptor used to get the resource
+ SharedResource descriptor = editor.createSharedResource(
+ id,
+ name);
+
+
+ Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+
+ descriptor = (SharedResource) setDateHistory(descriptor, element, editor);
+
+ if (propertiesElement != null) {
+ // now we add the system properties to the configuration object
+ descriptor = (SharedResource)addProperties(propertiesElement, descriptor,
editor);
+ }
+
+ return descriptor;
+ }
+
+ public Element createSharedResourcesElement() {
+ return new Element(XMLConfig_ElementNames.Configuration.Resources.ELEMENT);
+ }
+
+ /**
+ * This method will create a ComponentType configuration object from an XML element
+ * that represents a ComponentType.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the ComponentType configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public ComponentType createComponentType(Element element, ConfigurationObjectEditor
editor, String name, boolean maintainParentID) throws
InvalidConfigurationElementException{
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+
+ if
(!element.getName().equals(XMLConfig_ElementNames.ComponentTypes.ComponentType.ELEMENT))
{
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0035,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0035, element.getName()),
element);
+ }
+
+ // retreive the attributes of this ComponentType from the JDOM element
+ String parentType =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.PARENT_COMPONENT_TYPE);
+ String superType =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE);
+ String componentTypeCode =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE);
+ String deployable =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE);
+ String monitorable =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE);
+ String description =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.DESCRIPTION);
+
+
+
+ // convert them into their proper data types
+ int typeCode = Integer.parseInt(componentTypeCode);
+
+ if (! BasicUtil.isValdComponentTypeCode(typeCode)) {
+ throw new RuntimeException("File error2, invalid component type code "
+ componentTypeCode + " for " + name + " super " + superType);
+ }
+
+ // we will use the passed in name unless it is null...
+ if (name == null) {
+ name =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.NAME);
+ }
+
+ ComponentTypeID parentTypeID = null;
+ ComponentTypeID superTypeID = null;
+
+ if (parentType != null && parentType.length() > 0) {
+ parentTypeID = new ComponentTypeID(parentType);
+ }
+
+ if (superType !=null && superType.length() > 0) {
+ superTypeID = new ComponentTypeID(superType);
+ }
+
+
+ boolean isDeployable = (Boolean.valueOf(deployable)).booleanValue();
+ boolean isMonitorable = (Boolean.valueOf(monitorable)).booleanValue();
+
+ // create the ComponentTypeObject
+ BasicComponentType type = (BasicComponentType)
editor.createComponentType(typeCode, name, parentTypeID, superTypeID, isDeployable,
isMonitorable);
+
+
+ if (description != null && description.length() > 0) {
+ type.setDescription(description);
+ }
+ ComponentType t = setDateHistory(type, element, editor);
+
+
+ // get the ComponentTypeDefn sub-Elements of this ComponentType
+ // and create them also.
+ List componentTypeDefnElements =
element.getChildren(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
+
+ if (componentTypeDefnElements == null || componentTypeDefnElements.size() == 0)
{
+ componentTypeDefnElements =
element.getChildren(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT);
+ return addPropertyDefns(componentTypeDefnElements, t, editor);
+ }
+
+ return addComponentTypeDefns(componentTypeDefnElements, t, editor);
+
+ }
+
+ public ComponentType loadComponentType(Element rootElement) throws
InvalidConfigurationElementException {
+ return createComponentType(rootElement, new BasicConfigurationObjectEditor(), null,
true);
+ }
+
+ /**
+ * This method will create a ProductType configuration object from an XML element
+ * that represents a ProductType.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @param componentTypeMap this is a map of ComponentTypeID--->ComponentType
+ * it must contain all of the Component types that the ProductType
+ * that is represented by the passed in XML element references.
+ * @return the ProductType configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+// public ProductType createProductType(Element element, ConfigurationObjectEditor
editor, Map componentTypeMap, String name)throws InvalidConfigurationElementException{
+// Assertion.isNotNull(element);
+// Assertion.isNotNull(editor);
+//
+// if
(!element.getName().equals(XMLConfig_ElementNames.ProductTypes.ProductType.ELEMENT)) {
+// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0036,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0036, element.getName()),
element);
+// }
+//
+// // retreive the attributes of this ComponentType from the JDOM element
+// String deployable =
element.getAttributeValue(XMLConfig_ElementNames.ProductTypes.ProductType.Attributes.DEPLOYABLE);
+//// String monitorable =
element.getAttributeValue(XMLConfig_ElementNames.ProductTypes.ProductType.Attributes.MONITORABLE);
+//
+// // we will use the passed in name unless it is null...
+// if (name == null) {
+// name =
element.getAttributeValue(XMLConfig_ElementNames.ProductTypes.ProductType.Attributes.NAME);
+// }
+//
+// boolean isDeployable = (Boolean.valueOf(deployable)).booleanValue();
+// // boolean isMonitorable = (Boolean.valueOf(monitorable)).booleanValue();
+//
+// List componentTypeIDs =
element.getChildren(XMLConfig_ElementNames.ComponentTypeID.ELEMENT);
+// List componentTypes = new ArrayList();
+// Iterator iter = componentTypeIDs.iterator();
+// while (iter.hasNext()) {
+// Element componentTypeIDElement = (Element)iter.next();
+// String componentTypeIDName =
componentTypeIDElement.getAttributeValue(XMLConfig_ElementNames.ComponentTypeID.Attributes.NAME);
+// ComponentTypeID componentTypeID = new
ComponentTypeID(componentTypeIDName);
+// ComponentType componentType =
(ComponentType)componentTypeMap.get(componentTypeID);
+// if (componentType == null) {
+// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0037,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0037, new Object[]
{componentTypeID, name}), element);
+// }
+// componentTypes.add(componentType);
+// }
+//
+// // create the ComponentTypeObject
+// ProductType type = editor.createProductType(name, componentTypes, isDeployable,
false);
+//
+// return type;
+//// // get the ComponentTypeDefn sub-Elements of this ComponentType
+//// // and create them also.
+//// Collection componentTypeDefnElements =
element.getChildren(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
+////
+//// type = (ProductType) setDateHistory(type, element, editor);
+////
+//// return (ProductType)addComponentTypeDefns(componentTypeDefnElements, type,
editor);
+// }
+
+ /**
+ * This method will create a Configuration configuration object from an XML element
+ * that represents a Configuration.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the Configuration configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public Configuration createConfiguration(Element element, ConfigurationObjectEditor
editor, String name) throws InvalidConfigurationElementException{
+
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+
+ if (!element.getName().equals(XMLConfig_ElementNames.Configuration.ELEMENT)) {
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0038,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0038, element.getName()),
element);
+ }
+
+ if (name==null) {
+ name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Attributes.NAME);
+ }
+
+ Configuration config = editor.createConfiguration(name);
+
+ config = (Configuration) setDateHistory(config, element, editor);
+
+ config = (Configuration)addProperties(element, config, editor);
+
+ return config;
+ }
+
+ /**
+ * This method will create a LogConfiguration configuration object from an XML
element
+ * that represents a LogConfiguration.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the LogConfiguration configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+// public LogConfiguration createLogConfiguration(Element element) throws
InvalidConfigurationElementException{
+// Assertion.isNotNull(element);
+//
+// if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.LogConfiguration.ELEMENT))
{
+// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0039,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0039, element.getName()),
element);
+// }
+//
+// Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+// Properties properties = new Properties();
+//
+//
+// List props =
propertiesElement.getChildren(XMLConfig_ElementNames.Properties.Property.ELEMENT);
+// Iterator iterator = props.iterator();
+// while (iterator.hasNext()) {
+// Element propertyElement = (Element)iterator.next();
+// String propertyName =
propertyElement.getAttributeValue(XMLConfig_ElementNames.Properties.Property.Attributes.NAME);
+// String propertyValue = propertyElement.getText();
+// properties.setProperty(propertyName, propertyValue);
+// }
+//
+// LogConfiguration config = null;
+//
+// try {
+// config = BasicLogConfiguration.createLogConfiguration(properties);
+// }catch(LogConfigurationException e) {
+// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0040,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0040,e.getMessage()), element);
+//
+// }
+//
+// return config;
+//
+// }
+
+ public Element createConnectorBindingElement(ConnectorBinding connector, boolean
isExportConfig) {
+
+ Assertion.isNotNull(connector);
+
+ Element connectorElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.ELEMENT,
connector, true);
+
+
connectorElement.setAttribute(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.Attributes.ROUTING_UUID,
connector.getRoutingUUID());
+
+
+ return connectorElement;
+
+ }
+
+
+ public ConnectorBinding createConnectorBinding(ConfigurationID configurationID,
Element element, ConfigurationObjectEditor editor, String name, boolean
isImportConfig)throws InvalidConfigurationElementException {
+
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+
+ if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.ELEMENT))
{
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0041,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0041,element.getName()),
element);
+ }
+
+ if (name==null) {
+ name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.Attributes.NAME);
+ }
+
+ String componentType =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.Attributes.COMPONENT_TYPE);
+
+ checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0057);
+
+ ComponentTypeID id = new ComponentTypeID(componentType);
+
+//
element.getAttributeValue(XMLConfig_ElementNames.ConnectorComponents.ConnectorComponent.Attributes.QUEUED_SERVICE);
+
+ String routingUUID = null;
+ // vah - 09-24-2003
+ // when importing a configuration use the routing uuid,
+ // otherwise do not use it (which will cause the routingUUID to be regenerated)
+ // This is done to help ensure there are no duplicate UUIDs
+ if (isImportConfig) {
+ routingUUID =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.Attributes.ROUTING_UUID);
+ }
+
+ ConnectorBinding defn = null;
+ defn = editor.createConnectorComponent(configurationID, id, name, routingUUID);
+
+ defn = (ConnectorBinding) setDateHistory(defn, element, editor);
+
+ // add the properties to this ComponentObject...
+ Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+ if (propertiesElement != null) {
+ // now we add the system properties to the configuration object
+ return (ConnectorBinding)addProperties(propertiesElement, defn, editor);
+ }
+
+ return defn;
+ }
+
+ public ConnectorBinding loadConnectorBinding(Element rootElement) throws
InvalidConfigurationElementException {
+ return createConnectorBinding(Configuration.NEXT_STARTUP_ID, rootElement, new
BasicConfigurationObjectEditor(), null, false);
+ }
+
+ /**
+ * This method will create a ServiceComponentDefn configuration object from an XML
element
+ * that represents a ServiceComponentDefn.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the ServiceComponentDefn configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public ComponentDefn createServiceComponentDefn(Element element, Configuration
config, ConfigurationObjectEditor editor, String name) throws
InvalidConfigurationElementException{
+ ConfigurationID configID = null;
+ if (config != null) {
+ configID = (ConfigurationID) config.getID();
+ }
+ return createServiceComponentDefn(element, configID, editor, name);
+
+ }
+
+ public ComponentDefn createServiceComponentDefn(Element element, ConfigurationID
configID, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException {
+
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+ Assertion.isNotNull(configID);
+
+ if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.Services.Service.ELEMENT))
{
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0042,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0042,element.getName()),
element);
+ }
+
+ if (name==null) {
+ name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Services.Service.Attributes.NAME);
+ }
+
+ String componentType =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Services.Service.Attributes.COMPONENT_TYPE);
+
+ checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0058);
+
+ ComponentTypeID id = new ComponentTypeID(componentType);
+
+//
element.getAttributeValue(XMLConfig_ElementNames.Configuration.ServiceComponentDefns.ServiceComponentDefn.Attributes.QUEUED_SERVICE);
+
+ String routingUUID =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Services.Service.Attributes.ROUTING_UUID);
+
+ ComponentDefn defn = null;
+ boolean isResourcePool = isResourcePool(componentType);
+
+ if (configID == null) {
+/*
+ if (!isResourcePool) {
+ if (routingUUID == null){
+ //allow the object editor to generate a UUID
+ defn = (ComponentDefn) editor.createServiceComponentDefn(id, name);
+ } else {
+ //use the UUID specified in the XML file
+ defn = (ComponentDefn) editor.createServiceComponentDefn(id, name,
routingUUID);
+ }
+
+ editor.setEnabled((ServiceComponentDefn) defn, isEnabled);
+ } else {
+ defn = editor.createResourceDescriptor(id, name);
+
+
+ }
+*/
+ }else {
+ if (!isResourcePool) {
+
+ if (routingUUID == null){
+ //allow the object editor to generate a UUID
+ defn = editor.createServiceComponentDefn(configID, id, name);
+ } else {
+ //use the UUID specified in the XML file
+ defn = editor.createServiceComponentDefn(configID, id, name,
routingUUID);
+ }
+
+ }
+// else {
+//
+// defn = editor.createResourceDescriptor(configID, id, name);
+//
+// }
+
+ }
+
+ defn = (ComponentDefn) setDateHistory(defn, element, editor);
+
+ // add the properties to this ComponentObject...
+ Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+ if (propertiesElement != null) {
+ // now we add the system properties to the configuration object
+ return (ComponentDefn)addProperties(propertiesElement, defn, editor);
+ }
+
+ return defn;
+
+ }
+
+ private boolean isResourcePool(String componentTypeName) {
+ boolean result = false;
+
+ if (componentTypeName.equals(SharedResource.MISC_COMPONENT_TYPE_NAME) ) {
+ return true;
+ }
+
+
+ return result;
+
+ }
+
+ /**
+ * This method will create a ProductServiceConfig configuration object from an XML
element
+ * that represents a ProductServiceConfig.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the ProductServiceConfig configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+// public ProductServiceConfig createProductServiceConfig(Element element,
ConfigurationID configID, ConfigurationObjectEditor editor, String name)throws
InvalidConfigurationElementException {
+// Assertion.isNotNull(element);
+// Assertion.isNotNull(editor);
+// Assertion.isNotNull(configID);
+//
+// if
(!element.getName().equals(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.ELEMENT))
{
+// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0043,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0043,element.getName()),
element);
+// }
+//
+// if (name==null) {
+// name =
element.getAttributeValue(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.Attributes.NAME);
+// }
+//
+// String componentType =
element.getAttributeValue(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.Attributes.COMPONENT_TYPE);
+// checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0059);
+//
+//
+// // ConfigurationID configID = (ConfigurationID)config.getID();
+// ProductTypeID id = new ProductTypeID(componentType);
+//
+//
+// // ConfigurationID configID = (ConfigurationID)config.getID();
+//
+// // this new editor is used only as a way to create a product service config
+// // the passed in editor is then used to add the PSC to the configuration
+// // as passed in.
+// // we dont want to add the actions again to the passed in editor.
+// ProductServiceConfig productServiceConfig =
editor.createProductServiceConfig(configID, id, name);
+//
+// Collection serviceComponentDefnIDs =
element.getChildren(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.ELEMENT);
+//
+// if
(id.getFullName().equals(MetaMatrixProductVersion.CONNECTOR_PRODUCT_TYPE_NAME)) {
+// Iterator iterator = serviceComponentDefnIDs.iterator();
+// while (iterator.hasNext()) {
+// Element serviceComponentDefnIDElement = (Element)iterator.next();
+// String serviceComponentDefnName =
serviceComponentDefnIDElement.getAttributeValue(XMLConfig_ElementNames.ID.Attributes.NAME);
+//
+// String enabled =
serviceComponentDefnIDElement.getAttributeValue(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.Attributes.IS_ENABLED);
+//
+// if (enabled == null) {
+// enabled = Boolean.TRUE.toString();
+// }
+//
+// ConnectorBindingID serviceComponentDefnID = new
ConnectorBindingID(configID, serviceComponentDefnName);
+// productServiceConfig =
editor.addServiceComponentDefn(productServiceConfig, serviceComponentDefnID);
+// editor.setEnabled(serviceComponentDefnID, productServiceConfig,
Boolean.valueOf(enabled).booleanValue());
+//
+// }
+//
+//
+// } else {
+//
+// Iterator iterator = serviceComponentDefnIDs.iterator();
+// while (iterator.hasNext()) {
+// Element serviceComponentDefnIDElement = (Element)iterator.next();
+// String serviceComponentDefnName =
serviceComponentDefnIDElement.getAttributeValue(XMLConfig_ElementNames.ID.Attributes.NAME);
+//
+// String enabled =
serviceComponentDefnIDElement.getAttributeValue(XMLConfig_ElementNames.ProductServiceConfigs.ProductServiceConfig.Service.Attributes.IS_ENABLED);
+//
+// if (enabled == null) {
+// enabled = Boolean.TRUE.toString();
+// }
+//
+// ServiceComponentDefnID serviceComponentDefnID = new
ServiceComponentDefnID(configID, serviceComponentDefnName);
+// productServiceConfig =
editor.addServiceComponentDefn(productServiceConfig, serviceComponentDefnID);
+//
+// editor.setEnabled(serviceComponentDefnID, productServiceConfig,
Boolean.valueOf(enabled).booleanValue());
+//
+// }
+//
+// }
+//
+// productServiceConfig = (ProductServiceConfig)
setDateHistory(productServiceConfig, element, editor);
+//
+// // add the properties to this ComponentObject...
+// Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+// if (propertiesElement != null) {
+// // now we add the system properties to the configuration object
+// productServiceConfig =
(ProductServiceConfig)addProperties(propertiesElement, productServiceConfig, editor);
+// return productServiceConfig;
+// }
+//
+// return productServiceConfig;
+// }
+
+
+
+ public DeployedComponent createDeployedServiceComponent(Element element,
+ ConfigurationID configID,
+ HostID hostID,
+ VMComponentDefnID vmID,
+ Map componentTypeMap,
+ ConfigurationObjectEditor editor)
+ throws
InvalidConfigurationElementException{
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+ Assertion.isNotNull(configID);
+ Assertion.isNotNull(hostID);
+ Assertion.isNotNull(vmID);
+
+ DeployedComponent component;
+
+ if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.DeployedService.ELEMENT))
{
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()),
element);
+ }
+
+ String name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedService.Attributes.NAME);
+ checkElementValue(name, "NAME", ErrorMessageKeys.CONFIG_ERR_0048);
//$NON-NLS-1$
+
+ String componentTypeIDString =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedService.Attributes.COMPONENT_TYPE);
+// String serviceComponentDefnIDString =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedComponent.Attributes.SERVICE_COMPONENT_DEFN_ID);
+
+ checkElementValue(componentTypeIDString, name,
ErrorMessageKeys.CONFIG_ERR_0049);
+// checkElementValue(serviceComponentDefnIDString, name,
ErrorMessageKeys.CONFIG_ERR_0049);
+
+
+ ComponentType type = null;
+ Iterator it = componentTypeMap.keySet().iterator();
+ while (it.hasNext() ) {
+ ComponentTypeID id = (ComponentTypeID) it.next();
+ if (id.getFullName().equals(componentTypeIDString)) {
+ type = (ComponentType) componentTypeMap.get(id);
+ break;
+ }
+ }
+
+ if (type == null) {
+ throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[]
{componentTypeIDString, name} ), element);
+ }
+
+ ServiceComponentDefnID svcid = null;
+ if (type.getComponentTypeCode() == ComponentType.CONNECTOR_COMPONENT_TYPE_CODE)
{
+
+ svcid = new ConnectorBindingID(configID, name);
+
+ } else {
+
+
+ svcid = new ServiceComponentDefnID(configID, name);
+
+ }
+
+ component = editor.createDeployedServiceComponent(name, configID, hostID,vmID,
svcid, (ComponentTypeID) type.getID());
+
+
+ component = (DeployedComponent) setDateHistory(component, element, editor);
+
+
+ return component;
+ }
+
+
+// public DeployedComponent createDeployedVMComponentDefnx(Element element,
+// ConfigurationID configID,
+// HostID hostID,
+// // VMComponentDefnID vmID,
+// // ProductServiceConfigID
pscID,
+// ComponentTypeID typeID,
+// ConfigurationObjectEditor
editor)
+// throws
InvalidConfigurationElementException{
+// Assertion.isNotNull(element);
+// Assertion.isNotNull(editor);
+// Assertion.isNotNull(configID);
+// Assertion.isNotNull(hostID);
+// // Assertion.isNotNull(vmID);
+//
+// DeployedComponent component=null;
+//
+// if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.Process.ELEMENT)) {
+// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()),
element);
+// }
+//
+// String name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Process.Attributes.NAME);
+//// checkElementValue(name, "NAME",
ErrorMessageKeys.CONFIG_ERR_0048);
+//
+// String componentTypeIDString =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Process.Attributes.COMPONENT_TYPE);
+//
+// checkElementValue(componentTypeIDString, name,
ErrorMessageKeys.CONFIG_ERR_0049);
+//
+//
+//// ComponentType type = null;
+//// Iterator it = componentTypeMap.keySet().iterator();
+//// while (it.hasNext() ) {
+//// ComponentTypeID id = (ComponentTypeID) it.next();
+//// if (id.getFullName().equals(componentTypeIDString)) {
+//// type = (ComponentType) componentTypeMap.get(id);
+//// break;
+//// }
+//// }
+//
+//// if (type == null) {
+//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[]
{componentTypeIDString, name} ), element);
+//// }
+//
+// // VMComponentDefnID vmID = new VMComponentDefnID(configID, hostID,
name);
+/////// component = editor.createDeployedVMComponent(name, configID,
hostID, vmID, typeID);
+// // createDeployedServiceComponent(name, configID, hostID,vmID, svcid,
pscID, (ComponentTypeID) type.getID());
+//
+//
+// return component;
+// }
+
+
+
+ /**
+ * This method will create a DeployedComponent configuration object from an XML
element
+ * that represents a DeployedComponent.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @param serviceComponentDefnMap a map of
ServiceComponentDefnID-->ServiceComponentDefn
+ * this map must contain at the very least the ServiceComponentDefn that
+ * is the service definition of the deployed component that the XML element
+ * references. This is used if the deployedComponent is a Service. Otherwise
+ * it is ignored.
+ * @param vmComponentDefnMap a map of vmComponentDefnID-->vmComponentDefn
+ * this map must contain at the very least the vmComponentDefn that
+ * is the VM definition of the deployed component that the XML element
+ * references. This is used if the deployedComponent is a VM. Otherwise
+ * it is ignored.
+ * @return the DeployedComponent configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+// public DeployedComponent createDeployedComponent(Element element,
+// Configuration config, ConfigurationObjectEditor editor,
+// Map serviceComponentDefnMap, Map vmComponentDefnMap, Map componentTypeMap,
String name)
+// throws InvalidConfigurationElementException{
+// throw new UnsupportedOperationException("Method createDeployedComponent is
unsupported in 4.2"); //$NON-NLS-1$
+//
+////
+//// Assertion.isNotNull(element);
+//// Assertion.isNotNull(editor);
+//// Assertion.isNotNull(config);
+////
+//// DeployedComponent component;
+////
+//// if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.DeployedComponent.ELEMENT))
{
+//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()),
element);
+//// }
+////
+//// if (name == null) {
+//// name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedComponent.Attributes.NAME);
+//// }
+////
+//// String productServiceConfigIDString =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedComponent.Attributes.PRODUCT_SERVICE_CONFIG_ID);
+//// String vmComponentDefnIDString =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedComponent.Attributes.VM_COMPONENT_DEFN_ID);
+//// String serviceComponentDefnIDString =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedComponent.Attributes.SERVICE_COMPONENT_DEFN_ID);
+//// String HostIDString =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedComponent.Attributes.HOST_ID);
+////
+//// checkElementValue(vmComponentDefnIDString, name,
ErrorMessageKeys.CONFIG_ERR_0045);
+//// checkElementValue(HostIDString, name, ErrorMessageKeys.CONFIG_ERR_0046);
+////
+//// ConfigurationID configID = (ConfigurationID)config.getID();
+////
+//// HostID hostID = new HostID(HostIDString);
+//// VMComponentDefnID vmComponentDefnID = new VMComponentDefnID(configID,
vmComponentDefnIDString);
+////
+//// // this will check to see if this is actually a DeployedVMServiceComponent
+//// // these special deployed components dont have values for these ID's
+//// String componentTypeIDString =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.DeployedComponent.Attributes.COMPONENT_TYPE);
+////
+//// if (serviceComponentDefnIDString == null &&
productServiceConfigIDString == null) {
+//// VMComponentDefn defn =
(VMComponentDefn)vmComponentDefnMap.get(vmComponentDefnID);
+//// if (defn==null) {
+//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0047,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0047, new Object[] {name,
vmComponentDefnID} ), element);
+////
+//// }
+//// component = editor.createDeployedVMComponent(name, config, hostID,
defn);
+////
+//// // else this element represents a normal ServiceComponentDefn object
+//// }else {
+//// checkElementValue(productServiceConfigIDString, name,
ErrorMessageKeys.CONFIG_ERR_0048);
+//// checkElementValue(serviceComponentDefnIDString, name,
ErrorMessageKeys.CONFIG_ERR_0049);
+////
+//// ComponentType type = null;
+//// Iterator it = componentTypeMap.keySet().iterator();
+//// while (it.hasNext() ) {
+//// ComponentTypeID id = (ComponentTypeID) it.next();
+//// if (id.getFullName().equals(componentTypeIDString)) {
+//// type = (ComponentType) componentTypeMap.get(id);
+//// break;
+//// }
+//// }
+////
+//// if (type == null) {
+//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[]
{componentTypeIDString, serviceComponentDefnIDString} ), element);
+//// }
+//// ProductServiceConfigID productServiceConfigID = null;
+//// if (type instanceof ConnectorBindingType) {
+////
+//// productServiceConfigID = new ProductServiceConfigID(configID,
productServiceConfigIDString);
+////
+//// ConnectorBindingID bindingID = new ConnectorBindingID(configID,
serviceComponentDefnIDString);
+//// ConnectorBinding bdefn =
(ConnectorBinding)serviceComponentDefnMap.get(bindingID);
+////
+//// if (bdefn==null) {
+//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0051,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0051, new Object[] {name,
serviceComponentDefnIDString} ), element);
+//// }
+//// component = editor.createDeployedServiceComponent(name, config, hostID,
vmComponentDefnID, bdefn, productServiceConfigID);
+////
+//// } else {
+////
+//// productServiceConfigID = new ProductServiceConfigID(configID,
productServiceConfigIDString);
+////
+//// ServiceComponentDefnID serviceComponentDefnID = new
ServiceComponentDefnID(configID, serviceComponentDefnIDString);
+//// ServiceComponentDefn defn =
(ServiceComponentDefn)serviceComponentDefnMap.get(serviceComponentDefnID);
+////
+//// if (defn==null) {
+//// throw new
InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0052,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0052, new Object[] {name,
serviceComponentDefnIDString} ), element);
+//// }
+//// component = editor.createDeployedServiceComponent(name, config, hostID,
vmComponentDefnID, defn, productServiceConfigID);
+////
+//// }
+////
+//// }
+////
+//// component = (DeployedComponent) setDateHistory(component, element, editor);
+////
+//// Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+//// if (propertiesElement != null) {
+//// // now we add the system properties to the configuration object
+//// return (DeployedComponent)addProperties(propertiesElement, component,
editor);
+//// }
+////
+//// return component;
+// }
+
+ /**
+ * This method will create a VMComponentDefn configuration object from an XML element
+ * that represents a VMComponentDefn.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the VMComponentDefn configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public BasicVMComponentDefn createProcess(Element element, ConfigurationID configID,
HostID hostID, ConfigurationObjectEditor editor, String name) throws
InvalidConfigurationElementException{
+ Assertion.isNotNull(element);
+ Assertion.isNotNull(editor);
+ Assertion.isNotNull(configID);
+
+ if
(!element.getName().equals(XMLConfig_ElementNames.Configuration.Process.ELEMENT)) {
+ throw new InvalidConfigurationElementException("A Configuration object
cannot be created from a JDOM Element type: " + element.getName() + ".",
element); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (name==null) {
+ name =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Process.Attributes.NAME);
+ }
+
+ String componentType =
element.getAttributeValue(XMLConfig_ElementNames.Configuration.Process.Attributes.COMPONENT_TYPE);
+
+ checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0060);
+
+ ComponentTypeID id = new ComponentTypeID(componentType);
+
+ VMComponentDefn defn = editor.createVMComponentDefn(configID, hostID, id, name);
+
+ defn = (VMComponentDefn) setDateHistory(defn, element, editor);
+
+ // add the properties to this ComponentObject...
+ // Element propertiesElement =
element.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+ // if (propertiesElement != null) {
+ // now we add the system properties to the configuration object
+ defn = (VMComponentDefn)addProperties(element, defn, editor);
+ // }
+
+ return (BasicVMComponentDefn) defn;
+ }
+
+ /**
+ * This method is a helper method to create a PropertyDefinition object from
+ * an XML element that represents same.
+ *
+ * @param element the XML element that represents a PropertyDefinition object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public PropertyDefinition createPropertyDefinition(Element element) throws
InvalidConfigurationElementException{
+
+ if
(!element.getName().equals(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT))
{
+ throw new InvalidConfigurationElementException("A Configuration object
cannot be created from a JDOM Element type: " + element.getName() + ".",
element); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ String nameString =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.NAME);
+
+ String displayNameString =
element.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DISPLAY_NAME);
+
+
+ String shortDescriptionString = getAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.SHORT_DESCRIPTION,
+ PropertyDefinitionImpl.DEFAULT_SHORT_DESCRIPTION);
+
+ String defaultValueString = getAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DEFAULT_VALUE,
+ PropertyDefinitionImpl.DEFAULT_DEFAULT_VALUE);
+
+ String valueDelimiterString = getAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.VALUE_DELIMITER,
+ PropertyDefinitionImpl.DEFAULT_DELIMITER);
+
+
+ String multiplicityString = getAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.MULTIPLICITY,
+ PropertyDefinitionImpl.DEFAULT_MULTIPLICITY);
+ Multiplicity mult = null;
+ try {
+ mult = Multiplicity.getInstance(multiplicityString);
+ }catch(MultiplicityExpressionException e) {
+ throw new InvalidConfigurationElementException(e, "The
PropertyDefinition object: " + nameString + " could not be created because the
multiplicity definition: '" + multiplicityString + " is not a valid
multiplicity definition.", element); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+
+ String propertyTypeString = getAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.PROPERTY_TYPE,
+ PropertyDefinitionImpl.DEFAULT_TYPE.getDisplayName());
+ PropertyType type = PropertyType.getInstance(propertyTypeString);
+
+
+
+ boolean isConstrainedToAllowedValues = getAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_CONSTRAINED_TO_ALLOWED_VALUES,
+ PropertyDefinitionImpl.DEFAULT_IS_CONSTRAINED);
+
+ boolean isExpert = getAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_EXPERT,
+ PropertyDefinitionImpl.DEFAULT_IS_EXPERT);
+
+ boolean isHidden = getAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_HIDDEN,
+ PropertyDefinitionImpl.DEFAULT_IS_HIDDEN);
+
+ boolean isMasked = getAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MASKED,
+ PropertyDefinitionImpl.DEFAULT_IS_MASKED);
+
+ boolean isModifiable = getAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MODIFIABLE,
+ PropertyDefinitionImpl.DEFAULT_IS_MODIFIABLE);
+
+ boolean isPreferred = getAttributeBoolean(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_PREFERRED,
+ PropertyDefinitionImpl.DEFAULT_IS_PREFERRED);
+
+ String requiresRestart = getAttributeString(element,
+
XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.REQUIRES_RESTART,
+ PropertyDefinitionImpl.DEFAULT_REQUIRES_RESTART.toString());
+
+ RestartType restartType = null;
+
+ if ("true".equalsIgnoreCase(requiresRestart)) { //$NON-NLS-1$
+ restartType = RestartType.PROCESS;
+ } else {
+ restartType = RestartType.valueOf(requiresRestart.toUpperCase());
+ }
+
+
+ // we must retrieve all of the allowed values from the PropertyDefinition
+ // element
+ Collection allowedValuesElements =
element.getChildren(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.AllowedValue.ELEMENT);
+ ArrayList allowedValues = new ArrayList(allowedValuesElements.size());
+
+ Iterator iterator = allowedValuesElements.iterator();
+ while (iterator.hasNext()) {
+ Element allowedValueElement = (Element)iterator.next();
+ allowedValues.add(allowedValueElement.getText());
+ }
+
+ PropertyDefinitionImpl defn = new PropertyDefinitionImpl(nameString,
displayNameString, type,
+ mult, shortDescriptionString, defaultValueString,
+ allowedValues, valueDelimiterString,
+ isHidden, isPreferred, isExpert, isModifiable);
+
+ defn.setMasked(isMasked);
+ defn.setConstrainedToAllowedValues(isConstrainedToAllowedValues);
+ defn.setRequiresRestart(restartType);
+ return defn;
+
+ }
+
+
+
+ /**
+ * Get the value of the specified attribute from the on the specified element.
+ * If null, get the the default value.
+ * @param element
+ * @param attributeName name of Attribute to get
+ * @param defaultValue
+ * @return the attribute value, or defaultValue if it is null.
+ * @since 4.3
+ */
+ private static String getAttributeString(Element element, String attributeName,
String defaultValue) {
+ String stringValue = element.getAttributeValue(attributeName);
+ if (stringValue == null) {
+ return defaultValue;
+ }
+
+ return stringValue;
+ }
+ /**
+ * Get the value of the specified attribute from the on the specified element.
+ * If null, get the the default value.
+ * @param element
+ * @param attributeName name of Attribute to get
+ * @param defaultValue
+ * @return the attribute value, or defaultValue if it is null.
+ * @since 4.3
+ */
+ private static boolean getAttributeBoolean(Element element, String attributeName,
boolean defaultValue) {
+ String stringValue = element.getAttributeValue(attributeName);
+ if (stringValue == null) {
+ return defaultValue;
+ }
+
+ return Boolean.valueOf(stringValue).booleanValue();
+ }
+
+
+
+ /**
+ * This method will create a ComponentObject configuration object from an XML element
+ * that represents a ComponentObject.
+ *
+ * @param element the JDOM element to convert to a configuration object
+ * @param editor the editor to use to create the configuration object
+ * @param name the name of the returned configuration object. Note this
+ * name will override the name in the JDOM element. If the name parameter
+ * is null, the name of the object in the JDOM element will be used as
+ * the name of the object.
+ * @return the ComponentObject configuration object
+ * @throws InvalidConfigurationElementException if the element passed in
+ * or its XML structure do not conform to the XML structure specfied in
+ * the XMLConfig_ElementNames class.
+ */
+ public ComponentObject addProperties(Element propertiesElement, ComponentObject
object, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
+
+ if
(!propertiesElement.getName().equals(XMLConfig_ElementNames.Properties.ELEMENT)) {
+ propertiesElement =
propertiesElement.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
+ }
+
+ Properties props = null;
+ if (propertiesElement == null) {
+ props = new Properties();
+ }
+ else {
+ props = getProperties(propertiesElement);
+ }
+
+ object = editor.modifyProperties(object, props, ConfigurationObjectEditor.ADD);
+ return object;
+ }
+
+
+ private Properties getProperties(Element propertiesElement) {
+ Properties props = new Properties();
+
+ List properties =
propertiesElement.getChildren(XMLConfig_ElementNames.Properties.Property.ELEMENT);
+ Iterator iterator = properties.iterator();
+ while (iterator.hasNext()) {
+ Element propertyElement = (Element)iterator.next();
+ String propertyName =
propertyElement.getAttributeValue(XMLConfig_ElementNames.Properties.Property.Attributes.NAME);
+ String propertyValue = propertyElement.getText();
+
+ props.setProperty(propertyName, propertyValue);
+
+ }
+ return props;
+ }
+
+ /**
+ * This is a helper method for ProductTypes and ComponentTypes. this method
+ * will add a list of Component Type Definitions to a ComponentType using
+ * the passed in editor. The Collection of XML elements passed in are
+ * translated into ComponentTypeDefn objects and then set on the passed in
+ * ComponentType.
+ *
+ * @param componentTypeDefnElements a collection of JDOM elements that
+ * each represent a ComponentTypeDefn object.
+ * @param type the ComponentType object to add the ComponentTypeDefns to
+ * @param editor the editor to use to both create the ComponentTypeDefns
+ * and to set them on the passed in ComponentType.
+ * @return the ComponentType reference that now has the CompoenentTypeDefns
+ * set on it.
+ * @throws InvalidConfigurationElementException if the ComponentTypeDefn
+ * JDOM elements do not adhere to the proper XML structure as defined by the
+ * XMLConfig_ElementNames class.
+ */
+ private ComponentType addComponentTypeDefns(Collection componentTypeDefnElements,
ComponentType type, ConfigurationObjectEditor editor) throws
InvalidConfigurationElementException{
+ ArrayList componentTypeDefns = new ArrayList(componentTypeDefnElements.size());
+
+ Iterator iterator = componentTypeDefnElements.iterator();
+ while (iterator.hasNext()) {
+ Element componentTypeDefnElement = (Element)iterator.next();
+ Element propertyDefinitionElement =
componentTypeDefnElement.getChild(XMLConfig_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT);
+ PropertyDefinition propDefn =
createPropertyDefinition(propertyDefinitionElement);
+ componentTypeDefns.add(editor.createComponentTypeDefn(type, propDefn,
false));
+ }
+ return editor.setComponentTypeDefinitions(type, componentTypeDefns);
+ }
+
+ private ComponentType addPropertyDefns(Collection propertyDefnElements, ComponentType
type, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
+ ArrayList componentTypeDefns = new ArrayList(propertyDefnElements.size());
+
+ Iterator iterator = propertyDefnElements.iterator();
+ while (iterator.hasNext()) {
+ Element propertyDefinitionElement = (Element)iterator.next();
+ PropertyDefinition propDefn =
createPropertyDefinition(propertyDefinitionElement);
+ componentTypeDefns.add(editor.createComponentTypeDefn(type, propDefn,
false));
+ }
+ return editor.setComponentTypeDefinitions(type, componentTypeDefns);
+ }
+
+ public void orderComponentTypeElementList(List componentTypeElements) {
+ ComponentTypeElementComparator comparator = new
ComponentTypeElementComparator();
+ Collections.sort(componentTypeElements, comparator);
+ }
+
+
+ class ComponentTypeElementComparator implements Comparator{
+
+ /**
+ * This compare to will determine whether the ComponentType element
+ * represented by 'this' has a superComponentType that is the
+ * passed in ComponentType element representation to be compared to. if so, the
'this' element
+ * is considered to be greater than the passed in element. If it is
+ * determined that 'this' is the superCompoentType of the passed in
+ * object then 'greater than' will be returned. If it is determined
+ * that the two ComponentTypeObjects are unrelated, then equals is
+ * returned...Note that this is inconsistent with the equals() method.
+ */
+ public int compare(Object thisObject, Object thatObject) {
+ if (thisObject instanceof Element) {
+ Element thisElement = (Element)thisObject;
+ if (thatObject instanceof Element) {
+ Element thatElement = (Element)thatObject;
+ String thatSuperID = getElementSuperID(thatElement);
+ String thisSuperID = getElementSuperID(thisElement);
+ String thatID = getElementID(thatElement);
+ String thisID = getElementID(thisElement);
+
+ if(thisSuperID!=null && thisSuperID.equals(thatID)) {
+ return 1;
+ }else if(thatSuperID!=null && thatSuperID.equals(thisID)) {
+ return -1;
+ }else {
+ return 0;
+ }
+ }
+ }
+ return 0;
+ }
+
+
+ private String getElementSuperID(Element componentTypeElement) {
+ return
componentTypeElement.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE);
+ }
+
+ private String getElementID(Element componentTypeElement) {
+ return
componentTypeElement.getAttributeValue(XMLConfig_ElementNames.ComponentTypes.ComponentType.Attributes.NAME);
+ }
+ }
+
+ // helper class to check that an element is not null and length is greater than zero
+ // this should be used instead of Assertion when checking that
+ // component ID's exist
+ private void checkElementValue(String value, String name, String errorKey) throws
InvalidConfigurationElementException {
+ if (value == null || value.trim().length() > 0) {
+ if (name != null) {
+ if(value == null){
+ Assertion.isNotNull(value, CommonPlugin.Util.getString(errorKey,
name));
+ }
+ } else {
+ if(value == null){
+ Assertion.isNotNull(value, CommonPlugin.Util.getString(errorKey));
+ }
+ }
+
+ }
+
+ }
+
+
+
+// private static final String NOT_ASSIGNED = "NotAssigned";
+
+}
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperUtil.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperUtil.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperUtil.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -45,60 +45,10 @@
*/
static final String DEFAULT_USER_CREATED_BY = "Unknown"; //$NON-NLS-1$
-
- static final String APPLICATION_CREATED_BY = "ApplicationCreatedBy";
//$NON-NLS-1$
- static final String APPLICATION_VERSION_CREATED_BY = "ApplicationVersion";
//$NON-NLS-1$
- static final String USER_CREATED_BY = "UserCreatedBy"; //$NON-NLS-1$
- static final String CONFIGURATION_VERSION = "ConfigurationVersion";
//$NON-NLS-1$
- static final String METAMATRIX_SYSTEM_VERSION = "MetaMatrixSystemVersion";
//$NON-NLS-1$
- static final String TIME = "Time"; //$NON-NLS-1$
-
- // at 4.2 is where the configuration format changes, so anything prior
- // to this version will use the old (3.0) import/export utility
- static final String MM_CONFIG_4_2_VERSION = "4.2"; //$NON-NLS-1$
- static final String MM_CONFIG_3_0_VERSION = "3.0"; //$NON-NLS-1$
-
- static final double MM_LATEST_CONFIG_VERSION = 4.2;
-
-
- public static final boolean is42ConfigurationCompatible(Element root) throws
InvalidConfigurationElementException{
- Element headerElement = root.getChild(XMLElementNames.Header.ELEMENT);
- if (headerElement == null) {
- // If no header element found, assume it's pre vers 4.2
- return false;
- }
-
- Properties props = getHeaderProperties(headerElement);
-
- return is42ConfigurationCompatible(props);
-
- }
-
- public static final boolean is42ConfigurationCompatible(Properties props) throws
InvalidConfigurationElementException{
-
- String sVersion =
props.getProperty(XMLElementNames.Header.ConfigurationVersion.ELEMENT);
-
- if (sVersion == null) {
- return false;
- }
- try {
- double sv = Double.parseDouble(sVersion);
- if (sv >= MM_LATEST_CONFIG_VERSION) {
- return true;
- }
- return false;
-
- } catch (Throwable t) {
- return false;
- }
-
-
- }
-
public static final Properties getHeaderProperties(Element element) throws
InvalidConfigurationElementException{
Properties props=new Properties();
- if (!element.getName().equals(XMLElementNames.Header.ELEMENT)) {
+ if (!element.getName().equals(XMLConfig_ElementNames.Header.ELEMENT)) {
throw new InvalidConfigurationElementException("This is not the header
element: " + element.getName() + ".", element); //$NON-NLS-1$
//$NON-NLS-2$
}
@@ -113,7 +63,7 @@
public static final Element addHeaderElement(Element root, Properties properties) {
- XMLHelper xmlHelper = new XMLConfig_42_HelperImpl();
+ XMLHelperImpl xmlHelper = new XMLHelperImpl();
root.addContent(xmlHelper.createHeaderElement(createHeaderProperties(properties)));
@@ -130,8 +80,8 @@
if (props!=null) {
defaultProperties.putAll(props);
}
- defaultProperties.setProperty(ConfigurationPropertyNames.CONFIGURATION_VERSION,
ConfigurationPropertyNames.MM_CONFIG_4_2_VERSION);
-
defaultProperties.setProperty(ConfigurationPropertyNames.METAMATRIX_SYSTEM_VERSION,
ApplicationInfo.getInstance().getMajorReleaseNumber());
+ defaultProperties.setProperty(ConfigurationPropertyNames.CONFIGURATION_VERSION,
ConfigurationPropertyNames.CONFIG_CURR_VERSION);
+ defaultProperties.setProperty(ConfigurationPropertyNames.SYSTEM_VERSION,
ApplicationInfo.getInstance().getMajorReleaseNumber());
defaultProperties.setProperty(ConfigurationPropertyNames.TIME,
DateUtil.getCurrentDateAsString());
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/vdb/api/DEFReaderWriter.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/vdb/api/DEFReaderWriter.java 2009-04-10
18:43:00 UTC (rev 751)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/vdb/api/DEFReaderWriter.java 2009-04-11
02:42:44 UTC (rev 752)
@@ -41,8 +41,8 @@
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.config.util.InvalidConfigurationElementException;
-import com.metamatrix.common.config.xml.XMLConfig_42_HelperImpl;
-import com.metamatrix.common.config.xml.XMLElementNames;
+import com.metamatrix.common.config.xml.XMLConfig_ElementNames;
+import com.metamatrix.common.config.xml.XMLHelperImpl;
import com.metamatrix.common.xml.XMLReaderWriter;
import com.metamatrix.common.xml.XMLReaderWriterImpl;
import com.metamatrix.core.vdb.VDBStatus;
@@ -190,16 +190,16 @@
private void loadConnectorTypes (BasicVDBDefn vdbDefn, Element root) throws
IOException{
- Element components = root.getChild(XMLElementNames.ComponentTypes.ELEMENT);
+ Element components =
root.getChild(XMLConfig_ElementNames.ComponentTypes.ELEMENT);
if (components == null) {
return;
}
// TODO: eventually we need to get rid of this below class.
- XMLConfig_42_HelperImpl helper = new XMLConfig_42_HelperImpl();
+ XMLHelperImpl helper = new XMLHelperImpl();
try {
- List<Element> connectorTypes=
components.getChildren(XMLElementNames.ComponentTypes.ComponentType.ELEMENT);
+ List<Element> connectorTypes=
components.getChildren(XMLConfig_ElementNames.ComponentTypes.ComponentType.ELEMENT);
for(Element connectorTypeElement:connectorTypes) {
vdbDefn.addConnectorType(helper.loadComponentType(connectorTypeElement));
}
@@ -211,16 +211,16 @@
}
private void loadConnectorBindings (BasicVDBDefn vdbDefn, Element root) throws
IOException{
- Element components = root.getChild(XMLElementNames.ConnectorComponents.ELEMENT);
+ Element components =
root.getChild(XMLConfig_ElementNames.Configuration.ConnectorComponents.ELEMENT);
if (components == null) {
return;
}
// TODO: eventually we need to get rid of this below class.
- XMLConfig_42_HelperImpl helper = new XMLConfig_42_HelperImpl();
+ XMLHelperImpl helper = new XMLHelperImpl();
try {
- List<Element> connectorBindings=
components.getChildren(XMLElementNames.ConnectorComponents.ConnectorComponent.ELEMENT);
+ List<Element> connectorBindings=
components.getChildren(XMLConfig_ElementNames.Configuration.ConnectorComponents.ConnectorComponent.ELEMENT);
for(Element bindingElement:connectorBindings) {
vdbDefn.addConnectorBinding(helper.loadConnectorBinding(bindingElement));
}
@@ -257,7 +257,7 @@
}
// write the connector types elements
- Element componentTypesElement = new
Element(XMLElementNames.ComponentTypes.ELEMENT);
+ Element componentTypesElement = new
Element(XMLConfig_ElementNames.ComponentTypes.ELEMENT);
Collection<ComponentType> connectorTypes= def.getConnectorTypes().values();
for(ComponentType connectorType:connectorTypes) {
componentTypesElement.addContent(createConnectorType(connectorType));
@@ -265,7 +265,7 @@
rootElement.addContent(componentTypesElement);
// write the connector bindings elements
- Element connectorBindingsElement = new
Element(XMLElementNames.ConnectorComponents.ELEMENT);
+ Element connectorBindingsElement = new
Element(XMLConfig_ElementNames.Configuration.ConnectorComponents.ELEMENT);
Collection<ConnectorBinding> connectorBindings=
def.getConnectorBindings().values();
for(ConnectorBinding connectorBinding:connectorBindings) {
connectorBindingsElement.addContent(createConnectorBinding(connectorBinding));
@@ -329,13 +329,13 @@
private Element createConnectorType(com.metamatrix.common.config.api.ComponentType
connectorType) {
// TODO: eventually we need to get rid of this below class.
- XMLConfig_42_HelperImpl helper = new XMLConfig_42_HelperImpl();
+ XMLHelperImpl helper = new XMLHelperImpl();
return helper.createComponentTypeElement(connectorType);
}
private Element createConnectorBinding(ConnectorBinding binding) {
// TODO: eventually we need to get rid of this below class.
- XMLConfig_42_HelperImpl helper = new XMLConfig_42_HelperImpl();
+ XMLHelperImpl helper = new XMLHelperImpl();
return helper.createConnectorBindingElement(binding, false);
}
@@ -376,7 +376,7 @@
public static final String APPLICATION_CREATED_BY = "ApplicationCreatedBy";
//$NON-NLS-1$
public static final String APPLICATION_VERSION = "ApplicationVersion";
//$NON-NLS-1$
public static final String USER_CREATED_BY = "UserCreatedBy";
//$NON-NLS-1$
- public static final String SYSTEM_VERSION = "MetaMatrixSystemVersion";
//$NON-NLS-1$
+ public static final String SYSTEM_VERSION = "SystemVersion"; //$NON-NLS-1$
public static final String MODIFICATION_TIME = "Time"; //$NON-NLS-1$
}
Modified: branches/remove_psc/common-internal/src/test/resources/config-original.xml
===================================================================
--- branches/remove_psc/common-internal/src/test/resources/config-original.xml 2009-04-10
18:43:00 UTC (rev 751)
+++ branches/remove_psc/common-internal/src/test/resources/config-original.xml 2009-04-11
02:42:44 UTC (rev 752)
@@ -2,10 +2,10 @@
<ConfigurationDocument>
<Header>
<ApplicationCreatedBy>ConfigurationAdministration</ApplicationCreatedBy>
- <ApplicationVersionCreatedBy>4.2</ApplicationVersionCreatedBy>
+ <ApplicationVersionCreatedBy>6.0</ApplicationVersionCreatedBy>
<UserCreatedBy>Configuration</UserCreatedBy>
<ConfigurationVersion>4.2</ConfigurationVersion>
- <MetaMatrixSystemVersion>4.2</MetaMatrixSystemVersion>
+ <SystemVersion>6.0</SystemVersion>
<Time>2004-06-30T12:23:53.919-06:00</Time>
</Header>
<Configuration Name="Next Startup"
ComponentType="Configuration" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup">
@@ -75,12 +75,12 @@
<Property Name="vm.enabled">true</Property>
<Property
Name="vm.forced.shutdown.time">30</Property>
</Properties>
- <Service Name="MembershipService"
ComponentType="MembershipService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
- <Service Name="SessionService"
ComponentType="SessionService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
- <Service Name="AuthorizationService"
ComponentType="AuthorizationService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
- <Service Name="ConfigurationService"
ComponentType="ConfigurationService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
- <Service Name="QueryService"
ComponentType="QueryService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
- <Service Name="RuntimeMetadataService"
ComponentType="RuntimeMetadataService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
+ <DeployedService Name="MembershipService"
ComponentType="MembershipService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
+ <DeployedService Name="SessionService"
ComponentType="SessionService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
+ <DeployedService Name="AuthorizationService"
ComponentType="AuthorizationService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
+ <DeployedService Name="ConfigurationService"
ComponentType="ConfigurationService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
+ <DeployedService Name="QueryService"
ComponentType="QueryService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
+ <DeployedService Name="RuntimeMetadataService"
ComponentType="RuntimeMetadataService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
</Process>
</Host>
</Configuration>
Modified: branches/remove_psc/common-internal/src/test/resources/config.xml
===================================================================
--- branches/remove_psc/common-internal/src/test/resources/config.xml 2009-04-10 18:43:00
UTC (rev 751)
+++ branches/remove_psc/common-internal/src/test/resources/config.xml 2009-04-11 02:42:44
UTC (rev 752)
@@ -26,10 +26,10 @@
<ConfigurationDocument>
<Header>
<ApplicationCreatedBy>ConfigurationAdministration</ApplicationCreatedBy>
- <ApplicationVersionCreatedBy>4.2</ApplicationVersionCreatedBy>
+ <ApplicationVersionCreatedBy>6.0</ApplicationVersionCreatedBy>
<UserCreatedBy>Configuration</UserCreatedBy>
- <ConfigurationVersion>4.2</ConfigurationVersion>
- <MetaMatrixSystemVersion>4.2</MetaMatrixSystemVersion>
+ <ConfigurationVersion>6.0</ConfigurationVersion>
+ <SystemVersion>6.0</SystemVersion>
<Time>2004-06-30T12:23:53.919-06:00</Time>
</Header>
@@ -54,31 +54,7 @@
<Property Name="MaxPlanCacheSize">100</Property>
</Properties>
</Service>
- </Services>
-
- <ProductTypes>
- <ProductType Name="Connectors" ComponentTypeCode="3"
Deployable="false" Deprecated="false" Monitorable="false"
SuperComponentType="Product" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup">
- <ComponentTypeID Name="Oracle ANSI JDBC Connector"/>
- <ComponentTypeID Name="Oracle 8 JDBC Connector"/>
- <ComponentTypeID Name="DB2 JDBC Connector"/>
- <ComponentTypeID Name="Sybase ANSI JDBC Connector"/>
- <ComponentTypeID Name="Sybase 11 JDBC Connector"/>
- <ComponentTypeID Name="SQL Server JDBC Connector"/>
- <ComponentTypeID Name="JDBC Connector"/>
- <ComponentTypeID Name="MS Access Connector"/>
- <ComponentTypeID Name="JDBC ODBC Connector"/>
- <ComponentTypeID Name="Text File Connector"/>
- <ComponentTypeID Name="MySQL JDBC Connector"/>
- <ComponentTypeID Name="PostgreSQL JDBC Connector"/>
- <ComponentTypeID Name="Apache Derby Embedded Connector"/>
- <ComponentTypeID Name="Apache Derby Network Connector"/>
- <ComponentTypeID Name="Secure Data Source Connector"/>
- <ComponentTypeID Name="SOAP Connector"/>
- <ComponentTypeID Name="XML File Connector"/>
- <ComponentTypeID Name="XML HTTP Connector"/>
- </ProductType>
- </ProductTypes>
-
+ </Services>
<ComponentTypes>
<ComponentType Name="Service" ComponentTypeCode="1"
Deployable="false" Deprecated="false" Monitorable="false"
ParentComponentType="VM" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup">
<ComponentTypeDefn Deprecated="false">
Modified: branches/remove_psc/common-internal/src/test/resources/example.def
===================================================================
--- branches/remove_psc/common-internal/src/test/resources/example.def 2009-04-10 18:43:00
UTC (rev 751)
+++ branches/remove_psc/common-internal/src/test/resources/example.def 2009-04-11 02:42:44
UTC (rev 752)
@@ -5,7 +5,7 @@
<ApplicationCreatedBy>MetaMatrix Console</ApplicationCreatedBy>
<ApplicationVersion>5.5:2849</ApplicationVersion>
<UserCreatedBy>metamatrixadmin</UserCreatedBy>
- <MetaMatrixSystemVersion>5.5</MetaMatrixSystemVersion>
+ <SystemVersion>5.5</SystemVersion>
<Time>2007-10-18T11:01:41.622-06:00</Time>
</Header>
<VDBInfo>