Author: vhalbert(a)redhat.com
Date: 2009-04-13 12:46:55 -0400 (Mon, 13 Apr 2009)
New Revision: 764
Removed:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationObjectEditorHelper.java
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicComponentObject.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfigurationObjectEditor.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/model/ConfigurationModelContainerImpl.java
Log:
Teiid 323 - refactured, removing unused Config API classes: ProductType, ProductTypeID
and ConfigurationLock
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicComponentObject.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicComponentObject.java 2009-04-13
13:25:55 UTC (rev 763)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicComponentObject.java 2009-04-13
16:46:55 UTC (rev 764)
@@ -102,7 +102,7 @@
* @param properties the set of properties for this service; a reference to
* this Properties instance should <i>not</i> be maintained by the
caller
*/
- void setProperties(Properties properties){
+ public void setProperties(Properties properties){
Properties p = null;
if (properties != null) {
@@ -123,25 +123,25 @@
/**
* Add a name/value pair as a new property setting for the current
<code>Configuration</code>.
*/
- void addProperty(String name, String value) {
+ public void addProperty(String name, String value) {
properties.put(name, value);
}
/**
* Add a the newProperties to the current properties settings.
*/
- void addProperties(Properties newProperties) {
+ public void addProperties(Properties newProperties) {
properties.putAll(newProperties);
}
/**
* Remove a property setting based on the name
*/
- void removeProperty(String name) {
+ public void removeProperty(String name) {
properties.remove(name);
}
/**
* Remove the <code>Collection</code> of propertyNames from tthe current
properties settings.
*/
- void removeProperties(Collection propertyNames) {
+ public void removeProperties(Collection propertyNames) {
for (Iterator it = propertyNames.iterator(); it.hasNext(); ) {
removeProperty( (String) it.next() );
}
@@ -228,7 +228,7 @@
/**
* Helper method to enable building the property hierarchy for deployed Components
*/
- Properties getEditableProperties() {
+ public Properties getEditableProperties() {
return this.properties;
}
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfigurationObjectEditor.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfigurationObjectEditor.java 2009-04-13
13:25:55 UTC (rev 763)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfigurationObjectEditor.java 2009-04-13
16:46:55 UTC (rev 764)
@@ -2208,19 +2208,19 @@
}
public ComponentType setLastChangedHistory(ComponentType type, String lastChangedBy,
String lastChangedDate) {
- return ConfigurationObjectEditorHelper.setLastChangedHistory(type, lastChangedBy,
lastChangedDate);
+ return BasicUtil.setLastChangedHistory(type, lastChangedBy, lastChangedDate);
}
public ComponentType setCreationChangedHistory(ComponentType type, String createdBy,
String creationDate) {
- return ConfigurationObjectEditorHelper.setCreationChangedHistory(type, createdBy,
creationDate);
+ return BasicUtil.setCreationChangedHistory(type, createdBy, creationDate);
}
public ComponentObject setLastChangedHistory(ComponentObject defn, String
lastChangedBy, String lastChangedDate) {
- return ConfigurationObjectEditorHelper.setLastChangedHistory(defn, lastChangedBy,
lastChangedDate);
+ return BasicUtil.setLastChangedHistory(defn, lastChangedBy, lastChangedDate);
}
public ComponentObject setCreationChangedHistory(ComponentObject defn, String
createdBy, String creationDate) {
- return ConfigurationObjectEditorHelper.setCreationChangedHistory(defn, createdBy,
creationDate);
+ return BasicUtil.setCreationChangedHistory(defn, createdBy, creationDate);
}
@@ -2316,39 +2316,18 @@
// this should never happen except in development, no need to translate
throw new UnsupportedOperationException("Cannot call method
delete(ComponentObject, Configuration) to delete a configuration, call
delete(Configuration)."); //$NON-NLS-1$
}
+
+ BasicConfiguration basicConfig = (BasicConfiguration)
verifyTargetClass(configuration,BasicConfiguration.class);
- Configuration config = ConfigurationObjectEditorHelper.delete((ComponentObjectID)
target.getID(), configuration);
+ basicConfig.removeComponentObject( (ComponentObjectID) target.getID());
this.createDestroyAction(target.getID(), target);
- return config;
+ return basicConfig;
}
+
/**
- * Change the name of a previously defined PSC in the Next Startup config.
- * @param psc The psc whose name to change.
- * @param name The new name.
- * @return The PSC with its name changed.
- */
-// public ProductServiceConfig renamePSC(ProductServiceConfig psc, String name) throws
ConfigurationException {
-// if ( psc == null ) {
-// throw new
IllegalArgumentException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0089,
ProductServiceConfig.class.getName()));
-// }
-// BasicProductServiceConfig target = (BasicProductServiceConfig)
verifyTargetClass(psc,BasicProductServiceConfig.class);
-// ConfigurationID configID = target.getConfigurationID();
-//
-//// ProductServiceConfigID newID = new ProductServiceConfigID(configID, name);
-//// ComponentTypeID typeID = target.getComponentTypeID();
-// target = (BasicProductServiceConfig)
BasicUtil.createComponentDefn(ComponentDefn.PSC_COMPONENT_CODE, configID,
psc.getComponentTypeID(), name) ;
-//
-// createExchangeAction( target.getID(), ConfigurationModel.Attribute.NAME,
-// target.getName(), name );
-//
-//// new BasicProductServiceConfig(configID, newID, psc.getProductTypeID());
-// return target;
-// }
-
- /**
* Change the name of a previously defined VM in the Next Startup config.
* @param vm The VM whose name to change.
* @param name The new name.
@@ -2384,19 +2363,6 @@
return false;
}
- // since a component name must be unique within a configuration then
- // this simple method can validate an existance of a service defn.
-// public boolean doesComponentDefnExist(String name, Configuration config) {
-// Iterator iterator = config.getComponentDefns().values().iterator();
-// while (iterator.hasNext()) {
-// ComponentDefn comp = (ComponentDefn)iterator.next();
-// if (name.equalsIgnoreCase(comp.getName())) {
-// return true;
-// }
-// }
-// return false;
-// }
-
/**
* Sets the system next startup configuration
* @deprecated as of v 2.0 beta 1, use {@link #setNextStartupConfiguration}
@@ -2408,24 +2374,6 @@
/**
* Sets the system next startup configuration
*/
-/*
- public void setOperationalConfiguration(ConfigurationID configurationID) throws
ConfigurationException {
- this.createExchangeAction(configurationID,
ConfigurationModel.Attribute.CURRENT_CONFIGURATION, configurationID, configurationID);
- }
-*/
- /**
- * Sets the system startup configuration (This method will not be declared
- * in the public interface {@link ConfigurationObjectEditor}, since
- * the startup configuration should not be modifiable. But, this method
- * is needed by the JDBC service provider.)
- */
-// public void setStartupConfiguration(ConfigurationID configurationID) throws
ConfigurationException {
-// this.createExchangeAction(configurationID,
ConfigurationModel.Attribute.STARTUP_CONFIGURATION, configurationID, configurationID);
-// }
-
- /**
- * Sets the system next startup configuration
- */
public void setNextStartupConfiguration(ConfigurationID configurationID) throws
ConfigurationException {
this.createExchangeAction(configurationID,
ConfigurationModel.Attribute.NEXT_STARTUP_CONFIGURATION, configurationID,
configurationID);
}
@@ -2488,14 +2436,6 @@
return target;
}
-// public Configuration addConfigurationComponentDefn(Configuration t, ComponentDefn
defn ) {
-//
-// BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
-// target.addComponentDefn(defn);
-//
-// return target;
-// }
-
public Configuration setConfigurationDeployedComponents(Configuration t, Collection
deployedComponents) {
BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
@@ -2512,13 +2452,6 @@
return target;
}
-// public Configuration addConfigurationDeployedComponent(Configuration t,
DeployedComponent deployedComponent) {
-//
-// BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
-//
-// target.addDeployedComponent(deployedComponent);
-// return target;
-// }
public Configuration setConfigurationHostComponents(Configuration t, Collection
hostComponents) {
@@ -2536,14 +2469,7 @@
return target;
}
-// public Configuration addConfigurationHostComponent(Configuration t, Host host) {
-//
-// BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
-// target.addHost(host);
-// return target;
-// }
-
public Properties getEditableProperties(ComponentObject t) {
BasicComponentObject bco = (BasicComponentObject)
verifyTargetClass(t,BasicComponentObject.class);
return bco.getEditableProperties();
@@ -2592,34 +2518,6 @@
return newDefn;
}
-// public ConnectorBinding createConnectorComponent(Configuration configuration,
ComponentTypeID typeID, String componentName, ProductServiceConfigID pscID) {
-// if ( configuration == null ) {
-// throw new
IllegalArgumentException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0089,
Configuration.class.getName()));
-// }
-// if ( pscID == null ) {
-// throw new
IllegalArgumentException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0089,
ProductServiceConfigID.class.getName()));
-// }
-// ProductServiceConfig psc =
(ProductServiceConfig)configuration.getComponentDefn(pscID);
-// if (psc == null ) {
-// throw new
IllegalArgumentException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0089,
ProductServiceConfig.class.getName()));
-// }
-//
-// BasicConnectorBinding newServiceDefn = (BasicConnectorBinding)
-// createConnectorComponent((ConfigurationID) configuration.getID(), typeID,
componentName, null);
-//
-// // add the service to the psc so that this relationship is found in the
deployServiceDefn method
-// addServiceComponentDefn(psc, (ServiceComponentDefnID) newServiceDefn.getID());
-//
-// BasicConfiguration bc = (BasicConfiguration)
verifyTargetClass(configuration,BasicConfiguration.class);
-// bc.addComponentDefn(newServiceDefn);
-//
-// //automatically deploy the service anywhere that the PSC is already deployed
-// this.deployServiceDefn(bc,newServiceDefn,pscID);
-//
-// return newServiceDefn;
-// }
-
-
public ConnectorBinding createConnectorComponent(ConfigurationID configurationID,
ConnectorBinding original, String newName, String routingUUID) {
if (original == null ) {
@@ -2800,59 +2698,6 @@
}
-// HashSet deployedIDs = new HashSet();
-// for ( Iterator iter = targetConfig.getDeployedServiceForVM(serviceDefnID,
vm).iterator(); iter.hasNext(); ){
-// aDeployedComponent = (DeployedComponent)iter.next();
-// VMComponentDefnID aVMID = aDeployedComponent.getVMComponentDefnID();
-// if (aVMID != null && aVMID.equals(vmID)){
-// hostID = aDeployedComponent.getHostID();
-// // vmID = aDeployedComponent.getVMComponentDefnID();
-//
-//
-// DeployedComponentID id = new
DeployedComponentID(serviceDefnID.getName(), configID, hostID, vmID, serviceDefnID);
-// if (!deployedIDs.contains(id)){
-// deployedIDs.add(id);
-//
-// DeployedComponent deployComponent =
this.createDeployedServiceComponent(serviceDefnID.getName(), configuration, hostID, vmID,
basicService, aPscID);
-//// BasicDeployedComponent deployComponent = new
BasicDeployedComponent(id,
-////
configID,
-//// hostID,
-//// vmID,
-////
serviceDefnID,
-//// pscID,
-////
basicService.getComponentTypeID());
-////
-//// createCreationAction(id, deployComponent );
-//
-//// try {
-//// DeployedComponent newService = (DeployedComponent)
deployComponent.clone();
-//// targetConfig.addDeployedComponent(newService);
-// if (result == null){
-// result = new ArrayList();
-// }
-// result.add(deployComponent);
-//
-//
-// if (psc.getServiceComponentDefnIDs() == null) {
-// addServiceComponentDefn(psc, serviceDefnID);
-//
-// } else {
-// if (!psc.getServiceComponentDefnIDs().contains(serviceDefnID))
{
-// addServiceComponentDefn(psc, serviceDefnID);
-// }
-// }
-//
-//// } catch (CloneNotSupportedException e) {
-//// throw new
RuntimeException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0078,
-//// new Object[] {DeployedComponent.class.getName(),
e.getMessage()}));
-//// }
-// }
-// }
-// }
- //this will overwrite the service if it already is in the Configuration
- // targetConfig.addComponentDefn(basicService);
-
-
return deployComponent;
}
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-13
13:25:55 UTC (rev 763)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicUtil.java 2009-04-13
16:46:55 UTC (rev 764)
@@ -58,7 +58,7 @@
*/
public class BasicUtil {
- private static ConfigurationObjectEditor editor = new
BasicConfigurationObjectEditor();
+ private static BasicConfigurationObjectEditor editor = new
BasicConfigurationObjectEditor();
/**
@@ -354,6 +354,62 @@
}
return false;
}
+
+
+// ----------------------------------------------------------------------------------
+// M O D I F I C A T I O N M E T H O D S
+// ----------------------------------------------------------------------------------
+
+public static ComponentType setLastChangedHistory(ComponentType type, String
lastChangedBy, String lastChangedDate) {
+ Assertion.isNotNull(type);
+
+ BasicComponentType target = (BasicComponentType) type;
+
+ target.setLastChangedBy(lastChangedBy);
+ target.setLastChangedDate(lastChangedDate);
+
+ return target;
+
+}
+public static ComponentType setCreationChangedHistory(ComponentType type, String
createdBy, String creationDate) {
+ Assertion.isNotNull(type);
+
+ BasicComponentType target = (BasicComponentType) type;
+
+ target.setCreatedBy(createdBy);
+ target.setCreatedDate(creationDate);
+
+ return target;
+}
+
+
+public static ComponentObject setLastChangedHistory(ComponentObject defn, String
lastChangedBy, String lastChangedDate) {
+ Assertion.isNotNull(defn);
+
+ BasicComponentObject target = (BasicComponentObject) defn;
+
+ target.setLastChangedBy(lastChangedBy);
+
+ target.setLastChangedDate(lastChangedDate);
+
+ return target;
+
+}
+//public static boolean set = false;
+public static ComponentObject setCreationChangedHistory(ComponentObject defn, String
createdBy, String creationDate) {
+ Assertion.isNotNull(defn);
+
+ BasicComponentObject target = (BasicComponentObject) defn;
+
+ target.setCreatedBy(createdBy);
+ target.setCreatedDate(creationDate);
+
+
+ return target;
+
+}
+
+
}
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java 2009-04-13
13:25:55 UTC (rev 763)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java 2009-04-13
16:46:55 UTC (rev 764)
@@ -33,6 +33,7 @@
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.api.AuthenticationProvider;
+import com.metamatrix.common.config.api.ComponentObjectID;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeDefn;
import com.metamatrix.common.config.api.ComponentTypeID;
@@ -59,8 +60,6 @@
private BasicConfiguration configuration=null;
- private transient ConfigurationObjectEditorHelper editor = null;
-
private Map compTypes = Collections.synchronizedMap(new HashMap(45));
private Map resources = Collections.synchronizedMap(new HashMap(25));
@@ -85,13 +84,6 @@
this.configuration = (BasicConfiguration) config;
}
- protected ConfigurationObjectEditorHelper getEditor() {
- if (editor == null) {
- editor = new ConfigurationObjectEditorHelper();
- }
- return editor;
- }
-
public Configuration getConfiguration() {
return this.configuration;
}
@@ -463,9 +455,8 @@
if (configuration == null) {
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
+ configuration.addComponentDefn(scd);
- ConfigurationObjectEditorHelper.addConfigurationComponentDefn(configuration, scd);
-
} else if(obj instanceof DeployedComponent) {
DeployedComponent deployedComp = (DeployedComponent) obj;
@@ -473,7 +464,7 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
-
ConfigurationObjectEditorHelper.addConfigurationDeployedComponent(configuration,
deployedComp);
+ configuration.addDeployedComponent(deployedComp);
} else if (obj instanceof VMComponentDefn) {
VMComponentDefn vm = (VMComponentDefn) obj;
@@ -482,7 +473,7 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
- ConfigurationObjectEditorHelper.addConfigurationComponentDefn(configuration,
vm);
+ configuration.addComponentDefn(vm);
} else if (obj instanceof Host) {
Host host = (Host) obj;
@@ -490,7 +481,7 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
- ConfigurationObjectEditorHelper.addConfigurationHostComponent(configuration, host);
+ configuration.addHost(host);
// } else if (obj instanceof ProductServiceConfig) {
// ProductServiceConfig psc = (ProductServiceConfig) obj;
@@ -512,9 +503,9 @@
AuthenticationProvider rd = (AuthenticationProvider) obj;
- ConfigurationObjectEditorHelper.addConfigurationComponentDefn(configuration,
rd);
+ configuration.addComponentDefn(rd);
+
-
} else if (obj instanceof ResourceDescriptor) {
ResourceDescriptor rd = (ResourceDescriptor) obj;
@@ -523,7 +514,7 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
- ConfigurationObjectEditorHelper.addConfigurationComponentDefn(configuration, rd);
+ configuration.addComponentDefn(rd);
} else if (obj instanceof Configuration) {
@@ -533,10 +524,7 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0002,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0002));
}
-// } else if (obj instanceof ProductType) {
-// addProductType((ProductType) obj);
-
} else if (obj instanceof ComponentType) {
addComponentType((ComponentType) obj);
@@ -665,7 +653,7 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
- ConfigurationObjectEditorHelper.delete(defnID, configuration);
+ delete(defnID, configuration);
}
private void remove(VMComponentDefnID defnID) throws ConfigurationException {
@@ -674,7 +662,7 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
- ConfigurationObjectEditorHelper.delete(defnID, configuration);
+ delete(defnID, configuration);
}
private void remove(DeployedComponentID dcID) throws ConfigurationException {
@@ -683,7 +671,7 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
- ConfigurationObjectEditorHelper.delete(dcID, configuration);
+ delete(dcID, configuration);
}
private void remove(HostID hostID) throws ConfigurationException {
@@ -692,25 +680,16 @@
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
- ConfigurationObjectEditorHelper.delete(hostID, configuration);
+ delete(hostID, configuration);
}
-// private void remove(ProductServiceConfigID pscID) throws ConfigurationException {
-//
-// if (configuration == null) {
-// throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
-// }
-//
-// ConfigurationObjectEditorHelper.delete(pscID, configuration);
-// }
-
private void remove(ResourceDescriptorID rdID) throws ConfigurationException {
if (configuration == null) {
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
}
- ConfigurationObjectEditorHelper.delete(rdID, configuration);
+ delete(rdID, configuration);
}
@@ -725,5 +704,15 @@
return newConfig;
}
+
+ private Configuration delete( ComponentObjectID targetID, Configuration configuration )
throws ConfigurationException {
+ //System.out.println("<!><!><!><!>deleting " +
target + ", delete dependencies: " + deleteDependencies);
+ BasicConfiguration basicConfig = (BasicConfiguration) configuration;
+ basicConfig.removeComponentObject( targetID);
+
+ return basicConfig;
+ }
+
+
}
Deleted:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationObjectEditorHelper.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationObjectEditorHelper.java 2009-04-13
13:25:55 UTC (rev 763)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationObjectEditorHelper.java 2009-04-13
16:46:55 UTC (rev 764)
@@ -1,584 +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.model;
-
-import java.util.*;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.config.api.*;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.Assertion;
-
-
-/**
- * The ConfigurationObjectEditorHelper provides methods that do not deal with actions.
- *
- * This is new for the implementation of using configuration models
- */
-
-public class ConfigurationObjectEditorHelper {
-
- /**
- * The command to signify setting of an attribute.
- */
- public static final int SET = 0;
-
- /**
- * The command to signify addition of an attribute.
- */
- public static final int ADD = 1;
-
- /**
- * The command to signify removal of an attribute.
- */
- public static final int REMOVE = 2;
-
- //
----------------------------------------------------------------------------------
- // C R E A T E M E T H O D S
- //
----------------------------------------------------------------------------------
- public static Host createHost(Configuration config, String hostName ) throws
ConfigurationException {
- ArgCheck.isNotNull(hostName);
- ArgCheck.isNotNull(config);
-
- BasicHost bh = (BasicHost)
BasicUtil.createComponentDefn(ComponentDefn.HOST_COMPONENT_CODE, (ConfigurationID)
config.getID(), Host.HOST_COMPONENT_TYPE_ID, hostName);
-// HostID id = new HostID(hostName);
-// ComponentTypeID ctID = new ComponentTypeID(Host.COMPONENT_TYPE_NAME);
-
-// BasicHost bh = new BasicHost((ConfigurationID) config.getID(), id,
Host.HOST_COMPONENT_TYPE_ID);
-
-
- BasicConfiguration bc = (BasicConfiguration)
verifyTargetClass(config,BasicConfiguration.class);
- bc.addHost(bh);
-
-
- return bh;
-
- }
-
-
- //
----------------------------------------------------------------------------------
- // M O D I F I C A T I O N M E T H O D S
- //
----------------------------------------------------------------------------------
-
- public static ComponentType setLastChangedHistory(ComponentType type, String
lastChangedBy, String lastChangedDate) {
- Assertion.isNotNull(type);
-
- BasicComponentType target = (BasicComponentType)
verifyTargetClass(type,BasicComponentType.class);
-
- target.setLastChangedBy(lastChangedBy);
- target.setLastChangedDate(lastChangedDate);
-
- return target;
-
- }
- public static ComponentType setCreationChangedHistory(ComponentType type, String
createdBy, String creationDate) {
- Assertion.isNotNull(type);
-
- BasicComponentType target = (BasicComponentType)
verifyTargetClass(type,BasicComponentType.class);
-
- target.setCreatedBy(createdBy);
- target.setCreatedDate(creationDate);
-
- return target;
- }
-
-
- public static ComponentObject setLastChangedHistory(ComponentObject defn, String
lastChangedBy, String lastChangedDate) {
- Assertion.isNotNull(defn);
-
- BasicComponentObject target = (BasicComponentObject)
verifyTargetClass(defn,BasicComponentObject.class);
-
- target.setLastChangedBy(lastChangedBy);
-
- target.setLastChangedDate(lastChangedDate);
-
- return target;
-
- }
- public static boolean set = false;
- public static ComponentObject setCreationChangedHistory(ComponentObject defn, String
createdBy, String creationDate) {
- Assertion.isNotNull(defn);
-
- BasicComponentObject target = (BasicComponentObject)
verifyTargetClass(defn,BasicComponentObject.class);
-
- target.setCreatedBy(createdBy);
- target.setCreatedDate(creationDate);
-
-
- return target;
-
- }
-
-
-
- /**
- * Sets this ServiceComponentDefn's String routing UUID. This method
- * will modify the ServiceComponentDefn parameter, and also create the
- * action to set the routing UUID at the remote server.
- * @param serviceComponentDefn ServiceComponentDefn to have it's routing
- * UUID modified - this instance will be locally modified, and an action
- * will also be created for execution as a transaction later on
- * @param newRoutingUUID new String routing UUID for the indicated
- * ServiceComponentDefn
- */
- public static void setRoutingUUID(ServiceComponentDefn serviceComponentDefn, String
newRoutingUUID){
- Assertion.isNotNull(serviceComponentDefn);
-
- BasicServiceComponentDefn basicService = (BasicServiceComponentDefn)
verifyTargetClass(serviceComponentDefn,BasicServiceComponentDefn.class);
- basicService.setRoutingUUID(newRoutingUUID);
-
- }
-
-
-
- /**
- * This is a lighterweight version of the other
- * {@link #setEnabled(Configuration, ServiceComponentDefn, boolean, boolean)
setEnabled}
- * method. It simply modifies the ServiceComponentDefn parameter and
- * creates the necessary change object. It cannot update the
- * Configuration of the ServiceComponentDefn, nor can it automatically
- * delete any DeployedComponents of the ServiceComponentDefn parameter,
- * if the ServiceComponentDefn is being disabled. This method is only
- * needed by the JDBC spi and maybe the import/export tool.
- */
-
-// public static void setEnabled(ServiceComponentDefnID serviceComponentDefnID,
ProductServiceConfig psc, boolean enabled) {
-// Assertion.isNotNull(serviceComponentDefnID);
-// Assertion.isNotNull(psc);
-//
-//
-// if (!psc.containsService(serviceComponentDefnID)) {
-// return;
-// }
-//
-// boolean oldEnabled = psc.isServiceEnabled(serviceComponentDefnID);
-// //if a change is not being made to the enabled value, this whole method
-// //will be essentially bypassed
-// if (enabled != oldEnabled){
-// BasicProductServiceConfig basicPSC = (BasicProductServiceConfig)
verifyTargetClass(psc,BasicProductServiceConfig.class);
-// basicPSC.setServiceEnabled(serviceComponentDefnID, enabled);
-//
-// } //end if enabled!= oldEnabled
-// }
-
- public static Configuration addHostComponent(Configuration t, Host host) {
- if (host == null) {
- return t;
- }
-
- BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
-
- target.addHost(host);
-
- return target;
- }
-
-
-
- /**
- * Adds an existing ServiceComponentDefn to indicated PSC.
- * The ServiceComponentDefn will be removed from
- * any PSC it previously belonged to.
-
- * @param psc ProductServiceConfig to have service comp defn added to
- * @param serviceComponentDefnID will be added to the indicated
- * ProductServiceConfiguration (and removed from any PSC it previously
- * belonged to).
- */
-// public static ProductServiceConfig addServiceComponentDefn(ProductServiceConfig
psc, ServiceComponentDefnID serviceComponentDefnID){
-// Assertion.isNotNull(psc);
-// Assertion.isNotNull(serviceComponentDefnID);
-//
-// BasicProductServiceConfig basicPSC = (BasicProductServiceConfig)
verifyTargetClass(psc,BasicProductServiceConfig.class);
-// basicPSC.addServiceComponentDefnID(serviceComponentDefnID);
-//
-// return basicPSC;
-// }
-
-
- public static Configuration addComponentDefn( Configuration t, ComponentDefn defn) {
- BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
- target.addComponentDefn(defn);
- return target;
- }
-
-
- public static Configuration addDeployedComponent( Configuration t, DeployedComponent
deployComponent) {
- BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
- target.addDeployedComponent(deployComponent);
- return target;
- }
-
-
- public static ComponentObject addProperty( ComponentObject t, String name, String
value ) {
- Assertion.isNotNull(t);
- Assertion.isNotNull(name);
- Assertion.isNotNull(value);
-
-
- BasicComponentObject target = (BasicComponentObject)
verifyTargetClass(t,BasicComponentObject.class);
-
- target.addProperty(name, value);
-
- return target;
- }
-
- public static ComponentObject setProperty( ComponentObject t, String name, String
value ) {
- Assertion.isNotNull(t);
- Assertion.isNotNull(name);
- Assertion.isNotNull(value);
-
- BasicComponentObject target = (BasicComponentObject)
verifyTargetClass(t,BasicComponentObject.class);
-
- target.removeProperty(name);
-
- target.addProperty(name, value);
-
- return target;
- }
-
-// public static ProductServiceConfig resetServices(ProductServiceConfig psc) {
-// Assertion.isNotNull(psc);
-//
-// BasicProductServiceConfig basicPSC = (BasicProductServiceConfig)
verifyTargetClass(psc,BasicProductServiceConfig.class);
-// basicPSC.resetServices();
-//
-// return basicPSC;
-// }
-
-
-
-
- public static ComponentObject removeProperty( ComponentObject t, String name) {
- Assertion.isNotNull(t);
- Assertion.isNotNull(name);
-
- BasicComponentObject target = (BasicComponentObject)
verifyTargetClass(t,BasicComponentObject.class);
-
- target.removeProperty(name);
-
- return target;
-
- }
-
- public static ComponentObject modifyProperties( ComponentObject t, Properties props,
int command ) {
- Assertion.isNotNull(t);
-
- if (props == null) {
- return t;
- }
-
-
- BasicComponentObject target = (BasicComponentObject)
verifyTargetClass(t,BasicComponentObject.class);
- Properties newProps = null;
-
- switch ( command ) {
- case ADD:
- newProps = new Properties();
- newProps.putAll( target.getEditableProperties() );
- newProps.putAll( props );
-
- target.addProperties(newProps);
-
- break;
- case REMOVE:
- newProps = new Properties();
- newProps.putAll( target.getEditableProperties() );
- Iterator iter = props.keySet().iterator();
- while ( iter.hasNext() ) {
- newProps.remove( iter.next() );
- }
-
- target.setProperties(newProps);
- break;
- case SET:
- target.setProperties(props);
- break;
- }
-
- return target;
-
-
- }
-
-
-
- public static Configuration delete( ComponentObjectID targetID, Configuration
configuration ) throws ConfigurationException {
- //System.out.println("<!><!><!><!>deleting " +
target + ", delete dependencies: " + deleteDependencies);
-
- BasicConfiguration basicConfig = (BasicConfiguration)
verifyTargetClass(configuration,BasicConfiguration.class);
-
-// if (targetID instanceof ProductServiceConfigID) {
-//
-// if
(ProductServiceConfigID.ALL_STANDARD_PSC_NAMES.contains(targetID.getName())){
-// throw new
IllegalArgumentException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0070));
-// }
-//
-// basicConfig.removeComponentObject( targetID);
-// } else {
- basicConfig.removeComponentObject( targetID);
- // }
-
- return basicConfig;
- }
-
- /**
- * Adds the service type represented by the indicated ComponentType to
- * the list of legal service types of the indicated ProductType.
- * @param productType ProductType to have a new service type added to
- * @param serviceComponentType ComponentType to be added to the
- * ProductType
- */
-// public static ProductType addServiceComponentType(ProductType productType,
ComponentType serviceComponentType){
-// BasicProductType basicProdType = (BasicProductType)productType;
-//
-// ComponentTypeID productTypeID = (ComponentTypeID)basicProdType.getID();
-// setParentComponentTypeID(serviceComponentType, productTypeID);
-// //add the service ComponentTypeID to the BasicProductType
-// basicProdType.addServiceTypeID((ComponentTypeID)serviceComponentType.getID());
-//
-// return basicProdType;
-// }
-
- protected static ComponentType setParentComponentTypeID(ComponentType t,
ComponentTypeID parentID) {
-
- BasicComponentType target = (BasicComponentType)
verifyTargetClass(t,BasicComponentType.class);
- ComponentTypeID oldValue = target.getParentComponentTypeID();
-
- if ( (parentID == null && oldValue != null) ||
- ( oldValue==null ||!oldValue.equals(parentID)) ) {
- target.setParentComponentTypeID(parentID);
- }
-
- return target;
-
- }
-
-
-
-
- /**
- * Removes the service type represented by the indicated ComponentType from
- * the list of legal service types of the indicated ProductType.
- * @param productType ProductType to have the service type taken from
- * @param serviceComponentType ComponentType to be taken from the
- * ProductType
- */
-// public static ProductType removeServiceComponentType(ProductType productType,
ComponentType serviceComponentType){
-// BasicProductType basicProdType = (BasicProductType)productType;
-//
-// //add the service ComponentTypeID to the BasicProductType
-//
basicProdType.removeServiceTypeID((ComponentTypeID)serviceComponentType.getID());
-//
-// return basicProdType;
-// }
-
-
-// public static void renameHostAndDeployedComponents(ConfigurationModelContainer cmc,
String oldHostName, String newHostName, String newPortNumber) throws
ConfigurationException {
-//
-// /**
-// * We must add the host controller port property to this Host to
-// * allow it to be contacted over this port by the metamatrix platform.
-// */
-// Host oldHost = cmc.getHost(oldHostName);
-// if (oldHost == null) {
-// throw new ConfigurationException(ErrorMessageKeys.CONFIG_ERR_0070,
CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0070, new Object[] {oldHostName,
cmc.getConfiguration().getName()}));
-// }
-//
-//
-// /**
-// * Create a new host based on that URL
-// */
-//
-// Host host = createHost(cmc.getConfiguration(), newHostName);
-//
-// HostID hostID = (HostID) host.getID();
-// setProperty(host, HostPropertyNames.PORT_NUMBER, newPortNumber);
-//
-//
-//
-// Collection configObjects = cmc.getConfiguration().getDeployedComponents();
-//
-// Collection deployedObjects = new ArrayList();
-// Map vmObjects = new HashMap(5);
-// Iterator iterator = configObjects.iterator();
-// while (iterator.hasNext()) {
-// Object obj = iterator.next();
-// DeployedComponent origComponent = (DeployedComponent)obj;
-// HostID hID = origComponent.getHostID();
-// if (hID.getFullName().equalsIgnoreCase(oldHostName)) {
-//// VMComponentDefnID vmID = origComponent.getVMComponentDefnID();
-//// if (origComponent.isDeployedService()) {
-// deployedObjects.add(origComponent);
-//// } else if (!vmObjects.containsKey(vmID)) {
-//// VMComponentDefn vmDefn = cmc.getConfiguration().getVMComponentDefn(vmID);
-//// vmObjects.put(vmID, vmDefn);
-//// deployedObjects.add(origComponent);
-//// }
-// }
-// }
-//
-// delete((ComponentObjectID) oldHost.getID(), cmc.getConfiguration());
-//
-// Iterator iterator2 = cmc.getConfiguration().getVMComponentDefns().iterator();
-// //vmObjects.keySet().iterator();
-// while (iterator2.hasNext()) {
-// Object obj = iterator2.next();
-// VMComponentDefnID vmDefnID = (VMComponentDefnID)obj;
-// VMComponentDefn vmDefn = (VMComponentDefn) vmObjects.get(vmDefnID);
-// addConfigurationComponentDefn(cmc.getConfiguration(), vmDefn);
-//
-// }
-//
-// Iterator iterator3 = deployedObjects.iterator();
-// while (iterator3.hasNext()) {
-// Object obj = iterator3.next();
-// DeployedComponent origComponent = (DeployedComponent)obj;
-// String depComponentName = origComponent.getName();
-// ConfigurationID configID = origComponent.getConfigurationID();
-// VMComponentDefnID vmID = origComponent.getVMComponentDefnID();
-// ServiceComponentDefnID defnID =
origComponent.getServiceComponentDefnID();
-// ProductServiceConfigID pscID =
origComponent.getProductServiceConfigID();
-// ComponentTypeID typeID = origComponent.getComponentTypeID();
-//
-// /**
-// * We need to create a new Deployed ComponentID as the Host
-// * name is incorporated into the ID name of every Deployed
-// * Component.
-// */
-// DeployedComponentID newID = null;
-// if (origComponent.getServiceComponentDefnID() == null) {
-//
-// newID= new DeployedComponentID(depComponentName,
-// configID,
-// hostID,
-// vmID);
-// } else {
-//
-// newID= new DeployedComponentID(depComponentName,
-// configID,
-// hostID,
-// vmID,
-// pscID,
-// defnID);
-// }
-// /**
-// * Here we create a new DeployedComponent that is a clone of
-// * the original DeployedComponent in the list except for we
-// * switch out the HostID to reflect the new Host in the new
-// * server install.
-// */
-// BasicDeployedComponent newComponent = new BasicDeployedComponent(
-// newID,
-// configID,
-// hostID,
-// vmID,
-// defnID,
-// pscID,
-// typeID
-// );
-// /**
-// * Now we remove the original deployed component from the list of
-// * objects to be commited to the database and add the modified
-// * deployed component to the list of objects to be commited
-// * to the configuraiton database.
-// */
-//
-// addDeployedComponent(cmc.getConfiguration(), newComponent);
-//
-//
-// }
-//
-//
-//
-// }
-
- public static Configuration addConfigurationComponentDefn(Configuration t,
ComponentDefn defn ) {
- Assertion.isNotNull(defn);
-
- BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
- target.addComponentDefn(defn);
-
- return target;
- }
-
- public static Configuration addConfigurationDeployedComponent(Configuration t,
DeployedComponent deployedComponent) {
- Assertion.isNotNull(deployedComponent);
-
- BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
-
- target.addDeployedComponent(deployedComponent);
- return target;
- }
- public static Configuration addConfigurationHostComponent(Configuration t, Host host)
{
- Assertion.isNotNull(host);
-
- BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
- target.addHost(host);
- return target;
- }
-
- public static Configuration addAuthenticationProviderComponent(Configuration t,
AuthenticationProvider provider) {
- Assertion.isNotNull(provider);
-
- BasicConfiguration target = (BasicConfiguration)
verifyTargetClass(t,BasicConfiguration.class);
- target.addComponentDefn(provider);
- return target;
- }
-
-
-
- public static Properties getEditableProperties(ComponentObject t) {
- BasicComponentObject bco = (BasicComponentObject)
verifyTargetClass(t,BasicComponentObject.class);
- return bco.getEditableProperties();
- }
-
-
-
-
- //
----------------------------------------------------------------------------------
- // P R I V A T E
- //
----------------------------------------------------------------------------------
-
- /**
- * Subclass helper method that simply verifies that the specified target is either an
instance of
- * the specified class (or interface).
- * @param target the target or target identifier.
- * @param requiredClass the class/interface that the target must be an instance of.
- * @return the target object (for convenience)
- * @throws IllegalArgumentException if either the target is not an instance of the
specified class.
- */
- protected static Object verifyTargetClass( Object target, Class requiredClass )
throws IllegalArgumentException {
- if ( ! requiredClass.isInstance(target) ) {
- throw new
IllegalArgumentException(CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0072,
requiredClass.getName()) );
- }
- return target;
- }
-
-
-}
-
-
-