[rhq] 8 commits - modules/plugins
by Simeon Pinder
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 54 +++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java | 78 +++++++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java | 6
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java | 55 +++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java | 1
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 47 ++++--
6 files changed, 179 insertions(+), 62 deletions(-)
New commits:
commit 372c772cfec9ac3cda5d70e30c5e8ee773d63950
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 31 19:52:43 2012 -0400
Move plugin configuration exception code into IOException block to correctly detects unauthorized/401
since the exception handling behavior has been modified.
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 e87c68f..c024db7 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
@@ -156,7 +156,7 @@ public class ASConnection {
// This most likely just means the server is down.
if (log.isDebugEnabled()) {
log.debug("Failed to open connection to [" + urlString + "] in order to invoke [" + operation + "]: "
- + e);
+ + e);
}
// TODO (ips): Would it make more sense to return null here, since we didn't even connect?
Result failure = new Result();
@@ -182,7 +182,8 @@ public class ASConnection {
if ((operation != null) && (operation.getAddress() != null) && operation.getAddress().getPath() != null) {
if (containsSpaces(operation.getAddress().getPath())) {
Result noResult = new Result();
- String outcome = "- Path '" + operation.getAddress().getPath() + "' is invalid as it contains spaces -";
+ String outcome = "- Path '" + operation.getAddress().getPath()
+ + "' is invalid as it contains spaces -";
if (verbose) {
log.error(outcome);
}
@@ -229,22 +230,6 @@ public class ASConnection {
}
return operationResult;
- } else {
- // Empty response body - probably some sort of error - check the response code.
- int responseCode = conn.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
- if (log.isDebugEnabled()) {
- log.debug("Response to " + operation + " was empty and response code was " + responseCode + " "
- + conn.getResponseMessage() + " - throwing InvalidPluginConfigurationException...");
- }
- // Throw a InvalidPluginConfigurationException, so the user will get a yellow plugin connection
- // warning message in the GUI.
- throw new InvalidPluginConfigurationException(
- "Credentials for plugin to connect to AS7 management interface are invalid - update Connection Settings with valid credentials.");
- } else {
- log.warn("Response body for " + operation + " was empty and response code was " + responseCode + " ("
- + conn.getResponseMessage() + ").");
- }
}
} catch (IllegalArgumentException iae) {
log.error("Illegal argument for input " + operation + ": " + iae.getMessage());
@@ -273,11 +258,28 @@ public class ASConnection {
String responseCodeString;
try {
responseCodeString = conn.getResponseCode() + " (" + conn.getResponseMessage() + ")";
+
+ // Process response code to generate plugin configuration exception and/or logging
+ int responseCode = conn.getResponseCode();
+ if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
+ if (log.isDebugEnabled()) {
+ log.debug("Response to " + operation + " was " + responseCode + " " + conn.getResponseMessage()
+ + " - throwing InvalidPluginConfigurationException...");
+ }
+ // Throw a InvalidPluginConfigurationException, so the user will get a yellow plugin connection
+ // warning message in the GUI.
+ throw new InvalidPluginConfigurationException(
+ "Credentials for plugin to connect to AS7 management interface are invalid - update Connection Settings with valid credentials.");
+ } else {
+ log.warn("Response body for " + operation + " was empty and response code was " + responseCode
+ + " (" + conn.getResponseMessage() + ").");
+ }
+
} catch (IOException ioe) {
responseCodeString = "unknown response code";
}
String failureDescription = operation + " failed with " + responseCodeString + " - response body was ["
- + responseBody + "].";
+ + responseBody + "].";
log.error(failureDescription, e);
JsonNode operationResult = null;
@@ -331,7 +333,7 @@ public class ASConnection {
* @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean)
*/
public Result execute(Operation op) {
- return execute(op, false,10);
+ return execute(op, false, 10);
}
/**
@@ -342,8 +344,8 @@ public class ASConnection {
* @return Result of the execution
* @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean)
*/
- public Result execute(Operation op,int timeoutSec) {
- return execute(op, false,timeoutSec);
+ public Result execute(Operation op, int timeoutSec) {
+ return execute(op, false, timeoutSec);
}
/**
@@ -354,7 +356,7 @@ public class ASConnection {
* @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean)
*/
public ComplexResult executeComplex(Operation op) {
- return (ComplexResult) execute(op, true,10);
+ return (ComplexResult) execute(op, true, 10);
}
/**
@@ -365,8 +367,8 @@ public class ASConnection {
* @return ComplexResult of the execution
* @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean)
*/
- public ComplexResult executeComplex(Operation op,int timeoutSec) {
- return (ComplexResult) execute(op, true,timeoutSec);
+ public ComplexResult executeComplex(Operation op, int timeoutSec) {
+ return (ComplexResult) execute(op, true, timeoutSec);
}
/**
@@ -390,7 +392,7 @@ public class ASConnection {
* @return ComplexResult of the execution
*/
public Result execute(Operation op, boolean isComplex, int timeoutSec) {
- JsonNode node = executeRaw(op,timeoutSec);
+ JsonNode node = executeRaw(op, timeoutSec);
if (node == null) {
log.warn("Operation [" + op + "] returned null");
commit d09955b381a700a9fa97a457d6c8d6cea6853728
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 31 18:53:57 2012 -0400
Add WebServiceComponent class.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java
new file mode 100644
index 0000000..0dea886
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java
@@ -0,0 +1,55 @@
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Support for Webservices subsystem.
+ *
+ * @author Simeon Pinder
+ */
+public class WebservicesComponent extends BaseComponent implements OperationFacet, ConfigurationFacet {
+
+ @Override
+ public Configuration loadResourceConfiguration() throws Exception {
+ Configuration config = super.loadResourceConfiguration();
+
+ return config;
+ }
+
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+
+ super.updateResourceConfiguration(report);
+ }
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
+ Operation op = new Operation(name, getAddress());
+ OperationResult operationResult = new OperationResult();
+ Result result = null;
+
+ if ("list-proxies".equals(name)) {
+
+ } else {
+ /*
+ * This is a catch all for operations that are not explicitly treated above.
+ */
+ result = getASConnection().execute(op);
+ if (result.isSuccess()) {
+ operationResult.setSimpleResult("Success");
+ }
+ }
+
+ if (!result.isSuccess()) {
+ operationResult.setErrorMessage(result.getFailureDescription());
+ }
+
+ return operationResult;
+ }
+}
commit 53b98bcc3526825d3a9ec431f197e5e1c2433c3d
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 31 18:37:20 2012 -0400
Remove duplicate ThreadPool and Cache elements from plugin descriptor.
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 429a395..19b992d 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
@@ -3024,7 +3024,7 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="in-vm-remote-interface-invocation-pass-by-value" required="false" type="boolean" readOnly="false" defaultValue="true" description="If set to false, the parameters to invocations on remote interface of an EJB, will be passed by reference. Else, the parameters will be passed by value. The default value is true."/>
</resource-configuration>
- <service name="ThreadPool"
+<!-- <service name="ThreadPool"
discovery="SubsystemDiscovery"
class="BaseComponent"
description="A thread pool executor with an unbounded queue. Such a thread pool has a core size and a queue with no upper bound. When a task is submitted, if the number of running threads is less than the core size, a new thread is created. Otherwise, the task is placed in queue. If too many tasks are allowed to be submitted to this type of executor, an out of memory condition may occur.">
@@ -3051,7 +3051,7 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="name" required="false" type="string" readOnly="true" description="The name of the thread pool."/>
<c:simple-property name="thread-factory" required="false" type="string" readOnly="false" description="Specifies the name of a specific thread factory to use to create worker threads. If not defined an appropriate default thread factory will be used."/>
</resource-configuration>
- </service>
+ </service>-->
<service name="FilePassivationStore"
discovery="SubsystemDiscovery"
@@ -3089,7 +3089,7 @@ working area for individual server instances</li></ul>"/>
</resource-configuration>
</service>
- <service name="Cache"
+<!-- <service name="Cache"
discovery="SubsystemDiscovery"
class="BaseComponent"
description="A SFSB cache.">
@@ -3104,7 +3104,7 @@ working area for individual server instances</li></ul>"/>
</c:list-property>
<c:simple-property name="passivation-store" required="false" type="string" readOnly="false" description="The passivation store used by this cache"/>
</resource-configuration>
- </service>
+ </service>-->
<service name="ClusterPassivationStore"
discovery="SubsystemDiscovery"
commit 4bd1f66b32291238b3300064ab13a6f1ab9f367e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 31 13:33:33 2012 -0400
fix invalid webservice component attributes.
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 f3f06e3..429a395 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
@@ -2079,9 +2079,10 @@ working area for individual server instances</li></ul>"/>
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="endpoint"/>
+ <c:simple-property name="path" readOnly="true" default="endpoint-config"/>
</plugin-configuration>
+<!--
<metric property="average-processing-time" description="Average endpoint processing time." displayType="summary" units="milliseconds"/>
<metric property="min-processing-time" description="Minimal endpoint processing time." units="milliseconds"/>
<metric property="max-processing-time" description="Maximal endpoint processing time." units="milliseconds"/>
@@ -2089,7 +2090,7 @@ working area for individual server instances</li></ul>"/>
<metric property="request-count" description="Count of requests the endpoint processed." displayType="summary" measurementType="trendsup"/>
<metric property="response-count" description="Count of responses the endpoint generated." measurementType="trendsup"/>
<metric property="fault-count" description="Count of faults the endpoint generated." displayType="summary" measurementType="trendsup"/>
-
+-->
<resource-configuration>
<c:simple-property name="name" required="true" type="string" readOnly="true" description="Webservice endpoint name."/>
<c:simple-property name="context" required="true" type="string" readOnly="true" description="Webservice endpoint context."/>
commit 4ebcfc84e6a07d3dff6bd848465b5ad27a57a650
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 30 11:41:51 2012 -0400
Update configuration data for webservices subsystem afer attribute changes.
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 c0d32b0..f3f06e3 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
@@ -2034,7 +2034,7 @@ working area for individual server instances</li></ul>"/>
<server name="Webservices"
discovery="SubsystemDiscovery"
- class="BaseComponent"
+ class="WebservicesComponent"
singleton="true"
>
@@ -2047,15 +2047,31 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="path" readOnly="true" default="subsystem=webservices"/>
</plugin-configuration>
+<!-- REMOVING. These are lifecycle operations for AS container itself. Don't think we want to allow
+ customers to be able to remove/add a subsystem via RHQ.
+ <operation name="add" description="Adds the web services subsystem.">
+ <parameters>
+ <c:simple-property name="modify-wsdl-address" required="false" type="boolean" readOnly="false" description="Whether the soap address can be modified."/>
+ <c:simple-property name="wsdl-host" required="false" type="string" readOnly="false" description="The WSDL, that is a required deployment artifact for an endpoint, has a <soap:address> element which points to the location of the endpoint. JBoss supports rewriting of that SOAP address. If the content of <soap:address> is a valid URL, JBossWS will not rewrite it unless 'modify-wsdl-address' is true. If the content of <soap:address> is not a valid URL, JBossWS will rewrite it using the attribute values given below. If 'wsdl-host' is set to 'jbossws.undefined.host', JBossWS uses requesters host when rewriting the <soap:address>"/>
+ <c:simple-property name="wsdl-port" required="false" type="integer" readOnly="false" description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ <c:simple-property name="wsdl-secure-port" required="false" type="integer" readOnly="false" description="The secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ </parameters>
+ <results>
+ <c:simple-property name="operationResult" description="Adds the web services subsystem."/>
+ </results>
+ </operation>
+
+ <operation name="remove" description="Removes the web services subsystem.">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation> -->
+
<resource-configuration>
- <c:simple-property name="modify-soap-address" required="true" type="boolean" readOnly="true"
- description="Whether the soap address can be modified."/>
- <c:simple-property name="webservice-host" required="true" type="string" readOnly="true"
- description="The WSDL, that is a required deployment artifact for an endpoint, has a &soap:address> element which points to the location of the endpoint. JBoss supports rewriting of that SOAP address. If the content of &soap:address> is a valid URL, JBossWS will not rewrite it unless 'modifySOAPAddress' is true. If the content of &soap:address> is not a valid URL, JBossWS will rewrite it using the attribute values given below. If 'webServiceHost' is set to 'jbossws.undefined.host', JBossWS uses requesters host when rewriting the &soap:address>"/>
- <c:simple-property name="webservice-port" type="integer" readOnly="true"
- description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
- <c:simple-property name="webservice-secure-port" type="integer" readOnly="true"
- description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ <c:simple-property name="modify-wsdl-address" required="false" type="boolean" readOnly="false" description="Whether the soap address can be modified."/>
+ <c:simple-property name="wsdl-host" required="false" type="string" readOnly="false" description="The WSDL, that is a required deployment artifact for an endpoint, has a <soap:address> element which points to the location of the endpoint. JBoss supports rewriting of that SOAP address. If the content of <soap:address> is a valid URL, JBossWS will not rewrite it unless 'modify-wsdl-address' is true. If the content of <soap:address> is not a valid URL, JBossWS will rewrite it using the attribute values given below. If 'wsdl-host' is set to 'jbossws.undefined.host', JBossWS uses requesters host when rewriting the <soap:address>"/>
+ <c:simple-property name="wsdl-port" required="false" type="integer" readOnly="false" description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ <c:simple-property name="wsdl-secure-port" required="false" type="integer" readOnly="false" description="The secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
</resource-configuration>
<service name="Endpoint"
commit da08bb9c65ffefe88a0578a5b94a3f9e65a81744
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 30 09:06:34 2012 -0400
Exclude a few more shared operations from generated operations descriptor list.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index 347032f..a185461 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -171,6 +171,13 @@ public class Domain2Descriptor {
if (key.equals("write-attribute")) {
continue;
}
+ //exclude a few more shared operations: whoami, undefine-attribute
+ if (key.equals("whoami")) {
+ continue;
+ }
+ if (key.equals("undefine-attribute")) {
+ continue;
+ }
//for each custom operation found, retrieve child hierarchy and pass into
Map<String, Object> value = (Map<String, Object>) attributesMap.get(key);
commit c4847c45f5bf3b26edb7e51d7ef73e256b9c6c3a
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 29 16:04:40 2012 -0400
Some cleanup and more docs.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index ba2e445..347032f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -49,6 +49,8 @@ public class Domain2Descriptor {
private void run(String[] args) {
+ //process and populate command line args passed in and determine
+ //operation modes.
D2DMode mode = null;
String user = null;
String pass = null;
@@ -87,20 +89,28 @@ public class Domain2Descriptor {
String path = arg;
path = path.replaceAll("/", ","); // Allow path from jboss-cli.sh's
// pwd command
+
+ //spinder 3/29/12: if additional child type info passed in then load it. What does this look like?
String childType = null;
if (args.length > pos + 1) {
childType = args[pos + 1];
}
+ //create connection
ASConnection conn = new ASConnection("localhost", 9990, user, pass);
Address address = new Address(path);
+
+ //create request to get metadata type information
Operation op = new Operation("read-resource-description", address);
+ //recurse down the tree.
op.addAdditionalProperty("recursive", "true");
+ //additionally request operation metadata
if (mode == D2DMode.OPERATION) {
op.addAdditionalProperty("operations", true);
}
+ //additionally request metric metadata
if (mode == D2DMode.METRICS) {
op.addAdditionalProperty("include-runtime", true);
}
@@ -115,6 +125,7 @@ public class Domain2Descriptor {
return;
}
+ //load json object hierarchy of response
Map<String, Object> resMap = res.getResult();
String what;
if (mode == D2DMode.OPERATION) {
@@ -123,8 +134,12 @@ public class Domain2Descriptor {
what = "attributes";
}
+ //Determine which attributes to focus on.
Map<String, Object> attributesMap;
+
+ //when will childtype is actually passed then...
if (childType != null) {
+
Map childMap = (Map) resMap.get("children");
Map<String, Object> typeMap = (Map<String, Object>) childMap.get(childType);
if (typeMap == null) {
@@ -138,16 +153,18 @@ public class Domain2Descriptor {
}
Map starMap = (Map) descriptionMap.get("*");
attributesMap = (Map<String, Object>) starMap.get(what);
- } else {
+ } else {//no child type passed in just load typical map
attributesMap = (Map<String, Object>) resMap.get(what);
}
if (mode == D2DMode.OPERATION) {
+ //populate operations(each special map type) and sort them for ordered listing
Set<String> strings = attributesMap.keySet();
String[] keys = strings.toArray(new String[strings.size()]);
Arrays.sort(keys);
for (String key : keys) {
+ //exclude typical 'read-' and 'write-attribute' operations typical to all types.
if (key.startsWith("read-")) {
continue;
}
@@ -155,6 +172,7 @@ public class Domain2Descriptor {
continue;
}
+ //for each custom operation found, retrieve child hierarchy and pass into
Map<String, Object> value = (Map<String, Object>) attributesMap.get(key);
createOperation(key, value);
}
@@ -177,8 +195,8 @@ public class Domain2Descriptor {
Type ptype = getTypeFromProps(props);
if (ptype == Type.OBJECT && mode != D2DMode.METRICS) {
- System.out.println("<c:map-property name=\"" + key + "\" description=\""
- + props.get("description") + "\" >");
+ System.out.println("<c:map-property name=\"" + key + "\" description=\"" + props.get("description")
+ + "\" >");
Map<String, Object> attributesMap1 = (Map<String, Object>) props.get("attributes");
Map<String, Object> valueTypes = (Map<String, Object>) props.get("value-type");
@@ -200,7 +218,7 @@ public class Domain2Descriptor {
Map<String, Object> emapEntryValue = (Map<String, Object>) emapEntry.getValue();
Type ts = getTypeFromProps(emapEntryValue);
StringBuilder sb = generateProperty(indent, emapEntryValue, ts, emapEntry.getKey(),
- getAccessType(emapEntryValue));
+ getAccessType(emapEntryValue));
System.out.println(sb.toString());
} else {
System.out.println(emapEntry.getValue());
@@ -248,7 +266,7 @@ public class Domain2Descriptor {
HashMap<String, Object> myMap = (HashMap<String, Object>) props.get("value-type");
for (Map.Entry<String, Object> myEntry : myMap.entrySet()) {
createMetricEntry(indent, (Map<String, Object>) myEntry.getValue(),
- key + ":" + myEntry.getKey(), getTypeFromProps(myMap));
+ key + ":" + myEntry.getKey(), getTypeFromProps(myMap));
}
} else {
if (!accessType.equals("metric")) {
@@ -289,32 +307,41 @@ public class Domain2Descriptor {
if (emapEntry.getValue() instanceof Map) {
Map<String, Object> emapEntryValue = (Map<String, Object>) emapEntry.getValue();
- sb = generateProperty(indent, emapEntryValue, getTypeFromProps(emapEntryValue),
- emapEntry.getKey(), getAccessType(emapEntryValue));
+ sb = generateProperty(indent, emapEntryValue, getTypeFromProps(emapEntryValue), emapEntry.getKey(),
+ getAccessType(emapEntryValue));
} else {
sb = new StringBuilder();
- doIndent(indent,sb);
+ doIndent(indent, sb);
sb.append(emapEntry.getValue().toString());
}
System.out.println(sb.toString());
}
+ /** Assumes custom operation for AS7 node.
+ *
+ * @param name of custom operation.
+ * @param operationMap Json node representation of operation details as Map<String,Object>.
+ */
private void createOperation(String name, Map<String, Object> operationMap) {
- if (operationMap == null) {
+ if ((name == null) && (operationMap == null)) {
return;
}
+ //container for flexible string concatenation and each operation
StringBuilder builder = new StringBuilder("<operation name=\"");
builder.append(name).append('"');
+ //description attribute
String description = (String) operationMap.get("description");
appendDescription(builder, description, null);
+ //close xml tag
builder.append(">\n");
+ //detect operation parameters if present.
Map<String, Object> reqMap = (Map<String, Object>) operationMap.get("request-properties");
- if (reqMap != null && !reqMap.isEmpty()) {
+ if (reqMap != null && !reqMap.isEmpty()) {//if present build parameters segment for plugin descriptor.
builder.append(" <parameters>\n");
generatePropertiesForMap(builder, reqMap);
builder.append(" </parameters>\n");
@@ -333,13 +360,21 @@ public class Domain2Descriptor {
System.out.println(builder.toString());
}
+ /** Builds 'description' attribute for an xml node.
+ *
+ * @param builder
+ * @param description
+ * @param defaultValueText
+ */
private void appendDescription(StringBuilder builder, String description, String defaultValueText) {
if (description != null && !description.isEmpty()) {
+ //wrap onto a new line
if (builder.length() > 120) {
builder.append("\n ");
}
builder.append(" description=\"");
+ //trim period off of descriptions for consistency.
if (defaultValueText != null) {
if (description.charAt(description.length() - 1) != '.') {
description += ".";
@@ -347,6 +382,7 @@ public class Domain2Descriptor {
description = description + " " + defaultValueText;
}
+ //replace problematic strings with correct escaped xml references.
description = description.replace("<", "<");
description = description.replace(">", ">");
description = description.replace("\"", "\'");
@@ -370,8 +406,9 @@ public class Domain2Descriptor {
builder.append(generateProperty(4, entryValue, type, entryKey, null));
builder.append('\n');
} else {
+
builder.append("<!--").append(entry.getKey()).append("..").append(entry.getValue().toString())
- .append("-->");
+ .append("-->");
}
}
}
@@ -385,7 +422,7 @@ public class Domain2Descriptor {
}
private StringBuilder generateProperty(int indent, Map<String, Object> props, Type type, String entryName,
- String accessType) {
+ String accessType) {
boolean expressionsAllowed = false;
Boolean tmp = (Boolean) props.get("expressions-allowed");
@@ -466,14 +503,8 @@ public class Domain2Descriptor {
public enum Type {
- STRING(false,"string"),
- INT(true,"integer"),
- BOOLEAN(false,"boolean"),
- LONG(true,"long"),
- BIG_DECIMAL(true,"long"),
- OBJECT(false,"-object-"),
- LIST(false,"-list-"),
- DOUBLE(true,"long");
+ STRING(false, "string"), INT(true, "integer"), BOOLEAN(false, "boolean"), LONG(true, "long"), BIG_DECIMAL(true,
+ "long"), OBJECT(false, "-object-"), LIST(false, "-list-"), DOUBLE(true, "long");
private boolean numeric;
private String rhqName;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
index 9fbe31b..36bf8c2 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
@@ -83,7 +83,6 @@ public class Address {
String tmp = component.trim();
if (tmp.contains("=")) {
- // strip / from the start of the key if it happens to be there
PROPERTY_VALUE valuePair = pathFromSegment(tmp);
this.path.add(valuePair);
}
commit 75139360af7f2e7da66635cf8f5e9148f99e8b3e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 27 17:26:26 2012 -0400
Enable operations for modcluster domain mode.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java
index e90bd03..94c17cf 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java
@@ -191,4 +191,10 @@ public class ModClusterComponent extends BaseComponent implements OperationFacet
op.addAdditionalProperty(parameterName, value);
}
}
+
+ @Override
+ public Address getAddress() {
+ return new Address(key);
+ }
+
}
11 years, 8 months
[rhq] Branch 'feature/export-reports' - modules/enterprise
by mike thompson
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit e515e8fdfb796eb293b6dd4ddd4b0fa03ae63dd0
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Mar 30 15:48:24 2012 -0700
[BZ 800453] Export Csv Reports. Import fix.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java
index be8ed5f..b062dc2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java
@@ -2,6 +2,7 @@ package org.rhq.enterprise.server.rest.reporting;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.alert.*;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.util.PageList;
@@ -387,7 +388,7 @@ public class RecentAlertHandler extends AbstractRestBean implements RecentAlertL
.append(formattedHiValue)
.append("], inclusive");
} else {
- builder.append("BAD COMPARATOR! Report this bug: " + condition.getComparator());
+ builder.append("BAD COMPARATOR! Report this bug: ").append(condition.getComparator());
}
break;
default:
11 years, 8 months
[rhq] 3 commits - modules/plugins
by snegrea
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 255 +++++++---
1 file changed, 199 insertions(+), 56 deletions(-)
New commits:
commit 1202a185a1d01a47d221bb894bcb39f8fb0734f4
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Mar 30 17:11:56 2012 -0500
Add partial support for the ejb3 subsystem.
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 126e671..c0d32b0 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
@@ -2978,4 +2978,137 @@ working area for individual server instances</li></ul>"/>
</service>
+
+ <service name="EJB3"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ description="The configuration of the ejb3 subsystem."
+ singleton="true">
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=ejb3"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="default-clustered-sfsb-cache" required="false" type="string" readOnly="false" description="Name of the default stateful bean cache, which will be applicable to all clustered stateful EJBs, unless overridden at the deployment or bean level"/>
+ <c:simple-property name="default-entity-bean-instance-pool" required="false" type="string" readOnly="false" description="Name of the default entity bean instance pool, which will be applicable to all entity beans, unless overridden at the deployment or bean level"/>
+ <c:simple-property name="default-entity-bean-optimistic-locking" required="false" type="boolean" readOnly="false" description="If set to true entity beans will use optimistic locking by default"/>
+ <c:simple-property name="default-mdb-instance-pool" required="false" type="string" readOnly="false" description="Name of the default MDB instance pool, which will be applicable to all MDBs, unless overridden at the deployment or bean level"/>
+ <c:simple-property name="default-resource-adapter-name" required="false" type="string" readOnly="false" defaultValue="hornetq-ra" description="Name of the default resource adapter name that will be used by MDBs, unless overridden at the deployment or bean level. The default value is hornetq-ra."/>
+ <c:simple-property name="default-sfsb-cache" required="false" type="string" readOnly="false" description="Name of the default stateful bean cache, which will be applicable to all stateful EJBs, unless overridden at the deployment or bean level"/>
+ <c:simple-property name="default-singleton-bean-access-timeout:expr" required="false" type="string" readOnly="false" defaultValue="5000" description="The default access timeout for singleton beans. The default value is 5000."/>
+ <c:simple-property name="default-slsb-instance-pool" required="false" type="string" readOnly="false" description="Name of the default stateless bean instance pool, which will be applicable to all stateless EJBs, unless overridden at the deployment or bean level"/>
+ <c:simple-property name="default-stateful-bean-access-timeout:expr" required="false" type="string" readOnly="false" defaultValue="5000" description="The default access timeout for stateful beans. The default value is 5000."/>
+ <c:simple-property name="in-vm-remote-interface-invocation-pass-by-value" required="false" type="boolean" readOnly="false" defaultValue="true" description="If set to false, the parameters to invocations on remote interface of an EJB, will be passed by reference. Else, the parameters will be passed by value. The default value is true."/>
+ </resource-configuration>
+
+ <service name="ThreadPool"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ description="A thread pool executor with an unbounded queue. Such a thread pool has a core size and a queue with no upper bound. When a task is submitted, if the number of running threads is less than the core size, a new thread is created. Otherwise, the task is placed in queue. If too many tasks are allowed to be submitted to this type of executor, an out of memory condition may occur.">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="thread-pool"/>
+ </plugin-configuration>
+
+ <metric property="active-count" description="The approximate number of threads that are actively executing tasks."/>
+ <metric property="completed-task-count" description="The approximate total number of tasks that have completed execution."/>
+ <metric property="current-thread-count" description="The current number of threads in the pool."/>
+ <metric property="keepalive-time:time" description="The time"/>
+ <metric property="keepalive-time:unit" description="The time unit"/>
+ <metric property="largest-thread-count" description="The largest number of threads that have ever simultaneously been in the pool."/>
+ <metric property="rejected-count" description="The number of tasks that have been rejected."/>
+ <metric property="task-count" description="The approximate total number of tasks that have ever been scheduled for execution."/>
+
+ <resource-configuration>
+ <c:map-property name="keepalive-time" description="Used to specify the amount of time that pool threads should be kept running when idle; if not specified, threads will run until the executor is shut down." >
+ <c:simple-property name="time" required="true" type="long" readOnly="true" description="The time"/>
+ <c:simple-property name="unit" required="true" type="string" readOnly="true" description="The time unit"/>
+ </c:map-property>
+ <c:simple-property name="max-threads:expr" required="false" type="string" readOnly="false" description="The maximum thread pool size."/>
+ <c:simple-property name="name" required="false" type="string" readOnly="true" description="The name of the thread pool."/>
+ <c:simple-property name="thread-factory" required="false" type="string" readOnly="false" description="Specifies the name of a specific thread factory to use to create worker threads. If not defined an appropriate default thread factory will be used."/>
+ </resource-configuration>
+ </service>
+
+ <service name="FilePassivationStore"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ description="A file system based passivation store.">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="file-passivation-store"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="groups-path" required="false" type="string" readOnly="false" defaultValue="ejb3/groups"/>
+ <c:simple-property name="idle-timeout:expr" required="false" type="string" readOnly="false" defaultValue="300" description="The timeout in units specified by idle-timeout-unit, after which a bean will passivate. The default value is 300."/>
+ <c:simple-property name="idle-timeout-unit" required="false" type="string" readOnly="false" defaultValue="SECONDS" description="The unit of idle-timeout. The default value is SECONDS."/>
+ <c:simple-property name="max-size:expr" required="false" type="string" readOnly="false" defaultValue="10000" description="The maximum number of beans this cache should store before forcing old beans to passivate. The default value is 10000."/>
+ <c:simple-property name="relative-to" required="false" type="string" readOnly="false" defaultValue="jboss.server.data.dir"/>
+ <c:simple-property name="sessions-path" required="false" type="string" readOnly="false" defaultValue="ejb3/sessions"/>
+ <c:simple-property name="subdirectory-count:expr" required="false" type="string" readOnly="false" defaultValue="100"/>
+ </resource-configuration>
+ </service>
+
+ <service name="StrictMaxBeanInstancePool"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ description="A bean instance pool with a strict upper limit">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="strict-max-bean-instance-pool"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="max-pool-size:expr" required="false" type="string" readOnly="false" defaultValue="20" description="The maximum number of bean instances that the pool can hold at a given point in time. The default value is 20."/>
+ <c:simple-property name="timeout:expr" required="false" type="string" readOnly="false" defaultValue="5" description="The maximum amount of time to wait for a bean instance to be available from the pool. The default value is 5."/>
+ <c:simple-property name="timeout-unit" required="false" type="string" readOnly="false" defaultValue="MINUTES" description="The instance acquisition timeout unit. The default value is MINUTES."/>
+ </resource-configuration>
+ </service>
+
+ <service name="Cache"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ description="A SFSB cache.">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="cache"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:list-property name="aliases" description="The aliases by which this cache may also be referenced" >
+ <c:simple-property name="aliases" />
+ </c:list-property>
+ <c:simple-property name="passivation-store" required="false" type="string" readOnly="false" description="The passivation store used by this cache"/>
+ </resource-configuration>
+ </service>
+
+ <service name="ClusterPassivationStore"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ description="A clustered passivation store.">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="cluster-passivation-store"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="bean-cache" required="false" type="string" readOnly="false" description="The name of the cache used to store bean instances."/>
+ <c:simple-property name="cache-container" required="false" type="string" readOnly="false" defaultValue="ejb" description="The name of the cache container used for the bean and client-mappings caches. The default value is ejb."/>
+ <c:simple-property name="client-mappings-cache" required="false" type="string" readOnly="false" defaultValue="remote-connector-client-mappings" description="The name of the cache used to store client-mappings of the EJB remoting connector's socket-bindings. The default value is remote-connector-client-mappings."/>
+ <c:simple-property name="idle-timeout:expr" required="false" type="string" readOnly="false" defaultValue="300" description="The timeout in units specified by idle-timeout-unit, after which a bean will passivate. The default value is 300."/>
+ <c:simple-property name="idle-timeout-unit" required="false" type="string" readOnly="false" defaultValue="SECONDS" description="The unit of idle-timeout. The default value is SECONDS."/>
+ <c:simple-property name="max-size:expr" required="false" type="string" readOnly="false" defaultValue="10000" description="The maximum number of beans this cache should store before forcing old beans to passivate. The default value is 10000."/>
+ <c:simple-property name="passivate-events-on-replicate" required="false" type="boolean" readOnly="false" defaultValue="true" description="Indicates whether replication should trigger passivation events on the bean. The default value is true."/>
+ </resource-configuration>
+ </service>
+
+ </service>
+
</plugin>
commit cd23b2a0c8f6cd2995909730f03f73b029583cb4
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Mar 30 16:35:32 2012 -0500
Threadfactory and threadpool are not singletons.
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 2cf8052..126e671 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
@@ -2929,8 +2929,7 @@ working area for individual server instances</li></ul>"/>
<service name="ThreadFactory"
discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true">
+ class="BaseComponent">
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="thread-factory"/>
@@ -2951,8 +2950,7 @@ working area for individual server instances</li></ul>"/>
<service name="ThreadPool"
discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true">
+ class="BaseComponent">
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="bounded-queue-thread-pool|queueless-thread-pool|scheduled-thread-pool|unbounded-queue-thread-pool"/>
commit e1416f1a51f98911c597117021b94128f8547d02
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Mar 30 15:55:30 2012 -0500
Update support for threads subsystem. Also moved the subsystem from server to service.
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 1580f48..2cf8052 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
@@ -2030,63 +2030,7 @@ working area for individual server instances</li></ul>"/>
</server>
- <server name="Threads"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
- >
-
- <runs-inside>
- <parent-resource-type name="Profile" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
- </runs-inside>
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="subsystem=threads"/>
- </plugin-configuration>
-
- <service name="ThreadFactory"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
- >
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="thread-factory"/>
- </plugin-configuration>
- <resource-configuration>
- <c:simple-property name="name" required="true" type="string" readOnly="true" description="The bean name of the created thread factory."/>
- <c:simple-property name="group-name" type="string" readOnly="false"
- description="Specifies the name of a the thread group to create for this thread factory."/>
- <c:simple-property name="thread-name-pattern" type="string" readOnly="false"
- description="The template used to create names for threads. The following patterns may be used:
- %% - emit a percent sign
- %t - emit the per-factory thread sequence number
- %g - emit the global thread sequence number
- %f - emit the factory sequence number
- %i - emit the thread ID."/>
- <c:simple-property name="priority" type="integer" readOnly="false"
- description="May be used to specify the thread priority of created threads."/>
- <c:list-property name="properties" >
- <c:simple-property name="properties" /> <!-- TODO list of maps ? -->
- </c:list-property>
- </resource-configuration>
- </service>
-
- <service name="ThreadPool"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
- >
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="bounded-queue-thread-pool|queueless-thread-pool|scheduled-thread-pool|unbounded-queue-thread-pool"/>
- </plugin-configuration>
- </service>
-
-
- </server>
<server name="Webservices"
discovery="SubsystemDiscovery"
@@ -2968,4 +2912,72 @@ working area for individual server instances</li></ul>"/>
</service>
+
+ <service name="Threads"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true">
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=threads"/>
+ </plugin-configuration>
+
+ <service name="ThreadFactory"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="thread-factory"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="group-name" required="false" type="string" readOnly="false" description="Specifies the name of a thread group to create for this thread factory."/>
+ <c:simple-property name="name" required="false" type="string" readOnly="true" description="The name of the created thread factory."/>
+ <c:simple-property name="priority:expr" required="false" type="string" readOnly="false" defaultValue="-1" description="May be used to specify the thread priority of created threads. The default value is -1."/>
+ <c:simple-property name="thread-name-pattern" required="false" type="string" readOnly="false" description="The template used to create names for threads. The following patterns may be used:
+ %% - emit a percent sign
+ %t - emit the per-factory thread sequence number
+ %g - emit the global thread sequence number
+ %f - emit the factory sequence number
+ %i - emit the thread ID."/>
+ </resource-configuration>
+ </service>
+
+ <service name="ThreadPool"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="bounded-queue-thread-pool|queueless-thread-pool|scheduled-thread-pool|unbounded-queue-thread-pool"/>
+ </plugin-configuration>
+
+ <metric property="active-count" description="The approximate number of threads that are actively executing tasks."/>
+ <metric property="completed-task-count" description="The approximate total number of tasks that have completed execution."/>
+ <metric property="current-thread-count" description="The current number of threads in the pool."/>
+ <metric property="keepalive-time:time" description="The time"/>
+ <metric property="keepalive-time:unit" description="The time unit"/>
+ <metric property="largest-thread-count" description="The largest number of threads that have ever simultaneously been in the pool."/>
+ <metric property="rejected-count" description="The number of tasks that have been rejected."/>
+ <metric property="task-count" description="The approximate total number of tasks that have ever been scheduled for execution."/>
+
+ <resource-configuration>
+ <c:map-property name="keepalive-time" description="Used to specify the amount of time that pool threads should be kept running when idle; if not specified, threads will run until the executor is shut down." >
+ <c:simple-property name="time" required="true" type="long" readOnly="true" description="The time"/>
+ <c:simple-property name="unit" required="true" type="string" readOnly="true" description="The time unit"/>
+ </c:map-property>
+ <c:simple-property name="max-threads:expr" required="false" type="string" readOnly="false" description="The maximum thread pool size."/>
+ <c:simple-property name="name" required="false" type="string" readOnly="true" description="The name of the thread pool."/>
+ <c:simple-property name="thread-factory" required="false" type="string" readOnly="false" description="Specifies the name of a specific thread factory to use to create worker threads. If not defined an appropriate default thread factory will be used."/>
+ </resource-configuration>
+ </service>
+
+ </service>
+
</plugin>
11 years, 8 months
[rhq] Branch 'feature/export-reports' - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java | 38 ++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java | 39 +++++++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertLocal.java | 8 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java | 42 ++++++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsHandler.java | 22 ++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsLocal.java | 8 -
9 files changed, 102 insertions(+), 61 deletions(-)
New commits:
commit 125219cc3cc8b0a5fe951ecadb574e016efaae94
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Mar 30 13:19:40 2012 -0700
[BZ 800453] Export Csv Reports. First draft hooking up backend restful reports.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
index 9c19531..5ebf50c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
@@ -48,7 +48,6 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.LinkedHashMap;
/**
@@ -126,7 +125,6 @@ public class AlertHistoryView extends TableSection<AlertDataSource> implements H
toDateFilter = new DateItem();
toDateFilter.setUseTextField(true);
toDateFilter.setTitle(MSG.filter_to_date());
- toDateFilter.setValue(new Date());
if (isShowFilterForm()) {
setFilterFormItems(fromDateFilter, toDateFilter, priorityFilter);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java
index 6cbe4d3..2eddf11 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java
@@ -63,8 +63,8 @@ public class ReportExporter {
String driftPath;
// Date filtering
- Date fromDate;
- Date toDate;
+ Date startDate;
+ Date endDate;
/**
@@ -89,8 +89,8 @@ public class ReportExporter {
public static ReportExporter createStandardExporter(String reportUrl, Date fromDate, Date toDate) {
ReportExporter newExporter = new ReportExporter(reportUrl);
- newExporter.setFromDate(fromDate);
- newExporter.setToDate(toDate);
+ newExporter.setStartDate(fromDate);
+ newExporter.setEndDate(toDate);
return newExporter;
}
@@ -102,24 +102,24 @@ public class ReportExporter {
newExporter.setDriftDefinition(definition);
newExporter.setDriftPath(path);
newExporter.setDriftSnapshot(snapshot);
- newExporter.setFromDate(fromDate);
- newExporter.setToDate(toDate);
+ newExporter.setStartDate(fromDate);
+ newExporter.setEndDate(toDate);
return newExporter;
}
public static ReportExporter createExporterForRecentAlerts(String reportUrl, String[] alertPriorityList, Date fromDate, Date toDate) {
ReportExporter newExportDialog = new ReportExporter(reportUrl);
newExportDialog.setAlertPriorityFilters(alertPriorityList);
- newExportDialog.setFromDate(fromDate);
- newExportDialog.setToDate(toDate);
+ newExportDialog.setStartDate(fromDate);
+ newExportDialog.setEndDate(toDate);
return newExportDialog;
}
public static ReportExporter createExporterForRecentOperations(String reportUrl, String[] operationRequestStatuses, Date fromDate, Date toDate) {
ReportExporter newExportDialog = new ReportExporter(reportUrl);
newExportDialog.setOperationRequestStatusList(operationRequestStatuses);
- newExportDialog.setFromDate(fromDate);
- newExportDialog.setToDate(toDate);
+ newExportDialog.setStartDate(fromDate);
+ newExportDialog.setEndDate(toDate);
return newExportDialog;
}
@@ -142,7 +142,7 @@ public class ReportExporter {
if (showAllDetail) {
queryString.append("showAllDetails=").append("true");
- } else if (!resourceTypeIds.isEmpty()) {
+ } else if (null != resourceTypeIds && !resourceTypeIds.isEmpty()) {
queryString.append("resourceTypeId=").append(StringUtility.toString(resourceTypeIds));
}
@@ -183,11 +183,11 @@ public class ReportExporter {
}
// to/from Dates
- if(fromDate != null){
- queryString.append("fromDate=").append(fromDate.getTime());
+ if(startDate != null){
+ queryString.append("startTime=").append(startDate.getTime());
}
- if(toDate != null){
- queryString.append("toDate=").append(toDate.getTime());
+ if(endDate != null){
+ queryString.append("endTime=").append(endDate.getTime());
}
@@ -218,12 +218,12 @@ public class ReportExporter {
this.driftPath = driftPath;
}
- public void setFromDate(Date fromDate) {
- this.fromDate = fromDate;
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
}
- public void setToDate(Date toDate) {
- this.toDate = toDate;
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
}
public void export(){
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index 168cf14..f35a0f8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -42,7 +42,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
import java.util.ArrayList;
-import java.util.Date;
import java.util.LinkedHashMap;
/**
@@ -148,7 +147,6 @@ public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
toDateFilter = new DateItem();
toDateFilter.setUseTextField(true);
toDateFilter.setTitle(MSG.filter_to_date());
- toDateFilter.setValue(new Date());
if (isShowFilterForm()) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
index 021c78b..d2307fe 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
@@ -45,7 +45,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import java.util.ArrayList;
-import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
@@ -144,7 +143,6 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
toDateFilter = new DateItem();
toDateFilter.setUseTextField(true);
toDateFilter.setTitle(MSG.filter_to_date());
- toDateFilter.setValue(new Date());
if (isShowFilterForm()) {
setFilterFormItems(fromDateFilter, toDateFilter, statusFilter);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java
index f4687db..be8ed5f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertHandler.java
@@ -2,10 +2,10 @@ package org.rhq.enterprise.server.rest.reporting;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.alert.*;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.rest.AbstractRestBean;
import org.rhq.enterprise.server.rest.SetCallerInterceptor;
@@ -23,6 +23,7 @@ import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.Set;
@@ -39,20 +40,28 @@ public class RecentAlertHandler extends AbstractRestBean implements RecentAlertL
private AlertManagerLocal alertManager;
@Override
- public StreamingOutput recentAlerts(final String alertPriority, UriInfo uriInfo, final HttpServletRequest request,
- HttpHeaders headers) {
+ public StreamingOutput recentAlerts(final String alertPriority, final Long startTime, final Long endTime,
+ final UriInfo uriInfo, final HttpServletRequest request,
+ final HttpHeaders headers) {
return new StreamingOutput() {
@Override
public void write(OutputStream stream) throws IOException, WebApplicationException {
final AlertCriteria criteria = new AlertCriteria();
+ criteria.addSortCtime(PageOrdering.DESC);
- List<AlertPriority> alertPriorityList = new ArrayList<AlertPriority>(10);
- String alertPriorities[] = alertPriority.split(",");
- for ( String alertPriorityValue : alertPriorities) {
- log.info("Alert Priority Filter set for: " + alertPriorityValue);
- alertPriorityList.add(AlertPriority.valueOf(alertPriorityValue.toUpperCase()));
+ if(startTime != null){
+ criteria.addFilterStartTime(startTime);
+ }
+ if(endTime != null){
+ criteria.addFilterEndTime(endTime);
+ }
+ // lets default the end time for them to now if they didnt enter it
+ if(startTime != null && endTime == null){
+ Date today = new Date();
+ criteria.addFilterEndTime(today.getTime());
}
- criteria.addFilterPriorities(alertPriorityList.toArray(new AlertPriority[alertPriorityList.size()]));
+
+ criteria.addFilterPriorities(getAlertPriorities());
CriteriaQueryExecutor<Alert, AlertCriteria> queryExecutor =
new CriteriaQueryExecutor<Alert, AlertCriteria>() {
@@ -73,6 +82,18 @@ public class RecentAlertHandler extends AbstractRestBean implements RecentAlertL
}
}
+
+ private AlertPriority[] getAlertPriorities() {
+ List<AlertPriority> alertPriorityList = new ArrayList<AlertPriority>(10);
+ String alertPriorities[] = alertPriority.split(",");
+ for ( String alertPriorityValue : alertPriorities) {
+ log.info("Alert Priority Filter set for: " + alertPriorityValue);
+ alertPriorityList.add(AlertPriority.valueOf(alertPriorityValue.toUpperCase()));
+ }
+
+ return alertPriorityList.toArray(new AlertPriority[alertPriorityList.size()]);
+ }
+
private String toCSV(Alert alert) {
return formatDateTime(alert.getCtime()) + "," +
cleanForCSV(alert.getAlertDefinition().getName()) + "," +
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertLocal.java
index 035f316..456fb90 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentAlertLocal.java
@@ -2,11 +2,7 @@ package org.rhq.enterprise.server.rest.reporting;
import javax.ejb.Local;
import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.StreamingOutput;
@@ -21,6 +17,8 @@ public interface RecentAlertLocal {
@Produces({"text/csv", "application/xml"})
StreamingOutput recentAlerts(
@QueryParam("alertPriority") @DefaultValue("high,medium,low") String alertPriority,
+ @QueryParam("startTime") Long startTime,
+ @QueryParam("endTime") Long endTime,
@Context UriInfo uriInfo,
@Context HttpServletRequest request,
@Context HttpHeaders headers);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java
index fb30273..686e430 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java
@@ -24,6 +24,7 @@ import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import static org.rhq.enterprise.server.rest.reporting.ReportFormatHelper.cleanForCSV;
@@ -52,6 +53,19 @@ public class RecentDriftHandler extends AbstractRestBean implements RecentDriftL
criteria.fetchChangeSet(true);
criteria.addFilterChangeSetStartVersion(1);// always start at 1 for this report
+ if(startTime != null){
+ criteria.addFilterStartTime(startTime);
+ }
+ if(endTime != null){
+ criteria.addFilterEndTime(endTime);
+ }
+ // lets default the end time for them to now if they didnt enter it
+ if(startTime != null && endTime == null){
+ Date today = new Date();
+ criteria.addFilterEndTime(today.getTime());
+ }
+
+
if(snapshot != null){
log.info("Drift Snapshot version Filter set for: " + snapshot);
criteria.addFilterChangeSetEndVersion(snapshot);
@@ -62,23 +76,10 @@ public class RecentDriftHandler extends AbstractRestBean implements RecentDriftL
}
if(definition != null){
log.info("Drift Definition Filter set for: " + definition);
- criteria.addFilterId(path);
+ //@todo: drift sorting is done in the resultset after no criteria for definition
}
- List<DriftCategory> driftCategoryList = new ArrayList<DriftCategory>(10);
- String categoryArray[] = categories.split(",");
- for (String category : categoryArray) {
- log.info("DriftCategories Filter set for: " + category);
- driftCategoryList.add(DriftCategory.valueOf(category.toUpperCase()));
- }
- criteria.addFilterCategories(driftCategoryList.toArray(new DriftCategory[driftCategoryList.size()]));
-
- if(startTime != null){
- criteria.addFilterStartTime(startTime);
- }
- if(endTime != null){
- criteria.addFilterEndTime(endTime);
- }
+ criteria.addFilterCategories(getCategories());
CriteriaQueryExecutor<DriftComposite, DriftCriteria> queryExecutor =
new CriteriaQueryExecutor<DriftComposite, DriftCriteria>() {
@@ -99,6 +100,17 @@ public class RecentDriftHandler extends AbstractRestBean implements RecentDriftL
}
}
+
+ private DriftCategory[] getCategories() {
+ List<DriftCategory> driftCategoryList = new ArrayList<DriftCategory>(10);
+ String categoryArray[] = categories.split(",");
+ for (String category : categoryArray) {
+ log.info("DriftCategories Filter set for: " + category);
+ driftCategoryList.add(DriftCategory.valueOf(category.toUpperCase()));
+ }
+ return (driftCategoryList.toArray(new DriftCategory[driftCategoryList.size()]));
+ }
+
private String toCSV(DriftComposite drift) {
return formatDateTime(drift.getDrift().getCtime()) + "," +
cleanForCSV(drift.getDriftDefinitionName()) + "," +
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsHandler.java
index 3ce9a93..4064a09 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsHandler.java
@@ -6,6 +6,7 @@ import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.rest.AbstractRestBean;
import org.rhq.enterprise.server.rest.SetCallerInterceptor;
@@ -23,6 +24,7 @@ import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import static org.rhq.enterprise.server.rest.reporting.ReportFormatHelper.cleanForCSV;
@@ -33,16 +35,32 @@ import static org.rhq.enterprise.server.rest.reporting.ReportFormatHelper.format
public class RecentOperationsHandler extends AbstractRestBean implements RecentOperationsLocal {
private final Log log = LogFactory.getLog(RecentOperationsHandler.class);
+
@EJB
private OperationManagerLocal operationManager;
@Override
- public StreamingOutput recentOperations(final String operationRequestStatus, UriInfo uriInfo,
- final HttpServletRequest request, HttpHeaders headers) {
+ public StreamingOutput recentOperations(final String operationRequestStatus,
+ final Long startTime, final Long endTime, final UriInfo uriInfo,
+ final HttpServletRequest request, final HttpHeaders headers) {
return new StreamingOutput() {
@Override
public void write(OutputStream stream) throws IOException, WebApplicationException {
final ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+ criteria.addSortEndTime(PageOrdering.DESC);
+
+ if(startTime != null){
+ criteria.addFilterStartTime(startTime);
+ }
+ if(endTime != null){
+ criteria.addFilterEndTime(endTime);
+ }
+ // lets default the end time for them to now if they didnt enter it
+ if(startTime != null && endTime == null){
+ Date today = new Date();
+ criteria.addFilterEndTime(today.getTime());
+ }
+
List<OperationRequestStatus> operationRequestStatusList = new ArrayList<OperationRequestStatus>(10);
String statuses[] = operationRequestStatus.split(",");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsLocal.java
index d27d236..64077b1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentOperationsLocal.java
@@ -2,11 +2,7 @@ package org.rhq.enterprise.server.rest.reporting;
import javax.ejb.Local;
import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.StreamingOutput;
@@ -21,6 +17,8 @@ public interface RecentOperationsLocal {
@Produces({"text/csv", "application/xml"})
StreamingOutput recentOperations(
@QueryParam("operationRequestStatus") @DefaultValue("inprogress,success,failure,cancelled") String operationRequestStatus,
+ @QueryParam("startTime") Long startTime,
+ @QueryParam("endTime") Long endTime,
@Context UriInfo uriInfo,
@Context HttpServletRequest request,
@Context HttpHeaders headers);
11 years, 8 months
[rhq] modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java | 32 +
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java | 225 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 82 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 55 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java | 36 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java | 23 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java | 10
modules/enterprise/gui/coregui/src/main/webapp/images/types/Cluster_disabled_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/types/Cluster_disabled_24.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/types/Group_disabled_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/types/Group_disabled_24.png |binary
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 128 +++--
18 files changed, 399 insertions(+), 228 deletions(-)
New commits:
commit daec885053b6679e4bb6a80c7c8dc86c75868a4b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Mar 30 16:01:50 2012 -0400
[Bug 807671 - Count of number of children and descendants in compatible group list view goes wrong if a member resource is disabled]
The first pass at handling group avail given the latest avail changes
tried to maintain the old mechanism for determining the group avail. This
ended up not covering all of the cases. So, the double/ratio approach has
been completely scrapped and the mechanism now full incorporates
disabled group members. Now:
- group list views include a disabled member count and icon (note, the count columns are not 50% wider to accommodate).
- new group avail icons and badged group icons have been put in place for disabled
- group availability is now determined differenty, see http://rhq-project.org/display/RHQ/Design-Availability+Checking#Design-Av... for details.
- group composite queries incur a slight perf hit as they now return two
additional counts (although they are no longer called on to perform AVG functions).
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index dcc3740..00ea27b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -238,7 +238,7 @@ public class ResourceGroup extends Group {
public static final String QUERY_NATIVE_FIND_FILTERED_MEMBER = "" //
+ " SELECT "
- + " ( SELECT COUNT(eresAvail.ID) " // the count of all explicit members
+ + " ( SELECT COUNT(eresAvail.ID) " // total explicit members
+ " FROM rhq_resource_avail eresAvail "
+ " INNER JOIN rhq_resource eres "
+ " ON eresAvail.resource_id = eres.id "
@@ -247,17 +247,27 @@ public class ResourceGroup extends Group {
+ " WHERE expMap.resource_group_id = rg.id "
+ " ) as explicitCount, "
+ "" //
- + " ( SELECT COUNT(eresAvail.ID) " // the count of UP explicit members
+ + " ( SELECT COUNT(eresAvail.ID) " // DOWN explicit members
+ " FROM rhq_resource_avail eresAvail "
+ " INNER JOIN rhq_resource eres "
+ " ON eresAvail.resource_id = eres.id "
+ " INNER JOIN rhq_resource_group_res_exp_map expMap "
+ " ON eres.id = expMap.resource_id "
+ " WHERE expMap.resource_group_id = rg.id "
- + " AND eresAvail.availability_type = 1 "
+ + " AND eresAvail.availability_type = 0 "
+ " ) as explicitAvail, "
+ "" //
- + " ( SELECT COUNT(iresAvail.ID) " // the count of all implicit members
+ + " ( SELECT COUNT(eresAvail.ID) " // DISABLED explicit members
+ + " FROM rhq_resource_avail eresAvail "
+ + " INNER JOIN rhq_resource eres "
+ + " ON eresAvail.resource_id = eres.id "
+ + " INNER JOIN rhq_resource_group_res_exp_map expMap "
+ + " ON eres.id = expMap.resource_id "
+ + " WHERE expMap.resource_group_id = rg.id "
+ + " AND eresAvail.availability_type = 3 "
+ + " ) as explicitAvail, "
+ + "" //
+ + " ( SELECT COUNT(iresAvail.ID) " // total implicit members
+ " FROM rhq_resource_avail iresAvail "
+ " INNER JOIN rhq_resource ires "
+ " ON iresAvail.resource_id = ires.id "
@@ -266,14 +276,24 @@ public class ResourceGroup extends Group {
+ " WHERE impMap.resource_group_id = rg.id "
+ " ) as implicitCount, "
+ "" //
- + " ( SELECT COUNT(iresAvail.ID) " // the count of UP implicit members
+ + " ( SELECT COUNT(iresAvail.ID) " // DOWN implicit members
+ + " FROM rhq_resource_avail iresAvail "
+ + " INNER JOIN rhq_resource ires "
+ + " ON iresAvail.resource_id = ires.id "
+ + " INNER JOIN rhq_resource_group_res_imp_map impMap "
+ + " ON ires.id = impMap.resource_id "
+ + " WHERE impMap.resource_group_id = rg.id "
+ + " AND iresAvail.availability_type = 0 "
+ + " ) as implicitAvail, "
+ + "" //
+ + " ( SELECT COUNT(iresAvail.ID) " // DISABLED implicit members
+ " FROM rhq_resource_avail iresAvail "
+ " INNER JOIN rhq_resource ires "
+ " ON iresAvail.resource_id = ires.id "
+ " INNER JOIN rhq_resource_group_res_imp_map impMap "
+ " ON ires.id = impMap.resource_id "
+ " WHERE impMap.resource_group_id = rg.id "
- + " AND iresAvail.availability_type = 1 "
+ + " AND iresAvail.availability_type = 3 "
+ " ) as implicitAvail, "
+ "" //
+ " rg.id as groupId, "
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
index 3906d4e..85a3fab 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
@@ -32,25 +32,28 @@ import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
/**
- * @author Greg Hinkle
+ * @author Jay Shaughnessy
* @author Ian Springer
- * @author Joseph Marques
*/
public class ResourceGroupComposite implements Serializable {
+ public enum GroupAvailabilityType {
+ EMPTY, UP, DOWN, WARN, DISABLED
+ };
+
private static final long serialVersionUID = 1L;
////JAXB Needs no args constructor and final fields make that difficult.
- private Double implicitAvail;
- private Double explicitAvail;
private ResourceGroup resourceGroup;
private GroupCategory category;
- private long implicitUp;
+ private long implicitCount;
private long implicitDown;
- private long explicitUp;
+ private long implicitDisabled;
+ private long explicitCount;
private long explicitDown;
+ private long explicitDisabled;
private ResourceFacets resourceFacets;
@@ -61,63 +64,46 @@ public class ResourceGroupComposite implements Serializable {
public ResourceGroupComposite() {
}
- public ResourceGroupComposite(Long explicitUp, Long explicitDown, Long implicitUp, Long implicitDown,
- ResourceGroup resourceGroup) {
- this(explicitUp + explicitDown, //
- (double) explicitUp / (explicitUp + explicitDown), //
- implicitUp + implicitDown, //
- (double) implicitUp / (implicitUp + implicitDown), //
- resourceGroup, null, new ResourcePermission());
- }
+ // Constructor used in Hibernate Query, see ResourceGroupManagerBean
+ public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitDisabled, Long implicitCount,
+ Long implicitDown, Long implicitDisabled, ResourceGroup resourceGroup) {
- public ResourceGroupComposite(Long explicitCount, Double explicitAvailability, Long implicitCount,
- Double implicitAvailability, ResourceGroup resourceGroup) {
- this(explicitCount, explicitAvailability, implicitCount, implicitAvailability, resourceGroup, null,
- new ResourcePermission());
+ this(explicitCount, explicitDown, explicitDisabled, implicitCount, implicitDown, implicitDisabled,
+ resourceGroup, null, new ResourcePermission());
}
- public ResourceGroupComposite(Long explicitCount, Double explicitAvailability, Long implicitCount,
- Double implicitAvailability, ResourceGroup resourceGroup, Number measure, Number inventory, Number control,
- Number alert, Number event, Number configureRead, Number configureWrite, Number content,
+ // Constructor used in Hibernate Query, see ResourceGroupManagerBean
+ public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitDisabled, Long implicitCount,
+ Long implicitDown, Long implicitDisabled, ResourceGroup resourceGroup, Number measure, Number inventory,
+ Number control, Number alert, Number event, Number configureRead, Number configureWrite, Number content,
Number createChildResources, Number deleteResources, Number drift) {
- this(explicitCount, explicitAvailability, implicitCount, implicitAvailability, resourceGroup, null,
- new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0, control.intValue() > 0, alert
- .intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0, configureWrite.intValue() > 0,
- content.intValue() > 0, createChildResources.intValue() > 0, deleteResources.intValue() > 0, drift
- .intValue() > 0));
+
+ this(explicitCount, explicitDown, explicitDisabled, implicitCount, implicitDown, implicitDisabled,
+ resourceGroup, null, new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0,
+ control.intValue() > 0, alert.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0,
+ configureWrite.intValue() > 0, content.intValue() > 0, createChildResources.intValue() > 0,
+ deleteResources.intValue() > 0, drift.intValue() > 0));
}
- public ResourceGroupComposite(Long explicitCount, Double explicitAvailability, Long implicitCount,
- Double implicitAvailability, ResourceGroup resourceGroup, ResourceFacets facets) {
- this(explicitCount, explicitAvailability, implicitCount, implicitAvailability, resourceGroup, facets,
- new ResourcePermission());
+ public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitDisabled, Long implicitCount,
+ Long implicitDown, Long implicitDisabled, ResourceGroup resourceGroup, ResourceFacets facets) {
+
+ this(explicitCount, explicitDown, explicitDisabled, implicitCount, implicitDown, implicitDisabled,
+ resourceGroup, facets, new ResourcePermission());
}
// Private constructor that all public constructors delegate to
- public ResourceGroupComposite(Long explicitCount, Double explicitAvailability, Long implicitCount,
- Double implicitAvailability, ResourceGroup resourceGroup, ResourceFacets facets, ResourcePermission permissions) {
- long expCount = (explicitCount == null ? 0 : explicitCount);
- double expAvail = (explicitAvailability == null ? 0 : explicitAvailability);
- long impCount = (implicitCount == null ? 0 : implicitCount);
- double impAvail = (implicitAvailability == null ? 0 : implicitAvailability);
-
- explicitUp = Math.round(expCount * expAvail);
- explicitDown = expCount - explicitUp;
- if (explicitUp + explicitDown > 0) {
- // keep explicitAvail null if there are no explicit resources in the group
- explicitAvail = expAvail;
- } else {
- explicitAvail = null;
- }
+ public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitDisabled, Long implicitCount,
+ Long implicitDown, Long implicitDisabled, ResourceGroup resourceGroup, ResourceFacets facets,
+ ResourcePermission permissions) {
- implicitUp = Math.round(impCount * impAvail);
- implicitDown = impCount - implicitUp;
- if (implicitUp + implicitDown > 0) {
- // keep implicitAvail null if there are no implicit resources in the group
- implicitAvail = impAvail;
- } else {
- implicitAvail = null;
- }
+ this.implicitCount = implicitCount;
+ this.implicitDown = implicitDown;
+ this.implicitDisabled = implicitDisabled;
+
+ this.explicitCount = explicitCount;
+ this.explicitDown = explicitDown;
+ this.explicitDisabled = explicitDisabled;
this.resourceGroup = resourceGroup;
@@ -134,12 +120,36 @@ public class ResourceGroupComposite implements Serializable {
this.resourcePermission = permissions;
}
- public Double getImplicitAvail() {
- return this.implicitAvail;
+ public long getImplicitCount() {
+ return implicitCount;
}
- public Double getExplicitAvail() {
- return this.explicitAvail;
+ public long getImplicitDown() {
+ return implicitDown;
+ }
+
+ public long getImplicitDisabled() {
+ return implicitDisabled;
+ }
+
+ public long getImplicitUpAndUnknown() {
+ return implicitCount - implicitDown - implicitDisabled;
+ }
+
+ public long getExplicitCount() {
+ return explicitCount;
+ }
+
+ public long getExplicitDown() {
+ return explicitDown;
+ }
+
+ public long getExplicitDisabled() {
+ return explicitDisabled;
+ }
+
+ public long getExplicitUpAndUnknown() {
+ return explicitCount - explicitDown - explicitDisabled;
}
public ResourceGroup getResourceGroup() {
@@ -150,32 +160,60 @@ public class ResourceGroupComposite implements Serializable {
return this.category;
}
- public long getImplicitUp() {
- return this.implicitUp;
+ /**
+ * Returns the explicit group availability determined with the following algorithm, evaluated top to bottom:
+ * <pre>
+ * empty group = EMPTY
+ * allDown = DOWN
+ * someDown = WARN
+ * someDisabled = DISABLED
+ * otherwise = UP (all members UP or UNKNOWN)
+ * </pre>
+ *
+ * @return the group availability type, null for an empty group
+ */
+ public GroupAvailabilityType getExplicitAvailabilityType() {
+ return getAvailabilityType(true);
}
- public long getImplicitDown() {
- return this.implicitDown;
+ /**
+ * Returns the implicit group availability determined with the following algorithm, evaluated top to bottom:
+ * <pre>
+ * empty group = EMPTY
+ * allDown = DOWN
+ * someDown = WARN
+ * someDisabled = DISABLED
+ * otherwise = UP (all members UP or UNKNOWN)
+ * </pre>
+ *
+ * @return the group availability type, null for an empty group
+ */
+ public GroupAvailabilityType getImplicitAvailabilityType() {
+ return getAvailabilityType(false);
}
- public long getExplicitUp() {
- return this.explicitUp;
- }
+ private GroupAvailabilityType getAvailabilityType(boolean isExplicit) {
+ long count = isExplicit ? explicitCount : implicitCount;
+ long down = isExplicit ? explicitDown : implicitDown;
+ long disabled = isExplicit ? explicitDisabled : implicitDisabled;
- public long getExplicitDown() {
- return this.explicitDown;
- }
+ if (0 == count) {
+ return GroupAvailabilityType.EMPTY;
+ }
- // remove once the old UI is killed, for now this is still needed
- @Deprecated
- public String getExplicitFormatted() {
- return getAlignedAvailabilityResults(getExplicitUp(), getExplicitDown());
- }
+ if (down == count) {
+ return GroupAvailabilityType.DOWN;
+ }
- // remove once the old UI is killed, for now this is still needed
- @Deprecated
- public String getImplicitFormatted() {
- return getAlignedAvailabilityResults(getImplicitUp(), getImplicitDown());
+ if (down > 0) {
+ return GroupAvailabilityType.WARN;
+ }
+
+ if (disabled > 0) {
+ return GroupAvailabilityType.DISABLED;
+ }
+
+ return GroupAvailabilityType.UP;
}
@XmlTransient
@@ -207,10 +245,28 @@ public class ResourceGroupComposite implements Serializable {
// remove once the old UI is killed, for now this is still needed
@Deprecated
- private String getAlignedAvailabilityResults(long up, long down) {
+ public Double getExplicitAvail() {
+ return 0 == explicitCount ? null : (1.0 - (explicitDown / explicitCount));
+ }
+
+ // remove once the old UI is killed, for now this is still needed
+ @Deprecated
+ public String getExplicitFormatted() {
+ return getAlignedAvailabilityResults(getExplicitUpAndUnknown() + getExplicitDisabled(), getExplicitDown());
+ }
+
+ // remove once the old UI is killed, for now this is still needed
+ @Deprecated
+ public String getImplicitFormatted() {
+ return getAlignedAvailabilityResults(getImplicitUpAndUnknown() + getImplicitDisabled(), getImplicitDown());
+ }
+
+ // remove once the old UI is killed, for now this is still needed
+ @Deprecated
+ private String getAlignedAvailabilityResults(long up, long notUp) {
StringBuilder results = new StringBuilder();
results.append("<table width=\"120px\"><tr>");
- if (up == 0 && down == 0) {
+ if (up == 0 && notUp == 0) {
results.append(getColumn(false, "<img src=\""
+ "/coregui/images/subsystems/availability/availability_grey_16.png" + "\" /> 0"));
results.append(getColumn(true));
@@ -221,13 +277,13 @@ public class ResourceGroupComposite implements Serializable {
+ "/coregui/images/subsystems/availability/availability_green_16.png" + "\" />", up));
}
- if (up > 0 && down > 0) {
+ if (up > 0 && notUp > 0) {
results.append(getColumn(true)); // , " / ")); // use a vertical separator image if we want a separator
}
- if (down > 0) {
+ if (notUp > 0) {
results.append(getColumn(false, " <img src=\""
- + "/coregui/images/subsystems/availability/availability_red_16.png" + "\" />", down));
+ + "/coregui/images/subsystems/availability/availability_red_16.png" + "\" />", notUp));
} else {
results.append(getColumn(false,
" <img src=\"/coregui/images/blank.png\" width=\"16px\" height=\"16px\" />"));
@@ -261,8 +317,9 @@ public class ResourceGroupComposite implements Serializable {
public String toString() {
return "ResourceGroupComposite[name="
+ this.resourceGroup.getName() //
- + ", implicit[up/down/avail=," + this.implicitUp + "/" + this.implicitDown + "/" + this.implicitAvail + "]"
- + ", explicit[up/down/avail=," + this.explicitUp + "/" + this.explicitDown + "/" + this.explicitAvail + "]"
- + ", facets=" + ((this.resourceFacets == null) ? "none" : this.resourceFacets.getFacets()) + "]";
+ + ", implicit[count/down/disabled=," + this.implicitCount + "/" + this.implicitDown + "/"
+ + this.implicitDisabled + "]" + ", explicit[count/down/disabled=," + this.explicitCount + "/"
+ + this.explicitDown + "/" + this.explicitDisabled + "]" + ", facets="
+ + ((this.resourceFacets == null) ? "none" : this.resourceFacets.getFacets()) + "]";
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index 3aed726..f1be523 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -14,6 +14,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite.GroupAvailabilityType;
/**
* Provides an API to obtain links to images and icons, thus avoiding hardcoding image URLs throughout client code.
@@ -281,40 +282,43 @@ public class ImageManager {
}
/**
- * Returns the group icon badged with availability icon. Avails is the
- * percentage of resources in the group that are UP. If avails is 0, it is
- * red (no resources are available), if it is 1, it is green (all resources
- * are available), if it is between 0 and 1, it is yellow.
- *
- * If avails is null, this means there are no resources in the group. In that
- * case, this method returns the "UP" badged icon.
- *
+ * Returns the group icon badged with availability icon. Group avail
+ * badging is determined in the following way, in order:
+ * allDown = red
+ * someDown = yellow
+ * someDisabled = orange
+ * otherwise = green
+ *
* @param groupType the type of group
- * @param avails percentage of resources that are UP
* @return the group badge icon
*/
- public static String getGroupIcon(GroupCategory groupType, Double avails) {
- return getGroupIcon(groupType, avails, "16");
+ public static String getGroupIcon(GroupCategory groupType, GroupAvailabilityType groupAvailType) {
+ return getGroupIcon(groupType, groupAvailType, "16");
}
- public static String getGroupLargeIcon(GroupCategory groupType, Double avails) {
- return getGroupIcon(groupType, avails, "24");
+ /**
+ * @see #getGroupIcon(GroupCategory, GroupAvailabilityType)
+ */
+ public static String getGroupLargeIcon(GroupCategory groupType, GroupAvailabilityType groupAvailType) {
+ return getGroupIcon(groupType, groupAvailType, "24");
}
- private static String getGroupIcon(GroupCategory groupType, Double avails, String size) {
+ /**
+ * @see #getGroupIcon(GroupCategory, GroupAvailabilityType)
+ */
+ private static String getGroupIcon(GroupCategory groupType, GroupAvailabilityType groupAvailType, String size) {
String category = groupType == GroupCategory.COMPATIBLE ? "Cluster" : "Group";
- if (avails == null) {
+ switch (groupAvailType) {
+ case EMPTY:
return "types/" + category + "_up_" + size + ".png";
- }
-
- double val = avails.doubleValue();
-
- if (val == 0.0d) {
+ case DOWN:
return "types/" + category + "_down_" + size + ".png";
- } else if (val > 0.0d && val < 1.0d) {
+ case WARN:
return "types/" + category + "_warning_" + size + ".png";
- } else {
+ case DISABLED:
+ return "types/" + category + "_disabled_" + size + ".png";
+ default:
return "types/" + category + "_up_" + size + ".png";
}
}
@@ -368,28 +372,26 @@ public class ImageManager {
}
/**
- * Returns the large availability icon based on the given percentage.
- * Avails is the percentage of availabilities that are UP. If avails is 0, it is
- * red (nothing is available), if it is 1, it is green (everything is available),
- * if it is between 0 and 1, it is yellow.
- *
- * If avails is null, the icon will be the unknown/grey form.
- *
- * @param avails percentage of availabilities that are UP
- * @return the large availability icon
+ * Returns the large availability icon based on group availability. Determined in the following way, in order:
+ * empty = grey
+ * allDown = red
+ * someDown = yellow
+ * someDisabled = orange
+ * otherwise = green
+ *
+ * @return the large avail icon
*/
- public static String getAvailabilityGroupLargeIcon(Double avails) {
- if (avails == null) {
+ public static String getAvailabilityGroupLargeIcon(GroupAvailabilityType groupAvailType) {
+ switch (groupAvailType) {
+ case EMPTY:
return "subsystems/availability/availability_grey_24.png";
- }
-
- double val = avails.doubleValue();
-
- if (val == 0.0d) {
+ case DOWN:
return "subsystems/availability/availability_red_24.png";
- } else if (val > 0.0d && val < 1.0d) {
+ case WARN:
return "subsystems/availability/availability_yellow_24.png";
- } else {
+ case DISABLED:
+ return "subsystems/availability/availability_orange_24.png";
+ default:
return "subsystems/availability/availability_green_24.png";
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
index fe19915..e693f5c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
@@ -325,7 +325,7 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
ResourceGroup emptyGroup = new ResourceGroup("");
emptyGroup.setId(-1);
Long zero = new Long(0);
- groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, emptyGroup);
+ groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, zero, zero, emptyGroup);
groupHistoryTable = new GroupConfigurationHistoryCriteriaTable(extendLocatorId("Table"),
groupComposite);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index 7bb6d08..e8e7719 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -177,7 +177,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
ResourceGroup emptyGroup = new ResourceGroup("");
emptyGroup.setId(-1);
Long zero = new Long(0);
- groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, emptyGroup);
+ groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, zero, zero, emptyGroup);
groupOperations = new GroupOperationsCriteriaHistoryListView(locatorId,
new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
index e2f37f6..5586f13 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
@@ -227,7 +227,8 @@ public class FavoritesButton extends LocatableIMenuButton {
MenuItem item = new MenuItem(String.valueOf(groupId));
item.setTitle(group.getName());
- item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite.getImplicitAvail()));
+ item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(),
+ groupComposite.getImplicitAvailabilityType()));
item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
public void onClick(MenuItemClickEvent event) {
@@ -295,7 +296,8 @@ public class FavoritesButton extends LocatableIMenuButton {
MenuItem item = new MenuItem(String.valueOf(groupId));
item.setTitle(group.getName());
- item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite.getImplicitAvail()));
+ item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(),
+ groupComposite.getImplicitAvailabilityType()));
item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
public void onClick(MenuItemClickEvent event) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
index bdf2cb1..d334cd7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
@@ -39,6 +39,7 @@ import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -162,13 +163,15 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
rg.setResourceType(rt);
}
- Long explicitUp = Long.valueOf(from.getAttribute("explicitUp"));
+ Long explicitCount = Long.valueOf(from.getAttribute("explicitCount"));
Long explicitDown = Long.valueOf(from.getAttribute("explicitDown"));
- Long implicitUp = Long.valueOf(from.getAttribute("implicitUp"));
+ Long explicitDisabled = Long.valueOf(from.getAttribute("explicitDisabled"));
+ Long implicitCount = Long.valueOf(from.getAttribute("implicitCount"));
Long implicitDown = Long.valueOf(from.getAttribute("implicitDown"));
+ Long implicitDisabled = Long.valueOf(from.getAttribute("implicitDisabled"));
- ResourceGroupComposite composite = new ResourceGroupComposite(explicitUp, explicitDown, implicitUp,
- implicitDown, rg);
+ ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitDisabled,
+ implicitCount, implicitDown, implicitDisabled, rg);
return composite;
}
@@ -182,10 +185,12 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
record.setAttribute(DESCRIPTION.propertyName(), from.getResourceGroup().getDescription());
record.setAttribute(CATEGORY.propertyName(), from.getResourceGroup().getGroupCategory().name());
- record.setAttribute("explicitUp", String.valueOf(from.getExplicitUp()));
+ record.setAttribute("explicitCount", String.valueOf(from.getExplicitCount()));
record.setAttribute("explicitDown", String.valueOf(from.getExplicitDown()));
- record.setAttribute("implicitUp", String.valueOf(from.getImplicitUp()));
+ record.setAttribute("explicitDisabled", String.valueOf(from.getExplicitDisabled()));
+ record.setAttribute("implicitCount", String.valueOf(from.getImplicitCount()));
record.setAttribute("implicitDown", String.valueOf(from.getImplicitDown()));
+ record.setAttribute("implicitDisabled", String.valueOf(from.getImplicitDisabled()));
record.setAttribute(AVAIL_CHILDREN.propertyName(), getExplicitFormatted(from));
record.setAttribute(AVAIL_DESCENDANTS.propertyName(), getImplicitFormatted(from));
@@ -200,36 +205,48 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
}
private String getExplicitFormatted(ResourceGroupComposite from) {
- return getAlignedAvailabilityResults(from.getExplicitUp(), from.getExplicitDown());
+ return getAlignedAvailabilityResults(from.getExplicitCount(), from.getExplicitUpAndUnknown(),
+ from.getExplicitDown(), from.getExplicitDisabled());
}
private String getImplicitFormatted(ResourceGroupComposite from) {
- return getAlignedAvailabilityResults(from.getImplicitUp(), from.getImplicitDown());
+ return getAlignedAvailabilityResults(from.getImplicitCount(), from.getImplicitUpAndUnknown(),
+ from.getImplicitDown(), from.getImplicitDisabled());
}
- private String getAlignedAvailabilityResults(long up, long down) {
+ private String getAlignedAvailabilityResults(long total, long up, long down, long disabled) {
StringBuilder results = new StringBuilder();
- results.append("<table width=\"120px\"><tr>");
- if (up == 0 && down == 0) {
+
+ results.append("<table width=\"180px\"><tr>");
+ if (0 == total) {
results.append(getColumn(false,
"<img src=\"" + ImageManager.getFullImagePath(ImageManager.getAvailabilityIcon(null)) + "\" /> 0"));
results.append(getColumn(true));
results.append(getColumn(false));
+
} else {
if (up > 0) {
+ String imagePath = ImageManager.getFullImagePath(ImageManager
+ .getAvailabilityIconFromAvailType(AvailabilityType.UP));
+ results.append(getColumn(false, " <img src=\"" + imagePath + "\" />", up));
+ } else {
results.append(getColumn(false,
- " <img src=\"" + ImageManager.getFullImagePath(ImageManager.getAvailabilityIcon(Boolean.TRUE))
- + "\" />", up));
- }
-
- if (up > 0 && down > 0) {
- results.append(getColumn(true)); // , " / ")); // use a vertical separator image if we want a separator
+ " <img src=\"/images/blank.png\" width=\"16px\" height=\"16px\" />"));
}
if (down > 0) {
+ String imagePath = ImageManager.getFullImagePath(ImageManager
+ .getAvailabilityIconFromAvailType(AvailabilityType.DOWN));
+ results.append(getColumn(false, " <img src=\"" + imagePath + "\" />", down));
+ } else {
results.append(getColumn(false,
- " <img src=\"" + ImageManager.getFullImagePath(ImageManager.getAvailabilityIcon(Boolean.FALSE))
- + "\" />", down));
+ " <img src=\"/images/blank.png\" width=\"16px\" height=\"16px\" />"));
+ }
+
+ if (disabled > 0) {
+ String imagePath = ImageManager.getFullImagePath(ImageManager
+ .getAvailabilityIconFromAvailType(AvailabilityType.DISABLED));
+ results.append(getColumn(false, " <img src=\"" + imagePath + "\" />", disabled));
} else {
results.append(getColumn(false,
" <img src=\"/images/blank.png\" width=\"16px\" height=\"16px\" />"));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
index 77bf39a..6b1a9a9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
@@ -18,11 +18,29 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups;
+import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.AVAIL_CHILDREN;
+import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.AVAIL_DESCENDANTS;
+import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.CATEGORY;
+import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.DESCRIPTION;
+import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.NAME;
+import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.PLUGIN;
+import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.TYPE;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.events.*;
-import com.smartgwt.client.widgets.grid.*;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.events.CloseClickEvent;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+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 org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.search.SearchSubsystem;
@@ -30,7 +48,11 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.PopupWindow;
-import org.rhq.enterprise.gui.coregui.client.components.table.*;
+import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.AuthorizedTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.IconField;
+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.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.wizard.GroupCreateWizard;
@@ -39,8 +61,6 @@ 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.SeleniumUtility;
-import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.*;
-
/**
* @author Greg Hinkle
* @author Joseph Marques
@@ -74,7 +94,7 @@ public class ResourceGroupListView extends Table<ResourceGroupCompositeDataSourc
setDataSource(datasource);
}
- public ResourceGroupListView(String locatorId, Criteria criteria ){
+ public ResourceGroupListView(String locatorId, Criteria criteria) {
super(locatorId, null, criteria);
final ResourceGroupCompositeDataSource datasource = ResourceGroupCompositeDataSource.getInstance();
@@ -144,14 +164,14 @@ public class ResourceGroupListView extends Table<ResourceGroupCompositeDataSourc
pluginNameField.setWidth("8%");
ListGridField availabilityChildrenField = new ListGridField(AVAIL_CHILDREN.propertyName(),
- AVAIL_CHILDREN.title(), 110); // 110 due to the html in ResourceGroupCompositeDataSource.getAlignedAvailabilityResults
+ AVAIL_CHILDREN.title(), 170); // 170 due to the html in ResourceGroupCompositeDataSource.getAlignedAvailabilityResults
availabilityChildrenField.setCanSortClientOnly(true);
availabilityChildrenField.setCanGroupBy(false);
availabilityChildrenField.setWrap(false);
availabilityChildrenField.setAlign(Alignment.CENTER);
ListGridField availabilityDescendantsField = new ListGridField(AVAIL_DESCENDANTS.propertyName(),
- AVAIL_DESCENDANTS.title(), 110); // 110 due to the html in ResourceGroupCompositeDataSource.getAlignedAvailabilityResults
+ AVAIL_DESCENDANTS.title(), 170); // 110 due to the html in ResourceGroupCompositeDataSource.getAlignedAvailabilityResults
availabilityDescendantsField.setCanSortClientOnly(true);
availabilityDescendantsField.setCanGroupBy(false);
availabilityDescendantsField.setWrap(false);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
index 472d7f8..af036ac 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
@@ -18,12 +18,16 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
+import java.util.ArrayList;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.HLayout;
+
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.GroupDefinition;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -42,9 +46,6 @@ import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* A canvas that shows basic information/properties on a specific group.
*
@@ -58,7 +59,7 @@ public class GeneralProperties extends LocatableVLayout {
private boolean isAutoGroup;
public GeneralProperties(String locatorId, ResourceGroupComposite groupComposite, ResourceGroupTitleBar titleBar,
- boolean isAutoGroup) {
+ boolean isAutoGroup) {
super(locatorId);
this.groupComposite = groupComposite;
this.titleBar = titleBar;
@@ -114,8 +115,8 @@ public class GeneralProperties extends LocatableVLayout {
titleBar.displayGroupName(newName);
CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_group_summary_nameUpdateSuccessful(String.valueOf(group
- .getId()), oldName, newName), Message.Severity.Info));
+ new Message(MSG.view_group_summary_nameUpdateSuccessful(
+ String.valueOf(group.getId()), oldName, newName), Message.Severity.Info));
}
});
}
@@ -147,7 +148,7 @@ public class GeneralProperties extends LocatableVLayout {
formItems.add(typeItem);
StaticTextItem countItem = new StaticTextItem("memberCount", MSG.view_group_summary_memberCount());
- long memberCount = this.groupComposite.getImplicitUp() + this.groupComposite.getImplicitDown();
+ long memberCount = this.groupComposite.getImplicitCount();
countItem.setValue(memberCount);
formItems.add(countItem);
@@ -201,8 +202,8 @@ public class GeneralProperties extends LocatableVLayout {
FormItem recursiveItem;
if (isEditable) {
- CheckboxEditableFormItem editableRecursiveItem = new CheckboxEditableFormItem("recursive", MSG
- .view_group_summary_recursive());
+ CheckboxEditableFormItem editableRecursiveItem = new CheckboxEditableFormItem("recursive",
+ MSG.view_group_summary_recursive());
editableRecursiveItem.setValueEditedHandler(new ValueEditedHandler() {
public void editedValue(Object newValue) {
boolean isRecursive = ((newValue != null) && (Boolean) newValue);
@@ -239,8 +240,8 @@ public class GeneralProperties extends LocatableVLayout {
formItems.add(lastModifiedByItem);
if (isDynaGroup) {
- StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", MSG
- .view_group_summary_groupDefinition());
+ StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition",
+ MSG.view_group_summary_groupDefinition());
GroupDefinition groupDefinition = group.getGroupDefinition();
String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId());
String groupDefinitionName = StringUtility.escapeHtml(groupDefinition.getName());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
index 669da75..b423670 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
@@ -35,6 +35,7 @@ import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite.GroupAvailabilityType;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -270,10 +271,11 @@ public class ResourceGroupTitleBar extends LocatableVLayout {
this.title.markForRedraw();
}
- private void setGroupIcons(ResourceGroupComposite groupComposite) {
- Double avails = groupComposite.getExplicitAvail();
- this.badge.setSrc(ImageManager.getGroupLargeIcon(this.group.getGroupCategory(), avails));
- this.availabilityImage.setSrc(ImageManager.getAvailabilityGroupLargeIcon(avails));
+ private void setGroupIcons(ResourceGroupComposite composite) {
+ GroupAvailabilityType groupAvailType = composite.getExplicitAvailabilityType();
+
+ this.badge.setSrc(ImageManager.getGroupLargeIcon(this.group.getGroupCategory(), groupAvailType));
+ this.availabilityImage.setSrc(ImageManager.getAvailabilityGroupLargeIcon(groupAvailType));
}
private void updateFavoriteButton() {
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/types/Cluster_disabled_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/types/Cluster_disabled_16.png
new file mode 100644
index 0000000..9b4c638
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/types/Cluster_disabled_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/types/Cluster_disabled_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/types/Cluster_disabled_24.png
new file mode 100644
index 0000000..b7a173a
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/types/Cluster_disabled_24.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/types/Group_disabled_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/types/Group_disabled_16.png
new file mode 100644
index 0000000..6843f68
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/types/Group_disabled_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/types/Group_disabled_24.png b/modules/enterprise/gui/coregui/src/main/webapp/images/types/Group_disabled_24.png
new file mode 100644
index 0000000..cce9b4b
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/types/Group_disabled_24.png differ
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java
index b2cda55..9ad5969 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java
@@ -67,7 +67,7 @@ public class ResourceGroupUIBean {
public ResourceGroupUIBean(ResourceGroupComposite resourceGroupComposite, Subject subject) {
this.resourceGroup = resourceGroupComposite.getResourceGroup();
- this.upCount = resourceGroupComposite.getExplicitUp();
+ this.upCount = resourceGroupComposite.getExplicitUpAndUnknown();
this.downCount = resourceGroupComposite.getExplicitDown();
this.count = upCount + downCount;
this.availability = resourceGroupComposite.getExplicitAvail();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index d29eaac..8c37ac4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -87,7 +87,6 @@ import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
-import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
@@ -625,13 +624,11 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
ResourceGroupComposite groupComposite = this.resourceGroupManager.getResourceGroupComposite(subject, groupId);
// if the group is empty (has no members) the availability will be null
- if (groupComposite.getExplicitAvail() == null) {
+ if (0 == groupComposite.getExplicitCount()) {
return new HashMap<Integer, Configuration>();
}
- AvailabilityType availability = (groupComposite.getExplicitAvail() == 1) ? AvailabilityType.UP
- : AvailabilityType.DOWN;
- if (availability == AvailabilityType.DOWN)
+ if (groupComposite.getExplicitDown() > 0)
throw new Exception("Current group Resource configuration for " + groupId
+ " cannot be calculated, because one or more of this group's member Resources are DOWN.");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
index 75894ad..cd710ac 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
@@ -400,9 +400,20 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
} else if (context.type == EntityContext.Type.ResourceGroup) {
ResourceGroupComposite composite = resourceGroupManager.getResourceGroupComposite(subject,
context.groupId);
- Double firstAvailability = composite.getExplicitAvail();
- newFirstAvailabilityType = firstAvailability == null ? null
- : (firstAvailability == 1.0 ? AvailabilityType.UP : AvailabilityType.DOWN);
+ switch (composite.getExplicitAvailabilityType()) {
+ case EMPTY:
+ newFirstAvailabilityType = null;
+ break;
+ case DOWN:
+ case WARN:
+ newFirstAvailabilityType = AvailabilityType.DOWN;
+ break;
+ case DISABLED:
+ newFirstAvailabilityType = AvailabilityType.DISABLED;
+ break;
+ default:
+ newFirstAvailabilityType = AvailabilityType.UP;
+ }
} else {
// March 20, 2009: we only support the "summary area" for resources and resourceGroups to date
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index d808969..e3e243e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -241,6 +241,15 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
clearImplicitResources(groupId);
makeImplicitMirrorExplicit(groupId);
}
+
+ if (updateMembership) {
+ try {
+ setResourceType(groupId);
+ } catch (ResourceGroupDeleteException e) {
+ throw new ResourceGroupNotFoundException(e.getMessage());
+ }
+ }
+
return newlyAttachedGroup;
}
@@ -433,6 +442,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
@RequiredPermission(Permission.MANAGE_INVENTORY)
public void addResourcesToGroup(Subject subject, int groupId, int[] resourceIds) {
+
+ addResourcesToGroup(subject, groupId, resourceIds, true);
+ }
+
+ private void addResourcesToGroup(Subject subject, int groupId, int[] resourceIds, boolean setType) {
Integer[] ids = ArrayUtils.wrapInArray(resourceIds);
if (ids == null || ids.length == 0) {
return;
@@ -448,6 +462,14 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
addResourcesToGroupImplicit(subject, groupId, batchIds, true, isRecursive);
addResourcesToGroupExplicit(subject, groupId, batchIds, isRecursive);
}
+
+ if (setType) {
+ try {
+ setResourceType(groupId);
+ } catch (ResourceGroupDeleteException e) {
+ throw new ResourceGroupNotFoundException(e.getMessage());
+ }
+ }
}
private void addResourcesToGroupExplicit(Subject subject, Integer groupId, List<Integer> resourceIds,
@@ -571,6 +593,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
@RequiredPermission(Permission.MANAGE_INVENTORY)
public void removeResourcesFromGroup(Subject subject, int groupId, int[] resourceIds) {
+
+ removeResourcesFromGroup(subject, groupId, resourceIds, true);
+ }
+
+ private void removeResourcesFromGroup(Subject subject, int groupId, int[] resourceIds, boolean setType) {
Integer[] ids = ArrayUtils.wrapInArray(resourceIds);
if (ids == null || ids.length == 0) {
return;
@@ -584,6 +611,14 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
removeResourcesFromGroup_helper(subject, groupId, batchIdArray, isRecursive);
}
+
+ if (setType) {
+ try {
+ setResourceType(groupId);
+ } catch (ResourceGroupDeleteException e) {
+ throw new ResourceGroupNotFoundException(e.getMessage());
+ }
+ }
}
private void removeResourcesFromGroup_helper(Subject subject, Integer groupId, Integer[] resourceIds,
@@ -1156,18 +1191,14 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
try {
while (rs.next()) {
long explicitCount = rs.getLong(1);
- long explicitUpCount = rs.getLong(2);
- //double explicitAvail = rs.getDouble(2);
- long implicitCount = rs.getLong(3);
- long implicitUpCount = rs.getLong(4);
- //double implicitAvail = rs.getDouble(4);
- // In the past we had only DOWN/0 and UP/1 avails/ordinal and and the avails were just averages.
- // Now we have DISABLED and UNKNOWN. So group avail is done differently, instead of an indication
- // of UP vs DOWN it is now UP vs NOT UP (not up is every other avail).
- double explicitAvail = (explicitCount > 0) ? (explicitUpCount / explicitCount) : 0D;
- double implicitAvail = (implicitCount > 0) ? (implicitUpCount / implicitCount) : 0D;
+ long explicitDown = rs.getLong(2);
+ long explicitDisabled = rs.getLong(3);
+ long implicitCount = rs.getLong(4);
+ long implicitDown = rs.getLong(5);
+ long implicitDisabled = rs.getLong(6);
int groupKey = rs.getInt(5);
- Object[] next = new Object[] { explicitCount, explicitAvail, implicitCount, implicitAvail, groupKey };
+ Object[] next = new Object[] { explicitCount, explicitDown, explicitDisabled, implicitCount,
+ implicitDown, implicitDisabled, groupKey };
rawResults.add(next);
}
} finally {
@@ -1208,9 +1239,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
int i = 0;
for (Object[] row : rawResults) {
long explicitCount = (Long) row[0];
- double explicitAvail = (Double) row[1];
- long implicitCount = (Long) row[2];
- double implicitAvail = (Double) row[3];
+ long explicitDown = (Long) row[1];
+ long explicitDisabled = (Long) row[2];
+ long implicitCount = (Long) row[3];
+ long implicitDown = (Long) row[4];
+ long implicitDisabled = (Long) row[5];
ResourceGroup group = groupMap.get(groupIds.get(i++));
ResourceType type = group.getResourceType();
ResourceFacets facets;
@@ -1221,8 +1254,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
// compatible group
facets = resourceTypeManager.getResourceFacets(type.getId());
}
- ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitAvail, implicitCount,
- implicitAvail, group, facets);
+ ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown,
+ explicitDisabled, implicitCount, implicitDown, implicitDisabled, group, facets);
Set<Permission> perms = authorizationManager.getImplicitGroupPermissions(subject, group.getId());
composite.setResourcePermission(new ResourcePermission(perms));
results.add(composite);
@@ -1294,13 +1327,14 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
List<Integer> newMembers = ArrayUtils.wrapInList(resourceIds); // members needing addition
newMembers.removeAll(currentMembers);
if (newMembers.size() > 0) {
- addResourcesToGroup(subjectManager.getOverlord(), groupId, ArrayUtils.unwrapCollection(newMembers));
+ addResourcesToGroup(subjectManager.getOverlord(), groupId, ArrayUtils.unwrapCollection(newMembers), false);
}
List<Integer> extraMembers = new ArrayList<Integer>(currentMembers); // members needing removal
extraMembers.removeAll(ArrayUtils.wrapInList(resourceIds));
if (extraMembers.size() > 0) {
- removeResourcesFromGroup(subjectManager.getOverlord(), groupId, ArrayUtils.unwrapCollection(extraMembers));
+ removeResourcesFromGroup(subjectManager.getOverlord(), groupId, ArrayUtils.unwrapCollection(extraMembers),
+ false);
}
// As a result of the membership change ensure that the group type is set correctly.
@@ -1362,17 +1396,25 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
throw new PermissionException("You do not have permission to view this resource group");
}
+ // Could do this with two GROUP BY queries but we'll go with one RT to the db and hope that's best, despite
+ // all the subselects.
String queryString = "SELECT \n" //
- + " (SELECT count(er) "
+ + " (SELECT count(er) " // Total explicit
+ " FROM ResourceGroup g JOIN g.explicitResources er where g.id = :groupId),\n"
- + " (SELECT count(er) "
+ + " (SELECT count(er) " // DOWN explicit
+ " FROM ResourceGroup g JOIN g.explicitResources er where g.id = :groupId"
- + " AND er.currentAvailability.availabilityType = 1 ),\n"
- + " (SELECT count(ir) "
+ + " AND er.currentAvailability.availabilityType = 0 ),\n"
+ + " (SELECT count(er) " // DISABLED explicit
+ + " FROM ResourceGroup g JOIN g.explicitResources er where g.id = :groupId"
+ + " AND er.currentAvailability.availabilityType = 3 ),\n"
+ + " (SELECT count(ir) " // Total implicit
+ " FROM ResourceGroup g JOIN g.implicitResources ir where g.id = :groupId),\n"
- + " (SELECT count(ir) "
+ + " (SELECT count(ir) " // DOWN implicit
+ + " FROM ResourceGroup g JOIN g.implicitResources ir where g.id = :groupId"
+ + " AND ir.currentAvailability.availabilityType = 0 ), g \n"
+ + " (SELECT count(ir) " // DISABLED implicit
+ " FROM ResourceGroup g JOIN g.implicitResources ir where g.id = :groupId"
- + " AND ir.currentAvailability.availabilityType = 1 ), g \n"
+ + " AND ir.currentAvailability.availabilityType = 3 ), g \n"
+ "FROM ResourceGroup g where g.id = :groupId";
Query query = entityManager.createQuery(queryString);
@@ -1399,19 +1441,19 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
ResourceGroupComposite composite = null;
if (((Number) data[2]).longValue() > 0) {
long explicitCount = ((Number) data[0]).longValue();
- long explicitUpCount = ((Number) data[1]).longValue();
- long implicitCount = ((Number) data[2]).longValue();
- long implicitUpCount = ((Number) data[3]).longValue();
+ long explicitDownCount = ((Number) data[1]).longValue();
+ long explicitDisabledCount = ((Number) data[2]).longValue();
+ long implicitCount = ((Number) data[3]).longValue();
+ long implicitDownCount = ((Number) data[4]).longValue();
+ long implicitDisabledCount = ((Number) data[5]).longValue();
// In the past we had only DOWN/0 and UP/1 avails/ordinal and and the avails were just averages.
- // Now we have DISABLED and UNKNOWN. So group avail is done differently, instead of an indication
- // of UP vs DOWN it is now UP vs NOT UP (not up is every other avail).
- double explicitAvail = (explicitCount > 0) ? (explicitUpCount / explicitCount) : 0D;
- double implicitAvail = (implicitCount > 0) ? (implicitUpCount / implicitCount) : 0D;
+ // Now we have DISABLED and UNKNOWN. So group avail is done differently, instead of a ratio of
+ // of UP vs DOWN it is now handled with counts. This is handled in the composite.
- composite = new ResourceGroupComposite(explicitCount, explicitAvail, implicitCount, implicitAvail, group,
- facets);
+ composite = new ResourceGroupComposite(explicitCount, explicitDownCount, explicitDisabledCount,
+ implicitCount, implicitDownCount, implicitDisabledCount, group, facets);
} else {
- composite = new ResourceGroupComposite(0L, 0.0, 0L, 0.0, group, facets);
+ composite = new ResourceGroupComposite(0L, 0L, 0L, 0L, 0L, 0L, group, facets);
}
return composite;
@@ -1483,14 +1525,10 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
* 2) It can not be a candidate for filtering
* 3) It must be sorted by using the zero-based positional ordinal within the projection
*
- * This method offers 4 new aggregates that you can sort on. The
+ * This method offers 2 new aggregates that you can sort on. The
*
* explicitCount (ordinal 0) - the count of the number of children in the group
- * explicitAvail (ordinal 1) - decimal percentage representing the number of UP children relative to the total
- * number of children in the group
* implicitCount (ordinal 2) - the count of the number of descendents in the group
- * implicitAvail (ordinal 3) - decimal percentage representing the number of UP descendents relative to the total
- * number of descendents in the group
*/
public PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(Subject subject,
ResourceGroupCriteria criteria) {
@@ -1504,9 +1542,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
compositeProjection = ""
+ " new org.rhq.core.domain.resource.group.composite.ResourceGroupComposite( "
+ " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail ) AS explicitCount," // explicit member count
- + " ( SELECT AVG(avail.availabilityType) FROM %alias%.explicitResources res JOIN res.currentAvailability avail ) AS explicitAvail," // explicit member availability
+ + " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 0 ) AS explicitUpCount," // explicit member count with DOWN avail
+ + " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 3 ) AS explicitUpCount," // explicit member count with DISABLED avail
+ " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail ) AS implicitCount," // implicit member count
- + " ( SELECT AVG(avail.availabilityType) FROM %alias%.implicitResources res JOIN res.currentAvailability avail ) AS implicitAvail," // implicit member availability
+ + " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 0 ) AS implicitUpCount," // implicit member count with DOWN avail
+ + " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 3 ) AS implicitUpCount," // implicit member count with DISABLED avail
+ " %alias% ) "; // ResourceGroup
break;
case ROLE_OWNED:
@@ -1514,9 +1554,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
compositeProjection = ""
+ " new org.rhq.core.domain.resource.group.composite.ResourceGroupComposite( "
+ " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail ) AS explicitCount," // explicit member count
- + " ( SELECT AVG(avail.availabilityType) FROM %alias%.explicitResources res JOIN res.currentAvailability avail ) AS explicitAvail," // explicit member availability
+ + " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 0 ) AS explicitUpCount," // explicit member count with DOWN avail
+ + " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 3 ) AS explicitUpCount," // explicit member count with DISABLED avail
+ " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail ) AS implicitCount," // implicit member count
- + " ( SELECT AVG(avail.availabilityType) FROM %alias%.implicitResources res JOIN res.currentAvailability avail ) AS implicitAvail," // implicit member availability
+ + " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 0 ) AS implicitUpCount," // implicit member count with DOWN avail
+ + " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 3 ) AS implicitUpCount," // implicit member count with DISABLED avail
+ " %alias%, " // ResourceGroup
+ " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 8 ), " // MANAGE_MEASUREMENTS
+ " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 4 ), " // MODIFY_RESOURCE
11 years, 8 months
[rhq] modules/plugins
by ips
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 36 ++++++----
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java | 14 ++-
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java | 23 +++---
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java | 1
4 files changed, 45 insertions(+), 29 deletions(-)
New commits:
commit 612984a9167b6db1577858b7bf10641db88a8df4
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 16:12:30 2012 -0400
fix so rolled-back attribute gets correctly deserialized to JsonNode returned for 500 responses (this fixes a couple failing tests); further improve error reporting
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 10610fc..e87c68f 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
@@ -147,9 +147,8 @@ public class ASConnection {
int timeoutMillis = timeoutSec * 1000;
conn.setConnectTimeout(timeoutMillis);
conn.setReadTimeout(timeoutMillis);
-
if (conn.getReadTimeout() != timeoutMillis) {
- log.warn("The JRE uses a broken timeout mechanism - nothing we can do.");
+ log.warn("Read timeout did not get set on HTTP connection - the JRE uses a broken timeout mechanism - nothing we can do.");
}
out = conn.getOutputStream();
@@ -161,7 +160,7 @@ public class ASConnection {
}
// TODO (ips): Would it make more sense to return null here, since we didn't even connect?
Result failure = new Result();
- failure.setFailureDescription(e.getMessage());
+ failure.setFailureDescription(e.toString());
failure.setOutcome("failure");
failure.setRhqThrowable(e);
JsonNode ret = mapper.valueToTree(failure);
@@ -212,7 +211,7 @@ public class ASConnection {
String outcome;
JsonNode operationResult;
- if (responseBody.length() > 0) {
+ if (!responseBody.isEmpty()) {
outcome = responseBody;
operationResult = mapper.readTree(outcome);
if (verbose) {
@@ -277,16 +276,29 @@ public class ASConnection {
} catch (IOException ioe) {
responseCodeString = "unknown response code";
}
- log.error(operation + " failed with " + responseCodeString + " - response body was [" + responseBody + "].",
- e);
+ String failureDescription = operation + " failed with " + responseCodeString + " - response body was ["
+ + responseBody + "].";
+ log.error(failureDescription, e);
+
+ JsonNode operationResult = null;
+ if (!responseBody.isEmpty()) {
+ try {
+ operationResult = mapper.readTree(responseBody);
+ } catch (IOException ioe) {
+ log.error("Failed to deserialize response body [" + responseBody + "] to JsonNode: " + ioe);
+ }
+ }
- Result failure = new Result();
- failure.setFailureDescription(e.getMessage());
- failure.setOutcome("failure");
- failure.setRhqThrowable(e);
+ if (operationResult == null) {
+ Result result = new Result();
+ result.setOutcome("failure");
+ result.setFailureDescription(failureDescription);
+ result.setRolledBack(responseBody.contains("rolled-back=true"));
+ result.setRhqThrowable(e);
+ operationResult = mapper.valueToTree(result);
+ }
- JsonNode ret = mapper.valueToTree(failure);
- return ret;
+ return operationResult;
} finally {
long requestEndTime = System.currentTimeMillis();
PluginStats stats = PluginStats.getInstance();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index 478f303..2c34641 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -18,15 +18,18 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
-import java.util.List;
import java.util.Map;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/**
- * Counterpart of a result JSON object like e.g.:
- * <pre>{"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null}</pre>
+ * Counterpart of a result JSON object, e.g.:
+ * <pre>
+ * {"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null}
+ * {"outcome" : "failed", "failure-description" : "JBAS010850: No handler for operation foo at address []", "rolled-back" : true}
+ * </pre>
+ *
* @author Heiko W. Rupp
*/
public class Result {
@@ -134,7 +137,10 @@ public class Result {
@Override
public String toString() {
return "Result{" +
- "success=" + success +
+ "outcome='" + outcome + '\'' +
+ ", failureDescription=" + failureDescription +
+ ", rolledBack=" + rolledBack +
'}';
}
+
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java
index 20094da..2f8023a 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java
@@ -2,8 +2,6 @@ package org.rhq.modules.plugins.jbossas7.itest.nonpc;
import java.util.Map;
-import org.testng.annotations.Test;
-
import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
@@ -11,6 +9,8 @@ import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
import org.rhq.modules.plugins.jbossas7.json.Result;
+import static org.testng.Assert.*;
+
/**
* Miscellaneous tests that don't fit well into other test classes
*
@@ -21,11 +21,10 @@ public class MiscTest extends AbstractIntegrationTest {
public void testSetRollback() throws Exception {
Operation op = new Operation("foo", new Address());
Result res = getASConnection().execute(op);
- assert res != null;
- assert !res.isSuccess() : "Response was successful.";
- assert res.isRolledBack() : "Response was not rolled back: " + res.getFailureDescription();
- assert res.getFailureDescription().endsWith("rolled-back=true")
- : "Unexpected failure description: " + res.getFailureDescription();
+ assertNotNull(res);
+ assertFalse(res.isSuccess(), "Response outcome was success.");
+ assertTrue(res.isRolledBack(), "Response was not rolled back: " + res);
+ assertTrue(res.getFailureDescription().endsWith("rolled-back=true"), "Unexpected failure description: " + res);
}
public void testCompositeReadAttribute() throws Exception {
@@ -37,11 +36,11 @@ public class MiscTest extends AbstractIntegrationTest {
cop.addStep(step2);
ComplexResult res = getASConnection().executeComplex(cop);
- assert res!=null;
- assert res.isSuccess();
- Map<String,Object> resResult = res.getResult();
- assert resResult !=null;
- assert resResult.size()==2;
+ assertNotNull(res);
+ assertTrue(res.isSuccess(), "Response outcome was failure.");
+ Map<String, Object> resResult = res.getResult();
+ assertNotNull(resResult);
+ assertEquals(resResult.size(), 2);
}
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
index 279efdf..b1d9a40 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
@@ -22,7 +22,6 @@ package org.rhq.modules.plugins.jbossas7.itest.standalone;
import java.util.Iterator;
import org.jetbrains.annotations.NotNull;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.agent.PluginContainerException;
11 years, 8 months
[rhq] Branch 'feature/export-reports' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java | 1 -
1 file changed, 1 deletion(-)
New commits:
commit fd6b948e9a5104b6c0ea66d1b4fd00671870c2a2
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Mar 30 15:22:49 2012 -0400
[BZ 800453] removing some code that was for testing only
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java
index 21327ee..cfe94bd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java
@@ -86,7 +86,6 @@ public class SuspectMetricHandler extends AbstractRestBean implements SuspectMet
return new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
- PageControl pageControl = new PageControl(0, 5);
Criteria criteria = new Criteria() {
@Override
public Class<?> getPersistentClass() {
11 years, 8 months
[rhq] Branch 'feature/export-reports' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/ReportFormatHelper.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java | 165 ++++++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricLocal.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQuery.java | 36 +-
4 files changed, 137 insertions(+), 72 deletions(-)
New commits:
commit 288cd69dbefd4a55e748df82e583742d315f3292
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Mar 30 15:17:39 2012 -0400
[BZ 800453] convert suspect metrics report to streaming response
This commit also fixes the band and outlier fields that previously
displayed null for each row.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/ReportFormatHelper.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/ReportFormatHelper.java
index 9e0f533..03ce6c9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/ReportFormatHelper.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/ReportFormatHelper.java
@@ -20,11 +20,11 @@
*/
package org.rhq.enterprise.server.rest.reporting;
-import org.rhq.core.domain.resource.Resource;
-
import java.text.DateFormat;
import java.util.Date;
+import org.rhq.core.domain.resource.Resource;
+
/**
* Formatting tools for rest reporting.
*/
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java
index c2b4726..21327ee 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricHandler.java
@@ -1,22 +1,32 @@
package org.rhq.enterprise.server.rest.reporting;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.interceptor.Interceptors;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.StreamingOutput;
+import javax.ws.rs.core.UriInfo;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementOOBManagerLocal;
import org.rhq.enterprise.server.rest.AbstractRestBean;
import org.rhq.enterprise.server.rest.SetCallerInterceptor;
+import org.rhq.enterprise.server.util.CriteriaQuery;
+import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import javax.interceptor.Interceptors;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+import static org.rhq.enterprise.server.rest.reporting.ReportFormatHelper.cleanForCSV;
+import static org.rhq.enterprise.server.rest.reporting.ReportFormatHelper.parseAncestry;
@Interceptors(SetCallerInterceptor.class)
@Stateless
@@ -27,55 +37,108 @@ public class SuspectMetricHandler extends AbstractRestBean implements SuspectMet
@EJB
private MeasurementOOBManagerLocal measurementOOBMManager;
- @EJB
- private SubjectManagerLocal subjectMgr;
-
@Override
- public Response suspectMetrics(UriInfo uriInfo, javax.ws.rs.core.Request request, HttpHeaders headers ) {
- StringBuilder sb;
- log.info(" ** Suspect Metric History REST invocation");
-
- PageControl pageControl = new PageControl(0, 200); // not sure what the paging size should be?
- PageList<MeasurementOOBComposite> comps = measurementOOBMManager.getSchedulesWithOOBs(caller, null, null, null, pageControl);
- log.info(" Found MeasurementOOBComposite records: " + comps.size());
- Response.ResponseBuilder builder = Response.status(Response.Status.NOT_ACCEPTABLE); // default error response
- MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
- log.debug(" Suspect Metric media type: "+mediaType.toString());
- if (mediaType.equals(MediaType.APPLICATION_XML_TYPE)) {
- builder = Response.ok(comps.getValues(), mediaType);
-
- } else if (mediaType.toString().equals("text/csv")) {
- // CSV version
- log.info("text/csv Suspect handler for REST");
- sb = new StringBuilder("Id,Name,ResourceTypeId,\n"); // set title row
- if(!comps.isEmpty()){
- for (MeasurementOOBComposite oobComposite : comps) {
- sb.append( oobComposite.getResourceName());
- sb.append(",");
- sb.append(ReportFormatHelper.parseAncestry(oobComposite.getResourceAncestry()));
- sb.append(",");
- sb.append( oobComposite.getUnits()); // Metric
- sb.append(",");
- sb.append( oobComposite.getFormattedBaseband());
- sb.append(",");
- sb.append( oobComposite.getOutlier());
- sb.append(",");
- sb.append( oobComposite.getFactor());
- sb.append("\n");
+ public StreamingOutput suspectMetrics(UriInfo uriInfo, Request request, HttpHeaders headers ) {
+// StringBuilder sb;
+// log.info(" ** Suspect Metric History REST invocation");
+//
+// PageControl pageControl = new PageControl(0, 200); // not sure what the paging size should be?
+// PageList<MeasurementOOBComposite> comps = measurementOOBMManager.getSchedulesWithOOBs(caller, null, null, null, pageControl);
+// log.info(" Found MeasurementOOBComposite records: " + comps.size());
+// Response.ResponseBuilder builder = Response.status(Response.Status.NOT_ACCEPTABLE); // default error response
+// MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
+// log.debug(" Suspect Metric media type: "+mediaType.toString());
+// if (mediaType.equals(MediaType.APPLICATION_XML_TYPE)) {
+// builder = Response.ok(comps.getValues(), mediaType);
+//
+// } else if (mediaType.toString().equals("text/csv")) {
+// // CSV version
+// log.info("text/csv Suspect handler for REST");
+// sb = new StringBuilder("Id,Name,ResourceTypeId,\n"); // set title row
+// if(!comps.isEmpty()){
+// for (MeasurementOOBComposite oobComposite : comps) {
+// sb.append( oobComposite.getResourceName());
+// sb.append(",");
+// sb.append(ReportFormatHelper.parseAncestry(oobComposite.getResourceAncestry()));
+// sb.append(",");
+// sb.append( oobComposite.getUnits()); // Metric
+// sb.append(",");
+// sb.append( oobComposite.getFormattedBaseband());
+// sb.append(",");
+// sb.append( oobComposite.getOutlier());
+// sb.append(",");
+// sb.append( oobComposite.getFactor());
+// sb.append("\n");
+// }
+// } else {
+// //empty
+// sb.append("No Data Available");
+// }
+// builder = Response.ok(sb.toString(), mediaType);
+//
+// } else {
+// log.debug("Unknown Media Type: "+ mediaType.toString());
+// builder = Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE);
+//
+// }
+// return builder.build();
+
+ return new StreamingOutput() {
+ @Override
+ public void write(OutputStream output) throws IOException, WebApplicationException {
+ PageControl pageControl = new PageControl(0, 5);
+ Criteria criteria = new Criteria() {
+ @Override
+ public Class<?> getPersistentClass() {
+ return MeasurementOOBComposite.class;
+ }
+
+ };
+ criteria.setPaging(0, 5);
+ CriteriaQueryExecutor<MeasurementOOBComposite, Criteria> queryExecutor =
+ new CriteriaQueryExecutor<MeasurementOOBComposite, Criteria>() {
+ @Override
+ public PageList<MeasurementOOBComposite> execute(Criteria criteria) {
+ return measurementOOBMManager.getSchedulesWithOOBs(caller, null, null, null,
+ new PageControl(criteria.getPageNumber(), criteria.getPageSize()));
+ }
+ };
+ CriteriaQuery<MeasurementOOBComposite, Criteria> query =
+ new CriteriaQuery<MeasurementOOBComposite, Criteria>(criteria, queryExecutor);
+
+ output.write((getHeader() + "\n").getBytes());
+ for (MeasurementOOBComposite composite : query) {
+ applyFormatting(composite);
+ formatBaseband(composite);
+ String record = toCSV(composite) + "\n";
+ output.write(record.getBytes());
}
- } else {
- //empty
- sb.append("No Data Available");
}
- builder = Response.ok(sb.toString(), mediaType);
+ };
+ }
- } else {
- log.debug("Unknown Media Type: "+ mediaType.toString());
- builder = Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE);
+ private String getHeader() {
+ return "Resource,Ancestry,Metric,Band,Outlier,Out of Range Factor (%)";
+ }
- }
- return builder.build();
+ private String toCSV(MeasurementOOBComposite composite) {
+ return cleanForCSV(composite.getResourceName()) + "," +
+ cleanForCSV(parseAncestry(composite.getResourceAncestry())) + "," +
+ cleanForCSV(composite.getScheduleName()) + "," +
+ cleanForCSV(composite.getFormattedBaseband()) + "," +
+ cleanForCSV(composite.getFormattedOutlier()) + "," +
+ composite.getFactor();
}
+ private void applyFormatting(MeasurementOOBComposite oob) {
+ oob.setFormattedOutlier(MeasurementConverter.format(oob.getOutlier(), oob.getUnits(), true));
+ formatBaseband(oob);
+ }
+
+ private void formatBaseband(MeasurementOOBComposite oob) {
+ String min = MeasurementConverter.format(oob.getBlMin(), oob.getUnits(), true);
+ String max = MeasurementConverter.format(oob.getBlMax(), oob.getUnits(), true);
+ oob.setFormattedBaseband(min + ", " + max);
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricLocal.java
index ed284b3..3e283b0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/SuspectMetricLocal.java
@@ -10,8 +10,8 @@ public interface SuspectMetricLocal {
@GET
@Path("/")
- @Produces({"text/csv", "application/xml"})
- Response suspectMetrics(
+ @Produces("text/csv")
+ StreamingOutput suspectMetrics(
@Context UriInfo uriInfo,
@Context Request request,
@Context HttpHeaders headers);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQuery.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQuery.java
index c353571..be5b5a3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQuery.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQuery.java
@@ -1,30 +1,32 @@
/*
- * RHQ Management Platform
- * Copyright (C) 2005-2012 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.
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.
*
- * 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.server.util;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
import org.rhq.core.domain.criteria.BaseCriteria;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
public class CriteriaQuery<T, C extends BaseCriteria> implements Iterable<T> {
private C criteria;
11 years, 8 months
[rhq] Branch 'bug/759615' - 14 commits - modules/core modules/enterprise modules/plugins
by mazz
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java | 18
modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java | 1
modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java | 4
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/SnapshotGenerator.java | 7
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 5
modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java | 2
modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java | 4
modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java | 547 ---------
modules/core/util/src/main/java/org/rhq/core/util/StringUtil.java | 552 ++++++++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java | 3
modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java | 108 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java | 2
modules/plugins/jboss-as-7/d2d.sh | 2
modules/plugins/jboss-as-7/pom.xml | 109 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 118 --
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java | 11
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 26
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java | 6
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java | 8
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 3
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java | 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java | 2
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 362 +++---
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java | 4
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java | 2
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java | 8
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java | 10
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java | 4
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java | 12
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java | 51
49 files changed, 1109 insertions(+), 928 deletions(-)
New commits:
commit 049a3a753196661c097d03bdb207687ef9835527
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 30 14:57:58 2012 -0400
put the test methods in another, unique, group - trying to get testng to work the way we want
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
index 34c247e..b4fdf46 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
@@ -52,7 +52,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
- @Test(groups = { "plugin.metadata", "NewPlugin" })
+ @Test(groups = { "plugin.resource.metadata.test", "plugin.metadata", "NewPlugin" })
public void testRemovalOfObsoleteBundleAndDriftConfig() throws Exception {
// create the initial type that has bundle and drift definitions
createPlugin("test-plugin.jar", "1.0", "remove_bundle_drift_config_v1.xml");
@@ -107,7 +107,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(groups = { "plugin.metadata", "NewPlugin" })
+ @Test(groups = { "plugin.resource.metadata.test", "plugin.metadata", "NewPlugin" })
public void registerPluginWithDuplicateDriftDefinitions() {
try {
createPlugin("test-plugin.jar", "1.0", "dup_drift.xml");
@@ -117,19 +117,20 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "registerPluginWithDuplicateDriftDefinitions" }, groups = { "plugin.metadata",
- "NewPlugin" })
+ @Test(dependsOnMethods = { "registerPluginWithDuplicateDriftDefinitions" }, groups = {
+ "plugin.resource.metadata.test", "plugin.metadata", "NewPlugin" })
public void registerPlugin() throws Exception {
createPlugin("test-plugin.jar", "1.0", "plugin_v1.xml");
}
- @Test(dependsOnMethods = { "registerPlugin" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "registerPlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistNewTypes() {
List<String> newTypes = asList("ServerA", "ServerB");
assertTypesPersisted("Failed to persist new types", newTypes, "TestPlugin");
}
- // @Test(dependsOnMethods = {"persistNewTypes"}, groups = {"plugin.metadata", "NewPlugin"})
+ // @Test(dependsOnMethods = {"persistNewTypes"}, groups = {"plugin.resource.metadata.test", "plugin.metadata", "NewPlugin"})
// public void persistSubcategories() throws Exception {
// assertResourceTypeAssociationEquals(
// "ServerA",
@@ -139,29 +140,34 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
// );
// }
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistMeasurementDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "metricDefinitions",
asList("metric1", "metric2", "rhq.availability"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistEventDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "eventDefinitions",
asList("logAEntry", "logBEntry"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistOperationDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "operationDefinitions", asList("start", "stop"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistProcessScans() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "processScans", asList("serverA"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistDriftDefinitionTemplates() throws Exception {
ResourceType type = assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "driftDefinitionTemplates",
asList("drift-pc", "drift-fs"));
@@ -200,7 +206,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistBundleTargetConfigurations() throws Exception {
String resourceTypeName = "ServerA";
String plugin = "TestPlugin";
@@ -235,55 +242,64 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistChildTypes() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "childResourceTypes", asList("Child1", "Child2"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistPluginConfigurationDefinition() throws Exception {
assertAssociationExists("ServerA", "pluginConfigurationDefinition");
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistPackageTypes() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "packageTypes",
asList("ServerA.Content.1", "ServerA.Content.2"));
}
- @Test(groups = { "plugin.metadata", "UpgradePlugin" }, dependsOnGroups = { "NewPlugin" })
+ @Test(groups = { "plugin.resource.metadata.test", "plugin.metadata", "UpgradePlugin" }, dependsOnGroups = { "NewPlugin" })
public void upgradePlugin() throws Exception {
createPlugin("test-plugin.jar", "2.0", "plugin_v2.xml");
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeOperationDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "operationDefinitions",
asList("start", "shutdown", "restart"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeChildResources() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "childResourceTypes", asList("Child1", "Child3"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeParentTypeOfChild() throws Exception {
assertResourceTypeAssociationEquals("ServerB", "TestPlugin", "childResourceTypes", asList("Child2"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeEventDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "eventDefinitions",
asList("logAEntry", "logCEntry"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeProcessScans() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "processScans", asList("processA", "processB"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeDriftDefinitionTemplates() throws Exception {
ResourceType type = assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "driftDefinitionTemplates",
asList("drift-rc", "drift-mt"));
@@ -313,7 +329,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeBundleTargetConfigurations() throws Exception {
String resourceTypeName = "ServerA";
String plugin = "TestPlugin";
@@ -348,7 +365,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradePackageTypes() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "packageTypes",
asList("ServerA.Content.1", "ServerA.Content.3"));
@@ -367,7 +385,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
createPlugin("remove-types-plugin", "2.0", "remove_types_v2.xml");
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteOperationDefsForRemovedType() throws Exception {
OperationManagerLocal operationMgr = LookupUtil.getOperationManager();
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
@@ -382,7 +401,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The operation definition should have been deleted", 0, operationDefs.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteEventDefsForRemovedType() throws Exception {
List<?> results = getEntityManager()
.createQuery("from EventDefinition e where e.name = :ename and e.resourceType.name = :rname")
@@ -391,7 +411,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The event definition(s) should have been deleted", 0, results.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteParent() throws Exception {
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
ResourceTypeManagerLocal resourceTypeMgr = LookupUtil.getResourceTypeManager();
@@ -424,7 +445,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
return null;
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteTypeAndAllItsDescedantTypes() throws Exception {
List<?> typesNotRemoved = getEntityManager()
.createQuery("from ResourceType t where t.plugin = :plugin and t.name in (:resourceTypes)")
@@ -435,7 +457,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("Failed to delete resource type or one or more of its descendant types", 0, typesNotRemoved.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteProcessScans() {
List<?> processScans = getEntityManager()
.createQuery("from ProcessScan p where p.name = :name1 or p.name = :name2").setParameter("name1", "scan1")
@@ -444,7 +467,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The process scans should have been deleted", 0, processScans.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteSubcategories() {
List<?> subcategories = getEntityManager()
.createQuery("from ResourceSubCategory r where r.name = :name1 or r.name = :name2 or r.name = :name3")
@@ -453,7 +477,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The subcategories should have been deleted", 0, subcategories.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteResources() {
ResourceManagerLocal resourceMgr = LookupUtil.getResourceManager();
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
@@ -478,7 +503,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteBundles() {
List<?> bundles = getEntityManager().createQuery("from Bundle b where b.bundleType.name = :name")
.setParameter("name", "Test Bundle").getResultList();
@@ -486,7 +512,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("Failed to delete the bundles", 0, bundles.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteBundleTypes() {
List<?> bundleTypes = getEntityManager().createQuery("from BundleType b where b.name = :name")
.setParameter("name", "Test Bundle").getResultList();
@@ -494,7 +521,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The bundle type should have been deleted", 0, bundleTypes.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deletePackages() {
List<?> packages = getEntityManager().createQuery("from Package p where p.name = :name")
.setParameter("name", "ServerC::test-package").getResultList();
@@ -502,7 +530,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("All packages should have been deleted", 0, packages.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deletePackageTypes() {
List<?> packageTypes = getEntityManager().createQuery("from PackageType p where p.name = :name")
.setParameter("name", "ServerC.Content").getResultList();
@@ -510,7 +539,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("All package types should have been deleted", 0, packageTypes.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteResourceGroups() {
List<?> groups = getEntityManager()
.createQuery("from ResourceGroup g where g.name = :name and g.resourceType.name = :typeName")
@@ -519,7 +549,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("All resource groups should have been deleted", 0, groups.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteAlertTemplates() {
List<?> templates = getEntityManager()
.createQuery("from AlertDefinition a where a.name = :name and a.resourceType.name = :typeName")
@@ -528,7 +559,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("Alert templates should have been deleted.", 0, templates.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteMeasurementDefinitions() {
List<?> measurementDefs = getEntityManager().createQuery("from MeasurementDefinition m where m.name = :name")
.setParameter("name", "ServerC::metric1").getResultList();
commit 26c36e86ccd7895199936cb56ed585a0b5b98fa2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 30 14:57:09 2012 -0400
[BZ 759615] remove the last duplicate package across multiple jars
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java
index cf31a5f..183f8d5 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java
@@ -31,6 +31,7 @@ import org.rhq.core.clientapi.util.units.ScaleConstants;
import org.rhq.core.clientapi.util.units.UnitNumber;
import org.rhq.core.clientapi.util.units.UnitsConstants;
import org.rhq.core.clientapi.util.units.UnitsFormat;
+import org.rhq.core.util.StringUtil;
public class TimeUtil {
public static final String DATE_FORMAT = "MM-dd-yy-HH-mm-ss";
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java
index 9e9e4de..98c90aa 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java
@@ -27,7 +27,7 @@ import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
import org.rhq.core.clientapi.util.ArrayUtil;
-import org.rhq.core.clientapi.util.StringUtil;
+import org.rhq.core.util.StringUtil;
/**
* Format a value into a duration.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java
index d8ce6d5..5828a04 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java
@@ -26,7 +26,6 @@ import java.util.HashMap;
import java.util.Map;
import org.rhq.core.clientapi.server.operation.OperationServerService;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.operation.OperationDefinition;
@@ -34,6 +33,7 @@ import org.rhq.core.pluginapi.operation.OperationContext;
import org.rhq.core.pluginapi.operation.OperationServices;
import org.rhq.core.pluginapi.operation.OperationServicesResult;
import org.rhq.core.pluginapi.operation.OperationServicesResultCode;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ExceptionPackage;
/**
diff --git a/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java b/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java
deleted file mode 100644
index ecfed35..0000000
--- a/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * 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.clientapi.util;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class StringUtil {
-
- private static final Log log = LogFactory.getLog(StringUtil.class);
-
- /**
- * @param source The source string to perform replacements on.
- * @param find The substring to find in source.
- * @param replace The string to replace 'find' within source
- *
- * @return The source string, with all occurrences of 'find' replaced with 'replace'
- */
- public static String replace(String source, String find, String replace) {
- if ((source == null) || (find == null) || (replace == null)) {
- return source;
- }
-
- int sourceLen = source.length();
- int findLen = find.length();
- if ((sourceLen == 0) || (findLen == 0)) {
- return source;
- }
-
- StringBuilder buffer = new StringBuilder();
-
- int idx;
- int fromIndex;
-
- for (fromIndex = 0; (idx = source.indexOf(find, fromIndex)) != -1; fromIndex = idx + findLen) {
- buffer.append(source.substring(fromIndex, idx));
- buffer.append(replace);
- }
-
- if (fromIndex == 0) {
- return source;
- }
-
- buffer.append(source.substring(fromIndex));
-
- return buffer.toString();
- }
-
- /**
- * @param source The source string to perform replacements on.
- * @param find The substring to find in source.
- *
- * @return The source string, with all occurrences of 'find' removed
- */
- public static String remove(String source, String find) {
- if ((source == null) || (find == null)) {
- return source;
- }
-
- String retVal = null;
- int sourceLen = source.length();
- int findLen = find.length();
- StringBuilder remove = new StringBuilder(source);
-
- try {
- if ((sourceLen > 0) && (findLen > 0)) {
- int fromIndex;
- int idx;
-
- for (fromIndex = 0, idx = 0; (fromIndex = source.indexOf(find, idx)) != -1; idx = fromIndex + findLen) {
- remove.delete(fromIndex, findLen + fromIndex);
- }
-
- retVal = remove.toString();
- }
- } catch (Exception e) {
- log.error("This should not have happened.", e);
- retVal = null;
- }
-
- return retVal;
- }
-
- /**
- * Print out everything in an Iterator in a user-friendly string format.
- *
- * @param i An iterator to print out.
- * @param delim The delimiter to use between elements.
- *
- * @return The Iterator's elements in a user-friendly string format.
- */
- public static String iteratorToString(Iterator i, String delim) {
- return iteratorToString(i, delim, "");
- }
-
- /**
- * Print out everything in an Iterator in a user-friendly string format.
- *
- * @param i An iterator to print out.
- * @param delim The delimiter to use between elements.
- * @param quoteChar The character to quote each element with.
- *
- * @return The Iterator's elements in a user-friendly string format.
- */
- public static String iteratorToString(Iterator i, String delim, String quoteChar) {
- Object elt = null;
- StringBuilder rstr = new StringBuilder();
- String s;
-
- while (i.hasNext()) {
- if (rstr.length() > 0) {
- rstr.append(delim);
- }
-
- elt = i.next();
- if (elt == null) {
- rstr.append("NULL");
- } else {
- s = elt.toString();
- if (quoteChar != null) {
- rstr.append(quoteChar).append(s).append(quoteChar);
- } else {
- rstr.append(s);
- }
- }
- }
-
- return rstr.toString();
- }
-
- /**
- * Print out a List in a user-friendly string format.
- *
- * @param list A List to print out.
- * @param delim The delimiter to use between elements.
- *
- * @return The List in a user-friendly string format.
- */
- public static String listToString(List list, String delim) {
- if (list == null) {
- return "NULL";
- }
-
- Iterator i = list.iterator();
- return iteratorToString(i, delim, null);
- }
-
- public static String collectionToString(Collection collection, String delim) {
- if (collection == null) {
- return "NULL";
- }
-
- Iterator i = collection.iterator();
- return iteratorToString(i, delim, null);
- }
-
- /**
- * Print out a List in a user-friendly string format.
- *
- * @param list A List to print out.
- *
- * @return The List in a user-friendly string format.
- */
- public static String listToString(List list) {
- return listToString(list, ",");
- }
-
- public static String collectionToString(Collection collection) {
- return collectionToString(collection, ",");
- }
-
- /**
- * Print out an array as a String
- */
- public static String arrayToString(Object[] array) {
- return arrayToString(array, ',');
- }
-
- /**
- * Print out an array as a String
- */
- public static String arrayToString(boolean[] array) {
- if (array == null) {
- return "null";
- }
-
- String rstr = "";
- char delim = ',';
- for (int i = 0; i < array.length; i++) {
- if (i > 0) {
- rstr += delim;
- }
-
- rstr += array[i];
- }
-
- return rstr;
- }
-
- /**
- * Print out an array as a String
- *
- * @param array The array to print out
- * @param delim The delimiter to use between elements.
- */
- public static String arrayToString(Object[] array, char delim) {
- if (array == null) {
- return "null";
- }
-
- StringBuilder rstr = new StringBuilder();
- for (int i = 0; i < array.length; i++) {
- if (i > 0) {
- rstr.append(delim);
- }
-
- rstr.append(array[i]);
- }
-
- return rstr.toString();
- }
-
- /**
- * Print out an array as a String
- */
- public static String arrayToString(int[] array) {
- if (array == null) {
- return "null";
- }
-
- StringBuilder rstr = new StringBuilder();
- for (int i = 0; i < array.length; i++) {
- if (i > 0) {
- rstr.append(",");
- }
-
- rstr.append(array[i]);
- }
-
- return rstr.toString();
- }
-
- /**
- * Create a string formulated by inserting a delimiter in between consecutive array elements.
- *
- * @param objs List of objects to implode (elements may not be null)
- * @param delim String to place inbetween elements
- *
- * @return A string with objects in the list seperated by delim
- */
- public static String implode(List objs, String delim) {
- StringBuilder buf = new StringBuilder();
- int size = objs.size();
-
- for (int i = 0; i < (size - 1); i++) {
- buf.append(objs.get(i).toString());
- buf.append( delim);
- }
-
- if (size != 0) {
- buf.append(objs.get(size - 1).toString());
- }
-
- return buf.toString();
- }
-
- /**
- * Split a string on delimiter boundaries, and place each element into a List.
- *
- * @param s String to split up
- * @param delim Delimiting token, ala StringTokenizer
- *
- * @return a List comprised of elements split by the tokenizing
- */
-
- public static List<String> explode(String s, String delim) {
- List<String> res = new ArrayList<String>();
- if (s == null)
- return res;
-
- StringTokenizer tok = new StringTokenizer(s, delim);
-
- while (tok.hasMoreTokens()) {
- res.add(tok.nextToken());
- }
-
- return res;
- }
-
- /**
- * Split a string on delimiter boundaries, and place each element into an Array.
- *
- * @param toExplode String to split up
- * @param delim Delimiting token, ala StringTokenizer
- *
- * @return an Array comprised of elements split by the tokenizing
- */
- public static String[] explodeToArray(String toExplode, String delim) {
- List<String> strings = explode(toExplode, delim);
- String[] ret;
- ret = strings.toArray(new String[strings.size()]);
- return ret;
- }
-
- /**
- * Split a string up by whitespace, taking into account quoted subcomponents. If there is an uneven number of
- * quotes, a parse error will be thrown.
- *
- * @param arg String to parse
- *
- * @return an array of elements, the argument was split into
- *
- * @throws IllegalArgumentException indicating there was a quoting error
- */
-
- public static String[] explodeQuoted(String arg) throws IllegalArgumentException {
- List<String> res = new ArrayList<String>();
- StringTokenizer quoteTok;
- boolean inQuote = false;
-
- arg = arg.trim();
- quoteTok = new StringTokenizer(arg, "\"", true);
-
- while (quoteTok.hasMoreTokens()) {
- String elem = (String) quoteTok.nextElement();
-
- if (elem.equals("\"")) {
- inQuote = !inQuote;
- continue;
- }
-
- if (inQuote) {
- res.add(elem);
- } else {
- StringTokenizer spaceTok = new StringTokenizer(elem.trim());
-
- while (spaceTok.hasMoreTokens()) {
- res.add(spaceTok.nextToken());
- }
- }
- }
-
- if (inQuote) {
- throw new IllegalArgumentException("Unbalanced quotation marks");
- }
-
- return res.toArray(new String[res.size()]);
- }
-
- /**
- * Remove a prefix from a string. If value starts with prefix, it will be removed, the resultant string is trimmed
- * and returned.
- *
- * @return If value starts with prefix, then this method returns value with the prefix removed, and the resultant
- * string trimmed. If value does not start with prefix, value is returned as-is.
- */
- public static String removePrefix(String value, String prefix) {
- if (!value.startsWith(prefix)) {
- return value;
- }
-
- return value.substring(prefix.length()).trim();
- }
-
- /**
- * @return the plural of word. This is done by applying a few rules. These cover most (but not all) cases: 1. If the
- * word ends in s, ss, x, o, or ch, append es 2. If the word ends in a consonant followed by y, drop the y
- * and add ies 3. Append an s and call it a day. The ultimate references is at
- * http://en.wikipedia.org/wiki/English_plural
- */
- public static String pluralize(String word) {
- if (word.endsWith("s") || word.endsWith("x") || word.endsWith("o") || word.endsWith("ch")) {
- return word + "es";
- }
-
- if (word.endsWith("y")) {
- // Odd case to avoid StringIndexOutOfBounds later
- if (word.length() == 1) {
- return word;
- }
-
- // Check next-to-last letter
- char next2last = word.charAt(word.length() - 2);
- if ((next2last != 'a') && (next2last != 'e') && (next2last != 'i') && (next2last != 'o')
- && (next2last != 'u') && (next2last != 'y')) {
- return word.substring(0, word.length() - 1) + "ies";
- }
- }
-
- return word + "s";
- }
-
- /**
- * @return The stack trace for the given Throwable as a String.
- */
- public static String getStackTrace(Throwable t) {
- if (t == null) {
- return "THROWABLE-WAS-NULL (at " + getStackTrace(new Exception()) + ")";
- }
-
- try {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
-
- t.printStackTrace(pw);
-
- Throwable cause = t.getCause();
- if (cause != null) {
- return sw.toString() + getStackTrace(cause);
- }
-
- return sw.toString();
- } catch (Exception e) {
- return "\n\nStringUtil.getStackTrace " + "GENERATED EXCEPTION: '" + e.toString() + "' \n\n";
- }
- }
-
- /**
- * @return The stack trace for the given Throwable as a String.
- */
- public static String getFirstStackTrace(Throwable t) {
- if (t == null) {
- return null;
- }
-
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- t.printStackTrace(pw);
-
- return sw.toString();
- }
-
- /**
- * @param s A string that might contain unix-style path separators.
- *
- * @return The correct path for this platform (i.e, if win32, replace / with \).
- */
- public static String normalizePath(String s) {
- return StringUtil.replace(s, "/", File.separator);
- }
-
- public static String formatDuration(long duration) {
- return formatDuration(duration, 0, false);
- }
-
- public static String formatDuration(long duration, int scale, boolean minDigits) {
- long hours;
- long mins;
- int digits;
- double millis;
-
- hours = duration / 3600000;
- duration -= hours * 3600000;
-
- mins = duration / 60000;
- duration -= mins * 60000;
-
- millis = (double) duration / 1000;
-
- StringBuilder buf = new StringBuilder();
-
- if ((hours > 0) || (minDigits == false)) {
- buf.append(((hours < 10) && (minDigits == false)) ? ("0" + hours) : String.valueOf(hours)).append(':');
- minDigits = false;
- }
-
- if ((mins > 0) || (minDigits == false)) {
- buf.append(((mins < 10) && (minDigits == false)) ? ("0" + mins) : String.valueOf(mins)).append(':');
- minDigits = false;
- }
-
- // Format seconds and milliseconds
- NumberFormat fmt = NumberFormat.getInstance();
- digits = (((minDigits == false) || ((scale == 0) && (millis >= 9.5))) ? 2 : 1);
- fmt.setMinimumIntegerDigits(digits);
- fmt.setMaximumIntegerDigits(2); // Max of 2
- fmt.setMinimumFractionDigits(0); // Don't need any
- fmt.setMaximumFractionDigits(scale);
-
- buf.append(fmt.format(millis));
-
- return buf.toString();
- }
-
- public static String repeatChars(char c, int nTimes) {
- char[] arr = new char[nTimes];
-
- for (int i = 0; i < nTimes; i++) {
- arr[i] = c;
- }
-
- return new String(arr);
- }
-
- /**
- * Capitalizes the first letter of str.
- *
- * @param str The string to capitalize.
- *
- * @return A new string that is <code>str</code> capitalized. Returns <code>null</code> if str is null.
- */
- public static String capitalize(String str) {
- if (str == null) {
- return null;
- } else if (str.trim().equals("")) {
- return str;
- }
-
- String result = str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
-
- return result;
- }
-
- public static String truncate(String s, int truncLength, boolean removeWhiteSpace) {
- String temp = ((s.length() > truncLength) ? (s.substring(0, truncLength) + "...") : s);
- if (removeWhiteSpace) {
- temp = temp.replaceAll("\\s+", " ");
- }
-
- return temp;
- }
-}
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/StringUtil.java b/modules/core/util/src/main/java/org/rhq/core/util/StringUtil.java
new file mode 100644
index 0000000..7944bbd
--- /dev/null
+++ b/modules/core/util/src/main/java/org/rhq/core/util/StringUtil.java
@@ -0,0 +1,552 @@
+/*
+ * 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.util;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class StringUtil {
+
+ private static final Log log = LogFactory.getLog(StringUtil.class);
+
+ /**
+ * @param source The source string to perform replacements on.
+ * @param find The substring to find in source.
+ * @param replace The string to replace 'find' within source
+ *
+ * @return The source string, with all occurrences of 'find' replaced with 'replace'
+ */
+ public static String replace(String source, String find, String replace) {
+ if ((source == null) || (find == null) || (replace == null)) {
+ return source;
+ }
+
+ int sourceLen = source.length();
+ int findLen = find.length();
+ if ((sourceLen == 0) || (findLen == 0)) {
+ return source;
+ }
+
+ StringBuilder buffer = new StringBuilder();
+
+ int idx;
+ int fromIndex;
+
+ for (fromIndex = 0; (idx = source.indexOf(find, fromIndex)) != -1; fromIndex = idx + findLen) {
+ buffer.append(source.substring(fromIndex, idx));
+ buffer.append(replace);
+ }
+
+ if (fromIndex == 0) {
+ return source;
+ }
+
+ buffer.append(source.substring(fromIndex));
+
+ return buffer.toString();
+ }
+
+ /**
+ * @param source The source string to perform replacements on.
+ * @param find The substring to find in source.
+ *
+ * @return The source string, with all occurrences of 'find' removed
+ */
+ public static String remove(String source, String find) {
+ if ((source == null) || (find == null)) {
+ return source;
+ }
+
+ String retVal = null;
+ int sourceLen = source.length();
+ int findLen = find.length();
+ StringBuilder remove = new StringBuilder(source);
+
+ try {
+ if ((sourceLen > 0) && (findLen > 0)) {
+ int fromIndex;
+ int idx;
+
+ for (fromIndex = 0, idx = 0; (fromIndex = source.indexOf(find, idx)) != -1; idx = fromIndex + findLen) {
+ remove.delete(fromIndex, findLen + fromIndex);
+ }
+
+ retVal = remove.toString();
+ }
+ } catch (Exception e) {
+ log.error("This should not have happened.", e);
+ retVal = null;
+ }
+
+ return retVal;
+ }
+
+ /**
+ * Print out everything in an Iterator in a user-friendly string format.
+ *
+ * @param i An iterator to print out.
+ * @param delim The delimiter to use between elements.
+ *
+ * @return The Iterator's elements in a user-friendly string format.
+ */
+ public static String iteratorToString(Iterator i, String delim) {
+ return iteratorToString(i, delim, "");
+ }
+
+ /**
+ * Print out everything in an Iterator in a user-friendly string format.
+ *
+ * @param i An iterator to print out.
+ * @param delim The delimiter to use between elements.
+ * @param quoteChar The character to quote each element with.
+ *
+ * @return The Iterator's elements in a user-friendly string format.
+ */
+ public static String iteratorToString(Iterator i, String delim, String quoteChar) {
+ Object elt = null;
+ StringBuilder rstr = new StringBuilder();
+ String s;
+
+ while (i.hasNext()) {
+ if (rstr.length() > 0) {
+ rstr.append(delim);
+ }
+
+ elt = i.next();
+ if (elt == null) {
+ rstr.append("NULL");
+ } else {
+ s = elt.toString();
+ if (quoteChar != null) {
+ rstr.append(quoteChar).append(s).append(quoteChar);
+ } else {
+ rstr.append(s);
+ }
+ }
+ }
+
+ return rstr.toString();
+ }
+
+ /**
+ * Print out a List in a user-friendly string format.
+ *
+ * @param list A List to print out.
+ * @param delim The delimiter to use between elements.
+ *
+ * @return The List in a user-friendly string format.
+ */
+ public static String listToString(List list, String delim) {
+ if (list == null) {
+ return "NULL";
+ }
+
+ Iterator i = list.iterator();
+ return iteratorToString(i, delim, null);
+ }
+
+ public static String collectionToString(Collection collection, String delim) {
+ if (collection == null) {
+ return "NULL";
+ }
+
+ Iterator i = collection.iterator();
+ return iteratorToString(i, delim, null);
+ }
+
+ /**
+ * Print out a List in a user-friendly string format.
+ *
+ * @param list A List to print out.
+ *
+ * @return The List in a user-friendly string format.
+ */
+ public static String listToString(List list) {
+ return listToString(list, ",");
+ }
+
+ public static String collectionToString(Collection collection) {
+ return collectionToString(collection, ",");
+ }
+
+ /**
+ * Print out an array as a String
+ */
+ public static String arrayToString(Object[] array) {
+ return arrayToString(array, ',');
+ }
+
+ /**
+ * Print out an array as a String
+ */
+ public static String arrayToString(boolean[] array) {
+ if (array == null) {
+ return "null";
+ }
+
+ String rstr = "";
+ char delim = ',';
+ for (int i = 0; i < array.length; i++) {
+ if (i > 0) {
+ rstr += delim;
+ }
+
+ rstr += array[i];
+ }
+
+ return rstr;
+ }
+
+ /**
+ * Print out an array as a String
+ *
+ * @param array The array to print out
+ * @param delim The delimiter to use between elements.
+ */
+ public static String arrayToString(Object[] array, char delim) {
+ if (array == null) {
+ return "null";
+ }
+
+ StringBuilder rstr = new StringBuilder();
+ for (int i = 0; i < array.length; i++) {
+ if (i > 0) {
+ rstr.append(delim);
+ }
+
+ rstr.append(array[i]);
+ }
+
+ return rstr.toString();
+ }
+
+ /**
+ * Print out an array as a String
+ */
+ public static String arrayToString(int[] array) {
+ if (array == null) {
+ return "null";
+ }
+
+ StringBuilder rstr = new StringBuilder();
+ for (int i = 0; i < array.length; i++) {
+ if (i > 0) {
+ rstr.append(",");
+ }
+
+ rstr.append(array[i]);
+ }
+
+ return rstr.toString();
+ }
+
+ /**
+ * Create a string formulated by inserting a delimiter in between consecutive array elements.
+ *
+ * @param objs List of objects to implode (elements may not be null)
+ * @param delim String to place inbetween elements
+ *
+ * @return A string with objects in the list seperated by delim
+ */
+ public static String implode(List objs, String delim) {
+ StringBuilder buf = new StringBuilder();
+ int size = objs.size();
+
+ for (int i = 0; i < (size - 1); i++) {
+ buf.append(objs.get(i).toString());
+ buf.append( delim);
+ }
+
+ if (size != 0) {
+ buf.append(objs.get(size - 1).toString());
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Split a string on delimiter boundaries, and place each element into a List.
+ *
+ * @param s String to split up
+ * @param delim Delimiting token, ala StringTokenizer
+ *
+ * @return a List comprised of elements split by the tokenizing
+ */
+
+ public static List<String> explode(String s, String delim) {
+ List<String> res = new ArrayList<String>();
+ if (s == null)
+ return res;
+
+ StringTokenizer tok = new StringTokenizer(s, delim);
+
+ while (tok.hasMoreTokens()) {
+ res.add(tok.nextToken());
+ }
+
+ return res;
+ }
+
+ /**
+ * Split a string on delimiter boundaries, and place each element into an Array.
+ *
+ * @param toExplode String to split up
+ * @param delim Delimiting token, ala StringTokenizer
+ *
+ * @return an Array comprised of elements split by the tokenizing
+ */
+ public static String[] explodeToArray(String toExplode, String delim) {
+ List<String> strings = explode(toExplode, delim);
+ String[] ret;
+ ret = strings.toArray(new String[strings.size()]);
+ return ret;
+ }
+
+ /**
+ * Split a string up by whitespace, taking into account quoted subcomponents. If there is an uneven number of
+ * quotes, a parse error will be thrown.
+ *
+ * @param arg String to parse
+ *
+ * @return an array of elements, the argument was split into
+ *
+ * @throws IllegalArgumentException indicating there was a quoting error
+ */
+
+ public static String[] explodeQuoted(String arg) throws IllegalArgumentException {
+ List<String> res = new ArrayList<String>();
+ StringTokenizer quoteTok;
+ boolean inQuote = false;
+
+ arg = arg.trim();
+ quoteTok = new StringTokenizer(arg, "\"", true);
+
+ while (quoteTok.hasMoreTokens()) {
+ String elem = (String) quoteTok.nextElement();
+
+ if (elem.equals("\"")) {
+ inQuote = !inQuote;
+ continue;
+ }
+
+ if (inQuote) {
+ res.add(elem);
+ } else {
+ StringTokenizer spaceTok = new StringTokenizer(elem.trim());
+
+ while (spaceTok.hasMoreTokens()) {
+ res.add(spaceTok.nextToken());
+ }
+ }
+ }
+
+ if (inQuote) {
+ throw new IllegalArgumentException("Unbalanced quotation marks");
+ }
+
+ return res.toArray(new String[res.size()]);
+ }
+
+ /**
+ * Remove a prefix from a string. If value starts with prefix, it will be removed, the resultant string is trimmed
+ * and returned.
+ *
+ * @return If value starts with prefix, then this method returns value with the prefix removed, and the resultant
+ * string trimmed. If value does not start with prefix, value is returned as-is.
+ */
+ public static String removePrefix(String value, String prefix) {
+ if (!value.startsWith(prefix)) {
+ return value;
+ }
+
+ return value.substring(prefix.length()).trim();
+ }
+
+ /**
+ * @return the plural of word. This is done by applying a few rules. These cover most (but not all) cases: 1. If the
+ * word ends in s, ss, x, o, or ch, append es 2. If the word ends in a consonant followed by y, drop the y
+ * and add ies 3. Append an s and call it a day. The ultimate references is at
+ * http://en.wikipedia.org/wiki/English_plural
+ */
+ public static String pluralize(String word) {
+ if (word.endsWith("s") || word.endsWith("x") || word.endsWith("o") || word.endsWith("ch")) {
+ return word + "es";
+ }
+
+ if (word.endsWith("y")) {
+ // Odd case to avoid StringIndexOutOfBounds later
+ if (word.length() == 1) {
+ return word;
+ }
+
+ // Check next-to-last letter
+ char next2last = word.charAt(word.length() - 2);
+ if ((next2last != 'a') && (next2last != 'e') && (next2last != 'i') && (next2last != 'o')
+ && (next2last != 'u') && (next2last != 'y')) {
+ return word.substring(0, word.length() - 1) + "ies";
+ }
+ }
+
+ return word + "s";
+ }
+
+ /**
+ * @return The stack trace for the given Throwable as a String.
+ */
+ public static String getStackTrace(Throwable t) {
+ if (t == null) {
+ return "THROWABLE-WAS-NULL (at " + getStackTrace(new Exception()) + ")";
+ }
+
+ try {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ t.printStackTrace(pw);
+
+ Throwable cause = t.getCause();
+ if (cause != null) {
+ return sw.toString() + getStackTrace(cause);
+ }
+
+ return sw.toString();
+ } catch (Exception e) {
+ return "\n\nStringUtil.getStackTrace " + "GENERATED EXCEPTION: '" + e.toString() + "' \n\n";
+ }
+ }
+
+ /**
+ * @return The stack trace for the given Throwable as a String.
+ */
+ public static String getFirstStackTrace(Throwable t) {
+ if (t == null) {
+ return null;
+ }
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+
+ return sw.toString();
+ }
+
+ /**
+ * @param s A string that might contain unix-style path separators.
+ *
+ * @return The correct path for this platform (i.e, if win32, replace / with \).
+ */
+ public static String normalizePath(String s) {
+ return StringUtil.replace(s, "/", File.separator);
+ }
+
+ public static String formatDuration(long duration) {
+ return formatDuration(duration, 0, false);
+ }
+
+ public static String formatDuration(long duration, int scale, boolean minDigits) {
+ long hours;
+ long mins;
+ int digits;
+ double millis;
+
+ hours = duration / 3600000;
+ duration -= hours * 3600000;
+
+ mins = duration / 60000;
+ duration -= mins * 60000;
+
+ millis = (double) duration / 1000;
+
+ StringBuilder buf = new StringBuilder();
+
+ if ((hours > 0) || (minDigits == false)) {
+ buf.append(((hours < 10) && (minDigits == false)) ? ("0" + hours) : String.valueOf(hours)).append(':');
+ minDigits = false;
+ }
+
+ if ((mins > 0) || (minDigits == false)) {
+ buf.append(((mins < 10) && (minDigits == false)) ? ("0" + mins) : String.valueOf(mins)).append(':');
+ minDigits = false;
+ }
+
+ // Format seconds and milliseconds
+ NumberFormat fmt = NumberFormat.getInstance();
+ digits = (((minDigits == false) || ((scale == 0) && (millis >= 9.5))) ? 2 : 1);
+ fmt.setMinimumIntegerDigits(digits);
+ fmt.setMaximumIntegerDigits(2); // Max of 2
+ fmt.setMinimumFractionDigits(0); // Don't need any
+ fmt.setMaximumFractionDigits(scale);
+
+ buf.append(fmt.format(millis));
+
+ return buf.toString();
+ }
+
+ public static String repeatChars(char c, int nTimes) {
+ char[] arr = new char[nTimes];
+
+ for (int i = 0; i < nTimes; i++) {
+ arr[i] = c;
+ }
+
+ return new String(arr);
+ }
+
+ /**
+ * Capitalizes the first letter of str.
+ *
+ * @param str The string to capitalize.
+ *
+ * @return A new string that is <code>str</code> capitalized. Returns <code>null</code> if str is null.
+ */
+ public static String capitalize(String str) {
+ if (str == null) {
+ return null;
+ } else if (str.trim().equals("")) {
+ return str;
+ }
+
+ String result = str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
+
+ return result;
+ }
+
+ public static String truncate(String s, int truncLength, boolean removeWhiteSpace) {
+ String temp = ((s.length() > truncLength) ? (s.substring(0, truncLength) + "...") : s);
+ if (removeWhiteSpace) {
+ temp = temp.replaceAll("\\s+", " ");
+ }
+
+ return temp;
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java
index a13e89a..2c4c7b8 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java
@@ -28,7 +28,7 @@ import javax.faces.context.FacesContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.clientapi.util.StringUtil;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.alert.engine.internal.Tuple;
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java
index 203c929..88b434d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java
@@ -23,7 +23,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.rhq.core.clientapi.util.StringUtil;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.util.DashboardUtils;
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
index 5d317b0..6c31434 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
@@ -8,12 +8,12 @@ import java.util.List;
import java.util.ListIterator;
import java.util.StringTokenizer;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.composite.ResourceIdFlyWeight;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.legacy.action.resource.hub.HubView;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
index df45f52..470975b 100755
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
@@ -30,7 +30,6 @@ import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.clientapi.util.TimeUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
@@ -38,6 +37,7 @@ import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.DefaultConstants;
import org.rhq.enterprise.gui.legacy.ParamConstants;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java
index cb1e04e..e516033 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java
@@ -30,7 +30,6 @@ import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.auth.Subject;
@@ -38,6 +37,7 @@ import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.ParamConstants;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java
index f134028..2aefb23 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java
@@ -32,12 +32,12 @@ import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.Portal;
import org.rhq.enterprise.gui.legacy.Portlet;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java
index a1970ba..83afbd8 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java
@@ -29,9 +29,9 @@ import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.ParamConstants;
import org.rhq.enterprise.gui.legacy.WebUser;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java
index 1055210..a6b3230 100755
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java
@@ -21,7 +21,8 @@ package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.ImageButtonBean;
-import org.rhq.core.clientapi.util.StringUtil;
+
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.legacy.measurement.MeasurementConstants;
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java
index 9ec74ee..3f9f998 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java
@@ -35,7 +35,6 @@ import org.apache.struts.action.ActionMapping;
import org.apache.struts.tiles.ComponentContext;
import org.rhq.core.clientapi.util.ArrayUtil;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.measurement.MeasurementBaseline;
import org.rhq.core.domain.measurement.MeasurementDefinition;
@@ -51,6 +50,7 @@ import org.rhq.core.domain.resource.group.Group;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.server.MeasurementConverter;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.common.servlet.HighLowMetricValue;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.DefaultConstants;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java
index 28e1f8d..d4c86e1 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java
@@ -28,7 +28,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.struts.util.LabelValueBean;
-import org.rhq.core.clientapi.util.StringUtil;
+
+import org.rhq.core.util.StringUtil;
/**
* This bean is for use with html:options.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java
index 261af53..cf2fe2c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java
@@ -24,7 +24,8 @@ import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.taglibs.standard.tag.common.core.NullAttributeException;
import org.apache.taglibs.standard.tag.el.core.ExpressionUtil;
-import org.rhq.core.clientapi.util.StringUtil;
+
+import org.rhq.core.util.StringUtil;
public class RemovePrefixTag extends TagSupport {
private String prefix = null;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
index 2699f8e..7a0f490 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
@@ -13,7 +13,7 @@ $Header$
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.servlet.ServletRequest" %>
-<%@ page import="org.rhq.core.clientapi.util.StringUtil" %>
+<%@ page import="org.rhq.core.util.StringUtil" %>
<%@ page import="org.rhq.enterprise.server.RHQConstants"%>
<%@ page import="org.rhq.enterprise.server.util.LookupUtil" %>
<%@ page import="org.rhq.core.db.DatabaseTypeFactory" %>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
index 915510d..cc2f790 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
@@ -1,7 +1,7 @@
<%@ page language="java" %>
<%@ page isErrorPage="true" %>
<%@ page import="javax.servlet.ServletException" %>
-<%@ page import="org.rhq.core.clientapi.util.StringUtil" %>
+<%@ page import="org.rhq.core.util.StringUtil" %>
<%@ page import="org.rhq.enterprise.server.auth.SessionNotFoundException"%>
<%@ page import="org.rhq.enterprise.server.auth.SessionTimeoutException"%>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
index 5f05378..eafb2e1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
@@ -1,7 +1,7 @@
<%@ page language="java" %>
<%@ page isErrorPage="true" %>
<%@ page import="java.util.Enumeration"%>
-<%@ page import="org.rhq.core.clientapi.util.StringUtil" %>
+<%@ page import="org.rhq.core.util.StringUtil" %>
<%@ page import="org.rhq.enterprise.gui.legacy.WebUser" %>
<%@ page import="org.rhq.enterprise.gui.legacy.WebUserPreferences" %>
<%@ page import="org.rhq.enterprise.gui.legacy.util.SessionUtils" %>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
index d92e7ba..5b1b980 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
@@ -27,9 +27,9 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.util.StringUtil;
public abstract class SubjectPreferencesBase {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java
index 2e47466..fe59053 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java
@@ -3,8 +3,8 @@ package org.rhq.enterprise.server.measurement;
import java.util.Arrays;
import java.util.List;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.auth.prefs.SubjectPreferencesBase;
import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java
index 711fb75..7935e5f 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java
@@ -27,11 +27,11 @@ import java.util.Properties;
import org.jmock.Expectations;
import org.testng.annotations.Test;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.sync.entity.SystemSettings;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.sync.importers.SystemSettingsImporter;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.test.JMockTest;
commit 711a4a70a5e582ceaee488189f0cbdc3355e3c03
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 14:47:02 2012 -0400
include the IOE in the call to log.error() when logging 500 errors, so the stack trace will get logged; the stack trace of the IOE will help us track down which classes the requests returning errors originate from
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 088bc9a..10610fc 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
@@ -277,7 +277,8 @@ public class ASConnection {
} catch (IOException ioe) {
responseCodeString = "unknown response code";
}
- log.error(operation + " failed with " + responseCodeString + " - response body was [" + responseBody + "].");
+ log.error(operation + " failed with " + responseCodeString + " - response body was [" + responseBody + "].",
+ e);
Result failure = new Result();
failure.setFailureDescription(e.getMessage());
commit f15c5981f086d0f2f1ca5912840486a5cd5506c6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 14:24:22 2012 -0400
add support for EAP 6.0.0.ER4
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 49bbd0a..e3cf3c8 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -229,10 +229,25 @@
</activation>
<properties>
- <as7.url>Please set the as7.url system property to the location of the EAP 6.0.0.Beta distribution zipfile.</as7.url>
+ <as7.url>Please set the as7.url system property to the location of the EAP 6.0.0.Beta1 distribution zipfile.</as7.url>
<jboss-as-arquillian-container-managed.version>7.1.1.Final</jboss-as-arquillian-container-managed.version>
</properties>
+ </profile>
+
+ <profile>
+ <id>eap600ER4.itest.setup</id>
+
+ <activation>
+ <property>
+ <name>as7.version</name>
+ <value>6.0.0.ER4</value>
+ </property>
+ </activation>
+ <properties>
+ <as7.url>Please set the as7.url system property to the location of the EAP 6.0.0.ER4 distribution zipfile.</as7.url>
+ <jboss-as-arquillian-container-managed.version>7.1.1.Final</jboss-as-arquillian-container-managed.version>
+ </properties>
</profile>
<!-- Activate this profile to run the integration tests (these can take a while to complete). -->
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
index 0cd1e01..3c143fd 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
@@ -39,6 +39,8 @@ public abstract class AbstractServerComponentTest extends AbstractJBossAS7Plugin
private static final Map<String, String> EAP6_VERSION_TO_AS7_VERSION_MAP = new HashMap<String, String>();
static {
EAP6_VERSION_TO_AS7_VERSION_MAP.put("6.0.0.Beta1", "7.1.0.Final-redhat-1");
+ EAP6_VERSION_TO_AS7_VERSION_MAP.put("6.0.0.ER4", "7.1.1.Final-redhat-1");
+ EAP6_VERSION_TO_AS7_VERSION_MAP.put("6.0.0.CR1", "7.1.1.Final-redhat-1");
}
private static final String RELEASE_VERSION_TRAIT_NAME = "_skm:release-version";
commit 7390597117edfdb6528afa6630aa91443b761aad
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Mar 30 11:43:21 2012 -0500
Update properties for security subsystem and moved the subsystem from server to service.
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 87a14af..1580f48 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
@@ -1776,71 +1776,6 @@ working area for individual server instances</li></ul>"/>
</server>
- <server name="Security"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
- >
-
- <runs-inside>
- <parent-resource-type name="Profile" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
- </runs-inside>
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="subsystem=security"/>
- </plugin-configuration>
-
-
-
- <resource-configuration>
- <c:simple-property name="authentication-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
- description="Specifies the AuthenticationManager implementation class name to use. To use the container default set the value to 'default'"/>
- <c:simple-property name="deep-copy-subject-mode" required="false" type="boolean" readOnly="true" defaultValue="false"
- description="Sets the copy mode of subjects done by the security managers to be deep copies that makes copies of the subject principals and credentials if they are cloneable. It should be set to true if subject include mutable content that can be corrupted when multiple threads have the same identity and cache flushes/logout clearing the subject in one thread results in subject references affecting other threads."/>
- <c:simple-property name="default-callback-handler-class-name" required="false" type="string" readOnly="true" defaultValue="default"
- description="A global class name for the CallbackHandler implementation to be used with login modules. To use the container default set the value to 'default'"/>
- <c:simple-property name="subject-factory-class-name" required="false" type="string" readOnly="true" defaultValue="default"
- description="Sets the class name for the SubjectFactory implementation to be used. To use the container default set the value to 'default'."/>
- <c:simple-property name="authorization-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
- description="Specifies the AuthorizationManager implementation class name to use. To use the container default set the value to 'default'."/>
- <c:simple-property name="audit-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
- description="Specifies the AuditManager implementation class name to use. To use the container default set the value to 'default'."/>
- <c:simple-property name="identity-trust-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
- description="Specifies the IdentityTrustManager implementation class name to use. To use the container default set the value to 'default'."/>
- <c:simple-property name="mapping-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
- description="Specifies the MappingManager implementation class name to use. To use the container default set the value to 'default''."/>
- </resource-configuration>
-
- <service name="SecurtityDomain"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
-
- <runs-inside>
- <parent-resource-type name="Profile" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
- </runs-inside>
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="security-domain"/>
- </plugin-configuration>
-
-
-
- <resource-configuration>
- <c:simple-property name="extends" required="false" type="string" readOnly="true" description="The parent security domain"/>
- <c:simple-property name="cache-type" required="false" type="string" readOnly="true"
- description="Adds a cache to speed up authentication checks. Allowed values are 'default' to use simple map as the cache and 'infinispan' to use an Infinispan cache.">
- <c:property-options>
- <c:option value="default"/>
- <c:option value="infinispan"/>
- </c:property-options>
- </c:simple-property>
- </resource-configuration>
- </service>
-
- </server>
<server name="Infinispan"
discovery="SubsystemDiscovery"
@@ -2988,4 +2923,49 @@ working area for individual server instances</li></ul>"/>
</service>
+
+ <service name="Security"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true">
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=security"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="deep-copy-subject-mode" required="false" type="boolean" readOnly="false" defaultValue="false" description="Sets the copy mode of subjects done by the security managers to be deep copies that makes copies of the subject principals and credentials if they are cloneable. It should be set to true if subject include mutable content that can be corrupted when multiple threads have the same identity and cache flushes/logout clearing the subject in one thread results in subject references affecting other threads. The default value is false."/>
+ </resource-configuration>
+
+ <service name="SecurtityDomain"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="security-domain"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="extends" required="false" type="string" readOnly="true" description="The parent security domain"/>
+ <c:simple-property name="cache-type" required="false" type="string" readOnly="true" description="Adds a cache to speed up authentication checks. Allowed values are 'default' to use simple map as the cache and 'infinispan' to use an Infinispan cache.">
+ <c:property-options>
+ <c:option value="default"/>
+ <c:option value="infinispan"/>
+ </c:property-options>
+ </c:simple-property>
+ </resource-configuration>
+ </service>
+
+ </service>
+
</plugin>
commit 5f21ea8f447bff7d0b9375f71a0b21ef2afd14aa
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Mar 30 11:33:29 2012 -0500
Add rhq-core-util to the classpath for d2d tool.
diff --git a/modules/plugins/jboss-as-7/d2d.sh b/modules/plugins/jboss-as-7/d2d.sh
index 577c3f7..2300cbb 100755
--- a/modules/plugins/jboss-as-7/d2d.sh
+++ b/modules/plugins/jboss-as-7/d2d.sh
@@ -6,4 +6,4 @@ RHQ_VERSION='4.4.0-SNAPSHOT'
OPTS=""
#OPTS="-agentlib:jdwp=transport=dt_socket,address=8790,server=y,suspend=y"
-java $OPTS -cp target/rhq-jboss-as-7-plugin-${RHQ_VERSION}.jar:${M2_REPO}/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar:${M2_REPO}/org/codehaus/jackson/jackson-core-asl/1.7.4/jackson-core-asl-1.7.4.jar:${M2_REPO}/org/codehaus/jackson/jackson-mapper-asl/1.7.4/jackson-mapper-asl-1.7.4.jar:${M2_REPO}/org/rhq/rhq-core-plugin-api/${RHQ_VERSION}/rhq-core-plugin-api-${RHQ_VERSION}.jar org.rhq.modules.plugins.jbossas7.Domain2Descriptor $*
+java $OPTS -cp target/rhq-jboss-as-7-plugin-${RHQ_VERSION}.jar:${M2_REPO}/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar:${M2_REPO}/org/codehaus/jackson/jackson-core-asl/1.7.4/jackson-core-asl-1.7.4.jar:${M2_REPO}/org/codehaus/jackson/jackson-mapper-asl/1.7.4/jackson-mapper-asl-1.7.4.jar:${M2_REPO}/org/rhq/rhq-core-plugin-api/${RHQ_VERSION}/rhq-core-plugin-api-${RHQ_VERSION}.jar:${M2_REPO}/org/rhq/rhq-core-util/${RHQ_VERSION}/rhq-core-util-${RHQ_VERSION}.jar org.rhq.modules.plugins.jbossas7.Domain2Descriptor $*
commit 8faa9a3ab209551b783d92bb6719e82bf87b38c8
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Mar 30 10:49:03 2012 -0500
Add support resource-adapter sub-subsystems. Also moved resource-adapters from server to service.
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 497a38b..87a14af 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
@@ -1452,23 +1452,6 @@
</server>
- <server name="ResourceAdapters"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
- >
-
- <runs-inside>
- <parent-resource-type name="Profile" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
- </runs-inside>
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="subsystem=resource-adapters"/>
- </plugin-configuration>
- </server>
-
-
<server name="Logging"
discovery="SubsystemDiscovery"
class="LoggerComponent"
@@ -2965,4 +2948,44 @@ working area for individual server instances</li></ul>"/>
</resource-configuration>
</service>
+
+ <service name="ResourceAdapters"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true">
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=resource-adapters"/>
+ </plugin-configuration>
+
+ <service name="ResourceAdapter"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ description="The configuration of the resource adapter.">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="resource-adapter"/>
+ </plugin-configuration>
+
+ <operation name="activate" description="Force the resource adapter config activation without server reload">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+
+ <resource-configuration>
+ <c:simple-property name="archive" required="true" type="string" readOnly="false" description="Specifies the resource adapter archive"/>
+ <c:simple-property name="beanvalidationgroups" required="false" type="string" readOnly="false" description="Specifies the bean validation groups that should be used"/>
+ <c:simple-property name="bootstrapcontext" required="false" type="string" readOnly="false" description="Specifies the unique name of the bootstrap context that should be used"/>
+ <c:simple-property name="transaction-support" required="true" type="string" readOnly="false" description="Specifies the transaction support level of the resource adapter"/>
+ </resource-configuration>
+ </service>
+
+ </service>
+
</plugin>
commit 94e8bed5e4ba3bdff7265c1775fb1ef190d0765c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 12:19:41 2012 -0400
replace calls to Throwable.printStackTrace() with logging
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java
index 3c9d64f..a0a947d 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java
@@ -25,7 +25,6 @@ package org.rhq.core.clientapi.agent.metadata.i18n;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
@@ -37,14 +36,14 @@ import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
/**
* Generates localization properties files for a plugin descriptor. Can update existing files by appending properties
@@ -53,7 +52,10 @@ import org.xml.sax.SAXException;
* @author Greg Hinkle
*/
public class PropertiesGenerator {
- private Map<String, String> properties = new LinkedHashMap();
+
+ private final Log log = LogFactory.getLog(PropertiesGenerator.class);
+
+ private Map<String, String> properties = new LinkedHashMap<String, String>();
private boolean update;
private File xmlFile;
@@ -126,12 +128,8 @@ public class PropertiesGenerator {
FileOutputStream fos = new FileOutputStream(propertiesFile, this.update);
this.contentWriter = new PrintWriter(fos);
generateNode(doc.getDocumentElement(), "");
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SAXException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ log.error("Failed to generate i18n properties file.", e);
} finally {
if (this.contentWriter != null) {
this.contentWriter.close();
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
index 4447b9f..51735ab 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
@@ -42,7 +42,7 @@ import java.util.concurrent.Callable;
*/
public class ConfigurationCheckExecutor implements Runnable, Callable {
- private Log log = LogFactory.getLog(ConfigurationCheckExecutor.class);
+ private final Log log = LogFactory.getLog(ConfigurationCheckExecutor.class);
private ConfigurationManager configurationManager;
private ConfigurationServerService configurationServerService;
@@ -128,7 +128,7 @@ public class ConfigurationCheckExecutor implements Runnable, Callable {
try {
checkConfigurations(child, true);
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Failed to check Resource configuration for " + child + ".", e);
}
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/SnapshotGenerator.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/SnapshotGenerator.java
index 2867bb9..e6c4d07 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/SnapshotGenerator.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/SnapshotGenerator.java
@@ -3,6 +3,8 @@ package org.rhq.core.pc.drift;
import org.apache.commons.io.DirectoryWalker;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -19,12 +21,15 @@ import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
+import org.rhq.core.pc.configuration.ConfigurationCheckExecutor;
import org.rhq.core.util.MessageDigestGenerator;
import static java.io.File.separator;
public class SnapshotGenerator extends DirectoryWalker {
+ private final Log log = LogFactory.getLog(ConfigurationCheckExecutor.class);
+
private MessageDigestGenerator digestGenerator = new MessageDigestGenerator(MessageDigestGenerator.SHA_256);
private File snapshotDir;
@@ -65,7 +70,7 @@ public class SnapshotGenerator extends DirectoryWalker {
zos.putNextEntry(entry);
IOUtils.copy(istream, zos);
} catch (IOException e) {
- e.printStackTrace();
+ log.error("Failed to add file " + file + " to zipfile " + zipFile + ".", e);
} finally {
if (istream != null) {
istream.close();
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 9245d3c..078d7ef 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -1222,9 +1222,10 @@ public class InventoryManager extends AgentService implements ContainerService,
// TODO REMOVE THIS IF STATEMENT - IT IS JUST FOR TESTING
if (!resource.getChildResources().getClass().getName().contains("Collections$SetFromMap")) {
- new Exception("BAD CHILD SET - IF YOU SEE THIS, LOG IT IN BZ 801432:"
+ Exception e = new Exception("BAD CHILD SET - IF YOU SEE THIS, LOG IT IN BZ 801432:"
+ resource.getChildResources().getClass().getName() + ":" + resource.getId() + ":"
- + resource.getName()).printStackTrace();
+ + resource.getName());
+ log.fatal("[BZ 801432]", e);
}
for (Resource child : resource.getChildResources()) {
diff --git a/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java b/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java
index 789d9a0..ecfed35 100644
--- a/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java
+++ b/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java
@@ -32,7 +32,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
public class StringUtil {
+
+ private static final Log log = LogFactory.getLog(StringUtil.class);
+
/**
* @param source The source string to perform replacements on.
* @param find The substring to find in source.
@@ -98,8 +104,7 @@ public class StringUtil {
retVal = remove.toString();
}
} catch (Exception e) {
- // XXX This should never happen
- e.printStackTrace();
+ log.error("This should not have happened.", e);
retVal = null;
}
commit 622f72a64f2e89c7c9c07ebe5c9c6bb003f5dc0a
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 11:54:08 2012 -0400
upgrade jboss-sasl from 1.0.0.Beta9 to 1.0.0.Final; only pass options specific to java7 or 64-bit java on as7 java command line when appropriate
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 6aa58df..49bbd0a 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -21,10 +21,12 @@
<properties>
<json.version>${project.json.version}</json.version>
<jackson.version>1.9.5</jackson.version>
- <jboss.sasl.version>1.0.0.Beta9</jboss.sasl.version>
+ <jboss.sasl.version>1.0.0.Final</jboss.sasl.version>
<as7.version>7.1.2.Final-SNAPSHOT</as7.version>
<as7.url>https://hudson.jboss.org/hudson/view/JBoss%20AS/job/JBoss-AS-7.0.x/lastSu...</as7.url>
<jboss-as-arquillian-container-managed.version>7.1.1.Final</jboss-as-arquillian-container-managed.version>
+ <java.tieredCompilation>-Dxxx</java.tieredCompilation>
+ <java.useCompressedOOPS>-Dxxx</java.useCompressedOOPS>
</properties>
@@ -42,6 +44,8 @@
<!-- === Compile Deps === -->
+ <!-- NOTE: jackson 2.0.0 has moved to a new groupId - artifacts are under
+ http://repo1.maven.org/maven2/com/fasterxml/jackson/ -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
@@ -121,6 +125,36 @@
<profiles>
<profile>
+ <id>java7</id>
+ <activation>
+ <property>
+ <name>java.specification.version</name>
+ <value>1.7</value>
+ </property>
+ </activation>
+
+ <properties>
+ <java.tieredCompilation>-XX:+TieredCompilation</java.tieredCompilation>
+ </properties>
+
+ </profile>
+
+ <profile>
+ <id>java64bit</id>
+
+ <activation>
+ <property>
+ <name>sun.arch.data.model</name>
+ <value>64</value>
+ </property>
+ </activation>
+
+ <properties>
+ <java.useCompressedOOPS>-XX:+UseCompressedOops</java.useCompressedOOPS>
+ </properties>
+ </profile>
+
+ <profile>
<id>as700Final.itest.setup</id>
<activation>
@@ -368,8 +402,8 @@
<!-- Process Controller Java options -->
<argument>-D[Standalone]</argument>
<argument>-server</argument>
- <argument>-XX:+UseCompressedOops</argument>
- <argument>-XX:+TieredCompilation</argument>
+ <argument>${java.useCompressedOOPS}</argument>
+ <argument>${java.tieredCompilation}</argument>
<argument>-Xms64m</argument>
<argument>-Xmx512m</argument>
<argument>-XX:MaxPermSize=256m</argument>
commit 2d7c2be0cddaebba3adfbb43f57688f0fb775b9e
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 11:16:16 2012 -0400
when we receive 500 (Internal Server Error) responses, include the response body in the error message we log, since it often includes valuable details
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 39c3bd9..088bc9a 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
@@ -67,8 +67,7 @@ public class ASConnection {
private int port;
/**
- * Construct an ASConnection object. The real "physical" connection is done in
- * {@link #executeRaw(Operation)}.
+ * Construct an ASConnection object. The real "physical" connection is done in {@link #executeRaw(Operation)}.
*
* @param host Host of the DomainController or standalone server
* @param port Port of the JSON api.
@@ -135,7 +134,7 @@ public class ASConnection {
* @see #executeComplex(org.rhq.modules.plugins.jbossas7.json.Operation)
*/
public JsonNode executeRaw(Operation operation, int timeoutSec) {
- long t1 = System.currentTimeMillis();
+ long requestStartTime = System.currentTimeMillis();
HttpURLConnection conn;
OutputStream out;
@@ -169,12 +168,9 @@ public class ASConnection {
return ret;
}
- InputStream inputStream;
- BufferedReader inputReader = null;
- InputStream errorStream = null;
try {
- //add additional request property to include-defaults=true to all requests.
- //if it's already set we leave it alone and assume that Operation creator is taking over control.
+ // Add additional request property to include-defaults=true to all requests.
+ // If it's already set, we leave it alone and assume that Operation creator is taking over control.
if (operation.getAdditionalProperties().isEmpty()
|| !operation.getAdditionalProperties().containsKey(INCLUDE_DEFAULT)) {
operation.addAdditionalProperty("include-defaults", "true");
@@ -182,13 +178,12 @@ public class ASConnection {
String json_to_send = mapper.writeValueAsString(operation);
- //check for spaces in the path which the AS7 server will reject. Log verbose error and
+ // Check for spaces in the path which the AS7 server will reject. Log verbose error and
// generate failure indicator.
if ((operation != null) && (operation.getAddress() != null) && operation.getAddress().getPath() != null) {
if (containsSpaces(operation.getAddress().getPath())) {
Result noResult = new Result();
- String outcome = "- Path '" + operation.getAddress().getPath()
- + "' is invalid as it contains spaces -";
+ String outcome = "- Path '" + operation.getAddress().getPath() + "' is invalid as it contains spaces -";
if (verbose) {
log.error(outcome);
}
@@ -208,15 +203,11 @@ public class ASConnection {
out.flush();
out.close();
- int responseCode = conn.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK) {
- inputStream = conn.getInputStream();
- } else {
- inputStream = conn.getErrorStream();
- }
+ InputStream inputStream = (conn.getInputStream() != null) ? conn.getInputStream() : conn.getErrorStream();
if (inputStream != null) {
- inputReader = new BufferedReader(new InputStreamReader(inputStream));
+ BufferedReader inputReader = new BufferedReader(new InputStreamReader(inputStream));
+ // Note: slurp() will close the stream once it's done slurping it.
String responseBody = StreamUtil.slurp(inputReader);
String outcome;
@@ -240,18 +231,20 @@ public class ASConnection {
return operationResult;
} else {
- //if not properly authorized sends plugin exception for visual indicator in the ui.
- if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED
- || responseCode == HttpURLConnection.HTTP_BAD_METHOD) {
+ // Empty response body - probably some sort of error - check the response code.
+ int responseCode = conn.getResponseCode();
+ if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
if (log.isDebugEnabled()) {
log.debug("Response to " + operation + " was empty and response code was " + responseCode + " "
- + conn.getResponseMessage() + ".");
+ + conn.getResponseMessage() + " - throwing InvalidPluginConfigurationException...");
}
+ // Throw a InvalidPluginConfigurationException, so the user will get a yellow plugin connection
+ // warning message in the GUI.
throw new InvalidPluginConfigurationException(
- "Credentials for plugin to connect to AS7 management interface are invalid. Update Connection Settings with valid credentials.");
+ "Credentials for plugin to connect to AS7 management interface are invalid - update Connection Settings with valid credentials.");
} else {
- log.error("Response to " + operation + " was empty and response code was " + responseCode + " ("
- + conn.getResponseMessage() + ").");
+ log.warn("Response body for " + operation + " was empty and response code was " + responseCode + " ("
+ + conn.getResponseMessage() + ").");
}
}
} catch (IllegalArgumentException iae) {
@@ -267,25 +260,24 @@ public class ASConnection {
JsonNode ret = mapper.valueToTree(failure);
return ret;
} catch (IOException e) {
- log.error("Failed to get data: " + e);
-
- //the following code is in place to help keep-alive http connection re-use to occur.
- if (conn != null) {//on error conditions it's still necessary to read the response so JDK knows can reuse
- //the http connections behind the scenes.
- errorStream = conn.getErrorStream();
- if (errorStream != null) {
- BufferedReader dr = new BufferedReader(new InputStreamReader(errorStream));
- String ignore = null;
- try {
- while ((ignore = dr.readLine()) != null) {
- //already reported error. just empty stream.
- }
- errorStream.close();
- } catch (IOException e1) {
- // ignore
- }
- }
+ // On error conditions, it's still necessary to slurp the response stream so the JDK knows it can reuse the
+ // persistent HTTP connection behind the scenes.
+ String responseBody;
+ if (conn.getErrorStream() != null) {
+ BufferedReader errorReader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
+ // Note: slurp() will close the stream once it's done slurping it.
+ responseBody = StreamUtil.slurp(errorReader);
+ } else {
+ responseBody = "";
+ }
+
+ String responseCodeString;
+ try {
+ responseCodeString = conn.getResponseCode() + " (" + conn.getResponseMessage() + ")";
+ } catch (IOException ioe) {
+ responseCodeString = "unknown response code";
}
+ log.error(operation + " failed with " + responseCodeString + " - response body was [" + responseBody + "].");
Result failure = new Result();
failure.setFailureDescription(e.getMessage());
@@ -294,27 +286,11 @@ public class ASConnection {
JsonNode ret = mapper.valueToTree(failure);
return ret;
-
} finally {
- if (inputReader != null) {
- try {
- inputReader.close();
- } catch (IOException e) {
- log.error("Failed to close HTTP connection input stream: " + e.getMessage());
- }
- }
- if (errorStream != null) {
- try {
- errorStream.close();
- } catch (IOException e) {
- log.error("Failed to close HTTP connection error stream: " + e.getMessage());
- }
- }
-
- long t2 = System.currentTimeMillis();
+ long requestEndTime = System.currentTimeMillis();
PluginStats stats = PluginStats.getInstance();
stats.incrementRequestCount();
- stats.addRequestTime(t2 - t1);
+ stats.addRequestTime(requestEndTime - requestStartTime);
}
return null;
commit dabdfcff99f5c0a9a8fedbc5b6085838cc2e5de5
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Mar 30 09:51:38 2012 -0500
Added support for EE subsystem. Update CMP subsystems to allow multiple Hilo Keygenerators. Added support for JDNI bindings in the naming subsystem.
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 cec63da..497a38b 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
@@ -2387,11 +2387,10 @@ working area for individual server instances</li></ul>"/>
</resource-configuration>
</server>
- <server name="Naming"
+ <service name="Naming"
discovery="SubsystemDiscovery"
class="NamingComponent"
- singleton="true"
- >
+ singleton="true">
<runs-inside>
<parent-resource-type name="Host" plugin="jboss-as-7"/>
@@ -2420,67 +2419,85 @@ working area for individual server instances</li></ul>"/>
</c:list-property>
</results>
</operation>
- </server>
+ <service name="Binding"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ description="JNDI bindings for primitive types"
+ singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="binding"/>
+ </plugin-configuration>
- <service name="Transactions Subsystem"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
- description="The transactions subsystem."
- >
-
- <runs-inside>
- <parent-resource-type name="Profile" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
- </runs-inside>
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="subsystem=transactions"/>
- </plugin-configuration>
-
- <metric property="number-of-nested-transactions" description="The total number of nested (sub) transactions created."
- measurementType="trendsup" defaultInterval="300000" defaultOn="false"/>
- <metric property="number-of-timed-out-transactions" description="The number of transactions that have rolled back due to timeout."
- measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
- <metric property="number-of-committed-transactions" description="The number of committed transactions."
- measurementType="trendsup" defaultInterval="300000" defaultOn="false"/>
- <metric property="number-of-transactions" description="The total number of transactions (top-level and nested) created"
- measurementType="trendsup" defaultInterval="300000" defaultOn="false"/>
- <metric property="number-of-heuristics" description="The number of transactions which have terminated with heuristic outcomes."
- measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
- <metric property="number-of-aborted-transactions" description="The number of aborted (i.e. rolledback) transactions."
- measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
- <metric property="number-of-inflight-transactions" description="The number of transactions that have begun but not yet terminated."
- measurementType="trendsup" defaultInterval="300000" defaultOn="false"/>
- <metric property="number-of-application-rollbacks" description="The number of transactions that have been rolled back by application request. This includes those that timeout, since the timeout behaviour is considered an attribute of the application configuration."
- measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
- <metric property="number-of-resource-rollbacks" description="The number of transactions that rolled back due to resource (participant) failure."
- measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
-
- <resource-configuration>
- <c:simple-property name="relative-to" required="false" type="string" readOnly="false" defaultValue="jboss.server.data.dir"
- description="References a global path configuration in the domain model, defaulting to the JBoss Application Server data directory (jboss.server.data.dir). The value of the 'path' attribute will treated as relative to this path. Use an empty string to disable the default behavior and force the value of the 'path' attribute to be treated as an absolute path."/>
- <c:simple-property name="process-id-uuid" required="false" type="boolean" readOnly="false" description="Indicates whether the transaction manager should use a UUID based process id."/>
- <c:simple-property name="socket-binding" required="false" type="string" readOnly="false" description="Used to reference the correct socket binding to use for the recovery environment."/>
- <c:simple-property name="jts" required="false" type="boolean" readOnly="false" defaultValue="false" description="If true this enables the Java Transaction Service"/>
- <c:simple-property name="object-store-path" required="false" type="string" readOnly="false" defaultValue="tx-object-store"
- description="Denotes a relative or absolute filesystem path denoting where the transaction manager object store should store data. By default the value is treated as relative to the path denoted by the 'relative-to' attribute."/>
- <c:simple-property name="path" required="false" type="string" readOnly="false" defaultValue="var" description="Denotes a relative or absolute filesystem path denoting where the transaction manager core should store data. By default the value is treated as relative to the path denoted by the 'relative-to' attribute."/>
- <c:simple-property name="process-id-socket-binding" required="false" type="string" readOnly="false" description="The name of the socket binding configuration to use if the transaction manager should use a socket-based process id. Will be 'undefined' if 'process-id-uuid' is 'true'; otherwise must be set."/>
- <c:simple-property name="default-timeout" required="false" type="integer" readOnly="false" defaultValue="300" description="The default timeout."/>
- <c:simple-property name="process-id-socket-max-ports" required="false" type="integer" readOnly="false" defaultValue="10" description="The maximum number of ports to search for an open port if the transaction manager should use a socket-based process id. If the port specified by the socket binding referenced in 'process-id-socket-binding' is occupied, the next higher port will be tried until an open port is found or the number of ports specified by this attribute have been tried. Will be 'undefined' if 'process-id-uuid' is 'true'."/>
- <c:simple-property name="recovery-listener" required="false" type="boolean" readOnly="false" defaultValue="false" description="Used to specify if the recovery system should listen on a network socket or not."/>
- <c:simple-property name="status-socket-binding" required="false" type="string" readOnly="false" description="Used to reference the correct socket binding to use for the transaction status manager."/>
- <c:simple-property name="node-identifier" required="false" type="string" readOnly="false" defaultValue="1" description="Used to set the node identifier on the core environment."/>
- <c:simple-property name="enable-tsm-status" required="false" type="boolean" readOnly="false" defaultValue="false" description="Whether the transaction status manager (TSM) service, needed for out of process recovery, should be provided or not.."/>
- <c:simple-property name="object-store-relative-to" required="false" type="string" readOnly="false" defaultValue="jboss.server.data.dir"
- description="References a global path configuration in the domain model, defaulting to the JBoss Application Server data directory (jboss.server.data.dir). The value of the 'path' attribute will treated as relative to this path. Use an empty string to disable the default behavior and force the value of the 'path' attribute to be treated as an absolute path."/>
- <c:simple-property name="enable-statistics" required="false" type="boolean" readOnly="false" defaultValue="false" description="Whether statistics should be enabled."/>
- </resource-configuration>
-
- </service>
+ <resource-configuration>
+ <c:simple-property name="binding-type" required="false" type="string" readOnly="false" description="The type of binding to create, may be simple, lookup or object-factory"/>
+ <c:simple-property name="class" required="false" type="string" readOnly="false" description="The object factory class name for object factory bindings"/>
+ <c:simple-property name="lookup" required="false" type="string" readOnly="false" description="The entry to lookup in JNDI for lookup bindings"/>
+ <c:simple-property name="module" required="false" type="string" readOnly="false" description="The module to load the object factory from for object factory bindings"/>
+ <c:simple-property name="type" required="false" type="string" readOnly="false" description="The type of the value to bind for simple bindings, this must be a primitive type"/>
+ <c:simple-property name="value" required="false" type="string" readOnly="false" description="The value to bind for simple bindings"/>
+ </resource-configuration>
+ </service>
+ </service>
+
+ <service name="Transactions Subsystem"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ description="The transactions subsystem.">
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=transactions"/>
+ </plugin-configuration>
+
+ <metric property="number-of-nested-transactions" description="The total number of nested (sub) transactions created."
+ measurementType="trendsup" defaultInterval="300000" defaultOn="false"/>
+ <metric property="number-of-timed-out-transactions" description="The number of transactions that have rolled back due to timeout."
+ measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
+ <metric property="number-of-committed-transactions" description="The number of committed transactions."
+ measurementType="trendsup" defaultInterval="300000" defaultOn="false"/>
+ <metric property="number-of-transactions" description="The total number of transactions (top-level and nested) created"
+ measurementType="trendsup" defaultInterval="300000" defaultOn="false"/>
+ <metric property="number-of-heuristics" description="The number of transactions which have terminated with heuristic outcomes."
+ measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
+ <metric property="number-of-aborted-transactions" description="The number of aborted (i.e. rolledback) transactions."
+ measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
+ <metric property="number-of-inflight-transactions" description="The number of transactions that have begun but not yet terminated."
+ measurementType="trendsup" defaultInterval="300000" defaultOn="false"/>
+ <metric property="number-of-application-rollbacks" description="The number of transactions that have been rolled back by application request. This includes those that timeout, since the timeout behaviour is considered an attribute of the application configuration."
+ measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
+ <metric property="number-of-resource-rollbacks" description="The number of transactions that rolled back due to resource (participant) failure."
+ measurementType="trendsup" defaultInterval="300000" defaultOn="true"/>
+
+ <resource-configuration>
+ <c:simple-property name="relative-to" required="false" type="string" readOnly="false" defaultValue="jboss.server.data.dir"
+ description="References a global path configuration in the domain model, defaulting to the JBoss Application Server data directory (jboss.server.data.dir). The value of the 'path' attribute will treated as relative to this path. Use an empty string to disable the default behavior and force the value of the 'path' attribute to be treated as an absolute path."/>
+ <c:simple-property name="process-id-uuid" required="false" type="boolean" readOnly="false" description="Indicates whether the transaction manager should use a UUID based process id."/>
+ <c:simple-property name="socket-binding" required="false" type="string" readOnly="false" description="Used to reference the correct socket binding to use for the recovery environment."/>
+ <c:simple-property name="jts" required="false" type="boolean" readOnly="false" defaultValue="false" description="If true this enables the Java Transaction Service"/>
+ <c:simple-property name="object-store-path" required="false" type="string" readOnly="false" defaultValue="tx-object-store"
+ description="Denotes a relative or absolute filesystem path denoting where the transaction manager object store should store data. By default the value is treated as relative to the path denoted by the 'relative-to' attribute."/>
+ <c:simple-property name="path" required="false" type="string" readOnly="false" defaultValue="var" description="Denotes a relative or absolute filesystem path denoting where the transaction manager core should store data. By default the value is treated as relative to the path denoted by the 'relative-to' attribute."/>
+ <c:simple-property name="process-id-socket-binding" required="false" type="string" readOnly="false" description="The name of the socket binding configuration to use if the transaction manager should use a socket-based process id. Will be 'undefined' if 'process-id-uuid' is 'true'; otherwise must be set."/>
+ <c:simple-property name="default-timeout" required="false" type="integer" readOnly="false" defaultValue="300" description="The default timeout."/>
+ <c:simple-property name="process-id-socket-max-ports" required="false" type="integer" readOnly="false" defaultValue="10" description="The maximum number of ports to search for an open port if the transaction manager should use a socket-based process id. If the port specified by the socket binding referenced in 'process-id-socket-binding' is occupied, the next higher port will be tried until an open port is found or the number of ports specified by this attribute have been tried. Will be 'undefined' if 'process-id-uuid' is 'true'."/>
+ <c:simple-property name="recovery-listener" required="false" type="boolean" readOnly="false" defaultValue="false" description="Used to specify if the recovery system should listen on a network socket or not."/>
+ <c:simple-property name="status-socket-binding" required="false" type="string" readOnly="false" description="Used to reference the correct socket binding to use for the transaction status manager."/>
+ <c:simple-property name="node-identifier" required="false" type="string" readOnly="false" defaultValue="1" description="Used to set the node identifier on the core environment."/>
+ <c:simple-property name="enable-tsm-status" required="false" type="boolean" readOnly="false" defaultValue="false" description="Whether the transaction status manager (TSM) service, needed for out of process recovery, should be provided or not.."/>
+ <c:simple-property name="object-store-relative-to" required="false" type="string" readOnly="false" defaultValue="jboss.server.data.dir"
+ description="References a global path configuration in the domain model, defaulting to the JBoss Application Server data directory (jboss.server.data.dir). The value of the 'path' attribute will treated as relative to this path. Use an empty string to disable the default behavior and force the value of the 'path' attribute to be treated as an absolute path."/>
+ <c:simple-property name="enable-statistics" required="false" type="boolean" readOnly="false" defaultValue="false" description="Whether statistics should be enabled."/>
+ </resource-configuration>
+
+ </service>
<service name="Network Interface"
discovery="SubsystemDiscovery"
@@ -2498,16 +2515,16 @@ working area for individual server instances</li></ul>"/>
</plugin-configuration>
</service>
+
<service name="SocketBindingGroup"
discovery="SubsystemDiscovery"
- class="SocketBindingGroupComponent"
- >
+ class="SocketBindingGroupComponent">
+
<runs-inside>
<parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
<parent-resource-type name="JBossAS7 Host Controller" plugin="jboss-as-7"/>
</runs-inside>
-
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="socket-binding-group"/>
</plugin-configuration>
@@ -2897,8 +2914,16 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="path" default="subsystem=cmp" readOnly="true"/>
</plugin-configuration>
- <resource-configuration>
- <c:group name="child:hilo-keygenerator=hilo-keygenerator" displayName="HiLo based key generators.">
+ <service name="HiloKeygenerator"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ description="HiLo based key generators.">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="hilo-keygenerator"/>
+ </plugin-configuration>
+
+ <resource-configuration>
<c:simple-property name="block-size" required="false" type="long" readOnly="true" description="The block size"/>
<c:simple-property name="create-table" required="false" type="boolean" readOnly="true" description="Boolean to determine whether to create create the tables"/>
<c:simple-property name="create-table-ddl" required="false" type="string" readOnly="true" description="The DDL used to create the table"/>
@@ -2909,9 +2934,35 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="sequence-column" required="false" type="string" readOnly="true" description="The sequence column name"/>
<c:simple-property name="sequence-name" required="false" type="string" readOnly="true" description="The name of the sequence"/>
<c:simple-property name="table-name" required="false" type="string" readOnly="true" description="The table name"/>
- </c:group>
- </resource-configuration>
+ </resource-configuration>
+ </service>
+
+ </service>
+
+ <service name="EE"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ description="The configuration of the EE subsystem."
+ singleton="true">
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" default="subsystem=ee" readOnly="true"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="ear-subdeployments-isolated" required="false" type="boolean" readOnly="false" defaultValue="false" description="Flag indicating whether each of the subdeployments within a .ear can access classes belonging to another subdeployment within the same .ear. A value of false means the subdeployments can see classes belonging to other subdeployments within the .ear. The default value is false."/>
+ <c:list-property name="global-modules" description="A list of modules that should be made available to all deployments." >
+ <c:map-property name="globalmodule" displayName="Global module">
+ <c:simple-property name="name" type="string" displayName="Name" required="true"/>
+ <c:simple-property name="slot" type="string" displayName="Slot" required="true"/>
+ </c:map-property>
+ </c:list-property>
+ </resource-configuration>
</service>
</plugin>
commit b08d84b76985ca4d0cbbfa05435d401fdbe0068d
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 10:27:52 2012 -0400
make sure itests run in desired order; use exec plugin, rather than arquillian plugin, in pom to start as7 standalone instance; various minor tweaks; turn down some logging to make log less cluttered
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 2c6a98e..6aa58df 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -297,9 +297,9 @@
</execution>
</executions>
</plugin>
-
+<!--
<plugin>
- <!-- use the arquillian plugin to start/stop the standalone server -->
+ <!- - use the arquillian plugin to start/stop the standalone server - ->
<groupId>org.jboss.arquillian.maven</groupId>
<artifactId>arquillian-maven-plugin</artifactId>
<version>1.0.0.Alpha2</version>
@@ -343,15 +343,63 @@
</dependencies>
</plugin>
-
+-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1.jbossorg-3</version>
<executions>
+
+ <execution>
+ <id>start-as7-standalone</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <background>true</background>
+ <!-- test blocks until the port at backgroundPollingAddress is available (waiting for starting) -->
+ <!-- when maven jvm exits, this plugin will kill the running servers -->
+ <backgroundPollingAddress>${jboss.standalone.bindAddress}:${jboss.standalone.nativeManagementPort}
+ </backgroundPollingAddress>
+ <executable>${java.home}/bin/java</executable>
+ <arguments>
+ <!-- Process Controller Java options -->
+ <argument>-D[Standalone]</argument>
+ <argument>-server</argument>
+ <argument>-XX:+UseCompressedOops</argument>
+ <argument>-XX:+TieredCompilation</argument>
+ <argument>-Xms64m</argument>
+ <argument>-Xmx512m</argument>
+ <argument>-XX:MaxPermSize=256m</argument>
+ <argument>-Djava.net.preferIPv4Stack=true</argument>
+ <argument>-Dorg.jboss.resolver.warning=true</argument>
+ <argument>-Dsun.rmi.dgc.client.gcInterval=3600000</argument>
+ <argument>-Dsun.rmi.dgc.server.gcInterval=3600000</argument>
+ <argument>-Djboss.modules.system.pkgs=org.jboss.byteman</argument>
+ <argument>-Djava.awt.headless=true</argument>
+ <argument>-Djboss.server.default.config=standalone.xml</argument>
+ <argument>-Dorg.jboss.boot.log.file=${jboss7.home}/standalone/log/boot.log</argument>
+ <argument>-Dlogging.configuration=file:${jboss7.home}/standalone/configuration/logging.properties</argument>
+ <argument>-jar</argument>
+ <argument>${jboss7.home}/jboss-modules.jar</argument>
+ <argument>-mp</argument>
+ <argument>${jboss7.home}/modules</argument>
+ <argument>-jaxpmodule</argument>
+ <argument>javax.xml.jaxp-provider</argument>
+ <argument>org.jboss.as.standalone</argument>
+ <argument>-Djboss.home.dir=${jboss7.home}</argument>
+ <argument>-Djboss.bind.address.management=${jboss.standalone.bindAddress}</argument>
+ <argument>-Djboss.bind.address=${jboss.standalone.bindAddress}</argument>
+ <argument>-Djboss.bind.address.unsecure=${jboss.standalone.bindAddress}</argument>
+ <argument>-Djboss.socket.binding.port-offset=${jboss.standalone.portOffset}</argument>
+ </arguments>
+ </configuration>
+ </execution>
+
<execution>
- <id>start-jboss7-host-controller</id>
+ <id>start-as7-domain</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
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 5c1356a..39c3bd9 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
@@ -38,6 +38,7 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.Result;
@@ -114,7 +115,7 @@ public class ASConnection {
* @see #executeComplex(org.rhq.modules.plugins.jbossas7.json.Operation)
*/
public JsonNode executeRaw(Operation operation) {
- return executeRaw(operation, 10);
+ return executeRaw(operation, 20);
}
/**
@@ -169,8 +170,8 @@ public class ASConnection {
}
InputStream inputStream;
- BufferedReader br = null;
- InputStream es = null;
+ BufferedReader inputReader = null;
+ InputStream errorStream = null;
try {
//add additional request property to include-defaults=true to all requests.
//if it's already set we leave it alone and assume that Operation creator is taking over control.
@@ -215,17 +216,13 @@ public class ASConnection {
}
if (inputStream != null) {
- br = new BufferedReader(new InputStreamReader(inputStream));
- String line;
- StringBuilder builder = new StringBuilder();
- while ((line = br.readLine()) != null) {
- builder.append(line);
- }
+ inputReader = new BufferedReader(new InputStreamReader(inputStream));
+ String responseBody = StreamUtil.slurp(inputReader);
String outcome;
JsonNode operationResult;
- if (builder.length() > 0) {
- outcome = builder.toString();
+ if (responseBody.length() > 0) {
+ outcome = responseBody;
operationResult = mapper.readTree(outcome);
if (verbose) {
ObjectMapper om2 = new ObjectMapper();
@@ -240,26 +237,27 @@ public class ASConnection {
noResult.setOutcome("failure");
operationResult = mapper.valueToTree(noResult);
}
+
return operationResult;
} else {
//if not properly authorized sends plugin exception for visual indicator in the ui.
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED
|| responseCode == HttpURLConnection.HTTP_BAD_METHOD) {
if (log.isDebugEnabled()) {
- log.debug("[" + url + "] Response was empty and response code was " + responseCode + " "
+ log.debug("Response to " + operation + " was empty and response code was " + responseCode + " "
+ conn.getResponseMessage() + ".");
}
throw new InvalidPluginConfigurationException(
"Credentials for plugin to connect to AS7 management interface are invalid. Update Connection Settings with valid credentials.");
} else {
- log.error("[" + url + "] Response was empty and response code was " + responseCode + " "
- + conn.getResponseMessage() + ".");
+ log.error("Response to " + operation + " was empty and response code was " + responseCode + " ("
+ + conn.getResponseMessage() + ").");
}
}
} catch (IllegalArgumentException iae) {
- log.error("Illegal argument " + iae + "\n\t for input " + operation);
+ log.error("Illegal argument for input " + operation + ": " + iae.getMessage());
} catch (SocketTimeoutException ste) {
- log.error("Request to AS timed out " + ste.getMessage());
+ log.error(operation + " timed out: " + ste.getMessage());
conn.disconnect();
Result failure = new Result();
failure.setFailureDescription(ste.getMessage());
@@ -269,20 +267,20 @@ public class ASConnection {
JsonNode ret = mapper.valueToTree(failure);
return ret;
} catch (IOException e) {
- log.error("Failed to get data: " + e.getMessage());
+ log.error("Failed to get data: " + e);
//the following code is in place to help keep-alive http connection re-use to occur.
if (conn != null) {//on error conditions it's still necessary to read the response so JDK knows can reuse
//the http connections behind the scenes.
- es = conn.getErrorStream();
- if (es != null) {
- BufferedReader dr = new BufferedReader(new InputStreamReader(es));
+ errorStream = conn.getErrorStream();
+ if (errorStream != null) {
+ BufferedReader dr = new BufferedReader(new InputStreamReader(errorStream));
String ignore = null;
try {
while ((ignore = dr.readLine()) != null) {
//already reported error. just empty stream.
}
- es.close();
+ errorStream.close();
} catch (IOException e1) {
// ignore
}
@@ -298,20 +296,21 @@ public class ASConnection {
return ret;
} finally {
- if (br != null) {
+ if (inputReader != null) {
try {
- br.close();
+ inputReader.close();
} catch (IOException e) {
- log.error(e.getMessage());
+ log.error("Failed to close HTTP connection input stream: " + e.getMessage());
}
}
- if (es != null) {
+ if (errorStream != null) {
try {
- es.close();
+ errorStream.close();
} catch (IOException e) {
- log.error(e.getMessage());
+ log.error("Failed to close HTTP connection error stream: " + e.getMessage());
}
}
+
long t2 = System.currentTimeMillis();
PluginStats stats = PluginStats.getInstance();
stats.incrementRequestCount();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index c4c5c03..c225406 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -115,8 +115,10 @@ public class ASUploadConnection {
os.flush();
int code = connection.getResponseCode();
- log.info("Response code for file upload: " + code);
- if (code==500)
+ if (code != 200) {
+ log.warn("Response code for file upload: " + code + " " + connection.getResponseMessage());
+ }
+ if (code == 500)
is = connection.getErrorStream();
else
is = connection.getInputStream();
@@ -208,7 +210,6 @@ public class ASUploadConnection {
String reason = reasonNode.getTextValue();
return true;
}
-
} catch (Exception e) {
log.error(e);
return true;
@@ -217,12 +218,12 @@ public class ASUploadConnection {
return false;
}
-
private void closeQuietly(final Closeable closeable) {
if(closeable != null) {
try {
closeable.close();
- } catch (final IOException e) {}
+ } catch (final IOException ignore) {
+ }
}
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
index a1993bc..aaa688a 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
@@ -92,12 +92,12 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl
* @see #readStandaloneOrHostXmlFromFile(String) for how to obtain the parsed xml
* @param commandLine Command line arguments of the process to
*/
- protected HostPort getManagementPortFromHostXml(String[] commandLine) {
+ protected HostPort getManagementHostPortFromHostXml(String[] commandLine) {
if (hostXml == null)
throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST);
String portString;
- String interfaceExpession;
+ String interfaceExpression;
String socketBindingName;
@@ -106,10 +106,10 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl
String portOffset = null;
if (!socketInterface.isEmpty()) {
- interfaceExpession = obtainXmlPropertyViaXPath("//interfaces/interface[@name='" + socketInterface
+ interfaceExpression = obtainXmlPropertyViaXPath("//interfaces/interface[@name='" + socketInterface
+ "']/inet-address/@value");
- if (interfaceExpession.isEmpty()) {
- interfaceExpession = obtainXmlPropertyViaXPath("//interfaces/interface[@name='" + socketInterface
+ if (interfaceExpression.isEmpty()) {
+ interfaceExpression = obtainXmlPropertyViaXPath("//interfaces/interface[@name='" + socketInterface
+ "']/loopback-address/@value");
}
portString = obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/socket/@port");
@@ -117,10 +117,10 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl
// old AS7.0, early 7.1 style
portString = obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@port");
String interfaceName = obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@interface");
- interfaceExpession = obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" + interfaceName
+ interfaceExpression = obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" + interfaceName
+ "']/inet-address/@value");
- if (interfaceExpession.isEmpty()) {
- interfaceExpession = obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" + interfaceName
+ if (interfaceExpression.isEmpty()) {
+ interfaceExpression = obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" + interfaceName
+ "']/loopback-address/@value");
}
} else {
@@ -136,17 +136,17 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl
portOffset = obtainXmlPropertyViaXPath(xpathExpression);
// TODO the next may also be expressed differently
- interfaceExpession = obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" + interfaceName
+ interfaceExpression = obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" + interfaceName
+ "']/inet-address/@value");
- if (interfaceExpession.isEmpty()) {
- interfaceExpession = obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" + interfaceName
+ if (interfaceExpression.isEmpty()) {
+ interfaceExpression = obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" + interfaceName
+ "']/loopback-address/@value");
}
}
HostPort hp = new HostPort();
- if (!interfaceExpession.isEmpty())
- hp.host = replaceDollarExpression(interfaceExpession, commandLine, "localhost");
+ if (!interfaceExpression.isEmpty())
+ hp.host = replaceDollarExpression(interfaceExpression, commandLine, "localhost");
else
hp.host = "localhost"; // Fallback
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 590da14..cea3ee6 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
@@ -163,7 +163,7 @@ public class BaseComponent<T extends ResourceComponent<?>> implements AS7Compone
String reqName = req.getName();
ComplexRequest request = null;
- Operation op = null;
+ Operation op;
if (reqName.contains(":")) {
request = ComplexRequest.create(reqName);
op = new ReadAttribute(address, request.getProp());
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 2eec0d5..bffac1c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -116,7 +116,7 @@ public abstract class BaseProcessDiscovery extends AbstractBaseDiscovery
fillUserPassFromFile(pluginConfig, getMode(), baseDir);
File logFile = getLogFile(getLogDir(process, baseDir));
initLogEventSourcesConfigProp(logFile.getPath(), pluginConfig);
- HostPort managementHostPort = getManagementPortFromHostXml(commandLine);
+ HostPort managementHostPort = getManagementHostPortFromHostXml(commandLine);
pluginConfig.put(new PropertySimple("hostname", managementHostPort.host));
pluginConfig.put(new PropertySimple("port", managementHostPort.port));
pluginConfig.put(new PropertySimple("realm", getManagementSecurityRealmFromHostXml()));
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 20e5518..79fc444 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -357,8 +357,8 @@ public class BaseServerComponent<T extends ResourceComponent<?>> extends BaseCom
Result res = getASConnection().execute(op);
if (res.isSuccess()) {
- Long startTime= (Long) res.getResult();
- MeasurementDataTrait data = new MeasurementDataTrait(request,new Date(startTime).toString());
+ Long startTime = (Long) res.getResult();
+ MeasurementDataTrait data = new MeasurementDataTrait(request, new Date(startTime).toString());
report.addData(data);
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java
index c578607..d07ebeb 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java
@@ -40,10 +40,8 @@ public class HornetQComponent extends BaseComponent {
targetAddress.add(targetType.as7name,resourceName);
List<String> entries;
- Operation op;
-
Result res;
- op = new Operation("read-operation-description",targetAddress);
+ Operation op = new Operation("read-operation-description",targetAddress);
op.addAdditionalProperty("name","add");
ComplexResult cres = getASConnection().executeComplex(op);
Map<String,Map<String,Object>> definitions;
@@ -205,7 +203,7 @@ public class HornetQComponent extends BaseComponent {
/**
* Create a Type
* @param descriptorName type name as it is listed in the plugin descriptor
- * @param as7name the type undder which as7 knows it.
+ * @param as7name the type by which as7 knows it.
*/
CreationType(String descriptorName, String as7name) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
index a7e684d..140cef6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
@@ -82,14 +82,16 @@ public class HostControllerDiscovery extends BaseProcessDiscovery {
@Override
protected String buildDefaultResourceName(HostPort hostPort, String configName, JBossProductType productType) {
- String suffix = (hostPort.isLocal) ? "Domain Controller" : "Host Controller";
+ boolean isDomainController = hostPort.isLocal;
+ String suffix = (isDomainController) ? "Domain Controller" : "Host Controller";
return configName + " " + productType.NAME + " " + suffix;
}
@Override
protected String buildDefaultResourceDescription(HostPort hostPort, JBossProductType productType) {
- String prefix = (hostPort.isLocal) ? "Domain controller" : "Host controller";
- String suffix = (hostPort.isLocal) ? "domain" : "host";
+ boolean isDomainController = hostPort.isLocal;
+ String prefix = (isDomainController) ? "Domain controller" : "Host controller";
+ String suffix = (isDomainController) ? "domain" : "host";
return prefix + " for a " + productType.FULL_NAME + " " + suffix;
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 69bd8d4..0308fd1 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -45,8 +45,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
*
* @author Heiko W. Rupp
*/
-public class ManagedASDiscovery extends AbstractBaseDiscovery<HostControllerComponent<?>>
- {
+public class ManagedASDiscovery extends AbstractBaseDiscovery<HostControllerComponent<?>> {
private HostControllerComponent parentComponent;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
index 2075385..848f0e7 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
@@ -97,8 +97,8 @@ public class StandaloneASDiscovery extends BaseProcessDiscovery {
}
@Override
- protected HostPort getManagementPortFromHostXml(String[] commandLine) {
- HostPort managementPort = super.getManagementPortFromHostXml(commandLine);
+ protected HostPort getManagementHostPortFromHostXml(String[] commandLine) {
+ HostPort managementPort = super.getManagementHostPortFromHostXml(commandLine);
if (!managementPort.withOffset) {
managementPort = checkForSocketBindingOffset(managementPort, commandLine);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
index 504be88..9fbe31b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
@@ -49,7 +49,7 @@ public class Address {
}
/**
- * Construct an Addres by cloning another
+ * Construct an Address by cloning another
* @param other Address to clone
*/
public Address(Address other) {
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 47ad52d..cec63da 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
@@ -118,8 +118,7 @@
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000"
displayType="summary" measurementType="trendsup" description="Number of requests sent to the controller"
- displayName="Number of management requests"
- />
+ displayName="Number of management requests"/>
<metric property="_internal:requestTime" category="performance" dataType="measurement" defaultInterval="120000"
displayType="summary" measurementType="trendsup" description="Total time for requests" units="milliseconds"
displayName="Time used for management requests"/>
@@ -424,6 +423,7 @@
</service>
</server>
+
<server name="JBossAS7 Standalone Server"
discovery="StandaloneASDiscovery"
class="StandaloneASComponent"
@@ -495,10 +495,10 @@
displayType="summary" measurementType="dynamic" description="Max time for a request since last metric get" units="milliseconds"
displayName="Maximum request time"/>
- <metric property="server-state" dataType="trait" displayName="Server state" description="Detailed server state"
+ <metric property="server-state" dataType="trait" displayName="Server State" description="Detailed server state"
displayType="summary"/>
&serverKindMetrics;
- <metric property="startTime" dataType="trait" displayName="Start time of the server" defaultOn="true"/>
+ <metric property="startTime" dataType="trait" displayName="Server Start Time" defaultOn="true"/>
<event name="logEntry" description="an entry in a log file"/>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java
index 7c7c70f..243574e 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java
@@ -17,7 +17,7 @@ public class XmlFileReadingTest {
URL url = getClass().getClassLoader().getResource("standalone70.xml");
bd.readStandaloneOrHostXmlFromFile(url.getFile());
- AbstractBaseDiscovery.HostPort hp = bd.getManagementPortFromHostXml(new String[]{});
+ AbstractBaseDiscovery.HostPort hp = bd.getManagementHostPortFromHostXml(new String[]{});
System.out.println(hp);
assert hp.host.equals("127.0.0.70") : "Host is " + hp.host;
assert hp.port==19990 : "Port is " + hp.port;
@@ -29,7 +29,7 @@ public class XmlFileReadingTest {
URL url = getClass().getClassLoader().getResource("standalone71.xml");
bd.readStandaloneOrHostXmlFromFile(url.getFile());
- AbstractBaseDiscovery.HostPort hp = bd.getManagementPortFromHostXml(new String[]{});
+ AbstractBaseDiscovery.HostPort hp = bd.getManagementHostPortFromHostXml(new String[]{});
System.out.println(hp);
// hp : HostPort{host='localhost', port=9990, isLocal=true}
assert hp.host.equals("127.0.0.71") : "Host is " + hp.host;
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
index 5400e57..a4b6123 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
@@ -57,7 +57,7 @@ public class DomainServerComponentTest extends AbstractServerComponentTest {
return "jboss.domain.portOffset";
}
- @Test(priority = 20, groups = "discovery")
+ @Test(priority = 1000, groups = "discovery")
@RunDiscovery
public void testDomainServerDiscovery() throws Exception {
super.testAutoDiscovery();
@@ -65,20 +65,20 @@ public class DomainServerComponentTest extends AbstractServerComponentTest {
// ******************************* METRICS ******************************* //
@Override
- @Test(priority = 21, enabled = true)
+ @Test(priority = 1001, enabled = true)
public void testMetricsHaveNonNullValues() throws Exception {
super.testMetricsHaveNonNullValues();
}
@Override
- @Test(priority = 21, enabled = true)
+ @Test(priority = 1002, enabled = true)
public void testReleaseVersionTrait() throws Exception {
super.testReleaseVersionTrait();
}
// ******************************* OPERATIONS ******************************* //
// TODO: Re-enable this once "shutdown" operation has been fixed.
- @Test(priority = 22, enabled = false)
+ @Test(priority = 1003, enabled = false)
public void testDomainServerShutdownAndStartOperations() throws Exception {
super.testShutdownAndStartOperations();
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
index 0dd5d0c..f7730c8 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
@@ -54,7 +54,7 @@ public class DomainSocketBindingTest extends AbstractJBossAS7PluginTest {
public static final ResourceType RESOURCE_TYPE = new ResourceType("SocketBindingGroup", PLUGIN_NAME, ResourceCategory.SERVICE, null);
private static final String RESOURCE_KEY = "socket-binding-group=standard-sockets";
- @Test(priority = 10,groups = "discovery")
+ @Test(priority = 1010,groups = "discovery")
@RunDiscovery(discoverServices = true, discoverServers = true)
public void runDiscovery() throws Exception {
Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
@@ -68,13 +68,13 @@ public class DomainSocketBindingTest extends AbstractJBossAS7PluginTest {
}
- @Test(priority = 11)
+ @Test(priority = 1011)
public void loadBindings() throws Exception {
loadConfig();
}
- @Test(priority = 11)
+ @Test(priority = 1011)
public void addBinding() throws Exception {
Configuration configuration = loadConfig();
@@ -104,7 +104,7 @@ public class DomainSocketBindingTest extends AbstractJBossAS7PluginTest {
assert pl.getList().size() == count+1 : "Got only " + pl.getList().size() + " items, expected "+ (count+1);
}
- @Test(priority = 11)
+ @Test(priority = 1011)
public void addModifyBinding() throws Exception {
Configuration configuration = loadConfig();
@@ -146,7 +146,7 @@ public class DomainSocketBindingTest extends AbstractJBossAS7PluginTest {
}
- @Test(priority = 11)
+ @Test(priority = 1011)
public void addRemoveBinding() throws Exception {
Configuration configuration = loadConfig();
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
index 99f8347..279efdf 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
@@ -56,13 +56,13 @@ public class SocketBindingTest extends AbstractJBossAS7PluginTest {
private static final String RESOURCE_KEY = "socket-binding-group=standard-sockets";
@Test(priority = 10,groups = "discovery")
- @RunDiscovery(discoverServices = true, discoverServers = true) public void doSomeDiscovery() throws Exception {
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void doSomeDiscovery() throws Exception {
Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
assertNotNull(platform);
assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
Thread.sleep(20*1000L); // delay so that PC gets a chance to scan for resources
-
}
@Test(priority = 11)
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
index a221a27..9bd1d56 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
@@ -64,7 +64,7 @@ public class StandaloneServerComponentTest extends AbstractServerComponentTest {
return "jboss.standalone.portOffset";
}
- @Test(priority = 10, groups = "discovery")
+ @Test(priority = 1, groups = "discovery")
@RunDiscovery
public void testStandaloneServerDiscovery() throws Exception {
super.testAutoDiscovery();
@@ -72,31 +72,31 @@ public class StandaloneServerComponentTest extends AbstractServerComponentTest {
// ******************************* METRICS ******************************* //
@Override
- @Test(priority = 11, enabled = true)
+ @Test(priority = 2, enabled = true)
public void testMetricsHaveNonNullValues() throws Exception {
super.testMetricsHaveNonNullValues();
}
@Override
- @Test(priority = 11, enabled = true)
+ @Test(priority = 3, enabled = true)
public void testReleaseVersionTrait() throws Exception {
super.testReleaseVersionTrait();
}
// ******************************* OPERATIONS ******************************* //
- @Test(priority = 12)
+ @Test(priority = 4)
public void testReloadOperation() throws Exception {
invokeOperationAndAssertSuccess(getServerResource(), RELOAD_OPERATION_NAME, null);
}
// TODO: Re-enable this once "shutdown" operation has been fixed.
- @Test(priority = 13, enabled = false)
+ @Test(priority = 5, enabled = false)
public void testStandaloneServerShutdownAndStartOperations() throws Exception {
super.testShutdownAndStartOperations();
}
// TODO: Re-enable once fixed.
- @Test(priority = 13, dependsOnMethods = "testStandaloneServerShutdownAndStartOperations", enabled = false)
+ @Test(priority = 5, dependsOnMethods = "testStandaloneServerShutdownAndStartOperations", enabled = false)
public void testRestartOperation() throws Exception {
AvailabilityType avail = getAvailability(getServerResource());
assertEquals(avail, AvailabilityType.UP);
commit bc36e3a0e0596c527c6c272901453edcefcd3f97
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 09:51:54 2012 -0400
use longs, not ints, for timeout vars
diff --git a/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java b/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
index 8a28883..05e1578 100644
--- a/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
+++ b/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
@@ -151,7 +151,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
protected AvailabilityType getAvailability(Resource resource)
throws PluginContainerException {
ResourceContainer resourceContainer = this.pluginContainer.getInventoryManager().getResourceContainer(resource);
- int timeoutMillis = 5000;
+ long timeoutMillis = 5000;
AvailabilityFacet availFacet = resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
FacetLockType.READ, timeoutMillis, false, false);
AvailabilityType avail;
@@ -292,7 +292,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
+ "] is defined for ResourceType {" + resourceType.getPlugin() + "}" + resourceType.getName() + ".");
ResourceContainer resourceContainer = this.pluginContainer.getInventoryManager().getResourceContainer(resource);
- int timeoutMillis = 7000;
+ long timeoutMillis = 5000;
MeasurementFacet measurementFacet = resourceContainer.createResourceComponentProxy(MeasurementFacet.class,
FacetLockType.READ, timeoutMillis, false, false);
MeasurementReport report = new MeasurementReport();
commit 398398905dbe479a06866ce4834fb0e8f7413b8c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Mar 29 16:41:34 2012 -0400
don't attempt to do any yum stuff if the internal yum server is disabled
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java
index 38833eb..1f336fa 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2012 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -57,6 +57,7 @@ import org.rhq.plugins.platform.content.yum.YumProxy;
import org.rhq.plugins.platform.content.yum.YumServer;
public class LinuxPlatformComponent extends PosixPlatformComponent implements ContentFacet {
+
// the prefix for all distro trait names
private static final String DISTRO_TRAIT_NAME_PREFIX = "distro.";
@@ -66,15 +67,12 @@ public class LinuxPlatformComponent extends PosixPlatformComponent implements Co
private final Log log = LogFactory.getLog(LinuxPlatformComponent.class);
- private ContentContext contentContext;
-
- private YumServer yumServer = new YumServer();
- private YumProxy yumProxy = new YumProxy();
+ private YumServer yumServer;
+ private YumProxy yumProxy;
private boolean enableContentDiscovery = false;
private boolean enableInternalYumServer = false;
-
@Override
public void start(ResourceContext context) {
super.start(context);
@@ -106,17 +104,17 @@ public class LinuxPlatformComponent extends PosixPlatformComponent implements Co
startWithContentContext(context.getContentContext());
-
return;
}
@Override
public void stop() {
-
- try {
- yumServer.halt();
- } catch (Exception e) {
- log.warn("Failed to shutdown the yum server", e);
+ if (yumServer != null) {
+ try {
+ yumServer.halt();
+ } catch (Exception e) {
+ log.warn("Failed to shutdown the yum server.", e);
+ }
}
super.stop();
@@ -124,17 +122,18 @@ public class LinuxPlatformComponent extends PosixPlatformComponent implements Co
private void startWithContentContext(ContentContext context) {
if (this.enableInternalYumServer) {
+ yumServer = new YumServer();
+ yumProxy = new YumProxy();
+
int port = yumPort();
log.debug("yum port=[" + port + "]");
- this.contentContext = context;
try {
YumContext yumContext = new PluginContext(port, this.resourceContext, context);
yumServer.start(yumContext);
yumProxy.init(this.resourceContext);
-
} catch (Exception e) {
- log.error("Start failed:", e);
+ log.error("Failed to start yum server.", e);
}
} else {
log.info("Internal yum server is disabled.");
@@ -163,6 +162,10 @@ public class LinuxPlatformComponent extends PosixPlatformComponent implements Co
}
public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages, ContentServices contentServices) {
+ if (!this.enableInternalYumServer) {
+ throw new UnsupportedOperationException("Internal yum server is disabled - this operation is a no-op.");
+ }
+
try {
DeployPackagesResponse result = new DeployPackagesResponse(ContentResponseResult.SUCCESS);
List<String> pkgs = new ArrayList<String>();
@@ -188,6 +191,10 @@ public class LinuxPlatformComponent extends PosixPlatformComponent implements Co
}
public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) {
+ if (!this.enableInternalYumServer) {
+ throw new UnsupportedOperationException("Internal yum server is disabled - this operation is a no-op.");
+ }
+
try {
RemovePackagesResponse result = new RemovePackagesResponse(ContentResponseResult.SUCCESS);
List<String> pkgs = new ArrayList<String>();
@@ -223,14 +230,13 @@ public class LinuxPlatformComponent extends PosixPlatformComponent implements Co
@Override
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
if ("cleanYumMetadataCache".equals(name)) {
- if (this.yumServer.isStarted()) {
- log.info("Cleaning yum metadata");
- yumServer.cleanMetadata();
- yumProxy.cleanMetadata();
- return new OperationResult();
- } else {
- throw new UnsupportedOperationException("Internal yum server is disabled, this operation is a no-op");
+ if (!this.enableInternalYumServer) {
+ throw new UnsupportedOperationException("Internal yum server is disabled - this operation is a no-op.");
}
+ log.info("Cleaning yum metadata...");
+ yumServer.cleanMetadata();
+ yumProxy.cleanMetadata();
+ return new OperationResult();
}
return super.invokeOperation(name, parameters);
@@ -253,4 +259,5 @@ public class LinuxPlatformComponent extends PosixPlatformComponent implements Co
PropertySimple p = this.resourceContext.getPluginConfiguration().getSimple("yumPort");
return ((p != null) ? p.getIntegerValue() : 9080);
}
+
}
\ No newline at end of file
11 years, 8 months
[rhq] 4 commits - etc/m2 modules/core modules/enterprise
by mazz
etc/m2/settings.xml | 4
modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java | 1
modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java | 2
modules/core/dbutils/src/main/java/org/rhq/core/db/H2DatabaseType.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/server/EntitySerializer.java | 296 +++++
modules/core/domain/src/main/java/org/rhq/core/domain/server/ExternalizableStrategy.java | 64 +
modules/core/domain/src/main/java/org/rhq/core/domain/server/H2CustomDialect.java | 45
modules/core/domain/src/main/java/org/rhq/core/domain/server/PersistenceUtility.java | 563 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java | 2
modules/core/domain/src/main/java/org/rhq/core/server/EntitySerializer.java | 296 -----
modules/core/domain/src/main/java/org/rhq/core/server/ExternalizableStrategy.java | 64 -
modules/core/domain/src/main/java/org/rhq/core/server/H2CustomDialect.java | 45
modules/core/domain/src/main/java/org/rhq/core/server/PersistenceUtility.java | 563 ----------
modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java | 2
modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java | 552 ---------
modules/core/util/src/main/java/org/rhq/core/util/StringUtil.java | 552 +++++++++
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/ExternalizableStrategyCommandPreprocessor.java | 2
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml | 1
modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/ExternalizableStrategyCommandListener.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/StatisticsUtility.java | 2
modules/enterprise/gui/portal-war/src/main/webapp/admin/test/browser.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/admin/test/hibernate.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp | 2
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/clientapi/RemoteClientProxy.java | 2
modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/agentclient/impl/AgentClientImpl.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/AffinityGroupManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/PartitionEventManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteWsInvocationHandler.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/AlertSubsystemManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/ConfigurationSubsystemManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/OperationHistorySubsystemManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/CoreTestBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/DiscoveryTestBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java | 108 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 2
89 files changed, 1674 insertions(+), 1636 deletions(-)
New commits:
commit 6777c10c3d2d8e0c39e03b1c9ecfbdf69eb2b8ea
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 30 14:57:58 2012 -0400
put the test methods in another, unique, group - trying to get testng to work the way we want
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
index 34c247e..b4fdf46 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
@@ -52,7 +52,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
- @Test(groups = { "plugin.metadata", "NewPlugin" })
+ @Test(groups = { "plugin.resource.metadata.test", "plugin.metadata", "NewPlugin" })
public void testRemovalOfObsoleteBundleAndDriftConfig() throws Exception {
// create the initial type that has bundle and drift definitions
createPlugin("test-plugin.jar", "1.0", "remove_bundle_drift_config_v1.xml");
@@ -107,7 +107,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(groups = { "plugin.metadata", "NewPlugin" })
+ @Test(groups = { "plugin.resource.metadata.test", "plugin.metadata", "NewPlugin" })
public void registerPluginWithDuplicateDriftDefinitions() {
try {
createPlugin("test-plugin.jar", "1.0", "dup_drift.xml");
@@ -117,19 +117,20 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "registerPluginWithDuplicateDriftDefinitions" }, groups = { "plugin.metadata",
- "NewPlugin" })
+ @Test(dependsOnMethods = { "registerPluginWithDuplicateDriftDefinitions" }, groups = {
+ "plugin.resource.metadata.test", "plugin.metadata", "NewPlugin" })
public void registerPlugin() throws Exception {
createPlugin("test-plugin.jar", "1.0", "plugin_v1.xml");
}
- @Test(dependsOnMethods = { "registerPlugin" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "registerPlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistNewTypes() {
List<String> newTypes = asList("ServerA", "ServerB");
assertTypesPersisted("Failed to persist new types", newTypes, "TestPlugin");
}
- // @Test(dependsOnMethods = {"persistNewTypes"}, groups = {"plugin.metadata", "NewPlugin"})
+ // @Test(dependsOnMethods = {"persistNewTypes"}, groups = {"plugin.resource.metadata.test", "plugin.metadata", "NewPlugin"})
// public void persistSubcategories() throws Exception {
// assertResourceTypeAssociationEquals(
// "ServerA",
@@ -139,29 +140,34 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
// );
// }
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistMeasurementDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "metricDefinitions",
asList("metric1", "metric2", "rhq.availability"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistEventDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "eventDefinitions",
asList("logAEntry", "logBEntry"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistOperationDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "operationDefinitions", asList("start", "stop"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistProcessScans() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "processScans", asList("serverA"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistDriftDefinitionTemplates() throws Exception {
ResourceType type = assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "driftDefinitionTemplates",
asList("drift-pc", "drift-fs"));
@@ -200,7 +206,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistBundleTargetConfigurations() throws Exception {
String resourceTypeName = "ServerA";
String plugin = "TestPlugin";
@@ -235,55 +242,64 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistChildTypes() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "childResourceTypes", asList("Child1", "Child2"));
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistPluginConfigurationDefinition() throws Exception {
assertAssociationExists("ServerA", "pluginConfigurationDefinition");
}
- @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.metadata", "NewPlugin" })
+ @Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "NewPlugin" })
public void persistPackageTypes() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "packageTypes",
asList("ServerA.Content.1", "ServerA.Content.2"));
}
- @Test(groups = { "plugin.metadata", "UpgradePlugin" }, dependsOnGroups = { "NewPlugin" })
+ @Test(groups = { "plugin.resource.metadata.test", "plugin.metadata", "UpgradePlugin" }, dependsOnGroups = { "NewPlugin" })
public void upgradePlugin() throws Exception {
createPlugin("test-plugin.jar", "2.0", "plugin_v2.xml");
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeOperationDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "operationDefinitions",
asList("start", "shutdown", "restart"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeChildResources() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "childResourceTypes", asList("Child1", "Child3"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeParentTypeOfChild() throws Exception {
assertResourceTypeAssociationEquals("ServerB", "TestPlugin", "childResourceTypes", asList("Child2"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeEventDefinitions() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "eventDefinitions",
asList("logAEntry", "logCEntry"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeProcessScans() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "processScans", asList("processA", "processB"));
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeDriftDefinitionTemplates() throws Exception {
ResourceType type = assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "driftDefinitionTemplates",
asList("drift-rc", "drift-mt"));
@@ -313,7 +329,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradeBundleTargetConfigurations() throws Exception {
String resourceTypeName = "ServerA";
String plugin = "TestPlugin";
@@ -348,7 +365,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.metadata", "UpgradePlugin" })
+ @Test(dependsOnMethods = { "upgradePlugin" }, groups = { "plugin.resource.metadata.test", "plugin.metadata",
+ "UpgradePlugin" })
public void upgradePackageTypes() throws Exception {
assertResourceTypeAssociationEquals("ServerA", "TestPlugin", "packageTypes",
asList("ServerA.Content.1", "ServerA.Content.3"));
@@ -367,7 +385,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
createPlugin("remove-types-plugin", "2.0", "remove_types_v2.xml");
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteOperationDefsForRemovedType() throws Exception {
OperationManagerLocal operationMgr = LookupUtil.getOperationManager();
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
@@ -382,7 +401,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The operation definition should have been deleted", 0, operationDefs.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteEventDefsForRemovedType() throws Exception {
List<?> results = getEntityManager()
.createQuery("from EventDefinition e where e.name = :ename and e.resourceType.name = :rname")
@@ -391,7 +411,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The event definition(s) should have been deleted", 0, results.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteParent() throws Exception {
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
ResourceTypeManagerLocal resourceTypeMgr = LookupUtil.getResourceTypeManager();
@@ -424,7 +445,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
return null;
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteTypeAndAllItsDescedantTypes() throws Exception {
List<?> typesNotRemoved = getEntityManager()
.createQuery("from ResourceType t where t.plugin = :plugin and t.name in (:resourceTypes)")
@@ -435,7 +457,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("Failed to delete resource type or one or more of its descendant types", 0, typesNotRemoved.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteProcessScans() {
List<?> processScans = getEntityManager()
.createQuery("from ProcessScan p where p.name = :name1 or p.name = :name2").setParameter("name1", "scan1")
@@ -444,7 +467,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The process scans should have been deleted", 0, processScans.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteSubcategories() {
List<?> subcategories = getEntityManager()
.createQuery("from ResourceSubCategory r where r.name = :name1 or r.name = :name2 or r.name = :name3")
@@ -453,7 +477,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The subcategories should have been deleted", 0, subcategories.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteResources() {
ResourceManagerLocal resourceMgr = LookupUtil.getResourceManager();
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
@@ -478,7 +503,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
}
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteBundles() {
List<?> bundles = getEntityManager().createQuery("from Bundle b where b.bundleType.name = :name")
.setParameter("name", "Test Bundle").getResultList();
@@ -486,7 +512,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("Failed to delete the bundles", 0, bundles.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteBundleTypes() {
List<?> bundleTypes = getEntityManager().createQuery("from BundleType b where b.name = :name")
.setParameter("name", "Test Bundle").getResultList();
@@ -494,7 +521,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("The bundle type should have been deleted", 0, bundleTypes.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deletePackages() {
List<?> packages = getEntityManager().createQuery("from Package p where p.name = :name")
.setParameter("name", "ServerC::test-package").getResultList();
@@ -502,7 +530,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("All packages should have been deleted", 0, packages.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deletePackageTypes() {
List<?> packageTypes = getEntityManager().createQuery("from PackageType p where p.name = :name")
.setParameter("name", "ServerC.Content").getResultList();
@@ -510,7 +539,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("All package types should have been deleted", 0, packageTypes.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteResourceGroups() {
List<?> groups = getEntityManager()
.createQuery("from ResourceGroup g where g.name = :name and g.resourceType.name = :typeName")
@@ -519,7 +549,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("All resource groups should have been deleted", 0, groups.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteAlertTemplates() {
List<?> templates = getEntityManager()
.createQuery("from AlertDefinition a where a.name = :name and a.resourceType.name = :typeName")
@@ -528,7 +559,8 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
assertEquals("Alert templates should have been deleted.", 0, templates.size());
}
- @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.metadata", "RemoveTypes" })
+ @Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
+ "plugin.metadata", "RemoveTypes" })
public void deleteMeasurementDefinitions() {
List<?> measurementDefs = getEntityManager().createQuery("from MeasurementDefinition m where m.name = :name")
.setParameter("name", "ServerC::metric1").getResultList();
commit bb92f0d2bf0ab28e71c775b8b3abef3adc5ff864
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 30 14:57:09 2012 -0400
[BZ 759615] remove the last duplicate package across multiple jars
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java
index cf31a5f..183f8d5 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/TimeUtil.java
@@ -31,6 +31,7 @@ import org.rhq.core.clientapi.util.units.ScaleConstants;
import org.rhq.core.clientapi.util.units.UnitNumber;
import org.rhq.core.clientapi.util.units.UnitsConstants;
import org.rhq.core.clientapi.util.units.UnitsFormat;
+import org.rhq.core.util.StringUtil;
public class TimeUtil {
public static final String DATE_FORMAT = "MM-dd-yy-HH-mm-ss";
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java
index 9e9e4de..98c90aa 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/util/units/DurationFormatter.java
@@ -27,7 +27,7 @@ import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
import org.rhq.core.clientapi.util.ArrayUtil;
-import org.rhq.core.clientapi.util.StringUtil;
+import org.rhq.core.util.StringUtil;
/**
* Format a value into a duration.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java
index d8ce6d5..5828a04 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationServicesAdapter.java
@@ -26,7 +26,6 @@ import java.util.HashMap;
import java.util.Map;
import org.rhq.core.clientapi.server.operation.OperationServerService;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.operation.OperationDefinition;
@@ -34,6 +33,7 @@ import org.rhq.core.pluginapi.operation.OperationContext;
import org.rhq.core.pluginapi.operation.OperationServices;
import org.rhq.core.pluginapi.operation.OperationServicesResult;
import org.rhq.core.pluginapi.operation.OperationServicesResultCode;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ExceptionPackage;
/**
diff --git a/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java b/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java
deleted file mode 100644
index ecfed35..0000000
--- a/modules/core/util/src/main/java/org/rhq/core/clientapi/util/StringUtil.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * 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.clientapi.util;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class StringUtil {
-
- private static final Log log = LogFactory.getLog(StringUtil.class);
-
- /**
- * @param source The source string to perform replacements on.
- * @param find The substring to find in source.
- * @param replace The string to replace 'find' within source
- *
- * @return The source string, with all occurrences of 'find' replaced with 'replace'
- */
- public static String replace(String source, String find, String replace) {
- if ((source == null) || (find == null) || (replace == null)) {
- return source;
- }
-
- int sourceLen = source.length();
- int findLen = find.length();
- if ((sourceLen == 0) || (findLen == 0)) {
- return source;
- }
-
- StringBuilder buffer = new StringBuilder();
-
- int idx;
- int fromIndex;
-
- for (fromIndex = 0; (idx = source.indexOf(find, fromIndex)) != -1; fromIndex = idx + findLen) {
- buffer.append(source.substring(fromIndex, idx));
- buffer.append(replace);
- }
-
- if (fromIndex == 0) {
- return source;
- }
-
- buffer.append(source.substring(fromIndex));
-
- return buffer.toString();
- }
-
- /**
- * @param source The source string to perform replacements on.
- * @param find The substring to find in source.
- *
- * @return The source string, with all occurrences of 'find' removed
- */
- public static String remove(String source, String find) {
- if ((source == null) || (find == null)) {
- return source;
- }
-
- String retVal = null;
- int sourceLen = source.length();
- int findLen = find.length();
- StringBuilder remove = new StringBuilder(source);
-
- try {
- if ((sourceLen > 0) && (findLen > 0)) {
- int fromIndex;
- int idx;
-
- for (fromIndex = 0, idx = 0; (fromIndex = source.indexOf(find, idx)) != -1; idx = fromIndex + findLen) {
- remove.delete(fromIndex, findLen + fromIndex);
- }
-
- retVal = remove.toString();
- }
- } catch (Exception e) {
- log.error("This should not have happened.", e);
- retVal = null;
- }
-
- return retVal;
- }
-
- /**
- * Print out everything in an Iterator in a user-friendly string format.
- *
- * @param i An iterator to print out.
- * @param delim The delimiter to use between elements.
- *
- * @return The Iterator's elements in a user-friendly string format.
- */
- public static String iteratorToString(Iterator i, String delim) {
- return iteratorToString(i, delim, "");
- }
-
- /**
- * Print out everything in an Iterator in a user-friendly string format.
- *
- * @param i An iterator to print out.
- * @param delim The delimiter to use between elements.
- * @param quoteChar The character to quote each element with.
- *
- * @return The Iterator's elements in a user-friendly string format.
- */
- public static String iteratorToString(Iterator i, String delim, String quoteChar) {
- Object elt = null;
- StringBuilder rstr = new StringBuilder();
- String s;
-
- while (i.hasNext()) {
- if (rstr.length() > 0) {
- rstr.append(delim);
- }
-
- elt = i.next();
- if (elt == null) {
- rstr.append("NULL");
- } else {
- s = elt.toString();
- if (quoteChar != null) {
- rstr.append(quoteChar).append(s).append(quoteChar);
- } else {
- rstr.append(s);
- }
- }
- }
-
- return rstr.toString();
- }
-
- /**
- * Print out a List in a user-friendly string format.
- *
- * @param list A List to print out.
- * @param delim The delimiter to use between elements.
- *
- * @return The List in a user-friendly string format.
- */
- public static String listToString(List list, String delim) {
- if (list == null) {
- return "NULL";
- }
-
- Iterator i = list.iterator();
- return iteratorToString(i, delim, null);
- }
-
- public static String collectionToString(Collection collection, String delim) {
- if (collection == null) {
- return "NULL";
- }
-
- Iterator i = collection.iterator();
- return iteratorToString(i, delim, null);
- }
-
- /**
- * Print out a List in a user-friendly string format.
- *
- * @param list A List to print out.
- *
- * @return The List in a user-friendly string format.
- */
- public static String listToString(List list) {
- return listToString(list, ",");
- }
-
- public static String collectionToString(Collection collection) {
- return collectionToString(collection, ",");
- }
-
- /**
- * Print out an array as a String
- */
- public static String arrayToString(Object[] array) {
- return arrayToString(array, ',');
- }
-
- /**
- * Print out an array as a String
- */
- public static String arrayToString(boolean[] array) {
- if (array == null) {
- return "null";
- }
-
- String rstr = "";
- char delim = ',';
- for (int i = 0; i < array.length; i++) {
- if (i > 0) {
- rstr += delim;
- }
-
- rstr += array[i];
- }
-
- return rstr;
- }
-
- /**
- * Print out an array as a String
- *
- * @param array The array to print out
- * @param delim The delimiter to use between elements.
- */
- public static String arrayToString(Object[] array, char delim) {
- if (array == null) {
- return "null";
- }
-
- StringBuilder rstr = new StringBuilder();
- for (int i = 0; i < array.length; i++) {
- if (i > 0) {
- rstr.append(delim);
- }
-
- rstr.append(array[i]);
- }
-
- return rstr.toString();
- }
-
- /**
- * Print out an array as a String
- */
- public static String arrayToString(int[] array) {
- if (array == null) {
- return "null";
- }
-
- StringBuilder rstr = new StringBuilder();
- for (int i = 0; i < array.length; i++) {
- if (i > 0) {
- rstr.append(",");
- }
-
- rstr.append(array[i]);
- }
-
- return rstr.toString();
- }
-
- /**
- * Create a string formulated by inserting a delimiter in between consecutive array elements.
- *
- * @param objs List of objects to implode (elements may not be null)
- * @param delim String to place inbetween elements
- *
- * @return A string with objects in the list seperated by delim
- */
- public static String implode(List objs, String delim) {
- StringBuilder buf = new StringBuilder();
- int size = objs.size();
-
- for (int i = 0; i < (size - 1); i++) {
- buf.append(objs.get(i).toString());
- buf.append( delim);
- }
-
- if (size != 0) {
- buf.append(objs.get(size - 1).toString());
- }
-
- return buf.toString();
- }
-
- /**
- * Split a string on delimiter boundaries, and place each element into a List.
- *
- * @param s String to split up
- * @param delim Delimiting token, ala StringTokenizer
- *
- * @return a List comprised of elements split by the tokenizing
- */
-
- public static List<String> explode(String s, String delim) {
- List<String> res = new ArrayList<String>();
- if (s == null)
- return res;
-
- StringTokenizer tok = new StringTokenizer(s, delim);
-
- while (tok.hasMoreTokens()) {
- res.add(tok.nextToken());
- }
-
- return res;
- }
-
- /**
- * Split a string on delimiter boundaries, and place each element into an Array.
- *
- * @param toExplode String to split up
- * @param delim Delimiting token, ala StringTokenizer
- *
- * @return an Array comprised of elements split by the tokenizing
- */
- public static String[] explodeToArray(String toExplode, String delim) {
- List<String> strings = explode(toExplode, delim);
- String[] ret;
- ret = strings.toArray(new String[strings.size()]);
- return ret;
- }
-
- /**
- * Split a string up by whitespace, taking into account quoted subcomponents. If there is an uneven number of
- * quotes, a parse error will be thrown.
- *
- * @param arg String to parse
- *
- * @return an array of elements, the argument was split into
- *
- * @throws IllegalArgumentException indicating there was a quoting error
- */
-
- public static String[] explodeQuoted(String arg) throws IllegalArgumentException {
- List<String> res = new ArrayList<String>();
- StringTokenizer quoteTok;
- boolean inQuote = false;
-
- arg = arg.trim();
- quoteTok = new StringTokenizer(arg, "\"", true);
-
- while (quoteTok.hasMoreTokens()) {
- String elem = (String) quoteTok.nextElement();
-
- if (elem.equals("\"")) {
- inQuote = !inQuote;
- continue;
- }
-
- if (inQuote) {
- res.add(elem);
- } else {
- StringTokenizer spaceTok = new StringTokenizer(elem.trim());
-
- while (spaceTok.hasMoreTokens()) {
- res.add(spaceTok.nextToken());
- }
- }
- }
-
- if (inQuote) {
- throw new IllegalArgumentException("Unbalanced quotation marks");
- }
-
- return res.toArray(new String[res.size()]);
- }
-
- /**
- * Remove a prefix from a string. If value starts with prefix, it will be removed, the resultant string is trimmed
- * and returned.
- *
- * @return If value starts with prefix, then this method returns value with the prefix removed, and the resultant
- * string trimmed. If value does not start with prefix, value is returned as-is.
- */
- public static String removePrefix(String value, String prefix) {
- if (!value.startsWith(prefix)) {
- return value;
- }
-
- return value.substring(prefix.length()).trim();
- }
-
- /**
- * @return the plural of word. This is done by applying a few rules. These cover most (but not all) cases: 1. If the
- * word ends in s, ss, x, o, or ch, append es 2. If the word ends in a consonant followed by y, drop the y
- * and add ies 3. Append an s and call it a day. The ultimate references is at
- * http://en.wikipedia.org/wiki/English_plural
- */
- public static String pluralize(String word) {
- if (word.endsWith("s") || word.endsWith("x") || word.endsWith("o") || word.endsWith("ch")) {
- return word + "es";
- }
-
- if (word.endsWith("y")) {
- // Odd case to avoid StringIndexOutOfBounds later
- if (word.length() == 1) {
- return word;
- }
-
- // Check next-to-last letter
- char next2last = word.charAt(word.length() - 2);
- if ((next2last != 'a') && (next2last != 'e') && (next2last != 'i') && (next2last != 'o')
- && (next2last != 'u') && (next2last != 'y')) {
- return word.substring(0, word.length() - 1) + "ies";
- }
- }
-
- return word + "s";
- }
-
- /**
- * @return The stack trace for the given Throwable as a String.
- */
- public static String getStackTrace(Throwable t) {
- if (t == null) {
- return "THROWABLE-WAS-NULL (at " + getStackTrace(new Exception()) + ")";
- }
-
- try {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
-
- t.printStackTrace(pw);
-
- Throwable cause = t.getCause();
- if (cause != null) {
- return sw.toString() + getStackTrace(cause);
- }
-
- return sw.toString();
- } catch (Exception e) {
- return "\n\nStringUtil.getStackTrace " + "GENERATED EXCEPTION: '" + e.toString() + "' \n\n";
- }
- }
-
- /**
- * @return The stack trace for the given Throwable as a String.
- */
- public static String getFirstStackTrace(Throwable t) {
- if (t == null) {
- return null;
- }
-
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- t.printStackTrace(pw);
-
- return sw.toString();
- }
-
- /**
- * @param s A string that might contain unix-style path separators.
- *
- * @return The correct path for this platform (i.e, if win32, replace / with \).
- */
- public static String normalizePath(String s) {
- return StringUtil.replace(s, "/", File.separator);
- }
-
- public static String formatDuration(long duration) {
- return formatDuration(duration, 0, false);
- }
-
- public static String formatDuration(long duration, int scale, boolean minDigits) {
- long hours;
- long mins;
- int digits;
- double millis;
-
- hours = duration / 3600000;
- duration -= hours * 3600000;
-
- mins = duration / 60000;
- duration -= mins * 60000;
-
- millis = (double) duration / 1000;
-
- StringBuilder buf = new StringBuilder();
-
- if ((hours > 0) || (minDigits == false)) {
- buf.append(((hours < 10) && (minDigits == false)) ? ("0" + hours) : String.valueOf(hours)).append(':');
- minDigits = false;
- }
-
- if ((mins > 0) || (minDigits == false)) {
- buf.append(((mins < 10) && (minDigits == false)) ? ("0" + mins) : String.valueOf(mins)).append(':');
- minDigits = false;
- }
-
- // Format seconds and milliseconds
- NumberFormat fmt = NumberFormat.getInstance();
- digits = (((minDigits == false) || ((scale == 0) && (millis >= 9.5))) ? 2 : 1);
- fmt.setMinimumIntegerDigits(digits);
- fmt.setMaximumIntegerDigits(2); // Max of 2
- fmt.setMinimumFractionDigits(0); // Don't need any
- fmt.setMaximumFractionDigits(scale);
-
- buf.append(fmt.format(millis));
-
- return buf.toString();
- }
-
- public static String repeatChars(char c, int nTimes) {
- char[] arr = new char[nTimes];
-
- for (int i = 0; i < nTimes; i++) {
- arr[i] = c;
- }
-
- return new String(arr);
- }
-
- /**
- * Capitalizes the first letter of str.
- *
- * @param str The string to capitalize.
- *
- * @return A new string that is <code>str</code> capitalized. Returns <code>null</code> if str is null.
- */
- public static String capitalize(String str) {
- if (str == null) {
- return null;
- } else if (str.trim().equals("")) {
- return str;
- }
-
- String result = str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
-
- return result;
- }
-
- public static String truncate(String s, int truncLength, boolean removeWhiteSpace) {
- String temp = ((s.length() > truncLength) ? (s.substring(0, truncLength) + "...") : s);
- if (removeWhiteSpace) {
- temp = temp.replaceAll("\\s+", " ");
- }
-
- return temp;
- }
-}
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/StringUtil.java b/modules/core/util/src/main/java/org/rhq/core/util/StringUtil.java
new file mode 100644
index 0000000..7944bbd
--- /dev/null
+++ b/modules/core/util/src/main/java/org/rhq/core/util/StringUtil.java
@@ -0,0 +1,552 @@
+/*
+ * 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.util;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class StringUtil {
+
+ private static final Log log = LogFactory.getLog(StringUtil.class);
+
+ /**
+ * @param source The source string to perform replacements on.
+ * @param find The substring to find in source.
+ * @param replace The string to replace 'find' within source
+ *
+ * @return The source string, with all occurrences of 'find' replaced with 'replace'
+ */
+ public static String replace(String source, String find, String replace) {
+ if ((source == null) || (find == null) || (replace == null)) {
+ return source;
+ }
+
+ int sourceLen = source.length();
+ int findLen = find.length();
+ if ((sourceLen == 0) || (findLen == 0)) {
+ return source;
+ }
+
+ StringBuilder buffer = new StringBuilder();
+
+ int idx;
+ int fromIndex;
+
+ for (fromIndex = 0; (idx = source.indexOf(find, fromIndex)) != -1; fromIndex = idx + findLen) {
+ buffer.append(source.substring(fromIndex, idx));
+ buffer.append(replace);
+ }
+
+ if (fromIndex == 0) {
+ return source;
+ }
+
+ buffer.append(source.substring(fromIndex));
+
+ return buffer.toString();
+ }
+
+ /**
+ * @param source The source string to perform replacements on.
+ * @param find The substring to find in source.
+ *
+ * @return The source string, with all occurrences of 'find' removed
+ */
+ public static String remove(String source, String find) {
+ if ((source == null) || (find == null)) {
+ return source;
+ }
+
+ String retVal = null;
+ int sourceLen = source.length();
+ int findLen = find.length();
+ StringBuilder remove = new StringBuilder(source);
+
+ try {
+ if ((sourceLen > 0) && (findLen > 0)) {
+ int fromIndex;
+ int idx;
+
+ for (fromIndex = 0, idx = 0; (fromIndex = source.indexOf(find, idx)) != -1; idx = fromIndex + findLen) {
+ remove.delete(fromIndex, findLen + fromIndex);
+ }
+
+ retVal = remove.toString();
+ }
+ } catch (Exception e) {
+ log.error("This should not have happened.", e);
+ retVal = null;
+ }
+
+ return retVal;
+ }
+
+ /**
+ * Print out everything in an Iterator in a user-friendly string format.
+ *
+ * @param i An iterator to print out.
+ * @param delim The delimiter to use between elements.
+ *
+ * @return The Iterator's elements in a user-friendly string format.
+ */
+ public static String iteratorToString(Iterator i, String delim) {
+ return iteratorToString(i, delim, "");
+ }
+
+ /**
+ * Print out everything in an Iterator in a user-friendly string format.
+ *
+ * @param i An iterator to print out.
+ * @param delim The delimiter to use between elements.
+ * @param quoteChar The character to quote each element with.
+ *
+ * @return The Iterator's elements in a user-friendly string format.
+ */
+ public static String iteratorToString(Iterator i, String delim, String quoteChar) {
+ Object elt = null;
+ StringBuilder rstr = new StringBuilder();
+ String s;
+
+ while (i.hasNext()) {
+ if (rstr.length() > 0) {
+ rstr.append(delim);
+ }
+
+ elt = i.next();
+ if (elt == null) {
+ rstr.append("NULL");
+ } else {
+ s = elt.toString();
+ if (quoteChar != null) {
+ rstr.append(quoteChar).append(s).append(quoteChar);
+ } else {
+ rstr.append(s);
+ }
+ }
+ }
+
+ return rstr.toString();
+ }
+
+ /**
+ * Print out a List in a user-friendly string format.
+ *
+ * @param list A List to print out.
+ * @param delim The delimiter to use between elements.
+ *
+ * @return The List in a user-friendly string format.
+ */
+ public static String listToString(List list, String delim) {
+ if (list == null) {
+ return "NULL";
+ }
+
+ Iterator i = list.iterator();
+ return iteratorToString(i, delim, null);
+ }
+
+ public static String collectionToString(Collection collection, String delim) {
+ if (collection == null) {
+ return "NULL";
+ }
+
+ Iterator i = collection.iterator();
+ return iteratorToString(i, delim, null);
+ }
+
+ /**
+ * Print out a List in a user-friendly string format.
+ *
+ * @param list A List to print out.
+ *
+ * @return The List in a user-friendly string format.
+ */
+ public static String listToString(List list) {
+ return listToString(list, ",");
+ }
+
+ public static String collectionToString(Collection collection) {
+ return collectionToString(collection, ",");
+ }
+
+ /**
+ * Print out an array as a String
+ */
+ public static String arrayToString(Object[] array) {
+ return arrayToString(array, ',');
+ }
+
+ /**
+ * Print out an array as a String
+ */
+ public static String arrayToString(boolean[] array) {
+ if (array == null) {
+ return "null";
+ }
+
+ String rstr = "";
+ char delim = ',';
+ for (int i = 0; i < array.length; i++) {
+ if (i > 0) {
+ rstr += delim;
+ }
+
+ rstr += array[i];
+ }
+
+ return rstr;
+ }
+
+ /**
+ * Print out an array as a String
+ *
+ * @param array The array to print out
+ * @param delim The delimiter to use between elements.
+ */
+ public static String arrayToString(Object[] array, char delim) {
+ if (array == null) {
+ return "null";
+ }
+
+ StringBuilder rstr = new StringBuilder();
+ for (int i = 0; i < array.length; i++) {
+ if (i > 0) {
+ rstr.append(delim);
+ }
+
+ rstr.append(array[i]);
+ }
+
+ return rstr.toString();
+ }
+
+ /**
+ * Print out an array as a String
+ */
+ public static String arrayToString(int[] array) {
+ if (array == null) {
+ return "null";
+ }
+
+ StringBuilder rstr = new StringBuilder();
+ for (int i = 0; i < array.length; i++) {
+ if (i > 0) {
+ rstr.append(",");
+ }
+
+ rstr.append(array[i]);
+ }
+
+ return rstr.toString();
+ }
+
+ /**
+ * Create a string formulated by inserting a delimiter in between consecutive array elements.
+ *
+ * @param objs List of objects to implode (elements may not be null)
+ * @param delim String to place inbetween elements
+ *
+ * @return A string with objects in the list seperated by delim
+ */
+ public static String implode(List objs, String delim) {
+ StringBuilder buf = new StringBuilder();
+ int size = objs.size();
+
+ for (int i = 0; i < (size - 1); i++) {
+ buf.append(objs.get(i).toString());
+ buf.append( delim);
+ }
+
+ if (size != 0) {
+ buf.append(objs.get(size - 1).toString());
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Split a string on delimiter boundaries, and place each element into a List.
+ *
+ * @param s String to split up
+ * @param delim Delimiting token, ala StringTokenizer
+ *
+ * @return a List comprised of elements split by the tokenizing
+ */
+
+ public static List<String> explode(String s, String delim) {
+ List<String> res = new ArrayList<String>();
+ if (s == null)
+ return res;
+
+ StringTokenizer tok = new StringTokenizer(s, delim);
+
+ while (tok.hasMoreTokens()) {
+ res.add(tok.nextToken());
+ }
+
+ return res;
+ }
+
+ /**
+ * Split a string on delimiter boundaries, and place each element into an Array.
+ *
+ * @param toExplode String to split up
+ * @param delim Delimiting token, ala StringTokenizer
+ *
+ * @return an Array comprised of elements split by the tokenizing
+ */
+ public static String[] explodeToArray(String toExplode, String delim) {
+ List<String> strings = explode(toExplode, delim);
+ String[] ret;
+ ret = strings.toArray(new String[strings.size()]);
+ return ret;
+ }
+
+ /**
+ * Split a string up by whitespace, taking into account quoted subcomponents. If there is an uneven number of
+ * quotes, a parse error will be thrown.
+ *
+ * @param arg String to parse
+ *
+ * @return an array of elements, the argument was split into
+ *
+ * @throws IllegalArgumentException indicating there was a quoting error
+ */
+
+ public static String[] explodeQuoted(String arg) throws IllegalArgumentException {
+ List<String> res = new ArrayList<String>();
+ StringTokenizer quoteTok;
+ boolean inQuote = false;
+
+ arg = arg.trim();
+ quoteTok = new StringTokenizer(arg, "\"", true);
+
+ while (quoteTok.hasMoreTokens()) {
+ String elem = (String) quoteTok.nextElement();
+
+ if (elem.equals("\"")) {
+ inQuote = !inQuote;
+ continue;
+ }
+
+ if (inQuote) {
+ res.add(elem);
+ } else {
+ StringTokenizer spaceTok = new StringTokenizer(elem.trim());
+
+ while (spaceTok.hasMoreTokens()) {
+ res.add(spaceTok.nextToken());
+ }
+ }
+ }
+
+ if (inQuote) {
+ throw new IllegalArgumentException("Unbalanced quotation marks");
+ }
+
+ return res.toArray(new String[res.size()]);
+ }
+
+ /**
+ * Remove a prefix from a string. If value starts with prefix, it will be removed, the resultant string is trimmed
+ * and returned.
+ *
+ * @return If value starts with prefix, then this method returns value with the prefix removed, and the resultant
+ * string trimmed. If value does not start with prefix, value is returned as-is.
+ */
+ public static String removePrefix(String value, String prefix) {
+ if (!value.startsWith(prefix)) {
+ return value;
+ }
+
+ return value.substring(prefix.length()).trim();
+ }
+
+ /**
+ * @return the plural of word. This is done by applying a few rules. These cover most (but not all) cases: 1. If the
+ * word ends in s, ss, x, o, or ch, append es 2. If the word ends in a consonant followed by y, drop the y
+ * and add ies 3. Append an s and call it a day. The ultimate references is at
+ * http://en.wikipedia.org/wiki/English_plural
+ */
+ public static String pluralize(String word) {
+ if (word.endsWith("s") || word.endsWith("x") || word.endsWith("o") || word.endsWith("ch")) {
+ return word + "es";
+ }
+
+ if (word.endsWith("y")) {
+ // Odd case to avoid StringIndexOutOfBounds later
+ if (word.length() == 1) {
+ return word;
+ }
+
+ // Check next-to-last letter
+ char next2last = word.charAt(word.length() - 2);
+ if ((next2last != 'a') && (next2last != 'e') && (next2last != 'i') && (next2last != 'o')
+ && (next2last != 'u') && (next2last != 'y')) {
+ return word.substring(0, word.length() - 1) + "ies";
+ }
+ }
+
+ return word + "s";
+ }
+
+ /**
+ * @return The stack trace for the given Throwable as a String.
+ */
+ public static String getStackTrace(Throwable t) {
+ if (t == null) {
+ return "THROWABLE-WAS-NULL (at " + getStackTrace(new Exception()) + ")";
+ }
+
+ try {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ t.printStackTrace(pw);
+
+ Throwable cause = t.getCause();
+ if (cause != null) {
+ return sw.toString() + getStackTrace(cause);
+ }
+
+ return sw.toString();
+ } catch (Exception e) {
+ return "\n\nStringUtil.getStackTrace " + "GENERATED EXCEPTION: '" + e.toString() + "' \n\n";
+ }
+ }
+
+ /**
+ * @return The stack trace for the given Throwable as a String.
+ */
+ public static String getFirstStackTrace(Throwable t) {
+ if (t == null) {
+ return null;
+ }
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+
+ return sw.toString();
+ }
+
+ /**
+ * @param s A string that might contain unix-style path separators.
+ *
+ * @return The correct path for this platform (i.e, if win32, replace / with \).
+ */
+ public static String normalizePath(String s) {
+ return StringUtil.replace(s, "/", File.separator);
+ }
+
+ public static String formatDuration(long duration) {
+ return formatDuration(duration, 0, false);
+ }
+
+ public static String formatDuration(long duration, int scale, boolean minDigits) {
+ long hours;
+ long mins;
+ int digits;
+ double millis;
+
+ hours = duration / 3600000;
+ duration -= hours * 3600000;
+
+ mins = duration / 60000;
+ duration -= mins * 60000;
+
+ millis = (double) duration / 1000;
+
+ StringBuilder buf = new StringBuilder();
+
+ if ((hours > 0) || (minDigits == false)) {
+ buf.append(((hours < 10) && (minDigits == false)) ? ("0" + hours) : String.valueOf(hours)).append(':');
+ minDigits = false;
+ }
+
+ if ((mins > 0) || (minDigits == false)) {
+ buf.append(((mins < 10) && (minDigits == false)) ? ("0" + mins) : String.valueOf(mins)).append(':');
+ minDigits = false;
+ }
+
+ // Format seconds and milliseconds
+ NumberFormat fmt = NumberFormat.getInstance();
+ digits = (((minDigits == false) || ((scale == 0) && (millis >= 9.5))) ? 2 : 1);
+ fmt.setMinimumIntegerDigits(digits);
+ fmt.setMaximumIntegerDigits(2); // Max of 2
+ fmt.setMinimumFractionDigits(0); // Don't need any
+ fmt.setMaximumFractionDigits(scale);
+
+ buf.append(fmt.format(millis));
+
+ return buf.toString();
+ }
+
+ public static String repeatChars(char c, int nTimes) {
+ char[] arr = new char[nTimes];
+
+ for (int i = 0; i < nTimes; i++) {
+ arr[i] = c;
+ }
+
+ return new String(arr);
+ }
+
+ /**
+ * Capitalizes the first letter of str.
+ *
+ * @param str The string to capitalize.
+ *
+ * @return A new string that is <code>str</code> capitalized. Returns <code>null</code> if str is null.
+ */
+ public static String capitalize(String str) {
+ if (str == null) {
+ return null;
+ } else if (str.trim().equals("")) {
+ return str;
+ }
+
+ String result = str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
+
+ return result;
+ }
+
+ public static String truncate(String s, int truncLength, boolean removeWhiteSpace) {
+ String temp = ((s.length() > truncLength) ? (s.substring(0, truncLength) + "...") : s);
+ if (removeWhiteSpace) {
+ temp = temp.replaceAll("\\s+", " ");
+ }
+
+ return temp;
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java
index a13e89a..2c4c7b8 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/error/GenericErrorUIBean.java
@@ -28,7 +28,7 @@ import javax.faces.context.FacesContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.clientapi.util.StringUtil;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.alert.engine.internal.Tuple;
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java
index 203c929..88b434d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/Portal.java
@@ -23,7 +23,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.rhq.core.clientapi.util.StringUtil;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.util.DashboardUtils;
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
index 5d317b0..6c31434 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
@@ -8,12 +8,12 @@ import java.util.List;
import java.util.ListIterator;
import java.util.StringTokenizer;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.composite.ResourceIdFlyWeight;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.legacy.action.resource.hub.HubView;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
index df45f52..470975b 100755
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
@@ -30,7 +30,6 @@ import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.clientapi.util.TimeUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
@@ -38,6 +37,7 @@ import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.DefaultConstants;
import org.rhq.enterprise.gui.legacy.ParamConstants;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java
index cb1e04e..e516033 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/PortalAction.java
@@ -30,7 +30,6 @@ import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.auth.Subject;
@@ -38,6 +37,7 @@ import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.ParamConstants;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java
index f134028..2aefb23 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java
@@ -32,12 +32,12 @@ import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.Portal;
import org.rhq.enterprise.gui.legacy.Portlet;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java
index a1970ba..83afbd8 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsDisplayAction.java
@@ -29,9 +29,9 @@ import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.ParamConstants;
import org.rhq.enterprise.gui.legacy.WebUser;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java
index 1055210..a6b3230 100755
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/MetricsFilterForm.java
@@ -21,7 +21,8 @@ package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.ImageButtonBean;
-import org.rhq.core.clientapi.util.StringUtil;
+
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.legacy.measurement.MeasurementConstants;
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java
index 9ec74ee..3f9f998 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java
@@ -35,7 +35,6 @@ import org.apache.struts.action.ActionMapping;
import org.apache.struts.tiles.ComponentContext;
import org.rhq.core.clientapi.util.ArrayUtil;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.measurement.MeasurementBaseline;
import org.rhq.core.domain.measurement.MeasurementDefinition;
@@ -51,6 +50,7 @@ import org.rhq.core.domain.resource.group.Group;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.server.MeasurementConverter;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.gui.common.servlet.HighLowMetricValue;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.DefaultConstants;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java
index 28e1f8d..d4c86e1 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/OptionItem.java
@@ -28,7 +28,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.struts.util.LabelValueBean;
-import org.rhq.core.clientapi.util.StringUtil;
+
+import org.rhq.core.util.StringUtil;
/**
* This bean is for use with html:options.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java
index 261af53..cf2fe2c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/RemovePrefixTag.java
@@ -24,7 +24,8 @@ import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.taglibs.standard.tag.common.core.NullAttributeException;
import org.apache.taglibs.standard.tag.el.core.ExpressionUtil;
-import org.rhq.core.clientapi.util.StringUtil;
+
+import org.rhq.core.util.StringUtil;
public class RemovePrefixTag extends TagSupport {
private String prefix = null;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
index 2699f8e..7a0f490 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
@@ -13,7 +13,7 @@ $Header$
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.servlet.ServletRequest" %>
-<%@ page import="org.rhq.core.clientapi.util.StringUtil" %>
+<%@ page import="org.rhq.core.util.StringUtil" %>
<%@ page import="org.rhq.enterprise.server.RHQConstants"%>
<%@ page import="org.rhq.enterprise.server.util.LookupUtil" %>
<%@ page import="org.rhq.core.db.DatabaseTypeFactory" %>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
index 915510d..cc2f790 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
@@ -1,7 +1,7 @@
<%@ page language="java" %>
<%@ page isErrorPage="true" %>
<%@ page import="javax.servlet.ServletException" %>
-<%@ page import="org.rhq.core.clientapi.util.StringUtil" %>
+<%@ page import="org.rhq.core.util.StringUtil" %>
<%@ page import="org.rhq.enterprise.server.auth.SessionNotFoundException"%>
<%@ page import="org.rhq.enterprise.server.auth.SessionTimeoutException"%>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
index 5f05378..eafb2e1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
@@ -1,7 +1,7 @@
<%@ page language="java" %>
<%@ page isErrorPage="true" %>
<%@ page import="java.util.Enumeration"%>
-<%@ page import="org.rhq.core.clientapi.util.StringUtil" %>
+<%@ page import="org.rhq.core.util.StringUtil" %>
<%@ page import="org.rhq.enterprise.gui.legacy.WebUser" %>
<%@ page import="org.rhq.enterprise.gui.legacy.WebUserPreferences" %>
<%@ page import="org.rhq.enterprise.gui.legacy.util.SessionUtils" %>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
index d92e7ba..5b1b980 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
@@ -27,9 +27,9 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.util.StringUtil;
public abstract class SubjectPreferencesBase {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java
index 2e47466..fe59053 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementPreferences.java
@@ -3,8 +3,8 @@ package org.rhq.enterprise.server.measurement;
import java.util.Arrays;
import java.util.List;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.auth.prefs.SubjectPreferencesBase;
import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java
index 711fb75..7935e5f 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/SystemSettingsImporterTest.java
@@ -27,11 +27,11 @@ import java.util.Properties;
import org.jmock.Expectations;
import org.testng.annotations.Test;
-import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.sync.entity.SystemSettings;
+import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.sync.importers.SystemSettingsImporter;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.test.JMockTest;
commit 3266294b4768113f529df1d77b03e056579389e5
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 30 11:07:13 2012 -0400
[BZ 759615] put our dynamic class definition in a separate package to avoid conflict with signed packages
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
index 2c1258d..74c0019 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
@@ -144,9 +144,10 @@ public class ResourceClientFactory {
private Class<?> defineCustomInterface(ResourceClientProxy proxy) {
try {
- // define the dynamic class
+ // define the dynamic class - do not put it in any known rhq package in case our jars are signed (see BZ-794503)
ClassPool pool = ClassPool.getDefault();
- CtClass customClass = pool.makeInterface(ResourceClientProxy.class.getName() + proxy.fingerprint);
+ CtClass customClass = pool.makeInterface("org.rhq.bindings.client.dynamic."
+ + ResourceClientProxy.class.getSimpleName() + proxy.fingerprint);
for (String key : proxy.allProperties.keySet()) {
Object prop = proxy.allProperties.get(key);
commit b0bcb5d6f5ef3f3c28e00a2bee24e3e0599de525
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 29 17:50:17 2012 -0400
[BZ 759615] refactor the domain jar's org.rhq.core.server package name to org.rhq.core.domain.server
diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml
index 1bbc1e2..af1441e 100644
--- a/etc/m2/settings.xml
+++ b/etc/m2/settings.xml
@@ -154,7 +154,7 @@
<rhq.test.ds.port>9092</rhq.test.ds.port>
<rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
<!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.test.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.test.ds.hibernate-dialect>org.rhq.core.domain.server.H2CustomDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
@@ -170,7 +170,7 @@
<rhq.dev.ds.port>9092</rhq.dev.ds.port>
<rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
<!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.dev.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.dev.ds.hibernate-dialect>
+ <rhq.dev.ds.hibernate-dialect>org.rhq.core.domain.server.H2CustomDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/H2DatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/H2DatabaseType.java
index e7258bd..05f8de4 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/H2DatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/H2DatabaseType.java
@@ -46,7 +46,7 @@ public abstract class H2DatabaseType extends DatabaseType {
}
public String getHibernateDialect() {
- return "org.rhq.core.server.H2CustomDialect";
+ return "org.rhq.core.domain.server.H2CustomDialect";
}
/**
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/server/EntitySerializer.java b/modules/core/domain/src/main/java/org/rhq/core/domain/server/EntitySerializer.java
new file mode 100644
index 0000000..5c05c57
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/server/EntitySerializer.java
@@ -0,0 +1,296 @@
+/*
+ * 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.server;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Id;
+
+import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.server.ExternalizableStrategy.Subsystem;
+
+/**
+ * A utility specifically tailored to entities which will iterate over its persistence fields with a consistent
+ * ordering for serialization and deserialization. If this class is passed a non-entity object, it will ignore
+ * field-level annotations and just serialize and deserialize all fields in that object.
+ *
+ * @author Joseph Marques
+ */
+public class EntitySerializer {
+ private static Set<Class<? extends Annotation>> PERSISTENCE_ANNOTATIONS = new HashSet<Class<? extends Annotation>>();
+ static {
+ PERSISTENCE_ANNOTATIONS.add(Id.class);
+ PERSISTENCE_ANNOTATIONS.add(Column.class);
+ PERSISTENCE_ANNOTATIONS.add(ManyToOne.class);
+ PERSISTENCE_ANNOTATIONS.add(OneToMany.class);
+ PERSISTENCE_ANNOTATIONS.add(ManyToMany.class);
+ }
+
+ private static Set<Class<?>> BASIC_TYPES = new HashSet<Class<?>>();
+ static {
+ BASIC_TYPES.add(Byte.TYPE);
+ BASIC_TYPES.add(Short.TYPE);
+ BASIC_TYPES.add(Integer.TYPE);
+ BASIC_TYPES.add(Long.TYPE);
+ BASIC_TYPES.add(Float.TYPE);
+ BASIC_TYPES.add(Double.TYPE);
+ BASIC_TYPES.add(Boolean.TYPE);
+ }
+
+ private static Comparator<Field> fieldComparator = new Comparator<Field>() {
+ public int compare(Field first, Field second) {
+ return first.getName().compareTo(second.getName());
+ }
+ };
+
+ private static Field[] getFields(Object object) {
+ Class<?> objectClass = object.getClass();
+ Entity entityAnnotation = objectClass.getAnnotation(Entity.class);
+
+ List<Field> serializableFields;
+ if (entityAnnotation == null) {
+ serializableFields = getNonEntityFieldList(object);
+ } else {
+ serializableFields = getEntityFieldList(object);
+ }
+
+ Collections.sort(serializableFields, fieldComparator);
+
+ Field[] results = serializableFields.toArray(new Field[serializableFields.size()]);
+ return results;
+ }
+
+ private static List<Field> getNonEntityFieldList(Object object) {
+ Class<?> objectClass = object.getClass();
+ Field[] fields = objectClass.getDeclaredFields();
+ List<Field> serializableFields = new ArrayList<Field>();
+
+ for (Field field : fields) {
+ serializableFields.add(field);
+ field.setAccessible(true);
+ }
+
+ return serializableFields;
+ }
+
+ private static List<Field> getEntityFieldList(Object entity) {
+ Class<?> entityClass = entity.getClass();
+ Entity entityAnnotation = entityClass.getAnnotation(Entity.class);
+ if (entityAnnotation == null) {
+ throw new IllegalArgumentException("EntitySerializer only introspects objects annotated with @Entity ");
+ }
+
+ List<Field> serializableFields = new ArrayList<Field>();
+
+ while (entityClass != null) {
+
+ Field[] fields = entityClass.getDeclaredFields();
+ for (Field field : fields) {
+ Annotation[] fieldAnnotations = field.getAnnotations();
+ for (Annotation fieldAnnotation : fieldAnnotations) {
+ if (PERSISTENCE_ANNOTATIONS.contains(fieldAnnotation.annotationType())) {
+ serializableFields.add(field);
+ field.setAccessible(true);
+ break;
+ }
+ }
+ }
+ entityClass = entityClass.getSuperclass();
+ }
+
+ return serializableFields;
+ }
+
+ public static void writeExternalRemote(Object object, ObjectOutput out) throws IOException {
+ Field[] fields = getFields(object);
+ for (Field field : fields) {
+ //System.out.println("Serializing " + field.getName() + "...");
+ try {
+ Class<?> type = field.getType();
+ Object value = field.get(object);
+
+ if (BASIC_TYPES.contains(type)) {
+ if (type.equals(Byte.TYPE)) {
+ out.writeByte((Byte) value);
+ } else if (type.equals(Short.TYPE)) {
+ out.writeShort((Short) value);
+ } else if (type.equals(Integer.TYPE)) {
+ out.writeInt((Integer) value);
+ } else if (type.equals(Long.TYPE)) {
+ out.writeLong((Long) value);
+ } else if (type.equals(Float.TYPE)) {
+ out.writeFloat((Float) value);
+ } else if (type.equals(Double.TYPE)) {
+ out.writeDouble((Double) value);
+ } else if (type.equals(Boolean.TYPE)) {
+ out.writeBoolean((Boolean) value);
+ } else {
+ throw new IllegalStateException(
+ "BASIC_TYPES contains an entry that doesn't have serialization support: " + type);
+ }
+ continue;
+ }
+
+ // either a string, an enum, numeric wrapper, collection, or some other object
+ out.writeObject(value);
+ } catch (IllegalAccessException iae) {
+ throw new IllegalStateException("Could not access field '" + field.getName() + "' for serialization");
+ }
+ }
+ }
+
+ public static void readExternalRemote(Object object, ObjectInput in) throws IOException, ClassNotFoundException {
+ Field[] fields = getFields(object);
+ for (Field field : fields) {
+ //System.out.println("Deserializing " + field.getName() + "...");
+ try {
+ Class<?> type = field.getType();
+
+ if (BASIC_TYPES.contains(type)) {
+ if (type.equals(Byte.TYPE)) {
+ field.setByte(object, in.readByte());
+ } else if (type.equals(Short.TYPE)) {
+ field.setShort(object, in.readShort());
+ } else if (type.equals(Integer.TYPE)) {
+ field.setInt(object, in.readInt());
+ } else if (type.equals(Long.TYPE)) {
+ field.setLong(object, in.readLong());
+ } else if (type.equals(Float.TYPE)) {
+ field.setFloat(object, in.readFloat());
+ } else if (type.equals(Double.TYPE)) {
+ field.setDouble(object, in.readDouble());
+ } else if (type.equals(Boolean.TYPE)) {
+ field.setBoolean(object, in.readBoolean());
+ } else {
+ throw new IllegalStateException(
+ "BASIC_TYPES contains an entry that doesn't have deserialization support: " + type);
+ }
+ continue;
+ }
+
+ // either a string, an enum, numeric wrapper, collection, or some other object
+ field.set(object, in.readObject());
+ } catch (IllegalAccessException iae) {
+ throw new IllegalStateException("Could not access field '" + field.getName() + "' for deserialization");
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ ExternalizableStrategy.setStrategy(Subsystem.REFLECTIVE_SERIALIZATION);
+
+ // create objects
+ Agent writeAgent = new Agent("reflectiveAgent", "reflectiveAddress", 0, "reflectiveEndpoint", "reflectiveToken");
+
+ ResourceType writeResourceType = new ResourceType();
+ writeResourceType.setName("reflectiveType");
+ writeResourceType.setPlugin("reflectivePlugin");
+ writeResourceType.setId(7);
+
+ Resource writeParentResource = new Resource();
+ writeParentResource.setId(11);
+ writeParentResource.setName("reflectiveParentResource");
+ writeParentResource.setResourceKey("reflectiveParentKey");
+
+ Resource writeResource = new Resource();
+ writeResource.setId(42);
+ writeResource.setName("reflectiveResource");
+ writeResource.setResourceKey("reflectiveKey");
+
+ // setup relationships
+ writeResource.setAgent(writeAgent);
+ writeResource.setResourceType(writeResourceType);
+ writeResource.setParentResource(writeParentResource);
+
+ System.out.println("BEFORE");
+ System.out.println(writeResource.toString());
+ System.out.println("BEFORE");
+
+ String tempDir = System.getProperty("java.io.tmpdir");
+ File tempFile = new File(tempDir, "entitySerializerTest.txt");
+
+ FileOutputStream fos = new FileOutputStream(tempFile);
+ try {
+ ObjectOutput output = new ObjectOutputStream(fos);
+ try {
+ writeExternalRemote(writeResource, output);
+ } finally {
+ output.close();
+ }
+ } finally {
+ fos.close();
+ }
+
+ Resource readResource = new Resource();
+ FileInputStream fis = new FileInputStream(tempFile);
+ try {
+ ObjectInput ois = new ObjectInputStream(fis);
+ try {
+ readExternalRemote(readResource, ois);
+ } finally {
+ ois.close();
+ }
+ } finally {
+ fis.close();
+ }
+
+ // quick verification
+ System.out.println("AFTER");
+ System.out.println(readResource.toString());
+ System.out.println("AFTER");
+
+ // deeper verification
+ boolean equalsResource = writeResource.equals(readResource);
+ boolean equalsParentResource = writeParentResource.equals(readResource.getParentResource());
+ boolean equalsResourceType = writeResourceType.equals(readResource.getResourceType());
+ boolean equalsAgent = writeAgent.equals(readResource.getAgent());
+
+ System.out.println("equalsResource: " + equalsResource);
+ System.out.println("equalsParentResource: " + equalsParentResource);
+ System.out.println("equalsResourceType: " + equalsResourceType);
+ System.out.println("equalsAgent: " + equalsAgent);
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/server/ExternalizableStrategy.java b/modules/core/domain/src/main/java/org/rhq/core/domain/server/ExternalizableStrategy.java
new file mode 100644
index 0000000..f7ad860
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/server/ExternalizableStrategy.java
@@ -0,0 +1,64 @@
+/*
+ * 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.server;
+
+/**
+ * This uses a ThreadLocal to bind an externalization strategy based on the invoking subsystem. In other
+ * words, when we know we're serializing for Server-Agent communication then set to AGENT, when we know we're
+ * serializing for RemoteClient-Server communication set to REMOTEAPI. By keeping this info on the thread
+ * we avoid having to tag all of the relevant objects that will be serialized.
+ *
+ * @author jay shaughnessy
+ */
+public class ExternalizableStrategy {
+
+ public enum Subsystem {
+ AGENT((char) 1), // set bidirectionally for agent<--->server communication
+ REFLECTIVE_SERIALIZATION((char) 3); // set unidirectionally for both CLI-->server and WS-->server communication
+
+ private char id;
+
+ Subsystem(char id) {
+ this.id = id;
+ }
+
+ public char id() {
+ return id;
+ }
+ }
+
+ private static ThreadLocal<Subsystem> strategy = new ThreadLocal<Subsystem>() {
+
+ protected ExternalizableStrategy.Subsystem initialValue() {
+ return Subsystem.AGENT;
+ }
+ };
+
+ public static Subsystem getStrategy() {
+ return strategy.get();
+ }
+
+ public static void setStrategy(Subsystem newStrategy) {
+ strategy.set(newStrategy);
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/server/H2CustomDialect.java b/modules/core/domain/src/main/java/org/rhq/core/domain/server/H2CustomDialect.java
new file mode 100644
index 0000000..cb73aef
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/server/H2CustomDialect.java
@@ -0,0 +1,45 @@
+/*
+ * 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 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.core.domain.server;
+
+import org.hibernate.dialect.H2Dialect;
+
+/**
+ * This class extends the basic H2Dialect that comes in the
+ * Hibernate core distribution to force it to use sequences
+ * for H2 database.
+ *
+ * @author Joseph Marques
+ */
+public class H2CustomDialect extends H2Dialect {
+
+ @Override
+ public boolean supportsIdentityColumns() {
+ /*
+ * By default, GeneratorType.AUTO strategy will choose IDENTITY if a database supports it.
+ * However, the embedded database was originally written using sequences. Later, SQL Server
+ * support was added which required changing the generation strategy from SEQUENCE to AUTO.
+ * This broke support for the embedded database because the H2Dialect was trying to use
+ * identity data types for key columns, which the H2DatabaseType did not support. This hack
+ * basically tricks Hibernate into believing that H2 doesn't support identity types, which
+ * then forces it to fall back to using the SEQUENCE strategy.
+ */
+ return false;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/server/PersistenceUtility.java b/modules/core/domain/src/main/java/org/rhq/core/domain/server/PersistenceUtility.java
new file mode 100644
index 0000000..662d97c
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/server/PersistenceUtility.java
@@ -0,0 +1,563 @@
+/*
+ * 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.server;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.ejb.EntityManagerImpl;
+import org.hibernate.engine.NamedQueryDefinition;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.jmx.StatisticsService;
+import org.hibernate.stat.Statistics;
+import org.hibernate.type.CustomType;
+import org.hibernate.type.EntityType;
+import org.hibernate.type.PrimitiveType;
+import org.hibernate.type.Type;
+
+import org.rhq.core.domain.util.OrderingField;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * Various persistence utility methods - mostly Hibernate-specific.
+ *
+ * @author Heiko Rupp
+ * @author Joseph Marques
+ * @author Greg Hinkle
+ */
+public class PersistenceUtility {
+ private static final Log LOG = LogFactory.getLog(PersistenceUtility.class);
+
+ private static final Pattern COUNT_QUERY_PATTERN = Pattern.compile("^(\\s*SELECT\\s+)(.*?)(\\s+FROM.*)",
+ Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
+ private static final Pattern COUNT_QUERY_REMOVE_FETCH = Pattern.compile("FETCH", Pattern.CASE_INSENSITIVE
+ | Pattern.MULTILINE | Pattern.DOTALL);
+
+ public static final String HIBERNATE_STATISTICS_MBEAN_OBJECTNAME = "Hibernate:type=statistics,application=RHQ";
+
+ @SuppressWarnings("unchecked")
+ // used in hibernate.jsp
+ public static String getDisplayString(Type hibernateType) {
+ if (hibernateType instanceof EntityType) {
+ return hibernateType.getName() + " (enter integer of ID / primary key field)";
+ } else if (hibernateType instanceof CustomType) {
+ if (Enum.class.isAssignableFrom(hibernateType.getReturnedClass())) {
+ Class<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>) hibernateType.getReturnedClass();
+ StringBuilder result = new StringBuilder();
+ result.append(enumClass.getName());
+ result.append(" (");
+ boolean first = true;
+ for (Enum<?> nextEnum : enumClass.getEnumConstants()) {
+ if (!first) {
+ result.append(" | ");
+ } else {
+ first = false;
+ }
+ result.append(nextEnum.name());
+ }
+ result.append(")");
+ return result.toString();
+ }
+ }
+ return hibernateType == null ? "" : hibernateType.getName();
+ }
+
+ @SuppressWarnings("unchecked")
+ // used in hibernate.jsp
+ public static Object cast(String value, Type hibernateType) {
+ if (hibernateType instanceof PrimitiveType) {
+ Class<?> type = ((PrimitiveType) hibernateType).getPrimitiveClass();
+ if (type.equals(Byte.TYPE)) {
+ return Byte.valueOf(value);
+ } else if (type.equals(Short.TYPE)) {
+ return Short.valueOf(value);
+ } else if (type.equals(Integer.TYPE)) {
+ return Integer.valueOf(value);
+ } else if (type.equals(Long.TYPE)) {
+ return Long.valueOf(value);
+ } else if (type.equals(Float.TYPE)) {
+ return Float.valueOf(value);
+ } else if (type.equals(Double.TYPE)) {
+ return Double.valueOf(value);
+ } else if (type.equals(Boolean.TYPE)) {
+ return Boolean.valueOf(value);
+ }
+ } else if (hibernateType instanceof EntityType) {
+ String entityName = ((EntityType) hibernateType).getAssociatedEntityName();
+ try {
+ Class<?> entityClass = Class.forName(entityName);
+ Object entity = entityClass.newInstance();
+
+ Field primaryKeyField = entityClass.getDeclaredField("id");
+ primaryKeyField.setAccessible(true);
+ primaryKeyField.setInt(entity, Integer.valueOf(value));
+ return entity;
+ } catch (Throwable t) {
+ throw new IllegalArgumentException("Type[" + entityName + "] must have PK field named 'id'");
+ }
+ } else if (hibernateType instanceof CustomType) {
+ if (Enum.class.isAssignableFrom(hibernateType.getReturnedClass())) {
+ Class<? extends Enum<?>> enumClass = hibernateType.getReturnedClass();
+ Enum<?>[] enumValues = enumClass.getEnumConstants();
+ try {
+ int enumOrdinal = Integer.valueOf(value);
+ try {
+ return enumValues[enumOrdinal];
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ throw new IllegalArgumentException("There is no " + enumClass.getSimpleName()
+ + " enum with ordinal '" + enumOrdinal + "'");
+ }
+ } catch (NumberFormatException nfe) {
+ String ucaseValue = value.toUpperCase();
+ for (Enum<?> nextEnum : enumValues) {
+ if (nextEnum.name().toUpperCase().equals(ucaseValue)) {
+ return nextEnum;
+ }
+ }
+ throw new IllegalArgumentException("There is no " + enumClass.getSimpleName() + " enum with name '"
+ + value + "'");
+ }
+ }
+ }
+ return value;
+ }
+
+ /**
+ * Used to create queries to use with the {@link org.rhq.core.domain.util.PageControl} objects. The query will already have its sort column
+ * and order appended as well as having its first result and max results set according to the page control data.
+ *
+ * @param entityManager your entity manager
+ * @param queryName name of the query
+ * @param pageControl the controls on the paging and sorting
+ *
+ * @return a preconfigured query for ordered pagination
+ */
+ public static Query createQueryWithOrderBy(EntityManager entityManager, String queryName, PageControl pageControl) {
+ Query query;
+
+ if (pageControl.getPrimarySortColumn() != null) {
+ query = createQueryWithOrderBy(entityManager, queryName, pageControl.getOrderingFieldsAsArray());
+ } else {
+ StackTraceElement caller = new Throwable().fillInStackTrace().getStackTrace()[1];
+ LOG.warn("Queries should really supply default sort columns. Caller did not: " + caller);
+
+ // Use the standard named query if no sorting is specified
+ query = entityManager.createNamedQuery(queryName);
+ }
+
+ setDataPage(query, pageControl);
+
+ return query;
+ }
+
+ /**
+ * Create a query from a named query with a transformed order by clause with multiple new ordery by clauses.
+ *
+ * @param entityManager the entity manager to build the query against
+ * @param queryName the name of the query to transform
+ * @param orderByFields an array of clauses to contribute to the order by
+ *
+ * @return the transformed query
+ */
+ public static Query createQueryWithOrderBy(EntityManager entityManager, String queryName,
+ OrderingField... orderByFields) {
+ NamedQueryDefinition ndc = getNamedQueryDefinition(entityManager, queryName);
+ StringBuilder query = new StringBuilder(ndc.getQueryString());
+ buildOrderBy(query, orderByFields);
+ return entityManager.createQuery(query.toString());
+ }
+
+ private static StringBuilder buildOrderBy(StringBuilder query, OrderingField... orderByFields) {
+ boolean first = true;
+ for (OrderingField orderingField : orderByFields) {
+ if (first) {
+ // TODO GH: We could see if there already is an order by clause and contribute or override it
+ query.append(" ORDER BY ");
+ first = false;
+ } else {
+ query.append(", ");
+ }
+
+ query.append(orderingField.getField()).append(" ").append(orderingField.getOrdering());
+ }
+
+ return query;
+ }
+
+ private static String getOrderByFragment(OrderingField... orderByFields) {
+ boolean first = true;
+ StringBuilder builder = new StringBuilder();
+ for (OrderingField orderingField : orderByFields) {
+ if (first) {
+ builder.append(" ORDER BY ");
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+
+ builder.append(orderingField.getField()).append(" ").append(orderingField.getOrdering());
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Builds a count(*) version of the named query so we don't have duplicate all our queries to use two query
+ * pagination model.
+ *
+ * @param em the entity manager to build the query for
+ * @param queryName the NamedQuery to transform
+ *
+ * @return a query that can be bound and executed to get the total count of results
+ */
+ public static Query createCountQuery(EntityManager em, String queryName) {
+ return createCountQuery(em, queryName, "*");
+ }
+
+ /**
+ * Builds a count(*) version of the named query so we don't have duplicate all our queries to use two query
+ * pagination model.
+ *
+ * @param entityManager the entity manager to build the query for
+ * @param queryName the NamedQuery to transform
+ * @param countItem the object or attribute that needs to be counted, when it's ambiguous
+ *
+ * @return a query that can be bound and executed to get the total count of results
+ */
+ public static Query createCountQuery(EntityManager entityManager, String queryName, String countItem) {
+ NamedQueryDefinition namedQueryDefinition = getNamedQueryDefinition(entityManager, queryName);
+ String query = namedQueryDefinition.getQueryString();
+
+ Matcher matcher = COUNT_QUERY_PATTERN.matcher(query);
+ if (!matcher.find()) {
+ throw new RuntimeException("Unable to transform query into count query [" + queryName + " - " + query + "]");
+ }
+
+ String newQuery = matcher.group(1) + "COUNT(" + countItem + ")" + matcher.group(3);
+
+ matcher = COUNT_QUERY_REMOVE_FETCH.matcher(newQuery);
+ if (matcher.find()) {
+ StringBuffer buffer = new StringBuffer();
+ do {
+ matcher.appendReplacement(buffer, "");
+ } while (matcher.find());
+ matcher.appendTail(buffer);
+ newQuery = buffer.toString();
+ }
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Transformed query to count query [" + queryName + "] resulting in [" + newQuery + "]");
+ }
+
+ return entityManager.createQuery(newQuery);
+ }
+
+ public static void setDataPage(Query query, PageControl pageControl) {
+ if (pageControl.getPageSize() > 0) {
+ query.setFirstResult(pageControl.getStartRow());
+ query.setMaxResults(pageControl.getPageSize());
+ }
+ }
+
+ /**
+ * Creates and executes a filter query for a collection relationship. This executes without passing back the query
+ * object because the most common case is to simply paginate for a relationship. Use the createFilter method to
+ * create more generic filters and get access to the hibernate query object for setting parameters etc.
+ *
+ * @param entityManager
+ * @param collection
+ * @param pageControl
+ *
+ * @return the result list of the entities from the filtered relationship
+ */
+ @SuppressWarnings("unchecked")
+ public static PageList createPaginationFilter(EntityManager entityManager, Collection collection,
+ PageControl pageControl) {
+ if (collection == null) {
+ return new PageList(pageControl);
+ }
+
+ String filter = "";
+ if (pageControl.getPrimarySortColumn() != null) {
+ PageOrdering order = (pageControl.getPrimarySortOrder() == null) ? PageOrdering.ASC : pageControl
+ .getPrimarySortOrder();
+ filter = getOrderByFragment(new OrderingField(pageControl.getPrimarySortColumn(), order));
+ }
+
+ org.hibernate.Query query = getHibernateSession(entityManager).createFilter(collection, filter);
+ if (pageControl.getPageSize() > 0) {
+ query.setFirstResult(pageControl.getPageNumber() * pageControl.getPageSize());
+ query.setMaxResults(pageControl.getPageSize());
+ }
+
+ // TODO GH: Always flushing is probably not what we really want here
+ // relationship filters don't seem to cause the proper flush, so manually flush
+ getHibernateSession(entityManager).flush();
+
+ // TODO GH: This can only create unbounded PageLists since I don't know how to do a count query to find the size
+ return new PageList<Object>(query.list(), pageControl);
+ }
+
+ /**
+ * Use this inside subclasses as a convenience method.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> List<T> findByCriteria(EntityManager entityManager, Class<T> type,
+ org.hibernate.criterion.Criterion... criterion) {
+ // Using Hibernate, more difficult with EntityManager and EJB-QL
+ org.hibernate.Criteria crit = getHibernateSession(entityManager).createCriteria(type);
+ for (org.hibernate.criterion.Criterion c : criterion) {
+ crit.add(c);
+ }
+
+ return crit.list();
+ }
+
+ public static Session getHibernateSession(EntityManager entityManager) {
+ Session session;
+ if (entityManager.getDelegate() instanceof EntityManagerImpl) {
+ EntityManagerImpl entityManagerImpl = (EntityManagerImpl) entityManager.getDelegate();
+ session = entityManagerImpl.getSession();
+ } else {
+ session = (Session) entityManager.getDelegate();
+ }
+
+ return session;
+ }
+
+ /**
+ * Enables the hibernate statistics mbean to provide access to information on the ejb3 persistence tier.
+ *
+ * @param entityManager an inject entity manager whose session factory will be tracked with these statistics
+ * @param server the MBeanServer where the statistics MBean should be registered; if <code>null</code>, the
+ * first one in the list returned by MBeanServerFactory.findMBeanServer(null) is used
+ */
+ public static void enableHibernateStatistics(EntityManager entityManager, MBeanServer server) {
+ try {
+ SessionFactory sessionFactory = PersistenceUtility.getHibernateSession(entityManager).getSessionFactory();
+
+ if (server == null) {
+ ArrayList<MBeanServer> list = MBeanServerFactory.findMBeanServer(null);
+ server = list.get(0);
+ }
+
+ ObjectName objectName = new ObjectName(HIBERNATE_STATISTICS_MBEAN_OBJECTNAME);
+ StatisticsService mBean = new StatisticsService();
+ mBean.setSessionFactory(sessionFactory);
+ server.registerMBean(mBean, objectName);
+ sessionFactory.getStatistics().setStatisticsEnabled(true);
+ } catch (InstanceAlreadyExistsException iaee) {
+ LOG.info("Duplicate mbean registration ignored: " + HIBERNATE_STATISTICS_MBEAN_OBJECTNAME);
+ } catch (Exception e) {
+ LOG.warn("Couldn't register hibernate statistics mbean", e);
+ }
+ }
+
+ public static Statistics getStatisticsService(EntityManager entityManager, MBeanServer server) {
+ Session hibernateSession = PersistenceUtility.getHibernateSession(entityManager);
+ SessionFactory hibernateSessionFactory = hibernateSession.getSessionFactory();
+ Statistics hibernateStatistics = hibernateSessionFactory.getStatistics();
+ return hibernateStatistics;
+ }
+
+ private static NamedQueryDefinition getNamedQueryDefinition(EntityManager entityManager, String queryName) {
+ SessionFactoryImplementor sessionFactory = getHibernateSessionFactoryImplementor(entityManager);
+ NamedQueryDefinition namedQueryDefinition = sessionFactory.getNamedQuery(queryName);
+ if (namedQueryDefinition == null) {
+ throw new RuntimeException("EJB3 query not found [" + queryName + "]");
+ }
+
+ return namedQueryDefinition;
+ }
+
+ private static SessionFactoryImplementor getHibernateSessionFactoryImplementor(EntityManager entityManager) {
+ Session session = getHibernateSession(entityManager);
+ SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) session.getSessionFactory();
+ return sessionFactory;
+ }
+
+ // wanted to combine postgres and oracle methods, but org.rhq.core.db.DatabaseType objects are not visible to domain
+ public static String addPostgresNativePagingSortingToQuery(String query, PageControl pageControl) {
+ return addLimitOffsetToQuery(query, pageControl);
+ }
+
+ // wanted to combine postgres and oracle methods, but org.rhq.core.db.DatabaseType objects are not visible to domain
+ public static String addOracleNativePagingSortingToQuery(String query, PageControl pageControl) {
+ StringBuilder queryWithPagingSorting = new StringBuilder(query.length() + 50);
+
+ int minRowNum = pageControl.getStartRow() + 1;
+ int maxRowNum = minRowNum + pageControl.getPageSize() - 1;
+
+ // pagination calculations based off of double-projection of the results
+ queryWithPagingSorting.append("SELECT outerResults.* FROM ( ");
+
+ queryWithPagingSorting.append("SELECT innerResults.*, ROWNUM rnum FROM ( ");
+ queryWithPagingSorting.append(query);
+ // for oracle, order by occurs at the end of the original query, whether grouped or not
+ queryWithPagingSorting.append(getOrderByFragment(pageControl.getOrderingFieldsAsArray()));
+ queryWithPagingSorting.append(" ) innerResults ");
+
+ // for oracle, paginate high off of the inner projection
+ queryWithPagingSorting.append(" WHERE ROWNUM <= ").append(maxRowNum);
+
+ // for oracle, paginate low off of the outer projection
+ queryWithPagingSorting.append(" ) outerResults ");
+ queryWithPagingSorting.append(" WHERE rnum >= ").append(minRowNum);
+
+ return queryWithPagingSorting.toString();
+ }
+
+ /**
+ * Note: always put the rownum column at the END of the columns, so that code
+ * which relies on index-based access to the result set data doesn't break
+ *
+ * Method 1:
+ *
+ * SELECT outerResults.* FROM (
+ * SELECT innerResults.*,
+ * ROW_NUMBER() OVER( {orderByClause} ) AS rownum
+ * FROM ( {queryWithoutOrderBy} ) AS innerResults
+ * ) AS outerResults
+ * WHERE rownum <= maxRowNum AND rownum >= minRowNum
+ *
+ * The above method fails in circumstances where the orderByClause is built up with
+ * aliases that aren't in the explicit select list returned from queryWithoutOrderBy
+ *
+ *
+ * Method 2:
+ *
+ * Fix above shortcomings by pushing the orderByClause into the actual select list
+ *
+ * SELECT singleResults.* FROM (
+ * {queryWithoutOrderBySelectList}
+ * , ROW_NUMBER() OVER( {orderByClause} ) AS rownum
+ * {queryWithoutOrderByRestOfQuery}
+ * ) AS singleResults
+ * WHERE rownum <= maxRowNum AND rownum >= minRowNum
+ *
+ *
+ * Actually, both of the above methods have small flaws. The first can not sort by columns that
+ * aren't in the explicit return list. The second can not sort by computed columns and subqueries
+ * in the select list. The only way I see how this can work is by modifying the queryWithoutOrderBy
+ * to explicitly return all parameters that will be sorted on (even if the use case wouldn't normally
+ * require them to be in the select list), alias them, and order by the aliases by modifying the web
+ * ui code to use those tokens when generating the sortable column headers (jmarques - June/2009)
+ */
+ public static String addSQLServerNativePagingSortingToQuery(String query, PageControl pageControl) {
+ return addSQLServerNativePagingSortingToQuery(query, pageControl, false);
+ }
+
+ public static String addSQLServerNativePagingSortingToQuery(String query, PageControl pageControl,
+ boolean alternatePagingStyle) {
+ StringBuilder queryWithPagingSorting = new StringBuilder(query.length() + 50);
+
+ int minRowNum = pageControl.getStartRow() + 1;
+ int maxRowNum = minRowNum + pageControl.getPageSize() - 1;
+
+ String orderByClause = getOrderByFragment(pageControl.getOrderingFieldsAsArray());
+
+ if (alternatePagingStyle) {
+ int index = findSelectListEndIndex(query);
+ String selectList = query.substring(0, index);
+ String restOfQuery = query.substring(index);
+ queryWithPagingSorting.append("SELECT singleResults.* FROM ( ");
+ queryWithPagingSorting.append(selectList);
+ queryWithPagingSorting.append(", ROW_NUMBER() OVER( " + orderByClause + " ) AS rownum ");
+ queryWithPagingSorting.append(restOfQuery);
+ queryWithPagingSorting.append(") AS singleResults ");
+ } else {
+ queryWithPagingSorting.append("SELECT outerResults.* FROM ( ");
+ queryWithPagingSorting.append(" SELECT innerResults.*, ");
+ queryWithPagingSorting.append(" ROW_NUMBER() OVER( " + orderByClause + " ) AS rownum ");
+ queryWithPagingSorting.append(" FROM ( " + query + " ) AS innerResults ");
+ queryWithPagingSorting.append(" ) AS outerResults ");
+ }
+ queryWithPagingSorting.append("WHERE rownum <= ").append(maxRowNum);
+ queryWithPagingSorting.append(" AND rownum >= ").append(minRowNum);
+
+ return queryWithPagingSorting.toString();
+ }
+
+ // beginning of from clause (not counting retrievals via subqueries) should indicate end of select list
+ private static int findSelectListEndIndex(String query) {
+ int nesting = 0;
+ query = query.toLowerCase();
+ StringBuilder wordBuffer = new StringBuilder();
+ for (int i = 0; i < query.length(); i++) {
+ char next = query.charAt(i);
+ if (next == '(') {
+ nesting++;
+ } else if (next == ')') {
+ nesting--;
+ } else {
+ if (nesting != 0) {
+ continue;
+ }
+ if (Character.isLetter(next)) {
+ wordBuffer.append(next);
+ if (wordBuffer.toString().equals("from")) {
+ return i - 4; // return index representing the character just before "from"
+ }
+ } else {
+ wordBuffer.setLength(0); // clear buffer if we find any non-letter
+ }
+ }
+ }
+ throw new IllegalArgumentException("Could not find select list end index");
+ }
+
+ // wanted to combine postgres and oracle methods, but org.rhq.core.db.DatabaseType objects are not visible to domain
+ public static String addH2NativePagingSortingToQuery(String query, PageControl pageControl) {
+ return addLimitOffsetToQuery(query, pageControl);
+ }
+
+ private static String addLimitOffsetToQuery(String query, PageControl pageControl) {
+ StringBuilder queryWithPagingSorting = new StringBuilder(query.length() + 50);
+ queryWithPagingSorting.append(query);
+
+ // for postgres, first order by
+ queryWithPagingSorting.append(getOrderByFragment(pageControl.getOrderingFieldsAsArray()));
+
+ // for postgres, then paginate
+ queryWithPagingSorting.append(" LIMIT ").append(pageControl.getPageSize());
+ queryWithPagingSorting.append(" OFFSET ").append(pageControl.getStartRow());
+
+ return queryWithPagingSorting.toString();
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java
index e24805c..6963141 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java
@@ -29,7 +29,7 @@ import java.util.List;
/**
* Used to pass information on pagination and sorting to data lookup methods.
- * {@link org.rhq.core.server.PersistenceUtility} provides several methods
+ * {@link org.rhq.core.domain.server.PersistenceUtility} provides several methods
* that can be called to apply PageControls to various types of queries.
*
* @author Greg Hinkle
diff --git a/modules/core/domain/src/main/java/org/rhq/core/server/EntitySerializer.java b/modules/core/domain/src/main/java/org/rhq/core/server/EntitySerializer.java
deleted file mode 100644
index cdacd46..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/server/EntitySerializer.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * 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.server;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Id;
-
-import org.rhq.core.domain.resource.Agent;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.server.ExternalizableStrategy.Subsystem;
-
-/**
- * A utility specifically tailored to entities which will iterate over its persistence fields with a consistent
- * ordering for serialization and deserialization. If this class is passed a non-entity object, it will ignore
- * field-level annotations and just serialize and deserialize all fields in that object.
- *
- * @author Joseph Marques
- */
-public class EntitySerializer {
- private static Set<Class<? extends Annotation>> PERSISTENCE_ANNOTATIONS = new HashSet<Class<? extends Annotation>>();
- static {
- PERSISTENCE_ANNOTATIONS.add(Id.class);
- PERSISTENCE_ANNOTATIONS.add(Column.class);
- PERSISTENCE_ANNOTATIONS.add(ManyToOne.class);
- PERSISTENCE_ANNOTATIONS.add(OneToMany.class);
- PERSISTENCE_ANNOTATIONS.add(ManyToMany.class);
- }
-
- private static Set<Class<?>> BASIC_TYPES = new HashSet<Class<?>>();
- static {
- BASIC_TYPES.add(Byte.TYPE);
- BASIC_TYPES.add(Short.TYPE);
- BASIC_TYPES.add(Integer.TYPE);
- BASIC_TYPES.add(Long.TYPE);
- BASIC_TYPES.add(Float.TYPE);
- BASIC_TYPES.add(Double.TYPE);
- BASIC_TYPES.add(Boolean.TYPE);
- }
-
- private static Comparator<Field> fieldComparator = new Comparator<Field>() {
- public int compare(Field first, Field second) {
- return first.getName().compareTo(second.getName());
- }
- };
-
- private static Field[] getFields(Object object) {
- Class<?> objectClass = object.getClass();
- Entity entityAnnotation = objectClass.getAnnotation(Entity.class);
-
- List<Field> serializableFields;
- if (entityAnnotation == null) {
- serializableFields = getNonEntityFieldList(object);
- } else {
- serializableFields = getEntityFieldList(object);
- }
-
- Collections.sort(serializableFields, fieldComparator);
-
- Field[] results = serializableFields.toArray(new Field[serializableFields.size()]);
- return results;
- }
-
- private static List<Field> getNonEntityFieldList(Object object) {
- Class<?> objectClass = object.getClass();
- Field[] fields = objectClass.getDeclaredFields();
- List<Field> serializableFields = new ArrayList<Field>();
-
- for (Field field : fields) {
- serializableFields.add(field);
- field.setAccessible(true);
- }
-
- return serializableFields;
- }
-
- private static List<Field> getEntityFieldList(Object entity) {
- Class<?> entityClass = entity.getClass();
- Entity entityAnnotation = entityClass.getAnnotation(Entity.class);
- if (entityAnnotation == null) {
- throw new IllegalArgumentException("EntitySerializer only introspects objects annotated with @Entity ");
- }
-
- List<Field> serializableFields = new ArrayList<Field>();
-
- while (entityClass != null) {
-
- Field[] fields = entityClass.getDeclaredFields();
- for (Field field : fields) {
- Annotation[] fieldAnnotations = field.getAnnotations();
- for (Annotation fieldAnnotation : fieldAnnotations) {
- if (PERSISTENCE_ANNOTATIONS.contains(fieldAnnotation.annotationType())) {
- serializableFields.add(field);
- field.setAccessible(true);
- break;
- }
- }
- }
- entityClass = entityClass.getSuperclass();
- }
-
- return serializableFields;
- }
-
- public static void writeExternalRemote(Object object, ObjectOutput out) throws IOException {
- Field[] fields = getFields(object);
- for (Field field : fields) {
- //System.out.println("Serializing " + field.getName() + "...");
- try {
- Class<?> type = field.getType();
- Object value = field.get(object);
-
- if (BASIC_TYPES.contains(type)) {
- if (type.equals(Byte.TYPE)) {
- out.writeByte((Byte) value);
- } else if (type.equals(Short.TYPE)) {
- out.writeShort((Short) value);
- } else if (type.equals(Integer.TYPE)) {
- out.writeInt((Integer) value);
- } else if (type.equals(Long.TYPE)) {
- out.writeLong((Long) value);
- } else if (type.equals(Float.TYPE)) {
- out.writeFloat((Float) value);
- } else if (type.equals(Double.TYPE)) {
- out.writeDouble((Double) value);
- } else if (type.equals(Boolean.TYPE)) {
- out.writeBoolean((Boolean) value);
- } else {
- throw new IllegalStateException(
- "BASIC_TYPES contains an entry that doesn't have serialization support: " + type);
- }
- continue;
- }
-
- // either a string, an enum, numeric wrapper, collection, or some other object
- out.writeObject(value);
- } catch (IllegalAccessException iae) {
- throw new IllegalStateException("Could not access field '" + field.getName() + "' for serialization");
- }
- }
- }
-
- public static void readExternalRemote(Object object, ObjectInput in) throws IOException, ClassNotFoundException {
- Field[] fields = getFields(object);
- for (Field field : fields) {
- //System.out.println("Deserializing " + field.getName() + "...");
- try {
- Class<?> type = field.getType();
-
- if (BASIC_TYPES.contains(type)) {
- if (type.equals(Byte.TYPE)) {
- field.setByte(object, in.readByte());
- } else if (type.equals(Short.TYPE)) {
- field.setShort(object, in.readShort());
- } else if (type.equals(Integer.TYPE)) {
- field.setInt(object, in.readInt());
- } else if (type.equals(Long.TYPE)) {
- field.setLong(object, in.readLong());
- } else if (type.equals(Float.TYPE)) {
- field.setFloat(object, in.readFloat());
- } else if (type.equals(Double.TYPE)) {
- field.setDouble(object, in.readDouble());
- } else if (type.equals(Boolean.TYPE)) {
- field.setBoolean(object, in.readBoolean());
- } else {
- throw new IllegalStateException(
- "BASIC_TYPES contains an entry that doesn't have deserialization support: " + type);
- }
- continue;
- }
-
- // either a string, an enum, numeric wrapper, collection, or some other object
- field.set(object, in.readObject());
- } catch (IllegalAccessException iae) {
- throw new IllegalStateException("Could not access field '" + field.getName() + "' for deserialization");
- }
- }
- }
-
- public static void main(String[] args) throws Exception {
- ExternalizableStrategy.setStrategy(Subsystem.REFLECTIVE_SERIALIZATION);
-
- // create objects
- Agent writeAgent = new Agent("reflectiveAgent", "reflectiveAddress", 0, "reflectiveEndpoint", "reflectiveToken");
-
- ResourceType writeResourceType = new ResourceType();
- writeResourceType.setName("reflectiveType");
- writeResourceType.setPlugin("reflectivePlugin");
- writeResourceType.setId(7);
-
- Resource writeParentResource = new Resource();
- writeParentResource.setId(11);
- writeParentResource.setName("reflectiveParentResource");
- writeParentResource.setResourceKey("reflectiveParentKey");
-
- Resource writeResource = new Resource();
- writeResource.setId(42);
- writeResource.setName("reflectiveResource");
- writeResource.setResourceKey("reflectiveKey");
-
- // setup relationships
- writeResource.setAgent(writeAgent);
- writeResource.setResourceType(writeResourceType);
- writeResource.setParentResource(writeParentResource);
-
- System.out.println("BEFORE");
- System.out.println(writeResource.toString());
- System.out.println("BEFORE");
-
- String tempDir = System.getProperty("java.io.tmpdir");
- File tempFile = new File(tempDir, "entitySerializerTest.txt");
-
- FileOutputStream fos = new FileOutputStream(tempFile);
- try {
- ObjectOutput output = new ObjectOutputStream(fos);
- try {
- writeExternalRemote(writeResource, output);
- } finally {
- output.close();
- }
- } finally {
- fos.close();
- }
-
- Resource readResource = new Resource();
- FileInputStream fis = new FileInputStream(tempFile);
- try {
- ObjectInput ois = new ObjectInputStream(fis);
- try {
- readExternalRemote(readResource, ois);
- } finally {
- ois.close();
- }
- } finally {
- fis.close();
- }
-
- // quick verification
- System.out.println("AFTER");
- System.out.println(readResource.toString());
- System.out.println("AFTER");
-
- // deeper verification
- boolean equalsResource = writeResource.equals(readResource);
- boolean equalsParentResource = writeParentResource.equals(readResource.getParentResource());
- boolean equalsResourceType = writeResourceType.equals(readResource.getResourceType());
- boolean equalsAgent = writeAgent.equals(readResource.getAgent());
-
- System.out.println("equalsResource: " + equalsResource);
- System.out.println("equalsParentResource: " + equalsParentResource);
- System.out.println("equalsResourceType: " + equalsResourceType);
- System.out.println("equalsAgent: " + equalsAgent);
- }
-
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/server/ExternalizableStrategy.java b/modules/core/domain/src/main/java/org/rhq/core/server/ExternalizableStrategy.java
deleted file mode 100644
index a43fcdc..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/server/ExternalizableStrategy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.server;
-
-/**
- * This uses a ThreadLocal to bind an externalization strategy based on the invoking subsystem. In other
- * words, when we know we're serializing for Server-Agent communication then set to AGENT, when we know we're
- * serializing for RemoteClient-Server communication set to REMOTEAPI. By keeping this info on the thread
- * we avoid having to tag all of the relevant objects that will be serialized.
- *
- * @author jay shaughnessy
- */
-public class ExternalizableStrategy {
-
- public enum Subsystem {
- AGENT((char) 1), // set bidirectionally for agent<--->server communication
- REFLECTIVE_SERIALIZATION((char) 3); // set unidirectionally for both CLI-->server and WS-->server communication
-
- private char id;
-
- Subsystem(char id) {
- this.id = id;
- }
-
- public char id() {
- return id;
- }
- }
-
- private static ThreadLocal<Subsystem> strategy = new ThreadLocal<Subsystem>() {
-
- protected ExternalizableStrategy.Subsystem initialValue() {
- return Subsystem.AGENT;
- }
- };
-
- public static Subsystem getStrategy() {
- return strategy.get();
- }
-
- public static void setStrategy(Subsystem newStrategy) {
- strategy.set(newStrategy);
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/server/H2CustomDialect.java b/modules/core/domain/src/main/java/org/rhq/core/server/H2CustomDialect.java
deleted file mode 100644
index cbbb8c5..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/server/H2CustomDialect.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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 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.core.server;
-
-import org.hibernate.dialect.H2Dialect;
-
-/**
- * This class extends the basic H2Dialect that comes in the
- * Hibernate core distribution to force it to use sequences
- * for H2 database.
- *
- * @author Joseph Marques
- */
-public class H2CustomDialect extends H2Dialect {
-
- @Override
- public boolean supportsIdentityColumns() {
- /*
- * By default, GeneratorType.AUTO strategy will choose IDENTITY if a database supports it.
- * However, the embedded database was originally written using sequences. Later, SQL Server
- * support was added which required changing the generation strategy from SEQUENCE to AUTO.
- * This broke support for the embedded database because the H2Dialect was trying to use
- * identity data types for key columns, which the H2DatabaseType did not support. This hack
- * basically tricks Hibernate into believing that H2 doesn't support identity types, which
- * then forces it to fall back to using the SEQUENCE strategy.
- */
- return false;
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/server/PersistenceUtility.java b/modules/core/domain/src/main/java/org/rhq/core/server/PersistenceUtility.java
deleted file mode 100644
index 82c315e..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/server/PersistenceUtility.java
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
- * 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.server;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.ejb.EntityManagerImpl;
-import org.hibernate.engine.NamedQueryDefinition;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.jmx.StatisticsService;
-import org.hibernate.stat.Statistics;
-import org.hibernate.type.CustomType;
-import org.hibernate.type.EntityType;
-import org.hibernate.type.PrimitiveType;
-import org.hibernate.type.Type;
-
-import org.rhq.core.domain.util.OrderingField;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-
-/**
- * Various persistence utility methods - mostly Hibernate-specific.
- *
- * @author Heiko Rupp
- * @author Joseph Marques
- * @author Greg Hinkle
- */
-public class PersistenceUtility {
- private static final Log LOG = LogFactory.getLog(PersistenceUtility.class);
-
- private static final Pattern COUNT_QUERY_PATTERN = Pattern.compile("^(\\s*SELECT\\s+)(.*?)(\\s+FROM.*)",
- Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
- private static final Pattern COUNT_QUERY_REMOVE_FETCH = Pattern.compile("FETCH", Pattern.CASE_INSENSITIVE
- | Pattern.MULTILINE | Pattern.DOTALL);
-
- public static final String HIBERNATE_STATISTICS_MBEAN_OBJECTNAME = "Hibernate:type=statistics,application=RHQ";
-
- @SuppressWarnings("unchecked")
- // used in hibernate.jsp
- public static String getDisplayString(Type hibernateType) {
- if (hibernateType instanceof EntityType) {
- return hibernateType.getName() + " (enter integer of ID / primary key field)";
- } else if (hibernateType instanceof CustomType) {
- if (Enum.class.isAssignableFrom(hibernateType.getReturnedClass())) {
- Class<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>) hibernateType.getReturnedClass();
- StringBuilder result = new StringBuilder();
- result.append(enumClass.getName());
- result.append(" (");
- boolean first = true;
- for (Enum<?> nextEnum : enumClass.getEnumConstants()) {
- if (!first) {
- result.append(" | ");
- } else {
- first = false;
- }
- result.append(nextEnum.name());
- }
- result.append(")");
- return result.toString();
- }
- }
- return hibernateType == null ? "" : hibernateType.getName();
- }
-
- @SuppressWarnings("unchecked")
- // used in hibernate.jsp
- public static Object cast(String value, Type hibernateType) {
- if (hibernateType instanceof PrimitiveType) {
- Class<?> type = ((PrimitiveType) hibernateType).getPrimitiveClass();
- if (type.equals(Byte.TYPE)) {
- return Byte.valueOf(value);
- } else if (type.equals(Short.TYPE)) {
- return Short.valueOf(value);
- } else if (type.equals(Integer.TYPE)) {
- return Integer.valueOf(value);
- } else if (type.equals(Long.TYPE)) {
- return Long.valueOf(value);
- } else if (type.equals(Float.TYPE)) {
- return Float.valueOf(value);
- } else if (type.equals(Double.TYPE)) {
- return Double.valueOf(value);
- } else if (type.equals(Boolean.TYPE)) {
- return Boolean.valueOf(value);
- }
- } else if (hibernateType instanceof EntityType) {
- String entityName = ((EntityType) hibernateType).getAssociatedEntityName();
- try {
- Class<?> entityClass = Class.forName(entityName);
- Object entity = entityClass.newInstance();
-
- Field primaryKeyField = entityClass.getDeclaredField("id");
- primaryKeyField.setAccessible(true);
- primaryKeyField.setInt(entity, Integer.valueOf(value));
- return entity;
- } catch (Throwable t) {
- throw new IllegalArgumentException("Type[" + entityName + "] must have PK field named 'id'");
- }
- } else if (hibernateType instanceof CustomType) {
- if (Enum.class.isAssignableFrom(hibernateType.getReturnedClass())) {
- Class<? extends Enum<?>> enumClass = hibernateType.getReturnedClass();
- Enum<?>[] enumValues = enumClass.getEnumConstants();
- try {
- int enumOrdinal = Integer.valueOf(value);
- try {
- return enumValues[enumOrdinal];
- } catch (ArrayIndexOutOfBoundsException aioobe) {
- throw new IllegalArgumentException("There is no " + enumClass.getSimpleName()
- + " enum with ordinal '" + enumOrdinal + "'");
- }
- } catch (NumberFormatException nfe) {
- String ucaseValue = value.toUpperCase();
- for (Enum<?> nextEnum : enumValues) {
- if (nextEnum.name().toUpperCase().equals(ucaseValue)) {
- return nextEnum;
- }
- }
- throw new IllegalArgumentException("There is no " + enumClass.getSimpleName() + " enum with name '"
- + value + "'");
- }
- }
- }
- return value;
- }
-
- /**
- * Used to create queries to use with the {@link org.rhq.core.domain.util.PageControl} objects. The query will already have its sort column
- * and order appended as well as having its first result and max results set according to the page control data.
- *
- * @param entityManager your entity manager
- * @param queryName name of the query
- * @param pageControl the controls on the paging and sorting
- *
- * @return a preconfigured query for ordered pagination
- */
- public static Query createQueryWithOrderBy(EntityManager entityManager, String queryName, PageControl pageControl) {
- Query query;
-
- if (pageControl.getPrimarySortColumn() != null) {
- query = createQueryWithOrderBy(entityManager, queryName, pageControl.getOrderingFieldsAsArray());
- } else {
- StackTraceElement caller = new Throwable().fillInStackTrace().getStackTrace()[1];
- LOG.warn("Queries should really supply default sort columns. Caller did not: " + caller);
-
- // Use the standard named query if no sorting is specified
- query = entityManager.createNamedQuery(queryName);
- }
-
- setDataPage(query, pageControl);
-
- return query;
- }
-
- /**
- * Create a query from a named query with a transformed order by clause with multiple new ordery by clauses.
- *
- * @param entityManager the entity manager to build the query against
- * @param queryName the name of the query to transform
- * @param orderByFields an array of clauses to contribute to the order by
- *
- * @return the transformed query
- */
- public static Query createQueryWithOrderBy(EntityManager entityManager, String queryName,
- OrderingField... orderByFields) {
- NamedQueryDefinition ndc = getNamedQueryDefinition(entityManager, queryName);
- StringBuilder query = new StringBuilder(ndc.getQueryString());
- buildOrderBy(query, orderByFields);
- return entityManager.createQuery(query.toString());
- }
-
- private static StringBuilder buildOrderBy(StringBuilder query, OrderingField... orderByFields) {
- boolean first = true;
- for (OrderingField orderingField : orderByFields) {
- if (first) {
- // TODO GH: We could see if there already is an order by clause and contribute or override it
- query.append(" ORDER BY ");
- first = false;
- } else {
- query.append(", ");
- }
-
- query.append(orderingField.getField()).append(" ").append(orderingField.getOrdering());
- }
-
- return query;
- }
-
- private static String getOrderByFragment(OrderingField... orderByFields) {
- boolean first = true;
- StringBuilder builder = new StringBuilder();
- for (OrderingField orderingField : orderByFields) {
- if (first) {
- builder.append(" ORDER BY ");
- first = false;
- } else {
- builder.append(", ");
- }
-
- builder.append(orderingField.getField()).append(" ").append(orderingField.getOrdering());
- }
-
- return builder.toString();
- }
-
- /**
- * Builds a count(*) version of the named query so we don't have duplicate all our queries to use two query
- * pagination model.
- *
- * @param em the entity manager to build the query for
- * @param queryName the NamedQuery to transform
- *
- * @return a query that can be bound and executed to get the total count of results
- */
- public static Query createCountQuery(EntityManager em, String queryName) {
- return createCountQuery(em, queryName, "*");
- }
-
- /**
- * Builds a count(*) version of the named query so we don't have duplicate all our queries to use two query
- * pagination model.
- *
- * @param entityManager the entity manager to build the query for
- * @param queryName the NamedQuery to transform
- * @param countItem the object or attribute that needs to be counted, when it's ambiguous
- *
- * @return a query that can be bound and executed to get the total count of results
- */
- public static Query createCountQuery(EntityManager entityManager, String queryName, String countItem) {
- NamedQueryDefinition namedQueryDefinition = getNamedQueryDefinition(entityManager, queryName);
- String query = namedQueryDefinition.getQueryString();
-
- Matcher matcher = COUNT_QUERY_PATTERN.matcher(query);
- if (!matcher.find()) {
- throw new RuntimeException("Unable to transform query into count query [" + queryName + " - " + query + "]");
- }
-
- String newQuery = matcher.group(1) + "COUNT(" + countItem + ")" + matcher.group(3);
-
- matcher = COUNT_QUERY_REMOVE_FETCH.matcher(newQuery);
- if (matcher.find()) {
- StringBuffer buffer = new StringBuffer();
- do {
- matcher.appendReplacement(buffer, "");
- } while (matcher.find());
- matcher.appendTail(buffer);
- newQuery = buffer.toString();
- }
- if (LOG.isTraceEnabled()) {
- LOG.trace("Transformed query to count query [" + queryName + "] resulting in [" + newQuery + "]");
- }
-
- return entityManager.createQuery(newQuery);
- }
-
- public static void setDataPage(Query query, PageControl pageControl) {
- if (pageControl.getPageSize() > 0) {
- query.setFirstResult(pageControl.getStartRow());
- query.setMaxResults(pageControl.getPageSize());
- }
- }
-
- /**
- * Creates and executes a filter query for a collection relationship. This executes without passing back the query
- * object because the most common case is to simply paginate for a relationship. Use the createFilter method to
- * create more generic filters and get access to the hibernate query object for setting parameters etc.
- *
- * @param entityManager
- * @param collection
- * @param pageControl
- *
- * @return the result list of the entities from the filtered relationship
- */
- @SuppressWarnings("unchecked")
- public static PageList createPaginationFilter(EntityManager entityManager, Collection collection,
- PageControl pageControl) {
- if (collection == null) {
- return new PageList(pageControl);
- }
-
- String filter = "";
- if (pageControl.getPrimarySortColumn() != null) {
- PageOrdering order = (pageControl.getPrimarySortOrder() == null) ? PageOrdering.ASC : pageControl
- .getPrimarySortOrder();
- filter = getOrderByFragment(new OrderingField(pageControl.getPrimarySortColumn(), order));
- }
-
- org.hibernate.Query query = getHibernateSession(entityManager).createFilter(collection, filter);
- if (pageControl.getPageSize() > 0) {
- query.setFirstResult(pageControl.getPageNumber() * pageControl.getPageSize());
- query.setMaxResults(pageControl.getPageSize());
- }
-
- // TODO GH: Always flushing is probably not what we really want here
- // relationship filters don't seem to cause the proper flush, so manually flush
- getHibernateSession(entityManager).flush();
-
- // TODO GH: This can only create unbounded PageLists since I don't know how to do a count query to find the size
- return new PageList<Object>(query.list(), pageControl);
- }
-
- /**
- * Use this inside subclasses as a convenience method.
- */
- @SuppressWarnings("unchecked")
- public static <T> List<T> findByCriteria(EntityManager entityManager, Class<T> type,
- org.hibernate.criterion.Criterion... criterion) {
- // Using Hibernate, more difficult with EntityManager and EJB-QL
- org.hibernate.Criteria crit = getHibernateSession(entityManager).createCriteria(type);
- for (org.hibernate.criterion.Criterion c : criterion) {
- crit.add(c);
- }
-
- return crit.list();
- }
-
- public static Session getHibernateSession(EntityManager entityManager) {
- Session session;
- if (entityManager.getDelegate() instanceof EntityManagerImpl) {
- EntityManagerImpl entityManagerImpl = (EntityManagerImpl) entityManager.getDelegate();
- session = entityManagerImpl.getSession();
- } else {
- session = (Session) entityManager.getDelegate();
- }
-
- return session;
- }
-
- /**
- * Enables the hibernate statistics mbean to provide access to information on the ejb3 persistence tier.
- *
- * @param entityManager an inject entity manager whose session factory will be tracked with these statistics
- * @param server the MBeanServer where the statistics MBean should be registered; if <code>null</code>, the
- * first one in the list returned by MBeanServerFactory.findMBeanServer(null) is used
- */
- public static void enableHibernateStatistics(EntityManager entityManager, MBeanServer server) {
- try {
- SessionFactory sessionFactory = PersistenceUtility.getHibernateSession(entityManager).getSessionFactory();
-
- if (server == null) {
- ArrayList<MBeanServer> list = MBeanServerFactory.findMBeanServer(null);
- server = list.get(0);
- }
-
- ObjectName objectName = new ObjectName(HIBERNATE_STATISTICS_MBEAN_OBJECTNAME);
- StatisticsService mBean = new StatisticsService();
- mBean.setSessionFactory(sessionFactory);
- server.registerMBean(mBean, objectName);
- sessionFactory.getStatistics().setStatisticsEnabled(true);
- } catch (InstanceAlreadyExistsException iaee) {
- LOG.info("Duplicate mbean registration ignored: " + HIBERNATE_STATISTICS_MBEAN_OBJECTNAME);
- } catch (Exception e) {
- LOG.warn("Couldn't register hibernate statistics mbean", e);
- }
- }
-
- public static Statistics getStatisticsService(EntityManager entityManager, MBeanServer server) {
- Session hibernateSession = PersistenceUtility.getHibernateSession(entityManager);
- SessionFactory hibernateSessionFactory = hibernateSession.getSessionFactory();
- Statistics hibernateStatistics = hibernateSessionFactory.getStatistics();
- return hibernateStatistics;
- }
-
- private static NamedQueryDefinition getNamedQueryDefinition(EntityManager entityManager, String queryName) {
- SessionFactoryImplementor sessionFactory = getHibernateSessionFactoryImplementor(entityManager);
- NamedQueryDefinition namedQueryDefinition = sessionFactory.getNamedQuery(queryName);
- if (namedQueryDefinition == null) {
- throw new RuntimeException("EJB3 query not found [" + queryName + "]");
- }
-
- return namedQueryDefinition;
- }
-
- private static SessionFactoryImplementor getHibernateSessionFactoryImplementor(EntityManager entityManager) {
- Session session = getHibernateSession(entityManager);
- SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) session.getSessionFactory();
- return sessionFactory;
- }
-
- // wanted to combine postgres and oracle methods, but org.rhq.core.db.DatabaseType objects are not visible to domain
- public static String addPostgresNativePagingSortingToQuery(String query, PageControl pageControl) {
- return addLimitOffsetToQuery(query, pageControl);
- }
-
- // wanted to combine postgres and oracle methods, but org.rhq.core.db.DatabaseType objects are not visible to domain
- public static String addOracleNativePagingSortingToQuery(String query, PageControl pageControl) {
- StringBuilder queryWithPagingSorting = new StringBuilder(query.length() + 50);
-
- int minRowNum = pageControl.getStartRow() + 1;
- int maxRowNum = minRowNum + pageControl.getPageSize() - 1;
-
- // pagination calculations based off of double-projection of the results
- queryWithPagingSorting.append("SELECT outerResults.* FROM ( ");
-
- queryWithPagingSorting.append("SELECT innerResults.*, ROWNUM rnum FROM ( ");
- queryWithPagingSorting.append(query);
- // for oracle, order by occurs at the end of the original query, whether grouped or not
- queryWithPagingSorting.append(getOrderByFragment(pageControl.getOrderingFieldsAsArray()));
- queryWithPagingSorting.append(" ) innerResults ");
-
- // for oracle, paginate high off of the inner projection
- queryWithPagingSorting.append(" WHERE ROWNUM <= ").append(maxRowNum);
-
- // for oracle, paginate low off of the outer projection
- queryWithPagingSorting.append(" ) outerResults ");
- queryWithPagingSorting.append(" WHERE rnum >= ").append(minRowNum);
-
- return queryWithPagingSorting.toString();
- }
-
- /**
- * Note: always put the rownum column at the END of the columns, so that code
- * which relies on index-based access to the result set data doesn't break
- *
- * Method 1:
- *
- * SELECT outerResults.* FROM (
- * SELECT innerResults.*,
- * ROW_NUMBER() OVER( {orderByClause} ) AS rownum
- * FROM ( {queryWithoutOrderBy} ) AS innerResults
- * ) AS outerResults
- * WHERE rownum <= maxRowNum AND rownum >= minRowNum
- *
- * The above method fails in circumstances where the orderByClause is built up with
- * aliases that aren't in the explicit select list returned from queryWithoutOrderBy
- *
- *
- * Method 2:
- *
- * Fix above shortcomings by pushing the orderByClause into the actual select list
- *
- * SELECT singleResults.* FROM (
- * {queryWithoutOrderBySelectList}
- * , ROW_NUMBER() OVER( {orderByClause} ) AS rownum
- * {queryWithoutOrderByRestOfQuery}
- * ) AS singleResults
- * WHERE rownum <= maxRowNum AND rownum >= minRowNum
- *
- *
- * Actually, both of the above methods have small flaws. The first can not sort by columns that
- * aren't in the explicit return list. The second can not sort by computed columns and subqueries
- * in the select list. The only way I see how this can work is by modifying the queryWithoutOrderBy
- * to explicitly return all parameters that will be sorted on (even if the use case wouldn't normally
- * require them to be in the select list), alias them, and order by the aliases by modifying the web
- * ui code to use those tokens when generating the sortable column headers (jmarques - June/2009)
- */
- public static String addSQLServerNativePagingSortingToQuery(String query, PageControl pageControl) {
- return addSQLServerNativePagingSortingToQuery(query, pageControl, false);
- }
-
- public static String addSQLServerNativePagingSortingToQuery(String query, PageControl pageControl,
- boolean alternatePagingStyle) {
- StringBuilder queryWithPagingSorting = new StringBuilder(query.length() + 50);
-
- int minRowNum = pageControl.getStartRow() + 1;
- int maxRowNum = minRowNum + pageControl.getPageSize() - 1;
-
- String orderByClause = getOrderByFragment(pageControl.getOrderingFieldsAsArray());
-
- if (alternatePagingStyle) {
- int index = findSelectListEndIndex(query);
- String selectList = query.substring(0, index);
- String restOfQuery = query.substring(index);
- queryWithPagingSorting.append("SELECT singleResults.* FROM ( ");
- queryWithPagingSorting.append(selectList);
- queryWithPagingSorting.append(", ROW_NUMBER() OVER( " + orderByClause + " ) AS rownum ");
- queryWithPagingSorting.append(restOfQuery);
- queryWithPagingSorting.append(") AS singleResults ");
- } else {
- queryWithPagingSorting.append("SELECT outerResults.* FROM ( ");
- queryWithPagingSorting.append(" SELECT innerResults.*, ");
- queryWithPagingSorting.append(" ROW_NUMBER() OVER( " + orderByClause + " ) AS rownum ");
- queryWithPagingSorting.append(" FROM ( " + query + " ) AS innerResults ");
- queryWithPagingSorting.append(" ) AS outerResults ");
- }
- queryWithPagingSorting.append("WHERE rownum <= ").append(maxRowNum);
- queryWithPagingSorting.append(" AND rownum >= ").append(minRowNum);
-
- return queryWithPagingSorting.toString();
- }
-
- // beginning of from clause (not counting retrievals via subqueries) should indicate end of select list
- private static int findSelectListEndIndex(String query) {
- int nesting = 0;
- query = query.toLowerCase();
- StringBuilder wordBuffer = new StringBuilder();
- for (int i = 0; i < query.length(); i++) {
- char next = query.charAt(i);
- if (next == '(') {
- nesting++;
- } else if (next == ')') {
- nesting--;
- } else {
- if (nesting != 0) {
- continue;
- }
- if (Character.isLetter(next)) {
- wordBuffer.append(next);
- if (wordBuffer.toString().equals("from")) {
- return i - 4; // return index representing the character just before "from"
- }
- } else {
- wordBuffer.setLength(0); // clear buffer if we find any non-letter
- }
- }
- }
- throw new IllegalArgumentException("Could not find select list end index");
- }
-
- // wanted to combine postgres and oracle methods, but org.rhq.core.db.DatabaseType objects are not visible to domain
- public static String addH2NativePagingSortingToQuery(String query, PageControl pageControl) {
- return addLimitOffsetToQuery(query, pageControl);
- }
-
- private static String addLimitOffsetToQuery(String query, PageControl pageControl) {
- StringBuilder queryWithPagingSorting = new StringBuilder(query.length() + 50);
- queryWithPagingSorting.append(query);
-
- // for postgres, first order by
- queryWithPagingSorting.append(getOrderByFragment(pageControl.getOrderingFieldsAsArray()));
-
- // for postgres, then paginate
- queryWithPagingSorting.append(" LIMIT ").append(pageControl.getPageSize());
- queryWithPagingSorting.append(" OFFSET ").append(pageControl.getStartRow());
-
- return queryWithPagingSorting.toString();
- }
-}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
index 57aba89..754d331 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
@@ -90,9 +90,9 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.GroupDefinition;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.exception.ThrowableUtil;
@SuppressWarnings("unchecked")
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/ExternalizableStrategyCommandPreprocessor.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/ExternalizableStrategyCommandPreprocessor.java
index 8eef33b..a6c520f 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/ExternalizableStrategyCommandPreprocessor.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/ExternalizableStrategyCommandPreprocessor.java
@@ -18,7 +18,7 @@
*/
package org.rhq.enterprise.agent;
-import org.rhq.core.server.ExternalizableStrategy;
+import org.rhq.core.domain.server.ExternalizableStrategy;
import org.rhq.enterprise.communications.command.Command;
import org.rhq.enterprise.communications.command.client.ClientCommandSender;
import org.rhq.enterprise.communications.command.client.CommandPreprocessor;
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml
index 1be06f4..c8a85f0 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml
@@ -35,6 +35,7 @@
<!-- Exclude any domain classes that can not be used client-side due to use of unsupported class use -->
<exclude name="**/JPADriftFileBits.*"/> <!-- a server-side entity that requires SQL Blob support -->
<exclude name="sync/**"/> <!-- a server-side package used by the CLI to export system settings -->
+ <exclude name="server/**"/> <!-- a server-side package -->
</source>
<!--<generate-with class="org.rhq.core.rebind.RecordBuilderGenerator">
diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
index ae64ec4..1ee1741 100644
--- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
+++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
@@ -671,7 +671,7 @@ public class ConfigurationBean {
dialect = "org.hibernate.dialect.Oracle10gDialect";
quartzDriverDelegateClass = "org.quartz.impl.jdbcjobstore.oracle.OracleDelegate";
} else if (db.toLowerCase().indexOf("h2") > -1) {
- dialect = "org.rhq.core.server.H2CustomDialect";
+ dialect = "org.rhq.core.domain.server.H2CustomDialect";
} else if (db.toLowerCase().indexOf("sqlserver") > -1) {
dialect = "org.hibernate.dialect.SQLServerDialect";
quartzDriverDelegateClass = "org.quartz.impl.jdbcjobstore.MSSQLDelegate";
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/ExternalizableStrategyCommandListener.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/ExternalizableStrategyCommandListener.java
index 7ca48b2..2833c9e 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/ExternalizableStrategyCommandListener.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/ExternalizableStrategyCommandListener.java
@@ -18,7 +18,7 @@
*/
package org.rhq.enterprise.gui.startup;
-import org.rhq.core.server.ExternalizableStrategy;
+import org.rhq.core.domain.server.ExternalizableStrategy;
import org.rhq.enterprise.communications.command.Command;
import org.rhq.enterprise.communications.command.CommandResponse;
import org.rhq.enterprise.communications.command.client.CommandPreprocessor;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
index 8b94c7b..651129c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
@@ -376,7 +376,7 @@ public class StartupServlet extends HttpServlet {
.getServiceContainer()
.addCommandListener(
new ExternalizableStrategyCommandListener(
- org.rhq.core.server.ExternalizableStrategy.Subsystem.AGENT));
+ org.rhq.core.domain.server.ExternalizableStrategy.Subsystem.AGENT));
} catch (Exception e) {
throw new ServletException("Cannot start the server-side communications services.", e);
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/StatisticsUtility.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/StatisticsUtility.java
index 0a6bb59..be34373 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/StatisticsUtility.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/StatisticsUtility.java
@@ -23,7 +23,7 @@ import org.hibernate.stat.Statistics;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.server.PersistenceUtility;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.enterprise.server.util.LookupUtil;
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/browser.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/browser.jsp
index 67587db..e379377 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/browser.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/browser.jsp
@@ -1,7 +1,7 @@
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="org.hibernate.engine.SessionFactoryImplementor" %>
-<%@ page import="org.rhq.core.server.PersistenceUtility" %>
+<%@ page import="org.rhq.core.domain.server.PersistenceUtility" %>
<%@ page import="org.rhq.enterprise.gui.legacy.util.SessionUtils" %>
<%@ page import="org.rhq.enterprise.server.util.LookupUtil" %>
<%@ page import="javax.naming.InitialContext" %>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
index 0261703..1fbc38d 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
@@ -3,7 +3,7 @@
<%@ page import="java.util.Map" %>
<%@ page import="org.rhq.core.domain.auth.Subject" %>
-<%@ page import="org.rhq.core.server.PersistenceUtility" %>
+<%@ page import="org.rhq.core.domain.server.PersistenceUtility" %>
<%@ page import="org.rhq.enterprise.gui.legacy.util.SessionUtils"%>
<%@ page import="org.rhq.enterprise.gui.util.WebUtility"%>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/hibernate.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/hibernate.jsp
index c151a34..ce3f671 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/hibernate.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/hibernate.jsp
@@ -7,7 +7,7 @@
<%@ page import="org.hibernate.type.IntegerType" %>
<%@ page import="org.hibernate.type.LongType" %>
<%@ page import="org.hibernate.type.Type" %>
-<%@ page import="org.rhq.core.server.PersistenceUtility" %>
+<%@ page import="org.rhq.core.domain.server.PersistenceUtility" %>
<%@ page import="org.rhq.enterprise.gui.legacy.util.SessionUtils" %>
<%@ page import="org.rhq.enterprise.server.util.LookupUtil" %>
<%@ page import="javax.naming.InitialContext" %>
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/clientapi/RemoteClientProxy.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/clientapi/RemoteClientProxy.java
index a3daeb7..e9751c2 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/clientapi/RemoteClientProxy.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/clientapi/RemoteClientProxy.java
@@ -29,7 +29,7 @@ import org.jboss.remoting.invocation.NameBasedInvocation;
import org.rhq.bindings.client.AbstractRhqFacadeProxy;
import org.rhq.bindings.client.RhqManagers;
import org.rhq.bindings.util.InterfaceSimplifier;
-import org.rhq.core.server.ExternalizableStrategy;
+import org.rhq.core.domain.server.ExternalizableStrategy;
/**
* This class acts as a local SLSB proxy to make remote invocations
diff --git a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java
index 73ef3e3..bb132fe 100644
--- a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java
+++ b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java
@@ -52,8 +52,8 @@ import org.rhq.core.domain.drift.JPADrift;
import org.rhq.core.domain.drift.JPADriftChangeSet;
import org.rhq.core.domain.drift.JPADriftFile;
import org.rhq.core.domain.drift.JPADriftSet;
+import org.rhq.core.domain.server.EntitySerializer;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.EntitySerializer;
import org.rhq.test.AssertUtils;
import org.rhq.test.TransactionCallback;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/agentclient/impl/AgentClientImpl.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/agentclient/impl/AgentClientImpl.java
index 76d9c3e..219af8d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/agentclient/impl/AgentClientImpl.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/agentclient/impl/AgentClientImpl.java
@@ -28,7 +28,7 @@ import org.rhq.core.clientapi.agent.measurement.MeasurementAgentService;
import org.rhq.core.clientapi.agent.operation.OperationAgentService;
import org.rhq.core.clientapi.agent.support.SupportAgentService;
import org.rhq.core.domain.resource.Agent;
-import org.rhq.core.server.ExternalizableStrategy;
+import org.rhq.core.domain.server.ExternalizableStrategy;
import org.rhq.enterprise.communications.Ping;
import org.rhq.enterprise.communications.command.Command;
import org.rhq.enterprise.communications.command.CommandResponse;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
index fa38154..fa03aaf 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
@@ -38,9 +38,9 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.composite.AbstractAlertConditionCategoryComposite;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index db954c4..79fca41 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -48,10 +48,10 @@ import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.NumericType;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.alert.engine.AlertDefinitionEvent;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
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 38230af..672a2c9 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
@@ -67,10 +67,10 @@ 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.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.server.MeasurementConverter;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
index d8ce44e..94f1d35 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
@@ -37,10 +37,10 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
index 79bdec2..8974c30 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
@@ -39,10 +39,10 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
index 966a960..334b546 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
@@ -55,9 +55,9 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
index 6413b89..00fefd2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
@@ -43,9 +43,9 @@ import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.core.domain.resource.group.LdapGroup;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/AffinityGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/AffinityGroupManagerBean.java
index 8cf985b..2ebbdab 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/AffinityGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/AffinityGroupManagerBean.java
@@ -38,9 +38,9 @@ import org.rhq.core.domain.cloud.PartitionEventType;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.cloud.composite.AffinityGroupCountComposite;
import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.RequiredPermission;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java
index 4b98c67..01faa80 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java
@@ -39,9 +39,9 @@ import org.rhq.core.domain.cloud.PartitionEventType;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.cloud.composite.ServerWithAgentCountComposite;
import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/PartitionEventManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/PartitionEventManagerBean.java
index 8eb345b..147dbc0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/PartitionEventManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/PartitionEventManagerBean.java
@@ -43,10 +43,10 @@ import org.rhq.core.domain.cloud.PartitionEventType;
import org.rhq.core.domain.cloud.PartitionEvent.ExecutionStatus;
import org.rhq.core.domain.cloud.composite.FailoverListComposite;
import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.core.AgentManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index f88d2ba..d29eaac 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -97,11 +97,11 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.core.util.exception.ThrowableUtil;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
index 03530e9..c8f12e9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
@@ -38,9 +38,9 @@ import org.rhq.core.domain.content.AdvisoryCVE;
import org.rhq.core.domain.content.AdvisoryPackage;
import org.rhq.core.domain.content.CVE;
import org.rhq.core.domain.content.PackageVersion;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.RequiredPermission;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
index 5f65afb..3f42ef7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
@@ -94,10 +94,10 @@ import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.ProductVersion;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.stream.StreamUtil;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index b14ca51..2455c49 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -50,11 +50,11 @@ import org.rhq.core.domain.content.composite.LoadedPackageBitsComposite;
import org.rhq.core.domain.content.composite.PackageListItemComposite;
import org.rhq.core.domain.content.composite.PackageVersionComposite;
import org.rhq.core.domain.criteria.InstalledPackageHistoryCriteria;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
index 959b321..4a7c2f2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
@@ -69,10 +69,10 @@ import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
index d851761..5a7d750 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
@@ -53,9 +53,9 @@ import org.rhq.core.domain.common.composite.SystemSetting;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.composite.AgentLastAvailabilityPingComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.RHQConstants;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index f74b287..ce4e6a7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -71,10 +71,10 @@ import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.core.domain.resource.ResourceErrorType;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
index ec1c956..75894ad 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
@@ -49,10 +49,10 @@ import org.rhq.core.domain.measurement.ResourceAvailability;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceIdWithAvailabilityComposite;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.StopWatch;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
index dfaf5e8..82c1915 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
@@ -55,10 +55,10 @@ import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.calltime.CallTimeData;
import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
import org.rhq.core.domain.measurement.calltime.CallTimeDataValue;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
index 7a70948..32567f0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
@@ -74,10 +74,10 @@ import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.jdbc.JDBCUtil;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java
index 0bf42d3..cdfb7cc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java
@@ -51,10 +51,10 @@ import org.rhq.core.domain.measurement.MeasurementDataPK;
import org.rhq.core.domain.measurement.MeasurementOOB;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java
index d398141..2804936 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java
@@ -32,10 +32,10 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index 69a22db..77956e1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -78,11 +78,11 @@ 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.ResourceType;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
index 4c007ae..d95bd9f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
@@ -77,10 +77,10 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java
index d11cc03..8d5ca9a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java
@@ -35,7 +35,7 @@ import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.invocation.NameBasedInvocation;
-import org.rhq.core.server.ExternalizableStrategy;
+import org.rhq.core.domain.server.ExternalizableStrategy;
import org.rhq.core.util.exception.WrappedRemotingException;
import org.rhq.enterprise.server.safeinvoker.HibernateDetachUtility;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteWsInvocationHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteWsInvocationHandler.java
index 22cbddb..16c2195 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteWsInvocationHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteWsInvocationHandler.java
@@ -27,7 +27,7 @@ import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.invocation.NameBasedInvocation;
-import org.rhq.core.server.ExternalizableStrategy;
+import org.rhq.core.domain.server.ExternalizableStrategy;
import org.rhq.enterprise.server.safeinvoker.HibernateDetachUtility;
public class RemoteWsInvocationHandler implements ServerInvocationHandler {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
index 6c016e7..214e46a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
@@ -58,10 +58,10 @@ import org.rhq.core.domain.resource.DeleteResourceStatus;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
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 6339eda..468f619 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
@@ -109,9 +109,9 @@ import org.rhq.core.domain.resource.flyweight.FlyweightCache;
import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.IntExtractor;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.server.RHQConstants;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
index 2f00d16..eeeb4fc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
@@ -51,9 +51,9 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.common.composite.SystemSetting;
import org.rhq.core.domain.resource.group.LdapGroup;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index eb493c3..d808969 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -76,10 +76,10 @@ import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index 8cc810f..3776c70 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -41,9 +41,9 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
import org.rhq.core.domain.resource.group.GroupDefinition;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/AlertSubsystemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/AlertSubsystemManagerBean.java
index 6adb7e2..823c9f2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/AlertSubsystemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/AlertSubsystemManagerBean.java
@@ -37,10 +37,10 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.composite.AlertDefinitionComposite;
import org.rhq.core.domain.alert.composite.AlertHistoryComposite;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/ConfigurationSubsystemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/ConfigurationSubsystemManagerBean.java
index 6e6da2b..ff9ae0f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/ConfigurationSubsystemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/ConfigurationSubsystemManagerBean.java
@@ -30,10 +30,10 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.composite.ConfigurationUpdateComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.util.QueryUtility;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/OperationHistorySubsystemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/OperationHistorySubsystemManagerBean.java
index fbc7923..17a4ed4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/OperationHistorySubsystemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/subsystem/OperationHistorySubsystemManagerBean.java
@@ -30,10 +30,10 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.operation.composite.ResourceOperationHistoryComposite;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.util.QueryUtility;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
index c3c26f2..849dfba 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
@@ -65,7 +65,7 @@ import org.rhq.core.domain.common.SystemConfiguration;
import org.rhq.core.domain.common.composite.SystemSetting;
import org.rhq.core.domain.common.composite.SystemSettings;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
-import org.rhq.core.server.PersistenceUtility;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.util.ObjectNameFactory;
import org.rhq.core.util.StopWatch;
import org.rhq.enterprise.server.RHQConstants;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/CoreTestBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/CoreTestBean.java
index c56e395..be872ae 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/CoreTestBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/CoreTestBean.java
@@ -36,7 +36,7 @@ import org.rhq.core.clientapi.server.core.AgentRegistrationResults;
import org.rhq.core.clientapi.server.core.CoreServerService;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.resource.Agent;
-import org.rhq.core.server.PersistenceUtility;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.core.CoreServerServiceImpl;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/DiscoveryTestBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/DiscoveryTestBean.java
index 6ac5be2..9fb1661 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/DiscoveryTestBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/DiscoveryTestBean.java
@@ -50,7 +50,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.server.PersistenceUtility;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.core.CoreServerServiceImpl;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 9511e63..54fce8f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -48,11 +48,11 @@ import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.search.SearchSubsystem;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.server.search.SearchExpressionException;
import org.rhq.enterprise.server.search.execution.SearchTranslationManager;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java
index 7c58b43..96394ce 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java
@@ -30,7 +30,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.stat.Statistics;
-import org.rhq.core.server.PersistenceUtility;
+import org.rhq.core.domain.server.PersistenceUtility;
/**
* @author Joseph Marques
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java
index 742adf9..d429bc8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java
@@ -25,7 +25,7 @@ import javax.persistence.EntityManager;
import org.hibernate.stat.Statistics;
-import org.rhq.core.server.PersistenceUtility;
+import org.rhq.core.domain.server.PersistenceUtility;
/**
* @author Joseph Marques
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index 43c1401..4647e1b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -50,7 +50,7 @@ import org.jboss.mx.util.MBeanServerLocator;
import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.db.PostgresqlDatabaseType;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.server.PersistenceUtility;
+import org.rhq.core.domain.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SessionManager;
import org.rhq.enterprise.server.content.ContentSourceManagerBean;
11 years, 8 months