Author: vhalbert(a)redhat.com
Date: 2009-04-13 12:47:42 -0400 (Mon, 13 Apr 2009)
New Revision: 765
Modified:
branches/remove_psc/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java
branches/remove_psc/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java
branches/remove_psc/server/src/test/java/com/metamatrix/admin/server/FakeConfiguration.java
branches/remove_psc/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java
Log:
Teiid 323 - refactured, removing unused Config API classes: ProductType, ProductTypeID
and ConfigurationLock
Modified:
branches/remove_psc/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java
===================================================================
---
branches/remove_psc/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java 2009-04-13
16:46:55 UTC (rev 764)
+++
branches/remove_psc/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java 2009-04-13
16:47:42 UTC (rev 765)
@@ -27,10 +27,12 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.actions.ObjectEditor;
@@ -110,6 +112,8 @@
VDBDefn def = vdbArchive.getConfigurationDef();
Map connectorBindings = def.getConnectorBindings();
Map connectorTypes = def.getConnectorTypes();
+
+ Set addedTypes = new HashSet(connectorTypes.size());
ConfigurationModelContainer cmc =null;
@@ -117,22 +121,24 @@
XMLConfigurationConnector writer = getWriter();
BasicConfigurationObjectEditor editor = new
BasicConfigurationObjectEditor(true);
+ if (cmc == null) {
+ cmc = CurrentConfiguration.getInstance().getConfigurationModel();
+ }
+
for (Iterator it= connectorBindings.values().iterator(); it.hasNext(); ) {
ConnectorBinding cb = (ConnectorBinding) it.next();
// add the components to configuration
ComponentType ct = (ComponentType)
connectorTypes.get(cb.getComponentTypeID().getName());
-
- if (cmc == null) {
- cmc = CurrentConfiguration.getInstance().getConfigurationModel();
- }
- ConnectorBinding existingBinding = addConfigurationObjects(cmc, cb, ct,
writer, editor);
+
+ ConnectorBinding existingBinding = addConfigurationObjects(cmc, cb, ct,
writer, editor, addedTypes);
// if the binding is returned, it indicates the binding already existed and
// therefore will need to be remapped in its related model so that the
// model-to-binding mapping is correct
if (existingBinding != null) {
reMapBinding.put(cb.getRoutingUUID(), existingBinding);
}
+
}
writer.executeActions(editor.getDestination().popActions());
@@ -176,24 +182,30 @@
* @throws Exception
* @since 4.2
*/
- protected ConnectorBinding addConfigurationObjects(ConfigurationModelContainer cmc,
ConnectorBinding binding, ComponentType type, XMLConfigurationConnector writer,
BasicConfigurationObjectEditor editor)throws Exception {
- ComponentType tExist = null;
- if (type != null) {
- tExist = cmc.getComponentType(type.getFullName());
+ protected ConnectorBinding addConfigurationObjects(ConfigurationModelContainer cmc,
ConnectorBinding binding, ComponentType type, XMLConfigurationConnector writer,
BasicConfigurationObjectEditor editor, Set addedTypes)throws Exception {
+ boolean addType = false;
+
+ ComponentType tExist = null;
+ if (type != null ) {
+ if ( ! addedTypes.contains(type.getID())) {
+
+ tExist = cmc.getComponentType(type.getFullName());
+ if (tExist == null) {
+ addType=true;
+ }
+ }
} else {
+ // if here, the type wasnt in the .def file, therefore it must already exist
+
tExist = cmc.getComponentType(binding.getComponentTypeID().getFullName());
+ if (tExist == null) {
+ throw new
MetaMatrixException(RuntimeMetadataPlugin.Util.getString("VDBCreation.No_type_passed_and_bindingtype_not_found",
new Object[] { binding.getFullName(), binding.getComponentTypeID().getFullName()}));
//$NON-NLS-1$
+
+ }
type = tExist;
}
- boolean addType = false;
- if (tExist != null) {
- addType = false;
- } else if (type != null) {
- addType = true;
- } else {
- throw new
MetaMatrixException(RuntimeMetadataPlugin.Util.getString("VDBCreation.No_type_passed_and_bindingtype_not_found",
new Object[] { binding.getFullName(), binding.getComponentTypeID().getFullName()}));
//$NON-NLS-1$
- }
-
+
boolean bindingExist = false;
// determine if the binding exist,
@@ -224,6 +236,8 @@
editor.createComponentTypeDefn(type, ctd.getPropertyDefinition(),
false);
}
+
+ addedTypes.add(type.getID());
} else if (updateBindingProperties) {
// if the bindings are being updated, the type needs to be updated to ensure
// the matching componenttypedefns exists.
Modified:
branches/remove_psc/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java
===================================================================
---
branches/remove_psc/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java 2009-04-13
16:46:55 UTC (rev 764)
+++
branches/remove_psc/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java 2009-04-13
16:47:42 UTC (rev 765)
@@ -46,6 +46,7 @@
import com.metamatrix.common.config.api.ComponentDefn;
import com.metamatrix.common.config.api.ComponentDefnID;
import com.metamatrix.common.config.api.ComponentObject;
+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.ComponentTypeDefnID;
@@ -74,15 +75,17 @@
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
import com.metamatrix.common.config.api.exceptions.InvalidDeployedComponentException;
import com.metamatrix.common.config.api.exceptions.InvalidPropertyValueException;
+import com.metamatrix.common.config.model.BasicComponentObject;
import com.metamatrix.common.config.model.BasicComponentType;
import com.metamatrix.common.config.model.BasicComponentTypeDefn;
import com.metamatrix.common.config.model.BasicConfiguration;
import com.metamatrix.common.config.model.BasicDeployedComponent;
import com.metamatrix.common.config.model.BasicHost;
+import com.metamatrix.common.config.model.BasicServiceComponentDefn;
import com.metamatrix.common.config.model.BasicSharedResource;
+import com.metamatrix.common.config.model.BasicUtil;
import com.metamatrix.common.config.model.ConfigurationModel;
import com.metamatrix.common.config.model.ConfigurationModelContainerImpl;
-import com.metamatrix.common.config.model.ConfigurationObjectEditorHelper;
import com.metamatrix.common.config.model.PropertyValidations;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.namedobject.BaseID;
@@ -91,7 +94,6 @@
import com.metamatrix.common.util.crypto.CryptoUtil;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.core.util.DateUtil;
-import com.metamatrix.core.util.MetaMatrixProductVersion;
import com.metamatrix.platform.config.ConfigMessages;
import com.metamatrix.platform.config.ConfigPlugin;
@@ -327,7 +329,7 @@
affectedIDs.add(targetID);
- Configuration cfg = config.getConfiguration();
+ BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
try {
@@ -362,8 +364,7 @@
processPropertyForNewObject(rd, type, config, transaction
.getLockAcquiredBy());
- ConfigurationObjectEditorHelper
- .addConfigurationComponentDefn(cfg, rd);
+ cfg.addComponentDefn(rd);
} else if (action instanceof AddObject
|| action instanceof RemoveObject
@@ -389,7 +390,7 @@
} else if (action instanceof DestroyObject) {
if (rd != null) {
- ConfigurationObjectEditorHelper.delete(targetID, cfg);
+ delete(targetID, cfg);
setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
}
@@ -427,7 +428,7 @@
int actionIndex = -1;
affectedIDs.add(targetID);
- Configuration cfg = config.getConfiguration();
+ BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
try {
@@ -459,7 +460,7 @@
throw new
InvalidDeployedComponentException(ConfigMessages.CONFIG_0077,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0077, targetID.getName()));
}
- ConfigurationObjectEditorHelper.addDeployedComponent(cfg, dc);
+ cfg.addDeployedComponent(dc);
} else if (action instanceof AddObject ||
action instanceof RemoveObject ||
@@ -484,7 +485,7 @@
if (dc != null) {
- ConfigurationObjectEditorHelper.delete(targetID, config.getConfiguration());
+ delete(targetID, config.getConfiguration());
setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
}
@@ -522,7 +523,7 @@
affectedIDs.add(targetID);
- Configuration cfg = config.getConfiguration();
+ BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
try {
@@ -555,7 +556,7 @@
// System.out.println("STRATEGY: Add ComponentDefn Target " + targetID);
- ConfigurationObjectEditorHelper.addConfigurationComponentDefn(cfg,
cd);
+ cfg.addComponentDefn(cd);
} else if (action instanceof AddObject ||
action instanceof RemoveObject) {
@@ -616,7 +617,7 @@
} else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.ROUTING_UUID.getCode()) {
if (cd instanceof ServiceComponentDefn) {
- ConfigurationObjectEditorHelper.setRoutingUUID((ServiceComponentDefn)
cd, (String) anAction.getNewValue());
+ setRoutingUUID((ServiceComponentDefn) cd, (String)
anAction.getNewValue());
setLastChangedDate(cd, transaction.getLockAcquiredBy());
@@ -638,7 +639,7 @@
if (cd != null) {
// System.out.println("STRATEGY: Destroy ServiceDefn Target " + targetID);
- ConfigurationObjectEditorHelper.delete(targetID, cfg);
+ delete(targetID, cfg);
setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
}
@@ -676,7 +677,7 @@
affectedIDs.add(targetID);
- Configuration cfg = config.getConfiguration();
+ BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
try {
@@ -706,8 +707,8 @@
// process properties for any encryptions
processPropertyForNewObject(cd, type, config,
transaction.getLockAcquiredBy());
- ConfigurationObjectEditorHelper.addConfigurationComponentDefn(cfg,
cd);
-
+ cfg.addComponentDefn(cd);
+
} else if (action instanceof AddObject ||
action instanceof RemoveObject) {
@@ -780,7 +781,7 @@
if (cd != null) {
// System.out.println("STRATEGY: Destroy ComponentDefn Target " + targetID);
- ConfigurationObjectEditorHelper.delete(targetID, cfg);
+ delete(targetID, cfg);
setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
}
@@ -819,7 +820,7 @@
affectedIDs.add(targetID);
- Configuration cfg = config.getConfiguration();
+ BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
try {
@@ -851,7 +852,7 @@
// System.out.println("STRATEGY: Add ConnectorBinding Target " + dvt.getID() +
" to config " + cfg.getID());
- ConfigurationObjectEditorHelper.addConfigurationComponentDefn(cfg, cd);
+ cfg.addComponentDefn(cd);
} else if (action instanceof AddObject ||
action instanceof RemoveObject) {
@@ -930,7 +931,7 @@
cd = (ConnectorBinding) setLastChangedDate(cd,
transaction.getLockAcquiredBy());
- ConfigurationObjectEditorHelper.setRoutingUUID((ConnectorBinding) cd,
(String) anAction.getNewValue());
+ setRoutingUUID((ConnectorBinding) cd, (String)
anAction.getNewValue());
} else {
throw new InvalidArgumentException(ConfigMessages.CONFIG_0096,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0096, anAction.getActionDescription()
));
@@ -941,7 +942,7 @@
if (cd != null) {
// System.out.println("STRATEGY: Destroy ConnectorBinding Target " +
targetID);
- ConfigurationObjectEditorHelper.delete(targetID, cfg);
+ delete(targetID, cfg);
setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
}
@@ -1380,9 +1381,10 @@
dvt = (BasicHost) setCreationDate(dvt, transaction.getLockAcquiredBy());
+
+ BasicConfiguration bc = (BasicConfiguration) config.getConfiguration();
+ bc.addHost(dvt);
-
ConfigurationObjectEditorHelper.addHostComponent(config.getConfiguration(), dvt);
-
} else if (action instanceof AddObject ||
action instanceof RemoveObject ||
action instanceof ExchangeObject) {
@@ -1410,7 +1412,7 @@
if (host != null) {
// if the host is deleted, so must the dependent objects be deleted
(if they exist)
- ConfigurationObjectEditorHelper.delete(targetID, config.getConfiguration());
+ delete(targetID, config.getConfiguration());
setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
}
@@ -1691,7 +1693,10 @@
// because new objects may no longer have seperate actions for their properties, the
// properties that they have must be checked for passwords so that
// they can be encrypted.
- Properties props =
ConfigurationObjectEditorHelper.getEditableProperties(object);
+
+ BasicComponentObject bco = (BasicComponentObject) object;
+
+ Properties props = bco.getEditableProperties();
updateProperties(object, props, ConfigurationObjectEditor.SET, type, config,
principal);
@@ -1806,7 +1811,7 @@
}
- ConfigurationObjectEditorHelper.modifyProperties(object, passwordProps, operation);
+ modifyProperties(object, passwordProps, operation);
}
@@ -1832,15 +1837,24 @@
if (operation == ConfigurationObjectEditor.ADD) {
LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "adding",
propName, "with value", propValue); //$NON-NLS-1$ //$NON-NLS-2$
- ConfigurationObjectEditorHelper.addProperty(object, propName,
propValue);
+ BasicComponentObject target = (BasicComponentObject) object;
+ target.addProperty(propName, propValue);
+
} else if (operation == ConfigurationObjectEditor.SET) {
LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "setting",
propName, "to value", propValue); //$NON-NLS-1$ //$NON-NLS-2$
- ConfigurationObjectEditorHelper.setProperty(object, propName,
propValue);
+ BasicComponentObject target = (BasicComponentObject) object;
+
+ target.removeProperty(propName);
+
+ target.addProperty(propName, propValue);
+
} else if (operation == ConfigurationObjectEditor.REMOVE) {
LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "removing",
propName); //$NON-NLS-1$
- ConfigurationObjectEditorHelper.removeProperty(object, propName);
+ BasicComponentObject target = (BasicComponentObject) object;
+
+ target.removeProperty(propName);
}
}
@@ -1946,14 +1960,14 @@
String lastChangedDate = DateUtil.getCurrentDateAsString();
- return ConfigurationObjectEditorHelper.setLastChangedHistory(defn, principal,
lastChangedDate);
+ return BasicUtil.setLastChangedHistory(defn, principal, lastChangedDate);
}
private ComponentType setLastChangedDate(ComponentType defn, String principal) {
String lastChangedDate = DateUtil.getCurrentDateAsString();
- return ConfigurationObjectEditorHelper.setLastChangedHistory(defn, principal,
lastChangedDate);
+ return BasicUtil.setLastChangedHistory(defn, principal, lastChangedDate);
}
@@ -1961,20 +1975,92 @@
String creationDate = DateUtil.getCurrentDateAsString();
- defn = ConfigurationObjectEditorHelper.setLastChangedHistory(defn, principal,
creationDate);
+ defn = BasicUtil.setLastChangedHistory(defn, principal, creationDate);
- return ConfigurationObjectEditorHelper.setCreationChangedHistory(defn, principal,
creationDate);
+ return BasicUtil.setCreationChangedHistory(defn, principal, creationDate);
}
private ComponentType setCreationDate(ComponentType defn, String principal) {
String creationDate = DateUtil.getCurrentDateAsString();
- defn = ConfigurationObjectEditorHelper.setLastChangedHistory(defn, principal,
creationDate);
+ defn = BasicUtil.setLastChangedHistory(defn, principal, creationDate);
- return ConfigurationObjectEditorHelper.setCreationChangedHistory(defn, principal,
creationDate);
+ return BasicUtil.setCreationChangedHistory(defn, principal, creationDate);
}
+
+
+ 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;
+ }
+
+ /**
+ * 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;
+ private ComponentObject modifyProperties( ComponentObject t, Properties props, int
command ) {
+ Assertion.isNotNull(t);
+
+ if (props == null) {
+ return t;
+ }
+
+
+ BasicComponentObject target = (BasicComponentObject) t;
+ 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;
+
+
+ }
+
+ private void setRoutingUUID(ServiceComponentDefn serviceComponentDefn, String
newRoutingUUID){
+ Assertion.isNotNull(serviceComponentDefn);
+
+ BasicServiceComponentDefn basicService = (BasicServiceComponentDefn)
serviceComponentDefn;
+ basicService.setRoutingUUID(newRoutingUUID);
+
+ }
+
}
Modified:
branches/remove_psc/server/src/test/java/com/metamatrix/admin/server/FakeConfiguration.java
===================================================================
---
branches/remove_psc/server/src/test/java/com/metamatrix/admin/server/FakeConfiguration.java 2009-04-13
16:46:55 UTC (rev 764)
+++
branches/remove_psc/server/src/test/java/com/metamatrix/admin/server/FakeConfiguration.java 2009-04-13
16:47:42 UTC (rev 765)
@@ -49,11 +49,11 @@
import com.metamatrix.common.config.api.ServiceComponentDefnID;
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.BasicConfigurationObjectEditor;
import com.metamatrix.common.config.model.BasicConnectorBinding;
import com.metamatrix.common.config.model.BasicDeployedComponent;
import com.metamatrix.common.config.model.BasicVMComponentDefn;
-import com.metamatrix.common.config.model.ConfigurationObjectEditorHelper;
import com.metamatrix.common.config.model.ConfigurationVisitor;
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.namedobject.BaseID;
@@ -345,9 +345,11 @@
BasicConnectorBinding connectorBinding = new
BasicConnectorBinding(Configuration.NEXT_STARTUP_ID, connectorBindingID,
ConnectorBindingType.CONNECTOR_TYPE_ID);
connectorBinding.setRoutingUUID(name+"uuid"); //$NON-NLS-1$
-
- ConfigurationObjectEditorHelper.addProperty(connectorBinding,
"prop1", "value1"); //$NON-NLS-1$ //$NON-NLS-2$
- ConfigurationObjectEditorHelper.addProperty(connectorBinding,
"prop2", "value2"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ BasicComponentObject target = (BasicComponentObject) connectorBinding;
+
+ target.addProperty("prop1", "value1");
+ target.addProperty("prop2", "value2");
return connectorBinding;
Modified:
branches/remove_psc/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java
===================================================================
---
branches/remove_psc/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java 2009-04-13
16:46:55 UTC (rev 764)
+++
branches/remove_psc/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java 2009-04-13
16:47:42 UTC (rev 765)
@@ -61,12 +61,12 @@
import com.metamatrix.common.config.api.VMComponentDefnID;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
+import com.metamatrix.common.config.model.BasicComponentObject;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
import com.metamatrix.common.config.model.BasicConnectorBindingType;
import com.metamatrix.common.config.model.BasicHost;
import com.metamatrix.common.config.model.BasicSharedResource;
import com.metamatrix.common.config.model.ConfigurationModelContainerImpl;
-import com.metamatrix.common.config.model.ConfigurationObjectEditorHelper;
import com.metamatrix.common.config.xml.XMLConfigurationImportExportUtility;
import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.common.util.PropertiesUtils;
@@ -398,9 +398,12 @@
SharedResourceID resourceID1 = new SharedResourceID("resource1");
//$NON-NLS-1$
SharedResource resource1 = new BasicSharedResource(resourceID1,
SharedResource.MISC_COMPONENT_TYPE_ID);
- ConfigurationObjectEditorHelper.addProperty(resource1, "prop1",
"value1"); //$NON-NLS-1$ //$NON-NLS-2$
- ConfigurationObjectEditorHelper.addProperty(resource1, Resource.RESOURCE_POOL,
"pool"); //$NON-NLS-1$
+ BasicComponentObject target = (BasicComponentObject) resource1;
+
+ target.addProperty("prop1", "value1");
+ target.addProperty(Resource.RESOURCE_POOL, "pool");
+
results.add(resource1);