[rhq] modules/core modules/enterprise
by lkrejci
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java | 2 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java | 19 +++-------
2 files changed, 6 insertions(+), 15 deletions(-)
New commits:
commit 4d895c6794fc8b746e4f8c2f7593b7deaa083d76
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Jan 14 14:25:40 2011 +0100
Fix the discrepancy between the return type of the query ResourceType.FIND_ALL_TEMPLATE_COUNT_COMPOSITES and the type expected in the code.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
index 947bf62..9e0ce28 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
@@ -96,8 +96,6 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = ResourceType.FIND_CHILDREN_BY_PARENT, query = "SELECT DISTINCT rt FROM ResourceType AS rt "
+ "JOIN FETCH rt.parentResourceTypes AS pa " + // also fetch parents, as we need them later
"WHERE rt.deleted = false and pa IN (:resourceType)"),
- // template count composites need the parent types fetched; however, because of a quirk in hibernate,
- // we can't use the template component constructor in the select, we'll build the composites in our code
@NamedQuery(name = ResourceType.FIND_ALL_TEMPLATE_COUNT_COMPOSITES, query = "" //
+ "SELECT new org.rhq.core.domain.resource.composite.ResourceTypeTemplateCountComposite" //
+ "(" //
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
index b4086b9..e225f7e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
@@ -391,23 +391,19 @@ public class ResourceTypeManagerBean implements ResourceTypeManagerLocal, Resour
ResourceFacetsCache.getSingleton().reload(facets);
}
- @SuppressWarnings("unchecked")
public Map<Integer, ResourceTypeTemplateCountComposite> getTemplateCountCompositeMap() {
Query templateCountQuery = entityManager.createNamedQuery(ResourceType.FIND_ALL_TEMPLATE_COUNT_COMPOSITES);
- // the weirdness here is because we needed to JOIN FETCH the parent types, but hibernate bombs when you do that
- // and try to use a composite constructor in the query itself. We need to build the composites here.
- // Our results will be a list of arrays that we'll build into the composite below
- List<?> results = templateCountQuery.getResultList();
+
+ @SuppressWarnings("unchecked")
+ List<ResourceTypeTemplateCountComposite> results = (List<ResourceTypeTemplateCountComposite>) templateCountQuery.getResultList();
// we don't need to send all the data in resource types over the wire, so we'll be scrubbing the types
// to avoid the scrubbed types getting persisted back to the db, let's clear the persistence context
entityManager.clear();
Map<Integer, ResourceTypeTemplateCountComposite> compositeMap = new HashMap<Integer, ResourceTypeTemplateCountComposite>();
- for (Object result : results) {
- Object[] array = (Object[]) result;
-
- ResourceType type = (ResourceType) array[0];
+ for (ResourceTypeTemplateCountComposite result : results) {
+ ResourceType type = result.getType();
// scrub it to avoid sending data over the wire we don't need
// some of these are eagerly loaded, but my paranoia says assume everything is eagerly loaded to purge it all
@@ -427,10 +423,7 @@ public class ResourceTypeManagerBean implements ResourceTypeManagerLocal, Resour
type.setResources(null);
type.setSubCategory(null);
- ResourceTypeTemplateCountComposite composite = new ResourceTypeTemplateCountComposite(type,
- ((Number) array[1]).longValue(), ((Number) array[2]).longValue(), ((Number) array[3]).longValue(),
- ((Number) array[4]).longValue());
- compositeMap.put(composite.getType().getId(), composite);
+ compositeMap.put(type.getId(), result);
}
return compositeMap;
13 years, 4 months
[rhq] Branch 'release-3.0.0' - modules/common modules/core modules/enterprise modules/helpers modules/plugins modules/pom.xml modules/test-utils pom.xml
by John Sanda
modules/common/ant-bundle/pom.xml | 2 +-
modules/common/filetemplate-bundle/pom.xml | 2 +-
modules/common/jboss-as/pom.xml | 2 +-
modules/common/pom.xml | 2 +-
modules/core/client-api/pom.xml | 2 +-
modules/core/comm-api/pom.xml | 2 +-
modules/core/dbutils/pom.xml | 2 +-
modules/core/domain/pom.xml | 2 +-
modules/core/gui/pom.xml | 2 +-
modules/core/native-system/pom.xml | 2 +-
modules/core/plugin-api/pom.xml | 2 +-
modules/core/plugin-container/pom.xml | 2 +-
modules/core/plugin-validator/pom.xml | 2 +-
modules/core/plugindoc/pom.xml | 2 +-
modules/core/pom.xml | 2 +-
modules/core/util/pom.xml | 2 +-
modules/enterprise/agent/pom.xml | 2 +-
modules/enterprise/agentupdate/pom.xml | 2 +-
modules/enterprise/comm/pom.xml | 2 +-
modules/enterprise/gui/base-perspective-jar/pom.xml | 2 +-
modules/enterprise/gui/base-perspective-war/pom.xml | 2 +-
modules/enterprise/gui/content_http-war/pom.xml | 2 +-
modules/enterprise/gui/coregui/pom.xml | 2 +-
modules/enterprise/gui/installer-war/pom.xml | 2 +-
modules/enterprise/gui/pom.xml | 2 +-
modules/enterprise/gui/portal-war/pom.xml | 2 +-
modules/enterprise/gui/webdav-war/pom.xml | 2 +-
modules/enterprise/pom.xml | 2 +-
modules/enterprise/remoting/cli/pom.xml | 2 +-
modules/enterprise/remoting/client-api/pom.xml | 2 +-
modules/enterprise/remoting/pom.xml | 2 +-
modules/enterprise/remoting/webservices/pom.xml | 2 +-
modules/enterprise/server/container-lib/pom.xml | 2 +-
modules/enterprise/server/container/pom.xml | 2 +-
modules/enterprise/server/ear/pom.xml | 2 +-
modules/enterprise/server/jar/pom.xml | 2 +-
modules/enterprise/server/plugins/alert-email/pom.xml | 2 +-
modules/enterprise/server/plugins/alert-irc/pom.xml | 2 +-
modules/enterprise/server/plugins/alert-microblog/pom.xml | 2 +-
modules/enterprise/server/plugins/alert-mobicents/pom.xml | 2 +-
modules/enterprise/server/plugins/alert-operations/pom.xml | 2 +-
modules/enterprise/server/plugins/alert-roles/pom.xml | 2 +-
modules/enterprise/server/plugins/alert-snmp/pom.xml | 2 +-
modules/enterprise/server/plugins/alert-subject/pom.xml | 2 +-
modules/enterprise/server/plugins/ant-bundle/pom.xml | 2 +-
modules/enterprise/server/plugins/cobbler/pom.xml | 2 +-
modules/enterprise/server/plugins/disk/pom.xml | 2 +-
modules/enterprise/server/plugins/filetemplate-bundle/pom.xml | 2 +-
modules/enterprise/server/plugins/jboss-software/pom.xml | 2 +-
modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml | 2 +-
modules/enterprise/server/plugins/perspectives/core/pom.xml | 2 +-
modules/enterprise/server/plugins/pom.xml | 2 +-
modules/enterprise/server/plugins/rhnhosted/pom.xml | 2 +-
modules/enterprise/server/plugins/url/pom.xml | 2 +-
modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml | 2 +-
modules/enterprise/server/plugins/yum/pom.xml | 2 +-
modules/enterprise/server/safe-invoker/pom.xml | 2 +-
modules/enterprise/server/sars/agent-sar/pom.xml | 2 +-
modules/enterprise/server/sars/pom.xml | 2 +-
modules/enterprise/server/xml-schemas/pom.xml | 2 +-
modules/helpers/pluginAnnotations/pom.xml | 2 +-
modules/helpers/pluginGen/pom.xml | 2 +-
modules/helpers/pom.xml | 2 +-
modules/helpers/rtfilter/pom.xml | 2 +-
modules/plugins/aliases/pom.xml | 2 +-
modules/plugins/ant-bundle/pom.xml | 2 +-
modules/plugins/apache/pom.xml | 2 +-
modules/plugins/augeas/pom.xml | 2 +-
modules/plugins/cobbler/pom.xml | 2 +-
modules/plugins/cron/pom.xml | 2 +-
modules/plugins/database/pom.xml | 2 +-
modules/plugins/filetemplate-bundle/pom.xml | 2 +-
modules/plugins/grub/pom.xml | 2 +-
modules/plugins/hibernate/pom.xml | 2 +-
modules/plugins/hosts/pom.xml | 2 +-
modules/plugins/hudson/pom.xml | 2 +-
modules/plugins/iis/pom.xml | 2 +-
modules/plugins/jboss-as-5/pom.xml | 2 +-
modules/plugins/jboss-as/pom.xml | 2 +-
modules/plugins/jboss-cache-v3/pom.xml | 2 +-
modules/plugins/jboss-cache/pom.xml | 2 +-
modules/plugins/jmx/pom.xml | 2 +-
modules/plugins/mysql/pom.xml | 2 +-
modules/plugins/netservices/pom.xml | 2 +-
modules/plugins/oracle/pom.xml | 2 +-
modules/plugins/perftest/pom.xml | 2 +-
modules/plugins/platform/pom.xml | 2 +-
modules/plugins/pom.xml | 2 +-
modules/plugins/postfix/pom.xml | 2 +-
modules/plugins/postgres/pom.xml | 2 +-
modules/plugins/rhq-agent/pom.xml | 2 +-
modules/plugins/rhq-server/pom.xml | 2 +-
modules/plugins/samba/pom.xml | 2 +-
modules/plugins/script/pom.xml | 2 +-
modules/plugins/snmptrapd/pom.xml | 2 +-
modules/plugins/sshd/pom.xml | 2 +-
modules/plugins/sudoers/pom.xml | 2 +-
modules/plugins/tomcat/pom.xml | 2 +-
modules/plugins/twitter/pom.xml | 2 +-
modules/plugins/validate-all-plugins/pom.xml | 2 +-
modules/pom.xml | 2 +-
modules/test-utils/pom.xml | 2 +-
pom.xml | 2 +-
103 files changed, 103 insertions(+), 103 deletions(-)
New commits:
commit ef158c9236c8bafdafaf07373b34af2080066218
Author: root <root(a)localhost.localdomain>
Date: Fri Jan 14 03:14:10 2011 -0500
[maven-release-plugin] prepare for next development iteration
diff --git a/modules/common/ant-bundle/pom.xml b/modules/common/ant-bundle/pom.xml
index 6479a13..0833b2a 100644
--- a/modules/common/ant-bundle/pom.xml
+++ b/modules/common/ant-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-common-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/common/filetemplate-bundle/pom.xml b/modules/common/filetemplate-bundle/pom.xml
index 59e5802..7f7127c 100644
--- a/modules/common/filetemplate-bundle/pom.xml
+++ b/modules/common/filetemplate-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-common-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/common/jboss-as/pom.xml b/modules/common/jboss-as/pom.xml
index 45c4f50..d69311c 100644
--- a/modules/common/jboss-as/pom.xml
+++ b/modules/common/jboss-as/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-common-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index dec6fd5..c6a6dab 100644
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index b513ee5..ae391f8 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/comm-api/pom.xml b/modules/core/comm-api/pom.xml
index 60d3e07..f52e92d 100644
--- a/modules/core/comm-api/pom.xml
+++ b/modules/core/comm-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index c16f709..7892321 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index bac6316..700912d 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/gui/pom.xml b/modules/core/gui/pom.xml
index f8c262e..5293ae1 100644
--- a/modules/core/gui/pom.xml
+++ b/modules/core/gui/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/native-system/pom.xml b/modules/core/native-system/pom.xml
index 9b3197e..b3a20e2 100644
--- a/modules/core/native-system/pom.xml
+++ b/modules/core/native-system/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/plugin-api/pom.xml b/modules/core/plugin-api/pom.xml
index 90fba0e..d9c8d4c 100644
--- a/modules/core/plugin-api/pom.xml
+++ b/modules/core/plugin-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/plugin-container/pom.xml b/modules/core/plugin-container/pom.xml
index afd763d..bc886fe 100644
--- a/modules/core/plugin-container/pom.xml
+++ b/modules/core/plugin-container/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/plugin-validator/pom.xml b/modules/core/plugin-validator/pom.xml
index 67d1da9..dfcdfde 100644
--- a/modules/core/plugin-validator/pom.xml
+++ b/modules/core/plugin-validator/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/plugindoc/pom.xml b/modules/core/plugindoc/pom.xml
index b426bcb..5831bc4 100644
--- a/modules/core/plugindoc/pom.xml
+++ b/modules/core/plugindoc/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index e754b38..b895d04 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/util/pom.xml b/modules/core/util/pom.xml
index 6761e16..405eaed 100644
--- a/modules/core/util/pom.xml
+++ b/modules/core/util/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/agent/pom.xml b/modules/enterprise/agent/pom.xml
index e258e39..70d6f6e 100644
--- a/modules/enterprise/agent/pom.xml
+++ b/modules/enterprise/agent/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/agentupdate/pom.xml b/modules/enterprise/agentupdate/pom.xml
index 605b27d..342369a 100644
--- a/modules/enterprise/agentupdate/pom.xml
+++ b/modules/enterprise/agentupdate/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/comm/pom.xml b/modules/enterprise/comm/pom.xml
index d851e50..93931da 100644
--- a/modules/enterprise/comm/pom.xml
+++ b/modules/enterprise/comm/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/base-perspective-jar/pom.xml b/modules/enterprise/gui/base-perspective-jar/pom.xml
index 737fed8..172ba27 100644
--- a/modules/enterprise/gui/base-perspective-jar/pom.xml
+++ b/modules/enterprise/gui/base-perspective-jar/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/base-perspective-war/pom.xml b/modules/enterprise/gui/base-perspective-war/pom.xml
index cc6da1b..d3c0764 100644
--- a/modules/enterprise/gui/base-perspective-war/pom.xml
+++ b/modules/enterprise/gui/base-perspective-war/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
index f67485c..57a30b9 100644
--- a/modules/enterprise/gui/content_http-war/pom.xml
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-gui-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 17b8008..82cddb6 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 53318ad..9a29f14 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/pom.xml b/modules/enterprise/gui/pom.xml
index 96820af..072ac8f 100644
--- a/modules/enterprise/gui/pom.xml
+++ b/modules/enterprise/gui/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/portal-war/pom.xml b/modules/enterprise/gui/portal-war/pom.xml
index 70ba9e9..cd485f1 100644
--- a/modules/enterprise/gui/portal-war/pom.xml
+++ b/modules/enterprise/gui/portal-war/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/webdav-war/pom.xml b/modules/enterprise/gui/webdav-war/pom.xml
index eea48bd..095ada1 100644
--- a/modules/enterprise/gui/webdav-war/pom.xml
+++ b/modules/enterprise/gui/webdav-war/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/pom.xml b/modules/enterprise/pom.xml
index a7a0de3..89f283c 100644
--- a/modules/enterprise/pom.xml
+++ b/modules/enterprise/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/remoting/cli/pom.xml b/modules/enterprise/remoting/cli/pom.xml
index 2dd7010..5453a41 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>rhq-remoting-cli</artifactId>
diff --git a/modules/enterprise/remoting/client-api/pom.xml b/modules/enterprise/remoting/client-api/pom.xml
index 4d9b29b..1bc500a 100644
--- a/modules/enterprise/remoting/client-api/pom.xml
+++ b/modules/enterprise/remoting/client-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>rhq-remoting-client-api</artifactId>
diff --git a/modules/enterprise/remoting/pom.xml b/modules/enterprise/remoting/pom.xml
index 44f056d..3879afd 100644
--- a/modules/enterprise/remoting/pom.xml
+++ b/modules/enterprise/remoting/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>rhq-remoting-parent</artifactId>
diff --git a/modules/enterprise/remoting/webservices/pom.xml b/modules/enterprise/remoting/webservices/pom.xml
index bd168be..393d2e9 100644
--- a/modules/enterprise/remoting/webservices/pom.xml
+++ b/modules/enterprise/remoting/webservices/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>rhq-remoting-webservices</artifactId>
diff --git a/modules/enterprise/server/container-lib/pom.xml b/modules/enterprise/server/container-lib/pom.xml
index 89de04e..9a2a929 100644
--- a/modules/enterprise/server/container-lib/pom.xml
+++ b/modules/enterprise/server/container-lib/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index f39320e..4748aa3 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index b4e152d..5e8343f 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 4e7d957..a897a53 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/alert-email/pom.xml b/modules/enterprise/server/plugins/alert-email/pom.xml
index 16d1c57..b51ba25 100644
--- a/modules/enterprise/server/plugins/alert-email/pom.xml
+++ b/modules/enterprise/server/plugins/alert-email/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-irc/pom.xml b/modules/enterprise/server/plugins/alert-irc/pom.xml
index 8df30ea..471e73f 100644
--- a/modules/enterprise/server/plugins/alert-irc/pom.xml
+++ b/modules/enterprise/server/plugins/alert-irc/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-microblog/pom.xml b/modules/enterprise/server/plugins/alert-microblog/pom.xml
index 75ef3eb..c8235e7 100644
--- a/modules/enterprise/server/plugins/alert-microblog/pom.xml
+++ b/modules/enterprise/server/plugins/alert-microblog/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-mobicents/pom.xml b/modules/enterprise/server/plugins/alert-mobicents/pom.xml
index 43679f4..40bc578 100644
--- a/modules/enterprise/server/plugins/alert-mobicents/pom.xml
+++ b/modules/enterprise/server/plugins/alert-mobicents/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-operations/pom.xml b/modules/enterprise/server/plugins/alert-operations/pom.xml
index ce2aa4c..232f907 100644
--- a/modules/enterprise/server/plugins/alert-operations/pom.xml
+++ b/modules/enterprise/server/plugins/alert-operations/pom.xml
@@ -2,7 +2,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-roles/pom.xml b/modules/enterprise/server/plugins/alert-roles/pom.xml
index fabe19a..43cd398 100644
--- a/modules/enterprise/server/plugins/alert-roles/pom.xml
+++ b/modules/enterprise/server/plugins/alert-roles/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-snmp/pom.xml b/modules/enterprise/server/plugins/alert-snmp/pom.xml
index 19f9532..7e6da01 100644
--- a/modules/enterprise/server/plugins/alert-snmp/pom.xml
+++ b/modules/enterprise/server/plugins/alert-snmp/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-subject/pom.xml b/modules/enterprise/server/plugins/alert-subject/pom.xml
index 103332f..6ba6f85 100644
--- a/modules/enterprise/server/plugins/alert-subject/pom.xml
+++ b/modules/enterprise/server/plugins/alert-subject/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/ant-bundle/pom.xml b/modules/enterprise/server/plugins/ant-bundle/pom.xml
index a5502ab..45280cd 100644
--- a/modules/enterprise/server/plugins/ant-bundle/pom.xml
+++ b/modules/enterprise/server/plugins/ant-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/cobbler/pom.xml b/modules/enterprise/server/plugins/cobbler/pom.xml
index 6ac95b6..d816e25 100644
--- a/modules/enterprise/server/plugins/cobbler/pom.xml
+++ b/modules/enterprise/server/plugins/cobbler/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/disk/pom.xml b/modules/enterprise/server/plugins/disk/pom.xml
index 1091107..621f3e5 100644
--- a/modules/enterprise/server/plugins/disk/pom.xml
+++ b/modules/enterprise/server/plugins/disk/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml b/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
index 87ddd11..da8e8e7 100644
--- a/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
+++ b/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/jboss-software/pom.xml b/modules/enterprise/server/plugins/jboss-software/pom.xml
index c76da08..8d1e368 100644
--- a/modules/enterprise/server/plugins/jboss-software/pom.xml
+++ b/modules/enterprise/server/plugins/jboss-software/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml b/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml
index 25b65b0..f5fbeb1 100644
--- a/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml
+++ b/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/perspectives/core/pom.xml b/modules/enterprise/server/plugins/perspectives/core/pom.xml
index ca1bd76..b7f3be7 100644
--- a/modules/enterprise/server/plugins/perspectives/core/pom.xml
+++ b/modules/enterprise/server/plugins/perspectives/core/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/pom.xml b/modules/enterprise/server/plugins/pom.xml
index db1c2b0..07be817 100644
--- a/modules/enterprise/server/plugins/pom.xml
+++ b/modules/enterprise/server/plugins/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/rhnhosted/pom.xml b/modules/enterprise/server/plugins/rhnhosted/pom.xml
index ac0a8a7..c1187d1 100644
--- a/modules/enterprise/server/plugins/rhnhosted/pom.xml
+++ b/modules/enterprise/server/plugins/rhnhosted/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/url/pom.xml b/modules/enterprise/server/plugins/url/pom.xml
index 4e4c973..9ada86c 100644
--- a/modules/enterprise/server/plugins/url/pom.xml
+++ b/modules/enterprise/server/plugins/url/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml b/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml
index ac80b24..ab4f217 100644
--- a/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml
+++ b/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/yum/pom.xml b/modules/enterprise/server/plugins/yum/pom.xml
index 94e8fe0..243eed4 100644
--- a/modules/enterprise/server/plugins/yum/pom.xml
+++ b/modules/enterprise/server/plugins/yum/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/safe-invoker/pom.xml b/modules/enterprise/server/safe-invoker/pom.xml
index 75a3ba8..24dd98a 100644
--- a/modules/enterprise/server/safe-invoker/pom.xml
+++ b/modules/enterprise/server/safe-invoker/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/sars/agent-sar/pom.xml b/modules/enterprise/server/sars/agent-sar/pom.xml
index 99d3efd..e933c81 100644
--- a/modules/enterprise/server/sars/agent-sar/pom.xml
+++ b/modules/enterprise/server/sars/agent-sar/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-sars-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/sars/pom.xml b/modules/enterprise/server/sars/pom.xml
index f78308e..786cead 100644
--- a/modules/enterprise/server/sars/pom.xml
+++ b/modules/enterprise/server/sars/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/xml-schemas/pom.xml b/modules/enterprise/server/xml-schemas/pom.xml
index 94f0b1c..5990106 100644
--- a/modules/enterprise/server/xml-schemas/pom.xml
+++ b/modules/enterprise/server/xml-schemas/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/helpers/pluginAnnotations/pom.xml b/modules/helpers/pluginAnnotations/pom.xml
index 226e657..8dab254 100644
--- a/modules/helpers/pluginAnnotations/pom.xml
+++ b/modules/helpers/pluginAnnotations/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-helpers</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq.helpers</groupId>
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index 78376ca..41d2820 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-helpers</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq.helpers</groupId>
diff --git a/modules/helpers/pom.xml b/modules/helpers/pom.xml
index 23489ee..154fc0f 100644
--- a/modules/helpers/pom.xml
+++ b/modules/helpers/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq.helpers</groupId>
diff --git a/modules/helpers/rtfilter/pom.xml b/modules/helpers/rtfilter/pom.xml
index 0590691..99ece1c 100644
--- a/modules/helpers/rtfilter/pom.xml
+++ b/modules/helpers/rtfilter/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-helpers</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/aliases/pom.xml b/modules/plugins/aliases/pom.xml
index 668b04f..0370302 100644
--- a/modules/plugins/aliases/pom.xml
+++ b/modules/plugins/aliases/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/ant-bundle/pom.xml b/modules/plugins/ant-bundle/pom.xml
index bc39c40..d7e6d8a 100644
--- a/modules/plugins/ant-bundle/pom.xml
+++ b/modules/plugins/ant-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/apache/pom.xml b/modules/plugins/apache/pom.xml
index b233031..9f46fc9 100644
--- a/modules/plugins/apache/pom.xml
+++ b/modules/plugins/apache/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/augeas/pom.xml b/modules/plugins/augeas/pom.xml
index 326d781..4a78b61 100644
--- a/modules/plugins/augeas/pom.xml
+++ b/modules/plugins/augeas/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/cobbler/pom.xml b/modules/plugins/cobbler/pom.xml
index 38facb0..1082bb3 100644
--- a/modules/plugins/cobbler/pom.xml
+++ b/modules/plugins/cobbler/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/cron/pom.xml b/modules/plugins/cron/pom.xml
index 4339a94..9371766 100644
--- a/modules/plugins/cron/pom.xml
+++ b/modules/plugins/cron/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/database/pom.xml b/modules/plugins/database/pom.xml
index 41c5e57..c72f79a 100644
--- a/modules/plugins/database/pom.xml
+++ b/modules/plugins/database/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/filetemplate-bundle/pom.xml b/modules/plugins/filetemplate-bundle/pom.xml
index d80f1ab..0b85a57 100644
--- a/modules/plugins/filetemplate-bundle/pom.xml
+++ b/modules/plugins/filetemplate-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/grub/pom.xml b/modules/plugins/grub/pom.xml
index c4fd8da..d783ffc 100644
--- a/modules/plugins/grub/pom.xml
+++ b/modules/plugins/grub/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/hibernate/pom.xml b/modules/plugins/hibernate/pom.xml
index d9fcc13..a7bac31 100644
--- a/modules/plugins/hibernate/pom.xml
+++ b/modules/plugins/hibernate/pom.xml
@@ -6,7 +6,7 @@
<groupId>org.rhq</groupId>
<!-- Bypass the jopr-plugins-parent which can not have children. It must build after the plugins in order to execute integration tests on them. -->
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/hosts/pom.xml b/modules/plugins/hosts/pom.xml
index a317231..ef32374 100644
--- a/modules/plugins/hosts/pom.xml
+++ b/modules/plugins/hosts/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/hudson/pom.xml b/modules/plugins/hudson/pom.xml
index 84acc4d..285f316 100644
--- a/modules/plugins/hudson/pom.xml
+++ b/modules/plugins/hudson/pom.xml
@@ -6,7 +6,7 @@
<parent>
<artifactId>rhq-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/iis/pom.xml b/modules/plugins/iis/pom.xml
index 0d3a151..ad90e83 100644
--- a/modules/plugins/iis/pom.xml
+++ b/modules/plugins/iis/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/jboss-as-5/pom.xml b/modules/plugins/jboss-as-5/pom.xml
index 12f7eb1..2766efd 100644
--- a/modules/plugins/jboss-as-5/pom.xml
+++ b/modules/plugins/jboss-as-5/pom.xml
@@ -9,7 +9,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/jboss-as/pom.xml b/modules/plugins/jboss-as/pom.xml
index a12be62..31d5fbc 100644
--- a/modules/plugins/jboss-as/pom.xml
+++ b/modules/plugins/jboss-as/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/jboss-cache-v3/pom.xml b/modules/plugins/jboss-cache-v3/pom.xml
index f3f9e8b..b09a9aa 100644
--- a/modules/plugins/jboss-cache-v3/pom.xml
+++ b/modules/plugins/jboss-cache-v3/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/jboss-cache/pom.xml b/modules/plugins/jboss-cache/pom.xml
index f57dc5c..e9dca27 100644
--- a/modules/plugins/jboss-cache/pom.xml
+++ b/modules/plugins/jboss-cache/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/jmx/pom.xml b/modules/plugins/jmx/pom.xml
index 4445455..83e3030 100644
--- a/modules/plugins/jmx/pom.xml
+++ b/modules/plugins/jmx/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/mysql/pom.xml b/modules/plugins/mysql/pom.xml
index a6cedd0..5152236 100644
--- a/modules/plugins/mysql/pom.xml
+++ b/modules/plugins/mysql/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/netservices/pom.xml b/modules/plugins/netservices/pom.xml
index 04b4394..67d24a0 100644
--- a/modules/plugins/netservices/pom.xml
+++ b/modules/plugins/netservices/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/oracle/pom.xml b/modules/plugins/oracle/pom.xml
index 25f88ff..be37d2b 100644
--- a/modules/plugins/oracle/pom.xml
+++ b/modules/plugins/oracle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/perftest/pom.xml b/modules/plugins/perftest/pom.xml
index 45527e8..136770c 100644
--- a/modules/plugins/perftest/pom.xml
+++ b/modules/plugins/perftest/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/platform/pom.xml b/modules/plugins/platform/pom.xml
index b4c643c..5597a30 100644
--- a/modules/plugins/platform/pom.xml
+++ b/modules/plugins/platform/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml
index 5928440..4859ad7 100644
--- a/modules/plugins/pom.xml
+++ b/modules/plugins/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/postfix/pom.xml b/modules/plugins/postfix/pom.xml
index 9f193c9..2130abe 100644
--- a/modules/plugins/postfix/pom.xml
+++ b/modules/plugins/postfix/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/postgres/pom.xml b/modules/plugins/postgres/pom.xml
index d72ce50..beab355 100644
--- a/modules/plugins/postgres/pom.xml
+++ b/modules/plugins/postgres/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/rhq-agent/pom.xml b/modules/plugins/rhq-agent/pom.xml
index 4e545b3..3aa3bb6 100644
--- a/modules/plugins/rhq-agent/pom.xml
+++ b/modules/plugins/rhq-agent/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/rhq-server/pom.xml b/modules/plugins/rhq-server/pom.xml
index 5e3af16..d0ef9fe 100644
--- a/modules/plugins/rhq-server/pom.xml
+++ b/modules/plugins/rhq-server/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/samba/pom.xml b/modules/plugins/samba/pom.xml
index 59bc78f..a338a98 100644
--- a/modules/plugins/samba/pom.xml
+++ b/modules/plugins/samba/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/script/pom.xml b/modules/plugins/script/pom.xml
index ba0ce39..05cb816 100644
--- a/modules/plugins/script/pom.xml
+++ b/modules/plugins/script/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/snmptrapd/pom.xml b/modules/plugins/snmptrapd/pom.xml
index dd4b39d..89178cc 100644
--- a/modules/plugins/snmptrapd/pom.xml
+++ b/modules/plugins/snmptrapd/pom.xml
@@ -2,7 +2,7 @@
<parent>
<artifactId>rhq-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/plugins/sshd/pom.xml b/modules/plugins/sshd/pom.xml
index 30decd7..a68e444 100644
--- a/modules/plugins/sshd/pom.xml
+++ b/modules/plugins/sshd/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/sudoers/pom.xml b/modules/plugins/sudoers/pom.xml
index 6e28cce..0353f4f 100644
--- a/modules/plugins/sudoers/pom.xml
+++ b/modules/plugins/sudoers/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/tomcat/pom.xml b/modules/plugins/tomcat/pom.xml
index f40e5d7..4c93bb3 100644
--- a/modules/plugins/tomcat/pom.xml
+++ b/modules/plugins/tomcat/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/twitter/pom.xml b/modules/plugins/twitter/pom.xml
index cf40656..9adaca6 100644
--- a/modules/plugins/twitter/pom.xml
+++ b/modules/plugins/twitter/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/validate-all-plugins/pom.xml b/modules/plugins/validate-all-plugins/pom.xml
index dcf2aa5..4f1c4c3 100644
--- a/modules/plugins/validate-all-plugins/pom.xml
+++ b/modules/plugins/validate-all-plugins/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/pom.xml b/modules/pom.xml
index d163344..e363555 100644
--- a/modules/pom.xml
+++ b/modules/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/test-utils/pom.xml b/modules/test-utils/pom.xml
index da3a64b..5f96131 100644
--- a/modules/test-utils/pom.xml
+++ b/modules/test-utils/pom.xml
@@ -4,7 +4,7 @@
<parent>
<artifactId>rhq-modules-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>test-utils</artifactId>
<name>RHQ Test Utils</name>
diff --git a/pom.xml b/pom.xml
index da17bca..46ae63b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.0.0.QA</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>RHQ</name>
13 years, 4 months
[rhq] Changes to 'refs/tags/RHQ_4_0_0_QA'
by John Sanda
Tag 'RHQ_4_0_0_QA' created by root <root(a)localhost.localdomain> at 2011-01-14 08:13 +0000
[maven-release-plugin] copy for tag RHQ_4_0_0_QA
Changes since 3_0_1_EC2_B01:
Filip Drabek (14):
BZ - 617603,617649,617653 - permission checks.
Merge branch 'release-3.0.0' of ssh://git.fedorahosted.org/git/rhq/rhq into release-3.0.0
BZ-617649 'DELETE SELECTED' button visible only when you can MODIFY_RESOURCE.
BZ-617649 permissions update
BZ-550046 (httpd) new virtual host creation fails if Resource Name is string.
reverting of BZ-648790 - user needs only View Group permission to see Group Plugin Configuration Update
BZ-618314 - fix of apache tests
BZ-642641 fix issue in collecting metrics after metric template update.
Merge branch 'release-3.0.0' of ssh://git.fedorahosted.org/git/rhq/rhq into release-3.0.0
BZ-655149 Deleting resource plugin config update from audit trail checks wrong permission.
BZ 535772 Internet Explorer (IE) problem with Advanced Settings
BZ 638216 - (AS5 plugin) Reconecting to profile service when connection is defunct.
Merge branch 'release-3.0.0' of ssh://git.fedorahosted.org/git/rhq/rhq into release-3.0.0
BZ 638216 - fix for AS4 messaging components - logging and collection of metrics
Heiko W. Rupp (3):
BZ 614300 - Add a notification type for the trap itself
BZ 663987 - disable direct path insert for the key, as direct path insert does not support select(<same table>) in the same Tx.
Enable tests again and pull over some fixes that have been issued on master already.
Ian Springer (4):
make PC more forgiving if a discovery component returns a Resource details
only ask discovery components for additional classpath URLs (i.e. client jars) if per-resource classloaders are enabled in the plugin container config
jboss-as-5 plugin: jboss-reflect.jar is required by some profileservice client calls and so should be included in the list of client jars returned by ApplicationServerDiscoveryComponent.getAdditionalClasspathUrls() (https://bugzilla.redhat.com/show_bug.cgi?id=647669)
comment out some code that was causing the following unit test failure:
Jay Shaughnessy (5):
Perf Work on the AS-5 Plugin to try and reduce avail and metric gathering
Fix dependency
remove explicit path from dep lib
[BZ 655187]
[BZ-610859] Fix issue in AS5 plugin discovery component that initializes
John Mazzitelli (6):
BZ 650201 - increase collection intervals - they should be no less than 10m
we need to remove the disabled resource's IDs from the callers set - removing resources from our internal resource set is useless
clean up some things that we forgot to clean up at shutdown - to help GC
BZ 615377 workaround sun bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6727821
BZ 615377 - use a new feature in EMS 1.2.13 that lets us clear the EMS classloader factory cache of classloaders and jar files. we now do this in the jmx plugin lifecycle listener.
paranoia - we might hit sun bug http://bugs.sun.com/view_bug.do?bug_id=6735255 so we explicitly close the input stream prior to closing the jar file
John Sanda (14):
[maven-release-plugin] prepare for next development iteration
[BZ 536549] Removing unused js code
Revert "[maven-release-plugin] prepare release 3_0_1_EC2_B01"
Merge branch 'ec2' into release-3.0.0
Putting build number generation plugins in profile to facilitate building in mead
Adding profile to generate build number by specifying it manually
[BZ 614251] Making multiple changes so that live metric data can be fetched and displayed
[BZ 614251] Forgot to include updated interface in previous commit
[BZ 619781] Handling more scenarios for settting connection properties to default values
Adding version to gmaven plugin in pluginManagement section
Merge branch 'release-3.0.0' of ssh://git.fedorahosted.org/git/rhq/rhq into release-3.0.0
Applying brew build patches
Upgrading release plugin to version 2.1
Make sure release number gets included in artifacts in brew builds
Joseph Marques (2):
BZ-649057: re-introduce AvailabilityReport customized serialization for performance
BZ-661203: improve inventory browser load efficiency
Lukas Krejci (33):
fix for the rare NPE in the disambiguation which could happen in the views that contained multiple results for single resource (e.g. list of alert history across all resources)
BZ 642588 - config is reloaded if ServerRoot is redefined in config
BZ 642591 - make sure we always have the same resource keys as in old plugin version.
BZ 642610 - directives found in included files aren't duplicated anymore
BZ 642622 - Adding the ability to extract the scheme and port from the ServerName so that proper ping URLs can be discovered.
BZ 617218 - always passing in the -d <serverroot> -f <conf-file> as parameters to the apache control script so that a correct instance is acted upon.
formatting
Refactored the ScriptDiscoveryComponent to use ManulAddFacet instead of the deprecated mechanism.
formatting
BZ 568917 - Enable creation of as5 scripts by uploading them to the server's bin. Also added support to delete arbitrary script.
removed a wrong @Override annotation so that this actually compiles in Java5.
BZ 651826 - Do not log the connection failures during auto-discovery on INFO level.
Code formatting
Removed unnecessary method in the postgres discovery component.
mvn package apparently isn't enough to check that something compiles :(
BZ 568917 - Implementing ContentFacet on ScriptComponent so that the support for uploading a new script is complete.
BZ 643919 - Unspecified condition (that appears after clicking "Add Another Condition") doesn't cause an exception on alert saving. A proper error message appears instead.
BZ 655156 - cherrypick of commit f6409557d36ab77f8baa69cb4dc4d11c5fedc39c with
a couple of robustness enhancements to the apache plugin:
BZ 657232
BZ 618214 - Create a temporary entry in RHQ_PLUGIN table for the snmp-alert plugin in case we need to add something to its configuration during db-upgrade.
BZ 659578 - Upgrade the Seam version to 2.2.1.CR2 to address the security vulnerability https://jira.jboss.org/browse/JBSEAM-4676. Also remove the custom SeamELResolver.class that contained a couple of fixes not present in 2.1.0.SP1.
BZ 610859 - Deleting an entry from a property list doesn't confuse the unset properties anymore.
BZ 659778 - fixing an NPE while adding a new entry into an open map.
BZ 662662 - restore the ability to view/edit open maps by "faking" property definitions for the individual properties in the open map.
BZ 663377 - Updating group config doesn't introduce "foreign" properties in open maps of individual resources.
BZ 656471 - add index on the timestamp of the RHQ_MEASUREMENT_DATA_NUM_1D table to speed up the data compression
BZ 663745 - refactor the apache discovery to continue processing the rest of process scan results after an error during processing one of them.
BZ 656471 - adding missing index definition in db setup.
BZ 665215 - xml-escaping the stacktraces to protect against XSS via malicious code inserted into the exception messages.
code formatting
BZ 665855 - try to find the control script file only on the OSes that actually have a chance of having it.
BZ 663998 - Write out an INFO message when a database plugin is about to be updated by a new version with different file name.
root (1):
[maven-release-plugin] prepare release RHQ_4_0_0_QA
---
.classpath | 2
dev/null |binary
modules/common/ant-bundle/pom.xml | 2
modules/common/filetemplate-bundle/pom.xml | 2
modules/common/jboss-as/pom.xml | 2
modules/common/pom.xml | 2
modules/core/client-api/pom.xml | 2
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/measurement/MeasurementAgentService.java | 4
modules/core/comm-api/pom.xml | 2
modules/core/dbutils/pom.xml | 4
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java | 163
modules/core/dbutils/src/main/scripts/dbsetup/cluster-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml | 5
modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml | 4
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 55
modules/core/domain/pom.xml | 2
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/discovery/AvailabilityReport.java | 141
modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataRequest.java | 61
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/Group.java | 65
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java | 33
modules/core/domain/src/test/java/org/rhq/core/domain/test/SerializableTest.java | 2
modules/core/gui/pom.xml | 4
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java | 6
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/ConfigurationUtility.java | 11
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java | 8
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/ConfigurationSet.java | 75
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java | 2
modules/core/native-system/pom.xml | 2
modules/core/plugin-api/pom.xml | 2
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java | 41
modules/core/plugin-container/pom.xml | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java | 23
modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 8
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 30
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java | 13
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java | 15
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java | 7
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java | 7
modules/core/plugin-validator/pom.xml | 2
modules/core/plugindoc/pom.xml | 38
modules/core/pom.xml | 2
modules/core/util/pom.xml | 2
modules/enterprise/agent/pom.xml | 40
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java | 16
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/AvailabilityPromptCommand.java | 20
modules/enterprise/agentupdate/pom.xml | 2
modules/enterprise/comm/pom.xml | 2
modules/enterprise/gui/base-perspective-jar/pom.xml | 6
modules/enterprise/gui/base-perspective-war/pom.xml | 2
modules/enterprise/gui/content_http-war/pom.xml | 2
modules/enterprise/gui/coregui/pom.xml | 2
modules/enterprise/gui/installer-war/pom.xml | 2
modules/enterprise/gui/pom.xml | 2
modules/enterprise/gui/portal-war/pom.xml | 4
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/metric/MetricRenderer.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/group/EditGroupResourceConfigurationUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationAddNewOpenMapMemberPropertyUIBean.java | 18
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ResourceConfigurationViewer.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/EditTestConfigurationUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupPluginConfigurationUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java | 10
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/GroupController.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/condition/ConverterValidatorManager.java | 7
modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties | 1
modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp | 8
modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp | 6
modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js | 118
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/DefinitionCondition.jsp | 4
modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/inventory/connectionHistory.xhtml | 3
modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/inventory/view.xhtml | 3
modules/enterprise/gui/webdav-war/pom.xml | 2
modules/enterprise/pom.xml | 2
modules/enterprise/remoting/cli/pom.xml | 2
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java | 4
modules/enterprise/remoting/client-api/pom.xml | 2
modules/enterprise/remoting/pom.xml | 2
modules/enterprise/remoting/webservices/pom.xml | 2
modules/enterprise/server/container-lib/pom.xml | 2
modules/enterprise/server/container/pom.xml | 4
modules/enterprise/server/container/src/main/resources/etc/RHQ-mib.txt | 58
modules/enterprise/server/ear/pom.xml | 4
modules/enterprise/server/jar/pom.xml | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 159
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java | 15
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java | 20
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 | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 67
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java | 15
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java | 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 65
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/test/DiscoveryTestBean.java | 6
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java | 36
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java | 8
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java | 7
modules/enterprise/server/plugins/alert-email/pom.xml | 2
modules/enterprise/server/plugins/alert-irc/pom.xml | 2
modules/enterprise/server/plugins/alert-microblog/pom.xml | 2
modules/enterprise/server/plugins/alert-mobicents/pom.xml | 2
modules/enterprise/server/plugins/alert-operations/pom.xml | 3
modules/enterprise/server/plugins/alert-roles/pom.xml | 3
modules/enterprise/server/plugins/alert-snmp/pom.xml | 2
modules/enterprise/server/plugins/alert-subject/pom.xml | 3
modules/enterprise/server/plugins/ant-bundle/pom.xml | 2
modules/enterprise/server/plugins/cobbler/pom.xml | 2
modules/enterprise/server/plugins/disk/pom.xml | 2
modules/enterprise/server/plugins/filetemplate-bundle/pom.xml | 2
modules/enterprise/server/plugins/jboss-software/pom.xml | 2
modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml | 2
modules/enterprise/server/plugins/perspectives/core/pom.xml | 2
modules/enterprise/server/plugins/pom.xml | 2
modules/enterprise/server/plugins/rhnhosted/pom.xml | 2
modules/enterprise/server/plugins/url/pom.xml | 2
modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml | 2
modules/enterprise/server/plugins/yum/pom.xml | 2
modules/enterprise/server/safe-invoker/pom.xml | 2
modules/enterprise/server/sars/agent-sar/pom.xml | 2
modules/enterprise/server/sars/pom.xml | 2
modules/enterprise/server/xml-schemas/pom.xml | 2
modules/helpers/pluginAnnotations/pom.xml | 2
modules/helpers/pluginGen/pom.xml | 2
modules/helpers/pom.xml | 2
modules/helpers/rtfilter/pom.xml | 2
modules/plugins/aliases/pom.xml | 2
modules/plugins/ant-bundle/pom.xml | 2
modules/plugins/apache/pom.xml | 23
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 77
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 197
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerOperationsDelegate.java | 29
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 125
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 91
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java | 12
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/AugeasConfigurationApache.java | 61
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/AugeasTreeBuilderApache.java | 10
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/parser/ApacheParserImpl.java | 4
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 170
modules/plugins/apache/src/test/java/org/rhq/plugins/apache/ApacheAugeasTest.java | 11
modules/plugins/apache/src/test/java/org/rhq/plugins/apache/ApachePluginTest.java | 13
modules/plugins/augeas/pom.xml | 2
modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java | 4
modules/plugins/cobbler/pom.xml | 2
modules/plugins/cron/pom.xml | 2
modules/plugins/database/pom.xml | 2
modules/plugins/filetemplate-bundle/pom.xml | 2
modules/plugins/grub/pom.xml | 2
modules/plugins/hibernate/pom.xml | 2
modules/plugins/hosts/pom.xml | 2
modules/plugins/hudson/pom.xml | 2
modules/plugins/iis/pom.xml | 2
modules/plugins/jboss-as-5/pom.xml | 2
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java | 10
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 129
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 86
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java | 14
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java | 80
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java | 42
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/AbstractDeployer.java | 196
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/LocalDeployer.java | 56
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/LocalDownloader.java | 42
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java | 183
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/PackageDownloader.java | 36
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/RemoteDeployer.java | 144
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/RemoteDownloader.java | 121
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ScriptDeployer.java | 151
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/CreateChildResourceFacetDelegate.java | 32
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java | 479 +-
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java | 193
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptFileFinder.java | 100
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java | 99
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 93
modules/plugins/jboss-as-5/testsuite/src/main/java/org/rhq/plugins/jbossas5/JBossServerTest.java | 13
modules/plugins/jboss-as/pom.xml | 2
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java | 8
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java | 14
modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml | 16
modules/plugins/jboss-cache-v3/pom.xml | 2
modules/plugins/jboss-cache/pom.xml | 2
modules/plugins/jmx/pom.xml | 2
modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXPluginLifecycleListener.java | 52
modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml | 1
modules/plugins/mysql/pom.xml | 2
modules/plugins/netservices/pom.xml | 2
modules/plugins/oracle/pom.xml | 2
modules/plugins/perftest/pom.xml | 2
modules/plugins/platform/pom.xml | 2
modules/plugins/pom.xml | 2
modules/plugins/postfix/pom.xml | 2
modules/plugins/postgres/pom.xml | 2
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java | 13
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java | 107
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java | 4
modules/plugins/rhq-agent/pom.xml | 2
modules/plugins/rhq-server/pom.xml | 2
modules/plugins/samba/pom.xml | 2
modules/plugins/script/pom.xml | 2
modules/plugins/snmptrapd/pom.xml | 2
modules/plugins/sshd/pom.xml | 2
modules/plugins/sudoers/pom.xml | 2
modules/plugins/tomcat/pom.xml | 2
modules/plugins/twitter/pom.xml | 2
modules/plugins/validate-all-plugins/pom.xml | 2
modules/pom.xml | 2
modules/test-utils/pom.xml | 2
pom.xml | 2275 +++++-----
215 files changed, 4404 insertions(+), 3121 deletions(-)
---
13 years, 4 months
[rhq] Branch 'release-3.0.0' - modules/common modules/core modules/enterprise modules/helpers modules/plugins modules/pom.xml modules/test-utils pom.xml
by John Sanda
modules/common/ant-bundle/pom.xml | 2 -
modules/common/filetemplate-bundle/pom.xml | 2 -
modules/common/jboss-as/pom.xml | 2 -
modules/common/pom.xml | 2 -
modules/core/client-api/pom.xml | 2 -
modules/core/comm-api/pom.xml | 2 -
modules/core/dbutils/pom.xml | 2 -
modules/core/domain/pom.xml | 2 -
modules/core/gui/pom.xml | 2 -
modules/core/native-system/pom.xml | 2 -
modules/core/plugin-api/pom.xml | 2 -
modules/core/plugin-container/pom.xml | 2 -
modules/core/plugin-validator/pom.xml | 2 -
modules/core/plugindoc/pom.xml | 2 -
modules/core/pom.xml | 2 -
modules/core/util/pom.xml | 2 -
modules/enterprise/agent/pom.xml | 2 -
modules/enterprise/agentupdate/pom.xml | 2 -
modules/enterprise/comm/pom.xml | 2 -
modules/enterprise/gui/base-perspective-jar/pom.xml | 2 -
modules/enterprise/gui/base-perspective-war/pom.xml | 2 -
modules/enterprise/gui/content_http-war/pom.xml | 2 -
modules/enterprise/gui/coregui/pom.xml | 2 -
modules/enterprise/gui/installer-war/pom.xml | 2 -
modules/enterprise/gui/pom.xml | 2 -
modules/enterprise/gui/portal-war/pom.xml | 2 -
modules/enterprise/gui/webdav-war/pom.xml | 2 -
modules/enterprise/pom.xml | 2 -
modules/enterprise/remoting/cli/pom.xml | 2 -
modules/enterprise/remoting/client-api/pom.xml | 2 -
modules/enterprise/remoting/pom.xml | 2 -
modules/enterprise/remoting/webservices/pom.xml | 2 -
modules/enterprise/server/container-lib/pom.xml | 2 -
modules/enterprise/server/container/pom.xml | 4 +-
modules/enterprise/server/ear/pom.xml | 2 -
modules/enterprise/server/jar/pom.xml | 2 -
modules/enterprise/server/plugins/alert-email/pom.xml | 2 -
modules/enterprise/server/plugins/alert-irc/pom.xml | 2 -
modules/enterprise/server/plugins/alert-microblog/pom.xml | 2 -
modules/enterprise/server/plugins/alert-mobicents/pom.xml | 2 -
modules/enterprise/server/plugins/alert-operations/pom.xml | 2 -
modules/enterprise/server/plugins/alert-roles/pom.xml | 2 -
modules/enterprise/server/plugins/alert-snmp/pom.xml | 2 -
modules/enterprise/server/plugins/alert-subject/pom.xml | 2 -
modules/enterprise/server/plugins/ant-bundle/pom.xml | 2 -
modules/enterprise/server/plugins/cobbler/pom.xml | 2 -
modules/enterprise/server/plugins/disk/pom.xml | 2 -
modules/enterprise/server/plugins/filetemplate-bundle/pom.xml | 2 -
modules/enterprise/server/plugins/jboss-software/pom.xml | 2 -
modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml | 2 -
modules/enterprise/server/plugins/perspectives/core/pom.xml | 2 -
modules/enterprise/server/plugins/pom.xml | 2 -
modules/enterprise/server/plugins/rhnhosted/pom.xml | 2 -
modules/enterprise/server/plugins/url/pom.xml | 2 -
modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml | 2 -
modules/enterprise/server/plugins/yum/pom.xml | 2 -
modules/enterprise/server/safe-invoker/pom.xml | 2 -
modules/enterprise/server/sars/agent-sar/pom.xml | 2 -
modules/enterprise/server/sars/pom.xml | 2 -
modules/enterprise/server/xml-schemas/pom.xml | 2 -
modules/helpers/pluginAnnotations/pom.xml | 2 -
modules/helpers/pluginGen/pom.xml | 2 -
modules/helpers/pom.xml | 2 -
modules/helpers/rtfilter/pom.xml | 2 -
modules/plugins/aliases/pom.xml | 2 -
modules/plugins/ant-bundle/pom.xml | 2 -
modules/plugins/apache/pom.xml | 2 -
modules/plugins/augeas/pom.xml | 2 -
modules/plugins/cobbler/pom.xml | 2 -
modules/plugins/cron/pom.xml | 2 -
modules/plugins/database/pom.xml | 2 -
modules/plugins/filetemplate-bundle/pom.xml | 2 -
modules/plugins/grub/pom.xml | 2 -
modules/plugins/hibernate/pom.xml | 2 -
modules/plugins/hosts/pom.xml | 2 -
modules/plugins/hudson/pom.xml | 2 -
modules/plugins/iis/pom.xml | 2 -
modules/plugins/jboss-as-5/pom.xml | 2 -
modules/plugins/jboss-as/pom.xml | 2 -
modules/plugins/jboss-cache-v3/pom.xml | 2 -
modules/plugins/jboss-cache/pom.xml | 2 -
modules/plugins/jmx/pom.xml | 2 -
modules/plugins/mysql/pom.xml | 2 -
modules/plugins/netservices/pom.xml | 2 -
modules/plugins/oracle/pom.xml | 2 -
modules/plugins/perftest/pom.xml | 2 -
modules/plugins/platform/pom.xml | 2 -
modules/plugins/pom.xml | 2 -
modules/plugins/postfix/pom.xml | 2 -
modules/plugins/postgres/pom.xml | 2 -
modules/plugins/rhq-agent/pom.xml | 2 -
modules/plugins/rhq-server/pom.xml | 2 -
modules/plugins/samba/pom.xml | 2 -
modules/plugins/script/pom.xml | 2 -
modules/plugins/snmptrapd/pom.xml | 2 -
modules/plugins/sshd/pom.xml | 2 -
modules/plugins/sudoers/pom.xml | 2 -
modules/plugins/tomcat/pom.xml | 2 -
modules/plugins/twitter/pom.xml | 2 -
modules/plugins/validate-all-plugins/pom.xml | 2 -
modules/pom.xml | 2 -
modules/test-utils/pom.xml | 2 -
pom.xml | 15 ++++------
103 files changed, 109 insertions(+), 112 deletions(-)
New commits:
commit 5daaab99d303e7a36c28727dc51395194c13282a
Author: root <root(a)localhost.localdomain>
Date: Fri Jan 14 03:13:49 2011 -0500
[maven-release-plugin] prepare release RHQ_4_0_0_QA
diff --git a/modules/common/ant-bundle/pom.xml b/modules/common/ant-bundle/pom.xml
index 18b3148..6479a13 100644
--- a/modules/common/ant-bundle/pom.xml
+++ b/modules/common/ant-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-common-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/common/filetemplate-bundle/pom.xml b/modules/common/filetemplate-bundle/pom.xml
index 7328519..59e5802 100644
--- a/modules/common/filetemplate-bundle/pom.xml
+++ b/modules/common/filetemplate-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-common-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/common/jboss-as/pom.xml b/modules/common/jboss-as/pom.xml
index ce47a67..45c4f50 100644
--- a/modules/common/jboss-as/pom.xml
+++ b/modules/common/jboss-as/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-common-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index 01eea5c..dec6fd5 100644
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index 9f3881a..b513ee5 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/comm-api/pom.xml b/modules/core/comm-api/pom.xml
index 74b5928..60d3e07 100644
--- a/modules/core/comm-api/pom.xml
+++ b/modules/core/comm-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index ea159a0..c16f709 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index a28eb3a..bac6316 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/gui/pom.xml b/modules/core/gui/pom.xml
index 61d8a02..f8c262e 100644
--- a/modules/core/gui/pom.xml
+++ b/modules/core/gui/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/native-system/pom.xml b/modules/core/native-system/pom.xml
index bdf222d..9b3197e 100644
--- a/modules/core/native-system/pom.xml
+++ b/modules/core/native-system/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/plugin-api/pom.xml b/modules/core/plugin-api/pom.xml
index 9010509..90fba0e 100644
--- a/modules/core/plugin-api/pom.xml
+++ b/modules/core/plugin-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/plugin-container/pom.xml b/modules/core/plugin-container/pom.xml
index 2f23428..afd763d 100644
--- a/modules/core/plugin-container/pom.xml
+++ b/modules/core/plugin-container/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/plugin-validator/pom.xml b/modules/core/plugin-validator/pom.xml
index df4f531..67d1da9 100644
--- a/modules/core/plugin-validator/pom.xml
+++ b/modules/core/plugin-validator/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/plugindoc/pom.xml b/modules/core/plugindoc/pom.xml
index afa1802..b426bcb 100644
--- a/modules/core/plugindoc/pom.xml
+++ b/modules/core/plugindoc/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index fa507c8..e754b38 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/core/util/pom.xml b/modules/core/util/pom.xml
index 39d1f3a..6761e16 100644
--- a/modules/core/util/pom.xml
+++ b/modules/core/util/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/agent/pom.xml b/modules/enterprise/agent/pom.xml
index d1c7d5a..e258e39 100644
--- a/modules/enterprise/agent/pom.xml
+++ b/modules/enterprise/agent/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/agentupdate/pom.xml b/modules/enterprise/agentupdate/pom.xml
index 565bc6b..605b27d 100644
--- a/modules/enterprise/agentupdate/pom.xml
+++ b/modules/enterprise/agentupdate/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/comm/pom.xml b/modules/enterprise/comm/pom.xml
index 4690f9c..d851e50 100644
--- a/modules/enterprise/comm/pom.xml
+++ b/modules/enterprise/comm/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/base-perspective-jar/pom.xml b/modules/enterprise/gui/base-perspective-jar/pom.xml
index 925cbfa..737fed8 100644
--- a/modules/enterprise/gui/base-perspective-jar/pom.xml
+++ b/modules/enterprise/gui/base-perspective-jar/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/base-perspective-war/pom.xml b/modules/enterprise/gui/base-perspective-war/pom.xml
index 128359c..cc6da1b 100644
--- a/modules/enterprise/gui/base-perspective-war/pom.xml
+++ b/modules/enterprise/gui/base-perspective-war/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
index 0d3bca5..f67485c 100644
--- a/modules/enterprise/gui/content_http-war/pom.xml
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-gui-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index ee22fea..17b8008 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 61363d3..53318ad 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/pom.xml b/modules/enterprise/gui/pom.xml
index 8cb4c27..96820af 100644
--- a/modules/enterprise/gui/pom.xml
+++ b/modules/enterprise/gui/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/portal-war/pom.xml b/modules/enterprise/gui/portal-war/pom.xml
index e42dbbe..70ba9e9 100644
--- a/modules/enterprise/gui/portal-war/pom.xml
+++ b/modules/enterprise/gui/portal-war/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/gui/webdav-war/pom.xml b/modules/enterprise/gui/webdav-war/pom.xml
index d723c43..eea48bd 100644
--- a/modules/enterprise/gui/webdav-war/pom.xml
+++ b/modules/enterprise/gui/webdav-war/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/pom.xml b/modules/enterprise/pom.xml
index c95bb90..a7a0de3 100644
--- a/modules/enterprise/pom.xml
+++ b/modules/enterprise/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/remoting/cli/pom.xml b/modules/enterprise/remoting/cli/pom.xml
index 1dd7aad..2dd7010 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<artifactId>rhq-remoting-cli</artifactId>
diff --git a/modules/enterprise/remoting/client-api/pom.xml b/modules/enterprise/remoting/client-api/pom.xml
index e13b3cb..4d9b29b 100644
--- a/modules/enterprise/remoting/client-api/pom.xml
+++ b/modules/enterprise/remoting/client-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<artifactId>rhq-remoting-client-api</artifactId>
diff --git a/modules/enterprise/remoting/pom.xml b/modules/enterprise/remoting/pom.xml
index d40ba9f..44f056d 100644
--- a/modules/enterprise/remoting/pom.xml
+++ b/modules/enterprise/remoting/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<artifactId>rhq-remoting-parent</artifactId>
diff --git a/modules/enterprise/remoting/webservices/pom.xml b/modules/enterprise/remoting/webservices/pom.xml
index bc901bb..bd168be 100644
--- a/modules/enterprise/remoting/webservices/pom.xml
+++ b/modules/enterprise/remoting/webservices/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<artifactId>rhq-remoting-webservices</artifactId>
diff --git a/modules/enterprise/server/container-lib/pom.xml b/modules/enterprise/server/container-lib/pom.xml
index 49604e7..89de04e 100644
--- a/modules/enterprise/server/container-lib/pom.xml
+++ b/modules/enterprise/server/container-lib/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index e14135c..f39320e 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
@@ -200,7 +200,7 @@
<property name="rhq.server.enable.ws" value="${rhq.server.enable.ws}" />
<property name="jbossws-native-dist.version" value="${jbossws-native-dist.version}" />
- <property name="rhq.sync.endpoint-address" value="${rhq.sync.endpoint-address}"/>
+ <property name="rhq.sync.endpoint-address" value="${rhq.sync.endpoint-address}" />
</ant>
</tasks>
</configuration>
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 3e4fc5c..b4e152d 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index ff09450..4e7d957 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/alert-email/pom.xml b/modules/enterprise/server/plugins/alert-email/pom.xml
index f7f4685..16d1c57 100644
--- a/modules/enterprise/server/plugins/alert-email/pom.xml
+++ b/modules/enterprise/server/plugins/alert-email/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-irc/pom.xml b/modules/enterprise/server/plugins/alert-irc/pom.xml
index 54c7628..8df30ea 100644
--- a/modules/enterprise/server/plugins/alert-irc/pom.xml
+++ b/modules/enterprise/server/plugins/alert-irc/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-microblog/pom.xml b/modules/enterprise/server/plugins/alert-microblog/pom.xml
index e6425e6..75ef3eb 100644
--- a/modules/enterprise/server/plugins/alert-microblog/pom.xml
+++ b/modules/enterprise/server/plugins/alert-microblog/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-mobicents/pom.xml b/modules/enterprise/server/plugins/alert-mobicents/pom.xml
index cc3e87e..43679f4 100644
--- a/modules/enterprise/server/plugins/alert-mobicents/pom.xml
+++ b/modules/enterprise/server/plugins/alert-mobicents/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-operations/pom.xml b/modules/enterprise/server/plugins/alert-operations/pom.xml
index 0b37848..ce2aa4c 100644
--- a/modules/enterprise/server/plugins/alert-operations/pom.xml
+++ b/modules/enterprise/server/plugins/alert-operations/pom.xml
@@ -2,7 +2,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-roles/pom.xml b/modules/enterprise/server/plugins/alert-roles/pom.xml
index 2bd8c5d..fabe19a 100644
--- a/modules/enterprise/server/plugins/alert-roles/pom.xml
+++ b/modules/enterprise/server/plugins/alert-roles/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-snmp/pom.xml b/modules/enterprise/server/plugins/alert-snmp/pom.xml
index d40372d..19f9532 100644
--- a/modules/enterprise/server/plugins/alert-snmp/pom.xml
+++ b/modules/enterprise/server/plugins/alert-snmp/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/alert-subject/pom.xml b/modules/enterprise/server/plugins/alert-subject/pom.xml
index 3105b12..103332f 100644
--- a/modules/enterprise/server/plugins/alert-subject/pom.xml
+++ b/modules/enterprise/server/plugins/alert-subject/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/ant-bundle/pom.xml b/modules/enterprise/server/plugins/ant-bundle/pom.xml
index 49fb793..a5502ab 100644
--- a/modules/enterprise/server/plugins/ant-bundle/pom.xml
+++ b/modules/enterprise/server/plugins/ant-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/cobbler/pom.xml b/modules/enterprise/server/plugins/cobbler/pom.xml
index 414089a..6ac95b6 100644
--- a/modules/enterprise/server/plugins/cobbler/pom.xml
+++ b/modules/enterprise/server/plugins/cobbler/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/enterprise/server/plugins/disk/pom.xml b/modules/enterprise/server/plugins/disk/pom.xml
index 1cf8dc4..1091107 100644
--- a/modules/enterprise/server/plugins/disk/pom.xml
+++ b/modules/enterprise/server/plugins/disk/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml b/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
index 19d8f63..87ddd11 100644
--- a/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
+++ b/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/jboss-software/pom.xml b/modules/enterprise/server/plugins/jboss-software/pom.xml
index d523815..c76da08 100644
--- a/modules/enterprise/server/plugins/jboss-software/pom.xml
+++ b/modules/enterprise/server/plugins/jboss-software/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml b/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml
index 5465cb7..25b65b0 100644
--- a/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml
+++ b/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/perspectives/core/pom.xml b/modules/enterprise/server/plugins/perspectives/core/pom.xml
index ef113ea..ca1bd76 100644
--- a/modules/enterprise/server/plugins/perspectives/core/pom.xml
+++ b/modules/enterprise/server/plugins/perspectives/core/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/pom.xml b/modules/enterprise/server/plugins/pom.xml
index 9fae1c6..db1c2b0 100644
--- a/modules/enterprise/server/plugins/pom.xml
+++ b/modules/enterprise/server/plugins/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/rhnhosted/pom.xml b/modules/enterprise/server/plugins/rhnhosted/pom.xml
index e897939..ac0a8a7 100644
--- a/modules/enterprise/server/plugins/rhnhosted/pom.xml
+++ b/modules/enterprise/server/plugins/rhnhosted/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/url/pom.xml b/modules/enterprise/server/plugins/url/pom.xml
index e94bc97..4e4c973 100644
--- a/modules/enterprise/server/plugins/url/pom.xml
+++ b/modules/enterprise/server/plugins/url/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml b/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml
index 972ffae..ac80b24 100644
--- a/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml
+++ b/modules/enterprise/server/plugins/validate-all-serverplugins/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/plugins/yum/pom.xml b/modules/enterprise/server/plugins/yum/pom.xml
index b0d0889..94e8fe0 100644
--- a/modules/enterprise/server/plugins/yum/pom.xml
+++ b/modules/enterprise/server/plugins/yum/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/safe-invoker/pom.xml b/modules/enterprise/server/safe-invoker/pom.xml
index bac02fe..75a3ba8 100644
--- a/modules/enterprise/server/safe-invoker/pom.xml
+++ b/modules/enterprise/server/safe-invoker/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/sars/agent-sar/pom.xml b/modules/enterprise/server/sars/agent-sar/pom.xml
index d4eb1d3..99d3efd 100644
--- a/modules/enterprise/server/sars/agent-sar/pom.xml
+++ b/modules/enterprise/server/sars/agent-sar/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-sars-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/sars/pom.xml b/modules/enterprise/server/sars/pom.xml
index 9c89fb0..f78308e 100644
--- a/modules/enterprise/server/sars/pom.xml
+++ b/modules/enterprise/server/sars/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/enterprise/server/xml-schemas/pom.xml b/modules/enterprise/server/xml-schemas/pom.xml
index adcee30..94f0b1c 100644
--- a/modules/enterprise/server/xml-schemas/pom.xml
+++ b/modules/enterprise/server/xml-schemas/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/helpers/pluginAnnotations/pom.xml b/modules/helpers/pluginAnnotations/pom.xml
index 34f96b7..226e657 100644
--- a/modules/helpers/pluginAnnotations/pom.xml
+++ b/modules/helpers/pluginAnnotations/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-helpers</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq.helpers</groupId>
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index 760aa47..78376ca 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-helpers</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq.helpers</groupId>
diff --git a/modules/helpers/pom.xml b/modules/helpers/pom.xml
index a9a1ed6..23489ee 100644
--- a/modules/helpers/pom.xml
+++ b/modules/helpers/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq.helpers</groupId>
diff --git a/modules/helpers/rtfilter/pom.xml b/modules/helpers/rtfilter/pom.xml
index 66817bb..0590691 100644
--- a/modules/helpers/rtfilter/pom.xml
+++ b/modules/helpers/rtfilter/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-helpers</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/aliases/pom.xml b/modules/plugins/aliases/pom.xml
index d45740a..668b04f 100644
--- a/modules/plugins/aliases/pom.xml
+++ b/modules/plugins/aliases/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/ant-bundle/pom.xml b/modules/plugins/ant-bundle/pom.xml
index e85b019..bc39c40 100644
--- a/modules/plugins/ant-bundle/pom.xml
+++ b/modules/plugins/ant-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/apache/pom.xml b/modules/plugins/apache/pom.xml
index 5781ac5..b233031 100644
--- a/modules/plugins/apache/pom.xml
+++ b/modules/plugins/apache/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/augeas/pom.xml b/modules/plugins/augeas/pom.xml
index 8ce4c7d..326d781 100644
--- a/modules/plugins/augeas/pom.xml
+++ b/modules/plugins/augeas/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/cobbler/pom.xml b/modules/plugins/cobbler/pom.xml
index f389aed..38facb0 100644
--- a/modules/plugins/cobbler/pom.xml
+++ b/modules/plugins/cobbler/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/cron/pom.xml b/modules/plugins/cron/pom.xml
index 134b32f..4339a94 100644
--- a/modules/plugins/cron/pom.xml
+++ b/modules/plugins/cron/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/database/pom.xml b/modules/plugins/database/pom.xml
index b835e7b..41c5e57 100644
--- a/modules/plugins/database/pom.xml
+++ b/modules/plugins/database/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/filetemplate-bundle/pom.xml b/modules/plugins/filetemplate-bundle/pom.xml
index 63f3c7e..d80f1ab 100644
--- a/modules/plugins/filetemplate-bundle/pom.xml
+++ b/modules/plugins/filetemplate-bundle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/grub/pom.xml b/modules/plugins/grub/pom.xml
index b7a6da7..c4fd8da 100644
--- a/modules/plugins/grub/pom.xml
+++ b/modules/plugins/grub/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/hibernate/pom.xml b/modules/plugins/hibernate/pom.xml
index 43a0d03..d9fcc13 100644
--- a/modules/plugins/hibernate/pom.xml
+++ b/modules/plugins/hibernate/pom.xml
@@ -6,7 +6,7 @@
<groupId>org.rhq</groupId>
<!-- Bypass the jopr-plugins-parent which can not have children. It must build after the plugins in order to execute integration tests on them. -->
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/hosts/pom.xml b/modules/plugins/hosts/pom.xml
index bf9b384..a317231 100644
--- a/modules/plugins/hosts/pom.xml
+++ b/modules/plugins/hosts/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/hudson/pom.xml b/modules/plugins/hudson/pom.xml
index 094349a..84acc4d 100644
--- a/modules/plugins/hudson/pom.xml
+++ b/modules/plugins/hudson/pom.xml
@@ -6,7 +6,7 @@
<parent>
<artifactId>rhq-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/iis/pom.xml b/modules/plugins/iis/pom.xml
index 7a22b82..0d3a151 100644
--- a/modules/plugins/iis/pom.xml
+++ b/modules/plugins/iis/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/jboss-as-5/pom.xml b/modules/plugins/jboss-as-5/pom.xml
index 2e26619..12f7eb1 100644
--- a/modules/plugins/jboss-as-5/pom.xml
+++ b/modules/plugins/jboss-as-5/pom.xml
@@ -9,7 +9,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/jboss-as/pom.xml b/modules/plugins/jboss-as/pom.xml
index 1556ac8..a12be62 100644
--- a/modules/plugins/jboss-as/pom.xml
+++ b/modules/plugins/jboss-as/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/jboss-cache-v3/pom.xml b/modules/plugins/jboss-cache-v3/pom.xml
index 4b3b21d..f3f9e8b 100644
--- a/modules/plugins/jboss-cache-v3/pom.xml
+++ b/modules/plugins/jboss-cache-v3/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/jboss-cache/pom.xml b/modules/plugins/jboss-cache/pom.xml
index 8c78ea7..f57dc5c 100644
--- a/modules/plugins/jboss-cache/pom.xml
+++ b/modules/plugins/jboss-cache/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/jmx/pom.xml b/modules/plugins/jmx/pom.xml
index 5f92e76..4445455 100644
--- a/modules/plugins/jmx/pom.xml
+++ b/modules/plugins/jmx/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/mysql/pom.xml b/modules/plugins/mysql/pom.xml
index c99ae4b..a6cedd0 100644
--- a/modules/plugins/mysql/pom.xml
+++ b/modules/plugins/mysql/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/netservices/pom.xml b/modules/plugins/netservices/pom.xml
index 67919cf..04b4394 100644
--- a/modules/plugins/netservices/pom.xml
+++ b/modules/plugins/netservices/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/oracle/pom.xml b/modules/plugins/oracle/pom.xml
index ad6478a..25f88ff 100644
--- a/modules/plugins/oracle/pom.xml
+++ b/modules/plugins/oracle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/perftest/pom.xml b/modules/plugins/perftest/pom.xml
index cb424ef..45527e8 100644
--- a/modules/plugins/perftest/pom.xml
+++ b/modules/plugins/perftest/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/platform/pom.xml b/modules/plugins/platform/pom.xml
index 6f8b8c3..b4c643c 100644
--- a/modules/plugins/platform/pom.xml
+++ b/modules/plugins/platform/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml
index 4d12efb..5928440 100644
--- a/modules/plugins/pom.xml
+++ b/modules/plugins/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/postfix/pom.xml b/modules/plugins/postfix/pom.xml
index 663c562..9f193c9 100644
--- a/modules/plugins/postfix/pom.xml
+++ b/modules/plugins/postfix/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/postgres/pom.xml b/modules/plugins/postgres/pom.xml
index 4551c56..d72ce50 100644
--- a/modules/plugins/postgres/pom.xml
+++ b/modules/plugins/postgres/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/rhq-agent/pom.xml b/modules/plugins/rhq-agent/pom.xml
index 2918cd1..4e545b3 100644
--- a/modules/plugins/rhq-agent/pom.xml
+++ b/modules/plugins/rhq-agent/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/rhq-server/pom.xml b/modules/plugins/rhq-server/pom.xml
index 71c3e26..5e3af16 100644
--- a/modules/plugins/rhq-server/pom.xml
+++ b/modules/plugins/rhq-server/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/samba/pom.xml b/modules/plugins/samba/pom.xml
index 99ef74e..59bc78f 100644
--- a/modules/plugins/samba/pom.xml
+++ b/modules/plugins/samba/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/script/pom.xml b/modules/plugins/script/pom.xml
index c7403c4..ba0ce39 100644
--- a/modules/plugins/script/pom.xml
+++ b/modules/plugins/script/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/snmptrapd/pom.xml b/modules/plugins/snmptrapd/pom.xml
index baa076b..dd4b39d 100644
--- a/modules/plugins/snmptrapd/pom.xml
+++ b/modules/plugins/snmptrapd/pom.xml
@@ -2,7 +2,7 @@
<parent>
<artifactId>rhq-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/modules/plugins/sshd/pom.xml b/modules/plugins/sshd/pom.xml
index efc4a8c..30decd7 100644
--- a/modules/plugins/sshd/pom.xml
+++ b/modules/plugins/sshd/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/sudoers/pom.xml b/modules/plugins/sudoers/pom.xml
index 8bd1665..6e28cce 100644
--- a/modules/plugins/sudoers/pom.xml
+++ b/modules/plugins/sudoers/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/tomcat/pom.xml b/modules/plugins/tomcat/pom.xml
index 37b1d4f..f40e5d7 100644
--- a/modules/plugins/tomcat/pom.xml
+++ b/modules/plugins/tomcat/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.jboss.on</groupId>
diff --git a/modules/plugins/twitter/pom.xml b/modules/plugins/twitter/pom.xml
index 44a9746..cf40656 100644
--- a/modules/plugins/twitter/pom.xml
+++ b/modules/plugins/twitter/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/validate-all-plugins/pom.xml b/modules/plugins/validate-all-plugins/pom.xml
index 4982e56..dcf2aa5 100644
--- a/modules/plugins/validate-all-plugins/pom.xml
+++ b/modules/plugins/validate-all-plugins/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/pom.xml b/modules/pom.xml
index fee12c3..d163344 100644
--- a/modules/pom.xml
+++ b/modules/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<groupId>org.rhq</groupId>
diff --git a/modules/test-utils/pom.xml b/modules/test-utils/pom.xml
index 432b517..da3a64b 100644
--- a/modules/test-utils/pom.xml
+++ b/modules/test-utils/pom.xml
@@ -4,7 +4,7 @@
<parent>
<artifactId>rhq-modules-parent</artifactId>
<groupId>org.rhq</groupId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
</parent>
<artifactId>test-utils</artifactId>
<name>RHQ Test Utils</name>
diff --git a/pom.xml b/pom.xml
index b502ef1..da17bca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,13 +1,12 @@
<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0.QA</version>
<packaging>pom</packaging>
<name>RHQ</name>
@@ -1063,10 +1062,9 @@ version is changed the versions of each of these should be validated and updated
<configuration>
<tasks>
<tstamp>
- <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US"
- timezone="GMT"/>
+ <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT" />
</tstamp>
- <mkdir dir="target"/>
+ <mkdir dir="target" />
<echo file="target/build-time.properties" level="error">buildTime = ${buildTime}
</echo>
</tasks>
@@ -1157,10 +1155,9 @@ version is changed the versions of each of these should be validated and updated
<configuration>
<tasks>
<tstamp>
- <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US"
- timezone="GMT"/>
+ <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT" />
</tstamp>
- <mkdir dir="target"/>
+ <mkdir dir="target" />
<echo file="target/build-time.properties" level="error">buildTime = ${maven.build.timestamp}</echo>
<echo file="target/build-number.properties" level="error">buildNumber = ${rhq.build.number}</echo>
</tasks>
13 years, 4 months
[rhq] Branch 'cli-alert-notifs' - 11 commits - modules/core modules/enterprise modules/plugins
by lkrejci
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java | 9
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeRequest.java | 57
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeResponse.java | 67
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java | 9
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java | 2
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeRequest.java | 67
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeResult.java | 65
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 60
modules/enterprise/binding/pom.xml | 200 ++
modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java | 135 +
modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardBindings.java | 178 ++
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java | 170 ++
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java | 641 +++++++++
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java | 132 +
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java | 116 +
modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java | 72 +
modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/ScriptEngineInitializer.java | 59
modules/enterprise/binding/src/main/java/org/rhq/bindings/export/ExportException.java | 43
modules/enterprise/binding/src/main/java/org/rhq/bindings/export/Exporter.java | 86 +
modules/enterprise/binding/src/main/java/org/rhq/bindings/output/TabularWriter.java | 708 ++++++++++
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ConfigurationClassBuilder.java | 158 ++
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/InterfaceSimplifier.java | 128 +
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/LazyLoadScenario.java | 44
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/PackageFinder.java | 125 +
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptAssert.java | 421 +++++
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptAssertionException.java | 57
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptUtil.java | 181 ++
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ShortOutput.java | 27
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/SummaryFilter.java | 127 +
modules/enterprise/binding/src/test/java/org/rhq/bindings/TabularWriterTest.java | 397 +++++
modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/AbstractPerspectiveResourceUIBean.java | 2
modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveClientUIBean.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java | 47
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java | 49
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java | 8
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 8
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16_Disabled.png |binary
modules/enterprise/pom.xml | 1
modules/enterprise/remoting/cli/pom.xml | 8
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/SummaryFilter.java | 127 -
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/TabularWriter.java | 708 ----------
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/HelpCommand.java | 2
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/LoginCommand.java | 3
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java | 163 --
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/export/ExportException.java | 43
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/export/Exporter.java | 86 -
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ConfigurationEditor.java | 2
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientFactory.java | 61
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientProxy.java | 71 +
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientFactory.java | 134 -
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java | 669 ---------
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ConfigurationClassBuilder.java | 158 --
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/LazyLoadScenario.java | 44
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/PackageFinder.java | 140 -
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptAssert.java | 413 -----
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptAssertionException.java | 57
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptUtil.java | 159 --
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ShortOutput.java | 27
modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml | 3
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/SummaryFilterTest.java | 2
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java | 396 -----
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java | 27
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptAssertTest.java | 2
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptUtilTest.java | 2
modules/enterprise/remoting/client-api/pom.xml | 96 -
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java | 185 --
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java | 117 -
modules/enterprise/server/jar/pom.xml | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 171 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java | 13
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java | 11
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java | 64
modules/enterprise/server/plugins/alert-cli/pom.xml | 23
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java | 95 +
modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java | 34
81 files changed, 5363 insertions(+), 3634 deletions(-)
New commits:
commit c240a5cdbf59e37c1d8d29fbb31e4c6343afa5d3
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jan 13 15:10:45 2011 +0100
unbreak the interactive configuration editors in the resource proxies.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
index b67acf1..13517df 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
@@ -560,12 +560,12 @@ public class ResourceClientProxy {
public Object invoke(Object proxy, Method method, Method proceedMethod, Object[] args) throws Throwable {
if (proceedMethod != null) {
- Method realMethod = ResourceClientProxy.class.getMethod(method.getName(), method.getParameterTypes());
+ Method realMethod = getResourceClientProxyClass().getMethod(method.getName(), method.getParameterTypes());
return realMethod.invoke(resourceClientProxy, args);
} else {
try {
- Method localMethod = ClientProxyMethodHandler.class.getDeclaredMethod(method.getName(), method
+ Method localMethod = getClass().getDeclaredMethod(method.getName(), method
.getParameterTypes());
return localMethod.invoke(this, args);
} catch (NoSuchMethodException nsme) {
@@ -592,6 +592,10 @@ public class ResourceClientProxy {
throw new RuntimeException("Can't find custom method: " + method);
}
}
+
+ protected Class<? extends ResourceClientProxy> getResourceClientProxyClass() {
+ return ResourceClientProxy.class;
+ }
}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientProxy.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientProxy.java
index 367a750..10fa51d 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientProxy.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientProxy.java
@@ -23,7 +23,6 @@ import org.rhq.bindings.client.ResourceClientProxy;
import org.rhq.bindings.client.RhqFacade;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.enterprise.client.ClientMain;
-import org.rhq.enterprise.client.RemoteClient;
/**
* Extends the {@link ResourceClientProxy} and provides the interactive configuration editing features.
@@ -63,5 +62,10 @@ public class EditableResourceClientProxy extends ResourceClientProxy {
updateResourceConfiguration(config);
}
}
+
+ @Override
+ protected Class<? extends ResourceClientProxy> getResourceClientProxyClass() {
+ return EditableResourceClientProxy.class;
+ }
}
}
commit 49cf35723fa3a6055d0fb3d9b89751c3f3ec41a8
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jan 13 14:33:26 2011 +0100
bind the controller's methods in the global scope of CLI
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
index 8f64679..dfc2b4c 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
@@ -184,7 +184,7 @@ public class ScriptCommand implements ClientCommand {
ScriptEngineFactory.injectStandardBindings(jsEngine, bindings);
ScriptEngineFactory.bindIndirectionMethods(jsEngine, "configurationEditor", bindings.get("configurationEditor"));
- ScriptEngineFactory.bindIndirectionMethods(jsEngine, "configurationEditor", bindings.get("configurationEditor"));
+ ScriptEngineFactory.bindIndirectionMethods(jsEngine, "rhq", bindings.get("rhq"));
}
private void executeUtilScripts() {
commit 06c19e276a98d7c5f56284494b2fe85001abe382
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jan 11 14:35:23 2011 +0100
adding the test-jar dependency on core.domain to make the tests work again.
diff --git a/modules/enterprise/binding/pom.xml b/modules/enterprise/binding/pom.xml
index 65aec88..661af79 100644
--- a/modules/enterprise/binding/pom.xml
+++ b/modules/enterprise/binding/pom.xml
@@ -31,122 +31,130 @@
</exclusions>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-enterprise-server</artifactId>
- <version>${project.version}</version>
- <type>ejb-client</type>
- <exclusions>
- <exclusion>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-validator</groupId>
- <artifactId>commons-validator</artifactId>
- </exclusion>
- <exclusion>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>gnu-getopt</groupId>
- <artifactId>getopt</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-cache</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jbpm</artifactId>
- </exclusion>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-dbutils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>safe-invoker</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>test-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.snmp4j</groupId>
- <artifactId>snmp4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>oswego-concurrent</groupId>
- <artifactId>concurrent</artifactId>
- </exclusion>
- <exclusion>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </exclusion>
- <exclusion>
- <groupId>rss4j</groupId>
- <artifactId>rss4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-common</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-jmx</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-remoting</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-serialization</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.antlr</groupId>
- <artifactId>antlr</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-comm</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <type>ejb-client</type>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>gnu-getopt</groupId>
+ <artifactId>getopt</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-cache</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jbpm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-client-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-dbutils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>safe-invoker</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>test-utils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.snmp4j</groupId>
+ <artifactId>snmp4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>rss4j</groupId>
+ <artifactId>rss4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-serialization</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-comm</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>commons-lang</groupId>
commit 3d4f4eda2afd62d322671ae629bfbda8635f0ce3
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jan 11 13:50:53 2011 +0100
don't blow up on the pretty printing of empty property lists
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/output/TabularWriter.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/output/TabularWriter.java
index 5e24f53..382ce8c 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/output/TabularWriter.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/output/TabularWriter.java
@@ -446,7 +446,7 @@ public class TabularWriter {
public void print(PropertyList p, int depth) {
out.println(indent(depth) + p.getName() + " [" + p.getList().size() + "] {");
- if (p.getList().get(0) instanceof PropertyMap) {
+ if (p.getList().size() > 0 && p.getList().get(0) instanceof PropertyMap) {
consistentMaps(p.getList());
} else {
commit 4ab19328ee3e10690a7499140ff316b7bff337e4
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jan 11 13:50:03 2011 +0100
The scripting engine can now be initialized with the standard bindings in a reusable way without being tied to remoting and CLI "user interface".
diff --git a/modules/enterprise/binding/pom.xml b/modules/enterprise/binding/pom.xml
index 8523c1d..65aec88 100644
--- a/modules/enterprise/binding/pom.xml
+++ b/modules/enterprise/binding/pom.xml
@@ -1,59 +1,192 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>rhq-enterprise-parent</artifactId>
- <groupId>org.rhq</groupId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-script-bindings</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <name>RHQ Script Bindings</name>
- <description>Abstraction of different facilities and default configurations for script bindings</description>
-
- <properties>
- <persistence-api.version>1.0</persistence-api.version>
- <opencsv.version>1.8</opencsv.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>hibernate</groupId>
- <artifactId>hibernate3</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>${persistence-api.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>${testng.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>net.sf.opencsv</groupId>
- <artifactId>opencsv</artifactId>
- <version>${opencsv.version}</version>
- </dependency>
- </dependencies>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>rhq-enterprise-parent</artifactId>
+ <groupId>org.rhq</groupId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-script-bindings</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>RHQ Script Bindings</name>
+ <description>Abstraction of different facilities and default configurations for script bindings</description>
+
+ <properties>
+ <persistence-api.version>1.0</persistence-api.version>
+ <opencsv.version>1.8</opencsv.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>hibernate</groupId>
+ <artifactId>hibernate3</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <type>ejb-client</type>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>gnu-getopt</groupId>
+ <artifactId>getopt</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-cache</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jbpm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-client-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-dbutils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>safe-invoker</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>test-utils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.snmp4j</groupId>
+ <artifactId>snmp4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>rss4j</groupId>
+ <artifactId>rss4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-serialization</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-comm</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>${persistence-api.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>hibernate-annotations</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement
+ section. -->
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testng.version}</version>
+ <scope>compile</scope> <!-- yes, this is meant to be in compile, because we're providing assertions
+ to the scripts -->
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
+ <version>${opencsv.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
index 4179dbe..0fdf46a 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
@@ -19,13 +19,22 @@
package org.rhq.bindings;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.MethodDescriptor;
import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Map;
import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.rhq.bindings.engine.JsEngineInitializer;
import org.rhq.bindings.engine.ScriptEngineInitializer;
import org.rhq.bindings.export.Exporter;
@@ -46,7 +55,8 @@ import org.rhq.core.domain.util.PageControl;
* @author Lukas Krejci
*/
public class ScriptEngineFactory {
-
+ private static final Log LOG = LogFactory.getLog(ScriptEngineFactory.class);
+
private static final ScriptEngineInitializer[] KNOWN_ENGINES = {new JsEngineInitializer()};
private ScriptEngineFactory() {
@@ -63,7 +73,7 @@ public class ScriptEngineFactory {
* @throws ScriptException on error during initialization of the script environment
* @throws IOException if the package finder fails to find the packages
*/
- public static ScriptEngine getScriptEngine(String language, PackageFinder packageFinder) throws ScriptException, IOException {
+ public static ScriptEngine getScriptEngine(String language, PackageFinder packageFinder, StandardBindings bindings) throws ScriptException, IOException {
ScriptEngineInitializer initializer = getInitializer(language);
if (initializer == null) {
@@ -72,25 +82,50 @@ public class ScriptEngineFactory {
ScriptEngine engine = initializer.instantiate(packageFinder.findPackages("org.rhq.core.domain"));
- injectStandardBindings(engine);
+ injectStandardBindings(engine, bindings);
return engine;
}
- public static void injectStandardBindings(ScriptEngine engine) {
- Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
- PageControl pc = new PageControl();
- pc.setPageNumber(-1);
- bindings.put("unlimitedPC", pc);
- bindings.put("pageControl", PageControl.getUnlimitedInstance());
- bindings.put("exporter", new Exporter());
+ public static void injectStandardBindings(ScriptEngine engine, StandardBindings bindings) {
+ bindings.preInject(engine);
+
+ Bindings engineBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
+
+ for(Map.Entry<String, Object> entry : bindings.entrySet()) {
+ engineBindings.put(entry.getKey(), entry.getValue());
+ }
+
+ engine.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);
- engine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
+ bindings.postInject(engine);
}
- private static ScriptEngineInitializer getInitializer(String language) {
+ public static void bindIndirectionMethods(ScriptEngine scriptEngine, String bindingName, Object object) {
+ ScriptEngineInitializer initializer = getInitializer(scriptEngine.getFactory().getLanguageName());
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass(), Object.class);
+ MethodDescriptor[] methodDescriptors = beanInfo.getMethodDescriptors();
+
+ for (MethodDescriptor methodDescriptor : methodDescriptors) {
+ Method method = methodDescriptor.getMethod();
+ try {
+ String methodDef = initializer.generateIndirectionMethod(bindingName, method);
+ scriptEngine.eval(methodDef);
+ } catch (ScriptException e) {
+ LOG.warn("Unable to bind global function " + method.getName(), e);
+ }
+ }
+ } catch (IntrospectionException e) {
+ // TODO Should we altogether remove the object from the script engine bindings?
+ LOG.warn("Could not bind " + object.getClass().getName() + " into script engine.");
+ }
+ }
+
+
+ public static ScriptEngineInitializer getInitializer(String language) {
for (ScriptEngineInitializer i : KNOWN_ENGINES) {
- if (i.getEngineName().equals(language)) {
+ if (i.implementsLanguage(language)) {
return i;
}
}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardBindings.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardBindings.java
new file mode 100644
index 0000000..2977023
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/StandardBindings.java
@@ -0,0 +1,178 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.bindings;
+
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+
+import org.rhq.bindings.client.ResourceClientFactory;
+import org.rhq.bindings.client.RhqFacade;
+import org.rhq.bindings.export.Exporter;
+import org.rhq.bindings.output.TabularWriter;
+import org.rhq.bindings.util.ScriptAssert;
+import org.rhq.bindings.util.ScriptUtil;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.util.PageControl;
+
+/**
+ * This class encapsulates the standard set of data inserted in the {@link ScriptContext#ENGINE_SCOPE} of the
+ * script engines.
+ * <p>
+ * Upon instantiation this class has all the properties initialized with the default values so that a common base
+ * is available for all the users of this class. The user is however able to later modify these defaults to provide
+ * use-case specific overrides (for example the CLI might want to supply impls that hook into the console to provide
+ * interactivity with user in some workflows, which, generically, is not possible in a common case).
+ *
+ * @author Lukas Krejci
+ */
+public class StandardBindings extends HashMap<String, Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String UNLIMITED_PC = "unlimitedPC";
+ public static final String PAGE_CONTROL = "pageControl";
+ public static final String EXPORTER = "exporter";
+ public static final String SUBJECT = "subject";
+ public static final String PRETTY = "pretty";
+ public static final String SCRIPT_UTIL = "scriptUtil";
+ public static final String PROXY_FACTORY = "ProxyFactory";
+ public static final String ASSERT = "Assert";
+
+ private Map<String, Object> managers;
+
+ private static class CastingEntry<T> implements Map.Entry<String, T> {
+
+ private Map.Entry<String, Object> inner;
+ private Class<T> clazz;
+
+ public CastingEntry(Map.Entry<String, Object> inner, Class<T> clazz) {
+ this.inner = inner;
+ this.clazz = clazz;
+ }
+
+ public String getKey() {
+ return inner.getKey();
+ }
+
+ public T getValue() {
+ return clazz.cast(inner.getValue());
+ }
+
+ public T setValue(T value) {
+ return clazz.cast(inner.setValue(value));
+ }
+
+ }
+
+ public StandardBindings(PrintWriter output, RhqFacade rhqFacade) {
+ PageControl pc = new PageControl();
+ pc.setPageNumber(-1);
+
+ managers = rhqFacade.getManagers();
+
+ put(UNLIMITED_PC, pc);
+ put(PAGE_CONTROL, PageControl.getUnlimitedInstance());
+ put(EXPORTER, new Exporter());
+ put(SUBJECT, rhqFacade.getSubject());
+ put(PRETTY, new TabularWriter(output));
+ put(SCRIPT_UTIL, new ScriptUtil(rhqFacade));
+ put(PROXY_FACTORY, new ResourceClientFactory(rhqFacade, output));
+ put(ASSERT, new ScriptAssert());
+
+ putAll(managers);
+
+ //I don't think these should belong in the standard bindings
+ //because all the controller does is "login/logout" as methods
+ //of the "rhq" object. ConfigurationEditor is interactive and
+ //thus unusable outside of console bound CLI.
+
+ //(the below were originally defined in the ScriptCommand)
+ //bindObjectAndGlobalFuctions(new Controller(client), "rhq");
+ //bindObjectAndGlobalFuctions(new ConfigurationEditor(client), "configurationEditor");
+ }
+
+ public void preInject(ScriptEngine scriptEngine) {
+ ((ScriptUtil) get(SCRIPT_UTIL)).init(scriptEngine);
+ ((ScriptAssert) get(ASSERT)).init(scriptEngine);
+ }
+
+ public void postInject(ScriptEngine scriptEngine) {
+ ScriptEngineFactory.bindIndirectionMethods(scriptEngine, SCRIPT_UTIL, get(SCRIPT_UTIL));
+ ScriptEngineFactory.bindIndirectionMethods(scriptEngine, ASSERT, get(ASSERT));
+ }
+
+ public Map.Entry<String, PageControl> getUnlimitedPC() {
+ return castEntry(UNLIMITED_PC, PageControl.class);
+ }
+
+ public Map.Entry<String, PageControl> getPageControl() {
+ return castEntry(PAGE_CONTROL, PageControl.class);
+ }
+
+ public Map.Entry<String, Exporter> getExporter() {
+ return castEntry(EXPORTER, Exporter.class);
+ }
+
+ public Map.Entry<String, Subject> getSubject() {
+ return castEntry(SUBJECT, Subject.class);
+ }
+
+ public Map.Entry<String, TabularWriter> getPretty() {
+ return castEntry(PRETTY, TabularWriter.class);
+ }
+
+ public Map.Entry<String, ScriptUtil> getScriptUtil() {
+ return castEntry(SCRIPT_UTIL, ScriptUtil.class);
+ }
+
+ public Map.Entry<String, ResourceClientFactory> getProxyFactory() {
+ return castEntry(PROXY_FACTORY, ResourceClientFactory.class);
+ }
+
+ public Map<String, Object> getManagers() {
+ //XXX ideally this should be a projection into our map
+ return managers;
+ }
+
+ private Map.Entry<String, Object> getEntry(String key) {
+ for (Map.Entry<String, Object> entry : entrySet()) {
+ if (key == null && entry.getKey() == null) {
+ return entry;
+ } else if (key.equals(entry.getKey())) {
+ return entry;
+ }
+ }
+
+ return null;
+ }
+
+ private <T> Map.Entry<String, T> castEntry(String key, Class<T> clazz) {
+ Map.Entry<String, Object> entry = getEntry(key);
+ if (entry == null) {
+ return null;
+ }
+
+ return new CastingEntry<T>(entry, clazz);
+ }
+}
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
new file mode 100644
index 0000000..2112073
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
@@ -0,0 +1,170 @@
+package org.rhq.bindings.client;
+
+import java.io.PrintWriter;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javassist.ClassPool;
+import javassist.CtNewMethod;
+import javassist.bytecode.ParameterAnnotationsAttribute;
+import javassist.util.proxy.MethodHandler;
+
+import org.rhq.bindings.util.ConfigurationClassBuilder;
+import org.rhq.core.domain.resource.ResourceCreationDataType;
+
+/**
+ *
+ * @author Greg Hinkle
+ * @author Lukas Krejci
+ */
+public class ResourceClientFactory {
+
+ private org.rhq.bindings.client.RhqFacade rhqFacade;
+ private PrintWriter outputWriter;
+
+ public ResourceClientFactory(org.rhq.bindings.client.RhqFacade remoteClient, PrintWriter outputWriter) {
+ this.rhqFacade = remoteClient;
+ this.outputWriter = outputWriter;
+ }
+
+ private static java.util.concurrent.atomic.AtomicInteger classIndex = new java.util.concurrent.atomic.AtomicInteger();
+
+ public org.rhq.bindings.client.RhqFacade getRemoteClient() {
+ return rhqFacade;
+ }
+
+ public PrintWriter getOutputWriter() {
+ return outputWriter;
+ }
+
+ public org.rhq.bindings.client.ResourceClientProxy getResource(int resourceId) {
+
+ org.rhq.bindings.client.ResourceClientProxy proxy = new org.rhq.bindings.client.ResourceClientProxy(this, resourceId);
+ java.lang.Class<?> customInterface = null;
+ try {
+ // define the dynamic class
+ javassist.ClassPool pool = ClassPool.getDefault();
+ javassist.CtClass customClass = pool.makeInterface(org.rhq.bindings.client.ResourceClientProxy.class.getName() + "__Custom__"
+ + classIndex.getAndIncrement());
+
+ for (java.lang.String key : proxy.allProperties.keySet()) {
+ java.lang.Object prop = proxy.allProperties.get(key);
+
+ if (prop instanceof org.rhq.bindings.client.ResourceClientProxy.Measurement) {
+ org.rhq.bindings.client.ResourceClientProxy.Measurement m = (org.rhq.bindings.client.ResourceClientProxy.Measurement) prop;
+ java.lang.String name = org.rhq.bindings.client.ResourceClientProxy.getterName(key);
+
+ try {
+ org.rhq.bindings.client.ResourceClientProxy.class.getMethod(name);
+ } catch (java.lang.NoSuchMethodException nsme) {
+ javassist.CtMethod method = CtNewMethod.abstractMethod(pool.get(org.rhq.bindings.client.ResourceClientProxy.Measurement.class.getName()),
+ org.rhq.bindings.client.ResourceClientProxy.getterName(key), new javassist.CtClass[0], new javassist.CtClass[0], customClass);
+ customClass.addMethod(method);
+ }
+ } else if (prop instanceof org.rhq.bindings.client.ResourceClientProxy.Operation) {
+ org.rhq.bindings.client.ResourceClientProxy.Operation o = (org.rhq.bindings.client.ResourceClientProxy.Operation) prop;
+
+ java.util.LinkedHashMap<java.lang.String, javassist.CtClass> types = ConfigurationClassBuilder.translateParameters(o
+ .getDefinition().getParametersConfigurationDefinition());
+
+ javassist.CtClass[] params = new javassist.CtClass[types.size()];
+ int x = 0;
+ for (java.lang.String param : types.keySet()) {
+ params[x++] = types.get(param);
+ }
+
+ javassist.CtMethod method = CtNewMethod.abstractMethod(ConfigurationClassBuilder.translateConfiguration(o
+ .getDefinition().getResultsConfigurationDefinition()), org.rhq.bindings.client.ResourceClientProxy.simpleName(key), params,
+ new javassist.CtClass[0], customClass);
+
+ // Setup @WebParam annotations so the signatures have the config prop names
+ javassist.bytecode.annotation.Annotation[][] newAnnotations = new javassist.bytecode.annotation.Annotation[params.length][1];
+ int i = 0;
+ for (java.lang.String paramName : types.keySet()) {
+ newAnnotations[i] = new javassist.bytecode.annotation.Annotation[1];
+
+ newAnnotations[i][0] = new javassist.bytecode.annotation.Annotation(javax.jws.WebParam.class.getName(), method.getMethodInfo()
+ .getConstPool());
+ newAnnotations[i][0].addMemberValue("name", new javassist.bytecode.annotation.StringMemberValue(paramName, method
+ .getMethodInfo().getConstPool()));
+ i++;
+ }
+
+ javassist.bytecode.ParameterAnnotationsAttribute newAnnotationsAttribute = new javassist.bytecode.ParameterAnnotationsAttribute(
+ method.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
+ newAnnotationsAttribute.setAnnotations(newAnnotations);
+ method.getMethodInfo().addAttribute(newAnnotationsAttribute);
+
+ customClass.addMethod(method);
+ }
+ }
+
+ customInterface = customClass.toClass();
+ } catch (javassist.NotFoundException e) {
+ e.printStackTrace();
+ } catch (javassist.CannotCompileException e) {
+ e.printStackTrace();
+ } catch (java.lang.Exception e) {
+ e.printStackTrace();
+ }
+
+ if (customInterface != null) {
+
+ java.util.List<java.lang.Class<?>> interfaces = new java.util.ArrayList<java.lang.Class<?>>();
+ interfaces.add(customInterface);
+ if (proxy.resourceConfigurationDefinition != null) {
+ interfaces.add(getResourceConfigurableInterface());
+ }
+ if (proxy.pluginConfigurationDefinition != null) {
+ interfaces.add(getPluginConfigurableInterface());
+ }
+
+ if (proxy.getResourceType().getCreationDataType() == ResourceCreationDataType.CONTENT) {
+ interfaces.add(getContentBackedInterface());
+ }
+
+ interfaces.addAll(getAdditionalInterfaces(proxy));
+
+ javassist.util.proxy.ProxyFactory proxyFactory = new javassist.util.proxy.ProxyFactory();
+ proxyFactory.setInterfaces(interfaces.toArray(new java.lang.Class[interfaces.size()]));
+ proxyFactory.setSuperclass(org.rhq.bindings.client.ResourceClientProxy.class);
+ org.rhq.bindings.client.ResourceClientProxy proxied = null;
+ try {
+ proxied = (org.rhq.bindings.client.ResourceClientProxy) proxyFactory.create(new java.lang.Class[]{}, new java.lang.Object[]{},
+ instantiateMethodHandler(proxy, interfaces, rhqFacade));
+ } catch (java.lang.InstantiationException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (java.lang.IllegalAccessException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (java.lang.NoSuchMethodException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ return proxied;
+ }
+ return proxy;
+
+ }
+
+ protected Class<?> getResourceConfigurableInterface() {
+ return org.rhq.bindings.client.ResourceClientProxy.ResourceConfigurable.class;
+ }
+
+ protected Class<?> getPluginConfigurableInterface() {
+ return org.rhq.bindings.client.ResourceClientProxy.PluginConfigurable.class;
+ }
+
+ protected Class<?> getContentBackedInterface() {
+ return org.rhq.bindings.client.ResourceClientProxy.ContentBackedResource.class;
+ }
+
+ protected Set<Class<?>> getAdditionalInterfaces(ResourceClientProxy proxy) {
+ return Collections.emptySet();
+ }
+
+ protected MethodHandler instantiateMethodHandler(ResourceClientProxy proxy, List<Class<?>> interfaces, org.rhq.bindings.client.RhqFacade remoteClient) {
+ return new org.rhq.bindings.client.ResourceClientProxy.ClientProxyMethodHandler(proxy, remoteClient);
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
new file mode 100644
index 0000000..b67acf1
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
@@ -0,0 +1,637 @@
+/*
+ * 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.bindings.client;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+
+import org.rhq.bindings.util.ConfigurationClassBuilder;
+import org.rhq.bindings.util.LazyLoadScenario;
+import org.rhq.bindings.util.ScriptUtil;
+import org.rhq.bindings.util.ShortOutput;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.content.InstalledPackage;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.PackageVersion;
+import org.rhq.core.domain.criteria.MeasurementDefinitionCriteria;
+import org.rhq.core.domain.criteria.OperationDefinitionCriteria;
+import org.rhq.core.domain.criteria.PackageVersionCriteria;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementCategory;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.core.domain.util.Summary;
+import org.rhq.core.server.MeasurementConverter;
+import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
+
+/**
+ * Implements a local object that exposes resource related data as
+ * if it were local.
+ *
+ * @author Greg Hinkle
+ * @author Lukas Krejci
+ */
+public class ResourceClientProxy {
+
+ private ResourceClientFactory proxyFactory;
+ private RhqFacade remoteClient;
+ private int resourceId;
+ private Resource resource;
+
+ Map<String, Object> allProperties = new HashMap<String, Object>();
+
+ // Metadata
+ private List<MeasurementDefinition> measurementDefinitions;
+ private Map<String, Measurement> measurementMap = new HashMap<String, Measurement>();
+
+ private List<OperationDefinition> operationDefinitions;
+ private Map<String, Operation> operationMap = new HashMap<String, Operation>();
+
+ private Map<String, ContentType> contentTypes = new HashMap<String, ContentType>();
+
+ private List<ResourceClientProxy> children;
+ ConfigurationDefinition resourceConfigurationDefinition;
+ ConfigurationDefinition pluginConfigurationDefinition;
+
+ public ResourceClientProxy() {
+ }
+
+ public ResourceClientProxy(ResourceClientProxy parentProxy) {
+ this.proxyFactory = parentProxy.proxyFactory;
+ this.remoteClient = parentProxy.remoteClient;
+ this.resourceId = parentProxy.resourceId;
+ this.resource = parentProxy.resource;
+ this.allProperties = parentProxy.allProperties;
+ this.measurementDefinitions = parentProxy.measurementDefinitions;
+ this.measurementMap = parentProxy.measurementMap;
+ this.children = parentProxy.children;
+
+ }
+
+ public ResourceClientProxy(ResourceClientFactory factory, int resourceId) {
+ this.proxyFactory = factory;
+ this.remoteClient = factory.getRemoteClient();
+ this.resourceId = resourceId;
+
+ init();
+ }
+
+ @Summary(index = 0)
+ public int getId() {
+ return resourceId;
+ }
+
+ @Summary(index = 1)
+ public String getName() {
+ return resource.getName();
+ }
+
+ public String getDescription() {
+ return resource.getDescription();
+ }
+
+ @Summary(index = 2)
+ public String getVersion() {
+ return resource.getVersion();
+ }
+
+ @Summary(index = 3)
+ public ResourceType getResourceType() {
+ return resource.getResourceType();
+ }
+
+ public Date getCreatedDate() {
+ return new Date(resource.getCtime());
+ }
+
+ public Date getModifiedDate() {
+ return new Date(resource.getCtime());
+ }
+
+ public Measurement getMeasurement(String name) {
+ return this.measurementMap.get(name);
+ }
+
+ public Measurement[] getMeasurements() {
+ return this.measurementMap.values().toArray(new Measurement[this.measurementMap.size()]);
+ }
+
+ public Operation[] getOperations() {
+ return this.operationMap.values().toArray(new Operation[this.operationMap.size()]);
+ }
+
+ public Map<String, ContentType> getContentTypes() {
+ return contentTypes;
+ }
+
+ public ResourceClientProxy[] getChildren() {
+ if (children == null && LazyLoadScenario.isShouldLoad()) {
+ children = new ArrayList<ResourceClientProxy>();
+
+ initChildren();
+
+ }
+ return children.toArray(new ResourceClientProxy[children.size()]);
+ }
+
+ public ResourceClientProxy getChild(String name) {
+ for (ResourceClientProxy child : getChildren()) {
+ if (name.equals(child.getName()))
+ return child;
+ }
+ return null;
+ }
+
+ public String toString() {
+ return "[" + resourceId + "] " + resource.getName() + " (" + resource.getResourceType().getName() + "::"
+ + resource.getResourceType().getPlugin() + ")";
+ }
+
+ public void init() {
+
+ this.resource = remoteClient.getResourceManager().getResource(remoteClient.getSubject(), resourceId);
+
+ // Lazy init children, not here
+ initMeasurements();
+ initOperations();
+ initConfigDefs();
+ initContent();
+ }
+
+ private void initConfigDefs() {
+ this.resourceConfigurationDefinition = remoteClient.getConfigurationManager()
+ .getResourceConfigurationDefinitionWithTemplatesForResourceType(remoteClient.getSubject(),
+ resource.getResourceType().getId());
+ this.pluginConfigurationDefinition = remoteClient.getConfigurationManager()
+ .getPluginConfigurationDefinitionForResourceType(remoteClient.getSubject(),
+ resource.getResourceType().getId());
+ }
+
+ private void initChildren() {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterParentResourceId(resourceId);
+ PageList<Resource> childResources = remoteClient.getResourceManager().findResourcesByCriteria(
+ remoteClient.getSubject(), criteria);
+
+ for (Resource child : childResources) {
+ this.children.add(proxyFactory.getResource(child.getId()));
+ }
+ }
+
+ private void initMeasurements() {
+ MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
+ criteria.addFilterResourceTypeId(resource.getResourceType().getId());
+// criteria.addFilterResourceTypeName(resource.getResourceType().getName());
+// criteria.setStrict(true);
+
+ this.measurementDefinitions = remoteClient.getMeasurementDefinitionManager()
+ .findMeasurementDefinitionsByCriteria(remoteClient.getSubject(), criteria);
+
+ this.measurementMap = new HashMap<String, Measurement>();
+ for (MeasurementDefinition def : measurementDefinitions) {
+ Measurement m = new Measurement(def);
+
+ String name = def.getDisplayName().replaceAll("\\W", "");
+ name = decapitalize(name);
+
+ this.measurementMap.put(name, m);
+ this.allProperties.put(name, m);
+ }
+ }
+
+ public void initOperations() {
+ OperationDefinitionCriteria criteria = new OperationDefinitionCriteria();
+ criteria.addFilterResourceIds(resourceId);
+ criteria.fetchParametersConfigurationDefinition(true);
+ criteria.fetchResultsConfigurationDefinition(true);
+
+ this.operationDefinitions = remoteClient.getOperationManager().findOperationDefinitionsByCriteria(
+ remoteClient.getSubject(), criteria);
+
+ for (OperationDefinition def : operationDefinitions) {
+ Operation o = new Operation(def);
+ this.operationMap.put(o.getName(), o);
+ this.allProperties.put(o.getName(), o);
+ }
+ }
+
+ private void initContent() {
+ ContentManagerRemote contentManager = remoteClient.getContentManager();
+ List<PackageType> types = null;
+ try {
+ types = contentManager.findPackageTypes(remoteClient.getSubject(), resource.getResourceType().getName(),
+ resource.getResourceType().getPlugin());
+
+ for (PackageType packageType : types) {
+ contentTypes.put(packageType.getName(), new ContentType(packageType));
+ }
+ } catch (ResourceTypeNotFoundException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ }
+
+ public class ContentType {
+
+ private PackageType packageType;
+
+ public ContentType(PackageType packageType) {
+ this.packageType = packageType;
+ }
+
+ public PackageType getPackageType() {
+ return this.packageType;
+ }
+
+ public List<PackageVersion> getInstalledPackages() {
+ ContentManagerRemote contentManager = remoteClient.getContentManager();
+
+ PackageVersionCriteria criteria = new PackageVersionCriteria();
+ criteria.addFilterResourceId(resourceId);
+ // criteria.addFilterPackageTypeId() TODO ADD this when the filter is added
+
+ return contentManager.findPackageVersionsByCriteria(remoteClient.getSubject(), criteria);
+ }
+
+ public String toString() {
+ return this.packageType.getDisplayName();
+ }
+
+ }
+
+ public class Measurement implements ShortOutput {
+
+ MeasurementDefinition definition;
+
+ public Measurement(MeasurementDefinition definition) {
+ this.definition = definition;
+ }
+
+ @Summary(index = 0)
+ public String getName() {
+ return definition.getDisplayName();
+ }
+
+ @Summary(index = 1)
+ public String getDisplayValue() {
+ Object val = getValue();
+ if (val instanceof Number) {
+ return MeasurementConverter.format(((Number) val).doubleValue(), getUnits(), true);
+ } else {
+ return String.valueOf(val);
+ }
+ }
+
+ @Summary(index = 2)
+ public String getDescription() {
+ return definition.getDescription();
+ }
+
+ public DataType getDataType() {
+ return definition.getDataType();
+ }
+
+ public MeasurementCategory getCategory() {
+ return definition.getCategory();
+ }
+
+ public MeasurementUnits getUnits() {
+ return definition.getUnits();
+ }
+
+ public Object getValue() {
+ try {
+ Set<MeasurementData> d = remoteClient.getMeasurementDataManager().findLiveData(
+ remoteClient.getSubject(), resourceId, new int[] { definition.getId() });
+ MeasurementData data = d.iterator().next();
+ return data.getValue();
+ } catch (Exception e) {
+ return "?";
+ }
+ }
+
+ public String toString() {
+ return getName();
+ }
+ public String getShortOutput() {
+ return getDisplayValue();
+ }
+ }
+
+ public class Operation {
+ OperationDefinition definition;
+
+ public Operation(OperationDefinition definition) {
+ this.definition = definition;
+ }
+
+ @Summary(index = 0)
+ public String getName() {
+ return simpleName(this.definition.getDisplayName());
+ }
+
+ @Summary(index = 1)
+ public String getDescription() {
+ return this.definition.getDescription();
+ }
+
+ public OperationDefinition getDefinition() {
+ return definition;
+ }
+
+ public Object invoke(Object[] args) throws Exception {
+ if (!LazyLoadScenario.isShouldLoad())
+ return null;
+
+ Configuration parameters = ConfigurationClassBuilder.translateParametersToConfig(definition
+ .getParametersConfigurationDefinition(), args);
+
+ ResourceOperationSchedule schedule = remoteClient.getOperationManager().scheduleResourceOperation(
+ remoteClient.getSubject(), resourceId, definition.getName(), 0, 0, 0, 30000, parameters,
+ "Executed from commandline");
+
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+ criteria.addFilterJobId(schedule.getJobId());
+ criteria.addFilterResourceIds(resourceId);
+ criteria.addSortStartTime(PageOrdering.DESC); // put most recent at top of results
+ criteria.setPaging(0, 1); // only return one result, in effect the latest
+ criteria.fetchOperationDefinition(true);
+ criteria.fetchParameters(true);
+ criteria.fetchResults(true);
+
+ int retries = 10;
+ ResourceOperationHistory history = null;
+ while (history == null && retries-- > 0) {
+ Thread.sleep(1000);
+ PageList<ResourceOperationHistory> histories = remoteClient.getOperationManager()
+ .findResourceOperationHistoriesByCriteria(remoteClient.getSubject(), criteria);
+ if (histories.size() > 0 && histories.get(0).getStatus() != OperationRequestStatus.INPROGRESS) {
+ history = histories.get(0);
+ }
+ }
+
+ Configuration result = (history != null ? history.getResults() : null);
+
+ Object returnResults = ConfigurationClassBuilder.translateResults(definition
+ .getResultsConfigurationDefinition(), result);
+
+ return returnResults;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+ }
+
+ public static class ClientProxyMethodHandler implements MethodHandler, ContentBackedResource, PluginConfigurable,
+ ResourceConfigurable {
+
+ ResourceClientProxy resourceClientProxy;
+ RhqFacade remoteClient;
+
+ public ClientProxyMethodHandler(ResourceClientProxy resourceClientProxy, RhqFacade remoteClient) {
+ this.resourceClientProxy = resourceClientProxy;
+ this.remoteClient = remoteClient;
+ }
+
+ // ------------------------------------------------------------------------------------------------------
+ // Methods here are optional and only accessible if their declared on the custom resource interface class
+
+ public Configuration getPluginConfiguration() {
+ if (!LazyLoadScenario.isShouldLoad())
+ return null;
+ return remoteClient.getConfigurationManager().getPluginConfiguration(remoteClient.getSubject(),
+ resourceClientProxy.resourceId);
+ }
+
+ public ConfigurationDefinition getPluginConfigurationDefinition() {
+ return resourceClientProxy.pluginConfigurationDefinition;
+ }
+
+ public PluginConfigurationUpdate updatePluginConfiguration(Configuration configuration) {
+ PluginConfigurationUpdate update =
+ remoteClient.getConfigurationManager().updatePluginConfiguration(
+ remoteClient.getSubject(),
+ resourceClientProxy.getId(),
+ configuration);
+
+ return update;
+ }
+
+ public Configuration getResourceConfiguration() {
+ if (!LazyLoadScenario.isShouldLoad())
+ return null;
+
+ return remoteClient.getConfigurationManager().getResourceConfiguration(remoteClient.getSubject(),
+ resourceClientProxy.resourceId);
+ }
+
+ public ConfigurationDefinition getResourceConfigurationDefinition() {
+ return resourceClientProxy.resourceConfigurationDefinition;
+ }
+
+ public ResourceConfigurationUpdate updateResourceConfiguration(Configuration configuration) {
+ ResourceConfigurationUpdate update =
+ remoteClient.getConfigurationManager().updateResourceConfiguration(
+ remoteClient.getSubject(),
+ resourceClientProxy.getId(),
+ configuration);
+
+ return update;
+
+ }
+
+ public InstalledPackage getBackingContent() {
+
+ return remoteClient.getContentManager().getBackingPackageForResource(remoteClient.getSubject(), resourceClientProxy.resourceId);
+ }
+
+ public void updateBackingContent(String filename) {
+ File file = new File(filename);
+ if (!file.exists()) {
+ throw new IllegalArgumentException("File not found: " + file.getAbsolutePath());
+ }
+ if (file.isDirectory()) {
+ throw new IllegalArgumentException("File expected, found directory: " + file.getAbsolutePath());
+ }
+
+
+ InstalledPackage oldPackage = getBackingContent();
+
+
+ String oldVersion = oldPackage.getPackageVersion().getVersion();
+ String newVersion = "1.0";
+ if (oldVersion != null && oldVersion.length() != 0) {
+ String[] parts = oldVersion.split("[^a-zA-Z0-9]");
+ String lastPart = parts[parts.length-1];
+ try {
+ int lastNumber = Integer.parseInt(lastPart);
+ newVersion = oldVersion.substring(0, oldVersion.length() - lastPart.length()) + (lastNumber + 1);
+ } catch (NumberFormatException nfe) {
+ newVersion = oldVersion + ".1";
+ }
+ }
+
+ byte[] fileContents = new ScriptUtil(remoteClient).getFileBytes(filename);
+
+
+ PackageVersion pv =
+ remoteClient.getContentManager().createPackageVersion(
+ remoteClient.getSubject(),
+ oldPackage.getPackageVersion().getGeneralPackage().getName(),
+ oldPackage.getPackageVersion().getGeneralPackage().getPackageType().getId(),
+ newVersion,
+ oldPackage.getPackageVersion().getArchitecture().getId(),
+ fileContents);
+
+ remoteClient.getContentManager().deployPackages(
+ remoteClient.getSubject(),
+ new int[] { resourceClientProxy.getId()},
+ new int[] {pv.getId()});
+
+
+ }
+
+ public void retrieveBackingContent(String fileName) throws IOException {
+
+ InstalledPackage installedPackage = getBackingContent();
+
+ if (fileName == null )
+ fileName = installedPackage.getPackageVersion().getFileName();
+
+ File file = new File(fileName);
+
+ byte[] data =
+ remoteClient.getContentManager().getPackageBytes(
+ remoteClient.getSubject(), resourceClientProxy.resourceId, installedPackage.getId());
+
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(data);
+ fos.close();
+
+ }
+
+ // ------------------------------------------------------------------------------------------------------
+
+
+
+ public Object invoke(Object proxy, Method method, Method proceedMethod, Object[] args) throws Throwable {
+
+ if (proceedMethod != null) {
+ Method realMethod = ResourceClientProxy.class.getMethod(method.getName(), method.getParameterTypes());
+ return realMethod.invoke(resourceClientProxy, args);
+ } else {
+
+ try {
+ Method localMethod = ClientProxyMethodHandler.class.getDeclaredMethod(method.getName(), method
+ .getParameterTypes());
+ return localMethod.invoke(this, args);
+ } catch (NoSuchMethodException nsme) {
+
+ String name = method.getName();
+ Object key = resourceClientProxy.allProperties.get(name);
+ if (key == null) {
+ name = decapitalize(method.getName().substring(3, method.getName().length()));
+ key = resourceClientProxy.allProperties.get(name);
+ }
+
+ if (key != null) {
+ if (key instanceof Measurement) {
+ return key;
+ } else if (key instanceof Operation) {
+ resourceClientProxy.proxyFactory.getOutputWriter().println("Invoking operation " + ((Operation) key).getName());
+
+ return ((Operation) key).invoke(args);
+
+ }
+ }
+ }
+
+ throw new RuntimeException("Can't find custom method: " + method);
+ }
+ }
+ }
+
+
+ static String simpleName(String name) {
+ return decapitalize(name.replaceAll("\\W", ""));
+ }
+
+ private static String decapitalize(String name) {
+ return Character.toLowerCase(name.charAt(0)) + name.substring(1, name.length());
+ }
+
+ static String getterName(String name) {
+ return "get" + Character.toUpperCase(name.charAt(0)) + name.substring(1, name.length());
+ }
+
+ public static interface PluginConfigurable {
+ public Configuration getPluginConfiguration();
+
+ public ConfigurationDefinition getPluginConfigurationDefinition();
+
+ public PluginConfigurationUpdate updatePluginConfiguration(Configuration configuration);
+ }
+
+ public static interface ResourceConfigurable {
+ public Configuration getResourceConfiguration();
+
+ public ConfigurationDefinition getResourceConfigurationDefinition();
+
+ public ResourceConfigurationUpdate updateResourceConfiguration(Configuration configuration);
+ }
+
+ public static interface ContentBackedResource {
+
+ public InstalledPackage getBackingContent();
+
+
+ public void updateBackingContent(String fileName);
+
+
+ public void retrieveBackingContent(String fileName) throws IOException;
+
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java
new file mode 100644
index 0000000..24fbc3b
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java
@@ -0,0 +1,132 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.bindings.client;
+
+import java.util.Map;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.enterprise.server.alert.AlertDefinitionManagerRemote;
+import org.rhq.enterprise.server.alert.AlertManagerRemote;
+import org.rhq.enterprise.server.auth.SubjectManagerRemote;
+import org.rhq.enterprise.server.authz.RoleManagerRemote;
+import org.rhq.enterprise.server.bundle.BundleManagerRemote;
+import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
+import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.content.RepoManagerRemote;
+import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
+import org.rhq.enterprise.server.event.EventManagerRemote;
+import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
+import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
+import org.rhq.enterprise.server.measurement.CallTimeDataManagerRemote;
+import org.rhq.enterprise.server.measurement.MeasurementBaselineManagerRemote;
+import org.rhq.enterprise.server.measurement.MeasurementDataManagerRemote;
+import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerRemote;
+import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerRemote;
+import org.rhq.enterprise.server.operation.OperationManagerRemote;
+import org.rhq.enterprise.server.report.DataAccessManagerRemote;
+import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
+import org.rhq.enterprise.server.resource.ResourceManagerRemote;
+import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
+import org.rhq.enterprise.server.resource.group.ResourceGroupManagerRemote;
+import org.rhq.enterprise.server.search.SavedSearchManagerRemote;
+import org.rhq.enterprise.server.support.SupportManagerRemote;
+import org.rhq.enterprise.server.system.SystemManagerRemote;
+import org.rhq.enterprise.server.tagging.TagManagerRemote;
+
+/**
+ * This is an interface through which the script can communicate with RHQ server.
+ *
+ * @author Lukas Krejci
+ */
+public interface RhqFacade {
+
+ /**
+ * @return the user the facade is authenticated as
+ */
+ Subject getSubject();
+
+ Subject login(String user, String password) throws Exception;
+
+ void logout();
+
+ boolean isLoggedIn();
+
+ AlertManagerRemote getAlertManager();
+
+ AlertDefinitionManagerRemote getAlertDefinitionManager();
+
+ AvailabilityManagerRemote getAvailabilityManager();
+
+ BundleManagerRemote getBundleManager();
+
+ CallTimeDataManagerRemote getCallTimeDataManager();
+
+ RepoManagerRemote getRepoManager();
+
+ ConfigurationManagerRemote getConfigurationManager();
+
+ ContentManagerRemote getContentManager();
+
+ DataAccessManagerRemote getDataAccessManager();
+
+ DiscoveryBossRemote getDiscoveryBoss();
+
+ EventManagerRemote getEventManager();
+
+ MeasurementBaselineManagerRemote getMeasurementBaselineManager();
+
+ MeasurementDataManagerRemote getMeasurementDataManager();
+
+ MeasurementDefinitionManagerRemote getMeasurementDefinitionManager();
+
+ MeasurementScheduleManagerRemote getMeasurementScheduleManager();
+
+ OperationManagerRemote getOperationManager();
+
+ ResourceManagerRemote getResourceManager();
+
+ ResourceFactoryManagerRemote getResourceFactoryManager();
+
+ ResourceGroupManagerRemote getResourceGroupManager();
+
+ ResourceTypeManagerRemote getResourceTypeManager();
+
+ RoleManagerRemote getRoleManager();
+
+ SavedSearchManagerRemote getSavedSearchManager();
+
+ SubjectManagerRemote getSubjectManager();
+
+ SupportManagerRemote getSupportManager();
+
+ SystemManagerRemote getSystemManager();
+
+ RemoteInstallManagerRemote getRemoteInstallManager();
+
+ TagManagerRemote getTagManager();
+
+ /**
+ * This map is constructed using all the elements in the {@link RhqManagers} enum which are then proxied
+ * using this instance.
+ *
+ * @return a map of all available proxied managers keyed by their names.
+ */
+ Map<String, Object> getManagers();
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java
new file mode 100644
index 0000000..b4e6f21
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java
@@ -0,0 +1,116 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.bindings.client;
+
+import org.rhq.enterprise.server.alert.AlertDefinitionManagerRemote;
+import org.rhq.enterprise.server.alert.AlertManagerRemote;
+import org.rhq.enterprise.server.auth.SubjectManagerRemote;
+import org.rhq.enterprise.server.authz.RoleManagerRemote;
+import org.rhq.enterprise.server.bundle.BundleManagerRemote;
+import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
+import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.content.RepoManagerRemote;
+import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
+import org.rhq.enterprise.server.event.EventManagerRemote;
+import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
+import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
+import org.rhq.enterprise.server.measurement.CallTimeDataManagerRemote;
+import org.rhq.enterprise.server.measurement.MeasurementBaselineManagerRemote;
+import org.rhq.enterprise.server.measurement.MeasurementDataManagerRemote;
+import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerRemote;
+import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerRemote;
+import org.rhq.enterprise.server.operation.OperationManagerRemote;
+import org.rhq.enterprise.server.report.DataAccessManagerRemote;
+import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
+import org.rhq.enterprise.server.resource.ResourceManagerRemote;
+import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
+import org.rhq.enterprise.server.resource.group.ResourceGroupManagerRemote;
+import org.rhq.enterprise.server.search.SavedSearchManagerRemote;
+import org.rhq.enterprise.server.support.SupportManagerRemote;
+import org.rhq.enterprise.server.system.SystemManagerRemote;
+import org.rhq.enterprise.server.tagging.TagManagerRemote;
+
+/**
+ * An enumeration of all remote SLSBs of the RHQ server.
+ *
+ * @author Lukas Krejci
+ * @author Greg Hinkle
+ */
+public enum RhqManagers {
+ AlertManager(AlertManagerRemote.class), //
+ AlertDefinitionManager(AlertDefinitionManagerRemote.class), //
+ AvailabilityManager(AvailabilityManagerRemote.class), //
+ BundleManager(BundleManagerRemote.class), //
+ CallTimeDataManager(CallTimeDataManagerRemote.class), //
+ RepoManager(RepoManagerRemote.class), //
+ ConfigurationManager(ConfigurationManagerRemote.class), //
+ ContentManager(ContentManagerRemote.class), //
+ DataAccessManager(DataAccessManagerRemote.class), //
+ DiscoveryBoss(DiscoveryBossRemote.class), //
+ EventManager(EventManagerRemote.class), //
+ MeasurementBaselineManager(MeasurementBaselineManagerRemote.class), //
+ MeasurementDataManager(MeasurementDataManagerRemote.class), //
+ MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class), //
+ MeasurementScheduleManager(MeasurementScheduleManagerRemote.class), //
+ OperationManager(OperationManagerRemote.class), //
+ ResourceManager(ResourceManagerRemote.class), //
+ ResourceFactoryManager(ResourceFactoryManagerRemote.class), //
+ ResourceGroupManager(ResourceGroupManagerRemote.class), //
+ ResourceTypeManager(ResourceTypeManagerRemote.class), //
+ RoleManager(RoleManagerRemote.class), //
+ SavedSearchManager(SavedSearchManagerRemote.class), //
+ SubjectManager(SubjectManagerRemote.class), //
+ SupportManager(SupportManagerRemote.class), //
+ SystemManager(SystemManagerRemote.class), //
+ RemoteInstallManager(RemoteInstallManagerRemote.class), //
+ TagManager(TagManagerRemote.class);
+
+ private Class<?> remote;
+ private String remoteName;
+ private String beanName;
+
+ private RhqManagers(Class<?> remote) {
+ this.remote = remote;
+ this.beanName = this.name() + "Bean";
+ this.remoteName = this.name() + "Remote";
+ }
+
+ public static RhqManagers forInterface(Class<?> iface) {
+ for (RhqManagers m : values()) {
+ if (m.remote().equals(iface)) {
+ return m;
+ }
+ }
+
+ return null;
+ }
+
+ public Class<?> remote() {
+ return this.remote;
+ }
+
+ public String beanName() {
+ return this.beanName;
+ }
+
+ public String remoteName() {
+ return this.remoteName;
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java
index 8186831..30b79e1 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java
@@ -19,6 +19,7 @@
package org.rhq.bindings.engine;
+import java.lang.reflect.Method;
import java.util.List;
import javax.script.ScriptEngine;
@@ -32,13 +33,13 @@ import javax.script.ScriptException;
*/
public class JsEngineInitializer implements ScriptEngineInitializer {
- public String getEngineName() {
- return "JavaScript";
+ public boolean implementsLanguage(String language) {
+ return language != null && ("JavaScript".equals(language) || "ECMAScript".equals(language));
}
public ScriptEngine instantiate(List<String> packages) throws ScriptException {
ScriptEngineManager sem = new ScriptEngineManager();
- ScriptEngine eng = sem.getEngineByName(getEngineName());
+ ScriptEngine eng = sem.getEngineByName("JavaScript");
for(String pkg : packages) {
eng.eval("importPackage(" + pkg + ")");
@@ -47,4 +48,25 @@ public class JsEngineInitializer implements ScriptEngineInitializer {
return eng;
}
+ public String generateIndirectionMethod(String boundObjectName, Method method) {
+ String methodName = method.getName();
+ int argCount = method.getParameterTypes().length;
+
+ StringBuilder functionBuilder = new StringBuilder();
+ functionBuilder.append(methodName).append("(");
+ for (int i = 0; i < argCount; ++i) {
+ if (i != 0) {
+ functionBuilder.append(", ");
+ }
+ functionBuilder.append("arg_" + i);
+ }
+ functionBuilder.append(")");
+ String functionFragment = functionBuilder.toString();
+ boolean returnsVoid = method.getReturnType().equals(Void.TYPE);
+
+ String functionDefinition = "function " + functionFragment + " { " + (returnsVoid ? "" : "return ")
+ + boundObjectName + "." + functionFragment + "; }";
+
+ return functionDefinition;
+ }
}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/ScriptEngineInitializer.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/ScriptEngineInitializer.java
index bc76433..d938589 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/ScriptEngineInitializer.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/ScriptEngineInitializer.java
@@ -19,20 +19,41 @@
package org.rhq.bindings.engine;
+import java.lang.reflect.Method;
import java.util.List;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
/**
- * Is able to instatiate a script engine and import packages into the context
+ * Is able to instantiate a script engine and import packages into the context
* of the engine.
*
* @author Lukas Krejci
*/
public interface ScriptEngineInitializer {
- String getEngineName();
+ boolean implementsLanguage(String language);
ScriptEngine instantiate(List<String> packages) throws ScriptException;
+
+ /**
+ * This function returns a definition string in the script engine's language
+ * that provides an indirection to calling the method on the bound object.
+ *
+ * for example for parameters:
+ * <ul>
+ * <li> <code>boundObjectName = foo</code>
+ * <li> <code> method = <int bar(int)></code>
+ * </ul>
+ * The method would generate this javascript:<br/>
+ * <code>
+ * function bar(arg) { return foo.bar(arg); }
+ * </code>
+ *
+ * @param boundObjectName
+ * @param method
+ * @return a string with method definition in the scripting language
+ */
+ String generateIndirectionMethod(String boundObjectName, Method method);
}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ConfigurationClassBuilder.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ConfigurationClassBuilder.java
new file mode 100644
index 0000000..29bd4a6
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ConfigurationClassBuilder.java
@@ -0,0 +1,158 @@
+/*
+ * 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.bindings.util;
+
+import java.util.LinkedHashMap;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ConfigurationClassBuilder {
+
+ public static LinkedHashMap<String, CtClass> translateParameters(ConfigurationDefinition def)
+ throws NotFoundException {
+ LinkedHashMap<String, CtClass> result = new LinkedHashMap<String, CtClass>();
+ if (def == null || def.getPropertyDefinitions() == null) {
+ return result;
+ }
+
+ for (PropertyDefinition pd : def.getPropertyDefinitions().values()) {
+ if (pd instanceof PropertyDefinitionSimple) {
+ PropertyDefinitionSimple simple = (PropertyDefinitionSimple) pd;
+ String name = simpleName(simple.getDisplayName());
+ CtClass paramType = getSimpleTypeClass(simple);
+ result.put(name, paramType);
+ }
+ }
+ return result;
+ }
+
+ private static CtClass getSimpleTypeClass(PropertyDefinitionSimple simple) throws NotFoundException {
+ Class<?> paramType = null;
+ switch (simple.getType()) {
+ case STRING:
+ case LONG_STRING:
+ case PASSWORD:
+ case FILE:
+ case DIRECTORY:
+ paramType = String.class;
+ break;
+ case BOOLEAN:
+ paramType = Boolean.TYPE;
+ break;
+ case INTEGER:
+ paramType = Integer.TYPE;
+ break;
+ case LONG:
+ paramType = Long.TYPE;
+ break;
+ case FLOAT:
+ paramType = Float.TYPE;
+ break;
+ case DOUBLE:
+ paramType = Double.TYPE;
+ break;
+ }
+ return ClassPool.getDefault().get(paramType.getName());
+ }
+
+ public static CtClass translateConfiguration(ConfigurationDefinition def) throws NotFoundException {
+ if (def == null) {
+ return CtClass.voidType;
+ } else if (def.getPropertyDefinitionSimple("operationResult") != null) {
+ // Its a simple type
+ return getSimpleTypeClass(def.getPropertyDefinitionSimple("operationResult"));
+ } else {
+
+ // TODO GH: Build a custom type?
+ return ClassPool.getDefault().get(Configuration.class.getName());
+ }
+ }
+
+ private static String simpleName(String name) {
+ return decapitalize(name.replaceAll("\\W", ""));
+ }
+
+ private static String decapitalize(String name) {
+ return Character.toLowerCase(name.charAt(0)) + name.substring(1, name.length());
+ }
+
+ public static Configuration translateParametersToConfig(ConfigurationDefinition parametersConfigurationDefinition,
+ Object[] args) throws NotFoundException {
+ LinkedHashMap<String, CtClass> translateParameters = translateParameters(parametersConfigurationDefinition);
+ Configuration config = new Configuration();
+
+ int index = 0;
+ for (String key : translateParameters.keySet()) {
+ config.put(new PropertySimple(key, args[index++]));
+
+ }
+ return config;
+
+ }
+
+ public static Object translateResults(ConfigurationDefinition resultsConfigurationDefinition, Configuration result)
+ throws NotFoundException {
+
+ CtClass expectedReturn = translateConfiguration(resultsConfigurationDefinition);
+
+ if (expectedReturn.equals(ClassPool.getDefault().get(Configuration.class.getName()))) {
+ return result;
+ } else {
+ //bail on translation if Configuration passed in is null
+ if (result == null)
+ return result;
+ PropertySimple simple = result.getSimple("operationResult");
+ if (simple != null) {
+ if (expectedReturn.getName().equals(String.class.getName())) {
+ return simple.getStringValue();
+ } else if (expectedReturn.getName().equals(Boolean.class.getName())
+ || expectedReturn.getName().equals(Boolean.TYPE.getName())) {
+ return simple.getBooleanValue();
+ } else if (expectedReturn.getName().equals(Integer.class.getName())
+ || expectedReturn.getName().equals(Integer.TYPE.getName())) {
+ return simple.getIntegerValue();
+ } else if (expectedReturn.getName().equals(Long.class.getName())
+ || expectedReturn.getName().equals(Long.TYPE.getName())) {
+ return simple.getLongValue();
+ } else if (expectedReturn.getName().equals(Float.class.getName())
+ || expectedReturn.getName().equals(Float.TYPE.getName())) {
+ return simple.getFloatValue();
+ } else if (expectedReturn.getName().equals(Double.class.getName())
+ || expectedReturn.getName().equals(Double.TYPE.getName())) {
+ return simple.getDoubleValue();
+ } else if (expectedReturn.getName().equals(Boolean.class.getName())
+ || expectedReturn.getName().equals(Boolean.TYPE.getName())) {
+ return simple.getBooleanValue();
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/InterfaceSimplifier.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/InterfaceSimplifier.java
new file mode 100644
index 0000000..fba954a
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/InterfaceSimplifier.java
@@ -0,0 +1,128 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.bindings.util;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+import javassist.NotFoundException;
+import javassist.bytecode.ParameterAnnotationsAttribute;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+
+/**
+ * The scripts can use simplified interfaces that omit the first "Subject" argument
+ * to most methods. This helper class prepares such simplified interfaces.
+ *
+ * @author Greg Hinkle
+ * @author Lukas Krejci
+ */
+public class InterfaceSimplifier {
+ private static final Log LOG = LogFactory.getLog(InterfaceSimplifier.class);
+
+ private InterfaceSimplifier() {
+
+ }
+
+ public static Class<?> simplify(Class<?> intf) {
+ try {
+ ClassPool cp = ClassPool.getDefault();
+
+ String simpleName = intf.getName() + "Simple";
+
+ try {
+ CtClass cached = cp.get(simpleName);
+ return Class.forName(simpleName, false, cp.getClassLoader());
+
+ } catch (NotFoundException e) {
+ // ok... load it
+ } catch (ClassNotFoundException e) {
+ LOG.debug("Class [" + simpleName + "] not found - cause: " + e);
+ }
+
+ CtClass cc = cp.get(intf.getName());
+
+ CtClass cz = cp.getAndRename(intf.getName(), simpleName);
+ // CtClass cz = cp.makeInterface(simpleName, cc);
+
+ cz.defrost();
+
+ cz.setSuperclass(cc);
+
+ CtMethod[] methods = cc.getMethods();
+
+ for (CtMethod originalMethod : methods) {
+
+ CtClass[] params = originalMethod.getParameterTypes();
+ if (params.length > 0 && params[0].getName().equals(Subject.class.getName())) {
+
+ CtClass[] simpleParams = new CtClass[params.length - 1];
+
+ System.arraycopy(params, 1, simpleParams, 0, params.length - 1);
+ cz.defrost();
+
+ CtMethod newMethod = CtNewMethod.abstractMethod(originalMethod.getReturnType(), originalMethod
+ .getName(), simpleParams, null, cz);
+
+ ParameterAnnotationsAttribute originalAnnotationsAttribute = (ParameterAnnotationsAttribute) originalMethod
+ .getMethodInfo().getAttribute(ParameterAnnotationsAttribute.visibleTag);
+
+ // If there are any parameter annotations, copy the one's we're keeping
+ if (originalAnnotationsAttribute != null) {
+
+ javassist.bytecode.annotation.Annotation[][] originalAnnotations = originalAnnotationsAttribute
+ .getAnnotations();
+ javassist.bytecode.annotation.Annotation[][] newAnnotations = new javassist.bytecode.annotation.Annotation[originalAnnotations.length - 1][];
+
+ for (int i = 1; i < originalAnnotations.length; i++) {
+ newAnnotations[i - 1] = new javassist.bytecode.annotation.Annotation[originalAnnotations[i].length];
+ System.arraycopy(originalAnnotations[i], 0, newAnnotations[i - 1], 0,
+ originalAnnotations[i].length);
+ }
+
+ ParameterAnnotationsAttribute newAnnotationsAttribute = new ParameterAnnotationsAttribute(
+ newMethod.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
+
+ newAnnotationsAttribute.setAnnotations(newAnnotations);
+
+ newMethod.getMethodInfo().addAttribute(newAnnotationsAttribute);
+
+ }
+
+ cz.addMethod(newMethod);
+ }
+ }
+
+ return cz.toClass();
+
+ } catch (NotFoundException e) {
+ LOG.debug("Failed to simplify " + intf + " - cause: " + e);
+ } catch (CannotCompileException e) {
+ LOG.error("Failed to simplify " + intf + ".", e);
+ }
+ return intf;
+ }
+
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/PackageFinder.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/PackageFinder.java
index d48382f..d1ba40c 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/PackageFinder.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/PackageFinder.java
@@ -44,14 +44,7 @@ public class PackageFinder {
}
public List<String> findPackages(String packageRoot) throws IOException {
- ArrayList<String> found = new ArrayList<String>();
-
-//TODO this is where the original package finder used to look for the jars.
-//update the code somewhere in the CLI client to supply this dir to this
-//new style impl.
-// String cwd = System.getProperty("user.dir");
-// File libDir = new File(cwd, "lib");
-
+ ArrayList<String> found = new ArrayList<String>();
List<File> jars = new ArrayList<File>();
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptAssert.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptAssert.java
new file mode 100644
index 0000000..6d68608
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptAssert.java
@@ -0,0 +1,421 @@
+/*
+ * 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.bindings.util;
+
+import java.util.Collection;
+
+import javax.script.ScriptEngine;
+
+import org.testng.Assert;
+
+public class ScriptAssert {
+
+ private ScriptEngine scriptEngine;
+
+ public ScriptAssert() {
+
+ }
+
+ public ScriptAssert(ScriptEngine scriptEngine) {
+ this.scriptEngine = scriptEngine;
+ }
+
+ public void init(ScriptEngine engine) {
+ this.scriptEngine = engine;
+ }
+
+ public void assertTrue(boolean condition, String msg) {
+ try {
+ Assert.assertTrue(condition, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertTrue(boolean condition) {
+ try {
+ Assert.assertTrue(condition);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertFalse(boolean condition, String msg) {
+ try {
+ Assert.assertFalse(condition, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertFalse(boolean condition) {
+ try {
+ Assert.assertFalse(condition);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void fail(String msg, Throwable throwable) {
+ try {
+ Assert.fail(msg, throwable);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void fail(String msg) {
+ try {
+ Assert.fail(msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void fail() {
+ throw new ScriptAssertionException(new AssertionError());
+ }
+
+ public void assertEquals(Object actual, Object expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(Object actual, Object expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(String actual, String expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(String actual, String expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(double actual, double expected, double delta, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, delta, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(double actual, double expected, double delta) {
+ try {
+ Assert.assertEquals(actual, expected, delta);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(float actual, float expected, float delta, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, delta, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(float actual, float expected, float delta) {
+ try {
+ Assert.assertEquals(actual, expected, delta);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(long actual, long expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(long actual, long expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(boolean actual, boolean expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(boolean actual, boolean expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(byte actual, byte expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(byte actual, byte expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(char actual, char expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(char actual, char expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(short actual, short expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch(AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(short actual, short expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(int actual, int expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(int actual, int expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertNotNull(Object object) {
+ try {
+ Assert.assertNotNull(object);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertNotNull(Object object, String msg) {
+ try {
+ Assert.assertNotNull(object, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertNull(Object object) {
+ try {
+ Assert.assertNull(object);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertNull(Object object, String msg) {
+ try {
+ Assert.assertNull(object, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertSame(Object actual, Object expected, String msg) {
+ try {
+ Assert.assertSame(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertSame(Object actual, Object expected) {
+ try {
+ Assert.assertSame(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertNotSame(Object actual, Object expected, String msg) {
+ try {
+ Assert.assertNotSame(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertNotSame(Object actual, Object expected) {
+ try {
+ Assert.assertNotSame(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(Collection actual, Collection expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(Collection actual, Collection expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(Object[] actual, Object[] expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEqualsNoOrder(Object[] actual, Object[] expected, String msg) {
+ try {
+ Assert.assertEqualsNoOrder(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(Object[] actual, Object[] expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEqualsNoOrder(Object[] actual, Object[] expected) {
+ try {
+ Assert.assertEqualsNoOrder(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(byte[] actual, byte[] expected) {
+ try {
+ Assert.assertEquals(actual, expected);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertEquals(byte[] actual, byte[] expected, String msg) {
+ try {
+ Assert.assertEquals(actual, expected, msg);
+ } catch (AssertionError e) {
+ throw new ScriptAssertionException(e);
+ }
+ }
+
+ public void assertExists(String identifier) {
+ assertNotNull(scriptEngine.get(identifier), identifier + " is not defined");
+ }
+
+ /**
+ * JavaScript has only a single numeric type such that <code>x = 1</code> and <code>y = 1.0</code> are considered to
+ * be of the same type. From within a (JavaScript) script if you were to call <code>assertEquals(x, y)</code>, you
+ * would get an exception that looks something like,
+ *
+ * <pre>
+ * Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: The choice of
+ * Java constructor assertEquals matching JavaScript argument types (number,number,string) is ambiguous;
+ * candidate constructors are:
+ * void assertEquals(java.lang.String,java.lang.String,java.lang.String)
+ * void assertEquals(double,double,double)
+ * void assertEquals(float,float,float)
+ * void assertEquals(long,long,java.lang.String)
+ * void assertEquals(byte,byte,java.lang.String)
+ * void assertEquals(char,char,java.lang.String)
+ * void assertEquals(short,short,java.lang.String)
+ * void assertEquals(int,int,java.lang.String) (<Unknown source>#1) in <Unknown source> at line number 1
+ </pre>
+ *
+ * To avoid the ambiguity when comparing numbers in JavaScript scripts, it is recommended to use this method.
+ *
+ * @param actual The actual value
+ * @param expected The expected value
+ * @param msg A useful, meaningful error message
+ */
+ public void assertNumberEqualsJS(double actual, double expected, String msg) {
+ assertEquals(actual, expected, msg);
+ }
+
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptAssertionException.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptAssertionException.java
new file mode 100644
index 0000000..f0305f3
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptAssertionException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.bindings.util;
+
+import javax.script.ScriptException;
+
+/**
+ * This is a wrapper exception class for {@link java.lang.AssertionError}. The default (i.e., rhino) scripting engine
+ * catches any exception, checked or unchecked, thrown from a script and wraps it in an instance of
+ * {@link javax.script.ScriptException}. ScriptException provides useful context information such as the script name
+ * and line number on which the exception occurred. For reasons unknown instances of {@link Error} are not caught and
+ * wrapped in a ScriptException; consequently, no context information is provided about the error, particularly, a line
+ * number.
+ */
+public class ScriptAssertionException extends RuntimeException {
+
+// public ScriptAssertionException() {
+// super();
+// }
+//
+// public ScriptAssertionException(String message) {
+// super(message);
+// }
+//
+// public ScriptAssertionException(String message, Throwable cause) {
+// super(message, cause);
+// }
+//
+// public ScriptAssertionException(Throwable cause) {
+// super(cause);
+// }
+
+ public ScriptAssertionException(AssertionError error) {
+ super(new ScriptException(error.getMessage()));
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptUtil.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptUtil.java
new file mode 100644
index 0000000..4e81e30
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ScriptUtil.java
@@ -0,0 +1,181 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 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.bindings.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+
+import org.rhq.bindings.StandardBindings;
+import org.rhq.bindings.client.RhqFacade;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+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.operation.bean.ResourceOperationSchedule;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.server.resource.ResourceManagerRemote;
+
+/**
+ * Instance of this class is injected into the script engine scope.
+ *
+ * @author Lukas Krejci
+ */
+public class ScriptUtil {
+
+ private RhqFacade remoteClient;
+ private ScriptEngine scriptEngine;
+
+ public ScriptUtil(RhqFacade remoteClient) {
+ this.remoteClient = remoteClient;
+ }
+
+ /**
+ * This method is called before the instance is inserted into the script engine scope.
+ *
+ * @param scriptEngine the script engine this instance is to be injected in
+ */
+ public void init(ScriptEngine scriptEngine) {
+ this.scriptEngine = scriptEngine;
+ }
+
+ public PageList<Resource> findResources(String string) {
+ ResourceManagerRemote resourceManager = remoteClient.getResourceManager();
+
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterName(string);
+ return resourceManager.findResourcesByCriteria(getSubjectFromEngine(), criteria);
+ }
+
+
+ public byte[] getFileBytes(String fileName) {
+ File file = new File(fileName);
+ long length = file.length();
+
+ if (length > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Can not read file larger than " + Integer.MAX_VALUE + " byte: "
+ + fileName);
+ }
+
+ byte[] bytes;
+ InputStream is = null;
+ try {
+ bytes = new byte[(int) length];
+ is = new FileInputStream(file);
+
+ int offset = 0, bytesRead = 0;
+ for (offset = 0, bytesRead = 0; offset < bytes.length && bytesRead >= 0; offset += bytesRead) {
+ bytesRead = is.read(bytes, offset, bytes.length - offset);
+ }
+
+ if (offset < bytes.length) {
+ throw new RuntimeException("Could not read entire file " + file.getName() + ", only " + offset + " of "
+ + bytes.length + " bytes read");
+ }
+ } catch (IOException ioe) {
+ throw new RuntimeException("Error reading file: " + ioe.getMessage());
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException ioe) {
+ throw new RuntimeException("Error closing file: " + ioe.getMessage());
+ }
+ }
+ return bytes;
+ }
+
+ public void sleep(long millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException ie) {
+ throw new RuntimeException(ie);
+ }
+ }
+
+ public ResourceOperationHistory waitForScheduledOperationToComplete(ResourceOperationSchedule schedule)
+ throws InterruptedException{
+
+ return waitForScheduledOperationToComplete(schedule, 1000L, 10);
+ }
+
+ public ResourceOperationHistory waitForScheduledOperationToComplete(ResourceOperationSchedule schedule,
+ long intervalDuration,
+ int maxIntervals) throws InterruptedException {
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+ criteria.addFilterJobId(schedule.getJobId());
+ criteria.addFilterResourceIds(schedule.getResource().getId());
+ criteria.addSortStartTime(PageOrdering.DESC);
+ criteria.setPaging(0, 1);
+ criteria.fetchOperationDefinition(true);
+ criteria.fetchParameters(true);
+ criteria.fetchResults(true);
+
+ ResourceOperationHistory history = null;
+
+ int i = 0;
+
+ while(history == null && i < maxIntervals) {
+ Thread.sleep(intervalDuration);
+ PageList<ResourceOperationHistory> histories = remoteClient.getOperationManager()
+ .findResourceOperationHistoriesByCriteria(remoteClient.getSubject(), criteria);
+ if (histories.size() > 0 && histories.get(0).getStatus() != OperationRequestStatus.INPROGRESS) {
+ history = histories.get(0);
+ }
+ ++i;
+ }
+
+ return history;
+ }
+
+ public boolean isDefined(String identifier) {
+ Bindings engineBindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
+ Bindings globalBindings = scriptEngine.getBindings(ScriptContext.GLOBAL_SCOPE);
+
+ return engineBindings.containsKey(identifier) || globalBindings.containsKey(identifier);
+ }
+
+ private Subject getSubjectFromEngine() {
+ return (Subject) findBinding(StandardBindings.SUBJECT);
+ }
+
+ private Object findBinding(String identifier) {
+ Bindings engineBindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
+ Bindings globalBindings = scriptEngine.getBindings(ScriptContext.GLOBAL_SCOPE);
+
+ if (engineBindings.containsKey(identifier)) {
+ return engineBindings.get(identifier);
+ } else {
+ return globalBindings.get(identifier);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/AbstractPerspectiveResourceUIBean.java b/modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/AbstractPerspectiveResourceUIBean.java
index b6ea66c..9b18acb 100644
--- a/modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/AbstractPerspectiveResourceUIBean.java
+++ b/modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/AbstractPerspectiveResourceUIBean.java
@@ -37,7 +37,7 @@ public class AbstractPerspectiveResourceUIBean extends AbstractPerspectiveUIBean
Subject subject = this.perspectiveClient.getSubject();
// ***NOTE***: The javassist.NotFoundException stack traces that are logged by this call can be ignored.
- ResourceManagerRemote resourceManager = remoteClient.getResourceManagerRemote();
+ ResourceManagerRemote resourceManager = remoteClient.getResourceManager();
ResourceCriteria resourceCriteria = new ResourceCriteria();
resourceCriteria.addFilterId(this.rhqResourceId);
PageList<Resource> resources = resourceManager.findResourcesByCriteria(subject, resourceCriteria);
diff --git a/modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveClientUIBean.java b/modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveClientUIBean.java
index 45437d7..9f91c88 100644
--- a/modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveClientUIBean.java
+++ b/modules/enterprise/gui/base-perspective-jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveClientUIBean.java
@@ -87,7 +87,7 @@ public class PerspectiveClientUIBean {
if (subject == null) {
RemoteClient remoteClient = getRemoteClient();
// ***NOTE***: The javassist.NotFoundException stack traces that are logged by this call can be ignored.
- SubjectManagerRemote subjectManager = remoteClient.getSubjectManagerRemote();
+ SubjectManagerRemote subjectManager = remoteClient.getSubjectManager();
if (this.rhqSessionId != null) {
log.info("Retrieving subject for user [" + getUsername() + "] and sessionId [" + this.rhqSessionId
+ "]...");
@@ -108,7 +108,7 @@ public class PerspectiveClientUIBean {
if (this.coreGuiBaseUrl == null) {
RemoteClient remoteClient = getRemoteClient();
Subject subject = getSubject();
- PerspectiveManagerRemote perspectiveManager = remoteClient.getPerspectiveManagerRemote();
+ PerspectiveManagerRemote perspectiveManager = remoteClient.getPerspectiveManager();
this.coreGuiBaseUrl = perspectiveManager.getRootUrl(subject, true, false);
}
return this.coreGuiBaseUrl;
diff --git a/modules/enterprise/pom.xml b/modules/enterprise/pom.xml
index 7e20613..bfd912f 100644
--- a/modules/enterprise/pom.xml
+++ b/modules/enterprise/pom.xml
@@ -71,6 +71,7 @@
<module>server/jar</module>
<module>server/safe-invoker</module>
<module>server/sars</module>
+ <module>binding</module>
<module>remoting</module>
<module>gui</module>
<module>server/plugins</module>
diff --git a/modules/enterprise/remoting/cli/pom.xml b/modules/enterprise/remoting/cli/pom.xml
index cab4a8c..f55dbb4 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -33,7 +33,13 @@
<artifactId>rhq-remoting-client-api</artifactId>
<version>${project.version}</version>
</dependency>
-
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-script-bindings</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>${groupId}</groupId>
<artifactId>rhq-core-domain</artifactId>
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/LoginCommand.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/LoginCommand.java
index d8344ff..95b1a8f 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/LoginCommand.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/LoginCommand.java
@@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.client.ClientMain;
import org.rhq.enterprise.client.RemoteClient;
+import org.rhq.enterprise.server.system.ServerVersion;
/**
* @author Greg Hinkle
@@ -103,6 +104,8 @@ public class LoginCommand implements ClientCommand {
client.setPass(password);
Subject subject = remoteClient.login(username, password);
+ ServerVersion version = remoteClient.getSystemManager().getServerVersion(subject);
+ client.getPrintWriter().println("Remote server version is: " + version);
client.setRemoteClient(remoteClient);
client.setSubject(subject);
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
index ca3a185..8f64679 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
@@ -18,53 +18,47 @@
*/
package org.rhq.enterprise.client.commands;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Arrays;
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.bindings.export.Exporter;
+import org.rhq.bindings.ScriptEngineFactory;
+import org.rhq.bindings.StandardBindings;
+import org.rhq.bindings.client.RhqManagers;
import org.rhq.bindings.output.TabularWriter;
import org.rhq.bindings.util.PackageFinder;
-import org.rhq.core.domain.util.PageControl;
import org.rhq.enterprise.client.ClientMain;
import org.rhq.enterprise.client.Controller;
-import org.rhq.enterprise.client.RemoteClient;
-import org.rhq.enterprise.client.proxy.ResourceClientFactory;
import org.rhq.enterprise.client.proxy.ConfigurationEditor;
+import org.rhq.enterprise.client.proxy.EditableResourceClientFactory;
import org.rhq.enterprise.client.script.CLIScriptException;
import org.rhq.enterprise.client.script.CmdLineParser;
import org.rhq.enterprise.client.script.CommandLineParseException;
import org.rhq.enterprise.client.script.NamedScriptArg;
import org.rhq.enterprise.client.script.ScriptArg;
import org.rhq.enterprise.client.script.ScriptCmdLine;
-import org.rhq.enterprise.client.utility.ScriptAssert;
-import org.rhq.enterprise.client.utility.ScriptUtil;
-
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.MethodDescriptor;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.InputStreamReader;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
/**
* @author Greg Hinkle
+ * @author Lukas Krejci
*/
public class ScriptCommand implements ClientCommand {
- private ScriptEngineManager sem;
private ScriptEngine jsEngine;
-
+ private StandardBindings bindings;
+
private final Log log = LogFactory.getLog(ScriptCommand.class);
private StringBuilder script = new StringBuilder();
@@ -72,37 +66,6 @@ public class ScriptCommand implements ClientCommand {
private boolean isMultilineScript = false;
private boolean inMultilineScript = false;
- public ScriptCommand() {
- sem = new ScriptEngineManager();
- PageControl pc = new PageControl();
- pc.setPageNumber(-1);
- sem.getBindings().put("unlimitedPC", pc);
- sem.getBindings().put("pageControl", PageControl.getUnlimitedInstance());
- sem.put("exporter", new Exporter());
- jsEngine = sem.getEngineByName("JavaScript");
- try {
- jsEngine.eval("1+1");
- } catch (ScriptException e) {
- e.printStackTrace();
- }
- importRecursive(jsEngine);
- }
-
- private void importRecursive(ScriptEngine jsEngine) {
-
- try {
-
- List<String> packages = new PackageFinder().findPackages("org.rhq.core.domain");
-
- for (String pkg : packages) {
- jsEngine.eval("importPackage(" + pkg + ")");
- }
- } catch (ScriptException e) {
- e.printStackTrace();
- }
-
- }
-
public ScriptEngine getScriptEngine() {
return jsEngine;
}
@@ -197,60 +160,31 @@ public class ScriptCommand implements ClientCommand {
}
public void initBindings(ClientMain client) {
- // These are prepared on every call in case the user logs out and logs into another server
- if (client.getSubject() != null) {
- jsEngine.put("subject", client.getSubject());
- sem.getBindings().putAll(client.getRemoteClient().getManagers());
- }
- TabularWriter tw = new TabularWriter(client.getPrintWriter());
- tw.setWidth(client.getConsoleWidth());
- sem.getBindings().put("pretty", tw);
-
- sem.getBindings().put("ProxyFactory", new ResourceClientFactory(client));
-
- bindObjectAndGlobalFuctions(new Controller(client), "rhq");
- bindObjectAndGlobalFuctions(new ScriptUtil(client), "scriptUtil");
- bindObjectAndGlobalFuctions(new ConfigurationEditor(client), "configurationEditor");
- bindObjectAndGlobalFuctions(new ScriptAssert(jsEngine), "Assert");
- }
-
- private void bindObjectAndGlobalFuctions(Object object, String bindingName) {
- jsEngine.put(bindingName, object);
- try {
- BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass(),Object.class);
- MethodDescriptor[] methodDescriptors = beanInfo.getMethodDescriptors();
-
- for (MethodDescriptor methodDescriptor : methodDescriptors) {
- Method method = methodDescriptor.getMethod();
- String methodName = method.getName();
- int argCount = method.getParameterTypes().length;
-
- StringBuilder functionBuilder = new StringBuilder();
- functionBuilder.append(methodName).append("(");
- for (int i = 0; i < argCount; ++i) {
- if (i != 0) {
- functionBuilder.append(", ");
- }
- functionBuilder.append("arg_" + i);
- }
- functionBuilder.append(")");
- String functionFragment = functionBuilder.toString();
- boolean returnsVoid = method.getReturnType().equals(Void.TYPE);
-
- String functionDefinition = "function " + functionFragment + " { " + (returnsVoid ? "" : "return ")
- + bindingName + "." + functionFragment + "; }";
-
- log.info("Binding global function --> " + functionDefinition);
- try {
- jsEngine.eval(functionDefinition);
- } catch (ScriptException e) {
- log.warn("Unable to bind global function " + functionFragment, e);
- }
+ if (jsEngine == null) {
+ bindings = new StandardBindings(client.getPrintWriter(), client.getRemoteClient());
+
+ try {
+ jsEngine = ScriptEngineFactory.getScriptEngine("JavaScript", new PackageFinder(Arrays.asList(getLibDir())), bindings);
+ jsEngine.eval("1+1");
+ } catch (ScriptException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
}
- } catch (IntrospectionException e) {
- // TODO Should we altogether remove the object from the script engine bindings?
- log.warn("Could not bind " + object.getClass().getName() + " into script engine.");
}
+
+ bindings.getSubject().setValue(client.getSubject());
+ bindings.getPretty().getValue().setWidth(client.getConsoleWidth());
+ bindings.getProxyFactory().setValue(new EditableResourceClientFactory(client));
+
+ //non-standard bindings
+ bindings.put("configurationEditor", new ConfigurationEditor(client));
+ bindings.put("rhq", new Controller(client));
+
+ ScriptEngineFactory.injectStandardBindings(jsEngine, bindings);
+
+ ScriptEngineFactory.bindIndirectionMethods(jsEngine, "configurationEditor", bindings.get("configurationEditor"));
+ ScriptEngineFactory.bindIndirectionMethods(jsEngine, "configurationEditor", bindings.get("configurationEditor"));
}
private void executeUtilScripts() {
@@ -337,11 +271,15 @@ public class ScriptCommand implements ClientCommand {
public String getDetailedHelp() {
return "Execute a statement or a script. The following services managers are available: " +
- RemoteClient.Manager.values();
+ RhqManagers.values();
}
public ScriptContext getContext() {
return jsEngine.getContext();
}
+ private File getLibDir() {
+ String cwd = System.getProperty("user.dir");
+ return new File(cwd, "lib");
+ }
}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientFactory.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientFactory.java
new file mode 100644
index 0000000..1027878
--- /dev/null
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientFactory.java
@@ -0,0 +1,61 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.client.proxy;
+
+import java.util.List;
+
+import javassist.util.proxy.MethodHandler;
+
+import org.rhq.bindings.client.ResourceClientFactory;
+import org.rhq.bindings.client.ResourceClientProxy;
+import org.rhq.bindings.client.RhqFacade;
+import org.rhq.enterprise.client.ClientMain;
+
+/**
+ * This is a specialization of the {@link ResourceClientFactory} class that provides the interactive
+ * configuration editing features.
+ *
+ * @author Lukas Krejci
+ */
+public class EditableResourceClientFactory extends ResourceClientFactory {
+
+ private ClientMain client;
+
+ public EditableResourceClientFactory(ClientMain client) {
+ super(client.getRemoteClient(), client.getPrintWriter());
+ this.client = client;
+ }
+
+ @Override
+ protected Class<?> getPluginConfigurableInterface() {
+ return org.rhq.enterprise.client.proxy.EditableResourceClientProxy.EditablePluginConfigurable.class;
+ }
+
+ @Override
+ protected Class<?> getResourceConfigurableInterface() {
+ return org.rhq.enterprise.client.proxy.EditableResourceClientProxy.EditableResourceConfigurable.class;
+ }
+
+ @Override
+ protected MethodHandler instantiateMethodHandler(ResourceClientProxy proxy, List<Class<?>> interfaces,
+ RhqFacade remoteClient) {
+ return new EditableResourceClientProxy.MethodHandler(proxy, remoteClient, client);
+ }
+}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientProxy.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientProxy.java
new file mode 100644
index 0000000..367a750
--- /dev/null
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/EditableResourceClientProxy.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.client.proxy;
+
+import org.rhq.bindings.client.ResourceClientProxy;
+import org.rhq.bindings.client.RhqFacade;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.enterprise.client.ClientMain;
+import org.rhq.enterprise.client.RemoteClient;
+
+/**
+ * Extends the {@link ResourceClientProxy} and provides the interactive configuration editing features.
+ *
+ * @author Lukas Krejci
+ */
+public class EditableResourceClientProxy extends ResourceClientProxy {
+
+ public interface EditableResourceConfigurable extends ResourceClientProxy.ResourceConfigurable {
+ void editResourceConfiguration();
+ }
+
+ public interface EditablePluginConfigurable extends ResourceClientProxy.PluginConfigurable {
+ public void editPluginConfiguration();
+ }
+
+ public static class MethodHandler extends ResourceClientProxy.ClientProxyMethodHandler implements EditableResourceConfigurable, EditablePluginConfigurable {
+
+ private ClientMain client;
+ public MethodHandler(ResourceClientProxy resourceClientProxy, RhqFacade remoteClient, ClientMain client) {
+ super(resourceClientProxy, remoteClient);
+ this.client = client;
+ }
+
+ public void editPluginConfiguration() {
+ ConfigurationEditor editor = new ConfigurationEditor(client);
+ Configuration config = editor.editConfiguration(getPluginConfigurationDefinition(), getPluginConfiguration());
+ if (config != null) {
+ updatePluginConfiguration(config);
+ }
+ }
+
+ public void editResourceConfiguration() {
+ ConfigurationEditor editor = new ConfigurationEditor(client);
+ Configuration config = editor.editConfiguration(getResourceConfigurationDefinition(), getResourceConfiguration());
+ if (config != null) {
+ updateResourceConfiguration(config);
+ }
+ }
+ }
+}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientFactory.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientFactory.java
deleted file mode 100644
index bbde2ed..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientFactory.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.rhq.enterprise.client.proxy;
-
-import javassist.ClassPool;
-import javassist.CtNewMethod;
-import javassist.bytecode.ParameterAnnotationsAttribute;
-import org.rhq.enterprise.client.ClientMain;
-import org.rhq.enterprise.client.utility.ConfigurationClassBuilder;
-import org.rhq.core.domain.resource.ResourceCreationDataType;
-
-/**
- *
- * @author Greg Hinkle
- */
-public class ResourceClientFactory {
-
- private ClientMain clientMain;
-
- private org.rhq.enterprise.client.RemoteClient remoteClient;
-
- public ResourceClientFactory(ClientMain clientMain) {
- this.clientMain = clientMain;
- this.remoteClient = clientMain.getRemoteClient();
- }
-
- private static java.util.concurrent.atomic.AtomicInteger classIndex = new java.util.concurrent.atomic.AtomicInteger();
-
- public org.rhq.enterprise.client.proxy.ResourceClientProxy getResource(int resourceId) {
-
- org.rhq.enterprise.client.proxy.ResourceClientProxy proxy = new org.rhq.enterprise.client.proxy.ResourceClientProxy(clientMain, resourceId);
- java.lang.Class customInterface = null;
- try {
- // define the dynamic class
- javassist.ClassPool pool = ClassPool.getDefault();
- javassist.CtClass customClass = pool.makeInterface(org.rhq.enterprise.client.proxy.ResourceClientProxy.class.getName() + "__Custom__"
- + classIndex.getAndIncrement());
-
- for (java.lang.String key : proxy.allProperties.keySet()) {
- java.lang.Object prop = proxy.allProperties.get(key);
-
- if (prop instanceof org.rhq.enterprise.client.proxy.ResourceClientProxy.Measurement) {
- org.rhq.enterprise.client.proxy.ResourceClientProxy.Measurement m = (org.rhq.enterprise.client.proxy.ResourceClientProxy.Measurement) prop;
- java.lang.String name = org.rhq.enterprise.client.proxy.ResourceClientProxy.getterName(key);
-
- try {
- org.rhq.enterprise.client.proxy.ResourceClientProxy.class.getMethod(name);
- } catch (java.lang.NoSuchMethodException nsme) {
- javassist.CtMethod method = CtNewMethod.abstractMethod(pool.get(org.rhq.enterprise.client.proxy.ResourceClientProxy.Measurement.class.getName()),
- org.rhq.enterprise.client.proxy.ResourceClientProxy.getterName(key), new javassist.CtClass[0], new javassist.CtClass[0], customClass);
- customClass.addMethod(method);
- }
- } else if (prop instanceof org.rhq.enterprise.client.proxy.ResourceClientProxy.Operation) {
- org.rhq.enterprise.client.proxy.ResourceClientProxy.Operation o = (org.rhq.enterprise.client.proxy.ResourceClientProxy.Operation) prop;
-
- java.util.LinkedHashMap<java.lang.String, javassist.CtClass> types = ConfigurationClassBuilder.translateParameters(o
- .getDefinition().getParametersConfigurationDefinition());
-
- javassist.CtClass[] params = new javassist.CtClass[types.size()];
- int x = 0;
- for (java.lang.String param : types.keySet()) {
- params[x++] = types.get(param);
- }
-
- javassist.CtMethod method = CtNewMethod.abstractMethod(ConfigurationClassBuilder.translateConfiguration(o
- .getDefinition().getResultsConfigurationDefinition()), org.rhq.enterprise.client.proxy.ResourceClientProxy.simpleName(key), params,
- new javassist.CtClass[0], customClass);
-
- // Setup @WebParam annotations so the signatures have the config prop names
- javassist.bytecode.annotation.Annotation[][] newAnnotations = new javassist.bytecode.annotation.Annotation[params.length][1];
- int i = 0;
- for (java.lang.String paramName : types.keySet()) {
- newAnnotations[i] = new javassist.bytecode.annotation.Annotation[1];
-
- newAnnotations[i][0] = new javassist.bytecode.annotation.Annotation(javax.jws.WebParam.class.getName(), method.getMethodInfo()
- .getConstPool());
- newAnnotations[i][0].addMemberValue("name", new javassist.bytecode.annotation.StringMemberValue(paramName, method
- .getMethodInfo().getConstPool()));
- i++;
- }
-
- javassist.bytecode.ParameterAnnotationsAttribute newAnnotationsAttribute = new javassist.bytecode.ParameterAnnotationsAttribute(
- method.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
- newAnnotationsAttribute.setAnnotations(newAnnotations);
- method.getMethodInfo().addAttribute(newAnnotationsAttribute);
-
- customClass.addMethod(method);
- }
- }
-
- customInterface = customClass.toClass();
- } catch (javassist.NotFoundException e) {
- e.printStackTrace();
- } catch (javassist.CannotCompileException e) {
- e.printStackTrace();
- } catch (java.lang.Exception e) {
- e.printStackTrace();
- }
-
- if (customInterface != null) {
-
- java.util.List<java.lang.Class> interfaces = new java.util.ArrayList<java.lang.Class>();
- interfaces.add(customInterface);
- if (proxy.resourceConfigurationDefinition != null) {
- interfaces.add(org.rhq.enterprise.client.proxy.ResourceClientProxy.ResourceConfigurable.class);
- }
- if (proxy.pluginConfigurationDefinition != null) {
- interfaces.add(org.rhq.enterprise.client.proxy.ResourceClientProxy.PluginConfigurable.class);
- }
-
- if (proxy.getResourceType().getCreationDataType() == ResourceCreationDataType.CONTENT) {
- interfaces.add(org.rhq.enterprise.client.proxy.ResourceClientProxy.ContentBackedResource.class);
- }
-
- javassist.util.proxy.ProxyFactory proxyFactory = new javassist.util.proxy.ProxyFactory();
- proxyFactory.setInterfaces(interfaces.toArray(new java.lang.Class[interfaces.size()]));
- proxyFactory.setSuperclass(org.rhq.enterprise.client.proxy.ResourceClientProxy.class);
- org.rhq.enterprise.client.proxy.ResourceClientProxy proxied = null;
- try {
- proxied = (org.rhq.enterprise.client.proxy.ResourceClientProxy) proxyFactory.create(new java.lang.Class[]{}, new java.lang.Object[]{},
- new org.rhq.enterprise.client.proxy.ResourceClientProxy.ClientProxyMethodHandler(proxy, remoteClient));
- } catch (java.lang.InstantiationException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } catch (java.lang.IllegalAccessException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } catch (java.lang.NoSuchMethodException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } catch (java.lang.reflect.InvocationTargetException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- return proxied;
- }
- return proxy;
-
- }
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java
deleted file mode 100644
index 5b21a94..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java
+++ /dev/null
@@ -1,669 +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.enterprise.client.proxy;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import javassist.util.proxy.MethodHandler;
-
-import org.rhq.bindings.util.LazyLoadScenario;
-import org.rhq.bindings.util.ShortOutput;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
-import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.content.InstalledPackage;
-import org.rhq.core.domain.content.PackageType;
-import org.rhq.core.domain.content.PackageVersion;
-import org.rhq.core.domain.criteria.MeasurementDefinitionCriteria;
-import org.rhq.core.domain.criteria.OperationDefinitionCriteria;
-import org.rhq.core.domain.criteria.PackageVersionCriteria;
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
-import org.rhq.core.domain.measurement.DataType;
-import org.rhq.core.domain.measurement.MeasurementCategory;
-import org.rhq.core.domain.measurement.MeasurementData;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.operation.OperationRequestStatus;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.core.domain.util.Summary;
-import org.rhq.core.server.MeasurementConverter;
-import org.rhq.enterprise.client.RemoteClient;
-import org.rhq.enterprise.client.ClientMain;
-import org.rhq.enterprise.client.utility.ConfigurationClassBuilder;
-import org.rhq.enterprise.client.utility.ScriptUtil;
-import org.rhq.enterprise.server.content.ContentManagerRemote;
-import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
-import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
-
-/**
- * Implements a local object that exposes resource related data as
- * if it were local.
- *
- * @author Greg Hinkle
- */
-public class ResourceClientProxy {
-
- private ClientMain client;
- private RemoteClient remoteClient;
- private int resourceId;
- private Resource resource;
-
- Map<String, Object> allProperties = new HashMap<String, Object>();
-
- // Metadata
- private List<MeasurementDefinition> measurementDefinitions;
- private Map<String, Measurement> measurementMap = new HashMap<String, Measurement>();
-
- private List<OperationDefinition> operationDefinitions;
- private Map<String, Operation> operationMap = new HashMap<String, Operation>();
-
- private Map<String, ContentType> contentTypes = new HashMap<String, ContentType>();
-
- private List<ResourceClientProxy> children;
- ConfigurationDefinition resourceConfigurationDefinition;
- ConfigurationDefinition pluginConfigurationDefinition;
-
- public ResourceClientProxy() {
- }
-
- public ResourceClientProxy(ResourceClientProxy parentProxy) {
- this.client = parentProxy.client;
- this.remoteClient = parentProxy.remoteClient;
- this.resourceId = parentProxy.resourceId;
- this.resource = parentProxy.resource;
- this.allProperties = parentProxy.allProperties;
- this.measurementDefinitions = parentProxy.measurementDefinitions;
- this.measurementMap = parentProxy.measurementMap;
- this.children = parentProxy.children;
-
- }
-
- public ResourceClientProxy(ClientMain clientMain, int resourceId) {
- this.client = clientMain;
- this.remoteClient = client.getRemoteClient();
- this.resourceId = resourceId;
-
- init();
- }
-
- @Summary(index = 0)
- public int getId() {
- return resourceId;
- }
-
- @Summary(index = 1)
- public String getName() {
- return resource.getName();
- }
-
- public String getDescription() {
- return resource.getDescription();
- }
-
- @Summary(index = 2)
- public String getVersion() {
- return resource.getVersion();
- }
-
- @Summary(index = 3)
- public ResourceType getResourceType() {
- return resource.getResourceType();
- }
-
- public Date getCreatedDate() {
- return new Date(resource.getCtime());
- }
-
- public Date getModifiedDate() {
- return new Date(resource.getCtime());
- }
-
- public Measurement getMeasurement(String name) {
- return this.measurementMap.get(name);
- }
-
- public Measurement[] getMeasurements() {
- return this.measurementMap.values().toArray(new Measurement[this.measurementMap.size()]);
- }
-
- public Operation[] getOperations() {
- return this.operationMap.values().toArray(new Operation[this.operationMap.size()]);
- }
-
- public Map<String, ContentType> getContentTypes() {
- return contentTypes;
- }
-
- public ResourceClientProxy[] getChildren() {
- if (children == null && LazyLoadScenario.isShouldLoad()) {
- children = new ArrayList<ResourceClientProxy>();
-
- initChildren();
-
- }
- return children.toArray(new ResourceClientProxy[children.size()]);
- }
-
- public ResourceClientProxy getChild(String name) {
- for (ResourceClientProxy child : getChildren()) {
- if (name.equals(child.getName()))
- return child;
- }
- return null;
- }
-
- public String toString() {
- return "[" + resourceId + "] " + resource.getName() + " (" + resource.getResourceType().getName() + "::"
- + resource.getResourceType().getPlugin() + ")";
- }
-
- public void init() {
-
- this.resource = remoteClient.getResourceManagerRemote().getResource(remoteClient.getSubject(), resourceId);
-
- // Lazy init children, not here
- initMeasurements();
- initOperations();
- initConfigDefs();
- initContent();
- }
-
- private void initConfigDefs() {
- this.resourceConfigurationDefinition = remoteClient.getConfigurationManagerRemote()
- .getResourceConfigurationDefinitionWithTemplatesForResourceType(remoteClient.getSubject(),
- resource.getResourceType().getId());
- this.pluginConfigurationDefinition = remoteClient.getConfigurationManagerRemote()
- .getPluginConfigurationDefinitionForResourceType(remoteClient.getSubject(),
- resource.getResourceType().getId());
- }
-
- private void initChildren() {
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.addFilterParentResourceId(resourceId);
- PageList<Resource> childResources = remoteClient.getResourceManagerRemote().findResourcesByCriteria(
- remoteClient.getSubject(), criteria);
-
- for (Resource child : childResources) {
- this.children.add(new ResourceClientFactory(client).getResource(child.getId()));
- }
- }
-
- private void initMeasurements() {
- MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
- criteria.addFilterResourceTypeId(resource.getResourceType().getId());
-// criteria.addFilterResourceTypeName(resource.getResourceType().getName());
-// criteria.setStrict(true);
-
- this.measurementDefinitions = remoteClient.getMeasurementDefinitionManagerRemote()
- .findMeasurementDefinitionsByCriteria(remoteClient.getSubject(), criteria);
-
- this.measurementMap = new HashMap<String, Measurement>();
- for (MeasurementDefinition def : measurementDefinitions) {
- Measurement m = new Measurement(def);
-
- String name = def.getDisplayName().replaceAll("\\W", "");
- name = decapitalize(name);
-
- this.measurementMap.put(name, m);
- this.allProperties.put(name, m);
- }
- }
-
- public void initOperations() {
- OperationDefinitionCriteria criteria = new OperationDefinitionCriteria();
- criteria.addFilterResourceIds(resourceId);
- criteria.fetchParametersConfigurationDefinition(true);
- criteria.fetchResultsConfigurationDefinition(true);
-
- this.operationDefinitions = remoteClient.getOperationManagerRemote().findOperationDefinitionsByCriteria(
- remoteClient.getSubject(), criteria);
-
- for (OperationDefinition def : operationDefinitions) {
- Operation o = new Operation(def);
- this.operationMap.put(o.getName(), o);
- this.allProperties.put(o.getName(), o);
- }
- }
-
- private void initContent() {
- ContentManagerRemote contentManager = remoteClient.getContentManagerRemote();
- List<PackageType> types = null;
- try {
- types = contentManager.findPackageTypes(remoteClient.getSubject(), resource.getResourceType().getName(),
- resource.getResourceType().getPlugin());
-
- for (PackageType packageType : types) {
- contentTypes.put(packageType.getName(), new ContentType(packageType));
- }
- } catch (ResourceTypeNotFoundException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
-
- }
-
- public class ContentType {
-
- private PackageType packageType;
-
- public ContentType(PackageType packageType) {
- this.packageType = packageType;
- }
-
- public PackageType getPackageType() {
- return this.packageType;
- }
-
- public List<PackageVersion> getInstalledPackages() {
- ContentManagerRemote contentManager = remoteClient.getContentManagerRemote();
-
- PackageVersionCriteria criteria = new PackageVersionCriteria();
- criteria.addFilterResourceId(resourceId);
- // criteria.addFilterPackageTypeId() TODO ADD this when the filter is added
-
- return contentManager.findPackageVersionsByCriteria(remoteClient.getSubject(), criteria);
- }
-
- public String toString() {
- return this.packageType.getDisplayName();
- }
-
- }
-
- public class Measurement implements ShortOutput {
-
- MeasurementDefinition definition;
-
- public Measurement(MeasurementDefinition definition) {
- this.definition = definition;
- }
-
- @Summary(index = 0)
- public String getName() {
- return definition.getDisplayName();
- }
-
- @Summary(index = 1)
- public String getDisplayValue() {
- Object val = getValue();
- if (val instanceof Number) {
- return MeasurementConverter.format(((Number) val).doubleValue(), getUnits(), true);
- } else {
- return String.valueOf(val);
- }
- }
-
- @Summary(index = 2)
- public String getDescription() {
- return definition.getDescription();
- }
-
- public DataType getDataType() {
- return definition.getDataType();
- }
-
- public MeasurementCategory getCategory() {
- return definition.getCategory();
- }
-
- public MeasurementUnits getUnits() {
- return definition.getUnits();
- }
-
- public Object getValue() {
- try {
- Set<MeasurementData> d = remoteClient.getMeasurementDataManagerRemote().findLiveData(
- remoteClient.getSubject(), resourceId, new int[] { definition.getId() });
- MeasurementData data = d.iterator().next();
- return data.getValue();
- } catch (Exception e) {
- return "?";
- }
- }
-
- public String toString() {
- return getName();
- }
- public String getShortOutput() {
- return getDisplayValue();
- }
- }
-
- public class Operation {
- OperationDefinition definition;
-
- public Operation(OperationDefinition definition) {
- this.definition = definition;
- }
-
- @Summary(index = 0)
- public String getName() {
- return simpleName(this.definition.getDisplayName());
- }
-
- @Summary(index = 1)
- public String getDescription() {
- return this.definition.getDescription();
- }
-
- public OperationDefinition getDefinition() {
- return definition;
- }
-
- public Object invoke(Object[] args) throws Exception {
- if (!LazyLoadScenario.isShouldLoad())
- return null;
-
- Configuration parameters = ConfigurationClassBuilder.translateParametersToConfig(definition
- .getParametersConfigurationDefinition(), args);
-
- ResourceOperationSchedule schedule = remoteClient.getOperationManagerRemote().scheduleResourceOperation(
- remoteClient.getSubject(), resourceId, definition.getName(), 0, 0, 0, 30000, parameters,
- "Executed from commandline");
-
- ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
- criteria.addFilterJobId(schedule.getJobId());
- criteria.addFilterResourceIds(resourceId);
- criteria.addSortStartTime(PageOrdering.DESC); // put most recent at top of results
- criteria.setPaging(0, 1); // only return one result, in effect the latest
- criteria.fetchOperationDefinition(true);
- criteria.fetchParameters(true);
- criteria.fetchResults(true);
-
- int retries = 10;
- ResourceOperationHistory history = null;
- while (history == null && retries-- > 0) {
- Thread.sleep(1000);
- PageList<ResourceOperationHistory> histories = remoteClient.getOperationManagerRemote()
- .findResourceOperationHistoriesByCriteria(remoteClient.getSubject(), criteria);
- if (histories.size() > 0 && histories.get(0).getStatus() != OperationRequestStatus.INPROGRESS) {
- history = histories.get(0);
- }
- }
-
- Configuration result = (history != null ? history.getResults() : null);
-
- Object returnResults = ConfigurationClassBuilder.translateResults(definition
- .getResultsConfigurationDefinition(), result);
-
- return returnResults;
- }
- }
-
- public static class ClientProxyMethodHandler implements MethodHandler, ContentBackedResource, PluginConfigurable,
- ResourceConfigurable {
-
- ResourceClientProxy resourceClientProxy;
- RemoteClient remoteClient;
-
- public ClientProxyMethodHandler(ResourceClientProxy resourceClientProxy, RemoteClient remoteClient) {
- this.resourceClientProxy = resourceClientProxy;
- this.remoteClient = remoteClient;
- }
-
- // ------------------------------------------------------------------------------------------------------
- // Methods here are optional and only accessible if their declared on the custom resource interface class
-
- public Configuration getPluginConfiguration() {
- if (!LazyLoadScenario.isShouldLoad())
- return null;
- return remoteClient.getConfigurationManagerRemote().getPluginConfiguration(remoteClient.getSubject(),
- resourceClientProxy.resourceId);
- }
-
- public ConfigurationDefinition getPluginConfigurationDefinition() {
- return resourceClientProxy.pluginConfigurationDefinition;
- }
-
- public PluginConfigurationUpdate updatePluginConfiguration(Configuration configuration) {
- PluginConfigurationUpdate update =
- remoteClient.getConfigurationManagerRemote().updatePluginConfiguration(
- remoteClient.getSubject(),
- resourceClientProxy.getId(),
- configuration);
-
- return update;
- }
-
- public void editPluginConfiguration() {
- ConfigurationEditor editor = new ConfigurationEditor(resourceClientProxy.client);
- Configuration config = editor.editConfiguration(getPluginConfigurationDefinition(), getPluginConfiguration());
- if (config != null) {
- updatePluginConfiguration(config);
- }
- }
-
- public void editResourceConfiguration() {
- ConfigurationEditor editor = new ConfigurationEditor(resourceClientProxy.client);
- Configuration config = editor.editConfiguration(getResourceConfigurationDefinition(), getResourceConfiguration());
- if (config != null) {
- updateResourceConfiguration(config);
- }
- }
-
- public Configuration getResourceConfiguration() {
- if (!LazyLoadScenario.isShouldLoad())
- return null;
-
- return remoteClient.getConfigurationManagerRemote().getResourceConfiguration(remoteClient.getSubject(),
- resourceClientProxy.resourceId);
- }
-
- public ConfigurationDefinition getResourceConfigurationDefinition() {
- return resourceClientProxy.resourceConfigurationDefinition;
- }
-
- public ResourceConfigurationUpdate updateResourceConfiguration(Configuration configuration) {
- ResourceConfigurationUpdate update =
- remoteClient.getConfigurationManagerRemote().updateResourceConfiguration(
- remoteClient.getSubject(),
- resourceClientProxy.getId(),
- configuration);
-
- return update;
-
- }
-
- public InstalledPackage getBackingContent() {
-
- return remoteClient.getContentManagerRemote().getBackingPackageForResource(remoteClient.getSubject(), resourceClientProxy.resourceId);
- }
-
- public void updateBackingContent(String filename) {
- File file = new File(filename);
- if (!file.exists()) {
- throw new IllegalArgumentException("File not found: " + file.getAbsolutePath());
- }
- if (file.isDirectory()) {
- throw new IllegalArgumentException("File expected, found directory: " + file.getAbsolutePath());
- }
-
-
- InstalledPackage oldPackage = getBackingContent();
-
-
- String oldVersion = oldPackage.getPackageVersion().getVersion();
- String newVersion = "1.0";
- if (oldVersion != null && oldVersion.length() != 0) {
- String[] parts = oldVersion.split("[^a-zA-Z0-9]");
- String lastPart = parts[parts.length-1];
- try {
- int lastNumber = Integer.parseInt(lastPart);
- newVersion = oldVersion.substring(0, oldVersion.length() - lastPart.length()) + (lastNumber + 1);
- } catch (NumberFormatException nfe) {
- newVersion = oldVersion + ".1";
- }
- }
-
- byte[] fileContents = new ScriptUtil(null).getFileBytes(filename);
-
-
- PackageVersion pv =
- remoteClient.getContentManagerRemote().createPackageVersion(
- remoteClient.getSubject(),
- oldPackage.getPackageVersion().getGeneralPackage().getName(),
- oldPackage.getPackageVersion().getGeneralPackage().getPackageType().getId(),
- newVersion,
- oldPackage.getPackageVersion().getArchitecture().getId(),
- fileContents);
-
- remoteClient.getContentManagerRemote().deployPackages(
- remoteClient.getSubject(),
- new int[] { resourceClientProxy.getId()},
- new int[] {pv.getId()});
-
-
- }
-
- public void retrieveBackingContent(String fileName) throws IOException {
-
- InstalledPackage installedPackage = getBackingContent();
-
- if (fileName == null )
- fileName = installedPackage.getPackageVersion().getFileName();
-
- File file = new File(fileName);
-
- byte[] data =
- remoteClient.getContentManagerRemote().getPackageBytes(
- remoteClient.getSubject(), resourceClientProxy.resourceId, installedPackage.getId());
-
- FileOutputStream fos = new FileOutputStream(file);
- fos.write(data);
- fos.close();
-
- }
-
- // ------------------------------------------------------------------------------------------------------
-
-
-
- public Object invoke(Object proxy, Method method, Method proceedMethod, Object[] args) throws Throwable {
-
- if (proceedMethod != null) {
- Method realMethod = ResourceClientProxy.class.getMethod(method.getName(), method.getParameterTypes());
- return realMethod.invoke(resourceClientProxy, args);
- } else {
-
- try {
- Method localMethod = ClientProxyMethodHandler.class.getDeclaredMethod(method.getName(), method
- .getParameterTypes());
- return localMethod.invoke(this, args);
- } catch (NoSuchMethodException nsme) {
-
- String name = method.getName();
- Object key = resourceClientProxy.allProperties.get(name);
- if (key == null) {
- name = decapitalize(method.getName().substring(3, method.getName().length()));
- key = resourceClientProxy.allProperties.get(name);
- }
-
- if (key != null) {
- if (key instanceof Measurement) {
- return key;
- } else if (key instanceof Operation) {
- System.out.println("Invoking operation " + ((Operation) key).getName());
-
- return ((Operation) key).invoke(args);
-
- }
- }
- }
-
- throw new RuntimeException("Can't find custom method: " + method);
- }
- }
- }
-
-
- static String simpleName(String name) {
- return decapitalize(name.replaceAll("\\W", ""));
- }
-
- private static String decapitalize(String name) {
- return Character.toLowerCase(name.charAt(0)) + name.substring(1, name.length());
- }
-
- static String getterName(String name) {
- return "get" + Character.toUpperCase(name.charAt(0)) + name.substring(1, name.length());
- }
-
- public static interface PluginConfigurable {
- public Configuration getPluginConfiguration();
-
- public ConfigurationDefinition getPluginConfigurationDefinition();
-
- public PluginConfigurationUpdate updatePluginConfiguration(Configuration configuration);
-
- public void editPluginConfiguration();
- }
-
- public static interface ResourceConfigurable {
- public Configuration getResourceConfiguration();
-
- public ConfigurationDefinition getResourceConfigurationDefinition();
-
- public ResourceConfigurationUpdate updateResourceConfiguration(Configuration configuration);
-
- public void editResourceConfiguration();
- }
-
- public static interface ContentBackedResource {
-
- public InstalledPackage getBackingContent();
-
-
- public void updateBackingContent(String fileName);
-
-
- public void retrieveBackingContent(String fileName) throws IOException;
-
- }
-
- public static void main(String[] args) throws Exception {
- RemoteClient rc = new RemoteClient("localhost", 7080);
-
- rc.login("rhqadmin", "rhqadmin");
- ClientMain cm = new ClientMain();
- cm.setRemoteClient(rc);
-
- ResourceClientFactory factory = new ResourceClientFactory(cm);
-
- ResourceClientProxy resource = factory.getResource(10571);
-
- for (Measurement m : resource.getMeasurements()) {
- System.out.println(m.toString());
- }
- }
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ConfigurationClassBuilder.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ConfigurationClassBuilder.java
deleted file mode 100644
index 138e45b..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ConfigurationClassBuilder.java
+++ /dev/null
@@ -1,158 +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.enterprise.client.utility;
-
-import java.util.LinkedHashMap;
-
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.NotFoundException;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-
-/**
- * @author Greg Hinkle
- */
-public class ConfigurationClassBuilder {
-
- public static LinkedHashMap<String, CtClass> translateParameters(ConfigurationDefinition def)
- throws NotFoundException {
- LinkedHashMap<String, CtClass> result = new LinkedHashMap<String, CtClass>();
- if (def == null || def.getPropertyDefinitions() == null) {
- return result;
- }
-
- for (PropertyDefinition pd : def.getPropertyDefinitions().values()) {
- if (pd instanceof PropertyDefinitionSimple) {
- PropertyDefinitionSimple simple = (PropertyDefinitionSimple) pd;
- String name = simpleName(simple.getDisplayName());
- CtClass paramType = getSimpleTypeClass(simple);
- result.put(name, paramType);
- }
- }
- return result;
- }
-
- private static CtClass getSimpleTypeClass(PropertyDefinitionSimple simple) throws NotFoundException {
- Class paramType = null;
- switch (simple.getType()) {
- case STRING:
- case LONG_STRING:
- case PASSWORD:
- case FILE:
- case DIRECTORY:
- paramType = String.class;
- break;
- case BOOLEAN:
- paramType = Boolean.TYPE;
- break;
- case INTEGER:
- paramType = Integer.TYPE;
- break;
- case LONG:
- paramType = Long.TYPE;
- break;
- case FLOAT:
- paramType = Float.TYPE;
- break;
- case DOUBLE:
- paramType = Double.TYPE;
- break;
- }
- return ClassPool.getDefault().get(paramType.getName());
- }
-
- public static CtClass translateConfiguration(ConfigurationDefinition def) throws NotFoundException {
- if (def == null) {
- return CtClass.voidType;
- } else if (def.getPropertyDefinitionSimple("operationResult") != null) {
- // Its a simple type
- return getSimpleTypeClass(def.getPropertyDefinitionSimple("operationResult"));
- } else {
-
- // TODO GH: Build a custom type?
- return ClassPool.getDefault().get(Configuration.class.getName());
- }
- }
-
- private static String simpleName(String name) {
- return decapitalize(name.replaceAll("\\W", ""));
- }
-
- private static String decapitalize(String name) {
- return Character.toLowerCase(name.charAt(0)) + name.substring(1, name.length());
- }
-
- public static Configuration translateParametersToConfig(ConfigurationDefinition parametersConfigurationDefinition,
- Object[] args) throws NotFoundException {
- LinkedHashMap<String, CtClass> translateParameters = translateParameters(parametersConfigurationDefinition);
- Configuration config = new Configuration();
-
- int index = 0;
- for (String key : translateParameters.keySet()) {
- config.put(new PropertySimple(key, args[index++]));
-
- }
- return config;
-
- }
-
- public static Object translateResults(ConfigurationDefinition resultsConfigurationDefinition, Configuration result)
- throws NotFoundException {
-
- CtClass expectedReturn = translateConfiguration(resultsConfigurationDefinition);
-
- if (expectedReturn.equals(ClassPool.getDefault().get(Configuration.class.getName()))) {
- return result;
- } else {
- //bail on translation if Configuration passed in is null
- if (result == null)
- return result;
- PropertySimple simple = result.getSimple("operationResult");
- if (simple != null) {
- if (expectedReturn.getName().equals(String.class.getName())) {
- return simple.getStringValue();
- } else if (expectedReturn.getName().equals(Boolean.class.getName())
- || expectedReturn.getName().equals(Boolean.TYPE.getName())) {
- return simple.getBooleanValue();
- } else if (expectedReturn.getName().equals(Integer.class.getName())
- || expectedReturn.getName().equals(Integer.TYPE.getName())) {
- return simple.getIntegerValue();
- } else if (expectedReturn.getName().equals(Long.class.getName())
- || expectedReturn.getName().equals(Long.TYPE.getName())) {
- return simple.getLongValue();
- } else if (expectedReturn.getName().equals(Float.class.getName())
- || expectedReturn.getName().equals(Float.TYPE.getName())) {
- return simple.getFloatValue();
- } else if (expectedReturn.getName().equals(Double.class.getName())
- || expectedReturn.getName().equals(Double.TYPE.getName())) {
- return simple.getDoubleValue();
- } else if (expectedReturn.getName().equals(Boolean.class.getName())
- || expectedReturn.getName().equals(Boolean.TYPE.getName())) {
- return simple.getBooleanValue();
- }
- }
- }
- return null;
- }
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptAssert.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptAssert.java
deleted file mode 100644
index f22af44..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptAssert.java
+++ /dev/null
@@ -1,413 +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.enterprise.client.utility;
-
-import org.testng.Assert;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import java.util.Collection;
-
-public class ScriptAssert {
-
- private ScriptEngine scriptEngine;
-
- public ScriptAssert(ScriptEngine scriptEngine) {
- this.scriptEngine = scriptEngine;
- }
-
- public void assertTrue(boolean condition, String msg) {
- try {
- Assert.assertTrue(condition, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertTrue(boolean condition) {
- try {
- Assert.assertTrue(condition);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertFalse(boolean condition, String msg) {
- try {
- Assert.assertFalse(condition, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertFalse(boolean condition) {
- try {
- Assert.assertFalse(condition);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void fail(String msg, Throwable throwable) {
- try {
- Assert.fail(msg, throwable);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void fail(String msg) {
- try {
- Assert.fail(msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void fail() {
- throw new ScriptAssertionException(new AssertionError());
- }
-
- public void assertEquals(Object actual, Object expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(Object actual, Object expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(String actual, String expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(String actual, String expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(double actual, double expected, double delta, String msg) {
- try {
- Assert.assertEquals(actual, expected, delta, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(double actual, double expected, double delta) {
- try {
- Assert.assertEquals(actual, expected, delta);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(float actual, float expected, float delta, String msg) {
- try {
- Assert.assertEquals(actual, expected, delta, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(float actual, float expected, float delta) {
- try {
- Assert.assertEquals(actual, expected, delta);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(long actual, long expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(long actual, long expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(boolean actual, boolean expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(boolean actual, boolean expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(byte actual, byte expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(byte actual, byte expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(char actual, char expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(char actual, char expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(short actual, short expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch(AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(short actual, short expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(int actual, int expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(int actual, int expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertNotNull(Object object) {
- try {
- Assert.assertNotNull(object);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertNotNull(Object object, String msg) {
- try {
- Assert.assertNotNull(object, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertNull(Object object) {
- try {
- Assert.assertNull(object);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertNull(Object object, String msg) {
- try {
- Assert.assertNull(object, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertSame(Object actual, Object expected, String msg) {
- try {
- Assert.assertSame(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertSame(Object actual, Object expected) {
- try {
- Assert.assertSame(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertNotSame(Object actual, Object expected, String msg) {
- try {
- Assert.assertNotSame(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertNotSame(Object actual, Object expected) {
- try {
- Assert.assertNotSame(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(Collection actual, Collection expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(Collection actual, Collection expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(Object[] actual, Object[] expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEqualsNoOrder(Object[] actual, Object[] expected, String msg) {
- try {
- Assert.assertEqualsNoOrder(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(Object[] actual, Object[] expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEqualsNoOrder(Object[] actual, Object[] expected) {
- try {
- Assert.assertEqualsNoOrder(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(byte[] actual, byte[] expected) {
- try {
- Assert.assertEquals(actual, expected);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertEquals(byte[] actual, byte[] expected, String msg) {
- try {
- Assert.assertEquals(actual, expected, msg);
- } catch (AssertionError e) {
- throw new ScriptAssertionException(e);
- }
- }
-
- public void assertExists(String identifier) {
- assertNotNull(scriptEngine.get(identifier), identifier + " is not defined");
- }
-
- /**
- * JavaScript has only a single numeric type such that <code>x = 1</code> and <code>y = 1.0</code> are considered to
- * be of the same type. From within a (JavaScript) script if you were to call <code>assertEquals(x, y)</code>, you
- * would get an exception that looks something like,
- *
- * <pre>
- * Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: The choice of
- * Java constructor assertEquals matching JavaScript argument types (number,number,string) is ambiguous;
- * candidate constructors are:
- * void assertEquals(java.lang.String,java.lang.String,java.lang.String)
- * void assertEquals(double,double,double)
- * void assertEquals(float,float,float)
- * void assertEquals(long,long,java.lang.String)
- * void assertEquals(byte,byte,java.lang.String)
- * void assertEquals(char,char,java.lang.String)
- * void assertEquals(short,short,java.lang.String)
- * void assertEquals(int,int,java.lang.String) (<Unknown source>#1) in <Unknown source> at line number 1
- </pre>
- *
- * To avoid the ambiguity when comparing numbers in JavaScript scripts, it is recommended to use this method.
- *
- * @param actual The actual value
- * @param expected The expected value
- * @param msg A useful, meaningful error message
- */
- public void assertNumberEqualsJS(double actual, double expected, String msg) {
- assertEquals(actual, expected, msg);
- }
-
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptAssertionException.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptAssertionException.java
deleted file mode 100644
index f17f02b..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptAssertionException.java
+++ /dev/null
@@ -1,57 +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.enterprise.client.utility;
-
-import javax.script.ScriptException;
-
-/**
- * This is a wrapper exception class for {@link java.lang.AssertionError}. The default (i.e., rhino) scripting engine
- * catches any exception, checked or unchecked, thrown from a script and wraps it in an instance of
- * {@link javax.script.ScriptException}. ScriptException provides useful context information such as the script name
- * and line number on which the exception occurred. For reasons unknown instances of {@link Error} are not caught and
- * wrapped in a ScriptException; consequently, no context information is provided about the error, particularly, a line
- * number.
- */
-public class ScriptAssertionException extends RuntimeException {
-
-// public ScriptAssertionException() {
-// super();
-// }
-//
-// public ScriptAssertionException(String message) {
-// super(message);
-// }
-//
-// public ScriptAssertionException(String message, Throwable cause) {
-// super(message, cause);
-// }
-//
-// public ScriptAssertionException(Throwable cause) {
-// super(cause);
-// }
-
- public ScriptAssertionException(AssertionError error) {
- super(new ScriptException(error.getMessage()));
- }
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptUtil.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptUtil.java
deleted file mode 100644
index 5333522..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ScriptUtil.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 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.enterprise.client.utility;
-
-import org.rhq.core.domain.criteria.ResourceCriteria;
-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.resource.Resource;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.client.ClientMain;
-import org.rhq.enterprise.client.commands.ScriptCommand;
-import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
-import org.rhq.enterprise.server.resource.ResourceManagerRemote;
-
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class ScriptUtil {
-
- private ClientMain client;
-
-
- public ScriptUtil(ClientMain client) {
- this.client = client;
- }
-
-
-
- public PageList<Resource> findResources(String string) {
- ResourceManagerRemote resourceManager = client.getRemoteClient().getResourceManagerRemote();
-
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.addFilterName(string);
- return resourceManager.findResourcesByCriteria(client.getSubject(), criteria);
- }
-
-
- public byte[] getFileBytes(String fileName) {
- File file = new File(fileName);
- long length = file.length();
-
- if (length > Integer.MAX_VALUE) {
- throw new IllegalArgumentException("Can not read file larger than " + Integer.MAX_VALUE + " byte: "
- + fileName);
- }
-
- byte[] bytes;
- InputStream is = null;
- try {
- bytes = new byte[(int) length];
- is = new FileInputStream(file);
-
- int offset = 0, bytesRead = 0;
- for (offset = 0, bytesRead = 0; offset < bytes.length && bytesRead >= 0; offset += bytesRead) {
- bytesRead = is.read(bytes, offset, bytes.length - offset);
- }
-
- if (offset < bytes.length) {
- throw new RuntimeException("Could not read entire file " + file.getName() + ", only " + offset + " of "
- + bytes.length + " bytes read");
- }
- } catch (IOException ioe) {
- throw new RuntimeException("Error reading file: " + ioe.getMessage());
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException ioe) {
- throw new RuntimeException("Error closing file: " + ioe.getMessage());
- }
- }
- return bytes;
- }
-
- public String getFileString(String fileName) {
- return new String(getFileBytes(fileName));
- }
-
- public void sleep(long millis) {
- try {
- Thread.sleep(millis);
- } catch (InterruptedException ie) {
- throw new RuntimeException(ie);
- }
- }
-
- public ResourceOperationHistory waitForScheduledOperationToComplete(ResourceOperationSchedule schedule)
- throws InterruptedException{
-
- return waitForScheduledOperationToComplete(schedule, 1000L, 10);
- }
-
- public ResourceOperationHistory waitForScheduledOperationToComplete(ResourceOperationSchedule schedule,
- long intervalDuration,
- int maxIntervals) throws InterruptedException {
- ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
- criteria.addFilterJobId(schedule.getJobId());
- criteria.addFilterResourceIds(schedule.getResource().getId());
- criteria.addSortStartTime(PageOrdering.DESC);
- criteria.setPaging(0, 1);
- criteria.fetchOperationDefinition(true);
- criteria.fetchParameters(true);
- criteria.fetchResults(true);
-
- ResourceOperationHistory history = null;
-
- int i = 0;
-
- while(history == null && i < maxIntervals) {
- Thread.sleep(intervalDuration);
- PageList<ResourceOperationHistory> histories = client.getRemoteClient().getOperationManagerRemote()
- .findResourceOperationHistoriesByCriteria(client.getRemoteClient().getSubject(), criteria);
- if (histories.size() > 0 && histories.get(0).getStatus() != OperationRequestStatus.INPROGRESS) {
- history = histories.get(0);
- }
- ++i;
- }
-
- return history;
- }
-
- public boolean isDefined(String identifier) {
- ScriptCommand cmd = (ScriptCommand) client.getCommands().get("exec");
- ScriptEngine scriptEngine = cmd.getScriptEngine();
-
- Bindings engineBindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
- Bindings globalBindings = scriptEngine.getBindings(ScriptContext.GLOBAL_SCOPE);
-
- return engineBindings.containsKey(identifier) || globalBindings.containsKey(identifier);
- }
-}
diff --git a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
index b80f900..f54a691 100644
--- a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
@@ -53,7 +53,7 @@
<copy file="${settings.localRepository}/org/rhq/rhq-remoting-client-api/${project.version}/rhq-remoting-client-api-${project.version}.jar" todir="${lib.home}" verbose="true" />
<copy file="${settings.localRepository}/org/rhq/rhq-core-domain/${project.version}/rhq-core-domain-${project.version}.jar" tofile="${lib.home}/rhq-core-domain-${project.version}.jar" verbose="true" />
<copy file="${settings.localRepository}/org/rhq/rhq-core-util/${project.version}/rhq-core-util-${project.version}.jar" tofile="${lib.home}/rhq-core-util-${project.version}.jar" verbose="true" />
- <copy file="${settings.localRepository}/org/rhq/rhq-enterprise-server/${project.version}/rhq-enterprise-server-${project.version}.jar" tofile="${lib.home}/rhq-enterprise-server-${project.version}.jar" verbose="true" />
+ <copy file="${settings.localRepository}/org/rhq/rhq-enterprise-server/${project.version}/rhq-enterprise-server-${project.version}-client.jar" tofile="${lib.home}/rhq-enterprise-server-${project.version}-client.jar" verbose="true" />
<copy file="${settings.localRepository}/org/rhq/rhq-enterprise-comm/${project.version}/rhq-enterprise-comm-${project.version}.jar" tofile="${lib.home}/rhq-enterprise-comm-${project.version}.jar" verbose="true" />
<copy file="${settings.localRepository}/jboss/jboss-common/${jboss-common.version}/jboss-common-${jboss-common.version}.jar" tofile="${lib.home}/jboss-common-${jboss-common.version}.jar" verbose="true" />
<copy file="${settings.localRepository}/jboss/jboss-remoting/${jboss-remoting.version}/jboss-remoting-${jboss-remoting.version}.jar" tofile="${lib.home}/jboss-remoting-${jboss-remoting.version}.jar" verbose="true" />
@@ -64,6 +64,7 @@
<copy file="${basedir}/target/${project.artifactId}-${project.version}.jar" tofile="${lib.home}/${project.artifactId}-${project.version}.jar" verbose="true" />
<copy file="${settings.localRepository}/net/sf/opencsv/opencsv/${opencsv.version}/opencsv-${opencsv.version}.jar" tofile="${lib.home}/opencsv-${opencsv.version}.jar" verbose="true" />
<copy file="${settings.localRepository}/org/testng/testng/${testng.version}/testng-${testng.version}.jar" tofile="${lib.home}/testng-${testng.version}.jar" verbose="true" />
+ <copy file="${settings.localRepository}/org/rhq/rhq-script-bindings/${project.version}/rhq-script-bindings-${project.version}.jar" tofile="${lib.home}/rhq-script-bindings-${project.version}.jar" verbose="true" />
</target>
</project>
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
index 22d5305..b795848 100644
--- a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
+++ b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
@@ -12,7 +12,6 @@ import java.util.ArrayList;
import org.testng.annotations.Test;
import org.rhq.enterprise.client.ClientMain;
import org.rhq.enterprise.client.RemoteClient;
-import org.rhq.enterprise.client.utility.ScriptUtil;
import org.rhq.enterprise.server.alert.AlertManagerRemote;
import org.rhq.enterprise.server.alert.AlertDefinitionManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
@@ -23,7 +22,9 @@ import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerRemote;
import org.rhq.enterprise.server.auth.SubjectManagerRemote;
+import org.rhq.bindings.client.RhqManagers;
import org.rhq.bindings.output.TabularWriter;
+import org.rhq.bindings.util.ScriptUtil;
import org.rhq.core.domain.auth.Subject;
import javax.script.ScriptEngine;
@@ -73,7 +74,7 @@ public class ScriptCommandTest {
ScriptEngine scriptEngine = cmd.getScriptEngine();
List<String> mgrsNotBound = new ArrayList<String>();
- for (RemoteClient.Manager mgr : RemoteClient.Manager.values()) {
+ for (RhqManagers mgr : RhqManagers.values()) {
if (!scriptEngine.getBindings(ScriptContext.GLOBAL_SCOPE).containsKey(mgr.name())) {
mgrsNotBound.add(mgr.remoteName());
}
@@ -121,52 +122,52 @@ public class ScriptCommandTest {
}
@Override
- public AlertManagerRemote getAlertManagerRemote() {
+ public AlertManagerRemote getAlertManager() {
return null;
}
@Override
- public AlertDefinitionManagerRemote getAlertDefinitionManagerRemote() {
+ public AlertDefinitionManagerRemote getAlertDefinitionManager() {
return null;
}
@Override
- public ConfigurationManagerRemote getConfigurationManagerRemote() {
+ public ConfigurationManagerRemote getConfigurationManager() {
return null;
}
@Override
- public RepoManagerRemote getRepoManagerRemote() {
+ public RepoManagerRemote getRepoManager() {
return null;
}
@Override
- public ContentManagerRemote getContentManagerRemote() {
+ public ContentManagerRemote getContentManager() {
return null;
}
@Override
- public OperationManagerRemote getOperationManagerRemote() {
+ public OperationManagerRemote getOperationManager() {
return null;
}
@Override
- public RoleManagerRemote getRoleManagerRemote() {
+ public RoleManagerRemote getRoleManager() {
return null;
}
@Override
- public ResourceManagerRemote getResourceManagerRemote() {
+ public ResourceManagerRemote getResourceManager() {
return null;
}
@Override
- public ResourceGroupManagerRemote getResourceGroupManagerRemote() {
+ public ResourceGroupManagerRemote getResourceGroupManager() {
return null;
}
@Override
- public SubjectManagerRemote getSubjectManagerRemote() {
+ public SubjectManagerRemote getSubjectManager() {
return null;
}
}
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptAssertTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptAssertTest.java
index a681efc..10f8fa7 100644
--- a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptAssertTest.java
+++ b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptAssertTest.java
@@ -28,6 +28,8 @@ import static org.testng.Assert.*;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
+import org.rhq.bindings.util.ScriptAssert;
+
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptUtilTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptUtilTest.java
index c257796..7a88720 100644
--- a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptUtilTest.java
+++ b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/utility/ScriptUtilTest.java
@@ -9,6 +9,8 @@ import javax.script.ScriptEngineManager;
import org.testng.annotations.Test;
+import org.rhq.bindings.util.ScriptUtil;
+
public class ScriptUtilTest {
@Test
diff --git a/modules/enterprise/remoting/client-api/pom.xml b/modules/enterprise/remoting/client-api/pom.xml
index ed44e2a..872ac37 100644
--- a/modules/enterprise/remoting/client-api/pom.xml
+++ b/modules/enterprise/remoting/client-api/pom.xml
@@ -63,94 +63,6 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>rhq-enterprise-server</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-validator</groupId>
- <artifactId>commons-validator</artifactId>
- </exclusion>
- <exclusion>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>gnu-getopt</groupId>
- <artifactId>getopt</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-cache</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jbpm</artifactId>
- </exclusion>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-dbutils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>safe-invoker</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.rhq</groupId>
- <artifactId>test-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.snmp4j</groupId>
- <artifactId>snmp4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>oswego-concurrent</groupId>
- <artifactId>concurrent</artifactId>
- </exclusion>
- <exclusion>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </exclusion>
- <exclusion>
- <groupId>rss4j</groupId>
- <artifactId>rss4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>rhq-core-domain</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index 05d8e2c..ddd8f94 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -22,11 +22,16 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.security.SSLSocketBuilder;
import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker;
+import org.rhq.bindings.client.RhqFacade;
+import org.rhq.bindings.client.RhqManagers;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.communications.util.SecurityUtil;
import org.rhq.enterprise.server.alert.AlertDefinitionManagerRemote;
@@ -66,60 +71,10 @@ import org.rhq.enterprise.server.tagging.TagManagerRemote;
* @author Jay Shaughnessy
* @author John Mazzitelli
*/
-public class RemoteClient {
-
- public enum Manager {
- AlertManager(AlertManagerRemote.class), //
- AlertDefinitionManager(AlertDefinitionManagerRemote.class), //
- AvailabilityManager(AvailabilityManagerRemote.class), //
- BundleManager(BundleManagerRemote.class), //
- CallTimeDataManager(CallTimeDataManagerRemote.class), //
- RepoManager(RepoManagerRemote.class), //
- ConfigurationManager(ConfigurationManagerRemote.class), //
- ContentManager(ContentManagerRemote.class), //
- DataAccessManager(DataAccessManagerRemote.class), //
- DiscoveryBoss(DiscoveryBossRemote.class), //
- EventManager(EventManagerRemote.class), //
- MeasurementBaselineManager(MeasurementBaselineManagerRemote.class), //
- MeasurementDataManager(MeasurementDataManagerRemote.class), //
- MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class), //
- MeasurementScheduleManager(MeasurementScheduleManagerRemote.class), //
- OperationManager(OperationManagerRemote.class), //
- ResourceManager(ResourceManagerRemote.class), //
- ResourceFactoryManager(ResourceFactoryManagerRemote.class), //
- ResourceGroupManager(ResourceGroupManagerRemote.class), //
- ResourceTypeManager(ResourceTypeManagerRemote.class), //
- RoleManager(RoleManagerRemote.class), //
- SavedSearchManager(SavedSearchManagerRemote.class), //
- SubjectManager(SubjectManagerRemote.class), //
- SupportManager(SupportManagerRemote.class), //
- SystemManager(SystemManagerRemote.class), //
- RemoteInstallManager(RemoteInstallManagerRemote.class), //
- TagManager(TagManagerRemote.class);
-
- private Class<?> remote;
- private String remoteName;
- private String beanName;
-
- private Manager(Class<?> remote) {
- this.remote = remote;
- this.beanName = this.name() + "Bean";
- this.remoteName = this.name() + "Remote";
- }
-
- Class<?> remote() {
- return this.remote;
- }
-
- public String beanName() {
- return this.beanName;
- }
-
- public String remoteName() {
- return this.remoteName;
- }
- };
+public class RemoteClient implements RhqFacade {
+ private static final Log LOG = LogFactory.getLog(RemoteClient.class);
+
public static final String NONSECURE_TRANSPORT = "servlet";
public static final String SECURE_TRANSPORT = "sslservlet";
@@ -184,12 +139,10 @@ public class RemoteClient {
logout();
doConnect();
- this.subject = getSubjectManagerRemote().login(user, password);
+ this.subject = getSubjectManager().login(user, password);
this.loggedIn = true;
- ServerVersion version = getSystemManagerRemote().getServerVersion(this.subject);
- // TODO: what to do with this?
- System.out.println("Remote server version is: " + version);
+ ServerVersion version = getSystemManager().getServerVersion(this.subject);
return this.subject;
}
@@ -200,7 +153,7 @@ public class RemoteClient {
public void logout() {
try {
if (this.loggedIn && this.subject != null) {
- getSubjectManagerRemote().logout(this.subject);
+ getSubjectManager().logout(this.subject);
}
} catch (Exception e) {
// just keep going so we can disconnect this client
@@ -304,112 +257,112 @@ public class RemoteClient {
this.transport = transport;
}
- public AlertManagerRemote getAlertManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.AlertManager);
+ public AlertManagerRemote getAlertManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.AlertManager);
}
- public AlertDefinitionManagerRemote getAlertDefinitionManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.AlertDefinitionManager);
+ public AlertDefinitionManagerRemote getAlertDefinitionManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.AlertDefinitionManager);
}
- public AvailabilityManagerRemote getAvailabilityManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.AvailabilityManager);
+ public AvailabilityManagerRemote getAvailabilityManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.AvailabilityManager);
}
- public BundleManagerRemote getBundleManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.BundleManager);
+ public BundleManagerRemote getBundleManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.BundleManager);
}
- public CallTimeDataManagerRemote getCallTimeDataManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.CallTimeDataManager);
+ public CallTimeDataManagerRemote getCallTimeDataManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.CallTimeDataManager);
}
- public RepoManagerRemote getRepoManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.RepoManager);
+ public RepoManagerRemote getRepoManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.RepoManager);
}
- public ConfigurationManagerRemote getConfigurationManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.ConfigurationManager);
+ public ConfigurationManagerRemote getConfigurationManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.ConfigurationManager);
}
- public ContentManagerRemote getContentManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.ContentManager);
+ public ContentManagerRemote getContentManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.ContentManager);
}
- public DataAccessManagerRemote getDataAccessManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.DataAccessManager);
+ public DataAccessManagerRemote getDataAccessManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.DataAccessManager);
}
- public DiscoveryBossRemote getDiscoveryBossRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.DiscoveryBoss);
+ public DiscoveryBossRemote getDiscoveryBoss() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.DiscoveryBoss);
}
- public EventManagerRemote getEventManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.EventManager);
+ public EventManagerRemote getEventManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.EventManager);
}
- public MeasurementBaselineManagerRemote getMeasurementBaselineManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.MeasurementBaselineManager);
+ public MeasurementBaselineManagerRemote getMeasurementBaselineManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.MeasurementBaselineManager);
}
- public MeasurementDataManagerRemote getMeasurementDataManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.MeasurementDataManager);
+ public MeasurementDataManagerRemote getMeasurementDataManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.MeasurementDataManager);
}
- public MeasurementDefinitionManagerRemote getMeasurementDefinitionManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.MeasurementDefinitionManager);
+ public MeasurementDefinitionManagerRemote getMeasurementDefinitionManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.MeasurementDefinitionManager);
}
- public MeasurementScheduleManagerRemote getMeasurementScheduleManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.MeasurementScheduleManager);
+ public MeasurementScheduleManagerRemote getMeasurementScheduleManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.MeasurementScheduleManager);
}
- public OperationManagerRemote getOperationManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.OperationManager);
+ public OperationManagerRemote getOperationManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.OperationManager);
}
- public ResourceManagerRemote getResourceManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.ResourceManager);
+ public ResourceManagerRemote getResourceManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.ResourceManager);
}
- public ResourceFactoryManagerRemote getResourceFactoryManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.ResourceFactoryManager);
+ public ResourceFactoryManagerRemote getResourceFactoryManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.ResourceFactoryManager);
}
- public ResourceGroupManagerRemote getResourceGroupManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.ResourceGroupManager);
+ public ResourceGroupManagerRemote getResourceGroupManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.ResourceGroupManager);
}
- public ResourceTypeManagerRemote getResourceTypeManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.ResourceTypeManager);
+ public ResourceTypeManagerRemote getResourceTypeManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.ResourceTypeManager);
}
- public RoleManagerRemote getRoleManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.RoleManager);
+ public RoleManagerRemote getRoleManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.RoleManager);
}
- public SavedSearchManagerRemote getSavedSearchManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.SavedSearchManager);
+ public SavedSearchManagerRemote getSavedSearchManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.SavedSearchManager);
}
- public SubjectManagerRemote getSubjectManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.SubjectManager);
+ public SubjectManagerRemote getSubjectManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.SubjectManager);
}
- public SupportManagerRemote getSupportManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.SupportManager);
+ public SupportManagerRemote getSupportManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.SupportManager);
}
- public SystemManagerRemote getSystemManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.SystemManager);
+ public SystemManagerRemote getSystemManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.SystemManager);
}
- public RemoteInstallManagerRemote getRemoteInstallManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.RemoteInstallManager);
+ public RemoteInstallManagerRemote getRemoteInstallManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.RemoteInstallManager);
}
- public TagManagerRemote getTagManagerRemote() {
- return RemoteClientProxy.getProcessor(this, Manager.TagManager);
+ public TagManagerRemote getTagManager() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.TagManager);
}
/**
@@ -423,12 +376,12 @@ public class RemoteClient {
this.managers = new HashMap<String, Object>();
- for (Manager manager : Manager.values()) {
+ for (RhqManagers manager : RhqManagers.values()) {
try {
- Method m = this.getClass().getMethod("get" + manager.remoteName());
+ Method m = this.getClass().getMethod("get" + manager.name());
this.managers.put(manager.name(), m.invoke(this));
} catch (Throwable e) {
- System.out.println("Failed to load manager " + manager + " due to missing class: " + e);
+ LOG.error("Failed to load manager " + manager + " due to missing class.", e);
}
}
}
@@ -461,7 +414,7 @@ public class RemoteClient {
this.remotingClient.disconnect();
}
} catch (Exception e) {
- e.printStackTrace(); // TODO what to do here?
+ LOG.warn(e); // TODO what to do here?
} finally {
this.remotingClient = null;
}
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java
index c76d46f..5e897cb 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java
@@ -22,18 +22,13 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import javassist.CannotCompileException;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtMethod;
-import javassist.CtNewMethod;
-import javassist.NotFoundException;
-import javassist.bytecode.ParameterAnnotationsAttribute;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jboss.remoting.invocation.NameBasedInvocation;
+import org.rhq.bindings.client.RhqManagers;
+import org.rhq.bindings.util.InterfaceSimplifier;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.server.ExternalizableStrategy;
@@ -43,116 +38,34 @@ import org.rhq.core.server.ExternalizableStrategy;
*
* @author Greg Hinkle
*/
-@SuppressWarnings("unchecked")
public class RemoteClientProxy implements InvocationHandler {
- private static final Log LOG = LogFactory.getLog(RemoteClientProxy.class);
-
private RemoteClient client;
- private RemoteClient.Manager manager;
+ private RhqManagers manager;
// public RHQRemoteClientProxy(RHQRemoteClient client, Class targetClass) {
- public RemoteClientProxy(RemoteClient client, RemoteClient.Manager manager) {
+ public RemoteClientProxy(RemoteClient client, RhqManagers manager) {
this.client = client;
this.manager = manager;
}
- public Class getRemoteInterface() {
+ public Class<?> getRemoteInterface() {
return this.manager.remote();
}
- public static <T> T getProcessor(RemoteClient remoteClient, RemoteClient.Manager manager) {
+ @SuppressWarnings("unchecked")
+ public static <T> T getProcessor(RemoteClient remoteClient, RhqManagers manager) {
try {
RemoteClientProxy gpc = new RemoteClientProxy(remoteClient, manager);
- Class intf = simplifyInterface(gpc.manager.remote());
+ Class<?> intf = InterfaceSimplifier.simplify(gpc.manager.remote());
return (T) Proxy
- .newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { intf }, gpc);
+ .newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[] { intf }, gpc);
} catch (Exception e) {
throw new RuntimeException("Failed to get remote connection proxy", e);
}
}
- private static Class simplifyInterface(Class intf) {
- try {
- ClassPool cp = ClassPool.getDefault();
-
- String simpleName = intf.getName() + "Simple";
-
- try {
- @SuppressWarnings({"UnusedDeclaration"})
- CtClass cached = cp.get(simpleName);
- return Class.forName(simpleName, false, cp.getClassLoader());
-
- } catch (NotFoundException e) {
- // ok... load it
- } catch (ClassNotFoundException e) {
- LOG.debug("Class [" + simpleName + "] not found - cause: " + e);
- }
-
- CtClass cc = cp.get(intf.getName());
-
- CtClass cz = cp.getAndRename(intf.getName(), simpleName);
- // CtClass cz = cp.makeInterface(simpleName, cc);
-
- cz.defrost();
-
- cz.setSuperclass(cc);
-
- CtMethod[] methods = cc.getMethods();
-
- for (CtMethod originalMethod : methods) {
-
- CtClass[] params = originalMethod.getParameterTypes();
- if (params.length > 0 && params[0].getName().equals(Subject.class.getName())) {
-
- CtClass[] simpleParams = new CtClass[params.length - 1];
-
- System.arraycopy(params, 1, simpleParams, 0, params.length - 1);
- cz.defrost();
-
- CtMethod newMethod = CtNewMethod.abstractMethod(originalMethod.getReturnType(), originalMethod
- .getName(), simpleParams, null, cz);
-
- ParameterAnnotationsAttribute originalAnnotationsAttribute = (ParameterAnnotationsAttribute) originalMethod
- .getMethodInfo().getAttribute(ParameterAnnotationsAttribute.visibleTag);
-
- // If there are any parameter annotations, copy the one's we're keeping
- if (originalAnnotationsAttribute != null) {
-
- javassist.bytecode.annotation.Annotation[][] originalAnnotations = originalAnnotationsAttribute
- .getAnnotations();
- javassist.bytecode.annotation.Annotation[][] newAnnotations = new javassist.bytecode.annotation.Annotation[originalAnnotations.length - 1][];
-
- for (int i = 1; i < originalAnnotations.length; i++) {
- newAnnotations[i - 1] = new javassist.bytecode.annotation.Annotation[originalAnnotations[i].length];
- System.arraycopy(originalAnnotations[i], 0, newAnnotations[i - 1], 0,
- originalAnnotations[i].length);
- }
-
- ParameterAnnotationsAttribute newAnnotationsAttribute = new ParameterAnnotationsAttribute(
- newMethod.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
-
- newAnnotationsAttribute.setAnnotations(newAnnotations);
-
- newMethod.getMethodInfo().addAttribute(newAnnotationsAttribute);
-
- }
-
- cz.addMethod(newMethod);
- }
- }
-
- return cz.toClass();
-
- } catch (NotFoundException e) {
- LOG.debug("Failed to simplify " + intf + " - cause: " + e);
- } catch (CannotCompileException e) {
- LOG.error("Failed to simplify " + intf + ".", e);
- }
- return intf;
- }
-
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
@@ -161,12 +74,12 @@ public class RemoteClientProxy implements InvocationHandler {
String methodName = manager.beanName() + ":" + method.getName();
- Class[] params = method.getParameterTypes();
+ Class<?>[] params = method.getParameterTypes();
try {
- Class[] interfaces = method.getDeclaringClass().getInterfaces();
+ Class<?>[] interfaces = method.getDeclaringClass().getInterfaces();
- Class originalClass;
+ Class<?> originalClass;
if (interfaces != null && interfaces.length > 0) {
originalClass = interfaces[0];
} else {
@@ -187,7 +100,7 @@ public class RemoteClientProxy implements InvocationHandler {
args = newArgs;
int numParams = (null == params) ? 0 : params.length;
- Class[] newParams = new Class[numParams + 1];
+ Class<?>[] newParams = new Class[numParams + 1];
if (numParams > 0) {
System.arraycopy(params, 0, newParams, 1, numParams);
}
@@ -210,7 +123,7 @@ public class RemoteClientProxy implements InvocationHandler {
}
}
- private String[] createParamSignature(Class[] types) {
+ private String[] createParamSignature(Class<?>[] types) {
String[] paramSig = new String[types.length];
for (int x = 0; x < types.length; x++) {
paramSig[x] = types[x].getName();
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 7363fcc..29abc06 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -482,6 +482,14 @@
</testResources>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ejb-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <generateClient>true</generateClient>
+ </configuration>
+ </plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
commit 8e0df522a432a66392d428aeb8e86a71c6d1061e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Jan 7 11:43:03 2011 +0100
Starting to rip out common ScriptEngine bindings out of the CLI code into a reusable component that could be used on the serverside without a standard input attached.
diff --git a/modules/enterprise/binding/pom.xml b/modules/enterprise/binding/pom.xml
new file mode 100644
index 0000000..8523c1d
--- /dev/null
+++ b/modules/enterprise/binding/pom.xml
@@ -0,0 +1,59 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>rhq-enterprise-parent</artifactId>
+ <groupId>org.rhq</groupId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-script-bindings</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>RHQ Script Bindings</name>
+ <description>Abstraction of different facilities and default configurations for script bindings</description>
+
+ <properties>
+ <persistence-api.version>1.0</persistence-api.version>
+ <opencsv.version>1.8</opencsv.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>hibernate</groupId>
+ <artifactId>hibernate3</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>${persistence-api.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testng.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
+ <version>${opencsv.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
new file mode 100644
index 0000000..4179dbe
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
@@ -0,0 +1,100 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.bindings;
+
+import java.io.IOException;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+import org.rhq.bindings.engine.JsEngineInitializer;
+import org.rhq.bindings.engine.ScriptEngineInitializer;
+import org.rhq.bindings.export.Exporter;
+import org.rhq.bindings.util.PackageFinder;
+import org.rhq.core.domain.util.PageControl;
+
+/**
+ * This is RHQ specific imitation of ScriptEngineFactory.
+ *
+ * In RHQ, we provide a standard set of bound variables in the script context
+ * and also import classes from our standard packages to ease the development
+ * of the scripts.
+ * <p>
+ * This factory is able to instantiate a script engine and initialize it consistently
+ * so that all users of the script engine get the uniform environment to write the scripts
+ * in.
+ *
+ * @author Lukas Krejci
+ */
+public class ScriptEngineFactory {
+
+ private static final ScriptEngineInitializer[] KNOWN_ENGINES = {new JsEngineInitializer()};
+
+ private ScriptEngineFactory() {
+
+ }
+
+ /**
+ * Initializes the script engine for given language.
+ *
+ * @param language the language of the script to instantiate
+ * @param packageFinder the package finder to find the standard packages in user provided locations
+ * @return the initialized engine or null if the engine for given language isn't known.
+ *
+ * @throws ScriptException on error during initialization of the script environment
+ * @throws IOException if the package finder fails to find the packages
+ */
+ public static ScriptEngine getScriptEngine(String language, PackageFinder packageFinder) throws ScriptException, IOException {
+ ScriptEngineInitializer initializer = getInitializer(language);
+
+ if (initializer == null) {
+ return null;
+ }
+
+ ScriptEngine engine = initializer.instantiate(packageFinder.findPackages("org.rhq.core.domain"));
+
+ injectStandardBindings(engine);
+
+ return engine;
+ }
+
+ public static void injectStandardBindings(ScriptEngine engine) {
+ Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
+ PageControl pc = new PageControl();
+ pc.setPageNumber(-1);
+ bindings.put("unlimitedPC", pc);
+ bindings.put("pageControl", PageControl.getUnlimitedInstance());
+ bindings.put("exporter", new Exporter());
+
+ engine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
+ }
+
+ private static ScriptEngineInitializer getInitializer(String language) {
+ for (ScriptEngineInitializer i : KNOWN_ENGINES) {
+ if (i.getEngineName().equals(language)) {
+ return i;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java
new file mode 100644
index 0000000..8186831
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java
@@ -0,0 +1,50 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.bindings.engine;
+
+import java.util.List;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class JsEngineInitializer implements ScriptEngineInitializer {
+
+ public String getEngineName() {
+ return "JavaScript";
+ }
+
+ public ScriptEngine instantiate(List<String> packages) throws ScriptException {
+ ScriptEngineManager sem = new ScriptEngineManager();
+ ScriptEngine eng = sem.getEngineByName(getEngineName());
+
+ for(String pkg : packages) {
+ eng.eval("importPackage(" + pkg + ")");
+ }
+
+ return eng;
+ }
+
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/ScriptEngineInitializer.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/ScriptEngineInitializer.java
new file mode 100644
index 0000000..bc76433
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/ScriptEngineInitializer.java
@@ -0,0 +1,38 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.bindings.engine;
+
+import java.util.List;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+/**
+ * Is able to instatiate a script engine and import packages into the context
+ * of the engine.
+ *
+ * @author Lukas Krejci
+ */
+public interface ScriptEngineInitializer {
+
+ String getEngineName();
+
+ ScriptEngine instantiate(List<String> packages) throws ScriptException;
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/export/ExportException.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/export/ExportException.java
new file mode 100644
index 0000000..6fe8e32
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/export/ExportException.java
@@ -0,0 +1,43 @@
+/*
+ * 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.bindings.export;
+
+public class ExportException extends RuntimeException {
+
+ public ExportException() {
+ super();
+ }
+
+ public ExportException(String message) {
+ super(message);
+ }
+
+ public ExportException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ExportException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/export/Exporter.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/export/Exporter.java
new file mode 100644
index 0000000..0e39b54
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/export/Exporter.java
@@ -0,0 +1,86 @@
+/*
+ * 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.bindings.export;
+
+import org.rhq.bindings.output.TabularWriter;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class Exporter {
+
+ private String format;
+
+ private String file;
+
+ private TabularWriter tabularWriter;
+
+ private FileWriter fileWriter;
+
+ public void setTarget(String format, String file) {
+ try {
+ this.format = format;
+ this.file = file;
+ fileWriter = new FileWriter(this.file);
+ tabularWriter = new TabularWriter(new PrintWriter(fileWriter), format);
+ tabularWriter.setExportMode(true);
+ } catch (IOException e) {
+ throw new ExportException(e);
+ }
+ }
+
+ public int getPageWidth() {
+ return tabularWriter.getWidth();
+ }
+
+ public void setPageWidth(int width) {
+ tabularWriter.setWidth(width);
+ }
+
+ public void write(Object object) {
+ try {
+ tabularWriter.print(object);
+ fileWriter.flush();
+ } catch (IOException e) {
+ throw new ExportException(e);
+ }
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public void setFormat(String format) {
+ this.format = format;
+ }
+
+ public String getFile() {
+ return file;
+ }
+
+ public void setFile(String file) {
+ this.file = file;
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/output/TabularWriter.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/output/TabularWriter.java
new file mode 100644
index 0000000..5e24f53
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/output/TabularWriter.java
@@ -0,0 +1,708 @@
+/*
+ * 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.bindings.output;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import au.com.bytecode.opencsv.CSVWriter;
+
+import org.rhq.bindings.util.LazyLoadScenario;
+import org.rhq.bindings.util.ShortOutput;
+import org.rhq.bindings.util.SummaryFilter;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.ResourceAvailability;
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ * @author Greg Hinkle
+ */
+public class TabularWriter {
+
+ private static final String CSV = "csv";
+
+ String[] headers;
+ int[] maxColumnLength;
+ boolean[] noShrinkColumns;
+ int width = 160;
+ PrintWriter out;
+ private String format = "raw";
+ private CSVWriter csvWriter;
+ private SummaryFilter summaryFilter = new SummaryFilter();
+ boolean exportMode;
+
+ static Set<String> IGNORED_PROPS = new HashSet<String>();
+
+ static {
+ IGNORED_PROPS.add("mtime");
+ IGNORED_PROPS.add("ctime");
+ IGNORED_PROPS.add("itime");
+ IGNORED_PROPS.add("uuid");
+ IGNORED_PROPS.add("parentResource");
+ }
+
+ static Set<Class> SIMPLE_TYPES = new HashSet<Class>();
+
+ static {
+ SIMPLE_TYPES.add(Byte.class);
+ SIMPLE_TYPES.add(Byte.TYPE);
+ SIMPLE_TYPES.add(Short.class);
+ SIMPLE_TYPES.add(Short.TYPE);
+ SIMPLE_TYPES.add(Integer.class);
+ SIMPLE_TYPES.add(Integer.TYPE);
+ SIMPLE_TYPES.add(Long.class);
+ SIMPLE_TYPES.add(Long.TYPE);
+ SIMPLE_TYPES.add(Float.class);
+ SIMPLE_TYPES.add(Float.TYPE);
+ SIMPLE_TYPES.add(Double.class);
+ SIMPLE_TYPES.add(Double.TYPE);
+ SIMPLE_TYPES.add(Boolean.class);
+ SIMPLE_TYPES.add(Boolean.TYPE);
+ SIMPLE_TYPES.add(String.class);
+ }
+
+ public TabularWriter(PrintWriter out, String... headers) {
+ this.headers = headers;
+ this.out = out;
+ }
+
+ public TabularWriter(PrintWriter out) {
+ this.out = out;
+ }
+
+ public TabularWriter(PrintWriter out, String format) {
+ this.out = out;
+ this.format = format;
+
+ if (CSV.equals(format)) {
+ csvWriter = new CSVWriter(out);
+ }
+ }
+
+ public void print(Object object) {
+
+ if (object instanceof Map) {
+ print((Map) object);
+ return;
+ }
+
+ if (object instanceof Collection) {
+ print((Collection) object);
+ return;
+ }
+
+ if (object instanceof Configuration) {
+ print((Configuration) object);
+ return;
+ }
+
+ if (object != null && object.getClass().isArray()) {
+ print((Object[]) object);
+ return;
+ }
+
+ try {
+
+ if (SIMPLE_TYPES.contains(object.getClass())) {
+ this.out.println(String.valueOf(object));
+ return;
+ }
+
+ out.println(object.getClass().getSimpleName() + ":");
+ Map<String, PropertyInfo> properties = new LinkedHashMap<String, PropertyInfo>();
+ int maxLength = 0;
+
+ for (PropertyDescriptor pd : summaryFilter.getPropertyDescriptors(object, exportMode)) {
+ Method m = pd.getReadMethod();
+ Object val = null;
+ if (m != null) {
+ val = invoke(object, m);
+ }
+
+ if (val == null) {
+ maxLength = Math.max(maxLength, pd.getName().length());
+ properties.put(pd.getName(), new PropertyInfo(pd.getName(), null));
+ } else {
+ try {
+ String str = shortVersion(val);
+ maxLength = Math.max(maxLength, pd.getName().length());
+ properties.put(pd.getName(), new PropertyInfo(str, pd.getPropertyType()));
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ for (String key : properties.keySet()) {
+ printProperty(key, properties.get(key), maxLength);
+ }
+
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (IntrospectionException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private static class PropertyInfo {
+ String value;
+
+ Class<?> type;
+
+ PropertyInfo(String propertyValue, Class<?> propertyType) {
+ value = propertyValue;
+ type = propertyType;
+ }
+ }
+
+ private void printProperty(String name, PropertyInfo propertyInfo, int maxLength) {
+ out.print("\t");
+ printPreSpaced(out, name, maxLength);
+ out.print(": ");
+
+ if (propertyInfo.type == null) {
+ out.println("");
+ } else if (exportMode || !String.class.equals(propertyInfo.type)) {
+ out.println(propertyInfo.value);
+ } else {
+ out.println(abbreviate(propertyInfo.value, width - 12 - maxLength));
+ }
+ }
+
+ // This method is taken verbatim from the Commons Lang project in the org.apache.commons.lang.StringUtils class
+ // TODO Should this method go into one our StringUtil classes?
+ private String abbreviate(String string, int maxWidth) {
+ int offset = 0;
+
+ if (string == null) {
+ return null;
+ }
+
+ if (maxWidth < 4) {
+ throw new IllegalArgumentException("Minimum abbreviation width is 4");
+ }
+
+ if (string.length() <= maxWidth) {
+ return string;
+ }
+
+ if (offset > string.length()) {
+ offset = string.length();
+ }
+
+ if ((string.length() - offset) < (maxWidth - 3)) {
+ offset = string.length() - (maxWidth - 3);
+ }
+
+ if (offset <= 4) {
+ return string.substring(0, maxWidth - 3) + "...";
+ }
+
+ if (maxWidth < 7) {
+ throw new IllegalArgumentException("Minimum abbreviation width with offset is 7");
+ }
+
+ if ((offset + (maxWidth - 3)) < string.length()) {
+ return "..." + abbreviate(string.substring(offset), maxWidth - 3);
+ }
+
+ return "..." + string.substring(string.length() - (maxWidth - 3));
+ }
+
+ public void print(Map map) {
+
+ String[][] data = new String[map.size()][];
+ int i = 0;
+ for (Object key : map.keySet()) {
+ Object value = map.get(key);
+ data[i] = new String[2];
+ data[i][0] = shortVersion(key);
+ data[i][1] = shortVersion(value);
+ i++;
+ }
+ this.headers = new String[] { "Key", "Value" };
+ print(data);
+ }
+
+ public void print(Collection list) {
+ // List of arbitrary objects
+ if (list == null || list.size() == 0)
+ out.println("no data");
+ else if (list.size() == 1 && !CSV.equals(format)) {
+ out.println("one row");
+
+ print(list.iterator().next());
+ } else {
+
+ String[][] data = null;
+
+ if (!allOneType(list)) {
+ printStrings(list);
+ } else {
+
+ Object firstObject = list.iterator().next();
+ try {
+
+ if (firstObject instanceof String) {
+ headers = new String[] { "Value" };
+ data = new String[list.size()][1];
+ int i = 0;
+ for (Object object : list) {
+ data[i++][0] = (String) object;
+ }
+
+ } else {
+
+ if (consistentMaps(list)) {
+ // results printed
+
+ } else {
+
+ int i = 0;
+
+ List<PropertyDescriptor> pdList = new ArrayList<PropertyDescriptor>();
+ for (PropertyDescriptor pd : summaryFilter.getPropertyDescriptors(firstObject, exportMode)) {
+ try {
+ boolean allNull = true;
+ for (Object row : list) {
+ Method m = pd.getReadMethod();
+ Object val = null;
+ if (m != null) {
+ val = invoke(row, pd.getReadMethod());
+ }
+ if ((val != null && !(val instanceof Collection))
+ || ((val != null && (val instanceof Collection) && !((Collection) val)
+ .isEmpty())))
+ allNull = false;
+ }
+ if (!allNull && !IGNORED_PROPS.contains(pd.getName())) {
+ pdList.add(pd);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ headers = new String[pdList.size()];
+ data = new String[list.size()][pdList.size()];
+
+ for (PropertyDescriptor pd : pdList) {
+ headers[i++] = pd.getName();
+ }
+ i = 0;
+ for (Object row : list) {
+ int j = 0;
+ for (PropertyDescriptor pd : pdList) {
+
+ Object val = "?";
+ val = invoke(row, pd.getReadMethod());
+ if (val == null) {
+ data[i][j++] = "";
+ } else {
+ data[i][j++] = shortVersion(val);
+ }
+ }
+ i++;
+ }
+
+ this.print(data);
+
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } finally {
+ headers = null;
+ }
+ }
+
+ }
+
+ }
+
+ private boolean consistentMaps(Collection list) {
+ List<String> keys = null;
+ String[][] data = new String[list.size()][];
+ int i = 0;
+ for (Object row : list) {
+ if (!(row instanceof Map) && !(row instanceof PropertyMap)) {
+ return false;
+ }
+ if (keys == null) {
+ keys = new ArrayList<String>();
+
+ //insert check for PropertyMap as they are not instances of Map
+ if (row instanceof PropertyMap) {
+ //TODO: spinder 1/15/10. PropertyMap is arbitrarily complex. Only serialize simple props?
+ for (Object key : ((PropertyMap) row).getMap().keySet()) {
+ String headerKey = stringValueOf(key);
+ keys.add(headerKey);
+ }
+ } else {//else row is a Map
+ for (Object key : ((Map) row).keySet()) {
+ String headerKey = stringValueOf(key);
+ keys.add(headerKey);
+ }
+ }
+ //conditionally put order on the headers to mimic core gui listing style/order
+ //Ex. Pid Name Size User Time Kernel Time
+ if (keys.contains("pid")) {
+ String[] processAttribute = { "pid", "name", "size", "userTime", "kernelTime" };
+ List<String> newKeyOrder = new ArrayList<String>();
+ for (String attribute : processAttribute) {
+ newKeyOrder.add(attribute);
+ keys.remove(attribute);
+ }
+ //postpend remaining keys if any to the newHeader list
+ for (String key : keys) {
+ newKeyOrder.add(key);
+ }
+ keys = newKeyOrder;
+ }
+ }
+
+ data[i] = new String[keys.size()];
+ if (row instanceof PropertyMap) {
+ for (String key : keys) {
+ if (!keys.contains(stringValueOf(key))) {
+ return false;
+ }
+ data[i][keys.lastIndexOf(stringValueOf(key))] = shortVersion(((PropertyMap) row).get(String
+ .valueOf(key)));
+ }
+ } else {//else row is a Map
+ for (Object key : ((Map) row).keySet()) {
+ if (!keys.contains(stringValueOf(key))) {
+ return false;
+ }
+ data[i][keys.lastIndexOf(stringValueOf(key))] = shortVersion(((Map) row).get(key));
+ }
+ }
+ i++;
+ }
+
+ if (keys != null) {
+ headers = keys.toArray(new String[keys.size()]);
+ print(data);
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ public void print(Configuration config) {
+ out.println("Configuration [" + config.getId() + "] - " + config.getNotes());
+ for (PropertySimple p : config.getSimpleProperties().values()) {
+ print(p, 1);
+ }
+ for (PropertyList p : config.getListProperties().values()) {
+ print(p, 1);
+ }
+ for (PropertyMap p : config.getMapProperties().values()) {
+ print(p, 1);
+ }
+
+ }
+
+ public void print(PropertySimple p, int depth) {
+ out.println(indent(depth) + p.getName() + " = " + p.getStringValue());
+ }
+
+ public void print(PropertyList p, int depth) {
+ out.println(indent(depth) + p.getName() + " [" + p.getList().size() + "] {");
+ if (p.getList().get(0) instanceof PropertyMap) {
+ consistentMaps(p.getList());
+
+ } else {
+ for (Property entry : p.getList()) {
+ if (entry instanceof PropertySimple) {
+ print((PropertySimple) entry, depth + 1);
+ } else if (entry instanceof PropertyMap) {
+ print((PropertyMap) entry, depth + 1);
+ }
+ }
+ }
+
+ out.println(indent(depth) + "}");
+ }
+
+ public void print(PropertyMap p, int depth) {
+ out.println(indent(depth) + p.getName() + " [" + p.getMap().size() + "] {");
+ for (String key : p.getMap().keySet()) {
+ Property entry = p.getMap().get(key);
+ if (entry instanceof PropertySimple) {
+ print((PropertySimple) entry, depth + 1);
+ } else if (entry instanceof PropertyMap) {
+ print((PropertyMap) entry, depth + 1);
+ }
+ }
+ out.println(indent(depth) + "}");
+ }
+
+ private String indent(int x) {
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < x; i++) {
+ buf.append(" ");
+ }
+ return buf.toString();
+ }
+
+ private void printStrings(Collection list) {
+ for (Object object : list) {
+ out.println(stringValueOf(object));
+ }
+ }
+
+ private boolean allOneType(Collection list) {
+ Class lastClass = null;
+ for (Object object : list) {
+ if (lastClass == null) {
+ lastClass = object.getClass();
+ } else if (!object.getClass().equals(lastClass)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void print(Object[] data) {
+ if (data == null || data.length == 0) {
+ out.println("0 rows");
+ return;
+ }
+ out.println("Array of " + (data.getClass().getComponentType().getName()));
+
+ print(Arrays.asList(data));
+ }
+
+ private void resizeColumns(int[] actualColumnWidths, int maxColumnWidth, List<Integer> columns) {
+ int extraSpace = 0;
+
+ Iterator<Integer> iterator = columns.iterator();
+ while (iterator.hasNext()) {
+ int col = iterator.next();
+
+ if (actualColumnWidths[col] < maxColumnWidth) {
+ extraSpace += maxColumnWidth - actualColumnWidths[col];
+ iterator.remove();
+ }
+ }
+
+ if (extraSpace == 0) {
+ // There is no extra space with which to work so at this point we have to
+ // truncate any columns that still need more space
+ for (Integer col : columns) {
+ actualColumnWidths[col] = maxColumnWidth;
+ }
+ }
+ else if (columns.size() == 0) {
+ // If the columns list is empty then that means that there is enough available
+ // space for each column so we are done.
+ return;
+ }
+ else if (extraSpace > 0) {
+ // Since we have extra space, we will go ahead and recalculate the widths for
+ // those columns still needing space
+ int newMaxColumnWidth = (maxColumnWidth + extraSpace) / columns.size();
+ resizeColumns(actualColumnWidths, newMaxColumnWidth, columns);
+ }
+ }
+
+ public void print(String[][] data) {
+
+ if (data == null || data.length == 0) {
+ out.println("0 rows");
+ return;
+ }
+
+ int numberOfColumns = data[0].length;
+ int maxColumnWidth = width / numberOfColumns;
+ int[] actualColumnWidths = new int[numberOfColumns];
+
+ for (String[] row : data) {
+ for (int col = 0; col < row.length; ++col) {
+ if (row[col] == null) {
+ row[col] = "";
+ }
+ actualColumnWidths[col] = Math.max(actualColumnWidths[col], row[col].length());
+ }
+ }
+
+ if (headers != null) {
+ for (int col = 0; col < headers.length; ++col) {
+ actualColumnWidths[col] = Math.max(actualColumnWidths[col], headers[col].length());
+ }
+ }
+
+ List<Integer> columns = new LinkedList();
+ for (int col = 0; col < actualColumnWidths.length; ++col) {
+ columns.add(col);
+ }
+ resizeColumns(actualColumnWidths, maxColumnWidth, columns);
+
+ if (headers != null) {
+ if (CSV.equals(format)) {
+ csvWriter.writeNext(headers);
+ } else {
+ for (int i = 0; i < actualColumnWidths.length; i++) {
+ int colSize = actualColumnWidths[i];
+ printSpaced(out, headers[i], colSize);
+ if (i < actualColumnWidths.length - 1) {
+ out.print(" ");
+ }
+ }
+
+ out.print("\n");
+
+ for (int i = 1; i < width; i++) {
+ out.print("-");
+ }
+ }
+ out.print("\n");
+
+ }
+
+ if (CSV.equals(format)) {
+ for (String[] row : data) {
+ csvWriter.writeNext(row);
+ }
+ } else {
+ for (String[] row : data) {
+ for (int i = 0; i < actualColumnWidths.length; i++) {
+ int colSize = actualColumnWidths[i];
+
+ printSpaced(out, row[i], colSize);
+ if (i < actualColumnWidths.length - 1) {
+ out.print(" ");
+ }
+ }
+ out.print("\n");
+ }
+ }
+
+ out.print(data.length + " rows\n");
+ }
+
+ private void printSpaced(PrintWriter out, String data, int length) {
+ int dataLength = data.length();
+ if (dataLength > length) {
+ out.print(data.substring(0, length));
+ } else {
+ out.print(data);
+
+ for (int i = dataLength; i < length; i++) {
+ out.print(" ");
+ }
+ }
+
+ }
+
+ private void printPreSpaced(PrintWriter out, String data, int length) {
+ int dataLength = data.length();
+ if (dataLength > length) {
+ out.print(data.substring(0, length));
+ } else {
+ for (int i = dataLength; i < length; i++) {
+ out.print(" ");
+ }
+ out.print(data);
+ }
+
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public boolean isExportMode() {
+ return exportMode;
+ }
+
+ public void setExportMode(boolean exportMode) {
+ this.exportMode = exportMode;
+ }
+
+ private static String shortVersion(Object object) {
+
+ if (object instanceof ShortOutput) {
+ return ((ShortOutput) object).getShortOutput();
+ } else if (object instanceof PropertySimple) {
+ return ((PropertySimple) object).getStringValue();
+ } else if (object instanceof ResourceType) {
+ return ((ResourceType) object).getName();
+ } else if (object instanceof ResourceAvailability) {
+ return ((ResourceAvailability) object).getAvailabilityType().getName();
+ } else if (object != null && object.getClass().isArray()) {
+ return Arrays.toString((Object[]) object);
+ } else {
+ return stringValueOf(object);
+ }
+ }
+
+ private static Object invoke(Object o, Method m) throws IllegalAccessException, InvocationTargetException {
+ boolean access = m.isAccessible();
+ m.setAccessible(true);
+ try {
+ LazyLoadScenario.setShouldLoad(false);
+
+ return m.invoke(o);
+ } catch (Exception e) {
+ // That's fine
+ return null;
+ } finally {
+ LazyLoadScenario.setShouldLoad(true);
+ m.setAccessible(access);
+ }
+ }
+
+ private static String stringValueOf(Object object) {
+ try {
+ LazyLoadScenario.setShouldLoad(false);
+ return String.valueOf(object);
+ } catch (Exception e) {
+ return "null";
+ } finally {
+ LazyLoadScenario.setShouldLoad(true);
+ }
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/LazyLoadScenario.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/LazyLoadScenario.java
new file mode 100644
index 0000000..8eb0128
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/LazyLoadScenario.java
@@ -0,0 +1,44 @@
+/*
+ * 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.bindings.util;
+
+/**
+ * Set by reflective access utilities like the tabular writer to avoid
+ * remote calls behind proxy methods.
+ *
+ * @author Greg Hinkle
+ */
+public class LazyLoadScenario {
+
+ private static ThreadLocal<Boolean> shouldLoad = new ThreadLocal<Boolean>() {
+
+ protected Boolean initialValue() {
+ return true;
+ }
+ };
+
+ public static boolean isShouldLoad() {
+ return shouldLoad.get();
+ }
+
+ public static void setShouldLoad(boolean shouldLoad) {
+ LazyLoadScenario.shouldLoad.set(shouldLoad);
+ }
+
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/PackageFinder.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/PackageFinder.java
new file mode 100644
index 0000000..d48382f
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/PackageFinder.java
@@ -0,0 +1,132 @@
+/*
+ * 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.bindings.util;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.net.URL;
+
+/**
+ * @author Greg Hinkle
+ * @author Lukas Krejci
+ */
+public class PackageFinder {
+
+ private List<File> jarLocations;
+
+ public PackageFinder(List<File> jarLocations) {
+ this.jarLocations = new ArrayList<File>(jarLocations);
+ }
+
+ public List<String> findPackages(String packageRoot) throws IOException {
+ ArrayList<String> found = new ArrayList<String>();
+
+//TODO this is where the original package finder used to look for the jars.
+//update the code somewhere in the CLI client to supply this dir to this
+//new style impl.
+// String cwd = System.getProperty("user.dir");
+// File libDir = new File(cwd, "lib");
+
+
+ List<File> jars = new ArrayList<File>();
+
+ for (File loc : jarLocations) {
+ if (loc.exists()) {
+ jars.addAll(Arrays.asList(loc.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.isFile() && pathname.getName().endsWith(".jar");
+ }
+ })));
+ }
+ }
+
+ jars.addAll(loadJARsFromClassPath(packageRoot));
+
+ for (File jar : jars) {
+ findPackages(packageRoot, found, jar);
+ }
+
+ return found;
+ }
+
+ private List<File> loadJARsFromClassPath(String pkgRoot) throws IOException {
+ List<File> jarFiles = new ArrayList<File>();
+ String pkgPath = pkgRoot.replaceAll("\\.", "/");
+ Enumeration<URL> resources = getClass().getClassLoader().getResources(pkgPath);
+ URL resource = null;
+
+ while (resources.hasMoreElements()) {
+ resource = resources.nextElement();
+ if (resource.toString().startsWith("jar:file")) {
+ String jarFilePath = getJARFilePath(resource);
+ jarFiles.add(new File(jarFilePath));
+ }
+ }
+
+ return jarFiles;
+ }
+
+ private String getJARFilePath(URL resource) {
+ int startIndex = "jar:file:".length();
+ String string = resource.toString().substring(startIndex);
+ int endIndex = string.indexOf("!");
+
+ return string.substring(0, endIndex);
+ }
+
+ private void findPackages(String packageRoot, List<String> list, File jar) throws IOException {
+
+ Set<String> paths = new HashSet<String>();
+ JarFile jf = null;
+ try {
+ jf = new JarFile(jar);
+
+ String packagePath = packageRoot.replaceAll("\\.", "/");
+
+ Enumeration<JarEntry> entries = jf.entries();
+
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+
+ if (entry.getName().startsWith(packagePath)) {
+ String match = entry.getName().substring(0, entry.getName().lastIndexOf("/"));
+ paths.add(match.replaceAll("/", "\\."));
+ }
+ }
+ list.addAll(paths);
+ } finally {
+ try {
+ if (jf != null) {
+ jf.close();
+ }
+ } catch (IOException e) {
+
+ }
+ }
+ }
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ShortOutput.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ShortOutput.java
new file mode 100644
index 0000000..c7f68e3
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ShortOutput.java
@@ -0,0 +1,27 @@
+/*
+ * 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.bindings.util;
+
+/**
+ * @author Greg Hinkle
+ */
+public interface ShortOutput {
+
+ String getShortOutput();
+}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/SummaryFilter.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/SummaryFilter.java
new file mode 100644
index 0000000..871484f
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/SummaryFilter.java
@@ -0,0 +1,127 @@
+/*
+ * 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.bindings.util;
+
+import org.rhq.core.domain.util.Summary;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.IndexedPropertyDescriptor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SummaryFilter {
+
+
+
+ public PropertyDescriptor[] getPropertyDescriptors(Object object, boolean exportMode) throws IntrospectionException {
+
+ BeanInfo info = Introspector.getBeanInfo(object.getClass(), object.getClass().getSuperclass());
+
+ final Map<PropertyDescriptor, Integer> indexes = new HashMap<PropertyDescriptor, Integer>();
+
+
+
+ for (PropertyDescriptor property : info.getPropertyDescriptors()) {
+ boolean add = false;
+ int index = 100;
+ try {
+ Field field = getField(property);
+
+ if (field.isAnnotationPresent(Summary.class)) {
+ add = true;
+ index = field.getAnnotation(Summary.class).index();
+ } else if (property.getReadMethod() != null && property.getReadMethod().isAnnotationPresent(Summary.class)) {
+ add = true;
+ index = property.getReadMethod().getAnnotation(Summary.class).index();
+ }
+
+ } catch (NoSuchFieldException e) {
+ if (property.getReadMethod() != null && property.getReadMethod().isAnnotationPresent(Summary.class)) {
+ add = true;
+ index = property.getReadMethod().getAnnotation(Summary.class).index();
+ }
+ }
+ if (add || exportMode) {
+ indexes.put(property, index);
+ }
+ }
+
+ if (indexes.isEmpty()) {
+ for (PropertyDescriptor property : info.getPropertyDescriptors()) {
+ indexes.put(property, 0);
+ }
+ }
+
+
+ PropertyDescriptor[] descriptors;
+ descriptors = indexes.keySet().toArray(new PropertyDescriptor[indexes.size()]);
+ Arrays.sort(descriptors, new Comparator<PropertyDescriptor>() {
+ public int compare(PropertyDescriptor o1, PropertyDescriptor o2) {
+ int i = indexes.get(o1).compareTo(indexes.get(o2));
+ if (i == 0) {
+ i = o1.getName().compareTo(o2.getName());
+ }
+ return i;
+ }
+ });
+
+ return descriptors;
+ }
+
+
+ private Field getField(PropertyDescriptor property) throws NoSuchFieldException {
+ String propertyName = property.getName();
+ Class<?> declaringClass = getDeclaringClass(property);
+
+ return declaringClass.getDeclaredField(propertyName);
+ }
+
+ private Class<?> getDeclaringClass(PropertyDescriptor property) {
+ Method method = null;
+
+ if (property instanceof IndexedPropertyDescriptor) {
+ method = ((IndexedPropertyDescriptor)property).getIndexedReadMethod();
+ if (method == null) {
+ method = ((IndexedPropertyDescriptor)property).getIndexedWriteMethod();
+ }
+ } else {
+ method = property.getReadMethod();
+
+ if (method == null) {
+ method = property.getWriteMethod();
+ }
+ }
+
+ return method.getDeclaringClass();
+
+ }
+
+
+}
diff --git a/modules/enterprise/binding/src/test/java/org/rhq/bindings/TabularWriterTest.java b/modules/enterprise/binding/src/test/java/org/rhq/bindings/TabularWriterTest.java
new file mode 100644
index 0000000..a80d2c2
--- /dev/null
+++ b/modules/enterprise/binding/src/test/java/org/rhq/bindings/TabularWriterTest.java
@@ -0,0 +1,397 @@
+/*
+ * 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.bindings;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+import org.apache.commons.lang.StringUtils;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.bindings.output.TabularWriter;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.shared.ResourceBuilder;
+
+import static org.testng.Assert.*;
+
+public class TabularWriterTest {
+
+ StringWriter stringWriter;
+
+ TabularWriter writer;
+
+ @BeforeMethod
+ public void initFixture() {
+ stringWriter = new StringWriter();
+ writer = new TabularWriter(new PrintWriter(stringWriter));
+ }
+
+ @Test
+ public void aByteShouldPrintUnchanged() {
+ byte value = 1;
+
+ writer.print(value);
+
+ String expected = "1\n";
+ String actual = stringWriter.toString();
+
+ assertEquals(actual, expected, "A byte or Byte should have its value printed as a String");
+ }
+
+ @Test
+ public void anIntegerShouldPrintUnchanged() {
+ int value = 1;
+
+ writer.print(value);
+
+ String expected = "1\n";
+ String actual = stringWriter.toString();
+
+ assertEquals(actual, expected, "An int or Integer should have its value printed as a String");
+ }
+
+ @Test
+ public void theSimpleClassNameShouldPrintFirstForEntity() {
+ User user = new User(1, "rhqadmin", "rhqadmin");
+
+ writer.print(user);
+
+ assertNumberOfLinesPrintedIs(4);
+ assertLineEquals(0, user.getClass().getSimpleName() + ":", "The simple class name should be the first line printed");
+ }
+
+ @Test
+ public void theIdShouldBeTheFirstPropertyPrintedForEntity() {
+ User user = new User(1, "rhqadmin", "rhqadmin");
+
+ writer.print(user);
+
+ int paddingSize = "username".length();
+ int idLineNumber = 1;
+ String expected = "\t" + StringUtils.leftPad("id", paddingSize) + ": " + user.getId();
+
+ assertLineEquals(idLineNumber, expected, "The id property should be the 2nd line printed");
+ }
+
+ @Test
+ public void otherPropertiesShouldPrintAfterIdForEntity() {
+ User user = new User(1, "rhqadmin", "rhqadmin");
+
+ writer.print(user);
+
+ int passwordLineNumber = 2;
+ String expectedPasswordLine = "\tpassword: " + user.getPassword();
+
+ assertLineEquals(passwordLineNumber, expectedPasswordLine, "The password property should be the 3rd line printed");
+
+ int usernameLineNumber = 3;
+ String expectedUsernameLine = "\tusername: " + user.getUsername();
+
+ assertLineEquals(usernameLineNumber, expectedUsernameLine, "The username property should be the 4th line printed");
+ }
+
+ @Test
+ public void oneToOneAssociationShouldPrintForAnEntity() {
+ User mgr = new User(1, "rhqadmin", "rhqadmin");
+ Department department = new Department(1, mgr);
+
+ writer.print(department);
+
+ int lineNumber = 2;
+ String expectedLine = "\tmanager: " + mgr;
+
+ assertLineEquals(lineNumber, expectedLine, "The manager property should be the 3rd line printed");
+ }
+
+ @Test(enabled = false) // TODO revisit
+ public void oneToManyAssociationShouldPrintForEntity() {
+ User employee = new User(1, "rhq", "rhq");
+
+ Company company = new Company(1);
+ company.addEmployee(employee);
+
+ writer.print(company);
+
+ int lineNumber = 2;
+ String expectedLine = "\temployees: " + company.getEmployees();
+
+ assertLineEquals(lineNumber, expectedLine, "The employees property should be the 2nd line printed and the " +
+ "toString() value of the collection should be displayed.");
+ }
+
+ @Test
+ public void idShouldBeFirstResourcePropertyPrinted() {
+ Resource resource = createResource();
+
+ writer.print(resource);
+
+ assertLineEquals(
+ 1,
+ "\t" + padResourceField("id") + ": " + resource.getId(),
+ "Expected Resource.id to be the first property printed."
+ );
+ }
+
+ @Test
+ public void nameShouldBeSecondResourcePropertyPrinted() {
+ Resource resource = createResource();
+
+ writer.print(resource);
+
+ assertLineEquals(
+ 2,
+ "\t" + padResourceField("name") + ": " + resource.getName(),
+ "Expected Resource.name to be second property printed"
+ );
+ }
+
+ @Test
+ public void versionShouldBeThirdResourcePropertyPrinted() {
+ Resource resource = createResource();
+
+ writer.print(resource);
+
+ assertLineEquals(
+ 3,
+ "\t" + padResourceField("version") + ": " + resource.getVersion(),
+ "Expected Resource.version to be third property printed"
+ );
+ }
+
+ @Test
+ public void currentAvailabilityShouldBeFourthResourcePropertyPrinted() {
+ Resource resource = createResource();
+
+ writer.print(resource);
+
+ assertLineEquals(
+ 4,
+ "\t" + padResourceField("currentAvailability") + ": " + resource.getCurrentAvailability().getAvailabilityType(),
+ "Expected short version of Resource.currentAvailability to be fourth property printed"
+ );
+ }
+
+ @Test
+ public void handleNullCurrentAvailabilityForResource() {
+ Resource resource = createUncommittedResource();
+
+ writer.print(resource);
+
+ assertLineEquals(
+ 4,
+ "\t" + padResourceField("currentAvailability") + ": ",
+ "Expected to see empty string for Resource.currentAvailability when property is null"
+ );
+ }
+
+ @Test
+ public void resourceTypeShouldBeLastResourcePropertyPrinted() {
+ Resource resource = createResource();
+
+ writer.print(resource);
+
+ assertLineEquals(
+ 5,
+ "\t" + padResourceField("resourceType") + ": " + resource.getResourceType().getName(),
+ "Expected short version of Resource.resourceType to be the fifth property printed"
+ );
+ }
+
+ private Resource createResource() {
+ return new ResourceBuilder().createServer()
+ .usingDefaultResourceType()
+ .withId(111)
+ .withName("test-server")
+ .withUuid("12345")
+ .withVersion("1.0")
+ .inInventory()
+ .withCurrentAvailability(AvailabilityType.UP)
+ .build();
+ }
+
+ private Resource createUncommittedResource() {
+ return new ResourceBuilder().createServer()
+ .usingDefaultResourceType()
+ .withId(111)
+ .withName("test-server")
+ .withUuid("12345")
+ .withVersion("1.0")
+ .notInInventory()
+ .build();
+ }
+
+ @Test
+ public void printCollectionOfUncommittedResource() {
+ Resource parent = new ResourceBuilder().createServer()
+ .usingDefaultResourceType()
+ .withName("test-server")
+ .withUuid("12345")
+ .withVersion("1.0")
+ .inInventory()
+ .with(2).randomChildServices()
+// .notInInventory()
+// .included()
+ .build();
+
+ writer.print(parent.getChildResources());
+ }
+
+ void assertNumberOfLinesPrintedIs(int expectedNumberOfLines) {
+ String lines[] = getLines();
+ assertEquals(lines.length, expectedNumberOfLines, "The actual lines printed were\n[\n" +
+ stringWriter.toString() + "\n]");
+ }
+
+ void assertLineEquals(int lineNumber, String expectedLine, String msg) {
+ String actualLine = getLines()[lineNumber];
+
+ assertEquals(actualLine, expectedLine, msg + " -- The actual output was \n[\n" + stringWriter + "\n].");
+ }
+
+ String[] getLines() {
+ return stringWriter.toString().split("\n");
+ }
+
+ String padResourceField(String field) {
+ return StringUtils.leftPad(field, "currentAvailability".length());
+ }
+
+ @Entity
+ static class User {
+ @Id
+ private int id;
+
+ private String username;
+
+ private String password;
+
+ public User(int id, String username, String password) {
+ this.id = id;
+ this.username = username;
+ this.password = password;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ @Override
+ public String toString() {
+ return User.class.getSimpleName() + "[id=" + id + ", username=" + username + ", password=" + password + "]";
+ }
+ }
+
+ @Entity
+ static class Department {
+ @Id
+ private int id;
+
+ @OneToOne
+ private User manager;
+
+ public Department(int id, User manager) {
+ this.id = id;
+ this.manager = manager;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public User getManager() {
+ return manager;
+ }
+
+ public void setManager(User manager) {
+ this.manager = manager;
+ }
+ }
+
+ @Entity
+ static class Company {
+ @Id
+ private int id;
+
+ @OneToMany
+ private List<User> employees = new ArrayList<User>();
+
+ public Company(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public List<User> getEmployees() {
+ return employees;
+ }
+
+ public void setEmployees(List<User> employees) {
+ this.employees = employees;
+ }
+
+ public void addEmployee(User employee) {
+ employees.add(employee);
+ }
+ }
+
+}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/SummaryFilter.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/SummaryFilter.java
deleted file mode 100644
index bc4151b..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/SummaryFilter.java
+++ /dev/null
@@ -1,127 +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.enterprise.client;
-
-import org.rhq.core.domain.util.Summary;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.beans.IndexedPropertyDescriptor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-
-public class SummaryFilter {
-
-
-
- public PropertyDescriptor[] getPropertyDescriptors(Object object, boolean exportMode) throws IntrospectionException {
-
- BeanInfo info = Introspector.getBeanInfo(object.getClass(), object.getClass().getSuperclass());
-
- final Map<PropertyDescriptor, Integer> indexes = new HashMap<PropertyDescriptor, Integer>();
-
-
-
- for (PropertyDescriptor property : info.getPropertyDescriptors()) {
- boolean add = false;
- int index = 100;
- try {
- Field field = getField(property);
-
- if (field.isAnnotationPresent(Summary.class)) {
- add = true;
- index = field.getAnnotation(Summary.class).index();
- } else if (property.getReadMethod() != null && property.getReadMethod().isAnnotationPresent(Summary.class)) {
- add = true;
- index = property.getReadMethod().getAnnotation(Summary.class).index();
- }
-
- } catch (NoSuchFieldException e) {
- if (property.getReadMethod() != null && property.getReadMethod().isAnnotationPresent(Summary.class)) {
- add = true;
- index = property.getReadMethod().getAnnotation(Summary.class).index();
- }
- }
- if (add || exportMode) {
- indexes.put(property, index);
- }
- }
-
- if (indexes.isEmpty()) {
- for (PropertyDescriptor property : info.getPropertyDescriptors()) {
- indexes.put(property, 0);
- }
- }
-
-
- PropertyDescriptor[] descriptors;
- descriptors = indexes.keySet().toArray(new PropertyDescriptor[indexes.size()]);
- Arrays.sort(descriptors, new Comparator<PropertyDescriptor>() {
- public int compare(PropertyDescriptor o1, PropertyDescriptor o2) {
- int i = indexes.get(o1).compareTo(indexes.get(o2));
- if (i == 0) {
- i = o1.getName().compareTo(o2.getName());
- }
- return i;
- }
- });
-
- return descriptors;
- }
-
-
- private Field getField(PropertyDescriptor property) throws NoSuchFieldException {
- String propertyName = property.getName();
- Class<?> declaringClass = getDeclaringClass(property);
-
- return declaringClass.getDeclaredField(propertyName);
- }
-
- private Class<?> getDeclaringClass(PropertyDescriptor property) {
- Method method = null;
-
- if (property instanceof IndexedPropertyDescriptor) {
- method = ((IndexedPropertyDescriptor)property).getIndexedReadMethod();
- if (method == null) {
- method = ((IndexedPropertyDescriptor)property).getIndexedWriteMethod();
- }
- } else {
- method = property.getReadMethod();
-
- if (method == null) {
- method = property.getWriteMethod();
- }
- }
-
- return method.getDeclaringClass();
-
- }
-
-
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/TabularWriter.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/TabularWriter.java
deleted file mode 100644
index 4b63c4e..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/TabularWriter.java
+++ /dev/null
@@ -1,708 +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.enterprise.client;
-
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import au.com.bytecode.opencsv.CSVWriter;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.measurement.ResourceAvailability;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.enterprise.client.utility.LazyLoadScenario;
-import org.rhq.enterprise.client.utility.ShortOutput;
-
-/**
- * @author Greg Hinkle
- */
-public class TabularWriter {
-
- private static final String CSV = "csv";
-
- String[] headers;
- int[] maxColumnLength;
- boolean[] noShrinkColumns;
- int width = 160;
- PrintWriter out;
- private String format = "raw";
- private CSVWriter csvWriter;
- private SummaryFilter summaryFilter = new SummaryFilter();
- boolean exportMode;
-
- static Set<String> IGNORED_PROPS = new HashSet<String>();
-
- static {
- IGNORED_PROPS.add("mtime");
- IGNORED_PROPS.add("ctime");
- IGNORED_PROPS.add("itime");
- IGNORED_PROPS.add("uuid");
- IGNORED_PROPS.add("parentResource");
- }
-
- static Set<Class> SIMPLE_TYPES = new HashSet<Class>();
-
- static {
- SIMPLE_TYPES.add(Byte.class);
- SIMPLE_TYPES.add(Byte.TYPE);
- SIMPLE_TYPES.add(Short.class);
- SIMPLE_TYPES.add(Short.TYPE);
- SIMPLE_TYPES.add(Integer.class);
- SIMPLE_TYPES.add(Integer.TYPE);
- SIMPLE_TYPES.add(Long.class);
- SIMPLE_TYPES.add(Long.TYPE);
- SIMPLE_TYPES.add(Float.class);
- SIMPLE_TYPES.add(Float.TYPE);
- SIMPLE_TYPES.add(Double.class);
- SIMPLE_TYPES.add(Double.TYPE);
- SIMPLE_TYPES.add(Boolean.class);
- SIMPLE_TYPES.add(Boolean.TYPE);
- SIMPLE_TYPES.add(String.class);
- }
-
- public TabularWriter(PrintWriter out, String... headers) {
- this.headers = headers;
- this.out = out;
- }
-
- public TabularWriter(PrintWriter out) {
- this.out = out;
- }
-
- public TabularWriter(PrintWriter out, String format) {
- this.out = out;
- this.format = format;
-
- if (CSV.equals(format)) {
- csvWriter = new CSVWriter(out);
- }
- }
-
- public void print(Object object) {
-
- if (object instanceof Map) {
- print((Map) object);
- return;
- }
-
- if (object instanceof Collection) {
- print((Collection) object);
- return;
- }
-
- if (object instanceof Configuration) {
- print((Configuration) object);
- return;
- }
-
- if (object != null && object.getClass().isArray()) {
- print((Object[]) object);
- return;
- }
-
- try {
-
- if (SIMPLE_TYPES.contains(object.getClass())) {
- this.out.println(String.valueOf(object));
- return;
- }
-
- out.println(object.getClass().getSimpleName() + ":");
- Map<String, PropertyInfo> properties = new LinkedHashMap<String, PropertyInfo>();
- int maxLength = 0;
-
- for (PropertyDescriptor pd : summaryFilter.getPropertyDescriptors(object, exportMode)) {
- Method m = pd.getReadMethod();
- Object val = null;
- if (m != null) {
- val = invoke(object, m);
- }
-
- if (val == null) {
- maxLength = Math.max(maxLength, pd.getName().length());
- properties.put(pd.getName(), new PropertyInfo(pd.getName(), null));
- } else {
- try {
- String str = shortVersion(val);
- maxLength = Math.max(maxLength, pd.getName().length());
- properties.put(pd.getName(), new PropertyInfo(str, pd.getPropertyType()));
- } catch (Exception e) {
- }
- }
- }
-
- for (String key : properties.keySet()) {
- printProperty(key, properties.get(key), maxLength);
- }
-
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (IntrospectionException e) {
- e.printStackTrace();
- }
-
- }
-
- private static class PropertyInfo {
- String value;
-
- Class<?> type;
-
- PropertyInfo(String propertyValue, Class<?> propertyType) {
- value = propertyValue;
- type = propertyType;
- }
- }
-
- private void printProperty(String name, PropertyInfo propertyInfo, int maxLength) {
- out.print("\t");
- printPreSpaced(out, name, maxLength);
- out.print(": ");
-
- if (propertyInfo.type == null) {
- out.println("");
- } else if (exportMode || !String.class.equals(propertyInfo.type)) {
- out.println(propertyInfo.value);
- } else {
- out.println(abbreviate(propertyInfo.value, width - 12 - maxLength));
- }
- }
-
- // This method is taken verbatim from the Commons Lang project in the org.apache.commons.lang.StringUtils class
- // TODO Should this method go into one our StringUtil classes?
- private String abbreviate(String string, int maxWidth) {
- int offset = 0;
-
- if (string == null) {
- return null;
- }
-
- if (maxWidth < 4) {
- throw new IllegalArgumentException("Minimum abbreviation width is 4");
- }
-
- if (string.length() <= maxWidth) {
- return string;
- }
-
- if (offset > string.length()) {
- offset = string.length();
- }
-
- if ((string.length() - offset) < (maxWidth - 3)) {
- offset = string.length() - (maxWidth - 3);
- }
-
- if (offset <= 4) {
- return string.substring(0, maxWidth - 3) + "...";
- }
-
- if (maxWidth < 7) {
- throw new IllegalArgumentException("Minimum abbreviation width with offset is 7");
- }
-
- if ((offset + (maxWidth - 3)) < string.length()) {
- return "..." + abbreviate(string.substring(offset), maxWidth - 3);
- }
-
- return "..." + string.substring(string.length() - (maxWidth - 3));
- }
-
- public void print(Map map) {
-
- String[][] data = new String[map.size()][];
- int i = 0;
- for (Object key : map.keySet()) {
- Object value = map.get(key);
- data[i] = new String[2];
- data[i][0] = shortVersion(key);
- data[i][1] = shortVersion(value);
- i++;
- }
- this.headers = new String[] { "Key", "Value" };
- print(data);
- }
-
- public void print(Collection list) {
- // List of arbitrary objects
- if (list == null || list.size() == 0)
- out.println("no data");
- else if (list.size() == 1 && !CSV.equals(format)) {
- out.println("one row");
-
- print(list.iterator().next());
- } else {
-
- String[][] data = null;
-
- if (!allOneType(list)) {
- printStrings(list);
- } else {
-
- Object firstObject = list.iterator().next();
- try {
-
- if (firstObject instanceof String) {
- headers = new String[] { "Value" };
- data = new String[list.size()][1];
- int i = 0;
- for (Object object : list) {
- data[i++][0] = (String) object;
- }
-
- } else {
-
- if (consistentMaps(list)) {
- // results printed
-
- } else {
-
- int i = 0;
-
- List<PropertyDescriptor> pdList = new ArrayList<PropertyDescriptor>();
- for (PropertyDescriptor pd : summaryFilter.getPropertyDescriptors(firstObject, exportMode)) {
- try {
- boolean allNull = true;
- for (Object row : list) {
- Method m = pd.getReadMethod();
- Object val = null;
- if (m != null) {
- val = invoke(row, pd.getReadMethod());
- }
- if ((val != null && !(val instanceof Collection))
- || ((val != null && (val instanceof Collection) && !((Collection) val)
- .isEmpty())))
- allNull = false;
- }
- if (!allNull && !IGNORED_PROPS.contains(pd.getName())) {
- pdList.add(pd);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- headers = new String[pdList.size()];
- data = new String[list.size()][pdList.size()];
-
- for (PropertyDescriptor pd : pdList) {
- headers[i++] = pd.getName();
- }
- i = 0;
- for (Object row : list) {
- int j = 0;
- for (PropertyDescriptor pd : pdList) {
-
- Object val = "?";
- val = invoke(row, pd.getReadMethod());
- if (val == null) {
- data[i][j++] = "";
- } else {
- data[i][j++] = shortVersion(val);
- }
- }
- i++;
- }
-
- this.print(data);
-
- }
- }
- } catch (Exception e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } finally {
- headers = null;
- }
- }
-
- }
-
- }
-
- private boolean consistentMaps(Collection list) {
- List<String> keys = null;
- String[][] data = new String[list.size()][];
- int i = 0;
- for (Object row : list) {
- if (!(row instanceof Map) && !(row instanceof PropertyMap)) {
- return false;
- }
- if (keys == null) {
- keys = new ArrayList<String>();
-
- //insert check for PropertyMap as they are not instances of Map
- if (row instanceof PropertyMap) {
- //TODO: spinder 1/15/10. PropertyMap is arbitrarily complex. Only serialize simple props?
- for (Object key : ((PropertyMap) row).getMap().keySet()) {
- String headerKey = stringValueOf(key);
- keys.add(headerKey);
- }
- } else {//else row is a Map
- for (Object key : ((Map) row).keySet()) {
- String headerKey = stringValueOf(key);
- keys.add(headerKey);
- }
- }
- //conditionally put order on the headers to mimic core gui listing style/order
- //Ex. Pid Name Size User Time Kernel Time
- if (keys.contains("pid")) {
- String[] processAttribute = { "pid", "name", "size", "userTime", "kernelTime" };
- List<String> newKeyOrder = new ArrayList<String>();
- for (String attribute : processAttribute) {
- newKeyOrder.add(attribute);
- keys.remove(attribute);
- }
- //postpend remaining keys if any to the newHeader list
- for (String key : keys) {
- newKeyOrder.add(key);
- }
- keys = newKeyOrder;
- }
- }
-
- data[i] = new String[keys.size()];
- if (row instanceof PropertyMap) {
- for (String key : keys) {
- if (!keys.contains(stringValueOf(key))) {
- return false;
- }
- data[i][keys.lastIndexOf(stringValueOf(key))] = shortVersion(((PropertyMap) row).get(String
- .valueOf(key)));
- }
- } else {//else row is a Map
- for (Object key : ((Map) row).keySet()) {
- if (!keys.contains(stringValueOf(key))) {
- return false;
- }
- data[i][keys.lastIndexOf(stringValueOf(key))] = shortVersion(((Map) row).get(key));
- }
- }
- i++;
- }
-
- if (keys != null) {
- headers = keys.toArray(new String[keys.size()]);
- print(data);
- return true;
- } else {
- return false;
- }
-
- }
-
- public void print(Configuration config) {
- out.println("Configuration [" + config.getId() + "] - " + config.getNotes());
- for (PropertySimple p : config.getSimpleProperties().values()) {
- print(p, 1);
- }
- for (PropertyList p : config.getListProperties().values()) {
- print(p, 1);
- }
- for (PropertyMap p : config.getMapProperties().values()) {
- print(p, 1);
- }
-
- }
-
- public void print(PropertySimple p, int depth) {
- out.println(indent(depth) + p.getName() + " = " + p.getStringValue());
- }
-
- public void print(PropertyList p, int depth) {
- out.println(indent(depth) + p.getName() + " [" + p.getList().size() + "] {");
- if (p.getList().get(0) instanceof PropertyMap) {
- consistentMaps(p.getList());
-
- } else {
- for (Property entry : p.getList()) {
- if (entry instanceof PropertySimple) {
- print((PropertySimple) entry, depth + 1);
- } else if (entry instanceof PropertyMap) {
- print((PropertyMap) entry, depth + 1);
- }
- }
- }
-
- out.println(indent(depth) + "}");
- }
-
- public void print(PropertyMap p, int depth) {
- out.println(indent(depth) + p.getName() + " [" + p.getMap().size() + "] {");
- for (String key : p.getMap().keySet()) {
- Property entry = p.getMap().get(key);
- if (entry instanceof PropertySimple) {
- print((PropertySimple) entry, depth + 1);
- } else if (entry instanceof PropertyMap) {
- print((PropertyMap) entry, depth + 1);
- }
- }
- out.println(indent(depth) + "}");
- }
-
- private String indent(int x) {
- StringBuilder buf = new StringBuilder();
- for (int i = 0; i < x; i++) {
- buf.append(" ");
- }
- return buf.toString();
- }
-
- private void printStrings(Collection list) {
- for (Object object : list) {
- out.println(stringValueOf(object));
- }
- }
-
- private boolean allOneType(Collection list) {
- Class lastClass = null;
- for (Object object : list) {
- if (lastClass == null) {
- lastClass = object.getClass();
- } else if (!object.getClass().equals(lastClass)) {
- return false;
- }
- }
- return true;
- }
-
- public void print(Object[] data) {
- if (data == null || data.length == 0) {
- out.println("0 rows");
- return;
- }
- out.println("Array of " + (data.getClass().getComponentType().getName()));
-
- print(Arrays.asList(data));
- }
-
- private void resizeColumns(int[] actualColumnWidths, int maxColumnWidth, List<Integer> columns) {
- int extraSpace = 0;
-
- Iterator<Integer> iterator = columns.iterator();
- while (iterator.hasNext()) {
- int col = iterator.next();
-
- if (actualColumnWidths[col] < maxColumnWidth) {
- extraSpace += maxColumnWidth - actualColumnWidths[col];
- iterator.remove();
- }
- }
-
- if (extraSpace == 0) {
- // There is no extra space with which to work so at this point we have to
- // truncate any columns that still need more space
- for (Integer col : columns) {
- actualColumnWidths[col] = maxColumnWidth;
- }
- }
- else if (columns.size() == 0) {
- // If the columns list is empty then that means that there is enough available
- // space for each column so we are done.
- return;
- }
- else if (extraSpace > 0) {
- // Since we have extra space, we will go ahead and recalculate the widths for
- // those columns still needing space
- int newMaxColumnWidth = (maxColumnWidth + extraSpace) / columns.size();
- resizeColumns(actualColumnWidths, newMaxColumnWidth, columns);
- }
- }
-
- public void print(String[][] data) {
-
- if (data == null || data.length == 0) {
- out.println("0 rows");
- return;
- }
-
- int numberOfColumns = data[0].length;
- int maxColumnWidth = width / numberOfColumns;
- int[] actualColumnWidths = new int[numberOfColumns];
-
- for (String[] row : data) {
- for (int col = 0; col < row.length; ++col) {
- if (row[col] == null) {
- row[col] = "";
- }
- actualColumnWidths[col] = Math.max(actualColumnWidths[col], row[col].length());
- }
- }
-
- if (headers != null) {
- for (int col = 0; col < headers.length; ++col) {
- actualColumnWidths[col] = Math.max(actualColumnWidths[col], headers[col].length());
- }
- }
-
- List<Integer> columns = new LinkedList();
- for (int col = 0; col < actualColumnWidths.length; ++col) {
- columns.add(col);
- }
- resizeColumns(actualColumnWidths, maxColumnWidth, columns);
-
- if (headers != null) {
- if (CSV.equals(format)) {
- csvWriter.writeNext(headers);
- } else {
- for (int i = 0; i < actualColumnWidths.length; i++) {
- int colSize = actualColumnWidths[i];
- printSpaced(out, headers[i], colSize);
- if (i < actualColumnWidths.length - 1) {
- out.print(" ");
- }
- }
-
- out.print("\n");
-
- for (int i = 1; i < width; i++) {
- out.print("-");
- }
- }
- out.print("\n");
-
- }
-
- if (CSV.equals(format)) {
- for (String[] row : data) {
- csvWriter.writeNext(row);
- }
- } else {
- for (String[] row : data) {
- for (int i = 0; i < actualColumnWidths.length; i++) {
- int colSize = actualColumnWidths[i];
-
- printSpaced(out, row[i], colSize);
- if (i < actualColumnWidths.length - 1) {
- out.print(" ");
- }
- }
- out.print("\n");
- }
- }
-
- out.print(data.length + " rows\n");
- }
-
- private void printSpaced(PrintWriter out, String data, int length) {
- int dataLength = data.length();
- if (dataLength > length) {
- out.print(data.substring(0, length));
- } else {
- out.print(data);
-
- for (int i = dataLength; i < length; i++) {
- out.print(" ");
- }
- }
-
- }
-
- private void printPreSpaced(PrintWriter out, String data, int length) {
- int dataLength = data.length();
- if (dataLength > length) {
- out.print(data.substring(0, length));
- } else {
- for (int i = dataLength; i < length; i++) {
- out.print(" ");
- }
- out.print(data);
- }
-
- }
-
- public int getWidth() {
- return width;
- }
-
- public void setWidth(int width) {
- this.width = width;
- }
-
- public boolean isExportMode() {
- return exportMode;
- }
-
- public void setExportMode(boolean exportMode) {
- this.exportMode = exportMode;
- }
-
- private static String shortVersion(Object object) {
-
- if (object instanceof ShortOutput) {
- return ((ShortOutput) object).getShortOutput();
- } else if (object instanceof PropertySimple) {
- return ((PropertySimple) object).getStringValue();
- } else if (object instanceof ResourceType) {
- return ((ResourceType) object).getName();
- } else if (object instanceof ResourceAvailability) {
- return ((ResourceAvailability) object).getAvailabilityType().getName();
- } else if (object != null && object.getClass().isArray()) {
- return Arrays.toString((Object[]) object);
- } else {
- return stringValueOf(object);
- }
- }
-
- private static Object invoke(Object o, Method m) throws IllegalAccessException, InvocationTargetException {
- boolean access = m.isAccessible();
- m.setAccessible(true);
- try {
- LazyLoadScenario.setShouldLoad(false);
-
- return m.invoke(o);
- } catch (Exception e) {
- // That's fine
- return null;
- } finally {
- LazyLoadScenario.setShouldLoad(true);
- m.setAccessible(access);
- }
- }
-
- private static String stringValueOf(Object object) {
- try {
- LazyLoadScenario.setShouldLoad(false);
- return String.valueOf(object);
- } catch (Exception e) {
- return "null";
- } finally {
- LazyLoadScenario.setShouldLoad(true);
- }
- }
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/HelpCommand.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/HelpCommand.java
index ab3023b..abddad4 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/HelpCommand.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/HelpCommand.java
@@ -32,8 +32,8 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import org.rhq.bindings.output.TabularWriter;
import org.rhq.enterprise.client.ClientMain;
-import org.rhq.enterprise.client.TabularWriter;
import org.rhq.enterprise.client.Controller;
import org.rhq.enterprise.client.utility.ReflectionUtility;
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
index 4aed6bd..ca3a185 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
@@ -20,12 +20,14 @@ package org.rhq.enterprise.client.commands;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.bindings.export.Exporter;
+import org.rhq.bindings.output.TabularWriter;
+import org.rhq.bindings.util.PackageFinder;
import org.rhq.core.domain.util.PageControl;
import org.rhq.enterprise.client.ClientMain;
import org.rhq.enterprise.client.Controller;
-import org.rhq.enterprise.client.export.Exporter;
import org.rhq.enterprise.client.RemoteClient;
-import org.rhq.enterprise.client.TabularWriter;
import org.rhq.enterprise.client.proxy.ResourceClientFactory;
import org.rhq.enterprise.client.proxy.ConfigurationEditor;
import org.rhq.enterprise.client.script.CLIScriptException;
@@ -34,7 +36,6 @@ import org.rhq.enterprise.client.script.CommandLineParseException;
import org.rhq.enterprise.client.script.NamedScriptArg;
import org.rhq.enterprise.client.script.ScriptArg;
import org.rhq.enterprise.client.script.ScriptCmdLine;
-import org.rhq.enterprise.client.utility.PackageFinder;
import org.rhq.enterprise.client.utility.ScriptAssert;
import org.rhq.enterprise.client.utility.ScriptUtil;
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/export/ExportException.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/export/ExportException.java
deleted file mode 100644
index 69f4fea..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/export/ExportException.java
+++ /dev/null
@@ -1,43 +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.enterprise.client.export;
-
-public class ExportException extends RuntimeException {
-
- public ExportException() {
- super();
- }
-
- public ExportException(String message) {
- super(message);
- }
-
- public ExportException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ExportException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/export/Exporter.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/export/Exporter.java
deleted file mode 100644
index 208a1f7..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/export/Exporter.java
+++ /dev/null
@@ -1,86 +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.enterprise.client.export;
-
-import org.rhq.enterprise.client.TabularWriter;
-
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-public class Exporter {
-
- private String format;
-
- private String file;
-
- private TabularWriter tabularWriter;
-
- private FileWriter fileWriter;
-
- public void setTarget(String format, String file) {
- try {
- this.format = format;
- this.file = file;
- fileWriter = new FileWriter(this.file);
- tabularWriter = new TabularWriter(new PrintWriter(fileWriter), format);
- tabularWriter.setExportMode(true);
- } catch (IOException e) {
- throw new ExportException(e);
- }
- }
-
- public int getPageWidth() {
- return tabularWriter.getWidth();
- }
-
- public void setPageWidth(int width) {
- tabularWriter.setWidth(width);
- }
-
- public void write(Object object) {
- try {
- tabularWriter.print(object);
- fileWriter.flush();
- } catch (IOException e) {
- throw new ExportException(e);
- }
- }
-
- public String getFormat() {
- return format;
- }
-
- public void setFormat(String format) {
- this.format = format;
- }
-
- public String getFile() {
- return file;
- }
-
- public void setFile(String file) {
- this.file = file;
- }
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ConfigurationEditor.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ConfigurationEditor.java
index 32fe93d..2fd6ee4 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ConfigurationEditor.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ConfigurationEditor.java
@@ -19,7 +19,7 @@
package org.rhq.enterprise.client.proxy;
import org.rhq.enterprise.client.ClientMain;
-import org.rhq.enterprise.client.TabularWriter;
+import org.rhq.bindings.output.TabularWriter;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java
index 6d56a76..5b21a94 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java
@@ -31,6 +31,8 @@ import java.io.IOException;
import javassist.util.proxy.MethodHandler;
+import org.rhq.bindings.util.LazyLoadScenario;
+import org.rhq.bindings.util.ShortOutput;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
@@ -59,8 +61,6 @@ import org.rhq.core.domain.util.Summary;
import org.rhq.core.server.MeasurementConverter;
import org.rhq.enterprise.client.RemoteClient;
import org.rhq.enterprise.client.ClientMain;
-import org.rhq.enterprise.client.utility.LazyLoadScenario;
-import org.rhq.enterprise.client.utility.ShortOutput;
import org.rhq.enterprise.client.utility.ConfigurationClassBuilder;
import org.rhq.enterprise.client.utility.ScriptUtil;
import org.rhq.enterprise.server.content.ContentManagerRemote;
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/LazyLoadScenario.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/LazyLoadScenario.java
deleted file mode 100644
index c6a9111..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/LazyLoadScenario.java
+++ /dev/null
@@ -1,44 +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.enterprise.client.utility;
-
-/**
- * Set by reflective access utilities like the tabular writer to avoid
- * remote calls behind proxy methods.
- *
- * @author Greg Hinkle
- */
-public class LazyLoadScenario {
-
- private static ThreadLocal<Boolean> shouldLoad = new ThreadLocal<Boolean>() {
-
- protected Boolean initialValue() {
- return true;
- }
- };
-
- public static boolean isShouldLoad() {
- return shouldLoad.get();
- }
-
- public static void setShouldLoad(boolean shouldLoad) {
- LazyLoadScenario.shouldLoad.set(shouldLoad);
- }
-
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/PackageFinder.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/PackageFinder.java
deleted file mode 100644
index 914b10c..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/PackageFinder.java
+++ /dev/null
@@ -1,140 +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.enterprise.client.utility;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.net.URL;
-
-/**
- * @author Greg Hinkle
- */
-public class PackageFinder {
-
-
-
- public List<String> findPackages(String packageRoot) {
- ArrayList<String> found = new ArrayList<String>();
-
- String cwd = System.getProperty("user.dir");
- File libDir = new File(cwd, "lib");
- File[] jars;
-
- if (libDir.exists()) {
- jars = libDir.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.isFile() && pathname.getName().endsWith(".jar");
- }
- });
- }
- else {
- jars = loadJARsFromClassPath(packageRoot);
- }
-
-
- for (File jar : jars) {
- findPackages(packageRoot, found, jar);
- }
-
- return found;
- }
-
- private File[] loadJARsFromClassPath(String pkgRoot) {
- try {
- List<File> jarFiles = new ArrayList<File>();
- String pkgPath = pkgRoot.replaceAll("\\.", "/");
- Enumeration<URL> resources = getClass().getClassLoader().getResources(pkgPath);
- URL resource = null;
-
- while (resources.hasMoreElements()) {
- resource = resources.nextElement();
- if (resource.toString().startsWith("jar:file")) {
- String jarFilePath = getJARFilePath(resource);
- jarFiles.add(new File(jarFilePath));
- }
- }
-
- return jarFiles.toArray(new File[] {});
- }
- catch (IOException e) {
- e.printStackTrace();
- return new File[] {};
- }
-
- }
-
- private String getJARFilePath(URL resource) {
- int startIndex = "jar:file:".length();
- String string = resource.toString().substring(startIndex);
- int endIndex = string.indexOf("!");
-
- return string.substring(0, endIndex);
- }
-
- private void findPackages(String packageRoot, List<String> list, File jar) {
-
- Set<String> paths = new HashSet<String>();
- JarFile jf = null;
- try {
- jf = new JarFile(jar);
-
- String packagePath = packageRoot.replaceAll("\\.", "/");
-
- Enumeration<JarEntry> entries = jf.entries();
-
- while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
-
- if (entry.getName().startsWith(packagePath)) {
- String match = entry.getName().substring(0, entry.getName().lastIndexOf("/"));
- paths.add(match.replaceAll("/", "\\."));
- }
- }
- list.addAll(paths);
-
- } catch (IOException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } finally {
- try {
- if (jf != null) {
- jf.close();
- }
- } catch (IOException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- }
-
-
-
-
-
- public static void main(String[] args) {
- new PackageFinder().findPackages("org.rhq.core.domain");
- }
-
-}
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ShortOutput.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ShortOutput.java
deleted file mode 100644
index 8f9099b..0000000
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/utility/ShortOutput.java
+++ /dev/null
@@ -1,27 +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.enterprise.client.utility;
-
-/**
- * @author Greg Hinkle
- */
-public interface ShortOutput {
-
- String getShortOutput();
-}
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/SummaryFilterTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/SummaryFilterTest.java
index f91bed9..a2abec5 100644
--- a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/SummaryFilterTest.java
+++ b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/SummaryFilterTest.java
@@ -26,6 +26,8 @@ package org.rhq.enterprise.client;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
+
+import org.rhq.bindings.util.SummaryFilter;
import org.rhq.core.domain.util.Summary;
import javax.persistence.Entity;
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java
deleted file mode 100644
index 665abf0..0000000
--- a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java
+++ /dev/null
@@ -1,396 +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.enterprise.client;
-
-import static org.testng.Assert.*;
-
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.shared.ResourceBuilder;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import org.apache.commons.lang.StringUtils;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-import javax.persistence.OneToMany;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.ArrayList;
-
-import static org.rhq.core.domain.measurement.AvailabilityType.*;
-
-public class TabularWriterTest {
-
- StringWriter stringWriter;
-
- TabularWriter writer;
-
- @BeforeMethod
- public void initFixture() {
- stringWriter = new StringWriter();
- writer = new TabularWriter(new PrintWriter(stringWriter));
- }
-
- @Test
- public void aByteShouldPrintUnchanged() {
- byte value = 1;
-
- writer.print(value);
-
- String expected = "1\n";
- String actual = stringWriter.toString();
-
- assertEquals(actual, expected, "A byte or Byte should have its value printed as a String");
- }
-
- @Test
- public void anIntegerShouldPrintUnchanged() {
- int value = 1;
-
- writer.print(value);
-
- String expected = "1\n";
- String actual = stringWriter.toString();
-
- assertEquals(actual, expected, "An int or Integer should have its value printed as a String");
- }
-
- @Test
- public void theSimpleClassNameShouldPrintFirstForEntity() {
- User user = new User(1, "rhqadmin", "rhqadmin");
-
- writer.print(user);
-
- assertNumberOfLinesPrintedIs(4);
- assertLineEquals(0, user.getClass().getSimpleName() + ":", "The simple class name should be the first line printed");
- }
-
- @Test
- public void theIdShouldBeTheFirstPropertyPrintedForEntity() {
- User user = new User(1, "rhqadmin", "rhqadmin");
-
- writer.print(user);
-
- int paddingSize = "username".length();
- int idLineNumber = 1;
- String expected = "\t" + StringUtils.leftPad("id", paddingSize) + ": " + user.getId();
-
- assertLineEquals(idLineNumber, expected, "The id property should be the 2nd line printed");
- }
-
- @Test
- public void otherPropertiesShouldPrintAfterIdForEntity() {
- User user = new User(1, "rhqadmin", "rhqadmin");
-
- writer.print(user);
-
- int passwordLineNumber = 2;
- String expectedPasswordLine = "\tpassword: " + user.getPassword();
-
- assertLineEquals(passwordLineNumber, expectedPasswordLine, "The password property should be the 3rd line printed");
-
- int usernameLineNumber = 3;
- String expectedUsernameLine = "\tusername: " + user.getUsername();
-
- assertLineEquals(usernameLineNumber, expectedUsernameLine, "The username property should be the 4th line printed");
- }
-
- @Test
- public void oneToOneAssociationShouldPrintForAnEntity() {
- User mgr = new User(1, "rhqadmin", "rhqadmin");
- Department department = new Department(1, mgr);
-
- writer.print(department);
-
- int lineNumber = 2;
- String expectedLine = "\tmanager: " + mgr;
-
- assertLineEquals(lineNumber, expectedLine, "The manager property should be the 3rd line printed");
- }
-
- @Test(enabled = false) // TODO revisit
- public void oneToManyAssociationShouldPrintForEntity() {
- User employee = new User(1, "rhq", "rhq");
-
- Company company = new Company(1);
- company.addEmployee(employee);
-
- writer.print(company);
-
- int lineNumber = 2;
- String expectedLine = "\temployees: " + company.getEmployees();
-
- assertLineEquals(lineNumber, expectedLine, "The employees property should be the 2nd line printed and the " +
- "toString() value of the collection should be displayed.");
- }
-
- @Test
- public void idShouldBeFirstResourcePropertyPrinted() {
- Resource resource = createResource();
-
- writer.print(resource);
-
- assertLineEquals(
- 1,
- "\t" + padResourceField("id") + ": " + resource.getId(),
- "Expected Resource.id to be the first property printed."
- );
- }
-
- @Test
- public void nameShouldBeSecondResourcePropertyPrinted() {
- Resource resource = createResource();
-
- writer.print(resource);
-
- assertLineEquals(
- 2,
- "\t" + padResourceField("name") + ": " + resource.getName(),
- "Expected Resource.name to be second property printed"
- );
- }
-
- @Test
- public void versionShouldBeThirdResourcePropertyPrinted() {
- Resource resource = createResource();
-
- writer.print(resource);
-
- assertLineEquals(
- 3,
- "\t" + padResourceField("version") + ": " + resource.getVersion(),
- "Expected Resource.version to be third property printed"
- );
- }
-
- @Test
- public void currentAvailabilityShouldBeFourthResourcePropertyPrinted() {
- Resource resource = createResource();
-
- writer.print(resource);
-
- assertLineEquals(
- 4,
- "\t" + padResourceField("currentAvailability") + ": " + resource.getCurrentAvailability().getAvailabilityType(),
- "Expected short version of Resource.currentAvailability to be fourth property printed"
- );
- }
-
- @Test
- public void handleNullCurrentAvailabilityForResource() {
- Resource resource = createUncommittedResource();
-
- writer.print(resource);
-
- assertLineEquals(
- 4,
- "\t" + padResourceField("currentAvailability") + ": ",
- "Expected to see empty string for Resource.currentAvailability when property is null"
- );
- }
-
- @Test
- public void resourceTypeShouldBeLastResourcePropertyPrinted() {
- Resource resource = createResource();
-
- writer.print(resource);
-
- assertLineEquals(
- 5,
- "\t" + padResourceField("resourceType") + ": " + resource.getResourceType().getName(),
- "Expected short version of Resource.resourceType to be the fifth property printed"
- );
- }
-
- private Resource createResource() {
- return new ResourceBuilder().createServer()
- .usingDefaultResourceType()
- .withId(111)
- .withName("test-server")
- .withUuid("12345")
- .withVersion("1.0")
- .inInventory()
- .withCurrentAvailability(UP)
- .build();
- }
-
- private Resource createUncommittedResource() {
- return new ResourceBuilder().createServer()
- .usingDefaultResourceType()
- .withId(111)
- .withName("test-server")
- .withUuid("12345")
- .withVersion("1.0")
- .notInInventory()
- .build();
- }
-
- @Test
- public void printCollectionOfUncommittedResource() {
- Resource parent = new ResourceBuilder().createServer()
- .usingDefaultResourceType()
- .withName("test-server")
- .withUuid("12345")
- .withVersion("1.0")
- .inInventory()
- .with(2).randomChildServices()
-// .notInInventory()
-// .included()
- .build();
-
- writer.print(parent.getChildResources());
- }
-
- void assertNumberOfLinesPrintedIs(int expectedNumberOfLines) {
- String lines[] = getLines();
- assertEquals(lines.length, expectedNumberOfLines, "The actual lines printed were\n[\n" +
- stringWriter.toString() + "\n]");
- }
-
- void assertLineEquals(int lineNumber, String expectedLine, String msg) {
- String actualLine = getLines()[lineNumber];
-
- assertEquals(actualLine, expectedLine, msg + " -- The actual output was \n[\n" + stringWriter + "\n].");
- }
-
- String[] getLines() {
- return stringWriter.toString().split("\n");
- }
-
- String padResourceField(String field) {
- return StringUtils.leftPad(field, "currentAvailability".length());
- }
-
- @Entity
- static class User {
- @Id
- private int id;
-
- private String username;
-
- private String password;
-
- public User(int id, String username, String password) {
- this.id = id;
- this.username = username;
- this.password = password;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- @Override
- public String toString() {
- return User.class.getSimpleName() + "[id=" + id + ", username=" + username + ", password=" + password + "]";
- }
- }
-
- @Entity
- static class Department {
- @Id
- private int id;
-
- @OneToOne
- private User manager;
-
- public Department(int id, User manager) {
- this.id = id;
- this.manager = manager;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public User getManager() {
- return manager;
- }
-
- public void setManager(User manager) {
- this.manager = manager;
- }
- }
-
- @Entity
- static class Company {
- @Id
- private int id;
-
- @OneToMany
- private List<User> employees = new ArrayList<User>();
-
- public Company(int id) {
- this.id = id;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public List<User> getEmployees() {
- return employees;
- }
-
- public void setEmployees(List<User> employees) {
- this.employees = employees;
- }
-
- public void addEmployee(User employee) {
- employees.add(employee);
- }
- }
-
-}
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
index 1bb32fd..22d5305 100644
--- a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
+++ b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
@@ -12,7 +12,6 @@ import java.util.ArrayList;
import org.testng.annotations.Test;
import org.rhq.enterprise.client.ClientMain;
import org.rhq.enterprise.client.RemoteClient;
-import org.rhq.enterprise.client.TabularWriter;
import org.rhq.enterprise.client.utility.ScriptUtil;
import org.rhq.enterprise.server.alert.AlertManagerRemote;
import org.rhq.enterprise.server.alert.AlertDefinitionManagerRemote;
@@ -24,6 +23,7 @@ import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerRemote;
import org.rhq.enterprise.server.auth.SubjectManagerRemote;
+import org.rhq.bindings.output.TabularWriter;
import org.rhq.core.domain.auth.Subject;
import javax.script.ScriptEngine;
diff --git a/modules/enterprise/remoting/client-api/pom.xml b/modules/enterprise/remoting/client-api/pom.xml
index 9434aa8..ed44e2a 100644
--- a/modules/enterprise/remoting/client-api/pom.xml
+++ b/modules/enterprise/remoting/client-api/pom.xml
@@ -166,7 +166,13 @@
</exclusion>
</exclusions>
</dependency>
-
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-script-bindings</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-remoting</artifactId>
commit 5d7eb67211b84c813e6fb7d22cf84517979dbd8a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jan 6 16:53:25 2011 +0100
Adding the new maven module for the cli alert plugin
diff --git a/modules/enterprise/server/plugins/alert-cli/pom.xml b/modules/enterprise/server/plugins/alert-cli/pom.xml
new file mode 100644
index 0000000..55aa5d3
--- /dev/null
+++ b/modules/enterprise/server/plugins/alert-cli/pom.xml
@@ -0,0 +1,23 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>rhq-enterprise-server-plugins-parent</artifactId>
+ <groupId>org.rhq</groupId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>alert-cli</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>RHQ Enterprise Server CLI Script Alert Plugin</name>
+ <description>An alert sender able to execute an arbitrary CLI script as a response to an alert</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/server/...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/server/...</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/enterprise/server/plugins/alert-cli/</scm.module.path>
+ </properties>
+
+</project>
\ No newline at end of file
commit 7f8e62733484bcdf28b48cd7db684f8811ed8ab3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 13 20:02:24 2011 -0500
log better errors
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index ee39eaa..3f56380 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -873,18 +873,27 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
bundleDeployment.setErrorMessage(null);
bundleDeployment.setStatus(BundleDeploymentStatus.SUCCESS);
} else {
+ bundleDeployment.setLive(true); // not all deployments are purged - error indicates it is still live somewhere
+
+ StringBuilder errorStr = new StringBuilder();
int totalDeployments = bundleDeployment.getResourceDeployments().size();
int failedPurges = failedToPurge.size();
- bundleDeployment.setLive(true); // not all deployments are purged - error indicates it is still live somewhere
if (failedPurges < totalDeployments) {
bundleDeployment.setStatus(BundleDeploymentStatus.MIXED); // some deployments were purged, so show MIXED status
- bundleDeployment.setErrorMessage("Failed to purge [" + failedPurges + "] of [" + totalDeployments
+ errorStr.append("Failed to purge [" + failedPurges + "] of [" + totalDeployments
+ "] remote resource deployments");
} else {
bundleDeployment.setStatus(BundleDeploymentStatus.FAILURE); // all deployments failed to be purged
- bundleDeployment.setErrorMessage("Failed to purge all [" + failedPurges
- + "] remote resource deployments");
+ errorStr.append("Failed to purge all [" + failedPurges + "] remote resource deployments");
}
+
+ // key is the resource deployment that failed to be purged; value is the error message
+ for (Map.Entry<BundleResourceDeployment, String> entry : failedToPurge.entrySet()) {
+ errorStr.append("\n\n");
+ errorStr.append(entry.getKey().getResource().getName()).append(": ").append(entry.getValue());
+ }
+
+ bundleDeployment.setErrorMessage(errorStr.toString());
}
return;
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index 24b6b72..ca528ea 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -140,9 +140,13 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
// Send the diffs to the Server so it can store them as an entry in the deployment history.
BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
DeployDifferences diffs = project.getDeployDifferences();
- // TODO: put the diffs in the "attachment" area and make it more formatted/legible
+
+ String msg = new StringBuilder("Added files=").append(diffs.getAddedFiles().size()).append(
+ "; Deleted files=").append(diffs.getDeletedFiles().size()).append(
+ " (see attached details for more information)").toString();
+ String fullDetails = formatDiff(diffs);
bundleManagerProvider.auditDeployment(resourceDeployment, "Deployment Differences", project.getName(),
- BundleResourceDeploymentHistory.Category.DEPLOY_STEP, null, diffs.toString(), null);
+ BundleResourceDeploymentHistory.Category.DEPLOY_STEP, null, msg, fullDetails);
} catch (Throwable t) {
if (log.isDebugEnabled()) {
try {
@@ -246,4 +250,55 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
}
return antProps;
}
+
+ private String formatDiff(DeployDifferences diffs) {
+ String indent = " ";
+ String nl = "\n";
+ StringBuilder str = new StringBuilder("DEPLOYMENT DETAILS:");
+ str.append(nl);
+
+ str.append("Added Files: ").append(diffs.getAddedFiles().size()).append(nl);
+ for (String f : diffs.getAddedFiles()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Deleted Files: ").append(diffs.getDeletedFiles().size()).append(nl);
+ for (String f : diffs.getDeletedFiles()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Changed Files: ").append(diffs.getChangedFiles().size()).append(nl);
+ for (String f : diffs.getChangedFiles()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Backed Up Files: ").append(diffs.getBackedUpFiles().size()).append(nl);
+ for (Map.Entry<String, String> entry : diffs.getBackedUpFiles().entrySet()) {
+ str.append(indent).append(entry.getKey()).append(" -> ").append(entry.getValue()).append(nl);
+ }
+
+ str.append("Restored Files: ").append(diffs.getRestoredFiles().size()).append(nl);
+ for (Map.Entry<String, String> entry : diffs.getRestoredFiles().entrySet()) {
+ str.append(indent).append(entry.getKey()).append(" <- ").append(entry.getValue()).append(nl);
+ }
+
+ str.append("Ignored Files: ").append(diffs.getIgnoredFiles().size()).append(nl);
+ for (String f : diffs.getIgnoredFiles()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Realized Files: ").append(diffs.getRealizedFiles().size()).append(nl);
+ for (String f : diffs.getRealizedFiles().keySet()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Was Cleaned?: ").append(diffs.wasCleaned()).append(nl);
+
+ str.append("Errors: ").append(diffs.getErrors().size()).append(nl);
+ for (Map.Entry<String, String> entry : diffs.getErrors().entrySet()) {
+ str.append(indent).append(entry.getKey()).append(" : ").append(entry.getValue()).append(nl);
+ }
+
+ return str.toString();
+ }
}
commit 0d3b7dad5fc2e8b3e496becb4d15425c2070f3ff
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 13 18:53:17 2011 -0500
BZ 645412 finish first attempt at end-to-end bundle purge. still need to test this.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
index ea8385a..9e28999 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
@@ -18,12 +18,15 @@
*/
package org.rhq.core.domain.criteria;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
+import org.rhq.core.domain.util.CriteriaUtils;
/**
* @author Jay Shaughnessy
@@ -35,6 +38,7 @@ public class BundleResourceDeploymentCriteria extends Criteria {
private static final long serialVersionUID = 1L;
private Integer filterId;
+ private List<Integer> filterIds; // needs overrides
private Integer filterBundleDeploymentId; // requires override
private String filterBundleDeploymentName; // requires override
private Integer filterResourceId; // requires override
@@ -46,6 +50,7 @@ public class BundleResourceDeploymentCriteria extends Criteria {
private boolean fetchHistories;
public BundleResourceDeploymentCriteria() {
+ filterOverrides.put("ids", "id IN ( ? )");
filterOverrides.put("bundleDeploymentId", "bundleDeployment.id = ?");
filterOverrides.put("bundleDeploymentName", "bundleDeployment.name like ?");
filterOverrides.put("resourceId", "resource.id = ?");
@@ -61,6 +66,10 @@ public class BundleResourceDeploymentCriteria extends Criteria {
this.filterId = filterId;
}
+ public void addFilterIds(Integer... filterIds) {
+ this.filterIds = CriteriaUtils.getListIgnoringNulls(filterIds);
+ }
+
public void addFilterBundleDeploymentId(Integer filterBundleDeploymentId) {
this.filterBundleDeploymentId = filterBundleDeploymentId;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
index c0bbe7c..1838e14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
@@ -87,8 +87,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class BundleDeploymentView extends LocatableVLayout implements BookmarkableView {
- private BundleGWTServiceAsync bundleService;
-
private BundleDeployment deployment;
private BundleVersion version;
private Bundle bundle;
@@ -211,7 +209,11 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
private Canvas getActionLayout(String locatorId) {
LocatableVLayout actionLayout = new LocatableVLayout(locatorId, 10);
- // we can only revert the live deployments, only show revert button when appropriate
+ // we can only revert the live deployments, only show revert button when appropriate
+ // in addition, we provide a purge button if you are viewing the live deployment, so
+ // they can be shown an option to purge the platform content (since only the "live"
+ // deployment represents content on the remote machines, showing purge only for live
+ // deployments makes sense).
if (deployment.isLive()) {
IButton revertButton = new LocatableIButton(actionLayout.extendLocatorId("Revert"), MSG
.view_bundle_revert());
@@ -222,8 +224,44 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
}
});
actionLayout.addMember(revertButton);
+
+ IButton purgeButton = new LocatableIButton(actionLayout.extendLocatorId("Purge"), MSG.view_bundle_purge());
+ purgeButton.setIcon("subsystems/bundle/BundleDestinationAction_Purge_16.png");
+ purgeButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ SC.ask(MSG.view_bundle_dest_purgeConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ final int destinationId = deployment.getDestination().getId();
+ final String destinationName = deployment.getDestination().getName();
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService(600000); // 10m should be enough right?
+ bundleService.purgeBundleDestination(destinationId, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_bundle_dest_purgeFailure(destinationName), caught);
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_bundle_dest_purgeSuccessful(destinationName),
+ Message.Severity.Info));
+ // Bundle destination is purged, go back to bundle deployment view - it is not live anymore
+ CoreGUI.goToView(LinkManager.getBundleDeploymentLink(bundle.getId(), deployment
+ .getId()), true);
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ actionLayout.addMember(purgeButton);
+
if (!canManageBundles) {
revertButton.setDisabled(true);
+ purgeButton.setDisabled(true);
}
}
@@ -235,6 +273,7 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
SC.ask(MSG.view_bundle_deploy_deleteConfirm(), new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
bundleService.deleteBundleDeployment(deployment.getId(), new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
@@ -385,7 +424,7 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
criteria.fetchDestination(true);
criteria.fetchTags(true);
- bundleService = GWTServiceLookup.getBundleService();
+ final BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deploy_loadFailure(), caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index d471742..e01ae47 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -66,8 +66,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class BundleDestinationView extends LocatableVLayout implements BookmarkableView {
- private BundleGWTServiceAsync bundleService;
-
private BundleDestination destination;
private Bundle bundle;
@@ -207,6 +205,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
SC.ask(MSG.view_bundle_dest_purgeConfirm(), new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService(600000); // 10m should be enough right?
bundleService.purgeBundleDestination(destination.getId(), new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
@@ -238,6 +237,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
SC.ask(MSG.view_bundle_dest_deleteConfirm(), new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
bundleService.deleteBundleDestination(destination.getId(), new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
@@ -288,7 +288,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
criteria.fetchDeployments(true);
criteria.fetchTags(true);
- bundleService = GWTServiceLookup.getBundleService();
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
bundleService.findBundleDestinationsByCriteria(criteria, new AsyncCallback<PageList<BundleDestination>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_dest_loadFailure(), caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index d675373..1e8a94e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -102,6 +102,10 @@ public class GWTServiceLookup {
return secure(BundleGWTServiceAsync.Util.getInstance());
}
+ public static BundleGWTServiceAsync getBundleService(int timeout) {
+ return secure(BundleGWTServiceAsync.Util.getInstance(), timeout);
+ }
+
public static ResourceBossGWTServiceAsync getResourceBossService() {
return secure(ResourceBossGWTServiceAsync.Util.getInstance());
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index 0f99049..ee39eaa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -45,6 +45,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeRequest;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeResponse;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleRequest;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleResponse;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
@@ -80,9 +82,11 @@ 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.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.StringUtils;
import org.rhq.core.util.NumberUtil;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
@@ -778,23 +782,112 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
+ @TransactionAttribute(TransactionAttributeType.NEVER)
public void purgeBundleDestination(Subject subject, int bundleDestinationId) throws Exception {
- BundleDeploymentCriteria c = new BundleDeploymentCriteria();
- c.addFilterDestinationId(bundleDestinationId);
- c.addFilterIsLive(true);
- c.fetchBundleVersion(true);
- c.fetchResourceDeployments(true);
- c.fetchDestination(true);
- List<BundleDeployment> liveDeployments = bundleManager.findBundleDeploymentsByCriteria(subject, c);
+ // find the live bundle deployment for this destination, and get all the resource deployments for that live deployment
+ BundleDeploymentCriteria bdc = new BundleDeploymentCriteria();
+ bdc.addFilterDestinationId(bundleDestinationId);
+ bdc.addFilterIsLive(true);
+ bdc.fetchBundleVersion(true);
+ bdc.fetchResourceDeployments(true);
+ bdc.fetchDestination(true);
+ List<BundleDeployment> liveDeployments = bundleManager.findBundleDeploymentsByCriteria(subject, bdc);
if (1 != liveDeployments.size()) {
throw new IllegalArgumentException("No live deployment to purge is found for destinationId ["
+ bundleDestinationId + "]");
}
BundleDeployment liveDeployment = liveDeployments.get(0);
- BundleDestination destination = liveDeployment.getDestination();
List<BundleResourceDeployment> resourceDeploys = liveDeployment.getResourceDeployments();
+ if (resourceDeploys == null || resourceDeploys.isEmpty()) {
+ return; // nothing to do
+ }
+
+ // we need to obtain the bundle type (the remote plugin container needs it). our first criteria can't fetch this deep, we have to do another query.
+ BundleVersionCriteria bvc = new BundleVersionCriteria();
+ bvc.addFilterId(liveDeployment.getBundleVersion().getId());
+ bvc.fetchBundle(true); // will eagerly fetch the bundle type
+ PageList<BundleVersion> bvs = bundleManager.findBundleVersionsByCriteria(subject, bvc);
+ liveDeployment.setBundleVersion(bvs.get(0)); // wire up the full bundle version back into the live deployment
- // TODO loop through each deployment and purge it on agent
+ // we need to obtain the resources for all resource deployments - our first criteria can't fetch this deep, we have to do another query.
+ List<Integer> resourceDeployIds = new ArrayList<Integer>();
+ for (BundleResourceDeployment resourceDeploy : resourceDeploys) {
+ resourceDeployIds.add(resourceDeploy.getId());
+ }
+ BundleResourceDeploymentCriteria brdc = new BundleResourceDeploymentCriteria();
+ brdc.addFilterIds(resourceDeployIds.toArray(new Integer[resourceDeployIds.size()]));
+ brdc.fetchResource(true);
+ brdc.setPageControl(PageControl.getUnlimitedInstance());
+ PageList<BundleResourceDeployment> brdResults = bundleManager.findBundleResourceDeploymentsByCriteria(subject,
+ brdc);
+ resourceDeploys.clear();
+ resourceDeploys.addAll(brdResults);
+ // need to wire the live bundle deployment back in - no need for another query or fetch it above because we have it already
+ for (BundleResourceDeployment brd : brdResults) {
+ brd.setBundleDeployment(liveDeployment);
+ }
+
+ // loop through each deployment and purge it on agent
+ Map<BundleResourceDeployment, String> failedToPurge = new HashMap<BundleResourceDeployment, String>();
+ for (BundleResourceDeployment resourceDeploy : resourceDeploys) {
+ try {
+ Subject overlord = subjectManager.getOverlord();
+ AgentClient agentClient = agentManager.getAgentClient(overlord, resourceDeploy.getResource().getId());
+ BundleAgentService bundleAgentService = agentClient.getBundleAgentService();
+ BundlePurgeRequest request = new BundlePurgeRequest(resourceDeploy);
+ BundlePurgeResponse results = bundleAgentService.purge(request);
+ if (!results.isSuccess()) {
+ String errorMessage = results.getErrorMessage();
+ failedToPurge.put(resourceDeploy, errorMessage);
+ }
+ } catch (Exception e) {
+ String errorMessage = ThrowableUtil.getStackAsString(e);
+ failedToPurge.put(resourceDeploy, errorMessage);
+ }
+ }
+
+ // marks the live deployment "no longer live"
+ bundleManager._finalizePurge(subject, liveDeployment, failedToPurge);
+
+ // throw an exception if we failed to purge one or more resource deployments.
+ // since we are not in a tx context, we lose nothing. All DB updates have already been committed by now
+ // which is what we want. All this does is inform the caller something went wrong.
+ if (!failedToPurge.isEmpty()) {
+ int totalDeployments = liveDeployment.getResourceDeployments().size();
+ int failedPurges = failedToPurge.size();
+ throw new Exception("Failed to purge [" + failedPurges + "] of [" + totalDeployments
+ + "] remote resource deployments");
+ }
+ return;
+ }
+
+ @Override
+ @RequiredPermission(Permission.MANAGE_SECURITY)
+ // no one should be calling us except overlord
+ public void _finalizePurge(Subject subject, BundleDeployment bundleDeployment,
+ Map<BundleResourceDeployment, String> failedToPurge) throws Exception {
+
+ bundleDeployment = entityManager.find(BundleDeployment.class, bundleDeployment.getId());
+ if (failedToPurge.isEmpty()) {
+ bundleDeployment.setLive(false); // all deployments are purged, no where is this live anymore
+ bundleDeployment.setErrorMessage(null);
+ bundleDeployment.setStatus(BundleDeploymentStatus.SUCCESS);
+ } else {
+ int totalDeployments = bundleDeployment.getResourceDeployments().size();
+ int failedPurges = failedToPurge.size();
+ bundleDeployment.setLive(true); // not all deployments are purged - error indicates it is still live somewhere
+ if (failedPurges < totalDeployments) {
+ bundleDeployment.setStatus(BundleDeploymentStatus.MIXED); // some deployments were purged, so show MIXED status
+ bundleDeployment.setErrorMessage("Failed to purge [" + failedPurges + "] of [" + totalDeployments
+ + "] remote resource deployments");
+ } else {
+ bundleDeployment.setStatus(BundleDeploymentStatus.FAILURE); // all deployments failed to be purged
+ bundleDeployment.setErrorMessage("Failed to purge all [" + failedPurges
+ + "] remote resource deployments");
+ }
+ }
+
+ return;
}
@Override
@@ -1178,10 +1271,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<BundleDeployment> findBundleDeploymentsByCriteria(Subject subject, BundleDeploymentCriteria criteria) {
-
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<BundleDeployment> queryRunner = new CriteriaQueryRunner<BundleDeployment>(criteria,
generator, entityManager);
return queryRunner.execute();
@@ -1191,8 +1281,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
public PageList<BundleDestination> findBundleDestinationsByCriteria(Subject subject,
BundleDestinationCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<BundleDestination> queryRunner = new CriteriaQueryRunner<BundleDestination>(criteria,
generator, entityManager);
return queryRunner.execute();
@@ -1226,8 +1314,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<BundleVersion> findBundleVersionsByCriteria(Subject subject, BundleVersionCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<BundleVersion> queryRunner = new CriteriaQueryRunner<BundleVersion>(criteria, generator,
entityManager);
return queryRunner.execute();
@@ -1236,8 +1322,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<BundleFile> findBundleFilesByCriteria(Subject subject, BundleFileCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<BundleFile> queryRunner = new CriteriaQueryRunner<BundleFile>(criteria, generator,
entityManager);
return queryRunner.execute();
@@ -1246,8 +1330,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<Bundle> findBundlesByCriteria(Subject subject, BundleCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<Bundle> queryRunner = new CriteriaQueryRunner<Bundle>(criteria, generator, entityManager);
return queryRunner.execute();
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
index c917d80..3069739 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.bundle;
import java.util.HashMap;
+import java.util.Map;
import javax.ejb.Local;
@@ -186,4 +187,16 @@ public interface BundleManagerLocal extends BundleManagerRemote {
BundleResourceDeployment setBundleResourceDeploymentStatus(Subject subject, int resourceDeploymentId,
BundleDeploymentStatus status) throws Exception;
+ /**
+ * This is for internal use only - when {@link #purgeBundleDestination(Subject, int)} is done, it
+ * calls this so the purge can be finalized. This is required because this method is called with
+ * a transactional context, as opposed to the main purge method.
+ *
+ * @param subject
+ * @param bundleDeployment
+ * @param failedToPurge
+ * @throws Exception
+ */
+ void _finalizePurge(Subject subject, BundleDeployment bundleDeployment,
+ Map<BundleResourceDeployment, String> failedToPurge) throws Exception;
}
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index 4a51bb2..24b6b72 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -140,6 +140,7 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
// Send the diffs to the Server so it can store them as an entry in the deployment history.
BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
DeployDifferences diffs = project.getDeployDifferences();
+ // TODO: put the diffs in the "attachment" area and make it more formatted/legible
bundleManagerProvider.auditDeployment(resourceDeployment, "Deployment Differences", project.getName(),
BundleResourceDeploymentHistory.Category.DEPLOY_STEP, null, diffs.toString(), null);
} catch (Throwable t) {
commit 5e1bc40e55ea854d21833b5cba82bfd82f4964d6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 13 12:39:49 2011 -0500
fix the delete bundle confirmation messages
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index 96ffd49..f4801ea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -231,7 +231,7 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
deleteButton.setIcon("subsystems/bundle/BundleAction_Delete_16.png");
deleteButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- SC.ask(MSG.view_bundle_list_deleteConfirm(), new BooleanCallback() {
+ SC.ask(MSG.view_bundle_deleteConfirm(), new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
bundleManager.deleteBundle(bundleBeingViewed, new AsyncCallback<Void>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
index 643d13a..ceb3c30 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
@@ -139,7 +139,7 @@ public class BundlesListView extends Table<RPCDataSource<BundleWithLatestVersion
}
});
- addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
+ addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG.view_bundle_list_deleteConfirm(),
new AbstractTableAction((hasAuth) ? TableActionEnablement.ANY : TableActionEnablement.NEVER) {
public void executeAction(ListGridRecord[] selections, Object actionValue) {
if (selections == null || selections.length == 0) {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 6ca3f92..4322960 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -907,6 +907,7 @@ view_bundle_recipe = Recipe
view_bundle_revert = Revert
view_bundle_purge = Purge
view_bundle_versions = Versions
+view_bundle_deleteConfirm = Are you sure you want to delete this bundle? All versions, destinations and deployments for this bundle will also be deleted.
# individual bundle views/wizards
view_bundle_fileListView_fileSize = File Size
commit b8a69d8b97c64c98e61da530b25be2ea369d0fd2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 13 10:11:05 2011 -0500
BZ 645412 the start of the end-to-end impl of purging bundles from remote platforms
This isn't fully functional yet - there is a main TODO in SLSB BundleManager:
// TODO loop through each deployment and purge it on agent
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java
index 345567f..29e4e47 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -36,4 +36,11 @@ public interface BundleAgentService {
* @return the results of the immediate scheduling
*/
BundleScheduleResponse schedule(BundleScheduleRequest request);
+
+ /**
+ * Purges the live deployment off the local filesystem.
+ * @param request
+ * @return the results of the purge
+ */
+ BundlePurgeResponse purge(BundlePurgeRequest request);
}
\ No newline at end of file
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeRequest.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeRequest.java
new file mode 100644
index 0000000..e1d83f2
--- /dev/null
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeRequest.java
@@ -0,0 +1,57 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, 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.agent.bundle;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.bundle.BundleResourceDeployment;
+
+/**
+ * The request that the server sends down to the agent to purge the live bundle deployment.
+ *
+ * @author John Mazzitelli
+ */
+public class BundlePurgeRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private BundleResourceDeployment resourceDeployment;
+
+ public BundlePurgeRequest(BundleResourceDeployment resourceDeployment) {
+ this.resourceDeployment = resourceDeployment;
+ }
+
+ /**
+ * @return the live resource deployment that is to be purged
+ */
+ public BundleResourceDeployment getLiveBundleResourceDeployment() {
+ return resourceDeployment;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder(this.getClass() + ": ");
+ str.append("live-deployment=[").append(resourceDeployment.toString()).append("]");
+ return str.toString();
+ }
+}
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeResponse.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeResponse.java
new file mode 100644
index 0000000..53db77c
--- /dev/null
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeResponse.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, 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.agent.bundle;import java.io.Serializable;
+
+import org.rhq.core.util.exception.ThrowableUtil;
+;
+
+/**
+ * The results of the purge.
+ *
+ * @author John Mazzitelli
+ */
+public class BundlePurgeResponse implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String errorMessage;
+
+ public BundlePurgeResponse() {
+ }
+
+ public boolean isSuccess() {
+ return this.errorMessage == null;
+ }
+
+ public String getErrorMessage() {
+ return this.errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public void setErrorMessage(Throwable t) {
+ this.errorMessage = ThrowableUtil.getAllMessages(t);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder(this.getClass().getSimpleName());
+ if (getErrorMessage() != null) {
+ str.append(" error=[").append(getErrorMessage()).append("];");
+ }
+ str.append(" success=[").append(isSuccess()).append("]");
+ return str.toString();
+ }
+}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java
index 2b76c0c..592e63f 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java
@@ -29,4 +29,6 @@ package org.rhq.core.pluginapi.bundle;
*/
public interface BundleFacet {
BundleDeployResult deployBundle(BundleDeployRequest request);
+
+ BundlePurgeResult purgeBundle(BundlePurgeRequest request);
}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeRequest.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeRequest.java
new file mode 100644
index 0000000..6f41339
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeRequest.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.pluginapi.bundle;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.bundle.BundleResourceDeployment;
+
+/**
+ * A request to purge a bundle, essentially erasing the bundle files from the destination.
+ *
+ * @author John Mazzitelli
+ */
+public class BundlePurgeRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private BundleResourceDeployment resourceDeployment;
+ private BundleManagerProvider bundleManagerProvider;
+
+ public BundlePurgeRequest() {
+ }
+
+ /**
+ * This is information about the last known live resource deployment - this is to be purged.
+ *
+ * @return information about the live resource deployment that is to be purged
+ */
+ public BundleResourceDeployment getLiveResourceDeployment() {
+ return resourceDeployment;
+ }
+
+ public void setLiveResourceDeployment(BundleResourceDeployment resourceDeployment) {
+ this.resourceDeployment = resourceDeployment;
+ }
+
+ public BundleManagerProvider getBundleManagerProvider() {
+ return this.bundleManagerProvider;
+ }
+
+ public void setBundleManagerProvider(BundleManagerProvider provider) {
+ this.bundleManagerProvider = provider;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder(this.getClass() + ": ");
+ str.append("live-deployment-to-be-purge=[").append(resourceDeployment.toString()).append("], ");
+ return str.toString();
+ }
+}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeResult.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeResult.java
new file mode 100644
index 0000000..71e0dfb
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeResult.java
@@ -0,0 +1,65 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, 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.pluginapi.bundle;
+
+import java.io.Serializable;
+
+import org.rhq.core.util.exception.ThrowableUtil;
+
+/**
+ * The results after an attempt to purge a bundle has been completed.
+ *
+ * @author John Mazzitelli
+ */
+public class BundlePurgeResult implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String errorMessage;
+
+ public boolean isSuccess() {
+ return this.errorMessage == null;
+ }
+
+ public String getErrorMessage() {
+ return this.errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public void setErrorMessage(Throwable t) {
+ this.errorMessage = ThrowableUtil.getAllMessages(t);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder(this.getClass().getSimpleName());
+ if (getErrorMessage() != null) {
+ str.append(" error=[").append(getErrorMessage()).append("];");
+ }
+ str.append(" success=[").append(isSuccess()).append("]");
+ return str.toString();
+ }
+
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index 8f1525b..b945ff1 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -37,6 +37,8 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeRequest;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeResponse;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleRequest;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleResponse;
import org.rhq.core.clientapi.server.bundle.BundleServerService;
@@ -46,6 +48,7 @@ import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Status;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -62,6 +65,7 @@ import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
+import org.rhq.core.pluginapi.bundle.BundlePurgeResult;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -81,6 +85,9 @@ public class BundleManager extends AgentService implements BundleAgentService, B
private final String AUDIT_FILE_DOWNLOAD_ENDED = "File Download Started";
private final String AUDIT_FILE_DOWNLOAD_STARTED = "File Download Started";
+ private final String AUDIT_PURGE_STARTED = "Purge Started";
+ private final String AUDIT_PURGE_ENDED = "Purge Ended";
+
private PluginContainerConfiguration configuration;
private ExecutorService deployerThreadPool;
@@ -126,6 +133,7 @@ public class BundleManager extends AgentService implements BundleAgentService, B
return size;
}
+ @Override
public BundleScheduleResponse schedule(final BundleScheduleRequest request) {
final BundleScheduleResponse response = new BundleScheduleResponse();
@@ -207,6 +215,58 @@ public class BundleManager extends AgentService implements BundleAgentService, B
return response;
}
+ @Override
+ public BundlePurgeResponse purge(BundlePurgeRequest request) {
+ final BundlePurgeResponse response = new BundlePurgeResponse();
+
+ try {
+ final BundleResourceDeployment resourceDeployment = request.getLiveBundleResourceDeployment();
+ final BundleDeployment bundleDeployment = resourceDeployment.getBundleDeployment();
+
+ // find the resource that will purge the bundle
+ InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+ BundleType bundleType = bundleDeployment.getBundleVersion().getBundle().getBundleType();
+ ResourceType resourceType = bundleType.getResourceType();
+ Set<Resource> resources = im.getResourcesWithType(resourceType);
+ if (resources.isEmpty()) {
+ throw new Exception("No bundle plugin supports bundle type [" + bundleType + "]");
+ }
+ final int bundleHandlerResourceId = resources.iterator().next().getId();
+ final ResourceContainer resourceContainer = im.getResourceContainer(bundleHandlerResourceId);
+ if (null == resourceContainer.getResourceContext()) {
+ throw new Exception("No bundle plugin resource available to handle purge for bundle type ["
+ + bundleType
+ + "]. Ensure the bundle plugin is deployed and its resource is imported into inventory.");
+ }
+
+ // purge the bundle utilizing the bundle facet object
+ String deploymentMessage = "Deployment [" + bundleDeployment + "] to be purged via ["
+ + resourceDeployment.getResource() + "]";
+ auditDeployment(resourceDeployment, AUDIT_PURGE_STARTED, bundleDeployment.getName(), deploymentMessage);
+
+ org.rhq.core.pluginapi.bundle.BundlePurgeRequest purgeRequest = new org.rhq.core.pluginapi.bundle.BundlePurgeRequest();
+ purgeRequest.setBundleManagerProvider(this);
+ purgeRequest.setLiveResourceDeployment(resourceDeployment);
+
+ // get the bundle facet object that will process the bundle and call it to start the purge
+ int facetMethodTimeout = 30 * 60 * 1000; // 30 minutes should be enough time for the bundle plugin to purge everything
+ BundleFacet bundlePluginComponent = getBundleFacet(bundleHandlerResourceId, facetMethodTimeout);
+ BundlePurgeResult result = bundlePluginComponent.purgeBundle(purgeRequest);
+ if (result.isSuccess()) {
+ auditDeployment(resourceDeployment, AUDIT_PURGE_ENDED, bundleDeployment.getName(), deploymentMessage);
+ } else {
+ response.setErrorMessage(result.getErrorMessage());
+ auditDeployment(resourceDeployment, AUDIT_PURGE_ENDED, bundleDeployment.getName(), null,
+ Status.FAILURE, "Failed: " + deploymentMessage, result.getErrorMessage());
+ }
+ } catch (Throwable t) {
+ log.error("Failed to purge bundle: " + request, t);
+ response.setErrorMessage(t);
+ }
+
+ return response;
+ }
+
/**
* convenience method:<br/>
* category defaults to null<br/>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index 324b510..d471742 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -189,11 +189,47 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
revertButton.setIcon("subsystems/bundle/BundleAction_Revert_16.png");
revertButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- new BundleRevertWizard(destination).startWizard();
+ SC.ask(MSG.view_bundle_dest_revertConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ new BundleRevertWizard(destination).startWizard();
+ }
+ }
+ });
}
});
actionLayout.addMember(revertButton);
+ IButton purgeButton = new LocatableIButton(actionLayout.extendLocatorId("Purge"), MSG.view_bundle_purge());
+ purgeButton.setIcon("subsystems/bundle/BundleDestinationAction_Purge_16.png");
+ purgeButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ SC.ask(MSG.view_bundle_dest_purgeConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ bundleService.purgeBundleDestination(destination.getId(), new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_bundle_dest_purgeFailure(destination.getName()), caught);
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_bundle_dest_purgeSuccessful(destination.getName()),
+ Message.Severity.Info));
+ // Bundle destination is purged, go back to bundle destinations root view
+ CoreGUI.goToView(LinkManager.getBundleDestinationLink(bundle.getId(), 0));
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ actionLayout.addMember(purgeButton);
+
IButton deleteButton = new LocatableIButton(actionLayout.extendLocatorId("Delete"), MSG.common_button_delete());
deleteButton.setIcon("subsystems/bundle/BundleDestinationAction_Delete_16.png");
deleteButton.addClickHandler(new ClickHandler() {
@@ -212,7 +248,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_bundle_dest_deleteSuccessful(destination.getName()),
Message.Severity.Info));
- // Bundle destination is deleted, go back to main bundle view
+ // Bundle destination is deleted, go back to bundle destinations root view
CoreGUI.goToView(LinkManager.getBundleDestinationLink(bundle.getId(), 0), true);
}
});
@@ -226,6 +262,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
if (!canManageBundles) {
deployButton.setDisabled(true);
revertButton.setDisabled(true);
+ purgeButton.setDisabled(true);
deleteButton.setDisabled(true);
}
@@ -264,4 +301,4 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
});
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
index 4c7b209..79166ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
@@ -96,4 +96,5 @@ public interface BundleGWTService extends RemoteService {
BundleDeployment scheduleRevertBundleDeployment(int bundleDestinationId, String deploymentDescription,
boolean isCleanDeployment) throws RuntimeException;
+ void purgeBundleDestination(int bundleDestinationId) throws RuntimeException;
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
index 4049454..daf457d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
@@ -266,4 +266,12 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
+
+ public void purgeBundleDestination(int bundleDestinationId) throws RuntimeException {
+ try {
+ bundleManager.purgeBundleDestination(getSessionSubject(), bundleDestinationId);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index acfd5e2..6ca3f92 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -905,6 +905,7 @@ view_bundle_files = Files
view_bundle_latestVersion = Latest Version
view_bundle_recipe = Recipe
view_bundle_revert = Revert
+view_bundle_purge = Purge
view_bundle_versions = Versions
# individual bundle views/wizards
@@ -970,7 +971,11 @@ view_bundle_dest_loadFailureVersionInfo = Failed to load bundle destination depl
view_bundle_dest_backToBundle = Back to Bundle
view_bundle_dest_tagUpdateFailure = Failed to update bundle destination tags
view_bundle_dest_tagUpdateSuccessful = You have successfully updated the bundle destination tags
-view_bundle_dest_deleteConfirm = Are you sure you want to delete this bundle destination?
+view_bundle_dest_purgeConfirm = This will purge the bundle content from all remote machines. Are you sure you want to do this?
+view_bundle_dest_purgeFailure = Failed to purge the bundle destination [{0}] from some or all of the remote machines.
+view_bundle_dest_purgeSuccessful = You successfully purged the bundle destination [{0}] from all of the remote machines.
+view_bundle_dest_revertConfirm = This will revert all remote machines back to the previous bundle deployment. Are you sure you want to do this?
+view_bundle_dest_deleteConfirm = Are you sure you want to delete this bundle destination? This only deletes it from the database; all bundle content that was deployed to this destination on remote machines will remain.
view_bundle_dest_deleteFailure = Failed to delete the bundle destination [{0}]
view_bundle_dest_deleteSuccessful = You successfully deleted the bundle destination [{0}]
view_bundle_resDeployDS_loadFailure = Failed to load bundle resource deployments
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16.png
new file mode 100644
index 0000000..c370e20
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16_Disabled.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16_Disabled.png
new file mode 100644
index 0000000..7647069
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16_Disabled.png differ
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index 25ff496..0f99049 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -142,6 +142,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@EJB
private ResourceGroupManagerLocal resourceGroupManager;
+ @Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleResourceDeploymentHistory addBundleResourceDeploymentHistory(Subject subject, int bundleDeploymentId,
@@ -159,6 +160,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return history;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public Bundle createBundle(Subject subject, String name, String description, int bundleTypeId) throws Exception {
if (null == name || "".equals(name.trim())) {
@@ -201,6 +203,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundle;
}
+ @Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment createBundleDeploymentInNewTrans(Subject subject, int bundleVersionId,
@@ -218,6 +221,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return createBundleDeploymentImpl(subject, bundleVersion, bundleDestination, name, description, configuration);
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment createBundleDeployment(Subject subject, int bundleVersionId, int bundleDestinationId,
String description, Configuration configuration) throws Exception {
@@ -262,6 +266,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return deployment;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDestination createBundleDestination(Subject subject, int bundleId, String name, String description,
String deployDir, Integer groupId) throws Exception {
@@ -289,6 +294,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return dest;
}
+ @Override
public String getBundleDeploymentName(Subject subject, int bundleDestinationId, int bundleVersionId,
int prevDeploymentId) {
BundleDestination bundleDestination = entityManager.find(BundleDestination.class, bundleDestinationId);
@@ -367,6 +373,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return deploymentName;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleType createBundleType(Subject subject, String name, int resourceTypeId) throws Exception {
if (null == name || "".equals(name.trim())) {
@@ -383,6 +390,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleType;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleVersion createBundleAndBundleVersion(Subject subject, String bundleName, String bundleDescription,
int bundleTypeId, String bundleVersionName, String bundleVersionDescription, String version, String recipe)
@@ -406,6 +414,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bv;
}
+ @Override
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleVersion createBundleVersion(Subject subject, int bundleId, String name, String description,
@@ -476,6 +485,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleVersion;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleVersion createBundleVersionViaRecipe(Subject subject, String recipe) throws Exception {
@@ -486,6 +496,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleVersion;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
@TransactionAttribute(TransactionAttributeType.NEVER)
public BundleVersion createBundleVersionViaFile(Subject subject, File distributionFile) throws Exception {
@@ -497,6 +508,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleVersion;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
@TransactionAttribute(TransactionAttributeType.NEVER)
public BundleVersion createBundleVersionViaURL(Subject subject, String distributionFileUrl) throws Exception {
@@ -659,6 +671,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return newVersion;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFile(Subject subject, int bundleVersionId, String name, String version,
Architecture architecture, InputStream fileStream) throws Exception {
@@ -716,6 +729,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleFile;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFileViaByteArray(Subject subject, int bundleVersionId, String name, String version,
Architecture architecture, byte[] fileBytes) throws Exception {
@@ -723,6 +737,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return addBundleFile(subject, bundleVersionId, name, version, architecture, new ByteArrayInputStream(fileBytes));
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFileViaURL(Subject subject, int bundleVersionId, String name, String version,
Architecture architecture, String bundleFileUrl) throws Exception {
@@ -733,6 +748,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return addBundleFile(subject, bundleVersionId, name, version, architecture, url.openStream());
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFileViaPackageVersion(Subject subject, int bundleVersionId, String name,
int packageVersionId) throws Exception {
@@ -760,12 +776,35 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleFile;
}
+ @Override
+ @RequiredPermission(Permission.MANAGE_BUNDLE)
+ public void purgeBundleDestination(Subject subject, int bundleDestinationId) throws Exception {
+ BundleDeploymentCriteria c = new BundleDeploymentCriteria();
+ c.addFilterDestinationId(bundleDestinationId);
+ c.addFilterIsLive(true);
+ c.fetchBundleVersion(true);
+ c.fetchResourceDeployments(true);
+ c.fetchDestination(true);
+ List<BundleDeployment> liveDeployments = bundleManager.findBundleDeploymentsByCriteria(subject, c);
+ if (1 != liveDeployments.size()) {
+ throw new IllegalArgumentException("No live deployment to purge is found for destinationId ["
+ + bundleDestinationId + "]");
+ }
+ BundleDeployment liveDeployment = liveDeployments.get(0);
+ BundleDestination destination = liveDeployment.getDestination();
+ List<BundleResourceDeployment> resourceDeploys = liveDeployment.getResourceDeployments();
+
+ // TODO loop through each deployment and purge it on agent
+ }
+
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment scheduleBundleDeployment(Subject subject, int bundleDeploymentId, boolean isCleanDeployment)
throws Exception {
return scheduleBundleDeploymentImpl(subject, bundleDeploymentId, isCleanDeployment, false);
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment scheduleRevertBundleDeployment(Subject subject, int bundleDestinationId,
String deploymentDescription, boolean isCleanDeployment) throws Exception {
@@ -920,6 +959,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return resourceDeployment;
}
+ @Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleScheduleRequest getScheduleRequest(Subject subject, int resourceDeploymentId,
@@ -971,6 +1011,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return request;
}
+ @Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleResourceDeployment createBundleResourceDeployment(Subject subject, int bundleDeploymentId,
@@ -991,6 +1032,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return resourceDeployment;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleResourceDeployment setBundleResourceDeploymentStatus(Subject subject, int resourceDeploymentId,
BundleDeploymentStatus status) throws Exception {
@@ -1042,6 +1084,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// return groupDeployment;
//}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public Set<String> getBundleVersionFilenames(Subject subject, int bundleVersionId, boolean withoutBundleFileOnly)
throws Exception {
@@ -1081,6 +1124,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public HashMap<String, Boolean> getAllBundleVersionFilenames(Subject subject, int bundleVersionId) throws Exception {
@@ -1114,6 +1158,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
+ @Override
@SuppressWarnings("unchecked")
public List<BundleType> getAllBundleTypes(Subject subject) {
// the list of types will be small, no need to support paging
@@ -1122,6 +1167,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return types;
}
+ @Override
public BundleType getBundleType(Subject subject, String bundleTypeName) {
// the list of types will be small, no need to support paging
Query q = entityManager.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
@@ -1130,6 +1176,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return type;
}
+ @Override
public PageList<BundleDeployment> findBundleDeploymentsByCriteria(Subject subject, BundleDeploymentCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
@@ -1140,6 +1187,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleDestination> findBundleDestinationsByCriteria(Subject subject,
BundleDestinationCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
@@ -1150,6 +1198,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleResourceDeployment> findBundleResourceDeploymentsByCriteria(Subject subject,
BundleResourceDeploymentCriteria criteria) {
@@ -1174,6 +1223,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleVersion> findBundleVersionsByCriteria(Subject subject, BundleVersionCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
;
@@ -1183,6 +1233,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleFile> findBundleFilesByCriteria(Subject subject, BundleFileCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
;
@@ -1192,6 +1243,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<Bundle> findBundlesByCriteria(Subject subject, BundleCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
;
@@ -1200,6 +1252,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleWithLatestVersionComposite> findBundlesWithLatestVersionCompositesByCriteria(Subject subject,
BundleCriteria criteria) {
@@ -1222,6 +1275,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// to avoid deadlocks, you cannot delete multiple bundles concurrently (see BZ 606530)
// instead, this simple method just loops over the given array and deletes them serially
// note they all get deleted in their own transaction; this method is never in a tx itself
+ @Override
@TransactionAttribute(TransactionAttributeType.NEVER)
public void deleteBundles(Subject subject, int[] bundleIds) throws Exception {
if (bundleIds != null) {
@@ -1231,6 +1285,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
}
+ @Override
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundle(Subject subject, int bundleId) throws Exception {
@@ -1257,6 +1312,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
repoManager.deleteRepo(subjectManager.getOverlord(), bundleRepo.getId());
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundleDeployment(Subject subject, int bundleDeploymentId) throws Exception {
BundleDeployment doomed = this.entityManager.find(BundleDeployment.class, bundleDeploymentId);
@@ -1273,6 +1329,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundleDestination(Subject subject, int destinationId) throws Exception {
BundleDestination doomed = this.entityManager.find(BundleDestination.class, destinationId);
@@ -1292,6 +1349,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
entityManager.remove(doomed);
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundleVersion(Subject subject, int bundleVersionId, boolean deleteBundleIfEmpty) throws Exception {
BundleVersion bundleVersion = this.entityManager.find(BundleVersion.class, bundleVersionId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
index e8fdd8f..231d4c3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
@@ -330,6 +330,17 @@ public interface BundleManagerRemote {
*/
/**
+ * Purges the destination's live deployment content from the remote platforms.
+ *
+ * @param subject user that must have proper permissions
+ * @param bundleDestinationId the ID of the destination that is to be purged of bundle content
+ */
+ @WebMethod
+ void purgeBundleDestination( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "bundleDestinationId") int bundleDestinationId) throws Exception;
+
+ /**
* Deploy the bundle to the destination, as described in the provided deployment.
* Deployment is asynchronous so return of this method does not indicate individual resource deployments are
* complete. The returned BundleDeployment can be used to track the history of the individual deployments.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 484a751..056582f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -374,6 +374,10 @@ public class WebservicesManagerBean implements WebservicesRemote {
isCleanDeployment);
}
+ public void purgeBundleDestination(Subject subject, int bundleDestinationId) throws Exception {
+ bundleManager.purgeBundleDestination(subject, bundleDestinationId);
+ }
+
//BUNDLEMANAGER: END ----------------------------------
//CALLTIMEDATAMANAGER: BEGIN ----------------------------------
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
index 2c08880..aa221f9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
@@ -25,6 +25,8 @@ import java.util.Set;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeRequest;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeResponse;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleRequest;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleResponse;
import org.rhq.core.clientapi.agent.configuration.ConfigurationAgentService;
@@ -55,7 +57,6 @@ import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
import org.rhq.core.domain.measurement.Availability;
-import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDataRequest;
import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest;
@@ -75,201 +76,248 @@ public class TestAgentClient implements AgentClient, BundleAgentService, Content
this.commService = commService;
}
+ @Override
public Agent getAgent() {
return this.agent;
}
+ @Override
public BundleAgentService getBundleAgentService() {
return (commService.bundleService != null) ? commService.bundleService : this;
}
+ @Override
public ContentAgentService getContentAgentService() {
return (commService.contentService != null) ? commService.contentService : this;
}
+ @Override
public ResourceFactoryAgentService getResourceFactoryAgentService() {
return (commService.resourceFactoryService != null) ? commService.resourceFactoryService : this;
}
+ @Override
public ConfigurationAgentService getConfigurationAgentService() {
return (commService.configurationService != null) ? commService.configurationService : this;
}
+ @Override
public DiscoveryAgentService getDiscoveryAgentService() {
return (commService.discoveryService != null) ? commService.discoveryService : this;
}
+ @Override
public MeasurementAgentService getMeasurementAgentService() {
return (commService.measurementService != null) ? commService.measurementService : this;
}
+ @Override
public OperationAgentService getOperationAgentService() {
return (commService.operationService != null) ? commService.operationService : this;
}
+ @Override
public SupportAgentService getSupportAgentService() {
return (commService.supportService != null) ? commService.supportService : this;
}
+ @Override
public void startSending() {
return; // no-op
}
+ @Override
public void stopSending() {
return; // no-op
}
+ @Override
public boolean ping(long timeoutMillis) {
return true;
}
// provide no-ops for all agent services
-
+ @Override
public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, List<MeasurementDataRequest> requests) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
+ @Override
public void scheduleCollection(Set<ResourceMeasurementScheduleRequest> resourceSchedules) {
}
+ @Override
public void unscheduleCollection(Set<Integer> resourceIds) {
}
+ @Override
public void updateCollection(Set<ResourceMeasurementScheduleRequest> resourceSchedules) {
}
+ @Override
public Map<String, Object> getMeasurementScheduleInfoForResource(int resourceId) {
return null;
}
+ @Override
public ConfigurationUpdateResponse executeUpdateResourceConfigurationImmediately(ConfigurationUpdateRequest request)
throws PluginContainerException {
return null;
}
+ @Override
public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException {
return null;
}
- public Configuration loadResourceConfiguration(int resourceId, boolean fromStructured)
- throws PluginContainerException {
- return null;
- }
-
+ @Override
public Configuration merge(Configuration configuration, int resourceId, boolean fromStructured)
throws PluginContainerException {
return null;
}
+ @Override
public void updateResourceConfiguration(ConfigurationUpdateRequest request) {
}
+ @Override
public CancelResults cancelOperation(String jobId) {
return null;
}
+ @Override
public void invokeOperation(String jobId, int resourceId, String operationName, Configuration parameters)
throws PluginContainerException {
}
+ @Override
public void deletePackages(DeletePackagesRequest request) {
}
+ @Override
public void deployPackages(DeployPackagesRequest request) {
}
+ @Override
public ContentDiscoveryReport executeResourcePackageDiscoveryImmediately(int resourceId, String packageTypeName)
throws PluginContainerException {
return null;
}
+ @Override
public Set<ResourcePackageDetails> getLastDiscoveredResourcePackages(int resourceId) {
return null;
}
+ @Override
public void retrievePackageBits(RetrievePackageBitsRequest request) {
}
+ @Override
public List<DeployPackageStep> translateInstallationSteps(int resourceId, ResourcePackageDetails packageDetails)
throws PluginContainerException {
return null;
}
+ @Override
public void disableServiceScans(int serverResourceId) {
}
+ @Override
public void enableServiceScans(int serverResourceId, Configuration config) {
}
+ @Override
public AvailabilityReport executeAvailabilityScanImmediately(boolean changedOnlyReport) {
return null;
}
+ @Override
public InventoryReport executeServerScanImmediately() throws PluginContainerException {
return null;
}
+ @Override
public InventoryReport executeServiceScanImmediately() throws PluginContainerException {
return null;
}
+ @Override
public void executeServiceScanDeferred() {
return;
}
+ @Override
public Availability getCurrentAvailability(Resource resource) {
return null;
}
+ @Override
public Resource getPlatform() {
return null;
}
+ @Override
public MergeResourceResponse manuallyAddResource(ResourceType resourceType, int parentResourceId,
Configuration pluginConfiguration, int creatorSubjectId) throws InvalidPluginConfigurationClientException,
PluginContainerException {
return null;
}
+ @Override
public void uninventoryResource(int resourceId) {
}
+ @Override
public void updatePluginConfiguration(int resourceId, Configuration newPluginConfiguration)
throws InvalidPluginConfigurationClientException, PluginContainerException {
}
@Asynchronous(guaranteedDelivery = true)
+ @Override
public void synchronizeInventory(ResourceSyncInfo syncInfo) {
return;
}
+ @Override
public void createResource(CreateResourceRequest request) throws PluginContainerException {
}
+ @Override
public void deleteResource(DeleteResourceRequest request) throws PluginContainerException {
}
+ @Override
public CreateResourceResponse executeCreateResourceImmediately(CreateResourceRequest request)
throws PluginContainerException {
return null;
}
+ @Override
public DeleteResourceResponse executeDeleteResourceImmediately(DeleteResourceRequest request)
throws PluginContainerException {
return null;
}
+ @Override
public InputStream getSnapshotReport(int resourceId, String name, String description) throws Exception {
return null;
}
+ @Override
public Configuration validate(Configuration configuration, int resourceId, boolean isStructured)
throws PluginContainerException {
return null;
}
+ @Override
public BundleScheduleResponse schedule(BundleScheduleRequest request) {
return new BundleScheduleResponse();
}
+
+ @Override
+ public BundlePurgeResponse purge(BundlePurgeRequest request) {
+ return new BundlePurgeResponse();
+ }
}
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index 51098ea..4a51bb2 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -43,6 +43,8 @@ import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Category;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Status;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -51,9 +53,12 @@ import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
+import org.rhq.core.pluginapi.bundle.BundlePurgeRequest;
+import org.rhq.core.pluginapi.bundle.BundlePurgeResult;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.system.SystemInfoFactory;
+import org.rhq.core.util.file.FileUtil;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.core.util.updater.DeployDifferences;
import org.rhq.core.util.updater.DeploymentsMetadata;
@@ -160,6 +165,38 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
return result;
}
+ // TODO: this is copied from FileTemplate bundle plugin - I think we want to be more smart here since
+ // we have more metadata about the live deployment to be purged in our .rhqdeployments (specifically about
+ // the external raw files that we should delete)
+ public BundlePurgeResult purgeBundle(BundlePurgeRequest request) {
+ BundlePurgeResult result = new BundlePurgeResult();
+ try {
+ BundleResourceDeployment deploymentToPurge = request.getLiveResourceDeployment();
+ BundleDeployment bundleDeployment = deploymentToPurge.getBundleDeployment();
+ File deployDir = new File(bundleDeployment.getDestination().getDeployDir());
+ String deployDirAbsolutePath = deployDir.getAbsolutePath();
+ BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
+
+ // completely purge the deployment directory.
+ // TODO: if the receipe copied a file outside of the deployment directory, it will still exist. How do we remove those?
+ FileUtil.purge(deployDir, true);
+
+ if (!deployDir.exists()) {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory has been purged", Category.AUDIT_MESSAGE, Status.SUCCESS,
+ "Directory purged: " + deployDirAbsolutePath, null);
+ } else {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE,
+ "The directory that failed to be purged: " + deployDirAbsolutePath, null);
+ }
+ } catch (Throwable t) {
+ log.error("Failed to purge bundle [" + request + "]", t);
+ result.setErrorMessage(t);
+ }
+ return result;
+ }
+
private BundleAntProject executeDeploymentPhase(File recipeFile, Properties antProps,
List<BuildListener> buildListeners, DeploymentPhase phase) throws InvalidBuildFileException {
AntLauncher antLauncher = new AntLauncher();
diff --git a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
index 0b96612..940a01e 100644
--- a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
+++ b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
@@ -27,14 +27,19 @@ import org.rhq.bundle.filetemplate.recipe.RecipeParser;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Category;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Status;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
+import org.rhq.core.pluginapi.bundle.BundlePurgeRequest;
+import org.rhq.core.pluginapi.bundle.BundlePurgeResult;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.util.FileUtils;
+import org.rhq.core.util.file.FileUtil;
/**
* @author John Mazzitelli
@@ -120,4 +125,33 @@ public class FileTemplateBundlePluginServerComponent implements ResourceComponen
return result;
}
+
+ public BundlePurgeResult purgeBundle(BundlePurgeRequest request) {
+ BundlePurgeResult result = new BundlePurgeResult();
+ try {
+ BundleResourceDeployment deploymentToPurge = request.getLiveResourceDeployment();
+ BundleDeployment bundleDeployment = deploymentToPurge.getBundleDeployment();
+ File deployDir = new File(bundleDeployment.getDestination().getDeployDir());
+ String deployDirAbsolutePath = deployDir.getAbsolutePath();
+ BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
+
+ // completely purge the deployment directory.
+ // TODO: if the receipe copied a file outside of the deployment directory, it will still exist. How do we remove those?
+ FileUtil.purge(deployDir, true);
+
+ if (!deployDir.exists()) {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory has been purged", Category.AUDIT_MESSAGE, Status.SUCCESS,
+ "Directory purged: " + deployDirAbsolutePath, null);
+ } else {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE,
+ "The directory that failed to be purged: " + deployDirAbsolutePath, null);
+ }
+ } catch (Throwable t) {
+ log.error("Failed to purge bundle [" + request + "]", t);
+ result.setErrorMessage(t);
+ }
+ return result;
+ }
}
13 years, 4 months
[rhq] 4 commits - modules/core modules/enterprise modules/plugins
by mazz
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java | 9
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeRequest.java | 57 +++
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeResponse.java | 67 +++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java | 9
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java | 2
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeRequest.java | 67 +++
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeResult.java | 65 +++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 60 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java | 47 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java | 49 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java | 8
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 8
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16_Disabled.png |binary
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 171 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java | 13
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java | 11
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java | 64 +++
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java | 95 +++++
modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java | 34 +
25 files changed, 815 insertions(+), 34 deletions(-)
New commits:
commit 7f8e62733484bcdf28b48cd7db684f8811ed8ab3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 13 20:02:24 2011 -0500
log better errors
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index ee39eaa..3f56380 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -873,18 +873,27 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
bundleDeployment.setErrorMessage(null);
bundleDeployment.setStatus(BundleDeploymentStatus.SUCCESS);
} else {
+ bundleDeployment.setLive(true); // not all deployments are purged - error indicates it is still live somewhere
+
+ StringBuilder errorStr = new StringBuilder();
int totalDeployments = bundleDeployment.getResourceDeployments().size();
int failedPurges = failedToPurge.size();
- bundleDeployment.setLive(true); // not all deployments are purged - error indicates it is still live somewhere
if (failedPurges < totalDeployments) {
bundleDeployment.setStatus(BundleDeploymentStatus.MIXED); // some deployments were purged, so show MIXED status
- bundleDeployment.setErrorMessage("Failed to purge [" + failedPurges + "] of [" + totalDeployments
+ errorStr.append("Failed to purge [" + failedPurges + "] of [" + totalDeployments
+ "] remote resource deployments");
} else {
bundleDeployment.setStatus(BundleDeploymentStatus.FAILURE); // all deployments failed to be purged
- bundleDeployment.setErrorMessage("Failed to purge all [" + failedPurges
- + "] remote resource deployments");
+ errorStr.append("Failed to purge all [" + failedPurges + "] remote resource deployments");
}
+
+ // key is the resource deployment that failed to be purged; value is the error message
+ for (Map.Entry<BundleResourceDeployment, String> entry : failedToPurge.entrySet()) {
+ errorStr.append("\n\n");
+ errorStr.append(entry.getKey().getResource().getName()).append(": ").append(entry.getValue());
+ }
+
+ bundleDeployment.setErrorMessage(errorStr.toString());
}
return;
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index 24b6b72..ca528ea 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -140,9 +140,13 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
// Send the diffs to the Server so it can store them as an entry in the deployment history.
BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
DeployDifferences diffs = project.getDeployDifferences();
- // TODO: put the diffs in the "attachment" area and make it more formatted/legible
+
+ String msg = new StringBuilder("Added files=").append(diffs.getAddedFiles().size()).append(
+ "; Deleted files=").append(diffs.getDeletedFiles().size()).append(
+ " (see attached details for more information)").toString();
+ String fullDetails = formatDiff(diffs);
bundleManagerProvider.auditDeployment(resourceDeployment, "Deployment Differences", project.getName(),
- BundleResourceDeploymentHistory.Category.DEPLOY_STEP, null, diffs.toString(), null);
+ BundleResourceDeploymentHistory.Category.DEPLOY_STEP, null, msg, fullDetails);
} catch (Throwable t) {
if (log.isDebugEnabled()) {
try {
@@ -246,4 +250,55 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
}
return antProps;
}
+
+ private String formatDiff(DeployDifferences diffs) {
+ String indent = " ";
+ String nl = "\n";
+ StringBuilder str = new StringBuilder("DEPLOYMENT DETAILS:");
+ str.append(nl);
+
+ str.append("Added Files: ").append(diffs.getAddedFiles().size()).append(nl);
+ for (String f : diffs.getAddedFiles()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Deleted Files: ").append(diffs.getDeletedFiles().size()).append(nl);
+ for (String f : diffs.getDeletedFiles()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Changed Files: ").append(diffs.getChangedFiles().size()).append(nl);
+ for (String f : diffs.getChangedFiles()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Backed Up Files: ").append(diffs.getBackedUpFiles().size()).append(nl);
+ for (Map.Entry<String, String> entry : diffs.getBackedUpFiles().entrySet()) {
+ str.append(indent).append(entry.getKey()).append(" -> ").append(entry.getValue()).append(nl);
+ }
+
+ str.append("Restored Files: ").append(diffs.getRestoredFiles().size()).append(nl);
+ for (Map.Entry<String, String> entry : diffs.getRestoredFiles().entrySet()) {
+ str.append(indent).append(entry.getKey()).append(" <- ").append(entry.getValue()).append(nl);
+ }
+
+ str.append("Ignored Files: ").append(diffs.getIgnoredFiles().size()).append(nl);
+ for (String f : diffs.getIgnoredFiles()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Realized Files: ").append(diffs.getRealizedFiles().size()).append(nl);
+ for (String f : diffs.getRealizedFiles().keySet()) {
+ str.append(indent).append(f).append(nl);
+ }
+
+ str.append("Was Cleaned?: ").append(diffs.wasCleaned()).append(nl);
+
+ str.append("Errors: ").append(diffs.getErrors().size()).append(nl);
+ for (Map.Entry<String, String> entry : diffs.getErrors().entrySet()) {
+ str.append(indent).append(entry.getKey()).append(" : ").append(entry.getValue()).append(nl);
+ }
+
+ return str.toString();
+ }
}
commit 0d3b7dad5fc2e8b3e496becb4d15425c2070f3ff
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 13 18:53:17 2011 -0500
BZ 645412 finish first attempt at end-to-end bundle purge. still need to test this.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
index ea8385a..9e28999 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
@@ -18,12 +18,15 @@
*/
package org.rhq.core.domain.criteria;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
+import org.rhq.core.domain.util.CriteriaUtils;
/**
* @author Jay Shaughnessy
@@ -35,6 +38,7 @@ public class BundleResourceDeploymentCriteria extends Criteria {
private static final long serialVersionUID = 1L;
private Integer filterId;
+ private List<Integer> filterIds; // needs overrides
private Integer filterBundleDeploymentId; // requires override
private String filterBundleDeploymentName; // requires override
private Integer filterResourceId; // requires override
@@ -46,6 +50,7 @@ public class BundleResourceDeploymentCriteria extends Criteria {
private boolean fetchHistories;
public BundleResourceDeploymentCriteria() {
+ filterOverrides.put("ids", "id IN ( ? )");
filterOverrides.put("bundleDeploymentId", "bundleDeployment.id = ?");
filterOverrides.put("bundleDeploymentName", "bundleDeployment.name like ?");
filterOverrides.put("resourceId", "resource.id = ?");
@@ -61,6 +66,10 @@ public class BundleResourceDeploymentCriteria extends Criteria {
this.filterId = filterId;
}
+ public void addFilterIds(Integer... filterIds) {
+ this.filterIds = CriteriaUtils.getListIgnoringNulls(filterIds);
+ }
+
public void addFilterBundleDeploymentId(Integer filterBundleDeploymentId) {
this.filterBundleDeploymentId = filterBundleDeploymentId;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
index c0bbe7c..1838e14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
@@ -87,8 +87,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class BundleDeploymentView extends LocatableVLayout implements BookmarkableView {
- private BundleGWTServiceAsync bundleService;
-
private BundleDeployment deployment;
private BundleVersion version;
private Bundle bundle;
@@ -211,7 +209,11 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
private Canvas getActionLayout(String locatorId) {
LocatableVLayout actionLayout = new LocatableVLayout(locatorId, 10);
- // we can only revert the live deployments, only show revert button when appropriate
+ // we can only revert the live deployments, only show revert button when appropriate
+ // in addition, we provide a purge button if you are viewing the live deployment, so
+ // they can be shown an option to purge the platform content (since only the "live"
+ // deployment represents content on the remote machines, showing purge only for live
+ // deployments makes sense).
if (deployment.isLive()) {
IButton revertButton = new LocatableIButton(actionLayout.extendLocatorId("Revert"), MSG
.view_bundle_revert());
@@ -222,8 +224,44 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
}
});
actionLayout.addMember(revertButton);
+
+ IButton purgeButton = new LocatableIButton(actionLayout.extendLocatorId("Purge"), MSG.view_bundle_purge());
+ purgeButton.setIcon("subsystems/bundle/BundleDestinationAction_Purge_16.png");
+ purgeButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ SC.ask(MSG.view_bundle_dest_purgeConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ final int destinationId = deployment.getDestination().getId();
+ final String destinationName = deployment.getDestination().getName();
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService(600000); // 10m should be enough right?
+ bundleService.purgeBundleDestination(destinationId, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_bundle_dest_purgeFailure(destinationName), caught);
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_bundle_dest_purgeSuccessful(destinationName),
+ Message.Severity.Info));
+ // Bundle destination is purged, go back to bundle deployment view - it is not live anymore
+ CoreGUI.goToView(LinkManager.getBundleDeploymentLink(bundle.getId(), deployment
+ .getId()), true);
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ actionLayout.addMember(purgeButton);
+
if (!canManageBundles) {
revertButton.setDisabled(true);
+ purgeButton.setDisabled(true);
}
}
@@ -235,6 +273,7 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
SC.ask(MSG.view_bundle_deploy_deleteConfirm(), new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
bundleService.deleteBundleDeployment(deployment.getId(), new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
@@ -385,7 +424,7 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
criteria.fetchDestination(true);
criteria.fetchTags(true);
- bundleService = GWTServiceLookup.getBundleService();
+ final BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deploy_loadFailure(), caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index d471742..e01ae47 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -66,8 +66,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class BundleDestinationView extends LocatableVLayout implements BookmarkableView {
- private BundleGWTServiceAsync bundleService;
-
private BundleDestination destination;
private Bundle bundle;
@@ -207,6 +205,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
SC.ask(MSG.view_bundle_dest_purgeConfirm(), new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService(600000); // 10m should be enough right?
bundleService.purgeBundleDestination(destination.getId(), new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
@@ -238,6 +237,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
SC.ask(MSG.view_bundle_dest_deleteConfirm(), new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
bundleService.deleteBundleDestination(destination.getId(), new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
@@ -288,7 +288,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
criteria.fetchDeployments(true);
criteria.fetchTags(true);
- bundleService = GWTServiceLookup.getBundleService();
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
bundleService.findBundleDestinationsByCriteria(criteria, new AsyncCallback<PageList<BundleDestination>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_dest_loadFailure(), caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index d675373..1e8a94e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -102,6 +102,10 @@ public class GWTServiceLookup {
return secure(BundleGWTServiceAsync.Util.getInstance());
}
+ public static BundleGWTServiceAsync getBundleService(int timeout) {
+ return secure(BundleGWTServiceAsync.Util.getInstance(), timeout);
+ }
+
public static ResourceBossGWTServiceAsync getResourceBossService() {
return secure(ResourceBossGWTServiceAsync.Util.getInstance());
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index 0f99049..ee39eaa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -45,6 +45,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeRequest;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeResponse;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleRequest;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleResponse;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
@@ -80,9 +82,11 @@ 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.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.StringUtils;
import org.rhq.core.util.NumberUtil;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
@@ -778,23 +782,112 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
+ @TransactionAttribute(TransactionAttributeType.NEVER)
public void purgeBundleDestination(Subject subject, int bundleDestinationId) throws Exception {
- BundleDeploymentCriteria c = new BundleDeploymentCriteria();
- c.addFilterDestinationId(bundleDestinationId);
- c.addFilterIsLive(true);
- c.fetchBundleVersion(true);
- c.fetchResourceDeployments(true);
- c.fetchDestination(true);
- List<BundleDeployment> liveDeployments = bundleManager.findBundleDeploymentsByCriteria(subject, c);
+ // find the live bundle deployment for this destination, and get all the resource deployments for that live deployment
+ BundleDeploymentCriteria bdc = new BundleDeploymentCriteria();
+ bdc.addFilterDestinationId(bundleDestinationId);
+ bdc.addFilterIsLive(true);
+ bdc.fetchBundleVersion(true);
+ bdc.fetchResourceDeployments(true);
+ bdc.fetchDestination(true);
+ List<BundleDeployment> liveDeployments = bundleManager.findBundleDeploymentsByCriteria(subject, bdc);
if (1 != liveDeployments.size()) {
throw new IllegalArgumentException("No live deployment to purge is found for destinationId ["
+ bundleDestinationId + "]");
}
BundleDeployment liveDeployment = liveDeployments.get(0);
- BundleDestination destination = liveDeployment.getDestination();
List<BundleResourceDeployment> resourceDeploys = liveDeployment.getResourceDeployments();
+ if (resourceDeploys == null || resourceDeploys.isEmpty()) {
+ return; // nothing to do
+ }
+
+ // we need to obtain the bundle type (the remote plugin container needs it). our first criteria can't fetch this deep, we have to do another query.
+ BundleVersionCriteria bvc = new BundleVersionCriteria();
+ bvc.addFilterId(liveDeployment.getBundleVersion().getId());
+ bvc.fetchBundle(true); // will eagerly fetch the bundle type
+ PageList<BundleVersion> bvs = bundleManager.findBundleVersionsByCriteria(subject, bvc);
+ liveDeployment.setBundleVersion(bvs.get(0)); // wire up the full bundle version back into the live deployment
- // TODO loop through each deployment and purge it on agent
+ // we need to obtain the resources for all resource deployments - our first criteria can't fetch this deep, we have to do another query.
+ List<Integer> resourceDeployIds = new ArrayList<Integer>();
+ for (BundleResourceDeployment resourceDeploy : resourceDeploys) {
+ resourceDeployIds.add(resourceDeploy.getId());
+ }
+ BundleResourceDeploymentCriteria brdc = new BundleResourceDeploymentCriteria();
+ brdc.addFilterIds(resourceDeployIds.toArray(new Integer[resourceDeployIds.size()]));
+ brdc.fetchResource(true);
+ brdc.setPageControl(PageControl.getUnlimitedInstance());
+ PageList<BundleResourceDeployment> brdResults = bundleManager.findBundleResourceDeploymentsByCriteria(subject,
+ brdc);
+ resourceDeploys.clear();
+ resourceDeploys.addAll(brdResults);
+ // need to wire the live bundle deployment back in - no need for another query or fetch it above because we have it already
+ for (BundleResourceDeployment brd : brdResults) {
+ brd.setBundleDeployment(liveDeployment);
+ }
+
+ // loop through each deployment and purge it on agent
+ Map<BundleResourceDeployment, String> failedToPurge = new HashMap<BundleResourceDeployment, String>();
+ for (BundleResourceDeployment resourceDeploy : resourceDeploys) {
+ try {
+ Subject overlord = subjectManager.getOverlord();
+ AgentClient agentClient = agentManager.getAgentClient(overlord, resourceDeploy.getResource().getId());
+ BundleAgentService bundleAgentService = agentClient.getBundleAgentService();
+ BundlePurgeRequest request = new BundlePurgeRequest(resourceDeploy);
+ BundlePurgeResponse results = bundleAgentService.purge(request);
+ if (!results.isSuccess()) {
+ String errorMessage = results.getErrorMessage();
+ failedToPurge.put(resourceDeploy, errorMessage);
+ }
+ } catch (Exception e) {
+ String errorMessage = ThrowableUtil.getStackAsString(e);
+ failedToPurge.put(resourceDeploy, errorMessage);
+ }
+ }
+
+ // marks the live deployment "no longer live"
+ bundleManager._finalizePurge(subject, liveDeployment, failedToPurge);
+
+ // throw an exception if we failed to purge one or more resource deployments.
+ // since we are not in a tx context, we lose nothing. All DB updates have already been committed by now
+ // which is what we want. All this does is inform the caller something went wrong.
+ if (!failedToPurge.isEmpty()) {
+ int totalDeployments = liveDeployment.getResourceDeployments().size();
+ int failedPurges = failedToPurge.size();
+ throw new Exception("Failed to purge [" + failedPurges + "] of [" + totalDeployments
+ + "] remote resource deployments");
+ }
+ return;
+ }
+
+ @Override
+ @RequiredPermission(Permission.MANAGE_SECURITY)
+ // no one should be calling us except overlord
+ public void _finalizePurge(Subject subject, BundleDeployment bundleDeployment,
+ Map<BundleResourceDeployment, String> failedToPurge) throws Exception {
+
+ bundleDeployment = entityManager.find(BundleDeployment.class, bundleDeployment.getId());
+ if (failedToPurge.isEmpty()) {
+ bundleDeployment.setLive(false); // all deployments are purged, no where is this live anymore
+ bundleDeployment.setErrorMessage(null);
+ bundleDeployment.setStatus(BundleDeploymentStatus.SUCCESS);
+ } else {
+ int totalDeployments = bundleDeployment.getResourceDeployments().size();
+ int failedPurges = failedToPurge.size();
+ bundleDeployment.setLive(true); // not all deployments are purged - error indicates it is still live somewhere
+ if (failedPurges < totalDeployments) {
+ bundleDeployment.setStatus(BundleDeploymentStatus.MIXED); // some deployments were purged, so show MIXED status
+ bundleDeployment.setErrorMessage("Failed to purge [" + failedPurges + "] of [" + totalDeployments
+ + "] remote resource deployments");
+ } else {
+ bundleDeployment.setStatus(BundleDeploymentStatus.FAILURE); // all deployments failed to be purged
+ bundleDeployment.setErrorMessage("Failed to purge all [" + failedPurges
+ + "] remote resource deployments");
+ }
+ }
+
+ return;
}
@Override
@@ -1178,10 +1271,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<BundleDeployment> findBundleDeploymentsByCriteria(Subject subject, BundleDeploymentCriteria criteria) {
-
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<BundleDeployment> queryRunner = new CriteriaQueryRunner<BundleDeployment>(criteria,
generator, entityManager);
return queryRunner.execute();
@@ -1191,8 +1281,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
public PageList<BundleDestination> findBundleDestinationsByCriteria(Subject subject,
BundleDestinationCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<BundleDestination> queryRunner = new CriteriaQueryRunner<BundleDestination>(criteria,
generator, entityManager);
return queryRunner.execute();
@@ -1226,8 +1314,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<BundleVersion> findBundleVersionsByCriteria(Subject subject, BundleVersionCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<BundleVersion> queryRunner = new CriteriaQueryRunner<BundleVersion>(criteria, generator,
entityManager);
return queryRunner.execute();
@@ -1236,8 +1322,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<BundleFile> findBundleFilesByCriteria(Subject subject, BundleFileCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<BundleFile> queryRunner = new CriteriaQueryRunner<BundleFile>(criteria, generator,
entityManager);
return queryRunner.execute();
@@ -1246,8 +1330,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<Bundle> findBundlesByCriteria(Subject subject, BundleCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
-
CriteriaQueryRunner<Bundle> queryRunner = new CriteriaQueryRunner<Bundle>(criteria, generator, entityManager);
return queryRunner.execute();
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
index c917d80..3069739 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.bundle;
import java.util.HashMap;
+import java.util.Map;
import javax.ejb.Local;
@@ -186,4 +187,16 @@ public interface BundleManagerLocal extends BundleManagerRemote {
BundleResourceDeployment setBundleResourceDeploymentStatus(Subject subject, int resourceDeploymentId,
BundleDeploymentStatus status) throws Exception;
+ /**
+ * This is for internal use only - when {@link #purgeBundleDestination(Subject, int)} is done, it
+ * calls this so the purge can be finalized. This is required because this method is called with
+ * a transactional context, as opposed to the main purge method.
+ *
+ * @param subject
+ * @param bundleDeployment
+ * @param failedToPurge
+ * @throws Exception
+ */
+ void _finalizePurge(Subject subject, BundleDeployment bundleDeployment,
+ Map<BundleResourceDeployment, String> failedToPurge) throws Exception;
}
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index 4a51bb2..24b6b72 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -140,6 +140,7 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
// Send the diffs to the Server so it can store them as an entry in the deployment history.
BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
DeployDifferences diffs = project.getDeployDifferences();
+ // TODO: put the diffs in the "attachment" area and make it more formatted/legible
bundleManagerProvider.auditDeployment(resourceDeployment, "Deployment Differences", project.getName(),
BundleResourceDeploymentHistory.Category.DEPLOY_STEP, null, diffs.toString(), null);
} catch (Throwable t) {
commit 5e1bc40e55ea854d21833b5cba82bfd82f4964d6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 13 12:39:49 2011 -0500
fix the delete bundle confirmation messages
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index 96ffd49..f4801ea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -231,7 +231,7 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
deleteButton.setIcon("subsystems/bundle/BundleAction_Delete_16.png");
deleteButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- SC.ask(MSG.view_bundle_list_deleteConfirm(), new BooleanCallback() {
+ SC.ask(MSG.view_bundle_deleteConfirm(), new BooleanCallback() {
public void execute(Boolean aBoolean) {
if (aBoolean) {
bundleManager.deleteBundle(bundleBeingViewed, new AsyncCallback<Void>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
index 643d13a..ceb3c30 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
@@ -139,7 +139,7 @@ public class BundlesListView extends Table<RPCDataSource<BundleWithLatestVersion
}
});
- addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
+ addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG.view_bundle_list_deleteConfirm(),
new AbstractTableAction((hasAuth) ? TableActionEnablement.ANY : TableActionEnablement.NEVER) {
public void executeAction(ListGridRecord[] selections, Object actionValue) {
if (selections == null || selections.length == 0) {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 6ca3f92..4322960 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -907,6 +907,7 @@ view_bundle_recipe = Recipe
view_bundle_revert = Revert
view_bundle_purge = Purge
view_bundle_versions = Versions
+view_bundle_deleteConfirm = Are you sure you want to delete this bundle? All versions, destinations and deployments for this bundle will also be deleted.
# individual bundle views/wizards
view_bundle_fileListView_fileSize = File Size
commit b8a69d8b97c64c98e61da530b25be2ea369d0fd2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 13 10:11:05 2011 -0500
BZ 645412 the start of the end-to-end impl of purging bundles from remote platforms
This isn't fully functional yet - there is a main TODO in SLSB BundleManager:
// TODO loop through each deployment and purge it on agent
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java
index 345567f..29e4e47 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -36,4 +36,11 @@ public interface BundleAgentService {
* @return the results of the immediate scheduling
*/
BundleScheduleResponse schedule(BundleScheduleRequest request);
+
+ /**
+ * Purges the live deployment off the local filesystem.
+ * @param request
+ * @return the results of the purge
+ */
+ BundlePurgeResponse purge(BundlePurgeRequest request);
}
\ No newline at end of file
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeRequest.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeRequest.java
new file mode 100644
index 0000000..e1d83f2
--- /dev/null
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeRequest.java
@@ -0,0 +1,57 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, 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.agent.bundle;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.bundle.BundleResourceDeployment;
+
+/**
+ * The request that the server sends down to the agent to purge the live bundle deployment.
+ *
+ * @author John Mazzitelli
+ */
+public class BundlePurgeRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private BundleResourceDeployment resourceDeployment;
+
+ public BundlePurgeRequest(BundleResourceDeployment resourceDeployment) {
+ this.resourceDeployment = resourceDeployment;
+ }
+
+ /**
+ * @return the live resource deployment that is to be purged
+ */
+ public BundleResourceDeployment getLiveBundleResourceDeployment() {
+ return resourceDeployment;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder(this.getClass() + ": ");
+ str.append("live-deployment=[").append(resourceDeployment.toString()).append("]");
+ return str.toString();
+ }
+}
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeResponse.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeResponse.java
new file mode 100644
index 0000000..53db77c
--- /dev/null
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundlePurgeResponse.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, 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.agent.bundle;import java.io.Serializable;
+
+import org.rhq.core.util.exception.ThrowableUtil;
+;
+
+/**
+ * The results of the purge.
+ *
+ * @author John Mazzitelli
+ */
+public class BundlePurgeResponse implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String errorMessage;
+
+ public BundlePurgeResponse() {
+ }
+
+ public boolean isSuccess() {
+ return this.errorMessage == null;
+ }
+
+ public String getErrorMessage() {
+ return this.errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public void setErrorMessage(Throwable t) {
+ this.errorMessage = ThrowableUtil.getAllMessages(t);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder(this.getClass().getSimpleName());
+ if (getErrorMessage() != null) {
+ str.append(" error=[").append(getErrorMessage()).append("];");
+ }
+ str.append(" success=[").append(isSuccess()).append("]");
+ return str.toString();
+ }
+}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java
index 2b76c0c..592e63f 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java
@@ -29,4 +29,6 @@ package org.rhq.core.pluginapi.bundle;
*/
public interface BundleFacet {
BundleDeployResult deployBundle(BundleDeployRequest request);
+
+ BundlePurgeResult purgeBundle(BundlePurgeRequest request);
}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeRequest.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeRequest.java
new file mode 100644
index 0000000..6f41339
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeRequest.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.pluginapi.bundle;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.bundle.BundleResourceDeployment;
+
+/**
+ * A request to purge a bundle, essentially erasing the bundle files from the destination.
+ *
+ * @author John Mazzitelli
+ */
+public class BundlePurgeRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private BundleResourceDeployment resourceDeployment;
+ private BundleManagerProvider bundleManagerProvider;
+
+ public BundlePurgeRequest() {
+ }
+
+ /**
+ * This is information about the last known live resource deployment - this is to be purged.
+ *
+ * @return information about the live resource deployment that is to be purged
+ */
+ public BundleResourceDeployment getLiveResourceDeployment() {
+ return resourceDeployment;
+ }
+
+ public void setLiveResourceDeployment(BundleResourceDeployment resourceDeployment) {
+ this.resourceDeployment = resourceDeployment;
+ }
+
+ public BundleManagerProvider getBundleManagerProvider() {
+ return this.bundleManagerProvider;
+ }
+
+ public void setBundleManagerProvider(BundleManagerProvider provider) {
+ this.bundleManagerProvider = provider;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder(this.getClass() + ": ");
+ str.append("live-deployment-to-be-purge=[").append(resourceDeployment.toString()).append("], ");
+ return str.toString();
+ }
+}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeResult.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeResult.java
new file mode 100644
index 0000000..71e0dfb
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundlePurgeResult.java
@@ -0,0 +1,65 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, 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.pluginapi.bundle;
+
+import java.io.Serializable;
+
+import org.rhq.core.util.exception.ThrowableUtil;
+
+/**
+ * The results after an attempt to purge a bundle has been completed.
+ *
+ * @author John Mazzitelli
+ */
+public class BundlePurgeResult implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String errorMessage;
+
+ public boolean isSuccess() {
+ return this.errorMessage == null;
+ }
+
+ public String getErrorMessage() {
+ return this.errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public void setErrorMessage(Throwable t) {
+ this.errorMessage = ThrowableUtil.getAllMessages(t);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder(this.getClass().getSimpleName());
+ if (getErrorMessage() != null) {
+ str.append(" error=[").append(getErrorMessage()).append("];");
+ }
+ str.append(" success=[").append(isSuccess()).append("]");
+ return str.toString();
+ }
+
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index 8f1525b..b945ff1 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -37,6 +37,8 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeRequest;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeResponse;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleRequest;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleResponse;
import org.rhq.core.clientapi.server.bundle.BundleServerService;
@@ -46,6 +48,7 @@ import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Status;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -62,6 +65,7 @@ import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
+import org.rhq.core.pluginapi.bundle.BundlePurgeResult;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -81,6 +85,9 @@ public class BundleManager extends AgentService implements BundleAgentService, B
private final String AUDIT_FILE_DOWNLOAD_ENDED = "File Download Started";
private final String AUDIT_FILE_DOWNLOAD_STARTED = "File Download Started";
+ private final String AUDIT_PURGE_STARTED = "Purge Started";
+ private final String AUDIT_PURGE_ENDED = "Purge Ended";
+
private PluginContainerConfiguration configuration;
private ExecutorService deployerThreadPool;
@@ -126,6 +133,7 @@ public class BundleManager extends AgentService implements BundleAgentService, B
return size;
}
+ @Override
public BundleScheduleResponse schedule(final BundleScheduleRequest request) {
final BundleScheduleResponse response = new BundleScheduleResponse();
@@ -207,6 +215,58 @@ public class BundleManager extends AgentService implements BundleAgentService, B
return response;
}
+ @Override
+ public BundlePurgeResponse purge(BundlePurgeRequest request) {
+ final BundlePurgeResponse response = new BundlePurgeResponse();
+
+ try {
+ final BundleResourceDeployment resourceDeployment = request.getLiveBundleResourceDeployment();
+ final BundleDeployment bundleDeployment = resourceDeployment.getBundleDeployment();
+
+ // find the resource that will purge the bundle
+ InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+ BundleType bundleType = bundleDeployment.getBundleVersion().getBundle().getBundleType();
+ ResourceType resourceType = bundleType.getResourceType();
+ Set<Resource> resources = im.getResourcesWithType(resourceType);
+ if (resources.isEmpty()) {
+ throw new Exception("No bundle plugin supports bundle type [" + bundleType + "]");
+ }
+ final int bundleHandlerResourceId = resources.iterator().next().getId();
+ final ResourceContainer resourceContainer = im.getResourceContainer(bundleHandlerResourceId);
+ if (null == resourceContainer.getResourceContext()) {
+ throw new Exception("No bundle plugin resource available to handle purge for bundle type ["
+ + bundleType
+ + "]. Ensure the bundle plugin is deployed and its resource is imported into inventory.");
+ }
+
+ // purge the bundle utilizing the bundle facet object
+ String deploymentMessage = "Deployment [" + bundleDeployment + "] to be purged via ["
+ + resourceDeployment.getResource() + "]";
+ auditDeployment(resourceDeployment, AUDIT_PURGE_STARTED, bundleDeployment.getName(), deploymentMessage);
+
+ org.rhq.core.pluginapi.bundle.BundlePurgeRequest purgeRequest = new org.rhq.core.pluginapi.bundle.BundlePurgeRequest();
+ purgeRequest.setBundleManagerProvider(this);
+ purgeRequest.setLiveResourceDeployment(resourceDeployment);
+
+ // get the bundle facet object that will process the bundle and call it to start the purge
+ int facetMethodTimeout = 30 * 60 * 1000; // 30 minutes should be enough time for the bundle plugin to purge everything
+ BundleFacet bundlePluginComponent = getBundleFacet(bundleHandlerResourceId, facetMethodTimeout);
+ BundlePurgeResult result = bundlePluginComponent.purgeBundle(purgeRequest);
+ if (result.isSuccess()) {
+ auditDeployment(resourceDeployment, AUDIT_PURGE_ENDED, bundleDeployment.getName(), deploymentMessage);
+ } else {
+ response.setErrorMessage(result.getErrorMessage());
+ auditDeployment(resourceDeployment, AUDIT_PURGE_ENDED, bundleDeployment.getName(), null,
+ Status.FAILURE, "Failed: " + deploymentMessage, result.getErrorMessage());
+ }
+ } catch (Throwable t) {
+ log.error("Failed to purge bundle: " + request, t);
+ response.setErrorMessage(t);
+ }
+
+ return response;
+ }
+
/**
* convenience method:<br/>
* category defaults to null<br/>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index 324b510..d471742 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -189,11 +189,47 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
revertButton.setIcon("subsystems/bundle/BundleAction_Revert_16.png");
revertButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- new BundleRevertWizard(destination).startWizard();
+ SC.ask(MSG.view_bundle_dest_revertConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ new BundleRevertWizard(destination).startWizard();
+ }
+ }
+ });
}
});
actionLayout.addMember(revertButton);
+ IButton purgeButton = new LocatableIButton(actionLayout.extendLocatorId("Purge"), MSG.view_bundle_purge());
+ purgeButton.setIcon("subsystems/bundle/BundleDestinationAction_Purge_16.png");
+ purgeButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ SC.ask(MSG.view_bundle_dest_purgeConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ bundleService.purgeBundleDestination(destination.getId(), new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_bundle_dest_purgeFailure(destination.getName()), caught);
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_bundle_dest_purgeSuccessful(destination.getName()),
+ Message.Severity.Info));
+ // Bundle destination is purged, go back to bundle destinations root view
+ CoreGUI.goToView(LinkManager.getBundleDestinationLink(bundle.getId(), 0));
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ actionLayout.addMember(purgeButton);
+
IButton deleteButton = new LocatableIButton(actionLayout.extendLocatorId("Delete"), MSG.common_button_delete());
deleteButton.setIcon("subsystems/bundle/BundleDestinationAction_Delete_16.png");
deleteButton.addClickHandler(new ClickHandler() {
@@ -212,7 +248,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_bundle_dest_deleteSuccessful(destination.getName()),
Message.Severity.Info));
- // Bundle destination is deleted, go back to main bundle view
+ // Bundle destination is deleted, go back to bundle destinations root view
CoreGUI.goToView(LinkManager.getBundleDestinationLink(bundle.getId(), 0), true);
}
});
@@ -226,6 +262,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
if (!canManageBundles) {
deployButton.setDisabled(true);
revertButton.setDisabled(true);
+ purgeButton.setDisabled(true);
deleteButton.setDisabled(true);
}
@@ -264,4 +301,4 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
});
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
index 4c7b209..79166ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
@@ -96,4 +96,5 @@ public interface BundleGWTService extends RemoteService {
BundleDeployment scheduleRevertBundleDeployment(int bundleDestinationId, String deploymentDescription,
boolean isCleanDeployment) throws RuntimeException;
+ void purgeBundleDestination(int bundleDestinationId) throws RuntimeException;
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
index 4049454..daf457d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
@@ -266,4 +266,12 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
+
+ public void purgeBundleDestination(int bundleDestinationId) throws RuntimeException {
+ try {
+ bundleManager.purgeBundleDestination(getSessionSubject(), bundleDestinationId);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index acfd5e2..6ca3f92 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -905,6 +905,7 @@ view_bundle_files = Files
view_bundle_latestVersion = Latest Version
view_bundle_recipe = Recipe
view_bundle_revert = Revert
+view_bundle_purge = Purge
view_bundle_versions = Versions
# individual bundle views/wizards
@@ -970,7 +971,11 @@ view_bundle_dest_loadFailureVersionInfo = Failed to load bundle destination depl
view_bundle_dest_backToBundle = Back to Bundle
view_bundle_dest_tagUpdateFailure = Failed to update bundle destination tags
view_bundle_dest_tagUpdateSuccessful = You have successfully updated the bundle destination tags
-view_bundle_dest_deleteConfirm = Are you sure you want to delete this bundle destination?
+view_bundle_dest_purgeConfirm = This will purge the bundle content from all remote machines. Are you sure you want to do this?
+view_bundle_dest_purgeFailure = Failed to purge the bundle destination [{0}] from some or all of the remote machines.
+view_bundle_dest_purgeSuccessful = You successfully purged the bundle destination [{0}] from all of the remote machines.
+view_bundle_dest_revertConfirm = This will revert all remote machines back to the previous bundle deployment. Are you sure you want to do this?
+view_bundle_dest_deleteConfirm = Are you sure you want to delete this bundle destination? This only deletes it from the database; all bundle content that was deployed to this destination on remote machines will remain.
view_bundle_dest_deleteFailure = Failed to delete the bundle destination [{0}]
view_bundle_dest_deleteSuccessful = You successfully deleted the bundle destination [{0}]
view_bundle_resDeployDS_loadFailure = Failed to load bundle resource deployments
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16.png
new file mode 100644
index 0000000..c370e20
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16_Disabled.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16_Disabled.png
new file mode 100644
index 0000000..7647069
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Purge_16_Disabled.png differ
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index 25ff496..0f99049 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -142,6 +142,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@EJB
private ResourceGroupManagerLocal resourceGroupManager;
+ @Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleResourceDeploymentHistory addBundleResourceDeploymentHistory(Subject subject, int bundleDeploymentId,
@@ -159,6 +160,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return history;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public Bundle createBundle(Subject subject, String name, String description, int bundleTypeId) throws Exception {
if (null == name || "".equals(name.trim())) {
@@ -201,6 +203,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundle;
}
+ @Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment createBundleDeploymentInNewTrans(Subject subject, int bundleVersionId,
@@ -218,6 +221,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return createBundleDeploymentImpl(subject, bundleVersion, bundleDestination, name, description, configuration);
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment createBundleDeployment(Subject subject, int bundleVersionId, int bundleDestinationId,
String description, Configuration configuration) throws Exception {
@@ -262,6 +266,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return deployment;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDestination createBundleDestination(Subject subject, int bundleId, String name, String description,
String deployDir, Integer groupId) throws Exception {
@@ -289,6 +294,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return dest;
}
+ @Override
public String getBundleDeploymentName(Subject subject, int bundleDestinationId, int bundleVersionId,
int prevDeploymentId) {
BundleDestination bundleDestination = entityManager.find(BundleDestination.class, bundleDestinationId);
@@ -367,6 +373,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return deploymentName;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleType createBundleType(Subject subject, String name, int resourceTypeId) throws Exception {
if (null == name || "".equals(name.trim())) {
@@ -383,6 +390,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleType;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleVersion createBundleAndBundleVersion(Subject subject, String bundleName, String bundleDescription,
int bundleTypeId, String bundleVersionName, String bundleVersionDescription, String version, String recipe)
@@ -406,6 +414,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bv;
}
+ @Override
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleVersion createBundleVersion(Subject subject, int bundleId, String name, String description,
@@ -476,6 +485,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleVersion;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleVersion createBundleVersionViaRecipe(Subject subject, String recipe) throws Exception {
@@ -486,6 +496,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleVersion;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
@TransactionAttribute(TransactionAttributeType.NEVER)
public BundleVersion createBundleVersionViaFile(Subject subject, File distributionFile) throws Exception {
@@ -497,6 +508,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleVersion;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
@TransactionAttribute(TransactionAttributeType.NEVER)
public BundleVersion createBundleVersionViaURL(Subject subject, String distributionFileUrl) throws Exception {
@@ -659,6 +671,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return newVersion;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFile(Subject subject, int bundleVersionId, String name, String version,
Architecture architecture, InputStream fileStream) throws Exception {
@@ -716,6 +729,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleFile;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFileViaByteArray(Subject subject, int bundleVersionId, String name, String version,
Architecture architecture, byte[] fileBytes) throws Exception {
@@ -723,6 +737,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return addBundleFile(subject, bundleVersionId, name, version, architecture, new ByteArrayInputStream(fileBytes));
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFileViaURL(Subject subject, int bundleVersionId, String name, String version,
Architecture architecture, String bundleFileUrl) throws Exception {
@@ -733,6 +748,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return addBundleFile(subject, bundleVersionId, name, version, architecture, url.openStream());
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFileViaPackageVersion(Subject subject, int bundleVersionId, String name,
int packageVersionId) throws Exception {
@@ -760,12 +776,35 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleFile;
}
+ @Override
+ @RequiredPermission(Permission.MANAGE_BUNDLE)
+ public void purgeBundleDestination(Subject subject, int bundleDestinationId) throws Exception {
+ BundleDeploymentCriteria c = new BundleDeploymentCriteria();
+ c.addFilterDestinationId(bundleDestinationId);
+ c.addFilterIsLive(true);
+ c.fetchBundleVersion(true);
+ c.fetchResourceDeployments(true);
+ c.fetchDestination(true);
+ List<BundleDeployment> liveDeployments = bundleManager.findBundleDeploymentsByCriteria(subject, c);
+ if (1 != liveDeployments.size()) {
+ throw new IllegalArgumentException("No live deployment to purge is found for destinationId ["
+ + bundleDestinationId + "]");
+ }
+ BundleDeployment liveDeployment = liveDeployments.get(0);
+ BundleDestination destination = liveDeployment.getDestination();
+ List<BundleResourceDeployment> resourceDeploys = liveDeployment.getResourceDeployments();
+
+ // TODO loop through each deployment and purge it on agent
+ }
+
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment scheduleBundleDeployment(Subject subject, int bundleDeploymentId, boolean isCleanDeployment)
throws Exception {
return scheduleBundleDeploymentImpl(subject, bundleDeploymentId, isCleanDeployment, false);
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment scheduleRevertBundleDeployment(Subject subject, int bundleDestinationId,
String deploymentDescription, boolean isCleanDeployment) throws Exception {
@@ -920,6 +959,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return resourceDeployment;
}
+ @Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleScheduleRequest getScheduleRequest(Subject subject, int resourceDeploymentId,
@@ -971,6 +1011,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return request;
}
+ @Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleResourceDeployment createBundleResourceDeployment(Subject subject, int bundleDeploymentId,
@@ -991,6 +1032,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return resourceDeployment;
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleResourceDeployment setBundleResourceDeploymentStatus(Subject subject, int resourceDeploymentId,
BundleDeploymentStatus status) throws Exception {
@@ -1042,6 +1084,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// return groupDeployment;
//}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public Set<String> getBundleVersionFilenames(Subject subject, int bundleVersionId, boolean withoutBundleFileOnly)
throws Exception {
@@ -1081,6 +1124,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public HashMap<String, Boolean> getAllBundleVersionFilenames(Subject subject, int bundleVersionId) throws Exception {
@@ -1114,6 +1158,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
+ @Override
@SuppressWarnings("unchecked")
public List<BundleType> getAllBundleTypes(Subject subject) {
// the list of types will be small, no need to support paging
@@ -1122,6 +1167,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return types;
}
+ @Override
public BundleType getBundleType(Subject subject, String bundleTypeName) {
// the list of types will be small, no need to support paging
Query q = entityManager.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
@@ -1130,6 +1176,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return type;
}
+ @Override
public PageList<BundleDeployment> findBundleDeploymentsByCriteria(Subject subject, BundleDeploymentCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
@@ -1140,6 +1187,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleDestination> findBundleDestinationsByCriteria(Subject subject,
BundleDestinationCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
@@ -1150,6 +1198,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleResourceDeployment> findBundleResourceDeploymentsByCriteria(Subject subject,
BundleResourceDeploymentCriteria criteria) {
@@ -1174,6 +1223,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleVersion> findBundleVersionsByCriteria(Subject subject, BundleVersionCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
;
@@ -1183,6 +1233,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleFile> findBundleFilesByCriteria(Subject subject, BundleFileCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
;
@@ -1192,6 +1243,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<Bundle> findBundlesByCriteria(Subject subject, BundleCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
;
@@ -1200,6 +1252,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
+ @Override
public PageList<BundleWithLatestVersionComposite> findBundlesWithLatestVersionCompositesByCriteria(Subject subject,
BundleCriteria criteria) {
@@ -1222,6 +1275,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// to avoid deadlocks, you cannot delete multiple bundles concurrently (see BZ 606530)
// instead, this simple method just loops over the given array and deletes them serially
// note they all get deleted in their own transaction; this method is never in a tx itself
+ @Override
@TransactionAttribute(TransactionAttributeType.NEVER)
public void deleteBundles(Subject subject, int[] bundleIds) throws Exception {
if (bundleIds != null) {
@@ -1231,6 +1285,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
}
+ @Override
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundle(Subject subject, int bundleId) throws Exception {
@@ -1257,6 +1312,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
repoManager.deleteRepo(subjectManager.getOverlord(), bundleRepo.getId());
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundleDeployment(Subject subject, int bundleDeploymentId) throws Exception {
BundleDeployment doomed = this.entityManager.find(BundleDeployment.class, bundleDeploymentId);
@@ -1273,6 +1329,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundleDestination(Subject subject, int destinationId) throws Exception {
BundleDestination doomed = this.entityManager.find(BundleDestination.class, destinationId);
@@ -1292,6 +1349,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
entityManager.remove(doomed);
}
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundleVersion(Subject subject, int bundleVersionId, boolean deleteBundleIfEmpty) throws Exception {
BundleVersion bundleVersion = this.entityManager.find(BundleVersion.class, bundleVersionId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
index e8fdd8f..231d4c3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
@@ -330,6 +330,17 @@ public interface BundleManagerRemote {
*/
/**
+ * Purges the destination's live deployment content from the remote platforms.
+ *
+ * @param subject user that must have proper permissions
+ * @param bundleDestinationId the ID of the destination that is to be purged of bundle content
+ */
+ @WebMethod
+ void purgeBundleDestination( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "bundleDestinationId") int bundleDestinationId) throws Exception;
+
+ /**
* Deploy the bundle to the destination, as described in the provided deployment.
* Deployment is asynchronous so return of this method does not indicate individual resource deployments are
* complete. The returned BundleDeployment can be used to track the history of the individual deployments.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 484a751..056582f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -374,6 +374,10 @@ public class WebservicesManagerBean implements WebservicesRemote {
isCleanDeployment);
}
+ public void purgeBundleDestination(Subject subject, int bundleDestinationId) throws Exception {
+ bundleManager.purgeBundleDestination(subject, bundleDestinationId);
+ }
+
//BUNDLEMANAGER: END ----------------------------------
//CALLTIMEDATAMANAGER: BEGIN ----------------------------------
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
index 2c08880..aa221f9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
@@ -25,6 +25,8 @@ import java.util.Set;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeRequest;
+import org.rhq.core.clientapi.agent.bundle.BundlePurgeResponse;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleRequest;
import org.rhq.core.clientapi.agent.bundle.BundleScheduleResponse;
import org.rhq.core.clientapi.agent.configuration.ConfigurationAgentService;
@@ -55,7 +57,6 @@ import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
import org.rhq.core.domain.measurement.Availability;
-import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDataRequest;
import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest;
@@ -75,201 +76,248 @@ public class TestAgentClient implements AgentClient, BundleAgentService, Content
this.commService = commService;
}
+ @Override
public Agent getAgent() {
return this.agent;
}
+ @Override
public BundleAgentService getBundleAgentService() {
return (commService.bundleService != null) ? commService.bundleService : this;
}
+ @Override
public ContentAgentService getContentAgentService() {
return (commService.contentService != null) ? commService.contentService : this;
}
+ @Override
public ResourceFactoryAgentService getResourceFactoryAgentService() {
return (commService.resourceFactoryService != null) ? commService.resourceFactoryService : this;
}
+ @Override
public ConfigurationAgentService getConfigurationAgentService() {
return (commService.configurationService != null) ? commService.configurationService : this;
}
+ @Override
public DiscoveryAgentService getDiscoveryAgentService() {
return (commService.discoveryService != null) ? commService.discoveryService : this;
}
+ @Override
public MeasurementAgentService getMeasurementAgentService() {
return (commService.measurementService != null) ? commService.measurementService : this;
}
+ @Override
public OperationAgentService getOperationAgentService() {
return (commService.operationService != null) ? commService.operationService : this;
}
+ @Override
public SupportAgentService getSupportAgentService() {
return (commService.supportService != null) ? commService.supportService : this;
}
+ @Override
public void startSending() {
return; // no-op
}
+ @Override
public void stopSending() {
return; // no-op
}
+ @Override
public boolean ping(long timeoutMillis) {
return true;
}
// provide no-ops for all agent services
-
+ @Override
public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, List<MeasurementDataRequest> requests) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
+ @Override
public void scheduleCollection(Set<ResourceMeasurementScheduleRequest> resourceSchedules) {
}
+ @Override
public void unscheduleCollection(Set<Integer> resourceIds) {
}
+ @Override
public void updateCollection(Set<ResourceMeasurementScheduleRequest> resourceSchedules) {
}
+ @Override
public Map<String, Object> getMeasurementScheduleInfoForResource(int resourceId) {
return null;
}
+ @Override
public ConfigurationUpdateResponse executeUpdateResourceConfigurationImmediately(ConfigurationUpdateRequest request)
throws PluginContainerException {
return null;
}
+ @Override
public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException {
return null;
}
- public Configuration loadResourceConfiguration(int resourceId, boolean fromStructured)
- throws PluginContainerException {
- return null;
- }
-
+ @Override
public Configuration merge(Configuration configuration, int resourceId, boolean fromStructured)
throws PluginContainerException {
return null;
}
+ @Override
public void updateResourceConfiguration(ConfigurationUpdateRequest request) {
}
+ @Override
public CancelResults cancelOperation(String jobId) {
return null;
}
+ @Override
public void invokeOperation(String jobId, int resourceId, String operationName, Configuration parameters)
throws PluginContainerException {
}
+ @Override
public void deletePackages(DeletePackagesRequest request) {
}
+ @Override
public void deployPackages(DeployPackagesRequest request) {
}
+ @Override
public ContentDiscoveryReport executeResourcePackageDiscoveryImmediately(int resourceId, String packageTypeName)
throws PluginContainerException {
return null;
}
+ @Override
public Set<ResourcePackageDetails> getLastDiscoveredResourcePackages(int resourceId) {
return null;
}
+ @Override
public void retrievePackageBits(RetrievePackageBitsRequest request) {
}
+ @Override
public List<DeployPackageStep> translateInstallationSteps(int resourceId, ResourcePackageDetails packageDetails)
throws PluginContainerException {
return null;
}
+ @Override
public void disableServiceScans(int serverResourceId) {
}
+ @Override
public void enableServiceScans(int serverResourceId, Configuration config) {
}
+ @Override
public AvailabilityReport executeAvailabilityScanImmediately(boolean changedOnlyReport) {
return null;
}
+ @Override
public InventoryReport executeServerScanImmediately() throws PluginContainerException {
return null;
}
+ @Override
public InventoryReport executeServiceScanImmediately() throws PluginContainerException {
return null;
}
+ @Override
public void executeServiceScanDeferred() {
return;
}
+ @Override
public Availability getCurrentAvailability(Resource resource) {
return null;
}
+ @Override
public Resource getPlatform() {
return null;
}
+ @Override
public MergeResourceResponse manuallyAddResource(ResourceType resourceType, int parentResourceId,
Configuration pluginConfiguration, int creatorSubjectId) throws InvalidPluginConfigurationClientException,
PluginContainerException {
return null;
}
+ @Override
public void uninventoryResource(int resourceId) {
}
+ @Override
public void updatePluginConfiguration(int resourceId, Configuration newPluginConfiguration)
throws InvalidPluginConfigurationClientException, PluginContainerException {
}
@Asynchronous(guaranteedDelivery = true)
+ @Override
public void synchronizeInventory(ResourceSyncInfo syncInfo) {
return;
}
+ @Override
public void createResource(CreateResourceRequest request) throws PluginContainerException {
}
+ @Override
public void deleteResource(DeleteResourceRequest request) throws PluginContainerException {
}
+ @Override
public CreateResourceResponse executeCreateResourceImmediately(CreateResourceRequest request)
throws PluginContainerException {
return null;
}
+ @Override
public DeleteResourceResponse executeDeleteResourceImmediately(DeleteResourceRequest request)
throws PluginContainerException {
return null;
}
+ @Override
public InputStream getSnapshotReport(int resourceId, String name, String description) throws Exception {
return null;
}
+ @Override
public Configuration validate(Configuration configuration, int resourceId, boolean isStructured)
throws PluginContainerException {
return null;
}
+ @Override
public BundleScheduleResponse schedule(BundleScheduleRequest request) {
return new BundleScheduleResponse();
}
+
+ @Override
+ public BundlePurgeResponse purge(BundlePurgeRequest request) {
+ return new BundlePurgeResponse();
+ }
}
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index 51098ea..4a51bb2 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -43,6 +43,8 @@ import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Category;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Status;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -51,9 +53,12 @@ import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
+import org.rhq.core.pluginapi.bundle.BundlePurgeRequest;
+import org.rhq.core.pluginapi.bundle.BundlePurgeResult;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.system.SystemInfoFactory;
+import org.rhq.core.util.file.FileUtil;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.core.util.updater.DeployDifferences;
import org.rhq.core.util.updater.DeploymentsMetadata;
@@ -160,6 +165,38 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
return result;
}
+ // TODO: this is copied from FileTemplate bundle plugin - I think we want to be more smart here since
+ // we have more metadata about the live deployment to be purged in our .rhqdeployments (specifically about
+ // the external raw files that we should delete)
+ public BundlePurgeResult purgeBundle(BundlePurgeRequest request) {
+ BundlePurgeResult result = new BundlePurgeResult();
+ try {
+ BundleResourceDeployment deploymentToPurge = request.getLiveResourceDeployment();
+ BundleDeployment bundleDeployment = deploymentToPurge.getBundleDeployment();
+ File deployDir = new File(bundleDeployment.getDestination().getDeployDir());
+ String deployDirAbsolutePath = deployDir.getAbsolutePath();
+ BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
+
+ // completely purge the deployment directory.
+ // TODO: if the receipe copied a file outside of the deployment directory, it will still exist. How do we remove those?
+ FileUtil.purge(deployDir, true);
+
+ if (!deployDir.exists()) {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory has been purged", Category.AUDIT_MESSAGE, Status.SUCCESS,
+ "Directory purged: " + deployDirAbsolutePath, null);
+ } else {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE,
+ "The directory that failed to be purged: " + deployDirAbsolutePath, null);
+ }
+ } catch (Throwable t) {
+ log.error("Failed to purge bundle [" + request + "]", t);
+ result.setErrorMessage(t);
+ }
+ return result;
+ }
+
private BundleAntProject executeDeploymentPhase(File recipeFile, Properties antProps,
List<BuildListener> buildListeners, DeploymentPhase phase) throws InvalidBuildFileException {
AntLauncher antLauncher = new AntLauncher();
diff --git a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
index 0b96612..940a01e 100644
--- a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
+++ b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
@@ -27,14 +27,19 @@ import org.rhq.bundle.filetemplate.recipe.RecipeParser;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Category;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Status;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
+import org.rhq.core.pluginapi.bundle.BundlePurgeRequest;
+import org.rhq.core.pluginapi.bundle.BundlePurgeResult;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.util.FileUtils;
+import org.rhq.core.util.file.FileUtil;
/**
* @author John Mazzitelli
@@ -120,4 +125,33 @@ public class FileTemplateBundlePluginServerComponent implements ResourceComponen
return result;
}
+
+ public BundlePurgeResult purgeBundle(BundlePurgeRequest request) {
+ BundlePurgeResult result = new BundlePurgeResult();
+ try {
+ BundleResourceDeployment deploymentToPurge = request.getLiveResourceDeployment();
+ BundleDeployment bundleDeployment = deploymentToPurge.getBundleDeployment();
+ File deployDir = new File(bundleDeployment.getDestination().getDeployDir());
+ String deployDirAbsolutePath = deployDir.getAbsolutePath();
+ BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
+
+ // completely purge the deployment directory.
+ // TODO: if the receipe copied a file outside of the deployment directory, it will still exist. How do we remove those?
+ FileUtil.purge(deployDir, true);
+
+ if (!deployDir.exists()) {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory has been purged", Category.AUDIT_MESSAGE, Status.SUCCESS,
+ "Directory purged: " + deployDirAbsolutePath, null);
+ } else {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE,
+ "The directory that failed to be purged: " + deployDirAbsolutePath, null);
+ }
+ } catch (Throwable t) {
+ log.error("Failed to purge bundle [" + request + "]", t);
+ result.setErrorMessage(t);
+ }
+ return result;
+ }
}
13 years, 4 months
[rhq] 2 commits - modules/core modules/enterprise
by ips
modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java | 11
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java | 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 31
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java | 632 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java | 121 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java | 125 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java | 36
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 11
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java | 20
16 files changed, 868 insertions(+), 213 deletions(-)
New commits:
commit f05066c5da6e3579c8a3b81bd2a754c5cdb59daa
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Jan 12 17:38:37 2011 -0500
add Next Fire Time field to op schedule list and details views; improve validation of start and end times on op schedule details view; various other improvements and fixes to Resource Operations > Schedule subtab
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java
index 70f6a36..da52024 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java
@@ -19,6 +19,7 @@
package org.rhq.core.domain.operation.bean;
import java.io.Serializable;
+import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -39,6 +40,7 @@ import org.rhq.core.domain.operation.JobId;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class OperationSchedule implements Serializable {
+
private static final long serialVersionUID = 1L;
private int id;
@@ -50,6 +52,7 @@ public abstract class OperationSchedule implements Serializable {
private Subject subject;
private String description;
private JobTrigger jobTrigger;
+ private Date nextFireTime;
public OperationSchedule() {
}
@@ -143,6 +146,14 @@ public abstract class OperationSchedule implements Serializable {
this.jobTrigger = jobTrigger;
}
+ public Date getNextFireTime() {
+ return nextFireTime;
+ }
+
+ public void setNextFireTime(Date nextFireTime) {
+ this.nextFireTime = nextFireTime;
+ }
+
/**
* The single job ID which identifies the operation. It can later be parsed via {@link JobId#JobId(String)}. Note
* that this job ID only identifies the scheduled operation; it does not identify any specific invocation of that
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
index 4fc86f8..efcf37e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
@@ -20,6 +20,7 @@
package org.rhq.enterprise.gui.coregui.client.components.trigger;
import java.util.Date;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -46,6 +47,8 @@ import com.smartgwt.client.widgets.form.validator.RegExpValidator;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
import org.rhq.core.domain.common.JobTrigger;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -775,12 +778,42 @@ public class JobTriggerEditor extends LocatableVLayout {
}
public boolean validate() {
+ // TODO (ips, 01/12/11): Use custom validators to do the startTime / endTime validation instead of the code
+ // below; that way field-specific validation errors will be used, rather than messages in
+ // the message bar.
boolean isValid = true;
+ Date currentTime = new Date();
+ Date startTime = getStartTime();
+ Date endTime = getEndTime();
if (this.isStartLater) {
isValid = isValid && this.laterForm.validate();
+ if (startTime != null) {
+ if (startTime.before(currentTime)) {
+ Message message = new Message("Start time must be in the future.", Message.Severity.Error,
+ EnumSet.of(Message.Option.Transient));
+ CoreGUI.getMessageCenter().notify(message);
+ isValid = false;
+ }
+ if (this.isRecurring && endTime != null) {
+ if (endTime.before(startTime)) {
+ Message message = new Message("End time must be after start time.", Message.Severity.Error,
+ EnumSet.of(Message.Option.Transient));
+ CoreGUI.getMessageCenter().notify(message);
+ isValid = false;
+ }
+ }
+ }
}
if (this.isRecurring) {
isValid = isValid && this.repeatForm.validate();
+ if (endTime != null) {
+ if (endTime.before(currentTime)) {
+ Message message = new Message("End time must be in the future.", Message.Severity.Error,
+ EnumSet.of(Message.Option.Transient));
+ CoreGUI.getMessageCenter().notify(message);
+ isValid = false;
+ }
+ }
}
return isValid;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
index 024f1e6..ec95731 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
@@ -26,12 +26,12 @@ import java.util.Set;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.apache.tools.ant.types.selectors.TypeSelector;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
@@ -56,6 +56,7 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
public static final String PARAMETERS = "parameters";
public static final String SUBJECT = "subject";
public static final String DESCRIPTION = "description";
+ public static final String NEXT_FIRE_TIME = "nextFireTime";
// job trigger fields
public static final String START_TIME = "startTime";
@@ -86,10 +87,12 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
idField.setCanEdit(false);
fields.add(idField);
- DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME, "Operation Name", null, 100, true);
+ DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME, "Operation Name", null, 100,
+ true);
fields.add(operationNameField);
- DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, "Operation", null, 100, true);
+ DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, "Operation", null,
+ 100, true);
fields.add(operationDisplayNameField);
Set<OperationDefinition> operationDefinitions = this.resourceType.getOperationDefinitions();
@@ -106,6 +109,10 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION, "Notes", null, 100, false);
fields.add(descriptionField);
+ DataSourceDateTimeField nextFireTimeField = new DataSourceDateTimeField(Field.NEXT_FIRE_TIME,
+ "Next Scheduled Execution");
+ nextFireTimeField.setCanEdit(false);
+
return fields;
}
@@ -124,6 +131,7 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
to.setOperationName(from.getAttribute(Field.OPERATION_NAME));
to.setOperationDisplayName(from.getAttribute(Field.OPERATION_DISPLAY_NAME));
to.setDescription(from.getAttribute(Field.DESCRIPTION));
+ to.setNextFireTime(from.getAttributeAsDate(Field.NEXT_FIRE_TIME));
to.setJobTrigger(createJobTrigger(from.getAttributeAsRecord("jobTrigger")));
@@ -143,6 +151,7 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
to.setAttribute(Field.OPERATION_NAME, from.getOperationName());
to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
to.setAttribute(Field.DESCRIPTION, from.getDescription());
+ to.setAttribute(Field.NEXT_FIRE_TIME, from.getNextFireTime());
JobTrigger jobTrigger = from.getJobTrigger();
Record jobTriggerRecord = new ListGridRecord();
@@ -206,11 +215,11 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
return jobTrigger;
}
- public class SubjectRecord extends ListGridRecord {
+ public static class SubjectRecord extends ListGridRecord {
static final String FIELD_ID = "id";
static final String FIELD_NAME = "name";
- SubjectRecord(Subject subject) {
+ public SubjectRecord(Subject subject) {
setAttribute(FIELD_ID, subject.getId());
setAttribute(FIELD_NAME, subject.getName());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
index 71d943e..3d8fd6d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
@@ -43,16 +43,19 @@ public abstract class OperationScheduleListView extends TableSection<OperationSc
protected void configureTable() {
super.configureTable();
- ListGridField operationField = new ListGridField(OperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME, 150);
+ ListGridField operationField = new ListGridField(OperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME, 180);
- ListGridField subjectField = new ListGridField(OperationScheduleDataSource.Field.SUBJECT, 150);
+ ListGridField subjectField = new ListGridField(OperationScheduleDataSource.Field.SUBJECT, 110);
subjectField.setCellFormatter(new SubjectRecordCellFormatter());
//ListGridField jobTriggerField = new ListGridField(OperationScheduleDataSource.Field.JOB_TRIGGER, 300);
+ ListGridField nextFireTimeField = new ListGridField(OperationScheduleDataSource.Field.NEXT_FIRE_TIME,
+ "Next Scheduled Execution", 190);
+
ListGridField descriptionField = new ListGridField(OperationScheduleDataSource.Field.DESCRIPTION);
- setListGridFields(operationField, subjectField, descriptionField);
+ setListGridFields(operationField, subjectField, nextFireTimeField, descriptionField);
addTableAction(extendLocatorId("New"), MSG.common_button_new(), new TableAction() {
public boolean isEnabled(ListGridRecord[] selection) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
index f7362ad..bc405b1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
@@ -138,10 +138,22 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
this.notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"), isReadOnly(),
isNewRecord());
this.notesForm.setWidth100();
+
+ List<FormItem> notesFields = new ArrayList<FormItem>();
+
+ if (!isNewRecord()) {
+ StaticTextItem nextFireTimeItem = new StaticTextItem(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME,
+ "Next Scheduled Execution");
+ notesFields.add(nextFireTimeItem);
+ }
+
TextAreaItem notesItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, "Notes");
notesItem.setWidth(450);
notesItem.setHeight(150);
- this.notesForm.setFields(notesItem);
+ notesFields.add(notesItem);
+
+ this.notesForm.setFields(notesFields.toArray(new FormItem[notesFields.size()]));
+
contentPane.addMember(this.notesForm);
return contentPane;
@@ -163,7 +175,9 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
protected Record createNewRecord() {
Record record = super.createNewRecord();
Subject sessionSubject = UserSessionManager.getSessionSubject();
- record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT, sessionSubject);
+ OperationScheduleDataSource.SubjectRecord subjectRecord =
+ new OperationScheduleDataSource.SubjectRecord(sessionSubject);
+ record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT, subjectRecord);
return record;
}
@@ -172,6 +186,11 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
refreshOperationDescriptionItem();
refreshOperationParametersItem();
+ if (!isNewRecord()) {
+ FormItem nextFireTimeItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME);
+ nextFireTimeItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME));
+ }
+
FormItem notesItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
notesItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION));
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 827d365..8bfa5cd 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
@@ -485,6 +485,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Trigger trigger = getTriggerOfJob(jobDetail);
JobTrigger jobTrigger = convertToJobTrigger(trigger);
sched.setJobTrigger(jobTrigger);
+ sched.setNextFireTime(trigger.getNextFireTime());
return sched;
}
commit 8a956b6b6e5d13f8ec7cf4a58b40af2f2474f85f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jan 11 20:07:05 2011 -0500
initial fully functional impl of Resource Operations > Schedule tab - list, detail, and create views
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java
index f5350fd..d178390 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java
@@ -207,7 +207,7 @@ public class DiscoveredResourceDetails {
if (resourceVersion.length() > RESOURCE_VERSION_MAX_LENGTH) {
log.warn("Plugin error: Resource version [" + resourceVersion + "] specified by [" + this.resourceType
+ "] discovery component is longer than the maximum length (" + RESOURCE_VERSION_MAX_LENGTH
- + " - truncating it to " + RESOURCE_VERSION_MAX_LENGTH + " characters...");
+ + ") - truncating it to " + RESOURCE_VERSION_MAX_LENGTH + " characters...");
this.resourceVersion = resourceVersion.substring(0, RESOURCE_VERSION_MAX_LENGTH);
} else {
this.resourceVersion = resourceVersion;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
index 3d63160..0264d3b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
@@ -313,7 +314,7 @@ public class RoleEditView extends AbstractRecordEditor<RolesDataSource> implemen
}
@Override
- protected void save() {
+ protected void save(DSRequest requestProperties) {
// Grab the currently assigned sets from each of the selectors and stick them into the corresponding canvas
// items on the form, so when the form is saved, they'll get submitted along with the rest of the simple fields
// to the datasource's add or update methods.
@@ -333,7 +334,7 @@ public class RoleEditView extends AbstractRecordEditor<RolesDataSource> implemen
}
// Submit the form values to the datasource.
- super.save();
+ super.save(requestProperties);
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index 04bc1b3..ffd8517 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.PasswordItem;
@@ -193,7 +194,7 @@ public class UserEditView extends AbstractRecordEditor<UsersDataSource> {
}
@Override
- protected void save() {
+ protected void save(DSRequest requestProperties) {
// Grab the currently assigned roles from the selector and stick them into the corresponding canvas
// item on the form, so when the form is saved, they'll get submitted along with the rest of the simple fields
// to the datasource's add or update methods.
@@ -203,7 +204,7 @@ public class UserEditView extends AbstractRecordEditor<UsersDataSource> {
}
// Submit the form values to the datasource.
- super.save();
+ super.save(requestProperties);
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java
index c134b69..b2a45b7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java
@@ -249,7 +249,7 @@ public abstract class AbstractRecordEditor<DS extends RPCDataSource> extends Loc
this.form.resetValues();
}
- protected void save() {
+ protected void save(DSRequest requestProperties) {
if (!this.form.validate()) {
Message message = new Message(MSG.widget_recordEditor_warn_validation(this.dataTypeName),
Message.Severity.Warning, EnumSet.of(Message.Option.Transient));
@@ -308,7 +308,7 @@ public abstract class AbstractRecordEditor<DS extends RPCDataSource> extends Loc
CoreGUI.getMessageCenter().notify(message);
}
}
- });
+ }, requestProperties);
}
protected void editNewRecord() {
@@ -451,7 +451,7 @@ public abstract class AbstractRecordEditor<DS extends RPCDataSource> extends Loc
saveButton.setDisabled(true);
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- save();
+ save(new DSRequest());
}
});
hLayout.addMember(saveButton);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java
new file mode 100644
index 0000000..7a45f5a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java
@@ -0,0 +1,34 @@
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+
+/**
+ * Formats a {@link org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource.SubjectRecord}
+ * (the SmartGWT {@link Record} representation of a {@link Subject}).
+ *
+ * @author Ian Springer
+ */
+public class SubjectRecordCellFormatter implements CellFormatter {
+
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String result;
+ if (value == null) {
+ result = "";
+ } else if (value instanceof JavaScriptObject) {
+ JavaScriptObject javaScriptObject = (JavaScriptObject) value;
+ Record subjectRecord = new ListGridRecord(javaScriptObject);
+ result = subjectRecord.getAttribute("name"); // the Subject's username
+ } else {
+ throw new IllegalArgumentException("value parameter is not a SubjectRecord - it is a "
+ + value.getClass().getName() + ".");
+ }
+ return result;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 78fb5db..7cfb393 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -686,20 +686,27 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
}
protected void deleteSelectedRecords() {
- getListGrid().removeSelectedData(new DSCallback() {
+ ListGrid listGrid = getListGrid();
+ final int selectedRecordCount = listGrid.getSelection().length;
+ final List<String> deletedRecordNames = new ArrayList<String>(selectedRecordCount);
+ listGrid.removeSelectedData(new DSCallback() {
public void execute(DSResponse response, Object rawData, DSRequest request) {
- Record[] deletedRecords = response.getData();
- List<String> recordNames = new ArrayList<String>(deletedRecords.length);
- for (Record deletedRecord : deletedRecords) {
- String name = deletedRecord.getAttribute(getTitleFieldName());
- recordNames.add(name);
+ if (response.getStatus() == DSResponse.STATUS_SUCCESS) {
+ Record[] deletedRecords = response.getData();
+ for (Record deletedRecord : deletedRecords) {
+ String name = deletedRecord.getAttribute(getTitleFieldName());
+ deletedRecordNames.add(name);
+ }
+ if (deletedRecordNames.size() == selectedRecordCount) {
+ // all selected schedules were successfully deleted.
+ Message message = new Message(MSG.widget_recordEditor_info_recordsDeletedConcise(String
+ .valueOf(deletedRecordNames.size()), getDataTypeNamePlural()), MSG
+ .widget_recordEditor_info_recordsDeletedDetailed(String.valueOf(deletedRecordNames.size()),
+ getDataTypeNamePlural(), deletedRecordNames.toString()));
+ CoreGUI.getMessageCenter().notify(message);
+ }
}
-
- Message message = new Message(MSG.widget_recordEditor_info_recordsDeletedConcise(String
- .valueOf(deletedRecords.length), getDataTypeNamePlural()), MSG
- .widget_recordEditor_info_recordsDeletedDetailed(String.valueOf(deletedRecords.length),
- getDataTypeNamePlural(), recordNames.toString()));
- CoreGUI.getMessageCenter().notify(message);
+ // TODO: Print error messages for failures or partial failures.
}
}, null);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
index fc9aef4..4fc86f8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -25,21 +25,28 @@ import java.util.LinkedHashMap;
import java.util.Map;
import com.smartgwt.client.types.Visibility;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.DateTimeItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
-import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
-import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-import com.smartgwt.client.widgets.form.fields.events.FocusEvent;
-import com.smartgwt.client.widgets.form.fields.events.FocusHandler;
+import com.smartgwt.client.widgets.form.fields.events.IconClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.IconClickHandler;
import com.smartgwt.client.widgets.form.validator.RegExpValidator;
+import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
import org.rhq.core.domain.common.JobTrigger;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -50,11 +57,17 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class JobTriggerEditor extends LocatableVLayout {
+ // Field Names
private static final String FIELD_REPEAT_INTERVAL = "repeatInterval";
private static final String FIELD_REPEAT_DURATION = "repeatDuration";
private static final String FIELD_END_TIME = "endTime";
+ private static final String FIELD_START_TYPE = "startType";
+ private static final String FIELD_START_TIME = "startTime";
+ private static final String FIELD_START_DELAY = "startDelay";
+ private static final String FIELD_RECURRENCE_TYPE = "recurrenceType";
+ private static final String FIELD_CRON_EXPRESSION = "cronExpression";
- private static final Map<String, Long> UNITS_TO_MILLIS_MULTIPLIER_MAP = new HashMap();
+ private static final Map<String, Long> UNITS_TO_MILLIS_MULTIPLIER_MAP = new HashMap<String, Long>();
static {
UNITS_TO_MILLIS_MULTIPLIER_MAP.put("seconds", 1000L);
UNITS_TO_MILLIS_MULTIPLIER_MAP.put("s", 1000L);
@@ -78,6 +91,7 @@ public class JobTriggerEditor extends LocatableVLayout {
private DynamicForm laterForm;
private DynamicForm repeatForm;
+ private LocatableDynamicForm cronForm;
// These flags allow us to determine the trigger type.
private boolean isCronMode;
@@ -87,10 +101,6 @@ public class JobTriggerEditor extends LocatableVLayout {
private boolean isEndTime;
private boolean isStartDelay;
private boolean isStartTime;
- private static final String FIELD_START_TYPE = "startType";
- private static final String FIELD_START_TIME = "startTime";
- private static final String FIELD_START_DELAY = "startDelay";
- private static final String FIELD_RECURRENCE_TYPE = "recurrenceType";
/**
* Create a new job trigger.
@@ -131,6 +141,8 @@ public class JobTriggerEditor extends LocatableVLayout {
modeForm.setFields(modeItem);
addMember(modeForm);
+ final LocatableVLayout calendarModeLayout = new LocatableVLayout(extendLocatorId("CalendarModeLayout"));
+ calendarModeLayout.setVisible(false);
final DynamicForm calendarTypeForm = new DynamicForm();
@@ -146,24 +158,349 @@ public class JobTriggerEditor extends LocatableVLayout {
calendarTypeItem.setVertical(false);
calendarTypeForm.setFields(calendarTypeItem);
- calendarTypeForm.setVisible(false);
- addMember(calendarTypeForm);
+ calendarModeLayout.addMember(calendarTypeForm);
+ addMember(calendarModeLayout);
+
+ final LocatableVLayout cronModeLayout = new LocatableVLayout(extendLocatorId("CronModeLayout"));
+ cronModeLayout.setVisible(false);
+
+ this.cronForm = new LocatableDynamicForm(cronModeLayout.extendLocatorId("Form"));
+
+ TextItem cronExpressionItem = new TextItem(FIELD_CRON_EXPRESSION, "Cron Expression");
+ cronExpressionItem.setRequired(true);
+ cronExpressionItem.setWidth(340);
+
+ this.cronForm.setFields(cronExpressionItem);
+
+ cronModeLayout.addMember(this.cronForm);
+
+ final TabSet cronHelpTabSet = new TabSet();
+ cronHelpTabSet.setWidth100();
+ cronHelpTabSet.setHeight(200);
+ Img closeIcon = new Img("[SKIN]/headerIcons/close.png", 16, 16);
+ closeIcon.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ cronHelpTabSet.hide();
+ }
+ });
+ cronHelpTabSet.setTabBarControls(closeIcon);
+
+ Tab formatTab = new Tab("Format");
+ HTMLFlow formatPane = new HTMLFlow();
+ formatPane.setWidth100();
+ formatPane.setContents("<p>A cron expression is a string comprised of 6 or 7 fields separated by white space. Fields can contain any of the\n" +
+ "allowed values, along with various combinations of the allowed special characters for that field. The fields are as\n" +
+ "follows:</p>\n" +
+ "<table cellpadding=\"3\" cellspacing=\"1\">\n" +
+ " <tbody>\n" +
+ "\n" +
+ " <tr>\n" +
+ " <th>Field Name</th>\n" +
+ " <th>Mandatory</th>\n" +
+ " <th>Allowed Values</th>\n" +
+ " <th>Allowed Special Characters</th>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td>Seconds</td>\n" +
+ " <td>YES</td>\n" +
+ "\n" +
+ " <td>0-59</td>\n" +
+ " <td>, - * /</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td>Minutes</td>\n" +
+ " <td>YES</td>\n" +
+ " <td>0-59</td>\n" +
+ "\n" +
+ " <td>, - * /</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td>Hours</td>\n" +
+ " <td>YES</td>\n" +
+ " <td>0-23</td>\n" +
+ " <td>, - * /</td>\n" +
+ "\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td>Day of month</td>\n" +
+ " <td>YES</td>\n" +
+ " <td>1-31</td>\n" +
+ " <td>, - * ? / L W<br clear=\"all\" />\n" +
+ " </td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td>Month</td>\n" +
+ " <td>YES</td>\n" +
+ " <td>1-12 or JAN-DEC</td>\n" +
+ " <td>, - * /</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td>Day of week</td>\n" +
+ "\n" +
+ " <td>YES</td>\n" +
+ " <td>1-7 or SUN-SAT</td>\n" +
+ " <td>, - * ? / L #</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td>Year</td>\n" +
+ " <td>NO</td>\n" +
+ "\n" +
+ " <td>empty, 1970-2099</td>\n" +
+ " <td>, - * /</td>\n" +
+ " </tr>\n" +
+ " </tbody>\n" +
+ "\n" +
+ "</table>\n" +
+ "<p>So cron expressions can be as simple as this: <tt>* * * * ? *</tt><br />\n" +
+ "or more complex, like this: <tt>0/5 14,18,3-39,52 * ? JAN,MAR,SEP MON-FRI 2002-2010</tt></p>\n" +
+ "\n" +
+ "<h2><a name=\"CronTriggersTutorial-Specialcharacters\"></a>Special Characters</h2>\n" +
+ "\n" +
+ "<ul>\n" +
+ " <li><tt><b>*</b></tt> (<em>\"all values\"</em>) - used to select all values within a field. For example, \"*\"\n" +
+ " in the minute field means <em>\"every minute\"</em>.</li>\n" +
+ "\n" +
+ "</ul>\n" +
+ "\n" +
+ "\n" +
+ "<ul>\n" +
+ " <li><tt><b>?</b></tt> (<em>\"no specific value\"</em>) - useful when you need to specify something in one of the\n" +
+ " two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a\n" +
+ " particular day of the month (say, the 10th), but don't care what day of the week that happens to be, I would put\n" +
+ " \"10\" in the day-of-month field, and \"?\" in the day-of-week field. See the examples below for clarification.</li>\n" +
+ "\n" +
+ "</ul>\n" +
+ "\n" +
+ "\n" +
+ "<ul>\n" +
+ " <li><tt><b>-</b></tt> - used to specify ranges. For example, \"10-12\" in the hour field means <em>\"the\n" +
+ " hours 10, 11 and 12\"</em>.</li>\n" +
+ "\n" +
+ "</ul>\n" +
+ "\n" +
+ "\n" +
+ "<ul>\n" +
+ " <li><tt><b>,</b></tt> - used to specify additional values. For example, \"MON,WED,FRI\" in the day-of-week\n" +
+ " field means <em>\"the days Monday, Wednesday, and Friday\"</em>.</li>\n" +
+ "\n" +
+ "</ul>\n" +
+ "\n" +
+ "\n" +
+ "<ul>\n" +
+ "\n" +
+ " <li><tt><b>/</b></tt> - used to specify increments. For example, \"0/15\" in the seconds field means <em>\"the\n" +
+ " seconds 0, 15, 30, and 45\"</em>. And \"5/15\" in the seconds field means <em>\"the seconds 5, 20, 35, and 50\"</em>. You can\n" +
+ " also specify '/' after the '<b>' character - in this case '</b>' is equivalent to having '0' before the '/'. '1/3'\n" +
+ " in the day-of-month field means <em>\"fire every 3 days starting on the first day of the month\"</em>.</li>\n" +
+ "\n" +
+ "</ul>\n" +
+ "\n" +
+ "<ul>\n" +
+ " <li><tt><b>L</b></tt> (<em>\"last\"</em>) - has different meaning in each of the two fields in which it is\n" +
+ " allowed. For example, the value \"L\" in the day-of-month field means <em>\"the last day of the month\"</em> - day\n" +
+ " 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means\n" +
+ " \"7\" or \"SAT\". But if used in the day-of-week field after another value, it means <em>\"the last xxx day of the\n" +
+ " month\"</em> - for example \"6L\" means <em>\"the last friday of the month\"</em>. When using the 'L' option, it is\n" +
+ " important not to specify lists, or ranges of values, as you'll get confusing results.</li>\n" +
+ "\n" +
+ "</ul>\n" +
+ "\n" +
+ "\n" +
+ "<ul>\n" +
+ " <li><tt><b>W</b></tt> (<em>\"weekday\"</em>) - used to specify the weekday (Monday-Friday) nearest the given day.\n" +
+ " As an example, if you were to specify \"15W\" as the value for the day-of-month field, the meaning is: <em>\"the\n" +
+ " nearest weekday to the 15th of the month\"</em>. So if the 15th is a Saturday, the trigger will fire on Friday the 14th.\n" +
+ " If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on\n" +
+ " Tuesday the 15th. However if you specify \"1W\" as the value for day-of-month, and the 1st is a Saturday, the trigger\n" +
+ " will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only\n" +
+ " be specified when the day-of-month is a single day, not a range or list of days.\n" +
+ " <div class=\"tip\">\n" +
+ " The 'L' and 'W' characters can also be combined in the day-of-month field to yield 'LW', which\n" +
+ " translates to <em>\"last weekday of the month\"</em>.\n" +
+ " </div>\n" +
+ "\n" +
+ " </li>\n" +
+ "\n" +
+ " <li><tt><b>#</b></tt> - used to specify \"the nth\" XXX day of the month. For example, the value of \"6#3\"\n" +
+ " in the day-of-week field means <em>\"the third Friday of the month\"</em> (day 6 = Friday and \"#3\" = the 3rd one in\n" +
+ " the month). Other examples: \"2#1\" = the first Monday of the month and \"4#5\" = the fifth Wednesday of the month. Note\n" +
+ " that if you specify \"#5\" and there is not 5 of the given day-of-week in the month, then no firing will occur that\n" +
+ " month.\n" +
+ " <div class=\"tip\">\n" +
+ " The legal characters and the names of months and days of the week are not case sensitive. <tt>MON</tt>\n" +
+ " is the same as <tt>mon</tt>.\n" +
+ " </div>\n" +
+ "\n" +
+ " </li>\n" +
+ "</ul>" +
+ "<h2><a name=\"CronTriggersTutorial-Notes\"></a>Notes</h2>\n" +
+ "\n" +
+ "<ul>\n" +
+ " <li>Support for specifying both a day-of-week and a day-of-month value is not complete (you must currently use\n" +
+ " the '?' character in one of these fields).</li>\n" +
+ " <li>Be careful when setting fire times between mid-night and 1:00 AM - \"daylight savings\" can cause a skip or a\n" +
+ " repeat depending on whether the time moves back or jumps forward.</li>\n" +
+ "\n" +
+ "</ul>");
+ formatTab.setPane(formatPane);
+
+ Tab examplesTab = new Tab("Examples");
+ HTMLFlow examplesPane = new HTMLFlow();
+ examplesPane.setWidth100();
+ examplesPane.setContents("<table cellpadding=\"3\" cellspacing=\"1\">\n" +
+ " <tbody>\n" +
+ " <tr>\n" +
+ " <th>Expression</th>\n" +
+ "\n" +
+ " <th>Meaning</th>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 0 12 * * ?</tt></td>\n" +
+ "\n" +
+ " <td>Fire at 12pm (noon) every day</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td><tt>0 15 10 ? * *</tt></td>\n" +
+ " <td>Fire at 10:15am every day</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 15 10 * * ?</tt></td>\n" +
+ "\n" +
+ " <td>Fire at 10:15am every day</td>\n" +
+ "\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 15 10 * * ? *</tt></td>\n" +
+ " <td>Fire at 10:15am every day</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 15 10 * * ? 2005</tt></td>\n" +
+ "\n" +
+ " <td>Fire at 10:15am every day during the year 2005</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 * 14 * * ?</tt></td>\n" +
+ " <td>Fire every minute starting at 2pm and ending at 2:59pm, every day</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td><tt>0 0/5 14 * * ?</tt></td>\n" +
+ "\n" +
+ " <td>Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 0/5 14,18 * * ?</tt></td>\n" +
+ " <td>Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5\n" +
+ " minutes starting at 6pm and ending at 6:55pm, every day</td>\n" +
+ "\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 0-5 14 * * ?</tt></td>\n" +
+ "\n" +
+ " <td>Fire every minute starting at 2pm and ending at 2:05pm, every day</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 10,44 14 ? 3 WED</tt></td>\n" +
+ "\n" +
+ " <td>Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 15 10 ? * MON-FRI</tt></td>\n" +
+ "\n" +
+ " <td>Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td><tt>0 15 10 15 * ?</tt></td>\n" +
+ " <td>Fire at 10:15am on the 15th day of every month</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 15 10 L * ?</tt></td>\n" +
+ "\n" +
+ " <td>Fire at 10:15am on the last day of every month</td>\n" +
+ "\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 15 10 ? * 6L</tt></td>\n" +
+ " <td>Fire at 10:15am on the last Friday of every month</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 15 10 ? * 6L</tt></td>\n" +
+ "\n" +
+ " <td>Fire at 10:15am on the last Friday of every month</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 15 10 ? * 6L 2002-2005</tt></td>\n" +
+ " <td>Fire at 10:15am on every last friday of every month during the years 2002,\n" +
+ " 2003, 2004 and 2005</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ "\n" +
+ " <td><tt>0 15 10 ? * 6#3</tt></td>\n" +
+ "\n" +
+ " <td>Fire at 10:15am on the third Friday of every month</td>\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 0 12 1/5 * ?</tt></td>\n" +
+ " <td>Fire at 12pm (noon) every 5 days every month, starting on the first day of the\n" +
+ " month.</td>\n" +
+ "\n" +
+ " </tr>\n" +
+ " <tr>\n" +
+ " <td><tt>0 11 11 11 11 ?</tt></td>\n" +
+ "\n" +
+ " <td>Fire every November 11th at 11:11am.</td>\n" +
+ " </tr>\n" +
+ " </tbody>\n" +
+ "</table>");
+ examplesTab.setPane(examplesPane);
+
+ cronHelpTabSet.addTab(formatTab);
+ cronHelpTabSet.addTab(examplesTab);
+
+ cronHelpTabSet.setVisible(false);
+
+ FormItemIcon helpIcon = new FormItemIcon();
+ helpIcon.setSrc("[SKIN]/actions/help.png");
+ cronExpressionItem.setIcons(helpIcon);
+ cronExpressionItem.addIconClickHandler(new IconClickHandler() {
+ public void onIconClick(IconClickEvent event) {
+ cronHelpTabSet.show();
+ }
+ });
+
+ cronModeLayout.addMember(cronHelpTabSet);
+ addMember(cronModeLayout);
modeItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
if (event.getValue().equals("calendar")) {
JobTriggerEditor.this.isCronMode = false;
- calendarTypeForm.show();
+ calendarModeLayout.show();
+ cronModeLayout.hide();
+ } else {
+ // cron mode
+ JobTriggerEditor.this.isCronMode = true;
+ calendarModeLayout.hide();
+ cronModeLayout.show();
}
}
});
this.laterForm = createLaterForm();
- addMember(this.laterForm);
+ calendarModeLayout.addMember(this.laterForm);
this.repeatForm = createRepeatForm();
- addMember(this.repeatForm);
+ calendarModeLayout.addMember(this.repeatForm);
calendarTypeItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
@@ -204,21 +541,13 @@ public class JobTriggerEditor extends LocatableVLayout {
TextItem repeatIntervalItem = new TextItem(FIELD_REPEAT_INTERVAL, "Run now and every");
repeatIntervalItem.setRequired(true);
- // Configure hint.
- repeatIntervalItem.setHint("N UNITS (where N is a positive integer and UNITS is \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"6 weeks\")");
- repeatIntervalItem.setShowHint(false);
- repeatIntervalItem.addFocusHandler(new FocusHandler() {
- public void onFocus(FocusEvent event) {
- repeatForm.setColWidths(130, 400, 130, 130, 130);
- event.getItem().setShowHint(true);
- repeatForm.markForRedraw();
- }
- });
- repeatIntervalItem.addBlurHandler(new BlurHandler() {
- public void onBlur(BlurEvent event) {
- repeatForm.setColWidths(130, 130, 130, 130, 130);
- event.getItem().setShowHint(false);
- repeatForm.markForRedraw();
+ // Configure context-sensitive help.
+ FormItemIcon helpIcon = new FormItemIcon();
+ helpIcon.setSrc("[SKIN]/actions/help.png");
+ repeatIntervalItem.setIcons(helpIcon);
+ repeatIntervalItem.addIconClickHandler(new IconClickHandler() {
+ public void onIconClick(IconClickEvent event) {
+ SC.say("N UNITS (where N is a positive integer and UNITS is \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"6 weeks\")");
}
});
@@ -228,6 +557,7 @@ public class JobTriggerEditor extends LocatableVLayout {
repeatIntervalItem.setValidateOnExit(true);
RadioGroupItem recurrenceTypeItem = new RadioGroupItem(FIELD_RECURRENCE_TYPE);
+ recurrenceTypeItem.setRequired(true);
recurrenceTypeItem.setShowTitle(false);
LinkedHashMap<String, String> recurrenceTypeValueMap = new LinkedHashMap<String, String>();
recurrenceTypeValueMap.put("for", "For");
@@ -239,21 +569,13 @@ public class JobTriggerEditor extends LocatableVLayout {
repeatDurationItem.setShowTitle(false);
repeatDurationItem.setVisible(false);
- // Configure hint.
- repeatDurationItem.setHint("N UNITS (where N is a positive integer and UNITS is \"times\", \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"5 repetitions\")");
- repeatDurationItem.setShowHint(false);
- repeatDurationItem.addFocusHandler(new FocusHandler() {
- public void onFocus(FocusEvent event) {
- repeatForm.setColWidths(130, 130, 400, 130, 130);
- event.getItem().setShowHint(true);
- repeatForm.markForRedraw();
- }
- });
- repeatDurationItem.addBlurHandler(new BlurHandler() {
- public void onBlur(BlurEvent event) {
- repeatForm.setColWidths(130, 130, 130, 130, 130);
- event.getItem().setShowHint(false);
- repeatForm.markForRedraw();
+ // Configure context-sensitive help.
+ helpIcon = new FormItemIcon();
+ helpIcon.setSrc("[SKIN]/actions/help.png");
+ repeatDurationItem.setIcons(helpIcon);
+ repeatDurationItem.addIconClickHandler(new IconClickHandler() {
+ public void onIconClick(IconClickEvent event) {
+ SC.say("N UNITS (where N is a positive integer and UNITS is \"times\", \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"5 repetitions\")");
}
});
@@ -321,21 +643,13 @@ public class JobTriggerEditor extends LocatableVLayout {
startDelayItem.setShowTitle(false);
startDelayItem.setVisible(false);
- // Configure hint.
- startDelayItem.setHint("N UNITS (where N is a positive integer and UNITS is \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"6 weeks\")");
- startDelayItem.setShowHint(false);
- startDelayItem.addFocusHandler(new FocusHandler() {
- public void onFocus(FocusEvent event) {
- laterForm.setColWidths(130, 130, 400);
- event.getItem().setShowHint(true);
- laterForm.markForRedraw();
- }
- });
- startDelayItem.addBlurHandler(new BlurHandler() {
- public void onBlur(BlurEvent event) {
- laterForm.setColWidths(130, 130, 130);
- event.getItem().setShowHint(false);
- laterForm.markForRedraw();
+ // Configure context-sensitive help.
+ FormItemIcon icon = new FormItemIcon();
+ icon.setSrc("[SKIN]/actions/help.png");
+ startDelayItem.setIcons(icon);
+ startDelayItem.addIconClickHandler(new IconClickHandler() {
+ public void onIconClick(IconClickEvent event) {
+ SC.say("N UNITS (where N is a positive integer and UNITS is \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"6 weeks\")");
}
});
@@ -378,108 +692,97 @@ public class JobTriggerEditor extends LocatableVLayout {
return laterForm;
}
- public JobTrigger getJobTrigger() throws Exception {
- JobTrigger jobTrigger = null;
-
- if (this.isCronMode) {
- // TODO
+ public Date getStartTime() {
+ Date startTime;
+ if (this.isStartDelay) {
+ // start delay - computer start time
+ String startDelay = this.laterForm.getValueAsString(FIELD_START_DELAY);
+ Duration startDelayDuration = parseDurationString(startDelay);
+ long delay = startDelayDuration.count * startDelayDuration.multiplier;
+ long startTimestamp = System.currentTimeMillis() + delay;
+ startTime = new Date(startTimestamp);
} else {
- // calendar mode
+ // start time
+ DateTimeItem startTimeItem = (DateTimeItem)this.laterForm.getField(FIELD_START_TIME);
+ startTime = startTimeItem.getValueAsDate();
+ }
+ return startTime;
+ }
- // Validate first.
- boolean isValid = true;
- if (this.isStartLater) {
- isValid = isValid && this.laterForm.validate();
- }
- if (this.isRecurring) {
- isValid = isValid && this.repeatForm.validate();
- }
- if (!isValid) {
- throw new Exception("The specified schedule is not valid.");
- }
+ public Long getRepeatInterval() {
+ Long intervalMillis;
+ if (this.isRecurring) {
+ String repeatInterval = this.repeatForm.getValueAsString(FIELD_REPEAT_INTERVAL);
+ Duration intervalDuration = parseDurationString(repeatInterval);
+ intervalMillis = intervalDuration.count * intervalDuration.multiplier;
+ } else {
+ intervalMillis = null;
+ }
+ return intervalMillis;
+ }
- if (this.isStartLater) {
- Date startDate;
- if (this.isStartDelay) {
- // start delay - computer start time
- String startDelay = this.laterForm.getValueAsString(FIELD_START_DELAY);
- Duration startDelayDuration = parseDurationString(startDelay);
- long delay = startDelayDuration.count * startDelayDuration.multiplier;
- long startTime = System.currentTimeMillis() + delay;
- startDate = new Date(startTime);
+ public Integer getRepeatCount() {
+ Integer repetitions;
+ if (this.isRecurring) {
+ if (this.isRepeatDuration) {
+ String repeatDurationString = this.repeatForm.getValueAsString(FIELD_REPEAT_DURATION);
+ Duration repeatDuration = parseDurationString(repeatDurationString);
+ if (repeatDuration.multiplier == null) {
+ // n repetitions
+ repetitions = repeatDuration.count;
} else {
- // start time
- DateTimeItem startTimeItem = (DateTimeItem)this.laterForm.getField(FIELD_START_TIME);
- startDate = startTimeItem.getValueAsDate();
+ // n units of time - compute end time
+ repetitions = null;
}
+ } else {
+ repetitions = null;
+ }
+ } else {
+ repetitions = null;
+ }
+ return repetitions;
+ }
- if (this.isRecurring) {
- // LATER AND REPEAT
-
- String repeatInterval = this.repeatForm.getValueAsString(FIELD_REPEAT_INTERVAL);
- Duration intervalDuration = parseDurationString(repeatInterval);
- long intervalMillis = intervalDuration.count * intervalDuration.multiplier;
-
- if (this.isRepeatDuration) {
- String repeatDurationString = this.repeatForm.getValueAsString(FIELD_REPEAT_DURATION);
- Duration repeatDuration = parseDurationString(repeatDurationString);
- if (repeatDuration.multiplier == null) {
- // n repetitions
- int repetitions = repeatDuration.count;
- jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startDate, intervalMillis, repetitions);
- } else {
- // n units of time - compute end time
- long delay = repeatDuration.count * repeatDuration.multiplier;
- long endTime = System.currentTimeMillis() + delay;
- Date endDate = new Date(endTime);
- jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startDate, intervalMillis, endDate);
- }
- } else if (this.isEndTime) {
- DateTimeItem endTimeItem = (DateTimeItem)this.repeatForm.getField(FIELD_END_TIME);
- Date endDate = endTimeItem.getValueAsDate();
- jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startDate, intervalMillis, endDate);
- }
+ public Date getEndTime() {
+ Date endTime;
+ if (this.isRecurring) {
+ if (this.isRepeatDuration) {
+ String repeatDurationString = this.repeatForm.getValueAsString(FIELD_REPEAT_DURATION);
+ Duration repeatDuration = parseDurationString(repeatDurationString);
+ if (repeatDuration.multiplier == null) {
+ // n repetitions
+ endTime = null;
} else {
- // LATER
-
- jobTrigger = JobTrigger.createLaterTrigger(startDate);
+ // n units of time - compute end time
+ long delay = repeatDuration.count * repeatDuration.multiplier;
+ long endTimestamp = System.currentTimeMillis() + delay;
+ endTime = new Date(endTimestamp);
}
+ } else if (this.isEndTime) {
+ DateTimeItem endTimeItem = (DateTimeItem)this.repeatForm.getField(FIELD_END_TIME);
+ endTime = endTimeItem.getValueAsDate();
} else {
- if (this.isRecurring) {
- // NOW AND REPEAT
-
- String repeatInterval = this.repeatForm.getValueAsString(FIELD_REPEAT_INTERVAL);
- Duration intervalDuration = parseDurationString(repeatInterval);
- long intervalMillis = intervalDuration.count * intervalDuration.multiplier;
-
- if (this.isRepeatDuration) {
- String repeatDurationString = this.repeatForm.getValueAsString(FIELD_REPEAT_DURATION);
- Duration repeatDuration = parseDurationString(repeatDurationString);
- if (repeatDuration.multiplier == null) {
- // n repetitions
- int repetitions = repeatDuration.count;
- jobTrigger = JobTrigger.createNowAndRepeatTrigger(intervalMillis, repetitions);
- } else {
- // n units of time - compute end time
- long delay = repeatDuration.count * repeatDuration.multiplier;
- long endTime = System.currentTimeMillis() + delay;
- Date endDate = new Date(endTime);
- jobTrigger = JobTrigger.createNowAndRepeatTrigger(intervalMillis, endDate);
- }
- } else if (this.isEndTime) {
- DateTimeItem endTimeItem = (DateTimeItem)this.repeatForm.getField(FIELD_END_TIME);
- Date endDate = endTimeItem.getValueAsDate();
- jobTrigger = JobTrigger.createNowAndRepeatTrigger(intervalMillis, endDate);
- }
- } else {
- // NOW
-
- jobTrigger = JobTrigger.createNowTrigger();
- }
+ endTime = null;
}
+ } else {
+ endTime = null;
}
+ return endTime;
+ }
+
+ public String getCronExpression() {
+ return this.cronForm.getValueAsString(FIELD_CRON_EXPRESSION);
+ }
- return jobTrigger;
+ public boolean validate() {
+ boolean isValid = true;
+ if (this.isStartLater) {
+ isValid = isValid && this.laterForm.validate();
+ }
+ if (this.isRecurring) {
+ isValid = isValid && this.repeatForm.validate();
+ }
+ return isValid;
}
private static Duration parseDurationString(String durationString) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
index dd52adc..0ddc80b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
@@ -54,6 +54,10 @@ public interface OperationGWTService extends RemoteService {
void invokeResourceOperation(int resourceId, String operationName, Configuration parameters, String description,
int timeout) throws RuntimeException;
+ int scheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule) throws RuntimeException;
+
+ void unscheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule) throws RuntimeException;
+
void scheduleResourceOperation(int resourceId, String operationName, Configuration parameters, String description,
int timeout, String cronString) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
index 8450214..024f1e6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
@@ -19,6 +19,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
@@ -27,8 +28,10 @@ import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.FieldType;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.apache.tools.ant.types.selectors.TypeSelector;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
@@ -53,7 +56,13 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
public static final String PARAMETERS = "parameters";
public static final String SUBJECT = "subject";
public static final String DESCRIPTION = "description";
- public static final String JOB_TRIGGER = "jobTrigger";
+
+ // job trigger fields
+ public static final String START_TIME = "startTime";
+ public static final String REPEAT_INTERVAL = "repeatInterval";
+ public static final String REPEAT_COUNT = "repeatCount";
+ public static final String END_TIME = "endTime";
+ public static final String CRON_EXPRESSION = "cronExpression";
}
protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
@@ -90,16 +99,13 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
}
operationNameField.setValueMap(valueMap);
- DataSourceTextField subjectField = createTextField(Field.SUBJECT, "Owner", null, 100, true);
+ DataSourceField subjectField = new DataSourceField(Field.SUBJECT, FieldType.ANY, "Owner");
subjectField.setCanEdit(false);
fields.add(subjectField);
DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION, "Notes", null, 100, false);
fields.add(descriptionField);
- DataSourceTextField jobTriggerField = createTextField(Field.JOB_TRIGGER, "Schedule", null, 100, true);
- fields.add(jobTriggerField);
-
return fields;
}
@@ -112,13 +118,15 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
to.setId(from.getAttributeAsInt(Field.ID));
to.setJobName(from.getAttribute(Field.JOB_NAME));
to.setJobGroup(from.getAttribute(Field.JOB_GROUP));
- to.setJobTrigger((JobTrigger)from.getAttributeAsObject(Field.JOB_TRIGGER));
- to.setSubject((Subject)from.getAttributeAsObject(Field.SUBJECT));
+ SubjectRecord subjectRecord = (SubjectRecord) from.getAttributeAsRecord(Field.SUBJECT);
+ to.setSubject(subjectRecord.toSubject());
to.setParameters((Configuration)from.getAttributeAsObject(Field.PARAMETERS));
to.setOperationName(from.getAttribute(Field.OPERATION_NAME));
to.setOperationDisplayName(from.getAttribute(Field.OPERATION_DISPLAY_NAME));
to.setDescription(from.getAttribute(Field.DESCRIPTION));
+ to.setJobTrigger(createJobTrigger(from.getAttributeAsRecord("jobTrigger")));
+
return to;
}
@@ -129,14 +137,98 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
to.setAttribute(Field.ID, from.getId());
to.setAttribute(Field.JOB_NAME, from.getJobName());
to.setAttribute(Field.JOB_GROUP, from.getJobGroup());
- to.setAttribute(Field.JOB_TRIGGER, from.getJobTrigger());
- to.setAttribute(Field.SUBJECT, from.getSubject());
+ SubjectRecord subjectRecord = new SubjectRecord(from.getSubject());
+ to.setAttribute(Field.SUBJECT, subjectRecord);
to.setAttribute(Field.PARAMETERS, from.getParameters());
to.setAttribute(Field.OPERATION_NAME, from.getOperationName());
to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
to.setAttribute(Field.DESCRIPTION, from.getDescription());
+ JobTrigger jobTrigger = from.getJobTrigger();
+ Record jobTriggerRecord = new ListGridRecord();
+ jobTriggerRecord.setAttribute(Field.START_TIME, jobTrigger.getStartDate());
+ jobTriggerRecord.setAttribute(Field.REPEAT_INTERVAL, jobTrigger.getRepeatInterval());
+ jobTriggerRecord.setAttribute(Field.REPEAT_COUNT, jobTrigger.getRepeatCount());
+ jobTriggerRecord.setAttribute(Field.END_TIME, jobTrigger.getEndDate());
+ jobTriggerRecord.setAttribute(Field.CRON_EXPRESSION, jobTrigger.getCronExpression());
+ to.setAttribute("jobTrigger", jobTriggerRecord);
+
return to;
}
+ public JobTrigger createJobTrigger(Record jobTriggerRecord) {
+ JobTrigger jobTrigger;
+
+ String cronExpression = jobTriggerRecord.getAttribute(Field.CRON_EXPRESSION);
+ if (cronExpression != null) {
+ jobTrigger = JobTrigger.createCronTrigger(cronExpression);
+ } else {
+ // calendar mode
+ Date startTime = jobTriggerRecord.getAttributeAsDate(Field.START_TIME);
+ Long repeatInterval = (Long)jobTriggerRecord.getAttributeAsObject(Field.REPEAT_INTERVAL);
+ Integer repeatCount = jobTriggerRecord.getAttributeAsInt(Field.REPEAT_COUNT);
+ Date endTime = jobTriggerRecord.getAttributeAsDate(Field.END_TIME);
+
+ if (startTime != null) {
+ // LATER
+
+ if (repeatInterval != null) {
+ // LATER AND REPEAT
+
+ if (repeatCount != null) {
+ jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startTime, repeatInterval, repeatCount);
+ } else {
+ jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startTime, repeatInterval, endTime);
+ }
+ } else {
+ // LATER ONCE
+
+ jobTrigger = JobTrigger.createLaterTrigger(startTime);
+ }
+ } else {
+ // NOW
+ if (repeatInterval != null) {
+ // NOW AND REPEAT
+
+ if (repeatCount != null) {
+ jobTrigger = JobTrigger.createNowAndRepeatTrigger(repeatInterval, repeatCount);
+ } else {
+ jobTrigger = JobTrigger.createNowAndRepeatTrigger(repeatInterval, endTime);
+ }
+ } else {
+ // NOW ONCE
+
+ jobTrigger = JobTrigger.createNowTrigger();
+ }
+ }
+ }
+
+ return jobTrigger;
+ }
+
+ public class SubjectRecord extends ListGridRecord {
+ static final String FIELD_ID = "id";
+ static final String FIELD_NAME = "name";
+
+ SubjectRecord(Subject subject) {
+ setAttribute(FIELD_ID, subject.getId());
+ setAttribute(FIELD_NAME, subject.getName());
+ }
+
+ public int getId() {
+ return getAttributeAsInt(FIELD_ID);
+ }
+
+ public String getName() {
+ return getAttribute(FIELD_NAME);
+ }
+
+ public Subject toSubject() {
+ Subject subject = new Subject();
+ subject.setId(getId());
+ subject.setName(getName());
+ return subject;
+ }
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
index d615316..71d943e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
@@ -22,6 +22,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.enterprise.gui.coregui.client.components.table.SubjectRecordCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
@@ -44,13 +45,14 @@ public abstract class OperationScheduleListView extends TableSection<OperationSc
ListGridField operationField = new ListGridField(OperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME, 150);
- //ListGridField subjectField = new ListGridField(OperationScheduleDataSource.Field.SUBJECT, 150);
+ ListGridField subjectField = new ListGridField(OperationScheduleDataSource.Field.SUBJECT, 150);
+ subjectField.setCellFormatter(new SubjectRecordCellFormatter());
//ListGridField jobTriggerField = new ListGridField(OperationScheduleDataSource.Field.JOB_TRIGGER, 300);
ListGridField descriptionField = new ListGridField(OperationScheduleDataSource.Field.DESCRIPTION);
- setListGridFields(operationField, descriptionField);
+ setListGridFields(operationField, subjectField, descriptionField);
addTableAction(extendLocatorId("New"), MSG.common_button_new(), new TableAction() {
public boolean isEnabled(ListGridRecord[] selection) {
@@ -70,9 +72,14 @@ public abstract class OperationScheduleListView extends TableSection<OperationSc
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- // TODO: unschedule the selected schedule items
+ deleteSelectedRecords();
}
});
}
+ @Override
+ protected String getDetailsLinkColumnName() {
+ return OperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
index 1a87bd3..f7362ad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -20,12 +20,16 @@
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.Record;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
@@ -33,20 +37,20 @@ import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-import org.rhq.core.domain.common.JobTrigger;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.form.AbstractRecordEditor;
import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
import org.rhq.enterprise.gui.coregui.client.components.trigger.JobTriggerEditor;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -62,11 +66,12 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
private Map<String, String> operationNameToDescriptionMap = new HashMap<String, String>();
private Map<String, ConfigurationDefinition> operationNameToParametersDefinitionMap =
new HashMap<String, ConfigurationDefinition>();
- private SelectItem operationNameItem;
private StaticTextItem operationDescriptionItem;
private StaticTextItem operationParametersItem;
private LocatableHLayout operationParametersConfigurationHolder;
private JobTriggerEditor triggerEditor;
+ private Configuration parameters;
+ private EnhancedDynamicForm notesForm;
public ResourceOperationScheduleDetailsView(String locatorId, ResourceComposite resourceComposite, int scheduleId) {
super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite), scheduleId, "Scheduled Operation", null);
@@ -94,9 +99,9 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
protected List<FormItem> createFormItems(EnhancedDynamicForm form) {
List<FormItem> items = new ArrayList<FormItem>();
- this.operationNameItem = new SelectItem(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
- items.add(this.operationNameItem);
- this.operationNameItem.addChangedHandler(new ChangedHandler() {
+ SelectItem operationNameItem = new SelectItem(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
+ items.add(operationNameItem);
+ operationNameItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
refreshOperationDescriptionItem();
refreshOperationParametersItem();
@@ -120,18 +125,24 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
this.operationParametersConfigurationHolder.setVisible(false);
contentPane.addMember(this.operationParametersConfigurationHolder);
+ HTMLFlow hr = new HTMLFlow("<p/><hr/><p/>");
+ contentPane.addMember(hr);
+
if (isNewRecord()) {
this.triggerEditor = new JobTriggerEditor(extendLocatorId("TriggerEditor"));
contentPane.addMember(this.triggerEditor);
+ hr = new HTMLFlow("<p/><hr/><p/>");
+ contentPane.addMember(hr);
}
-
- EnhancedDynamicForm notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"), isReadOnly(),
+
+ this.notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"), isReadOnly(),
isNewRecord());
+ this.notesForm.setWidth100();
TextAreaItem notesItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, "Notes");
- notesItem.setStartRow(true);
- notesItem.setColSpan(4);
- notesForm.setFields(notesItem);
- contentPane.addMember(notesForm);
+ notesItem.setWidth(450);
+ notesItem.setHeight(150);
+ this.notesForm.setFields(notesItem);
+ contentPane.addMember(this.notesForm);
return contentPane;
}
@@ -149,22 +160,61 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
}
@Override
- protected void save() {
- try {
- JobTrigger trigger = this.triggerEditor.getJobTrigger();
- System.out.println(trigger);
- }
- catch (Exception e) {
- e.printStackTrace();
- CoreGUI.getMessageCenter().notify(new Message(e.getMessage(), Message.Severity.Warning));
+ protected Record createNewRecord() {
+ Record record = super.createNewRecord();
+ Subject sessionSubject = UserSessionManager.getSessionSubject();
+ record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT, sessionSubject);
+ return record;
+ }
+
+ @Override
+ protected void editRecord(Record record) {
+ refreshOperationDescriptionItem();
+ refreshOperationParametersItem();
+
+ FormItem notesItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
+ notesItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION));
+
+ super.editRecord(record);
+ }
+
+ @Override
+ protected void save(DSRequest requestProperties) {
+ requestProperties.setAttribute("parameters", this.parameters);
+
+ if (!this.triggerEditor.validate()) {
+ // TODO: print error Message
return;
}
+ EnhancedDynamicForm form = getForm();
+
+ Record jobTriggerRecord = new ListGridRecord();
+
+ Date startTime = this.triggerEditor.getStartTime();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.START_TIME, startTime);
+
+ Date endTime = this.triggerEditor.getEndTime();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.END_TIME, endTime);
+
+ Integer repeatCount = this.triggerEditor.getRepeatCount();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_COUNT, repeatCount);
- super.save();
+ Long repeatInterval = this.triggerEditor.getRepeatInterval();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_INTERVAL, repeatInterval);
+
+ String cronExpression = this.triggerEditor.getCronExpression();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.CRON_EXPRESSION, cronExpression);
+
+ form.setValue("jobTrigger", jobTriggerRecord);
+
+ FormItem notesItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
+ form.setValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION, (String)notesItem.getValue());
+
+ super.save(requestProperties);
}
private void refreshOperationDescriptionItem() {
- String operationName = this.operationNameItem.getValueAsString();
+ String operationName = getSelectedOperationName();
String value;
if (operationName == null) {
value = "<i>Select an operation.</i>";
@@ -175,7 +225,7 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
}
private void refreshOperationParametersItem() {
- String operationName = this.operationNameItem.getValueAsString();
+ String operationName = getSelectedOperationName();
String value;
if (operationName == null) {
value = "<i>Select an operation.</i>";
@@ -189,7 +239,7 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
}
this.operationParametersConfigurationHolder.hide();
} else {
- value = "<i>Enter parameters below...</i>";
+ value = isNewRecord() ? "<i>Enter parameters below...</i>" : "";
for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
child.destroy();
@@ -199,6 +249,7 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
ConfigurationEditor configurationEditor = new ConfigurationEditor("ParametersEditor", parametersDefinition,
defaultConfiguration);
configurationEditor.setReadOnly(isReadOnly());
+ this.parameters = configurationEditor.getConfiguration();
this.operationParametersConfigurationHolder.addMember(configurationEditor);
this.operationParametersConfigurationHolder.show();
}
@@ -206,4 +257,9 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
this.operationParametersItem.setValue(value);
}
+ private String getSelectedOperationName() {
+ FormItem operationNameItem = getForm().getField(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
+ return (String)operationNameItem.getValue();
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
index 0adfdc3..c122bfb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
@@ -26,6 +26,7 @@ import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
+import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceComposite;
@@ -47,7 +48,9 @@ public class ResourceOperationScheduleDataSource extends OperationScheduleDataSo
@Override
protected ResourceOperationSchedule createOperationSchedule() {
- return new ResourceOperationSchedule();
+ ResourceOperationSchedule resourceOperationSchedule = new ResourceOperationSchedule();
+ resourceOperationSchedule.setResource(this.resourceComposite.getResource());
+ return resourceOperationSchedule;
}
@Override
@@ -68,7 +71,34 @@ public class ResourceOperationScheduleDataSource extends OperationScheduleDataSo
}
@Override
- protected void executeAdd(Record recordToAdd, DSRequest request, DSResponse response) {
- //operationService.scheduleResourceOperation();
+ protected void executeAdd(Record recordToAdd, final DSRequest request, final DSResponse response) {
+ Configuration parameters = (Configuration) request.getAttributeAsObject("parameters");
+ recordToAdd.setAttribute(Field.PARAMETERS, parameters);
+ final ResourceOperationSchedule scheduleToAdd = copyValues(recordToAdd);
+ operationService.scheduleResourceOperation(scheduleToAdd, new AsyncCallback<Integer>() {
+ public void onSuccess(Integer scheduleId) {
+ scheduleToAdd.setId(scheduleId);
+ sendSuccessResponse(request, response, scheduleToAdd);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to add " + scheduleToAdd, caught);
+ }
+ });
+ }
+
+ @Override
+ protected void executeRemove(Record recordToRemove, final DSRequest request, final DSResponse response) {
+ final ResourceOperationSchedule scheduleToRemove = copyValues(recordToRemove);
+
+ operationService.unscheduleResourceOperation(scheduleToRemove, new AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ sendSuccessResponse(request, response, scheduleToRemove);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException(caught);
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index 8d15f3c..6db4693 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -38,6 +38,7 @@ import org.rhq.core.util.IntExtractor;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
+import org.rhq.enterprise.server.exception.UnscheduleException;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies;
@@ -92,6 +93,25 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
}
}
+ public int scheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule) throws RuntimeException {
+ try {
+ return operationManager.scheduleResourceOperation(getSessionSubject(), resourceOperationSchedule);
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ public void unscheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule) throws RuntimeException {
+ try {
+ operationManager.unscheduleResourceOperation(getSessionSubject(), resourceOperationSchedule.getJobId().toString(),
+ resourceOperationSchedule.getResource().getId());
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
/** Find recently completed operations, disambiguate them and return that list.
*
*/
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 3c71dd4..827d365 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
@@ -166,12 +166,15 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
- public ResourceOperationSchedule scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule)
+ public int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule)
throws ScheduleException {
JobTrigger jobTrigger = schedule.getJobTrigger();
Trigger trigger = convertToTrigger(jobTrigger);
try {
- return scheduleResourceOperation(subject, schedule.getResource().getId(), schedule.getOperationName(), schedule.getParameters(), trigger, schedule.getDescription());
+ ResourceOperationSchedule resourceOperationSchedule = scheduleResourceOperation(subject,
+ schedule.getResource().getId(), schedule.getOperationName(), schedule.getParameters(), trigger,
+ schedule.getDescription());
+ return resourceOperationSchedule.getId();
}
catch (SchedulerException e) {
throw new ScheduleException(e);
@@ -200,6 +203,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
jobDataMap.putAsString(ResourceOperationJob.DATAMAP_INT_SUBJECT_ID, subject.getId());
jobDataMap.putAsString(ResourceOperationJob.DATAMAP_INT_RESOURCE_ID, resource.getId());
+ jobDataMap.put("description", notes);
JobDetail jobDetail = new JobDetail();
jobDetail.setName(uniqueJobId);
@@ -445,7 +449,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
String jobName = jobDetail.getName();
String jobGroup = jobDetail.getGroup();
- String description = jobDetail.getDescription();
+ String description = jobDataMap.getString("description");
String operationName = jobDataMap.getString(ResourceOperationJob.DATAMAP_STRING_OPERATION_NAME);
String displayName = jobDataMap.getString(ResourceOperationJob.DATAMAP_STRING_OPERATION_DISPLAY_NAME);
int subjectId = jobDataMap.getIntFromString(ResourceOperationJob.DATAMAP_INT_SUBJECT_ID);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
index d74a88c..a48a385 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
@@ -52,9 +52,28 @@ import org.rhq.enterprise.server.exception.UnscheduleException;
@Local
public interface OperationManagerLocal {
+
+ /**
+ * TODO
+ *
+ * @param groupId
+ *
+ * @return
+ */
public List<IntegerOptionItem> getResourceNameOptionItems(int groupId);
/**
+ * Schedules a Resource operation for execution.
+ *
+ * @param subject the user who is asking to schedule the job
+ * @param schedule the information describing the operation to be scheduled along with the schedule to be used
+ *
+ * @return the id of the {@link org.rhq.core.domain.operation.ResourceOperationScheduleEntity} created to track the
+ * scheduled operation
+ */
+ int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule);
+
+ /**
* Schedules an operation for execution on the given resource.
*
* @param subject the user who is asking to schedule the job
@@ -610,4 +629,5 @@ public interface OperationManagerLocal {
PageList<GroupOperationHistory> findGroupOperationHistoriesByCriteria(Subject subject,
GroupOperationHistoryCriteria criteria);
+
}
\ No newline at end of file
13 years, 4 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 127aa1c26de5cf82b0cfb847711ebb12a53ead65
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 12 16:34:56 2011 -0500
BZ 668105 - Top section, selected link is not highlighted
- fixed
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index 99596e0..1b3bc8c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -130,8 +130,8 @@ public class MenuBarView extends LocatableVLayout {
for (ViewName section : SECTIONS) {
String styleClass = "TopSectionLink";
- if (section.equals(currentlySelectedSection)) {
- styleClass += "Selected";
+ if (section.getName().equals(currentlySelectedSection)) {
+ styleClass = "TopSectionLinkSelected";
}
// Set explicit identifiers because the generated scLocator is not getting picked up by Selenium.
13 years, 4 months