Author: tejones
Date: 2010-11-18 14:18:39 -0500 (Thu, 18 Nov 2010)
New Revision: 2730
Removed:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToArrayValueAdapter.java
Modified:
branches/7.1.x/console/pom.xml
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleDiscoveryComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapterFactory.java
Log:
TEIID-1324: Removed MetaValueFactory code and replaced with specific metavalue code
depending on the underlying objects. Also added the Teiid client jar to the plugin's
lib folder.
Modified: branches/7.1.x/console/pom.xml
===================================================================
--- branches/7.1.x/console/pom.xml 2010-11-17 17:08:34 UTC (rev 2729)
+++ branches/7.1.x/console/pom.xml 2010-11-18 19:18:39 UTC (rev 2730)
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
@@ -19,6 +20,7 @@
<jopr.jboss.as5.plugin.version>1.4.0.B01</jopr.jboss.as5.plugin.version>
<org.rhq.version>1.3.0.GA</org.rhq.version>
<apache.ant.version>1.7.0</apache.ant.version>
+ <teiid.version>${project.version}</teiid.version>
</properties>
@@ -152,11 +154,40 @@
</dependency>
-
</dependencies>
+
+
<build>
<outputDirectory>target/classes</outputDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>src/main/resources/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -164,16 +195,9 @@
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
+ <include>**/teiid*client*.jar</include>
</includes>
</resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- <exclude>**/*.properties</exclude>
- </excludes>
- </resource>
</resources>
</build>
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-11-17
17:08:34 UTC (rev 2729)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -43,7 +43,6 @@
import org.jboss.metatype.api.values.CompositeValueSupport;
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
@@ -54,6 +53,8 @@
import org.teiid.adminapi.VDB.Status;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.RequestMetadataMapper;
+import org.teiid.adminapi.impl.SessionMetadataMapper;
+import org.teiid.adminapi.impl.TransactionMetadataMapper;
import org.teiid.rhq.plugin.objects.ExecutedResult;
import org.teiid.rhq.plugin.util.DeploymentUtils;
import org.teiid.rhq.plugin.util.PluginConstants;
@@ -65,7 +66,6 @@
private static ManagedComponent mc = null;
private static final Log LOG =
LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- private static final MetaValueFactory metaValueFactory =
MetaValueFactory.getInstance();
private static final String VDB_EXT = ".vdb"; //$NON-NLS-1$
@@ -153,7 +153,7 @@
*/
public void executeOperation(ProfileServiceConnection connection,
- ExecutedResult operationResult, final Map<String, Object> valueMap) {
+ ExecutedResult operationResult, final Map<String, Object> valueMap) throws
Exception {
if
(operationResult.getComponentType().equals(PluginConstants.ComponentType.Platform.NAME))
{
executePlatformOperation(connection,
operationResult, operationResult.getOperationName(), valueMap);
@@ -190,7 +190,7 @@
operationResult.setContent(createReportResultList(fieldNameList, resultObject.iterator()));
} else if (operationName.equals(Platform.Operations.KILL_TRANSACTION)) {
Long sessionID = (Long) valueMap.get(Operation.Value.TRANSACTION_ID);
- MetaValue[] args = new MetaValue[] { metaValueFactory .create(sessionID) };
+ MetaValue[] args = new MetaValue[] { SimpleValueSupport.wrap(sessionID) };
try {
executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
Platform.Operations.KILL_TRANSACTION, args);
} catch (Exception e) {
@@ -199,7 +199,7 @@
}
} else if (operationName.equals(Platform.Operations.KILL_SESSION)) {
Long sessionID = (Long) valueMap.get(Operation.Value.SESSION_ID);
- MetaValue[] args = new MetaValue[] { metaValueFactory .create(sessionID) };
+ MetaValue[] args = new MetaValue[] { SimpleValueSupport.wrap(sessionID) };
try {
executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
Platform.Operations.KILL_SESSION, args);
} catch (Exception e) {
@@ -210,8 +210,8 @@
Long requestID = (Long) valueMap.get(Operation.Value.REQUEST_ID);
Long sessionID = (Long) valueMap.get(Operation.Value.SESSION_ID);
MetaValue[] args = new MetaValue[] {
- metaValueFactory.create(requestID),
- metaValueFactory.create(sessionID) };
+ SimpleValueSupport.wrap(requestID),
+ SimpleValueSupport.wrap(sessionID) };
try {
executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
Platform.Operations.KILL_REQUEST, args);
} catch (Exception e) {
@@ -247,11 +247,12 @@
private void executeVdbOperation(ProfileServiceConnection connection,
ExecutedResult operationResult, final String operationName,
- final Map<String, Object> valueMap) {
+ final Map<String, Object> valueMap) throws Exception {
Collection<ArrayList<String>> sqlResultsObject = new
ArrayList<ArrayList<String>>();
Collection<Request> resultObject = new ArrayList<Request>();
- Collection<Session> activeSessionsCollection = new ArrayList<Session>();
+ Collection<MetaValue> activeSessionsCollection = new
ArrayList<MetaValue>();
String vdbName = (String) valueMap.get(PluginConstants.ComponentType.VDB.NAME);
+ vdbName = formatVdbName(vdbName);
String vdbVersion = (String) valueMap.get(PluginConstants.ComponentType.VDB.VERSION);
if (operationName.equals(VDB.Operations.GET_PROPERTIES)) {
@@ -270,11 +271,11 @@
operationResult.setContent(createReportResultList(fieldNameList, resultObject.iterator()));
} else if (operationName.equals(VDB.Operations.GET_MATVIEWS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue resultsMetaValue = executeMaterializedViewQuery( connection,
formatVdbName(vdbName), Integer.parseInt(vdbVersion));
+ MetaValue resultsMetaValue = executeMaterializedViewQuery( connection, vdbName,
Integer.parseInt(vdbVersion));
getResultsCollectionValue(resultsMetaValue, sqlResultsObject);
operationResult.setContent(createReportResultListForMatViewQuery(fieldNameList,
sqlResultsObject.iterator()));
} else if (operationName.equals(VDB.Operations.RELOAD_MATVIEW)) {
- MetaValue resultsMetaValue =
reloadMaterializedView(connection, formatVdbName(vdbName), Integer.parseInt(vdbVersion),
+ MetaValue resultsMetaValue = reloadMaterializedView(connection, vdbName,
Integer.parseInt(vdbVersion),
(String) valueMap.get(Operation.Value.MATVIEW_SCHEMA),
(String) valueMap.get(Operation.Value.MATVIEW_TABLE),
(Boolean) valueMap.get(Operation.Value.INVALIDATE_MATVIEW));
@@ -334,10 +335,10 @@
MetaValue resultsCollection = null;
MetaValue[] args = new MetaValue[] {
- MetaValueFactory.getInstance().create(vdbName),
- MetaValueFactory.getInstance().create(vdbVersion),
- MetaValueFactory.getInstance().create(Operation.Value.MAT_VIEW_QUERY),
- MetaValueFactory.getInstance().create(Long.parseLong("9999999")) };
//$NON-NLS-1$
+ SimpleValueSupport.wrap(vdbName),
+ SimpleValueSupport.wrap(vdbVersion),
+ SimpleValueSupport.wrap(Operation.Value.MAT_VIEW_QUERY),
+ SimpleValueSupport.wrap(Long.parseLong("9999999")) }; //$NON-NLS-1$
try {
resultsCollection =
executeManagedOperation(connection, getRuntimeEngineDeployer(connection,
mc), VDB.Operations.EXECUTE_QUERIES, args);
@@ -360,10 +361,10 @@
query = query.replace("param1", matView); //$NON-NLS-1$
query = query.replace("param2", invalidate.toString()); //$NON-NLS-1$
MetaValue[] args = new MetaValue[] {
- MetaValueFactory.getInstance().create(vdbName),
- MetaValueFactory.getInstance().create(vdbVersion),
- MetaValueFactory.getInstance().create(query),
- MetaValueFactory.getInstance().create(Long.parseLong("9999999")) };
//$NON-NLS-1$
+ SimpleValueSupport.wrap(vdbName),
+ SimpleValueSupport.wrap(vdbVersion),
+ SimpleValueSupport.wrap(query),
+ SimpleValueSupport.wrap(Long.parseLong("9999999")) }; //$NON-NLS-1$
try {
result = executeManagedOperation(connection, getRuntimeEngineDeployer(connection,
mc),
@@ -383,8 +384,8 @@
MetaValue requestsCollection = null;
MetaValue[] args = new MetaValue[] {
- MetaValueFactory.getInstance().create(vdbName),
- MetaValueFactory.getInstance().create(vdbVersion) };
+ SimpleValueSupport.wrap(vdbName),
+ SimpleValueSupport.wrap(vdbVersion) };
try {
requestsCollection = executeManagedOperation(connection,
@@ -651,7 +652,7 @@
if (metaType.isCollection()) {
for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isComposite()) {
- RequestMetadataMapper rmm = new RequestMetadataMapper();
+ RequestMetadataMapper rmm = new RequestMetadataMapper();
RequestMetadata request = rmm.unwrapMetaValue(value);
list.add(request);
} else {
@@ -661,23 +662,31 @@
}
}
- private void getResultsCollectionValue(MetaValue pValue,
Collection<ArrayList<String>> list) {
+ private void getResultsCollectionValue(MetaValue pValue,
Collection<ArrayList<String>> list) throws Exception {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isCollection()) {
- ArrayList<String> row = (ArrayList<String>)
MetaValueFactory.getInstance().unwrap(value);
+ ArrayList<String> row = new ArrayList<String>();
+ MetaValue[] metaValueArray = ((CollectionValueSupport)value).getElements();
+ for (MetaValue cell : metaValueArray){
+ row.add(ProfileServiceUtil.stringValue(cell));
+ }
list.add(row);
}
}
}
}
- private void getResultsCollectionValueForMatViewRefresh(MetaValue pValue,
Collection<ArrayList<String>> list) {
+ private void getResultsCollectionValueForMatViewRefresh(MetaValue pValue,
Collection<ArrayList<String>> list) throws Exception {
MetaType metaType = pValue.getMetaType();
for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isCollection()) {
- ArrayList<String> row = (ArrayList<String>)
MetaValueFactory.getInstance().unwrap(value);
+ ArrayList<String> row = new ArrayList<String>();
+ MetaValue[] metaValueArray = ((CollectionValueSupport)value).getElements();
+ for (MetaValue cell : metaValueArray){
+ row.add(ProfileServiceUtil.stringValue(cell));
+ }
list.add(row);
}
}
@@ -688,7 +697,8 @@
if (metaType.isCollection()) {
for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isComposite()) {
- Transaction transaction = (Transaction)
MetaValueFactory.getInstance().unwrap(value);
+ TransactionMetadataMapper tmm = new TransactionMetadataMapper();
+ Transaction transaction = tmm.unwrapMetaValue(value);
list.add(transaction);
} else {
throw new IllegalStateException(pValue
@@ -703,8 +713,9 @@
if (metaType.isCollection()) {
for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isComposite()) {
- Session Session = (Session) MetaValueFactory.getInstance().unwrap(value);
- list.add(Session);
+ SessionMetadataMapper rmm = new SessionMetadataMapper();
+ Session session = rmm.unwrapMetaValue(value);
+ list.add(session);
} else {
throw new IllegalStateException(pValue
+ " is not a Composite type"); //$NON-NLS-1$
@@ -713,14 +724,13 @@
}
}
- public static <T> void getSessionCollectionValueForVDB(MetaValue
pValue,Collection<Session> list, String vdbName) {
+ public static <T> void getSessionCollectionValueForVDB(MetaValue
pValue,Collection<MetaValue> list, String vdbName) throws Exception {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
if (value.getMetaType().isComposite()) {
- Session session = (Session) MetaValueFactory.getInstance().unwrap(value);
- if (session.getVDBName().equals(vdbName)) {
- list.add(session);
+ if
(ProfileServiceUtil.stringValue(((CompositeValueSupport)value).get("VDBName")).equals(vdbName))
{ //$NON-NLS-1$
+ list.add(value);
}
} else {
throw new IllegalStateException(pValue+ " is not a Composite type");
//$NON-NLS-1$
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java 2010-11-17
17:08:34 UTC (rev 2729)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -22,11 +22,7 @@
package org.teiid.rhq.plugin;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.naming.NamingException;
@@ -36,19 +32,15 @@
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.metatype.api.types.CollectionMetaType;
import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.EnumValueSupport;
-import org.jboss.metatype.api.values.GenericValue;
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
@@ -57,30 +49,25 @@
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
-import org.rhq.plugins.jbossas5.util.ConversionUtils;
-import org.teiid.adminapi.impl.PropertyMetadata;
-import org.teiid.rhq.admin.DQPManagementView;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
+import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
-import org.teiid.rhq.plugin.util.PluginConstants.Operation;
-import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
-import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.VDB;
/**
- * Component class for a Teiid VDB
+ * Component class for a Teiid VDB Data Role
*
*/
public class DataRoleComponent extends Facet {
@@ -99,6 +86,7 @@
this.componentType = PluginConstants.ComponentType.DATA_ROLE.NAME;
super.start(context);
}
+
/*
* (non-Javadoc)
*
@@ -106,7 +94,8 @@
*/
@Override
public AvailabilityType getAvailability() {
- return
((VDBComponent)this.resourceContext.getParentResourceComponent()).getAvailability();
+ return ((VDBComponent) this.resourceContext
+ .getParentResourceComponent()).getAvailability();
}
@Override
@@ -118,9 +107,9 @@
public void getValues(MeasurementReport arg0,
Set<MeasurementScheduleRequest> arg1) throws Exception {
// TODO Auto-generated method stub
-
+
}
-
+
/**
* The plugin container will call this method when it has a new
* configuration for your managed resource. Your plugin will re-configure
@@ -150,44 +139,52 @@
((VDBComponent) this.resourceContext
.getParentResourceComponent()).name, componentType);
ManagedProperty mp =
managedComponent.getProperty("dataPolicies");//$NON-NLS-1$
- List<ManagedObject> dataRolesListMp = (List<ManagedObject>)
MetaValueFactory
- .getInstance().unwrap(mp.getValue());
+ CollectionValueSupport dataRolesListMp = (CollectionValueSupport) mp
+ .getValue();
String name = resourceConfiguration.getSimpleValue("name", null);
//$NON-NLS-1$
String anyAuthenticated = resourceConfiguration.getSimpleValue(
"anyAuthenticated", null); //$NON-NLS-1$
- for (ManagedObject mo : dataRolesListMp) {
+ for (MetaValue val : dataRolesListMp.getElements()) {
+ GenericValueSupport genValueSupport = (GenericValueSupport) val;
+ ManagedObjectImpl managedObject = (ManagedObjectImpl) genValueSupport
+ .getValue();
- String pname = ProfileServiceUtil.stringValue(mo.getProperty(
- "name").getValue()); //$NON-NLS-1$
- if (!pname.equals(name)) {
- continue;
+ for (String dataRolesProp : managedObject.getPropertyNames()) {
+ ManagedProperty property = managedObject
+ .getProperty(dataRolesProp);
+
+ String pname = ProfileServiceUtil.stringValue(managedObject
+ .getProperty("name").getValue()); //$NON-NLS-1$
+ if (!pname.equals(name)) {
+ continue;
+ }
+
+ anyAuthenticatedMp = managedObject
+ .getProperty("anyAuthenticated"); //$NON-NLS-1$
+ anyAuthenticatedMp.setValue(ProfileServiceUtil.wrap(
+ SimpleMetaType.BOOLEAN, anyAuthenticated));
+ List<Property> mappedRoleNamePropertyList =
resourceConfiguration.getList("mappedRoleNameList").getList(); //$NON-NLS-1$
+ List<String> mappedRoleNameList = new ArrayList<String>();
+
+ for (Property mappedRoleNameProperty : mappedRoleNamePropertyList){
+ String mappedRoleNameString =
((PropertyMap)mappedRoleNameProperty).getSimpleValue("name", null);
//$NON-NLS-1$
+ mappedRoleNameList.add(mappedRoleNameString);
+ }
+ ManagedProperty mappedRoleNameMp =
managedObject.getProperty("mappedRoleNames"); //$NON-NLS-1$
+ mappedRoleNameMp.setValue(convertListOfStringsToMetaValue(mappedRoleNameList));
}
- anyAuthenticatedMp = mo.getProperty("anyAuthenticated"); //$NON-NLS-1$
- anyAuthenticatedMp.setValue(ProfileServiceUtil.wrap(
- SimpleMetaType.BOOLEAN, anyAuthenticated));
- List<Property> mappedRoleNamePropertyList = resourceConfiguration
- .getList("mappedRoleNameList").getList(); //$NON-NLS-1$
- List<String> mappedRoleNameList = new ArrayList<String>();
-
- for (Property mappedRoleNameProperty : mappedRoleNamePropertyList){
- String mappedRoleNameString =
((PropertyMap)mappedRoleNameProperty).getSimpleValue("name", null);
//$NON-NLS-1$
- mappedRoleNameList.add(mappedRoleNameString);
+ try {
+ managementView.updateComponent(managedComponent);
+ } catch (Exception e) {
+ LOG.error("Unable to update component [" //$NON-NLS-1$
+ + managedComponent.getName() + "] of type " //$NON-NLS-1$
+ + componentType + ".", e); //$NON-NLS-1$
+ report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ report.setErrorMessageFromThrowable(e);
}
- ManagedProperty mappedRoleNameMp = mo.getProperty("mappedRoleNames");
//$NON-NLS-1$
- mappedRoleNameMp.setValue(MetaValueFactory.getInstance().create(mappedRoleNameList));
}
-
- try {
- managementView.updateComponent(managedComponent);
- } catch (Exception e) {
- LOG.error("Unable to update component [" //$NON-NLS-1$
- + managedComponent.getName() + "] of type " //$NON-NLS-1$
- + componentType + ".", e); //$NON-NLS-1$
- report.setStatus(ConfigurationUpdateStatus.FAILURE);
- report.setErrorMessageFromThrowable(e);
- }
} catch (Exception e) {
LOG.error("Unable to process update request", e); //$NON-NLS-1$
report.setStatus(ConfigurationUpdateStatus.FAILURE);
@@ -196,6 +193,24 @@
}
+ /**
+ * @param mappedRoleNameList
+ */
+ private MetaValue convertListOfStringsToMetaValue(List<String> mappedRoleNameList)
{
+
+ MetaValue[] listMemberValues = new MetaValue[mappedRoleNameList.size()];
+ int memberIndex = 0;
+
+ for (String mappedRoleName : mappedRoleNameList)
+ {
+ MetaValue mappedRoleNameValue = SimpleValueSupport.wrap(mappedRoleName);
+ listMemberValues[memberIndex++] = mappedRoleNameValue;
+ }
+ return new CollectionValueSupport( new
CollectionMetaType("java.util.List", SimpleMetaType.STRING), //$NON-NLS-1$
+ listMemberValues);
+
+ }
+
@Override
public Configuration loadResourceConfiguration() {
@@ -246,14 +261,21 @@
configuration.put(mappedRoleNameList);
ManagedProperty mappedRoleNames = managedObject
.getProperty("mappedRoleNames"); //$NON-NLS-1$
- if (mappedRoleNames != null) {
- List<String> props = (List<String>) MetaValueFactory
- .getInstance().unwrap(mappedRoleNames.getValue());
- for (String mappedRoleName : props) {
+ if (mappedRoleNames != null) {
+ CollectionValueSupport props = (CollectionValueSupport) mappedRoleNames
+ .getValue();
+ for (MetaValue mappedRoleName : props.getElements()) {
PropertyMap mappedRoleNameMap = null;
- mappedRoleNameMap = new PropertyMap("map", //$NON-NLS-1$
- new PropertySimple("name", mappedRoleName)); //$NON-NLS-1$
+ try {
+ mappedRoleNameMap = new PropertyMap(
+ "map", //$NON-NLS-1$
+ new PropertySimple(
+ "name", (ProfileServiceUtil.stringValue(mappedRoleName))));
//$NON-NLS-1$
+ } catch (Exception e) {
+ final String msg = "Exception in loadResourceConfiguration(): " +
e.getMessage(); //$NON-NLS-1$
+ LOG.error(msg, e);
+ }
mappedRoleNameList.add(mappedRoleNameMap);
}
}
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleDiscoveryComponent.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleDiscoveryComponent.java 2010-11-17
17:08:34 UTC (rev 2729)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleDiscoveryComponent.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -22,23 +22,19 @@
package org.teiid.rhq.plugin;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.metatype.api.values.CollectionValueSupport;
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
@@ -120,10 +116,9 @@
ManagedProperty mappedRoleNames = managedObject
.getProperty("mappedRoleNames");
if (mappedRoleNames != null) {
- List<String> props = (List<String>) MetaValueFactory
- .getInstance().unwrap(mappedRoleNames.getValue());
- for (String mappedRoleName : props) {
- mappedRoleNameList.add(new PropertySimple("name", mappedRoleName));
+ CollectionValueSupport props = (CollectionValueSupport)mappedRoleNames.getValue();
+ for (MetaValue mappedRoleName : props.getElements()) {
+ mappedRoleNameList.add(new PropertySimple("name",
ProfileServiceUtil.stringValue(mappedRoleName)));
}
}
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-11-17
17:08:34 UTC (rev 2729)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -224,7 +224,11 @@
final ExecutedResult result, final Map<String, Object> valueMap) {
DQPManagementView dqp = new DQPManagementView();
- dqp.executeOperation(connection, result, valueMap);
+ try {
+ dqp.executeOperation(connection, result, valueMap);
+ } catch (Exception e) {
+ new RuntimeException(e);
+ }
}
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-11-17
17:08:34 UTC (rev 2729)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -32,8 +32,8 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
@@ -140,7 +140,11 @@
// First get translator specific properties
ManagedProperty translatorProps = translator.getProperty("property");
- getTranslatorValues(translatorProps.getValue(), propMap, list);
+ try {
+ getTranslatorValues(translatorProps.getValue(), propMap, list);
+ } catch (Exception e) {
+ throw new RuntimeException(e.getMessage());
+ }
// Now get common properties
c.put(new PropertySimple("name", translatorName));
@@ -151,16 +155,16 @@
}
public static <T> void getTranslatorValues(MetaValue pValue,
- PropertyMap map, PropertyList list) {
+ PropertyMap map, PropertyList list) throws Exception {
MetaType metaType = pValue.getMetaType();
- Map<String, T> unwrappedvalue = null;
+ MapCompositeValueSupport unwrappedvalueMap = null;
if (metaType.isComposite()) {
- unwrappedvalue = (Map<String, T>)
MetaValueFactory .getInstance().unwrap(pValue);
+ unwrappedvalueMap = (MapCompositeValueSupport) pValue;
- for (String key : unwrappedvalue.keySet()) {
+ for (String key : unwrappedvalueMap.getMetaType().keySet()) {
map = new PropertyMap("property");
map.put(new PropertySimple("name", key));
- map.put(new PropertySimple("value", unwrappedvalue.get(key)));
+ map.put(new PropertySimple("value",
ProfileServiceUtil.stringValue((MetaValue)unwrappedvalueMap.get(key))));
map.put(new PropertySimple("description", "Custom property"));
list.add(map);
}
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-11-17
17:08:34 UTC (rev 2729)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -22,7 +22,6 @@
package org.teiid.rhq.plugin;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -31,8 +30,8 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
@@ -115,17 +114,16 @@
public static <T> void getTranslatorValues(MetaValue pValue,
- PropertyMap map, PropertyList list) {
+ PropertyMap map, PropertyList list) throws Exception {
MetaType metaType = pValue.getMetaType();
- Map<String, T> unwrappedvalue = null;
+ MapCompositeValueSupport unwrappedvalue = null;
if (metaType.isComposite()) {
- unwrappedvalue = (Map<String, T>)
MetaValueFactory.getInstance().unwrap(pValue);
+ unwrappedvalue = (MapCompositeValueSupport)pValue;
- for (String key : unwrappedvalue.keySet()) {
+ for (String key : unwrappedvalue.getMetaType().keySet()) {
map = new PropertyMap("properties");//$NON-NLS-1$
map.put(new PropertySimple("name", key));//$NON-NLS-1$
- map.put(new PropertySimple("value",
unwrappedvalue.get(key)));//$NON-NLS-1$
- //map.put(new PropertySimple("description", "Custom property"));
+ map.put(new PropertySimple("value",
ProfileServiceUtil.stringValue((MetaValue)unwrappedvalue.get(key))));//$NON-NLS-1$
list.add(map);
}
} else {
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-11-17
17:08:34 UTC (rev 2729)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -47,7 +47,6 @@
import org.jboss.metatype.api.values.GenericValue;
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.mc4j.ems.connection.EmsConnection;
@@ -65,8 +64,6 @@
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.adminapi.impl.PropertyMetadata;
@@ -277,8 +274,7 @@
managedComponent = managementView.getComponent(this.name,
componentType);
ManagedProperty mp = managedComponent.getProperty("models");//$NON-NLS-1$
- List<ManagedObject> modelsMp = (List<ManagedObject>) MetaValueFactory
- .getInstance().unwrap(mp.getValue());
+ List<ManagedObject> modelsMp = (List<ManagedObject>) mp.getValue();
modelsMetaValue = (CollectionValueSupport) managedComponent
.getProperty("models").getValue();
GenericValue[] models = (GenericValue[]) modelsMetaValue
@@ -320,9 +316,7 @@
ManagedProperty sourceMappings = managedModel
.getProperty("sourceMappings");//$NON-NLS-1$
if (sourceMappings != null) {
- List<ManagedObject> mappings = (List<ManagedObject>) MetaValueFactory
- .getInstance()
- .unwrap(sourceMappings.getValue());
+ List<ManagedObject> mappings = (List<ManagedObject>)
sourceMappings.getValue();
for (ManagedObject mo : mappings) {
String sName = ProfileServiceUtil.getSimpleValue(
mo, "name", String.class);//$NON-NLS-1$
@@ -396,7 +390,12 @@
configuration.put(new PropertySimple("url", vdbURL));
configuration.put(new PropertySimple("connectionType", connectionType));
- getTranslators(mcVdb, configuration);
+ try {
+ getTranslators(mcVdb, configuration);
+ } catch (Exception e) {
+ final String msg = "Exception in loadResourceConfiguration(): " +
e.getMessage(); //$NON-NLS-1$
+ LOG.error(msg, e);
+ }
getModels(mcVdb, configuration);
@@ -420,8 +419,6 @@
private void getModels(ManagedComponent mcVdb, Configuration configuration) {
// Get models from VDB
ManagedProperty property = mcVdb.getProperty("models");
- List<ManagedObject> models = (List<ManagedObject>) MetaValueFactory
- .getInstance().unwrap(property.getValue());
CollectionValueSupport valueSupport = (CollectionValueSupport) property
.getValue();
MetaValue[] metaValues = valueSupport.getElements();
@@ -582,17 +579,15 @@
/**
* @param mcVdb
* @param configuration
- * @throws Exception
+ * @throws Exception
*/
private void getTranslators(ManagedComponent mcVdb,
- Configuration configuration) {
+ Configuration configuration) throws Exception {
// Get models from VDB
ManagedProperty property = mcVdb.getProperty("overrideTranslators");
if (property == null) {
return;
}
- List<ManagedObject> translators = (List<ManagedObject>) MetaValueFactory
- .getInstance().unwrap(property.getValue());
CollectionValueSupport valueSupport = (CollectionValueSupport) property
.getValue();
MetaValue[] metaValues = valueSupport.getElements();
@@ -612,11 +607,10 @@
ManagedProperty properties = managedObject.getProperty("property");
if (properties != null) {
- List<PropertyMetadata> props = (List<PropertyMetadata>) MetaValueFactory
- .getInstance().unwrap(properties.getValue());
- for (PropertyMetadata propertyMetaData : props) {
- String propertyName = propertyMetaData.getName();
- String propertyValue = propertyMetaData.getValue();
+ CollectionValueSupport props = (CollectionValueSupport) properties.getValue();
+ for (MetaValue propertyMetaData : props) {
+ String propertyName =
ProfileServiceUtil.stringValue(((CompositeValueSupport)propertyMetaData).get("name"));
+ String propertyValue =
ProfileServiceUtil.stringValue(((CompositeValueSupport)propertyMetaData).get("value"));
PropertyMap translatorMap = null;
translatorMap = new PropertyMap("translatorMap",
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapterFactory.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapterFactory.java 2010-11-17
17:08:34 UTC (rev 2729)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/adapter/api/PropertyAdapterFactory.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -28,7 +28,6 @@
import org.jboss.metatype.api.types.PropertiesMetaType;
import org.jboss.metatype.api.values.MetaValue;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.teiid.rhq.plugin.adapter.impl.PropertyListToArrayValueAdapter;
import org.teiid.rhq.plugin.adapter.impl.PropertyListToCollectionValueAdapter;
import org.teiid.rhq.plugin.adapter.impl.PropertyMapToCompositeValueSupportAdapter;
import org.teiid.rhq.plugin.adapter.impl.PropertyMapToGenericValueAdapter;
@@ -85,10 +84,6 @@
{
propertyAdapter = new PropertyListToCollectionValueAdapter();
}
- else if (metaType.isArray())
- {
- propertyAdapter = new PropertyListToArrayValueAdapter();
- }
else if (metaType.isEnum())
{
propertyAdapter = new PropertySimpleToEnumValueAdapter();
Deleted:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToArrayValueAdapter.java
===================================================================
---
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToArrayValueAdapter.java 2010-11-17
17:08:34 UTC (rev 2729)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyListToArrayValueAdapter.java 2010-11-18
19:18:39 UTC (rev 2730)
@@ -1,93 +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 org.teiid.rhq.plugin.adapter.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.teiid.rhq.plugin.adapter.api.AbstractPropertyListAdapter;
-import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
-import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
-
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.ArrayValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-
-/**
- *
- */
-public class PropertyListToArrayValueAdapter extends AbstractPropertyListAdapter
implements PropertyAdapter<PropertyList, PropertyDefinitionList>
-{
- //@todo need to implement this like the other List to Collection, but not until there
is an actual property that needs this
- public void populateMetaValueFromProperty(PropertyList property, MetaValue metaValue,
PropertyDefinitionList propertyDefinition)
- {
- PropertyDefinition memberDefinition = propertyDefinition.getMemberDefinition();
- List<Property> properties = property.getList();
- if (metaValue != null)
- {
- ArrayValueSupport valueSupport = (ArrayValueSupport)metaValue;
- MetaType listMetaType = valueSupport.getMetaType().getElementType();
- List<MetaValue> values = new
ArrayList<MetaValue>(properties.size());
- for (Property propertyWithinList : properties)
- {
- MetaValue value = MetaValueFactory.getInstance().create(null);
- PropertyAdapter<Property, PropertyDefinition> propertyAdapter =
PropertyAdapterFactory.getPropertyAdapter(listMetaType);
- propertyAdapter.populateMetaValueFromProperty(propertyWithinList, value,
memberDefinition);
- values.add(value);
- }
- valueSupport.setValue(values.toArray());
- }
- }
-
- //@todo need to implement this like the other List to Collection, but not until there
is an actual property that needs this
- public MetaValue convertToMetaValue(PropertyList property, PropertyDefinitionList
propertyDefinition, MetaType type)
- {
- return null;
- }
-
- public void populatePropertyFromMetaValue(PropertyList property, MetaValue metaValue,
PropertyDefinitionList propertyDefinition)
- {
- PropertyDefinition memberDefinition = propertyDefinition.getMemberDefinition();
- List<Property> properties = property.getList();
-
- // Since we want to load the PropertyList with fresh values, we want it cleared
out
- properties.clear();
-
- if (metaValue != null)
- {
- ArrayValueSupport valueSupport = (ArrayValueSupport)metaValue;
- MetaType listMetaType = valueSupport.getMetaType().getElementType();
- MetaValue[] metaValues = (MetaValue[])valueSupport.getValue();
- PropertyAdapter propertyAdapter =
PropertyAdapterFactory.getPropertyAdapter(listMetaType);
- for (MetaValue value : metaValues)
- {
- Property propertyToAddToList = propertyAdapter.convertToProperty(value,
memberDefinition);
- properties.add(propertyToAddToList);
- }
- }
- }
-}