[rhq] Changes to 'mssql'
by lkrejci
New branch 'mssql' available with the following commits:
commit baf0f7c97d5ddf16ff23d90e1ab6407c6a5ddb57
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Mar 25 17:05:23 2011 +0100
Explicitly merging the operation metadata changes so that unsaved properties are correctly persisted.
commit 590bc68f3e2ff804adb00a4d6902dea6006dda29
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Mar 28 16:59:20 2011 +0200
preliminary changes for MS SQL Server support
13 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java | 2 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 6 ++++--
2 files changed, 6 insertions(+), 2 deletions(-)
New commits:
commit d525381080087b8ca9d439e2d7d9ff16d8e14117
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 28 10:59:09 2011 -0400
suppress warnings due to the fact that subclass has different datasource types than the superclass
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
index 097383e..7e9883e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
@@ -67,6 +67,8 @@ public class ResourceCompositeSearchView extends ResourceSearchView {
this(locatorId, null, criteria, title, headerIcons);
}
+ // surpress unchecked warnings because the superclass has different generic types for the datasource
+ @SuppressWarnings("unchecked")
@Override
protected RPCDataSource getDataSourceInstance() {
return ResourceCompositeDataSource.getInstance();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index beb5579..27e67d7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
*/
-public class ResourceSearchView extends Table<RPCDataSource<Resource, ResourceCriteria>> {
+public class ResourceSearchView extends Table {
private static final String DEFAULT_TITLE = MSG.view_inventory_resources_title();
@@ -112,7 +112,9 @@ public class ResourceSearchView extends Table<RPCDataSource<Resource, ResourceCr
setDataSource(datasource);
}
- protected RPCDataSource<Resource, ResourceCriteria> getDataSourceInstance() {
+ // surpress unchecked warnings because the subclasses may have different generic types for the datasource
+ @SuppressWarnings("unchecked")
+ protected RPCDataSource getDataSourceInstance() {
return ResourceDatasource.getInstance();
}
13 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 14 +++-------
1 file changed, 5 insertions(+), 9 deletions(-)
New commits:
commit 9b58b90dbeaad340e36ee4d9036e353a648dde72
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 28 10:41:09 2011 -0400
add generic type info
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 6559a31..beb5579 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -41,6 +41,8 @@ import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -60,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
*/
-public class ResourceSearchView extends Table {
+public class ResourceSearchView extends Table<RPCDataSource<Resource, ResourceCriteria>> {
private static final String DEFAULT_TITLE = MSG.view_inventory_resources_title();
@@ -106,17 +108,11 @@ public class ResourceSearchView extends Table {
addHeaderIcon(headerIcon);
}
- // DynamicForm searchPanel = new DynamicForm();
- // final TextItem searchBox = new TextItem("query", "Search Resources");
- // searchBox.setValue("");
- // searchPanel.setWrapItemTitles(false);
- // searchPanel.setFields(searchBox);
-
- final RPCDataSource datasource = getDataSourceInstance();
+ final RPCDataSource<Resource, ResourceCriteria> datasource = getDataSourceInstance();
setDataSource(datasource);
}
- protected RPCDataSource getDataSourceInstance() {
+ protected RPCDataSource<Resource, ResourceCriteria> getDataSourceInstance() {
return ResourceDatasource.getInstance();
}
13 years, 1 month
[rhq] Branch 'as7plugin' - 5 commits - modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/pom.xml | 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 53 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 127 +++-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java | 19
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java | 101 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 13
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java | 8
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java | 106 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java | 62 ++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java | 53 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java | 45 +
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 285 ++++++----
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java | 73 ++
13 files changed, 765 insertions(+), 184 deletions(-)
New commits:
commit cac8c1fe12745ceb5b72573800d27787bc6398c2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 28 16:18:48 2011 +0200
Shuffle stuff around to support domain mode.
Add Domain discovery, improve handling of the "path" config element.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 64e575b..9407172 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -155,8 +155,14 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
JsonNode sub = json.findValue(propDef.getName());
if (propDef instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
- ret.put(propertySimple);
+ PropertySimple propertySimple;
+
+ if (sub!=null)
+ propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
+ else {
+ propertySimple = new PropertySimple(propDef.getName(),null); // TODO store it at all?
+ }
+ ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
index e2d73c4..96737dd 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
@@ -1,23 +1,19 @@
package org.rhq.modules.plugins.jbossas7;
import java.io.File;
-import java.net.InetAddress;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
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.event.log.LogFileEventResourceComponentHelper;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -68,7 +64,7 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
serverName = serverNameFull;
}
- String logFile = getLogFieFromCommandLine(commandLine);
+ String logFile = getLogFileFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
String javaClazz = psr.getProcessInfo().getName();
@@ -118,7 +114,7 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties
- String getLogFieFromCommandLine(String[] commandLine) {
+ String getLogFileFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
new file mode 100644
index 0000000..ad09c77
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
@@ -0,0 +1,101 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Subsystem;
+
+/**
+ * Discover the domain
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class DomainDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
+
+ // TODO get next from some host.xml file
+ String host = "localhost";
+ String portString = "9990";
+ int port = Integer.parseInt(portString);
+ ASConnection connection = new ASConnection(host,port);
+
+
+ Configuration config = context.getDefaultPluginConfiguration();
+
+
+ // A domain has a server group so check for it.
+ boolean found = false;
+ JsonNode json = connection.getLevelData(null,null);
+ if (!connection.isErrorReply(json)) {
+
+ Iterator<String> fields = json.getFieldNames();
+ while (fields.hasNext()) {
+ String field = fields.next();
+ if (field.equals("server-group"))
+ found=true;
+
+ }
+
+ if (found) {
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ "Domain", // Key
+ "Domain", // Name
+ null, // Version
+ context.getResourceType().getDescription(), // Description
+ config,
+ null);
+ details.add(detail);
+ }
+
+ return details;
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index a017194..4cde830 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -63,6 +63,8 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String cpath = config.getSimpleValue("path", null);
boolean recursive = false;
+ String parentPath = parentComponent.getPath();
+
String path;
if (cpath.endsWith("/*")) {
path = cpath.substring(0,cpath.length()-2);
@@ -71,6 +73,14 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
else
path = cpath;
+ if (parentPath!=null && !parentPath.isEmpty()) {
+ if (parentPath.endsWith("/") || path.startsWith("/"))
+ path = parentPath + path;
+ else
+ path = parentPath + "/" + path;
+ }
+ System.out.println("total path: [" + path + "]");
+
JsonNode json = connection.getLevelData(path,recursive, false);
if (!connection.isErrorReply(json)) {
@@ -86,6 +96,8 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String key = entry.getKey();
Subsystem subsystem = entry.getValue();
+ String newPath = cpath.replaceAll("\\*",key);
+ config.getSimple("path").setStringValue(newPath);
String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
@@ -108,6 +120,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String resKey = path;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+ config.getSimple("path").setStringValue(path);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 54fd4cf..654ee06 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -51,7 +51,7 @@
version="4.0.0-SNAPSHOT"
>
- <depends plugin="JMX"/>
+ <depends plugin="JMX" useClasses="true"/>
<!-- TODO I think we should introduce an abstract AS7 plugin that contains some base functionality and then
@@ -78,18 +78,33 @@
<!-- TODO supply parameters and return values -->
</operation>
- <!--
- <server name="ProcessManager JVM"
- description="JVM of the ProcessManager"
- sourcePlugin="JMX"
- sourceType="JMX Server"
- discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
- class="org.rhq.plugins.jmx.JMXServerComponent"
- singleton="true"
- />
- -->
+
+ </server>
+
+ <server name="Domain"
+ discovery="DomainDiscovery"
+ class="BaseComponent"
+ description="An AS7 management profile">
+ <server name="Profile"
+ description="One profile in a domain"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+
+ <plugin-configuration>
+ <c:simple-property name="path" default="/profile/*" readOnly="true"/>
+ </plugin-configuration>
+ </server>
+ <server name="ServerGroups"
+ description="Server groups on this domain"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" default="/server-group/*" readOnly="true"/>
+ </plugin-configuration>
+
+ </server>
</server>
@@ -116,16 +131,7 @@
<operation name="dummyOperation">
<!-- TODO supply parameters and return values -->
</operation>
- <!--
- <server name="JBoss AS standalone JVM"
- description="JVM of the standalone JBossAS"
- sourcePlugin="JMX"
- sourceType="JMX Server"
- discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
- class="org.rhq.plugins.jmx.JMXServerComponent"
- singleton="true"
- />
- -->
+
<resource-configuration>
<c:list-property name="schema-locations" displayName="Schema locations">
@@ -139,89 +145,154 @@
</c:list-property>
</resource-configuration>
- <server name="Messaging"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
+
+
+ </server>
+
+ <server name="JBossAS-Managed"
+ discovery="BaseDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="hostname" default="localhost" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true"/>
+
+ &logSources;
+ </plugin-configuration>
+
+ <process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
+
+
+ <metric property="serverGroup" dataType="trait" displayType="summary" />
+ <resource-configuration>
+ <!--<c:group name="interfaces">-->
+ <c:simple-property name="loopback" default="127.0.0.1" />
+ <c:simple-property name="external" default="any" />
+ <c:simple-property name="public" default="any" />
+ <!--</c:group>-->
+ </resource-configuration>
+
+
+ </server>
+
+
+<!--
+ <server name="JBoss AS JVM"
+ description="JVM of the standalone JBossAS"
+ sourcePlugin="JMX"
+ sourceType="JMX Server"
+ discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
+ class="org.rhq.plugins.jmx.JMXServerComponent"
+ singleton="true"
+ >
+ <runs-inside>
+ <parent-resource-type name="JBossAS-Managed" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ <parent-resource-type name="ProcessController" plugin="jboss-as-7"/>
+ </runs-inside>
+ </server>
+-->
+
+ <server name="Messaging"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="journal-min-files" />
+ <c:simple-property name="journal-type" />
+ </resource-configuration>
+
+
+ <service name="Acceptor"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
+ <c:simple-property name="path" readOnly="true" default="/acceptor"/>
</plugin-configuration>
- <resource-configuration>
- <c:simple-property name="journal-min-files" />
- <c:simple-property name="journal-type" />
- </resource-configuration>
+ </service>
- <service name="Acceptor"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/messaging/acceptor"/>
- </plugin-configuration>
+ </server>
+ <server name="JBossWeb"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
- </service>
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
- </server>
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/web"/>
+ </plugin-configuration>
- <server name="JBossWeb"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
+ <service name="Connector"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/web"/>
+ <c:simple-property name="path" readOnly="true" default="/connector/*"/>
</plugin-configuration>
- <service name="Connector"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/web/connector/*"/>
- </plugin-configuration>
-
- <metric property="bytesSent" measurementType="trendsup"/>
- <metric property="bytesReceived" measurementType="trendsup"/>
- <metric property="processingTime" measurementType="trendsup"/>
- <metric property="errorCount" measurementType="trendsup"/>
- <metric property="maxTime" />
- <metric property="requestCount" measurementType="trendsup"/>
+ <metric property="bytesSent" measurementType="trendsup"/>
+ <metric property="bytesReceived" measurementType="trendsup"/>
+ <metric property="processingTime" measurementType="trendsup"/>
+ <metric property="errorCount" measurementType="trendsup"/>
+ <metric property="maxTime" />
+ <metric property="requestCount" measurementType="trendsup"/>
- <resource-configuration>
- <c:simple-property name="protocol" required="false" description="The web connector protocol."/>
- <c:simple-property name="socket-binding" required="false" description="The web connector socket-binding reference, this connector should be bound to."/>
- <c:simple-property name="scheme" required="false" description="The web connector scheme"/>
- </resource-configuration>
+ <resource-configuration>
+ <c:simple-property name="protocol" required="false" description="The web connector protocol."/>
+ <c:simple-property name="socket-binding" required="false" description="The web connector socket-binding reference, this connector should be bound to."/>
+ <c:simple-property name="scheme" required="false" description="The web connector scheme"/>
+ </resource-configuration>
- </service>
+ </service>
- <service name="VHost"
- discovery="SubsystemDiscovery"
- class="BaseComponent">
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/web/virtual-server/*"/>
- </plugin-configuration>
+ <service name="VHost"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/virtual-server/*"/>
+ </plugin-configuration>
- <resource-configuration>
- <c:simple-property name="access-log"/>
- <c:list-property name="alias" description="The virtual server aliases"/>
- <c:simple-property name="rewrite"/>
- </resource-configuration>
+ <resource-configuration>
+ <c:simple-property name="access-log"/>
+ <c:list-property name="alias" description="The virtual server aliases"/>
+ <c:simple-property name="rewrite"/>
+ </resource-configuration>
- </service>
+ </service>
- </server>
+ </server>
<service name="NetworkInterface"
discovery="InterfaceDiscovery"
class="BaseComponent"
description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
+
+ <runs-inside>
+ <parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/"/>
</plugin-configuration>
@@ -231,13 +302,23 @@
discovery="SocketBindingGroupDiscovery"
class="BaseComponent"
>
+ <runs-inside>
+ <parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/socket-binding-group/"/>
</plugin-configuration>
<resource-configuration>
<c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition" required="false"/>
+ <!-- note: at domain level there is no port-offset -->
<c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group" required="false"/>
+ <c:list-property name="include">
+ <c:simple-property name="binding" displayName="Included bindings" description="Other bindings that are included in this one"/>
+ </c:list-property>
<c:list-property name="socket-binding">
<c:map-property name="binding">
<c:simple-property name="name" description="The name of the socket. Services which need to access the socket configuration information will find it using this name."/>
@@ -252,41 +333,4 @@
</service>
-
- </server>
-
- <server name="JBossAS-Managed"
- discovery="BaseDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="hostname" default="localhost" required="true"/>
- <c:simple-property name="port" default="9990" type="integer" required="true"/>
-
- &logSources;
- </plugin-configuration>
-
- <process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
-
-
- <metric property="serverGroup" dataType="trait" displayType="summary" />
- <resource-configuration>
- <!--<c:group name="interfaces">-->
- <c:simple-property name="loopback" default="127.0.0.1" />
- <c:simple-property name="external" default="any" />
- <c:simple-property name="public" default="any" />
- <!--</c:group>-->
- </resource-configuration>
-
- <server name="JBoss AS managed JVM"
- description="JVM of the managed JBossAS"
- sourcePlugin="JMX"
- sourceType="JMX Server"
- discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
- class="org.rhq.plugins.jmx.JMXServerComponent"
- singleton="true"
- />
-
- </server>
-
</plugin>
commit cab2192295a5186955f23713b763e32b6e64c8bc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 25 17:39:22 2011 +0100
Convert extensions to a list of simple props.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 8d3a7a8..64e575b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -247,6 +247,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
}
+ else if (memberDefinition instanceof PropertyDefinitionSimple) {
+ String name = memberDefinition.getName();
+ Iterator<String> keys = sub.getFieldNames();
+ while(keys.hasNext()) {
+ String entryKey = keys.next();
+
+ PropertySimple propertySimple = new PropertySimple(name,entryKey);
+ propertyList.add(propertySimple);
+ }
+ }
ret.put(propertyList);
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 6a00d57..54fd4cf 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -135,9 +135,7 @@
</c:map-property>
</c:list-property>
<c:list-property name="extension" displayName="Installed extensions">
- <c:map-property name="extension">
- <c:simple-property name="name" readOnly="true"/>
- </c:map-property>
+ <c:simple-property name="name" readOnly="true"/>
</c:list-property>
</resource-configuration>
commit 73ebc9d575c836294ac6f45df3e662c325def109
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 25 17:00:06 2011 +0100
Support /extension and /schema-locations as resource config on AS
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 50bd98d..c626c49 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -194,7 +194,6 @@ public class ASConnection {
while ((line = in.readLine()) != null) {
builder.append(line);
}
-// System.out.println(builder.toString());
in.close();
}
else {
@@ -207,11 +206,12 @@ public class ASConnection {
while ((line = br.readLine()) != null) {
builder.append(line);
}
-// System.out.println(builder.toString());
br.close();
}
}
- JsonNode operationResult = mapper.readTree(builder.toString());
+ String outcome = builder.toString();
+ System.out.println("==> " + outcome);
+ JsonNode operationResult = mapper.readTree(outcome);
return operationResult;
} catch (IOException e) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index a4c388f..8d3a7a8 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -21,6 +21,7 @@ package org.rhq.modules.plugins.jbossas7;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -45,8 +46,10 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -61,7 +64,6 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
String path;
String key;
-
/**
* Return availability of this resource
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
@@ -145,9 +147,10 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- JsonNode json = connection.getLevelData(key,true,false); // TODO path ? key?
+ JsonNode json = connection.getLevelData(path,true,false); // TODO path ? key?
Configuration ret = new Configuration();
+ ObjectMapper mapper = new ObjectMapper();
for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
JsonNode sub = json.findValue(propDef.getName());
@@ -156,7 +159,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
- if (((PropertyDefinitionList) propDef).getMemberDefinition()==null) {
+ PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
+ if (memberDefinition ==null) {
Iterator<JsonNode> values = sub.getElements();
while (values.hasNext()) {
JsonNode node = values.next();
@@ -165,20 +169,82 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
propertyList.add(propertySimple);
}
}
- else if (((PropertyDefinitionList) propDef).getMemberDefinition() instanceof PropertyDefinitionMap) {
- Iterator<String> entries = sub.getFieldNames();
- while (entries.hasNext()) {
- String entryKey = entries.next();
- JsonNode node = sub.findPath(entryKey);
- PropertyMap map = new PropertyMap(((PropertyDefinitionList) propDef).getMemberDefinition().getName()); // TODO : name from def or 'entryKey' ?
- Iterator<String> fields = node.getFieldNames(); // TODO loop over fields from map and not from json
- while (fields.hasNext()) {
- String key = fields.next();
-
- PropertySimple propertySimple = new PropertySimple(key,node.findValue(key).getValueAsText());
- map.put(propertySimple);
+ else if (memberDefinition instanceof PropertyDefinitionMap) {
+ PropertySimple propertySimple;
+
+ if (sub.isArray()) {
+ Iterator<JsonNode> entries = sub.getElements();
+ while (entries.hasNext()) {
+ JsonNode entry = entries.next(); // -> one row in the list i.e. one map
+
+ // Distinguish here?
+
+ PropertyMap map = new PropertyMap(memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
+ Iterator<JsonNode> fields = entry.getElements(); // TODO loop over fields from map and not from json
+ while (fields.hasNext()) {
+ JsonNode field = fields.next();
+ if (field.isObject()) {
+ // TODO only works for tuples at the moment - migrate to some different kind of parsing!
+ PROPERTY_VALUE prop = mapper.readValue(field,PROPERTY_VALUE.class);
+ // now need to find the names of the properties
+ List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
+ if (defList.isEmpty())
+ throw new IllegalArgumentException("Map " + memberDefinition.getName() + " has no members");
+ String key = defList.get(0).getName();
+ String value = prop.getKey();
+ propertySimple = new PropertySimple(key,value);
+ map.put(propertySimple);
+ if (defList.size()>1) {
+ key = defList.get(1).getName();
+ value = prop.getValue();
+ propertySimple = new PropertySimple(key,value);
+ map.put(propertySimple);
+
+ }
+ } else { // TODO reached?
+ String key = field.getValueAsText();
+ if (key.equals("PROPERTY_VALUE")) { // TODO this may change in the future in the AS implementation
+ JsonNode pv = entry.findValue(key);
+ String k = pv.toString();
+ String v = pv.getValueAsText();
+ propertySimple = new PropertySimple(k,v);
+ map.put(propertySimple);
+
+ }
+ else {
+ propertySimple = new PropertySimple(key,entry.findValue(key).getValueAsText());
+ map.put(propertySimple);
+
+ }
+ }
+ }
+ propertyList.add(map);
+ }
+ }
+ else if (sub.isObject()) {
+ Iterator<String> keys = sub.getFieldNames();
+ while(keys.hasNext()) {
+ String entryKey = keys.next();
+
+ JsonNode node = sub.findPath(entryKey);
+ PropertyMap map = new PropertyMap(memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
+ if (node.isObject()) {
+ Iterator<String> fields = node.getFieldNames(); // TODO loop over fields from map and not from json
+ while (fields.hasNext()) {
+ String key = fields.next();
+
+ propertySimple = new PropertySimple(key,node.findValue(key).getValueAsText());
+ map.put(propertySimple);
+ }
+ propertyList.add(map);
+ } else if (sub.isNull()) {
+ List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
+ String key = defList.get(0).getName();
+ propertySimple = new PropertySimple(key,entryKey);
+ map.put(propertySimple);
+ }
}
- propertyList.add(map);
+
}
}
ret.put(propertyList);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
index 571dbab..e2d73c4 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
@@ -67,17 +67,6 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
if (serverName.isEmpty())
serverName = serverNameFull;
-// DomainClient client = DomainClient.Factory.create(InetAddress.getByName("localhost"),9990); //
-// Map<ServerIdentity,ServerStatus> serverStatuses = client.getServerStatuses();
-// for (Map.Entry<ServerIdentity,ServerStatus> entry : serverStatuses.entrySet()) {
-// ServerIdentity identity = entry.getKey();
-// ServerStatus status = entry.getValue();
-// if (identity.getServerName().equals(serverName)) {
-// String serverGroupName = identity.getServerGroupName();
-// config.put(new PropertySimple("server-group",serverGroupName));
-// }
-//
-// }
}
String logFile = getLogFieFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
index fdc04c6..f145aa6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
@@ -30,6 +30,8 @@ public class NameValuePair {
public String name;
public String value;
+ public NameValuePair() {}
+
public NameValuePair(String name, String value) {
this.name = name;
this.value = value;
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 7abbfeb..6a00d57 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -127,9 +127,25 @@
/>
-->
+ <resource-configuration>
+ <c:list-property name="schema-locations" displayName="Schema locations">
+ <c:map-property name="location">
+ <c:simple-property name="urn" readOnly="true"/>
+ <c:simple-property name="location" readOnly="true"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property name="extension" displayName="Installed extensions">
+ <c:map-property name="extension">
+ <c:simple-property name="name" readOnly="true"/>
+ </c:map-property>
+ </c:list-property>
+ </resource-configuration>
+
<server name="Messaging"
discovery="SubsystemDiscovery"
- class="BaseComponent">
+ class="BaseComponent"
+ singleton="true"
+ >
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
</plugin-configuration>
@@ -156,6 +172,7 @@
<server name="JBossWeb"
discovery="SubsystemDiscovery"
class="BaseComponent"
+ singleton="true"
>
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/subsystem/web"/>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 4082612..4909595 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -51,13 +51,12 @@ public class OperationJsonTest {
String result = mapper.writeValueAsString(operation);
- System.out.println(operation);
- System.out.println(result);
-
Operation op = mapper.readValue(result,Operation.class);
assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation();
assert op.getName().equals("socket-binding") : "attribute name is " + op.getName();
assert op.getValue().equals("jndi") : "attribute value is " + op.getValue();
+ assert op.getAddress().size()==2 : "Address did not contain 2 parts, but " + op.getAddress().size();
+
}
commit 8256274472de89eeb3f733de08ff79740d7fca7e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 25 13:17:55 2011 +0100
Improve support for execute operations on AS
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 663df43..50bd98d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -51,6 +51,7 @@ public class ASConnection {
private String host;
URL url;
String urlString;
+ private StringBuilder builder;
public ASConnection(String host, int port) {
this.host = host;
@@ -157,18 +158,23 @@ public class ASConnection {
return false;
}
- public void execute(String path, String operationName, NameValuePair nvp) {
+ /**
+ * Execute an operation against the domain api
+ * @param path Node to manipulate
+ * @param operationName operation to run
+ * @param attributeValue attribute-name-value pair
+ */
+ public JsonNode execute(String path, String operationName, NameValuePair attributeValue) {
try {
- URL url = getBaseUrl(path,"operation="+operationName);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
-// conn.setRequestMethod("POST");
+ conn.setRequestMethod("POST");
OutputStream out = conn.getOutputStream();
ObjectMapper mapper = new ObjectMapper();
- Operation operation = new Operation(operationName,pathToAddress(path),nvp);
+ Operation operation = new Operation(operationName,pathToAddress(path),attributeValue);
String result = mapper.writeValueAsString(operation);
System.out.println("Json to send: " + result);
@@ -184,17 +190,35 @@ public class ASConnection {
BufferedReader in = new BufferedReader(new InputStreamReader(
inputStream));
String line;
- StringBuilder builder = new StringBuilder();
+ builder = new StringBuilder();
while ((line = in.readLine()) != null) {
builder.append(line);
}
- System.out.println(builder.toString());
+// System.out.println(builder.toString());
+ in.close();
}
+ else {
+ System.out.println(conn.getResponseCode());
+ InputStream errorStream = conn.getErrorStream();
+ if (errorStream!=null) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(errorStream));
+ String line;
+ builder = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ builder.append(line);
+ }
+// System.out.println(builder.toString());
+ br.close();
+ }
+ }
+ JsonNode operationResult = mapper.readTree(builder.toString());
+ return operationResult;
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
}
+ return null;
}
private List<PROPERTY_VALUE> pathToAddress(String path) {
@@ -237,4 +261,9 @@ public class ASConnection {
return url2;
}
+ public String getFailureDescription(JsonNode jsonNode) {
+ JsonNode node = jsonNode.findValue("failure-description");
+ return node.getValueAsText();
+
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index ad3516e..a4c388f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -195,10 +196,12 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (Map.Entry<String, PropertySimple> entry : conf.getSimpleProperties().entrySet()) {
NameValuePair nvp = new NameValuePair(entry.getKey(),entry.getValue().getStringValue());
- connection.execute(path,"write-attribute",nvp);
+ JsonNode result= connection.execute(key,"write-attribute",nvp); // TODO path / key handling
+ if(connection.isErrorReply(result)) {
+ report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ report.setErrorMessage(connection.getFailureDescription(result));
+ }
}
-
- // TODO: Customise this generated block
}
}
commit 0b87441a0a79ca22d01456a293213902b001795b
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 25 12:00:32 2011 +0100
Implement serialization and deserialization of Operation to/from json.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index ef75ab7..38cdfa0 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -30,8 +30,8 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
</configuration>
</plugin>
<plugin>
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 0fb28b1..663df43 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -35,8 +35,8 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.jetbrains.annotations.Nullable;
-import org.omg.CORBA.NamedValue;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
@@ -157,10 +157,10 @@ public class ASConnection {
return false;
}
- public void execute(String path, String s, NameValuePair nvp) {
+ public void execute(String path, String operationName, NameValuePair nvp) {
try {
- URL url = getBaseUrl(path,"operation="+s);
+ URL url = getBaseUrl(path,"operation="+operationName);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
// conn.setRequestMethod("POST");
@@ -168,11 +168,7 @@ public class ASConnection {
ObjectMapper mapper = new ObjectMapper();
- Operation operation = new Operation();
- operation.operation=s;
- operation.nvp=nvp;
- operation.address=pathToAddress(path);
-
+ Operation operation = new Operation(operationName,pathToAddress(path),nvp);
String result = mapper.writeValueAsString(operation);
System.out.println("Json to send: " + result);
@@ -201,17 +197,17 @@ public class ASConnection {
}
- private List<NameValuePair> pathToAddress(String path) {
+ private List<PROPERTY_VALUE> pathToAddress(String path) {
if (path.endsWith("/"))
path = path.substring(0,path.length()-1);
if (path.startsWith("/"))
path = path.substring(1);
- List<NameValuePair> result = new ArrayList<NameValuePair>();
+ List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
String[] components = path.split("/");
for (int i = 0; i < components.length ; i+=2) {
- NameValuePair valuePair = new NameValuePair(components[i],components[i+1]);
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(components[i],components[i+1]);
result.add(valuePair);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
index ff3f10c..fdc04c6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
@@ -18,6 +18,7 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonValue;
/**
@@ -34,9 +35,4 @@ public class NameValuePair {
this.value = value;
}
- @JsonValue
- @Override
- public String toString() {
- return name +":"+ value ;
- }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index 4f5cda1..642b41f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -18,8 +18,11 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonValue;
/**
@@ -28,20 +31,99 @@ import org.codehaus.jackson.annotate.JsonValue;
*/
public class Operation {
- public String operation;
- public List<NameValuePair> address;
+ public Operation(String operation, List<PROPERTY_VALUE> address, NameValuePair payload) {
+ this.operation = operation;
+ this.address = address;
+ this.name = payload.name;
+ this.value = payload.value;
+ }
+
+ public Operation() {
+ // needed for Jackson
+ }
+
+ private String operation;
+ @JsonProperty
+ private List<PROPERTY_VALUE> address = Collections.emptyList();
+
+ private String name;
+ private String value;
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
- public NameValuePair nvp;
+ public List<PROPERTY_VALUE> getAddress() {
+ return address;
+ }
+
+ public void setAddress(List<PROPERTY_VALUE> address) {
+ this.address = address;
+ }
- @JsonValue
- public String toString() {
- StringBuilder b = new StringBuilder();
- b.append("{");
- b.append("operation:").append(operation).append(",\n");
- b.append("address:").append(address).append(",\n");
- b.append(nvp);
- b.append("}");
- return b.toString();
+ public List<PROPERTY_VALUE> addToAddress(PROPERTY_VALUE component) {
+ if (address==null)
+ address = new ArrayList<PROPERTY_VALUE>();
+ address.add(component);
+ return address;
}
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /*
+ [localhost:9999 /subsystem=web/connector=http] :write-attribute(name=socket-binding,value=jndi)
+ yield JSON to send:
+ {
+ "operation" : "write-attribute",
+ "name" : "socket-binding",
+ "value" : "jndi",
+ "address" : [
+ {
+ "PROPERTY_VALUE" : {
+ "subsystem" : "web"
+ }
+ },
+ {
+ "PROPERTY_VALUE" : {
+ "connector" : "http"
+ }
+ }
+ ]
+ }
+ */
+
+// @JsonValue
+// public String toString() {
+// StringBuilder b = new StringBuilder();
+// b.append('{');
+// b.append("\"operation\":\"").append(operation).append("\",");
+// b.append("\"address\":");
+// if (address!=null && !address.isEmpty())
+// b.append(address);
+// else
+// b.append("[]");
+// b.append(',');
+// b.append(payload);
+// b.append("}");
+// return b.toString();
+// }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
new file mode 100644
index 0000000..b2c8223
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
@@ -0,0 +1,62 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.io.Serializable;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.annotate.JsonValue;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import org.rhq.modules.plugins.jbossas7.json.serializer.PropertyValueDeserializer;
+import org.rhq.modules.plugins.jbossas7.json.serializer.PropertyValueSerializer;
+
+/**
+ * @author Heiko W. Rupp
+ */
+@JsonSerialize(using = PropertyValueSerializer.class)
+@JsonDeserialize(using = PropertyValueDeserializer.class)
+public class PROPERTY_VALUE implements Serializable{
+
+ private String key;
+ private String value;
+
+ public PROPERTY_VALUE(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java
new file mode 100644
index 0000000..11e6ae3
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java
@@ -0,0 +1,53 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json.serializer;
+
+import java.io.IOException;
+import java.lang.ref.PhantomReference;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Deserialize {"foo":"bar"} into a PROPERTY_VALUE
+ * @author Heiko W. Rupp
+ */
+public class PropertyValueDeserializer extends JsonDeserializer<PROPERTY_VALUE> {
+
+
+ @Override
+ public PROPERTY_VALUE deserialize(JsonParser jsonParser,
+ DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+
+ String tmp = jsonParser.getText(); // {
+ jsonParser.nextToken();
+ String key = jsonParser.getText();
+ jsonParser.nextToken();
+ String value = jsonParser.getText();
+ jsonParser.nextToken();
+ tmp = jsonParser.getText(); // }
+
+ PROPERTY_VALUE pv = new PROPERTY_VALUE(key,value);
+ return pv;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java
new file mode 100644
index 0000000..e7dda18
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json.serializer;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Serialize the key/value pair from PROPERTY_VALUE into {"value of key":"value of value"}
+ * @author Heiko W. Rupp
+ */
+public class PropertyValueSerializer extends JsonSerializer<PROPERTY_VALUE> {
+
+ @Override
+ public void serialize(PROPERTY_VALUE property_value, JsonGenerator jsonGenerator,
+ SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
+
+ jsonGenerator.writeStartObject();
+ jsonGenerator.writeFieldName(property_value.getKey());
+ jsonGenerator.writeString(property_value.getValue());
+ jsonGenerator.writeEndObject();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
new file mode 100644
index 0000000..4082612
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -0,0 +1,74 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.testng.annotations.Test;
+
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+
+/**
+ * @author Heiko W. Rupp
+ */
+@Test
+public class OperationJsonTest {
+
+
+ public void operationSerDeserTest() throws Exception{
+
+ List<PROPERTY_VALUE> address=new ArrayList<PROPERTY_VALUE>(2);
+ PROPERTY_VALUE part = new PROPERTY_VALUE("subsystem","web");
+ address.add(part);
+ part = new PROPERTY_VALUE("connector","http");
+ address.add(part);
+
+ NameValuePair payload = new NameValuePair("socket-binding","jndi");
+ Operation operation = new Operation("write-attribute",address,payload);
+
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ String result = mapper.writeValueAsString(operation);
+
+ System.out.println(operation);
+ System.out.println(result);
+
+ Operation op = mapper.readValue(result,Operation.class);
+ assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation();
+ assert op.getName().equals("socket-binding") : "attribute name is " + op.getName();
+ assert op.getValue().equals("jndi") : "attribute value is " + op.getValue();
+
+ }
+
+ public void propertyValueDeserTest() throws Exception {
+
+ String json = "{\"myKey\":\"myValue\"}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ PROPERTY_VALUE pv = mapper.readValue(json,PROPERTY_VALUE.class);
+
+ assert pv.getKey().equals("myKey") : "Key is " + pv.getKey();
+ assert pv.getValue().equals("myValue"): "Value is " + pv.getValue();
+ }
+}
13 years, 1 month
[rhq] modules/core
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java | 3 ---
1 file changed, 3 deletions(-)
New commits:
commit 9dff0af39f538f28833c51ff2ef206328b3bdc8d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Mar 25 23:09:21 2011 -0400
remove link to unavailable package in jdoc
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java
index 5d87a7f..503f729 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java
@@ -26,11 +26,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlEnum;
-import org.rhq.enterprise.server.resource.ResourceManagerRemote;
-
/**
* Used to request the desired diplay format for resource ancestry.
- * @see {@link ResourceManagerRemote#getResourcesAncestry(org.rhq.core.domain.auth.Subject, Integer[], ResourceAncestryFormat)}
*
* @author Jay Shaughnessy
*/
13 years, 1 month
[rhq] modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java | 50 +++
modules/enterprise/server/ear/src/main/resources/alert-email-template.txt | 47 +--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java | 43 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 145 ++++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java | 20 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 23 -
7 files changed, 262 insertions(+), 70 deletions(-)
New commits:
commit 23820b201c04edcec4812d31ad4687abc30bf0ec
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Mar 25 21:48:10 2011 -0400
Resource Ancestry (Disambiguation) Work
- Bug 602178 - Resource hierarchy in alert emails not disambiguated
- Add SLSB support for getting formatted resource ancestry and use this
for disambiguated resource info for alert email text. This also provides
missing support for CLI users that may need formatted ancestry strings.
- Tweaked the alert-email-template.txt to be slightly better formatted (is
this ok to do? Is this file being parsed by users?)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java
new file mode 100644
index 0000000..5d87a7f
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceAncestryFormat.java
@@ -0,0 +1,50 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program 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 General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.resource;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlEnum;
+
+import org.rhq.enterprise.server.resource.ResourceManagerRemote;
+
+/**
+ * Used to request the desired diplay format for resource ancestry.
+ * @see {@link ResourceManagerRemote#getResourcesAncestry(org.rhq.core.domain.auth.Subject, Integer[], ResourceAncestryFormat)}
+ *
+ * @author Jay Shaughnessy
+ */
+@XmlEnum
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public enum ResourceAncestryFormat {
+ /**
+ * <ul>
+ * <li>RAW: The raw, encoded value. This is already provided by the Resource.ancestry field.
+ *
+ * <li>SIMPLE: Short, name only format: (eg. parentName < grandParentName < etc...)
+ *
+ * <li>VERBOSE: Verbose, MultiLine format incorporating name, type and indentation.
+ * </ul>
+ */
+ RAW, SIMPLE, VERBOSE
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/ear/src/main/resources/alert-email-template.txt b/modules/enterprise/server/ear/src/main/resources/alert-email-template.txt
index 40fb2cf..a791933 100644
--- a/modules/enterprise/server/ear/src/main/resources/alert-email-template.txt
+++ b/modules/enterprise/server/ear/src/main/resources/alert-email-template.txt
@@ -1,24 +1,23 @@
-Subject: [ALERT] priority of [@@@PRIORITY@@@] for alert [@@@ALERT_NAME@@@] on resource [@@@RESOURCE_NAME@@@]
-
-The resource @@@RESOURCE_NAME@@@ has generated the following alert:
-
-------------------------------------------
-
-- Resource Name: @@@RESOURCE_NAME@@@
-- Alert Name: @@@ALERT_NAME@@@
-- Alert Severity: @@@PRIORITY@@@
-- Alert Date/Time: @@@TIMESTAMP@@@
-- Conditions: @@@CONDITIONS@@@
-
-------------------------------------------
-
-Resource Hierarchy was:
-
-@@@FULL_RESOURCE_HIERARCHY@@@
-
-
-------------------------------------------
-
-For additional details about this alert, go to @@@ALERT_URL@@@
-
-This message was delivered to you by RHQ.
+Subject: [ALERT] priority of [@@@PRIORITY@@@] for alert [@@@ALERT_NAME@@@] on resource [@@@RESOURCE_NAME@@@]
+
+The resource @@@RESOURCE_NAME@@@ has generated the following alert:
+
+------------------------------------------
+
+Resource Name : @@@RESOURCE_NAME@@@
+Alert Name : @@@ALERT_NAME@@@
+Alert Severity : @@@PRIORITY@@@
+Alert Date/Time : @@@TIMESTAMP@@@
+Conditions: @@@CONDITIONS@@@
+
+------------------------------------------
+
+Resource Ancestry:
+
+@@@FULL_RESOURCE_HIERARCHY@@@
+
+------------------------------------------
+
+For additional details about this alert, go to @@@ALERT_URL@@@
+
+This message was delivered to you by RHQ.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
index d25d1c4..02ae7b1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
@@ -64,6 +64,7 @@ import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceAncestryFormat;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.server.MeasurementConverter;
import org.rhq.core.server.PersistenceUtility;
@@ -727,9 +728,11 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
AlertDefinition alertDefinition = alert.getAlertDefinition();
- Map<String, String> alertMessage = emailManager.getAlertEmailMessage(
- prettyPrintResourceHierarchy(alertDefinition.getResource()), //
- alertDefinition.getResource().getName(), //
+ Resource resource = alertDefinition.getResource();
+ Map<Integer, String> ancestry = resourceManager.getResourcesAncestry(subjectManager.getOverlord(),
+ new Integer[] { resource.getId() }, ResourceAncestryFormat.VERBOSE);
+ Map<String, String> alertMessage = emailManager.getAlertEmailMessage(ancestry.get(resource.getId()), //
+ resource.getName(), //
alertDefinition.getName(), //
alertDefinition.getPriority().toString(), //
new Date(alert.getCtime()).toString(), //
@@ -755,40 +758,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
private static String NEW_LINE = System.getProperty("line.separator");
- private String prettyPrintResourceHierarchy(Resource resource) {
- StringBuilder builder = new StringBuilder();
-
- List<Resource> lineage = resourceManager.getResourceLineage(resource.getId());
-
- int depth = 0;
- for (Resource res : lineage) {
- if (depth == 0) {
- builder.append(" - ");
- } else {
- builder.append(NEW_LINE);
-
- for (int i = 0; i < depth; i++) {
- builder.append(" ");
- }
-
- builder.append("|");
- builder.append(NEW_LINE);
-
- for (int i = 0; i < depth; i++) {
- builder.append(" ");
- }
-
- builder.append("+- ");
- }
-
- builder.append(res.getName());
-
- depth++;
- }
-
- return builder.toString();
- }
-
/**
* Create a human readable description of the conditions that led to this alert.
* @param alert Alert to create human readable condition description
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 384104a..30c2334 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -20,7 +20,9 @@ package org.rhq.enterprise.server.resource;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -66,6 +68,7 @@ import org.rhq.core.domain.content.InstalledPackageHistory;
import org.rhq.core.domain.content.PackageInstallationStep;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSource;
import org.rhq.core.domain.measurement.Availability;
@@ -84,6 +87,7 @@ import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.domain.resource.DeleteResourceHistory;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceAncestryFormat;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.core.domain.resource.ResourceErrorType;
@@ -827,6 +831,147 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return resourceLineage;
}
+ public Map<Integer, String> getResourcesAncestry(Subject subject, Integer[] resourceIds,
+ ResourceAncestryFormat format) {
+ Map<Integer, String> result = new HashMap<Integer, String>(resourceIds.length);
+
+ if (resourceIds.length == 0) {
+ return result;
+ }
+
+ ResourceCriteria resourceCriteria = new ResourceCriteria();
+ resourceCriteria.addFilterIds(resourceIds);
+ resourceCriteria.fetchResourceType(true);
+ List<Resource> resources = findResourcesByCriteria(subject, resourceCriteria);
+
+ if (ResourceAncestryFormat.RAW == format) {
+ for (Resource resource : resources) {
+ result.put(resource.getId(), resource.getAncestry());
+ }
+ return result;
+ }
+
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (Resource resource : resources) {
+ ResourceType type = resource.getResourceType();
+ if (type != null) {
+ typesSet.add(type.getId());
+ }
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(getAncestryTypeIds(ancestries));
+
+ ResourceTypeCriteria resourceTypeCriteria = new ResourceTypeCriteria();
+ resourceTypeCriteria.addFilterIds(typesSet.toArray(new Integer[typesSet.size()]));
+ List<ResourceType> types = typeManager.findResourceTypesByCriteria(subject, resourceTypeCriteria);
+
+ for (Resource resource : resources) {
+ String decodedAncestry = getDecodedAncestry(resource, types, format);
+ result.put(resource.getId(), decodedAncestry);
+ }
+ return result;
+ }
+
+ /**
+ * Get the complete set of resource type Ids in the ancestries provided. This is useful for
+ * being able to load all the types in advance of generating decoded values.
+ *
+ * @return
+ */
+ private HashSet<Integer> getAncestryTypeIds(Collection<String> ancestries) {
+ HashSet<Integer> result = new HashSet<Integer>();
+
+ for (String ancestry : ancestries) {
+ if (null == ancestry) {
+ continue;
+ }
+ String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
+ for (int i = 0; i < ancestryEntries.length; ++i) {
+ String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
+ int rtId = Integer.valueOf(entryTokens[0]);
+ result.add(rtId);
+ }
+ }
+
+ return result;
+ }
+
+ private String getDecodedAncestry(Resource resource, List<ResourceType> typeList, ResourceAncestryFormat format) {
+ String ancestry = resource.getAncestry();
+ StringBuilder sb = new StringBuilder();
+
+ if (ResourceAncestryFormat.VERBOSE != format) {
+ if (null == ancestry) {
+ sb.append("");
+ }
+
+ String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
+ for (int i = 0; i < ancestryEntries.length; ++i) {
+ String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
+ String ancestorName = entryTokens[2];
+
+ sb.append((i > 0) ? " < " : "");
+ sb.append(ancestorName);
+ }
+ } else {
+ Map<Integer, ResourceType> types = new HashMap<Integer, ResourceType>(typeList.size());
+ for (ResourceType type : typeList) {
+ types.put(type.getId(), type);
+ }
+
+ ResourceType type = types.get(resource.getResourceType().getId());
+ String resourceLongName = getResourceLongName(resource.getName(), type);
+
+ // decode ancestry
+ if (null != ancestry) {
+ String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
+ for (int i = ancestryEntries.length - 1, j = 0; i >= 0; --i, ++j) {
+ String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
+ int ancestorTypeId = Integer.valueOf(entryTokens[0]);
+ String ancestorName = entryTokens[2];
+
+ // indent with spaces
+ if (j > 0) {
+ sb.append("\n");
+ for (int k = 0; k < j; ++k) {
+ sb.append(" ");
+ }
+ }
+ type = types.get(ancestorTypeId);
+ sb.append(getResourceLongName(ancestorName, type));
+ }
+
+ // add target resource, indent with spaces
+ sb.append("\n");
+ for (int k = 0; k <= ancestryEntries.length; ++k) {
+ sb.append(" ");
+ }
+ sb.append(resourceLongName);
+
+ } else {
+ // just show the resource name/type info
+ sb.append(resourceLongName);
+ }
+ }
+
+ return sb.toString();
+ }
+
+ private String getResourceLongName(String resourceName, ResourceType type) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(resourceName);
+ sb.append(" [");
+ sb.append(type.getPlugin());
+ sb.append(", ");
+ sb.append(type.getName());
+ sb.append("]");
+
+ return sb.toString();
+ }
+
@NotNull
public Resource getRootResourceForResource(int resourceId) {
Query q = entityManager.createNamedQuery(Resource.QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
index 02b0266..841428b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
@@ -32,6 +32,7 @@ import org.rhq.core.domain.measurement.ResourceAvailability;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceAncestryFormat;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.core.domain.resource.ResourceErrorType;
@@ -506,4 +507,7 @@ public interface ResourceManagerLocal {
List<Integer> findIdsByTypeIds(List<Integer> resourceTypeIds);
Integer getResourceCount(List<Integer> resourceTypeIds);
+
+ Map<Integer, String> getResourcesAncestry(Subject subject, Integer[] resourceIds, ResourceAncestryFormat format);
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java
index 46b8e08..9d1c269 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.resource;
import java.util.List;
+import java.util.Map;
import javax.ejb.Remote;
import javax.jws.WebMethod;
@@ -31,6 +32,7 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.ResourceAvailability;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceAncestryFormat;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.jaxb.adapter.ResourceListAdapter;
@@ -138,4 +140,22 @@ public interface ResourceManagerRemote {
Resource getParentResource( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "resourceId") int resourceId);
+
+ /**
+ * Resource.ancestry is an encoded value that holds the resource's parental ancestry. It is not suitable for display.
+ * This method can be used to get decoded and formatted ancestry values for a set of resources. A typical usage
+ * would a criteria resource fetch, and then a subsequent call to this method for ancestry display, potentially
+ * for resource disambiguation purposes.
+ *
+ * @param subject
+ * @param resourceIds
+ * @param format
+ * @return A Map of ResourceIds to FormattedAncestryStrings, one entry for each unique, valid, resourceId passed in.
+ */
+ @WebMethod
+ Map<Integer, String> getResourcesAncestry( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceIds") Integer[] resourceIds, //
+ @WebParam(name = "format") ResourceAncestryFormat format);
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 3a4910b..e06d5ae 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -25,7 +25,6 @@ package org.rhq.enterprise.server.webservices;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
-import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -115,6 +114,7 @@ import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.domain.resource.DeleteResourceHistory;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceAncestryFormat;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -517,12 +517,12 @@ public class WebservicesManagerBean implements WebservicesRemote {
public PackageType findPackageType(Subject subject, Integer resourceTypeId, String packageTypeName) {
return contentManager.findPackageType(subject, resourceTypeId, packageTypeName);
}
-
+
public PackageTypeAndVersionFormatComposite findPackageTypeWithVersionFormat(Subject subject,
Integer resourceTypeId, String packageTypeName) {
return contentManager.findPackageTypeWithVersionFormat(subject, resourceTypeId, packageTypeName);
}
-
+
public InstalledPackage getBackingPackageForResource(Subject subject, int resourceId) {
return contentManager.getBackingPackageForResource(subject, resourceId);
}
@@ -533,15 +533,15 @@ public class WebservicesManagerBean implements WebservicesRemote {
public PageList<Package> findPackagesByCriteria(Subject subject, PackageCriteria criteria) {
checkParametersPassedIn(subject, criteria);
- return contentManager.findPackagesByCriteria(subject, criteria);
+ return contentManager.findPackagesByCriteria(subject, criteria);
}
-
+
public PageList<PackageAndLatestVersionComposite> findPackagesWithLatestVersion(Subject subject,
PackageCriteria criteria) {
checkParametersPassedIn(subject, criteria);
- return contentManager.findPackagesWithLatestVersion(subject, criteria);
+ return contentManager.findPackagesWithLatestVersion(subject, criteria);
}
-
+
//CONTENTMANAGER: END ----------------------------------
// //DATAACCESSMANAGER: BEGIN ----------------------------------
@@ -807,11 +807,11 @@ public class WebservicesManagerBean implements WebservicesRemote {
public PackageVersion getLatestPackageVersion(Subject subject, int packageId, int repoId) {
return repoManager.getLatestPackageVersion(subject, packageId, repoId);
}
-
+
public boolean deletePackageVersionsFromRepo(Subject subject, int repoId, int[] packageVersionIds) {
return repoManager.deletePackageVersionsFromRepo(subject, repoId, packageVersionIds);
}
-
+
public PageList<Resource> findSubscribedResources(Subject subject, int repoId, PageControl pc) {
return repoManager.findSubscribedResources(subject, repoId, pc);
}
@@ -911,6 +911,11 @@ public class WebservicesManagerBean implements WebservicesRemote {
return resourceManager.getResource(subject, resourceId);
}
+ public Map<Integer, String> getResourcesAncestry(Subject subject, Integer[] resourceIds,
+ ResourceAncestryFormat format) {
+ return resourceManager.getResourcesAncestry(subject, resourceIds, format);
+ }
+
public List<Integer> uninventoryResources(Subject subject, int[] resourceIds) {
return resourceManager.uninventoryResources(subject, resourceIds);
}
13 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 33 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java | 187 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 6
6 files changed, 178 insertions(+), 78 deletions(-)
New commits:
commit 3e764d153948be8b0d7b9d25e58947caa14295ca
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 25 18:23:16 2011 -0400
be able to clear out ResourcErrors for a particular resource.
This is needed because I'm seeing instances where I get ResourcErrors in the database that never go away, even after the plugin can later successfully connect and monitor the resource.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index 72be13d..921b82d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -59,6 +59,8 @@ public interface ResourceGWTService extends RemoteService {
List<ResourceError> findResourceErrors(int resourceId) throws RuntimeException;
+ void deleteResourceErrors(int[] resourceErrorIds) throws RuntimeException;
+
PageList<ProblemResourceComposite> findProblemResources(long ctime, int maxItems) throws RuntimeException;
Resource getPlatformForResource(int resourceId) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index 1046f31..7bc1cdd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -204,25 +204,25 @@ public class ResourceTitleBar extends LocatableVLayout {
winModal.setWidth("70%");
winModal.setHeight("70%");
winModal.setIsModal(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
winModal.centerInPage();
- winModal.setTitle(MSG.common_title_component_errors() + ":");
+ winModal.setTitle(MSG.common_title_component_errors());
LocatableVLayout form = new LocatableVLayout(extendLocatorId("_Modal_Form"));
form.setAlign(VerticalAlignment.CENTER);
- form.setLayoutMargin(20);
+ form.setLayoutMargin(10);
form.setWidth100();
- form.setHeight("40%");
- ResourceErrorsView errorsGrid = new ResourceErrorsView(extendLocatorId("errors"), MSG
- .view_summaryOverview_header_detectedErrors(), null, null,
- new String[] { ResourceErrorsDataSource.Field.DETAIL });
- errorsGrid.setWidth100();
- errorsGrid.setHeight("400");
+ form.setHeight100();
Resource resource = resourceComposite.getResource();
ResourceErrorsDataSource errors = new ResourceErrorsDataSource(resource.getId());
- errorsGrid.setShowFooter(false);
+ ResourceErrorsView errorsGrid = new ResourceErrorsView(extendLocatorId("errors"), MSG
+ .view_summaryOverview_header_detectedErrors(), null, null,
+ new String[] { ResourceErrorsDataSource.Field.DETAIL });
errorsGrid.setDataSource(errors);
+
form.addMember(errorsGrid);
winModal.addItem(form);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
index 5999e14..be76956 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
@@ -27,10 +27,6 @@ import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceDateTimeField;
-import com.smartgwt.client.data.fields.DataSourceEnumField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -42,22 +38,20 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
- *
* @author Lukas Krejci
* @author Simeon Pinder
+ * @author John Mazzitelli
*/
public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Criteria> {
public static abstract class Field {
+ public static final String ID = "id";
public static final String SUMMARY = "summary";
public static final String DETAIL = "detail";
public static final String ERROR_TYPE = "errorType";
public static final String TIME_OCCURED = "timeOccured";
- public static final String ICON = "icon";
}
- private static final String ERROR_ICON = "[SKIN]/Dialog/warn.png";
-
ResourceGWTServiceAsync resourceService;
int resourceId;
@@ -69,25 +63,6 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Crite
}
@Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- fields.add(new DataSourceEnumField(Field.ERROR_TYPE, MSG.dataSource_resourceErrors_field_errorType()));
- fields.add(new DataSourceDateTimeField(Field.TIME_OCCURED, MSG.dataSource_resourceErrors_field_timeOccured()));
- fields.add(new DataSourceTextField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary()));
- DataSourceTextField details = new DataSourceTextField(Field.DETAIL, MSG
- .dataSource_resourceErrors_field_detail());
- details.setHidden(true);//won't be displaying this value directly in the listgrid
- fields.add(details);
- fields.add(new DataSourceImageField(Field.ICON, MSG.dataSource_resourceErrors_field_detail()));
-
- return fields;
- }
-
- /* (non-Javadoc)
- * @see org.rhq.enterprise.gui.coregui.client.util.RPCDataSource#executeFetch(com.smartgwt.client.data.DSRequest, com.smartgwt.client.data.DSResponse)
- */
- @Override
protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
resourceService.findResourceErrors(resourceId, new AsyncCallback<List<ResourceError>>() {
public void onFailure(Throwable caught) {
@@ -110,16 +85,18 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Crite
return null;
}
+ @Override
public ResourceError copyValues(Record from) {
//This is read-only datasource, so no need to implement this.
return null;
}
+ @Override
public ListGridRecord copyValues(ResourceError from) {
ListGridRecord record = new ListGridRecord();
+ record.setAttribute(Field.ID, from.getId());
record.setAttribute(Field.DETAIL, from.getDetail());
- record.setAttribute(Field.ICON, ERROR_ICON);
record.setAttribute(Field.ERROR_TYPE, from.getErrorType().name());
record.setAttribute(Field.SUMMARY, from.getSummary());
record.setAttribute(Field.TIME_OCCURED, new Date(from.getTimeOccurred()));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
index 0309602..1c75bcc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
@@ -1,80 +1,189 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.AutoFitWidthApproach;
+import com.smartgwt.client.types.DateDisplayFormat;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsDataSource.Field;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-public class ResourceErrorsView extends Table {
+public class ResourceErrorsView extends Table<ResourceErrorsDataSource> {
+ private static final String ERROR_ICON = "[SKIN]/Dialog/warn.png";
+
public ResourceErrorsView(String locatorId, String string, Criteria criteria, Object object, String[] strings) {
super(locatorId, MSG.common_title_component_errors(), criteria);
+ setWidth100();
+ setHeight100();
+ setShowHeader(false);
+ }
+
+ @Override
+ protected SelectionStyle getDefaultSelectionStyle() {
+ return SelectionStyle.MULTIPLE;
}
- /** Set order and width of table display
- */
@Override
protected void configureTable() {
- getListGrid().getField(ResourceErrorsDataSource.Field.ERROR_TYPE).setWidth("20%");
- getListGrid().getField(ResourceErrorsDataSource.Field.TIME_OCCURED).setWidth("15%");
- getListGrid().getField(ResourceErrorsDataSource.Field.SUMMARY).setWidth("30%");
- //modify icon display listgrid element
- ListGridField iconField = getListGrid().getField(ResourceErrorsDataSource.Field.ICON);
- iconField.setWidth("35%");
- //add action on click of cell
+ ListGridField errorTypeField = new ListGridField(Field.ERROR_TYPE, MSG
+ .dataSource_resourceErrors_field_errorType());
+ errorTypeField.setAlign(Alignment.CENTER);
+ errorTypeField.setAutoFitWidth(true);
+ errorTypeField.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
+
+ ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG
+ .dataSource_resourceErrors_field_timeOccured());
+ timeField.setType(ListGridFieldType.DATE);
+ timeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
+ timeField.setAlign(Alignment.CENTER);
+ timeField.setWidth("20%");
+
+ ListGridField summaryField = new ListGridField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary());
+ summaryField.setAlign(Alignment.CENTER);
+ summaryField.setCellAlign(Alignment.LEFT);
+ summaryField.setWidth("*");
+
+ ListGridField iconField = new ListGridField("icon");
+ iconField.setType(ListGridFieldType.ICON);
+ iconField.setAlign(Alignment.CENTER);
+ iconField.setIcon(ERROR_ICON);
+ iconField.setCellIcon(ERROR_ICON);
+ iconField.setWidth("50");
+ iconField.setCanSort(false);
iconField.addRecordClickHandler(new RecordClickHandler() {
@Override
public void onRecordClick(RecordClickEvent event) {
- final Window winModal = new LocatableWindow(extendLocatorId("errorDetailsWin"));
- winModal.setTitle(MSG.common_title_component_errors());
- winModal.setOverflow(Overflow.VISIBLE);
- winModal.setShowMinimizeButton(false);
- winModal.setShowMaximizeButton(true);
- winModal.setIsModal(true);
- winModal.setShowModalMask(true);
- winModal.setAutoSize(true);
- winModal.setAutoCenter(true);
- winModal.setShowResizer(true);
- winModal.setCanDragResize(true);
- winModal.centerInPage();
- winModal.addCloseClickHandler(new CloseClickHandler() {
- @Override
- public void onCloseClick(CloseClientEvent event) {
- winModal.markForDestroy();
- }
- });
-
- LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("errorDetailsPane"));
- htmlPane.setMargin(10);
- htmlPane.setDefaultWidth(550);
- htmlPane.setDefaultHeight(550);
- htmlPane.setContents((event.getRecord().getAttribute(ResourceErrorsDataSource.Field.DETAIL)));
- winModal.addItem(htmlPane);
- winModal.show();
+ String details = event.getRecord().getAttribute(Field.DETAIL);
+ popupDetails(details);
}
});
iconField.setShowHover(true);
- //show some details in mouseOver
iconField.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- String html = record.getAttribute(ResourceErrorsDataSource.Field.DETAIL);
+ String html = record.getAttribute(Field.DETAIL);
if (html.length() > 80) {
// this was probably an error stack trace, snip it so the tooltip isn't too big
html = "<pre>" + html.substring(0, 80) + "...</pre><p>"
- + MSG.view_group_pluginConfig_table_clickStatusIcon() + "</p>";
+ + MSG.dataSource_resourceErrors_clickStatusIcon() + "</p>";
}
return html;
}
});
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length > 0) {
+ String details = selectedRows[0].getAttribute(Field.DETAIL);
+ popupDetails(details);
+ }
+ }
+ });
+
+ setListGridFields(errorTypeField, timeField, summaryField, iconField);
+
+ addTableAction(extendLocatorId("delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
+ new AbstractTableAction(TableActionEnablement.ANY) {
+ @Override
+ public void executeAction(final ListGridRecord[] selection, Object actionValue) {
+ if (selection == null || selection.length == 0) {
+ return;
+ }
+ int[] resourceErrorIds = new int[selection.length];
+ int i = 0;
+ for (ListGridRecord record : selection) {
+ resourceErrorIds[i++] = record.getAttributeAsInt(Field.ID);
+ }
+ GWTServiceLookup.getResourceService().deleteResourceErrors(resourceErrorIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ Message msg = new Message(MSG.dataSource_resourceErrors_deleteSuccess(String
+ .valueOf(selection.length)), Severity.Info);
+ CoreGUI.getMessageCenter().notify(msg);
+ refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_resourceErrors_deleteFailure(),
+ caught);
+ }
+ });
+ }
+ });
+ }
+
+ private void popupDetails(String details) {
+ final Window winModal = new LocatableWindow(extendLocatorId("errorDetailsWin"));
+ winModal.setTitle(MSG.common_title_component_errors());
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setShowMaximizeButton(true);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("errorDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(700);
+ htmlPane.setDefaultHeight(500);
+ htmlPane.setContents("<pre>" + details + "</pre>");
+ winModal.addItem(htmlPane);
+ winModal.show();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 7b32034..13fc75a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -314,6 +314,16 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
}
}
+ public void deleteResourceErrors(int[] resourceErrorIds) throws RuntimeException {
+ try {
+ for (int doomedId : resourceErrorIds) {
+ resourceManager.deleteResourceError(getSessionSubject(), doomedId);
+ }
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
public Resource manuallyAddResource(int resourceTypeId, int parentResourceId, Configuration pluginConfiguration)
throws RuntimeException {
try {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 8317263..35ff92d 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -108,7 +108,7 @@ common_title_columns = Columns
common_title_configuration = Configuration
common_title_compatibleGroups = Compatible Groups
common_title_compatibleGroups_total = Compatible Group Total
-common_title_component_errors = Component errors
+common_title_component_errors = Component Errors
common_title_count = Count
common_title_custom = Custom
common_title_dashboard_name = Dashboard Name
@@ -563,10 +563,12 @@ dataSource_configurationHistory_error_fetchFailure = Unable to load configuratio
# Resource Errors
#-------------------------
dataSource_resourceErrors_field_summary = Summary
-dataSource_resourceErrors_field_detail = Detailed Message
dataSource_resourceErrors_field_errorType = Error Type
dataSource_resourceErrors_field_timeOccured = Time
dataSource_resourceErrors_error_fetchFailure = Failed to find Resource errors for Resource with id [{0}].
+dataSource_resourceErrors_clickStatusIcon = Click the icon for more details
+dataSource_resourceErrors_deleteSuccess = You have successfully deleted [{0}] resource error messages.
+dataSource_resourceErrors_deleteFailure = Failed to delete resource errors
# Template Schedules
#-------------------------
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 92 ++++------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
3 files changed, 47 insertions(+), 50 deletions(-)
New commits:
commit 5e00d3c76b16f5e2f1e8c26467c3c1599add8e1c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 25 17:16:06 2011 -0400
make sure config editor renders everything appropriately when in read-only mode (https://bugzilla.redhat.com/show_bug.cgi?id=680233)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 9765188..449e9c3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -344,10 +344,6 @@ public class ConfigurationEditor extends LocatableVLayout {
}
public void reload() {
- /*if (this.loaded && !this.reloadable) {
- return;
- }*/
-
if (this.configurationDefinition == null || this.configuration == null) {
// Wait for both to load.
return;
@@ -364,13 +360,7 @@ public class ConfigurationEditor extends LocatableVLayout {
if (configurationDefinition.getConfigurationFormat() == ConfigurationFormat.STRUCTURED
|| configurationDefinition.getConfigurationFormat() == ConfigurationFormat.STRUCTURED_AND_RAW) {
Log.info("Building structured configuration editor...");
- LocatableVLayout structuredConfigLayout = null;
- try {
- structuredConfigLayout = buildStructuredPane();
- } catch (RuntimeException e) {
- e.printStackTrace();
- throw e;
- }
+ LocatableVLayout structuredConfigLayout = buildStructuredPane();
addMember(structuredConfigLayout);
} else {
Label label = new Label("Structured configuration is not supported.");
@@ -1267,7 +1257,9 @@ public class ConfigurationEditor extends LocatableVLayout {
FormItem valueItem = null;
boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple, propertySimple);
- if (propertyIsReadOnly) {
+ // TODO (ips, 03/25/11): We eventually want to use StaticTextItems for read-only PASSWORD props too, but we have
+ // to wait until we implement masking/unmasking of PASSWORD props at the SLSB layer first.
+ if (propertyIsReadOnly && propertyDefinitionSimple.getType() != PropertySimpleType.PASSWORD) {
valueItem = new StaticTextItem();
} else {
List<PropertyDefinitionEnumeration> enumeratedValues = propertyDefinitionSimple.getEnumeratedValues();
@@ -1319,7 +1311,7 @@ public class ConfigurationEditor extends LocatableVLayout {
}
}
- valueItem.setDisabled(isUnset(propertyDefinitionSimple, propertySimple));
+ valueItem.setDisabled(propertyIsReadOnly || isUnset(propertyDefinitionSimple, propertySimple));
List<Validator> validators = buildValidators(propertyDefinitionSimple, propertySimple);
valueItem.setValidators(validators.toArray(new Validator[validators.size()]));
@@ -1348,7 +1340,7 @@ public class ConfigurationEditor extends LocatableVLayout {
valueItem.setWidth(220);
/*
- Click handlers seem to be turned off for disabled fields... need an alternative
+ TODO: Click handlers seem to be turned off for disabled fields... need to find an alternative.
valueItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
com.allen_sauer.gwt.log.client.Log.info("Click in value field");
@@ -1532,7 +1524,7 @@ public class ConfigurationEditor extends LocatableVLayout {
private void displayMapEditor(final ListGrid summaryTable, final PropertyMapListGridRecord existingRecord,
PropertyDefinitionMap definition, final PropertyList list, final PropertyMap map,
- boolean mapReadOnly) {
+ final boolean mapReadOnly) {
final List<PropertyDefinition> memberDefinitions = new ArrayList<PropertyDefinition>(definition
.getPropertyDefinitions().values());
@@ -1542,7 +1534,8 @@ public class ConfigurationEditor extends LocatableVLayout {
final PropertyMap workingMap = (newRow) ? new PropertyMap(definition.getName()) : map.deepCopy(true);
final LocatableWindow popup = new LocatableWindow(extendLocatorId("MapEditor"));
- popup.setTitle(MSG.view_configEdit_editRow());
+ String title = (mapReadOnly) ? MSG.view_configEdit_viewRow() : MSG.view_configEdit_editRow();
+ popup.setTitle(title);
popup.setWidth(800);
popup.setHeight(600);
popup.setIsModal(true);
@@ -1568,31 +1561,33 @@ public class ConfigurationEditor extends LocatableVLayout {
}
okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- if (!childForm.validate()) {
- okButton.disable();
- return;
- }
- if (newRow) {
- try {
- list.add(workingMap);
- int index = list.getList().size() - 1;
- PropertyMapListGridRecord record = new PropertyMapListGridRecord(workingMap, index,
- memberDefinitions);
- summaryTable.addData(record);
- } catch (Exception e) {
- e.printStackTrace();
+ if (!mapReadOnly) {
+ if (!childForm.validate()) {
+ okButton.disable();
+ return;
}
- } else {
- try {
- mergePropertyMap(workingMap, map, memberDefinitions);
- existingRecord.refresh();
- summaryTable.updateData(existingRecord);
- } catch (Exception e) {
- e.printStackTrace();
+ if (newRow) {
+ try {
+ list.add(workingMap);
+ int index = list.getList().size() - 1;
+ PropertyMapListGridRecord record = new PropertyMapListGridRecord(workingMap, index,
+ memberDefinitions);
+ summaryTable.addData(record);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ mergePropertyMap(workingMap, map, memberDefinitions);
+ existingRecord.refresh();
+ summaryTable.updateData(existingRecord);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
+ firePropertyChangedEvent(list, null, true);
+ summaryTable.redraw();
}
- firePropertyChangedEvent(list, null, true);
- summaryTable.redraw();
layout.destroy();
popup.destroy();
@@ -1608,20 +1603,21 @@ public class ConfigurationEditor extends LocatableVLayout {
okButton.setDisabled(false);
}
});
+ buttonBar.addMember(okButton);
- final IButton cancelButton = new LocatableIButton(buttonBar.extendLocatorId("Cancel"), MSG.common_button_cancel());
- cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- layout.destroy();
- popup.destroy();
- }
- });
+ if (!mapReadOnly) {
+ final IButton cancelButton = new LocatableIButton(buttonBar.extendLocatorId("Cancel"), MSG.common_button_cancel());
+ cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ layout.destroy();
+ popup.destroy();
+ }
+ });
+ buttonBar.addMember(cancelButton);
+ }
- buttonBar.setMembers(okButton, cancelButton);
layout.addMember(buttonBar);
-
popup.addItem(layout);
-
popup.show();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
index 08c94d7..a080f13 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
@@ -226,7 +226,7 @@ public abstract class TestConfigurationFactory {
string2Prop.setErrorMessage("illegal value!");
configuration.put(string2Prop);
configuration.put(new PropertySimple("LongString", "blah blah blah\nblah blah blah"));
- configuration.put(new PropertySimple("Password", null));
+ configuration.put(new PropertySimple("Password", "ou812"));
configuration.put(new PropertySimple("Boolean", false));
configuration.put(new PropertySimple("Integer", 666));
configuration.put(new PropertySimple("Float", Math.PI));
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index df17ca8..8317263 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1332,7 +1332,8 @@ view_configEdit_addItem = Add Item to List
view_configEdit_confirm_1 = Are you sure you want to delete the selected properties from the set?
view_configEdit_confirm_2 = Are you sure you want to delete this row?
view_configEdit_confirm_3 = Are you sure you want to delete the [{0}] selected [{1}]?
-view_configEdit_editRow = Edit Configuration Row
+view_configEdit_viewRow = View Row
+view_configEdit_editRow = Edit Row
view_configEdit_enterPropName = Enter the name of the property to be added.
view_configEdit_error_1 = Configuration is not supported by this Resource.
view_configEdit_error_2 = Connection settings are not supported by this Resource.
13 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 3 ++-
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
New commits:
commit c6af7b79622870ece640027f06c0f1a40ee30f8e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 25 16:03:02 2011 -0400
BZ 675153 - fix confirm message
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 9958d0c..c113008 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -144,7 +144,8 @@ public class ConditionsEditor extends LocatableVLayout {
});
table.addTableAction(this.extendLocatorId("delete"), MSG.common_button_delete(), MSG
- .view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
+ .view_alert_definition_condition_editor_delete_confirm(), new AbstractTableAction(
+ TableActionEnablement.ANY) {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
for (ListGridRecord record : selection) {
AlertCondition cond = getDataSource().copyValues(record);
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index b8ce183..df17ca8 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -991,6 +991,7 @@ view_alert_definition_condition_editor_event_regex_tooltip = If specified, this
view_alert_definition_condition_editor_common_min = Minimum
view_alert_definition_condition_editor_common_avg = Average
view_alert_definition_condition_editor_common_max = Maximum
+view_alert_definition_condition_editor_delete_confirm = Delete the selected alert condition(s)?
view_alert_definition_notification_editor_title_add = Add Notification
view_alert_definition_notification_editor_title_edit = Edit Notification
view_alert_definition_notification_editor_sender = Notification Sender
13 years, 1 month
[rhq] 2 commits - modules/core modules/enterprise
by ips
modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java | 27 +++++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 3 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java | 1
4 files changed, 26 insertions(+), 7 deletions(-)
New commits:
commit d0bfc008ba20e4128377901b743d5680ff7f1bf3
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 25 14:58:58 2011 -0400
misc minor
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index c68da84..9765188 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -1267,12 +1267,9 @@ public class ConfigurationEditor extends LocatableVLayout {
FormItem valueItem = null;
boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple, propertySimple);
-
if (propertyIsReadOnly) {
valueItem = new StaticTextItem();
} else {
-
-
List<PropertyDefinitionEnumeration> enumeratedValues = propertyDefinitionSimple.getEnumeratedValues();
if (enumeratedValues != null && !enumeratedValues.isEmpty()) {
LinkedHashMap<String, String> valueOptions = new LinkedHashMap<String, String>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
index 80d6269..4c4a29f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
@@ -284,7 +284,6 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
setAllItems.add(canvasItem);
masterValueItem.addChangedHandler(new ChangedHandler() {
- @Override
public void onChanged(ChangedEvent changedEvent) {
applyButton.enable();
applyButton.focus();
@@ -292,7 +291,6 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
});
masterUnsetItem.addChangedHandler(new ChangedHandler() {
- @Override
public void onChanged(ChangedEvent changedEvent) {
applyButton.enable();
applyButton.focus();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
index 2ce842f..8713ecc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
@@ -217,6 +217,7 @@ public class WizardView extends LocatableVLayout {
// a valid step, continue
currentStep = stepIndex;
+ // TODO: i18n
stepLabel.setContents("Step " + (stepIndex + 1) + " of " + wizardSteps.size());
stepLabel.setWrap(false);
commit 5e63bfc1dd1b13a34196b011f1820b0d93b1d99d
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 25 14:58:36 2011 -0400
support plugin JARs whose MANIFEST.MF is not the 2nd entry of the JAR (fix for https://bugzilla.redhat.com/show_bug.cgi?id=682116)
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java
index ecaa80b..fbefc1d 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,8 @@
*/
package org.rhq.core.clientapi.descriptor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.Help;
@@ -29,6 +31,8 @@ import org.rhq.core.util.MessageDigestGenerator;
import java.net.URL;
import java.io.IOException;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.util.jar.Attributes;
@@ -38,6 +42,8 @@ import java.util.jar.Attributes;
*/
public class PluginTransformer {
+ private static final Log LOG = LogFactory.getLog(PluginTransformer.class);
+
/**
* Takes the given plugin descriptor and plugin JAR file URL and converts them into a
* {@link org.rhq.core.domain.plugin.Plugin} object. This method does not set the <code>content</code> property
@@ -112,8 +118,24 @@ public class PluginTransformer {
private String getVersionFromPluginJarManifest(URL pluginJarUrl) throws IOException {
JarInputStream jarInputStream = new JarInputStream(pluginJarUrl.openStream());
- jarInputStream.close();
Manifest manifest = jarInputStream.getManifest();
+ if (manifest == null) {
+ // BZ 682116 (ips, 03/25/11): The manifest file is not in the standard place as the 2nd entry of the JAR,
+ // but we want to be flexible and support JARs that have a manifest file somewhere else, so scan the entire
+ // JAR for one.
+ JarEntry jarEntry;
+ while((jarEntry = jarInputStream.getNextJarEntry()) != null) {
+ if (JarFile.MANIFEST_NAME.equalsIgnoreCase(jarEntry.getName())) {
+ manifest = new Manifest(jarInputStream);
+ break;
+ }
+ }
+ }
+ try {
+ jarInputStream.close();
+ } catch (IOException e) {
+ LOG.error("Failed to close plugin jar input stream for plugin jar [" + pluginJarUrl + "].", e);
+ }
if (manifest != null) {
Attributes attributes = manifest.getMainAttributes();
return attributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
@@ -121,4 +143,5 @@ public class PluginTransformer {
return null;
}
}
+
}
13 years, 1 month