[rhq] Branch 'gwt' - 2 commits - modules/core
by mazz
modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 8e70e180652b863016eb0b35c7ccc4e5fd1d5dd2
Merge: 011d6dc... c4f250a...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 26 18:20:26 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit 011d6dc59a9ac78a53c9714385d16029542a76e3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 26 18:20:11 2010 -0400
fix test to look for the normalize path in the map
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
index 324d46c..2fce1e4 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
@@ -228,7 +228,7 @@ public class FileHashcodeMapTest {
assert currentMap.getDeletions().get("test2.txt").equals(currentMap.get("test2.txt"));
assert currentMap.getChanges().size() == 2;
assert currentMap.getChanges().get("test1.txt").equals(currentMap.get("test1.txt"));
- assert currentMap.getChanges().get(absPathFile.getAbsolutePath()).equals(
+ assert currentMap.getChanges().get(currentMap.convertPath(absPathFile.getAbsolutePath())).equals(
currentMap.get(absPathFile.getAbsolutePath()));
assert currentMap.getIgnored().size() == 2 : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap.getIgnored();
@@ -255,7 +255,7 @@ public class FileHashcodeMapTest {
currentMap.get("subdir" + fileSeparator + "test4.txt"));
assert currentMap.getDeletions().size() == 2;
assert currentMap.getDeletions().get("test2.txt").equals(currentMap.get("test2.txt"));
- assert currentMap.getDeletions().get(absPathFile.getAbsolutePath()).equals(
+ assert currentMap.getDeletions().get(currentMap.convertPath(absPathFile.getAbsolutePath())).equals(
currentMap.get(absPathFile.getAbsolutePath()));
assert currentMap.getChanges().size() == 1;
assert currentMap.getChanges().get("test1.txt").equals(currentMap.get("test1.txt"));
14 years, 1 month
[rhq] Branch 'gwt' - 73 commits - etc/eclipse-tools modules/core modules/enterprise modules/plugins
by ips
etc/eclipse-tools/maven/RHQ | 4
modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java | 37
modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java | 10
modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java | 102 +
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java | 222 +++
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java | 34
modules/core/dbutils/src/main/resources/db-ant-tasks.properties | 1
modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml | 15
modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 8
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 736 ++++------
modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java | 34
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 1
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java | 50
modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroup.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroupPK.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/LockedResource.java | 50
modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java | 162 ++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/FlyweightCache.java | 253 +++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceAvailabilityFlyweight.java | 111 +
modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceFlyweight.java | 148 ++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceSubCategoryFlyweight.java | 95 +
modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceTypeFlyweight.java | 114 +
modules/enterprise/gui/alert-migration/README.txt | 18
modules/enterprise/gui/alert-migration/etc/dumpAlertDefinitions.js | 14
modules/enterprise/gui/alert-migration/pom.xml | 254 ---
modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/Alert13Parser.java | 202 --
modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/MigrationServlet.java | 100 -
modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/RestoreAlerts.java | 71
modules/enterprise/gui/alert-migration/src/main/webapp/WEB-INF/web.xml | 27
modules/enterprise/gui/alert-migration/src/main/webapp/index.html | 17
modules/enterprise/gui/alert-migration/src/test/java/Alert13ParserTest.java | 83 -
modules/enterprise/gui/alert-migration/src/test/resources/alertDef.csv | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 66
modules/enterprise/gui/pom.xml | 1
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java | 8
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java | 27
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java | 19
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java | 18
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java | 21
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java | 20
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java | 104 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java | 27
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java | 167 --
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml | 10
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml | 8
modules/enterprise/gui/portal-war/src/main/webapp/rhq/entity/layout/main.xhtml | 19
modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml | 24
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml | 31
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java | 3
modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh | 2
modules/enterprise/server/ear/pom.xml | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java | 168 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 36
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 164 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java | 3
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java | 18
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java | 555 +++++--
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java | 141 -
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateMeasurementSubsystemTest.java | 216 --
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateNativesSubsystemTest.java | 71
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateOperationsSubsystemTest.java | 130 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java | 466 ++++--
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceTypeSubsystemTest.java | 72
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java | 122 +
modules/enterprise/server/jar/src/test/resources/log4j.xml | 5
modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v1.xml | 2
modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v2.xml | 2
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java | 6
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java | 5
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 4
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/mappingImpl/MappingToAugeasParamPerMap.java | 11
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/ApacheDirectiveRegExpression.java | 28
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/SpecificParams.java | 126 +
modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml | 17
modules/plugins/augeas/src/main/java/org/rhq/augeas/tree/impl/AbstractAugeasTree.java | 2
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java | 6
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java | 10
modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java | 2
87 files changed, 3507 insertions(+), 2528 deletions(-)
New commits:
commit c4f250ab8591ae456b0abbc027ddc4501963dfd3
Merge: e3f54d7... 5f9cbe0...
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Apr 26 18:18:40 2010 -0400
Merge branch 'master' into gwt
commit 5f9cbe0fdb8074deadbcb091899441dc80ae2f52
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Apr 26 10:27:22 2010 -0400
switch back to old JBoss repo; add some blank lines to improve readability; remove no-longer-needed Wagon extensions
(cherry picked from commit 8b1db8427287236d45ebedb11a07999a2485eda8)
diff --git a/pom.xml b/pom.xml
index 9dab40a..88f81e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,8 @@
-<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">
+<?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">
<modelVersion>4.0.0</modelVersion>
@@ -24,10 +28,11 @@
</scm>
<issueManagement>
- <system>jira</system>
- <url>http://jira.rhq-project.org/</url>
+ <system>bugzilla</system>
+ <url>https://bugzilla.redhat.com/</url>
</issueManagement>
+
<properties>
<rhq.groupId>org.rhq</rhq.groupId>
<rhq.product.name>RHQ</rhq.product.name>
@@ -124,6 +129,7 @@
<localRepository>${user.home}/.m2/repository</localRepository>
</properties>
+
<dependencyManagement>
<dependencies>
@@ -386,6 +392,7 @@
</dependencyManagement>
+
<dependencies>
<dependency>
@@ -432,6 +439,7 @@
</dependencies>
+
<build>
<defaultGoal>install</defaultGoal>
@@ -816,70 +824,21 @@
</plugins>
- <!-- To allow deploying release artifacts to SVN and snapshot artifacts to HTTP/Dav. -->
-<!--
- <extensions>
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-scm</artifactId>
- <version>1.0-beta-6</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-manager-plexus</artifactId>
- <version>1.0</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-svnexe</artifactId>
- <version>1.0</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav</artifactId>
- <version>1.0-beta-2</version>
- </extension>
- </extensions>
--->
</build>
+
<repositories>
- <repository>
- <id>jboss-public-repository-group</id>
- <name>JBoss Public Maven Repository Group</name>
- <url>https://repository.jboss.org/nexus/content/groups/public/</url>
- <layout>default</layout>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </releases>
-<!--
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
--->
- </repository>
+ <repository>
+ <id>jboss-deprecated-repository</id>
+ <name>JBoss Deprecated</name>
+ <url>https://repository.jboss.org/maven2/</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ </repository>
</repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>jboss-public-repository-group</id>
- <name>JBoss Public Maven Repository Group</name>
- <url>https://repository.jboss.org/nexus/content/groups/public/</url>
- <layout>default</layout>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </releases>
-<!--
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
--->
- </pluginRepository>
- </pluginRepositories>
<distributionManagement>
@@ -897,10 +856,12 @@
</distributionManagement>
+
<modules>
<module>modules</module>
</modules>
+
<profiles>
<profile>
<id>ojdbc-driver</id>
@@ -1055,13 +1016,16 @@
</profiles>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3</version>
- </plugin>
- </plugins>
- </reporting>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>2.3.1</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
</project>
+
commit 4fd30d06a5ad9001591e4a573a3051ef657c1ae8
Merge: 7bb4095... e529883...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 26 14:21:51 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 7bb40954466ae844f2135f8062d4cd4ad0385bd2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 26 14:05:17 2010 +0200
BZ 548172 pg_relation_size() no longer understands names in postgres 8.4+
Also prevent a NPE from unboxing.
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
index c69496f..ff21e78 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
@@ -55,7 +55,7 @@ public class PostgresTableComponent implements DatabaseComponent<PostgresDatabas
private static final List<String> PG_STAT_USER_TABLE_STATS = Arrays.asList("seq_scan", "seq_tup_read", "idx_scan",
"idx_tup_fetch", "n_tup_ins", "n_tup_upd", "n_tup_del", "table_size", "total_size");
- public static final String PG_STAT_USER_TABLES_QUERY = "SELECT ts.*, pg_relation_size(ts.relname) AS table_size, pg_total_relation_size(ts.relname) AS total_size, \n"
+ public static final String PG_STAT_USER_TABLES_QUERY = "SELECT ts.*, pg_relation_size(ts.relid) AS table_size, pg_total_relation_size(ts.relid) AS total_size, \n"
+ " ios.heap_blks_read, ios.heap_blks_hit, ios.idx_blks_read, ios.idx_blks_hit, \n"
+ " ios.toast_blks_read, ios.toast_blks_hit, ios.tidx_blks_read, ios.tidx_blks_hit \n"
+ "FROM pg_stat_user_tables ts LEFT JOIN pg_statio_user_tables ios on ts.relid = ios.relid \n"
@@ -90,7 +90,7 @@ public class PostgresTableComponent implements DatabaseComponent<PostgresDatabas
getTableName());
for (MeasurementScheduleRequest request : requests) {
String metricName = request.getName();
- double value;
+ Double value;
if (metricName.equals("rows")) {
value = DatabaseQueryUtility.getSingleNumericQueryValue(this, PG_COUNT_ROWS + getTableName());
} else if (metricName.equals("rows_approx")) {
@@ -99,8 +99,10 @@ public class PostgresTableComponent implements DatabaseComponent<PostgresDatabas
value = results.get(metricName);
}
- MeasurementDataNumeric mdn = new MeasurementDataNumeric(request, value);
- report.addData(mdn);
+ if (value!=null) {
+ MeasurementDataNumeric mdn = new MeasurementDataNumeric(request, value);
+ report.addData(mdn);
+ }
}
}
commit 3b0f9d16573db48e4d5f85463a8d550356c79c2b
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 26 11:58:20 2010 +0200
Prevent NPE if no sshd is running/found.
diff --git a/modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java b/modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java
index a2cd1a6..c84beb5 100644
--- a/modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java
+++ b/modules/plugins/sshd/src/main/java/org/rhq/plugins/sshd/OpenSSHDComponent.java
@@ -70,7 +70,7 @@ public class OpenSSHDComponent implements ResourceComponent, ConfigurationFacet,
}
public AvailabilityType getAvailability() {
- return processInfo.isRunning() ? AvailabilityType.UP : AvailabilityType.DOWN;
+ return (processInfo != null && processInfo.isRunning()) ? AvailabilityType.UP : AvailabilityType.DOWN;
}
private void getSSHDProcess() {
commit e5298839fe034f63c45b100c2a1f2e5464794d23
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 19:15:39 2010 -0400
BZ-567297 add deletion/removal functionality to the inventory browser group tab
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
index 5c39367..37941e7 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
@@ -3,17 +3,20 @@ package org.rhq.enterprise.gui.inventory.browse;
import java.util.ArrayList;
import java.util.List;
+import javax.faces.application.FacesMessage;
import javax.faces.model.DataModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.gui.util.FacesContextUtility;
+import org.rhq.core.gui.util.StringUtility;
import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
@@ -93,4 +96,28 @@ public class BrowseGroupsUIBean extends PagedDataTableUIBean {
// offer suggestions based on currentInputText
return suggestions;
}
+
+ public String deleteSelectedGroups() {
+ try {
+ Subject subject = getSubject();
+
+ String[] selectedGroups = getSelectedItems();
+ int[] groupIds = StringUtility.getIntArray(selectedGroups);
+
+ for (int nextGroupId : groupIds) {
+ groupManager.deleteResourceGroup(subject, nextGroupId);
+ }
+
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted selected groups");
+ } catch (Exception e) {
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Failed to delete all selected groups", e);
+ }
+
+ return "success";
+ }
+
+ private String[] getSelectedItems() {
+ return FacesContextUtility.getRequest().getParameterValues("selectedItems");
+ }
+
}
commit 190d928d699c43b53b4f794b113fe035c701a10c
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 19:02:41 2010 -0400
BZ-585255 - fix resource search from the menu bar to properly show disambiguated results
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
index fb41230..232974b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
@@ -136,7 +136,7 @@
<rich:suggestionbox id="resourceSelectBox" for="selectedResource" tokens=",[]"
ajaxSingle="true" immediate="true"
suggestionAction="#{ResourceSelectUIBean.autocomplete}"
- var="result" data="foo" fetchValue="#{result.resource.id}"
+ var="result" data="foo" fetchValue="#{result.original.resource.id}"
nothingLabel="No matching resources found"
style="background-color: #cccccc;"
onselect="document.location.href='#{onf:getDefaultResourceTabURL()}?id=' + #{rich:element('selectedResource')}.value"
@@ -144,15 +144,15 @@
<h:column>
<f:facet name="header">Avail</f:facet>
<h:graphicImage
- value="/images/icons/availability_#{result.availability == 'UP' ? 'green' : 'red'}_16.png"/>
+ value="/images/icons/availability_#{result.original.availability == 'UP' ? 'green' : 'red'}_16.png"/>
</h:column>
<h:column>
<f:facet name="header">Resource</f:facet>
- <h:outputText value="#{result.resource.name}"/>
+ <h:outputText value="#{result.original.resource.name}"/>
</h:column>
<h:column>
<f:facet name="header">Parent</f:facet>
- <h:outputText value="#{result.parent.name}"/>
+ <h:outputText value="#{result.original.parent.name}"/>
</h:column>
</rich:suggestionbox>
</h:panelGroup>
commit 55e50e5881b78557432e365da3eb05f11f832ff5
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 23 17:01:56 2010 -0400
-updated log4j.xml to reduce unit test hibernate verbosity
-fixed failing test UpdateEventsSubsystemTest.testDeleteEventStuff()
-fixed a log message
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
index 270fad3..1031f42 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
@@ -46,7 +46,7 @@ public class SubcategoryTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testAddDeleteDefaultTemplate");
+ + ".testAddResourcTypeWithKnownSubCategory");
}
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
index 78d2788..4c8ab8a 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
@@ -45,12 +45,14 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
+ static final boolean ENABLED = true;
+
@Override
protected String getSubsystemDirectory() {
return "events";
}
- @Test
+ @Test(enabled = ENABLED)
public void testCreateDeleteEvent() throws Exception {
System.out.println("= testCreateDeleteEvent");
try {
@@ -124,7 +126,7 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
* Simulate just redeploying the plugin with no change in descriptor.
* @throws Exception
*/
- @Test
+ @Test(enabled = ENABLED)
public void testNoOpChange() throws Exception {
System.out.println("= testNoOpChange");
try {
@@ -172,7 +174,7 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testDeleteEventStuff() throws Exception {
System.out.println("= testDeleteEvent");
EventManagerLocal eventManager = LookupUtil.getEventManager();
@@ -186,8 +188,6 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("event1-2.xml");
getTransactionManager().begin();
entityManager = getEntityManager();
- getPluginId(entityManager);
-
platform = getResourceType("events");
testResource = new Resource("-test-", "-test resource", platform);
@@ -198,13 +198,13 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
getTransactionManager().begin();
entityManager = getEntityManager();
- //platform = getResourceType("events");
platform = entityManager.find(ResourceType.class, platform.getId());
testResource = entityManager.find(Resource.class, testResource.getId());
Set<EventDefinition> eDefs = platform.getEventDefinitions();
assert eDefs.size() == 2 : "Did not find the expected 2 eventDefinitions, but " + eDefs.size();
Iterator<EventDefinition> eIter = eDefs.iterator();
boolean found = false;
+ Map<EventSource, Set<Event>> events = new HashMap<EventSource, Set<Event>>(1);
while (eIter.hasNext()) {
EventDefinition def = eIter.next();
if (def.getName().equals("hans")) {
@@ -212,18 +212,17 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
// We got the definition that will vanish later, so attach some stuff to it
EventSource source = new EventSource("test location", def, testResource);
entityManager.persist(source);
+
Event ev = new Event(def.getName(), source.getLocation(), System.currentTimeMillis(),
EventSeverity.INFO, "This is a test");
- // entityManager.persist(ev); // We can't do this, as Event.source does not get filled this way :(
- Map<EventSource, Set<Event>> events = new HashMap<EventSource, Set<Event>>(1);
Set<Event> evSet = new HashSet<Event>(1);
evSet.add(ev);
events.put(source, evSet);
- eventManager.addEventData(events);
}
}
assert found : "Hans was not found";
getTransactionManager().commit();
+ eventManager.addEventData(events);
/*
* --- done with the setup ---
diff --git a/modules/enterprise/server/jar/src/test/resources/log4j.xml b/modules/enterprise/server/jar/src/test/resources/log4j.xml
index b9817dd..d721bff 100644
--- a/modules/enterprise/server/jar/src/test/resources/log4j.xml
+++ b/modules/enterprise/server/jar/src/test/resources/log4j.xml
@@ -44,6 +44,11 @@
</layout>
</appender>
+ <!-- Hibernate logs WARNINGS frequent from this class, in test envs. -->
+ <category name="org.hibernate.hql.ast.QueryTranslatorImpl">
+ <priority value="ERROR"/>
+ </category>
+
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
commit 520863990da701f0ba2c239726fa5bfac992afda
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 23 16:07:08 2010 -0400
Fix the cleanup of this test.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
index 696a25c..270fad3 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/SubcategoryTest.java
@@ -18,8 +18,6 @@
*/
package org.rhq.enterprise.server.resource.metadata.test;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.testng.annotations.Test;
/**
@@ -29,8 +27,6 @@ import org.testng.annotations.Test;
*/
public class SubcategoryTest extends UpdateSubsytemTestBase {
- private final Log log = LogFactory.getLog(SubcategoryTest.class);
-
@Override
protected String getSubsystemDirectory() {
return "resource";
@@ -38,14 +34,20 @@ public class SubcategoryTest extends UpdateSubsytemTestBase {
@Test
public void testAddResourcTypeWithKnownSubCategory() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("test-subcategories.xml");
registerPlugin("test-subcategories3.xml");
-
-
} finally {
- getTransactionManager().rollback();
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testAddDeleteDefaultTemplate");
+ }
}
}
commit 3259b72fe1efb4b46c0f47e2ef82b2de89b23c09
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 23 14:46:17 2010 -0400
Fixed a couple of too-long constraint names for ora.
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 8a89f96..6974780 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2066,7 +2066,7 @@
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_ALERT_NOTIFICATION_SENDER_CONFIG_ID_FK
+ ADD CONSTRAINT RHQ_AN_SENDER_CONFIG_ID_FK
FOREIGN KEY (SENDER_CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
@@ -2094,7 +2094,7 @@
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_ALERT_NOTIFICATION_TEMPLATE_ID_FK
+ ADD CONSTRAINT RHQ_AN_TEMPLATE_ID_FK
FOREIGN KEY (TEMPLATE_ID)
REFERENCES RHQ_ALERT_NOTIF_TEMPL (ID)
</statement>
commit 6d0e513b5a6ba7005e5da47c328a55a8104a7f19
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 13:17:31 2010 -0400
remove mention of the alert-migration maven module, since it is no longer needed
diff --git a/modules/enterprise/gui/pom.xml b/modules/enterprise/gui/pom.xml
index 5a91cab..0c529ba 100644
--- a/modules/enterprise/gui/pom.xml
+++ b/modules/enterprise/gui/pom.xml
@@ -38,7 +38,6 @@
<module>base-perspective-war</module>
<module>webdav-war</module>
<module>content_http-war</module>
- <module>alert-migration</module>
<module>coregui</module>
</modules>
</profile>
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 0cc1fb2..eba5172 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -80,13 +80,6 @@
<type>war</type>
</dependency>
- <dependency>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>alert-migration</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- </dependency>
-
<!-- ** SARs -->
<!--
<dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server-agent-sar</artifactId>
@@ -193,13 +186,6 @@
<contextRoot>/content</contextRoot>
</webModule>
- <webModule>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>alert-migration</artifactId>
- <bundleFileName>alert-migration.war</bundleFileName>
- <contextRoot>/alert-migration</contextRoot>
- </webModule>
-
<!-- ** EJB-JARs -->
<ejbModule>
commit 3d3f6dd4d74aa463dc54208aef82fd127be40a27
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 13:14:24 2010 -0400
alert notifications are now db-upgraded using the standard mechanism, this project is no longer needed
diff --git a/modules/enterprise/gui/alert-migration/README.txt b/modules/enterprise/gui/alert-migration/README.txt
deleted file mode 100644
index 511720f..0000000
--- a/modules/enterprise/gui/alert-migration/README.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-
-This module is to migrate alert definitions from rhq 1.3.1 to rhq 3
-
-You need to follow those steps:
-
-- have rhq 1.3.1 running
-- dump the old alerts (running the scripts need java 1.6 )
-
- $ rhq-cli.sh -u rhqadmin -p rhqadmin -f dumpAlertDefinitions.js
-
- This will dump the alert definitions in to a file called alertDefinitions.csv
- in the current directory
-
-- download rhq 3 and run the installer
-- *after* running the installer, direct the
- browser to localhost:7080/alert-migration
- and upload the alertDefinitions.csv file
-
diff --git a/modules/enterprise/gui/alert-migration/etc/dumpAlertDefinitions.js b/modules/enterprise/gui/alert-migration/etc/dumpAlertDefinitions.js
deleted file mode 100644
index d5c45b3..0000000
--- a/modules/enterprise/gui/alert-migration/etc/dumpAlertDefinitions.js
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# CLI script to export Alert Definitions
-# Writes the dump to a file 'alertDefinitions.csv' in the
-# current directory - appends to this file if it already exists.
-# call it liek this: "rhq-cli.sh -u rhqadmin -p rhqadmin -f dumpAlertDefinitions.js"
-#
-criteria = new AlertDefinitionCriteria()
-criteria.fetchAlertNotifications(true)
-
-defs = AlertDefinitionManager.findAlertDefinitionsByCriteria(subject,criteria)
-
-exporter.setTarget('csv', 'alertDefinitions.csv')
-exporter.write(defs)
-
diff --git a/modules/enterprise/gui/alert-migration/pom.xml b/modules/enterprise/gui/alert-migration/pom.xml
deleted file mode 100644
index b7e8205..0000000
--- a/modules/enterprise/gui/alert-migration/pom.xml
+++ /dev/null
@@ -1,254 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
- <parent>
- <artifactId>rhq-helpers</artifactId>
- <groupId>org.rhq.helpers</groupId>
- <version>3.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.rhq.helpers</groupId>
- <artifactId>alert-migration</artifactId>
- <packaging>war</packaging>
-
- <name>RHQ alert migration</name>
- <description>Migrate alert notification from RHQ 1.3.1 to RHQ 3 format</description>
-
- <scm>
- <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/ale...</connection>
- <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/ale...</developerConnection>
- </scm>
-
- <dependencies>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope> <!-- by ear -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope> <!-- by rhq.ear (as ejb-jar) -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-util</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope> <!-- by rhq.ear -->
- </dependency>
-
-
- <dependency>
- <groupId>net.sf.opencsv</groupId>
- <artifactId>opencsv</artifactId>
- <version>2.0</version>
- </dependency>
-
- <!-- This is a fix for the Javac bug requiring annotations to be
- available when compiling dependent classes. -->
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>hibernate-all</artifactId>
- <version>1.0.0.Alpha9</version>
- <scope>provided</scope>
- <!-- needed for referenced domain entities that use Hibernate annotations -->
- </dependency>
-
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>jboss-ejb3-all</artifactId>
- <version>1.0.0.Alpha9</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
-
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.2</version>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3.1</version>
- </dependency>
-
- <dependency>
- <groupId>i18nlog</groupId>
- <artifactId>i18nlog</artifactId>
- <version>1.0.9</version>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <finalName>alert-migration</finalName>
-
- <plugins>
-
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Build-Number>${buildNumber}</Build-Number>
- </manifestEntries>
- </archive>
- <webResources>
- <resource>
- <filtering>false</filtering>
- <directory>${basedir}/src/main/webapp</directory>
- <!--<includes>-->
- <!--<include>**/*.properties</include>-->
- <!--</includes>-->
- </resource>
- <!--<resource>-->
- <!--<filtering>true</filtering>-->
- <!--<directory>${basedir}/target/resources</directory>-->
- <!--<includes>-->
- <!--<include>**/*.properties</include>-->
- <!--</includes>-->
- <!--</resource>-->
- </webResources>
- </configuration>
- </plugin>
-
-<!--
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>Generate I18N Resource Bundles</id>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <- - generate the I18N resource bundles - - >
- <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
- <- -<i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">- ->
- <i18n outputdir="${basedir}/target/resources/WEB-INF/classes" defaultlocale="en" verbose="false" append="false" verify="true">
- <classpath refid="maven.runtime.classpath" />
- <classfileset dir="${project.build.outputDirectory}">
- <include name="**/*I18NResourceKeys.class" />
- </classfileset>
- </i18n>
- <copy todir="${project.build.outputDirectory}" encoding="UTF-8" outputencoding="UTF-8">
- <fileset dir="${basedir}/target/resources/WEB-INF/classes">
- <include name="InstallerMessages*.properties" />
- </fileset>
- <mapper type="glob" from="*" to="*.unfiltered" />
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
--->
- </plugins>
-
- </build>
-
- <profiles>
-
- <profile>
- <id>dev</id>
-
- <properties>
- <rhq.rootDir>../../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentName>${project.build.finalName}.war</rhq.deploymentName>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}</rhq.deploymentDir>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
-
- <execution>
- <id>deploy-classes</id>
- <phase>compile</phase>
- <configuration>
- <tasks>
- <property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" />
- <echo>*** Copying updated files from target/classes to ${classes.dir}...</echo>
- <copy todir="${classes.dir}" verbose="${rhq.verbose}">
- <fileset dir="target/classes" />
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>deploy</id>
- <phase>package</phase>
- <configuration>
- <tasks>
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Copying updated files from target${file.separator}${project.build.finalName}${file.separator} to ${deployment.dir}${file.separator}...</echo>
- <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
- <fileset dir="${basedir}/target/${project.build.finalName}" />
- </copy>
- <delete dir="${deployment.dir}.rej" /> <!-- need to remove any residual backups -->
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <tasks>
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
- <delete dir="${deployment.dir}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
-
- </profiles>
-</project>
\ No newline at end of file
diff --git a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/Alert13Parser.java b/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/Alert13Parser.java
deleted file mode 100644
index 9107354..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/Alert13Parser.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * 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.helpers.alertMigration;
-
-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.io.StringReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import au.com.bytecode.opencsv.CSVReader;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-
-/**
- * Parser for a dump of the 1.3 alert structures via CLI
- * @author Heiko W. Rupp
- */
-public class Alert13Parser {
-
- private final Log log = LogFactory.getLog(Alert13Parser.class);
- File inputFile;
- Reader inputReader;
-
- public static final String RHQ_USERS = "RHQ Users";
-
- public Alert13Parser(File input) {
- this.inputFile = input;
- try {
- inputReader = new FileReader(input);
- } catch (FileNotFoundException e) {
- throw new RuntimeException("File " + input.getAbsolutePath() + " not found");
- }
- }
-
- public Alert13Parser(Reader reader) {
- inputReader = reader;
- }
-
- public Alert13Parser(InputStream stream) {
- inputReader = new InputStreamReader(stream);
- }
-
-
-
- public List<AlertNotification> parse() {
-
- List<AlertNotification> result = new ArrayList<AlertNotification>();
-
- List<String[]> lines = null;
- try {
- CSVReader reader = new CSVReader(inputReader);
- lines = reader.readAll();
- reader.close();
-
-
- boolean isFirst = true;
- for (String[] line : lines) {
- if (isFirst) { // Skip over first line with headers
- isFirst=false;
- continue;
- }
- if (line.length<2) // Skip over empty lines
- continue;
-
- log.debug(Arrays.asList(line));
- String tmp = line[9]; // alert definition id
- int alertDefinitionId = Integer.valueOf(tmp);
- log.debug(" adefid " + alertDefinitionId);
-
- tmp = line[1]; // Notifications
- CSVReader nr = new CSVReader(new StringReader(tmp));
- String[] notifications = nr.readNext();
- int i = 0;
- int pos = 0;
- while (i < notifications.length) {
- int nid;
- String n = notifications[i];
- log.debug(" Notification: " + n);
- /*
- * A single notification now runs over multiple lines
- */
- if (n.startsWith("[") || n.startsWith(" "))
- n = n.substring(1);
-
- if (n.equals("]")) {
- i++;
- continue;
- }
-
- nid = Integer.valueOf(getField(n,"id"));
-
-
- AlertNotification alNo = new AlertNotification(alertDefinitionId,nid);
- Configuration config = new Configuration();
- alNo.setConfiguration(config);
- alNo.setOrder(pos);
-
- if (n.startsWith("Subject")) {
- String subjectId = getField(notifications[i+1],"id");
- String subject = getField(notifications[i+2],"name");
- i+=4;
- log.debug("subject: " + subjectId);
- config.put(new PropertySimple("subjectId", subjectId));
- alNo.setSenderName(RHQ_USERS);
- alNo.setName(subject);
-
- } else if (n.startsWith("Role")) {
- String roleId = getField(notifications[i+1],"id");
- String role = getField(notifications[i+2],"name");
- i+=4;
- log.debug("role: " + roleId);
- config.put(new PropertySimple("roleId", roleId));
- alNo.setSenderName("Roles");
- alNo.setName(role);
-
-
- } else if (n.startsWith("Snmp")) {
- String host = getField(notifications[i+1],"host");
- String port = getField(notifications[i+2],"port");
- String oid = getField(notifications[i+3],"oid");
- i+=5;
- log.debug("snmp: " + host + ", " + port + ", " + oid);
- config.put(new PropertySimple("host",host));
- config.put(new PropertySimple("port",port));
- config.put(new PropertySimple("OID",oid));
- alNo.setSenderName("SNMP");
- alNo.setName(host+oid);
-
- } else if (n.startsWith("Email")) {
- String emails = getField(notifications[i+1],"emailAddress");
- log.debug("email: " + emails);
- config.put(new PropertySimple("emailAddress",emails));
- alNo.setSenderName("Email");
- alNo.setName(emails);
- i+=3;
- } else {
- log.error("Unknown notification :>" + n + "<");
- i++;
- }
- log.debug(" -- for nid : " + nid);
-
- result.add(alNo);
- pos++;
- }
-
- tmp = line[12];
- nr = new CSVReader(new StringReader(tmp));
- String[] operations = nr.readNext();
-// for (String op: operations) {
-// log.debug(" Operation: " + op);
-// }
-
- }
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- return result;
- }
-
- return result;
- }
-
- private String getField(String input, String fieldName) {
-
- String str = fieldName + "=";
- int pos = input.indexOf(str);
- if (pos==-1)
- return "";
- String tmp = input.substring(pos+str.length());
- if (tmp.endsWith("]"))
- tmp = tmp.substring(0,tmp.length()-1);
-
- return tmp;
- }
-}
diff --git a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/MigrationServlet.java b/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/MigrationServlet.java
deleted file mode 100644
index 9ac4b25..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/MigrationServlet.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.helpers.alertMigration;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * Simple servlet to upload an rhq 1.3 alert definition dump after
- * migrating the database to rhq 3.0 format.
- *
- * @author Heiko W. Rupp
- */
-public class MigrationServlet extends HttpServlet {
-
- private final Log log = LogFactory.getLog(MigrationServlet.class);
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- PrintWriter writer;
- if (ServletFileUpload.isMultipartContent(req)){
-
- ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
- List fileItemsList = null;
- try {
- fileItemsList = servletFileUpload.parseRequest(req);
- } catch (FileUploadException e) {
-
- writer = resp.getWriter();
- writer.write("<strong>File upload failed: </strong><br/>");
- for (StackTraceElement elem : e.getStackTrace())
- writer.write(elem.toString() + "br/>");
- writer.flush();
- return;
- }
-
- Iterator it = fileItemsList.iterator();
- while (it.hasNext()){
- FileItem fileItem = (FileItem)it.next();
- if (fileItem.isFormField()){
- /* The file item contains a simple name-value pair of a form field */
- // TODO flag as error ?
- }
- else{
- /* The file item contains an uploaded file */
-
- Alert13Parser parser = new Alert13Parser(fileItem.getInputStream());
- List<AlertNotification> notifications = parser.parse();
- AlertNotificationManagerLocal notificationManager = LookupUtil.getAlertNotificationManager();
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
- notificationManager.mergeTransientAlertNotifications(overlord,notifications);
-
- writer = resp.getWriter();
- writer.write("<strong>Alert Definitions have been migrated</strong><p/>");
- writer.write("<a href=\"/Dashboard.do\">To the RHQ Dashboard</a>");
- writer.flush();
-
- }
- }
- }
-
- }
-}
diff --git a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/RestoreAlerts.java b/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/RestoreAlerts.java
deleted file mode 100644
index 7e9e761..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/java/org/rhq/helpers/alertMigration/RestoreAlerts.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.helpers.alertMigration;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-
-/**
- * Read in a dump file and print the Alert notifications to stdout.
- * Only useful for testing.
- *
- * @author Heiko W. Rupp
- */
-public class RestoreAlerts {
-
- private final Log log = LogFactory.getLog(RestoreAlerts.class);
-
-
- public static void main(String[] args) {
-
- if (args.length<1) {
- usage();
- System.exit(1);
- }
-
- File file = new File(args[0]);
- if (!file.canRead()) {
- System.err.println("Can not read file " + file.getAbsolutePath());
- System.exit(2);
- }
-
- Alert13Parser parser = new Alert13Parser(file);
- List<AlertNotification> notifications = parser.parse();
-
- System.out.println("Found " + notifications.size() + " notifications in the dump");
- for (AlertNotification n : notifications)
- System.out.println(n);
-
- }
-
-
- private static void usage() {
- System.out.println("Usage:");
- System.out.println(" RestoreAlerts inputFile");
- }
-
-}
diff --git a/modules/enterprise/gui/alert-migration/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/alert-migration/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index ec27207..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0"?>
-
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
- version="2.4">
-
- <display-name>RHQ Alert Migration Helper</display-name>
- <description>RHQ Alert Migration Helper. This is uesd to migrate 1.3.1 style alerts to the 3.0 format.</description>
-
- <servlet>
- <servlet-name>Migration Servlet</servlet-name>
- <servlet-class>org.rhq.helpers.alertMigration.MigrationServlet</servlet-class>
- <load-on-startup>2</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>Migration Servlet</servlet-name>
- <url-pattern>/migration</url-pattern>
- </servlet-mapping>
-
-
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- </welcome-file-list>
-
-</web-app>
\ No newline at end of file
diff --git a/modules/enterprise/gui/alert-migration/src/main/webapp/index.html b/modules/enterprise/gui/alert-migration/src/main/webapp/index.html
deleted file mode 100644
index 0650df0..0000000
--- a/modules/enterprise/gui/alert-migration/src/main/webapp/index.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
- <title>Alert Migration</title>
-</head>
-<body>
-
-<h1>Alert Migration</h1>
-<strong>Please supply the dump file</strong>
-<form action="migration" method="POST" enctype="multipart/form-data">
- <input name="alertDumpFile" type="file" size="50" maxlength="100000" accept="text/*">
- <br/>
- <input type="submit" value="Upload!">
-</form>
-</body>
-</html>
\ No newline at end of file
diff --git a/modules/enterprise/gui/alert-migration/src/test/java/Alert13ParserTest.java b/modules/enterprise/gui/alert-migration/src/test/java/Alert13ParserTest.java
deleted file mode 100644
index d038f8e..0000000
--- a/modules/enterprise/gui/alert-migration/src/test/java/Alert13ParserTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.helpers.alertMigration.Alert13Parser;
-
-/**
- * Test for the alert13 parser
- * @author Heiko W. Rupp
- */
-@Test
-public class Alert13ParserTest {
-
- private final Log log = LogFactory.getLog(Alert13ParserTest.class);
-
-
-
- public void testParser() throws Exception {
-
- File input = new File("src/test/resources/alertDef.csv");
-
- Alert13Parser parser = new Alert13Parser(input);
- List<AlertNotification> notifications = parser.parse();
-
- assert notifications != null;
- assert notifications.size()==15 : "Did not find 15 notifications, but " + notifications.size();
-
- for (AlertNotification n : notifications) {
-
- switch (n.getAlertNotificationId()) {
- case 10001:
- assert n.getAlertDefinitionId() == 10001;
- assert n.getSenderName().equals(Alert13Parser.RHQ_USERS);
- break;
- case 10011:
- assert n.getAlertDefinitionId() == 10011;
- assert n.getSenderName().equals("Roles");
- break;
- case 10002:
- assert n.getAlertDefinitionId() == 10011;
- assert n.getSenderName().equals("Email");
- assert n.getConfiguration().getSimpleValue("emailAddress","").equals("hwr(a)bsd.de");
- break;
- case 10031:
- assert n.getAlertDefinitionId() == 10011;
- assert n.getSenderName().equals("Email");
- assert n.getConfiguration().getSimpleValue("emailAddress","").equals("hwr(a)pilhuhn.de");
- break;
- case 10032:
- assert n.getAlertDefinitionId() == 10051;
- assert n.getSenderName().equals("SNMP");
- Configuration c = n.getConfiguration();
- assert c.getSimpleValue("host","").equals("localhost");
- assert c.getSimpleValue("OID","").equals("1.2.3.4.5.6.7");
-
- }
- }
- }
-}
diff --git a/modules/enterprise/gui/alert-migration/src/test/resources/alertDef.csv b/modules/enterprise/gui/alert-migration/src/test/resources/alertDef.csv
deleted file mode 100644
index 4a7bb87..0000000
--- a/modules/enterprise/gui/alert-migration/src/test/resources/alertDef.csv
+++ /dev/null
@@ -1,13 +0,0 @@
-"alertDampening","alertNotifications","conditionExpression","context","controlFiltered","deleted","description","enabled","groupAlertDefinition","id","name","notifyFiltered","operationDefinition","parentId","priority","readOnly","recoveryId","resource","resourceGroup","resourceType","willRecover"
-
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[SubjectNotification[id=10001, subject=org.rhq.core.domain.auth.Subject[id=2,name=rhqadmin], ]]","ANY","Resource","false","false","","false","null","10001","test1","false","null","0","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","false"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10011, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], EmailNotification[id=10031, emailAddress=hwr(a)pilhuhn.de, ], EmailNotification[id=10002, emailAddress=hwr(a)bsd.de, ]]","ANY","Resource","false","false","","false","null","10011","test2","false","null","0","!!! - High","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","false"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10021, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10022, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Group","false","false","","true","null","10041","Group Alert","false","null","0","!! - Medium","false","0","null","ResourceGroup[id=10001, name=ASse, category=COMPATIBLE, type=JBossAS Server, isDynaGroup=false, isClusterGroup=false]","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10023, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10024, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Resource","false","false","","true","org.rhq.core.domain.alert.AlertDefinition[ id=10041, name=Group Alert, conditionExpression=ANY, priority=!! - Medium, ]","10042","Group Alert","false","null","0","!! - Medium","false","0","Resource[id=10004, type=JBossAS Server, key=/jon/jopr-server-2.3.1/jbossas/server/default, name=snert JBossAS 4.2.3.GA default (snert:2099), parent=snert-embedded, version=4.2.3.GA]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10025, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10026, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Resource","false","false","","true","org.rhq.core.domain.alert.AlertDefinition[ id=10041, name=Group Alert, conditionExpression=ANY, priority=!! - Medium, ]","10043","Group Alert","false","null","0","!! - Medium","false","0","Resource[id=11034, type=JBossAS Server, key=/devel/jboss-4.0.5.GA/server/default, name=pickeldi JBossAS 4.0.5.GA default (1099), version=4.0.5.GA]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[SnmpNotification[id=10032, host=localhost, port=162, oid=1.2.3.4.5.6.7, ]]","ANY","Resource","false","false","","true","null","10051","snmp","false","null","0","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10041, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10042, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Type","false","false","","true","null","10061","test-template","false","null","0","!! - Medium","false","0","null","null","Mac OS X","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[RoleNotification[id=10043, role=org.rhq.core.domain.authz.Role[id=1, name=Super User Role], ], RoleNotification[id=10044, role=org.rhq.core.domain.authz.Role[id=2, name=All Resources Role], ]]","ANY","Resource","false","false","","true","null","10062","test-template","false","null","10061","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[]","ANY","Resource","false","false","no explicit notification","false","null","10021","Test3","false","null","0","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","true"
-"org.rhq.core.domain.alert.AlertDampening[ category=NONE[] ]","[]","ANY","Resource","false","false","","false","null","10031","OPs","false","OperationDefinition[id=10016, resourceType=ResourceType[id=10051, category=Platform, name=Mac OS X, plugin=Platforms], name=viewProcessList]","0","!! - Medium","false","0","Resource[id=10001, type=Mac OS X, key=snert-embedded, name=snert-embedded, parent=<null>, version=MacOSX 10.6.2]","null","null","true"
-10 rows
commit 6308d13ee4d776800175ba2d07d44bb8c00aba90
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 12:52:39 2010 -0400
remove OrderBy attribute, since alert notification order column was removed
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index f607af3..afa5671 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -352,7 +352,6 @@ public class AlertDefinition implements Serializable {
private Set<AlertCondition> conditions = new LinkedHashSet<AlertCondition>(1); // Most alerts will only have one condition.
@OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL)
- @OrderBy("order asc")
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private List<AlertNotification> alertNotifications = new ArrayList<AlertNotification>();
commit 24bb8b4dfe497ca6f8e0716e5933f8dbe55f3e8d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:16:47 2010 -0400
move the upgrade procedures for postgreaming blob streaming out into its own schemaSpec
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index af19962..8a89f96 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2665,6 +2665,27 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.81">
+ <!-- fix for postgres not properly streaming blobs to JDBC clients -->
+ <schema-directSQL targetDBVendor="postgresql">
+ <statement desc="Change bytea column to oid in postgres.">
+ ALTER TABLE RHQ_PACKAGE_BITS ADD COLUMN NEWOID OID
+ </statement>
+ <statement desc="Change bytea column to oid in postgres.">
+ UPDATE RHQ_PACKAGE_BITS t SET NEWOID = (
+ SELECT oid FROM (
+ SELECT oid, lowrite(lo_open(oid, 131072), t.bits)
+ FROM lo_create(0) o(oid)) x)
+ </statement>
+ <statement desc="Change bytea column to oid in postgres.">
+ ALTER TABLE RHQ_PACKAGE_BITS DROP COLUMN BITS
+ </statement>
+ <statement desc="Change bytea column to oid in postgres.">
+ ALTER TABLE RHQ_PACKAGE_BITS RENAME COLUMN NEWOID TO BITS
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
<schemaSpec version="2.82">
<schema-directSQL>
<statement desc="Creating table RHQ_SAVED_SEARCH">
@@ -2711,23 +2732,6 @@
VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, 1)
</statement>
</schema-directSQL>
- <schema-directSQL targetDBVendor="postgresql">
- <statement desc="Change bytea column to oid in postgres.">
- ALTER TABLE RHQ_PACKAGE_BITS ADD COLUMN NEWOID OID
- </statement>
- <statement desc="Change bytea column to oid in postgres.">
- UPDATE RHQ_PACKAGE_BITS t SET NEWOID = (
- SELECT oid FROM (
- SELECT oid, lowrite(lo_open(oid, 131072), t.bits)
- FROM lo_create(0) o(oid)) x)
- </statement>
- <statement desc="Change bytea column to oid in postgres.">
- ALTER TABLE RHQ_PACKAGE_BITS DROP COLUMN BITS
- </statement>
- <statement desc="Change bytea column to oid in postgres.">
- ALTER TABLE RHQ_PACKAGE_BITS RENAME COLUMN NEWOID TO BITS
- </statement>
- </schema-directSQL>
</schemaSpec>
<schemaSpec version="2.83">
commit 169dc47215afcf11a84e7d8161b2d9071d4fa4ac
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:11:34 2010 -0400
fix/simplified dbupgrade for RHQ_SAVED_SEARCH table
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index c3aeffe..af19962 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2668,14 +2668,11 @@
<schemaSpec version="2.82">
<schema-directSQL>
<statement desc="Creating table RHQ_SAVED_SEARCH">
- CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement desc="Creating primary key for RHQ_SAVED_SEARCH">
- ALTER TABLE RHQ_SAVED_SEARCH ADD PRIMARY KEY ( ID )
+ CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="ID" nullable="FALSE" />
+
<schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
commit fb8574a8eaa130bb1d2af1bb97cac5bf03d81d16
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:11:15 2010 -0400
change name of primary key constraint on RHQ_SUBJECT_ROLE_LDAP_MAP to be less than 30 chars, to match dbupgrade task 2.83
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
index 45cc880..8d9f738 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml
@@ -84,7 +84,7 @@
<table name="RHQ_SUBJECT_ROLE_LDAP_MAP">
<column name="SUBJECT_ID" required="true" type="INTEGER" references="RHQ_SUBJECT"/>
<column name="ROLE_ID" required="true" type="INTEGER" references="RHQ_ROLE"/>
- <constraint name="RHQ_SUBJECT_ROLE_LDAP_MAP_KEY">
+ <constraint name="RHQ_SUBJECT_ROLE_LDAP_MAP_PK">
<primaryKey>
<field ref="SUBJECT_ID" />
<field ref="ROLE_ID"/>
commit a58af3b6c8c4e5aaab67c1e706d249392dcbe79e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:08:22 2010 -0400
add necessary dbupgrade pieces for RHQ_SUBJECT_ROLE_LDAP_MAP table
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 047be90..c3aeffe 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2090,7 +2090,7 @@
</schemaSpec>
<schemaSpec version="2.70.2">
<!-- add structures for alert notification templates -->
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="TEMPLATE_ID" columnType="INTEGER" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
@@ -2734,18 +2734,30 @@
</schemaSpec>
<schemaSpec version="2.83">
- <!-- The following constraint change shortens the constraint name < 30 chars for Oracle. -->
- <schema-directSQL>
- <statement targetDBVendor="postgresql" desc="Dropping RHQ_SUBJECT_ROLE_LDAP_MAP constraint RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY.">
- ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP DROP CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY;
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_SUBJECT_ROLE_LDAP_MAP">
+ CREATE TABLE RHQ_SUBJECT_ROLE_LDAP_MAP ( SUBJECT_ID INTEGER, ROLE_ID INTEGER )
</statement>
- <!-- There is no PL/SQL update for ora dbs as the problematic statement could never be created on oracle, so nothing to fix. -->
- <statement targetDBVendor="postgresql" desc="Creating new RHQ_SUBJECT_ROLE_LDAP_MAP constraint RHQ_SUBJECT_ROLE_LDAP_MAP_KEY">
+ <statement desc="Creating composite PK for RHQ_SUBJECT_ROLE_LDAP_MAP">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
- ADD CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAP_KEY
+ ADD CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAP_PK
PRIMARY KEY ( SUBJECT_ID, ROLE_ID )
</statement>
+ <statement desc="Creating FK relation to RHQ_SUBJECT table for SUBJECT_ID column">
+ ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
+ ADD CONSTRAINT RHQ_SRLM_SUBJECT_ID_FK
+ FOREIGN KEY (SUBJECT_ID)
+ REFERENCES RHQ_SUBJECT (ID)
+ </statement>
+ <statement desc="Creating FK relation to RHQ_ROLE table for ROLE_ID column">
+ ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
+ ADD CONSTRAINT RHQ_SRLM_ROLE_ID_FK
+ FOREIGN KEY (ROLE_ID)
+ REFERENCES RHQ_ROLE (ID)
+ </statement>
</schema-directSQL>
+ <schema-alterColumn table="RHQ_SUBJECT_ROLE_LDAP_MAP" column="SUBJECT_ID" nullable="FALSE" />
+ <schema-alterColumn table="RHQ_SUBJECT_ROLE_LDAP_MAP" column="ROLE_ID" nullable="FALSE" />
</schemaSpec>
</dbupgrade>
commit 1a06c55942f3b03f78b061ec3aee6e36a8820173
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 23 11:03:28 2010 -0400
fix dbupgrade logic for subject/role/email notifications
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
index a94f095..0fa4ee8 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
@@ -147,7 +147,7 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration("operation-definition-id", operationDefinitionId, "selection-mode",
"SELF");
- persistNotification(alertDefinitionId, configId, "Resource Operations", "Operational ");
+ persistNotification(alertDefinitionId, configId, "Resource Operations", "Operation Invocation");
}
}
@@ -165,13 +165,18 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
persistNotification(definitionId, configId, sender, name);
}
buffer = new StringBuilder(); // reset for the next definitionId
- } else {
- if (buffer.length() != 0) {
- // elements are already in the list
- buffer.append(',');
- }
- buffer.append(nextData);
}
+
+ if (buffer.length() != 0) {
+ // elements are already in the list
+ buffer.append(',');
+ }
+ buffer.append(nextData);
+ }
+
+ if (buffer.length() != 0) {
+ int configId = persistConfiguration(propertyName, buffer.toString());
+ persistNotification(definitionId, configId, sender, name);
}
}
commit e8b7b579f801fc1c50afc7f8631dd5471d01beb1
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Apr 22 14:34:17 2010 -0400
add database upgrade support for customer alert senders
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
index b083510..707694f 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
@@ -74,9 +74,6 @@ public class SST_JavaTask extends SchemaSpecTask {
validateAttributes();
try {
- DatabaseType db_type = getDatabaseType();
- Connection conn = getConnection();
-
if (className.indexOf(".") == -1) {
className = "org.rhq.core.db.upgrade." + className;
}
@@ -85,7 +82,11 @@ public class SST_JavaTask extends SchemaSpecTask {
Class<?> javaTaskClass = Class.forName(className);
DatabaseUpgradeTask javaTask = (DatabaseUpgradeTask) javaTaskClass.newInstance();
- javaTask.execute(conn, db_type);
+
+ DatabaseType db_type = getDatabaseType();
+ Connection conn = getConnection();
+
+ javaTask.execute(db_type, conn);
} catch (Exception e) {
throw new BuildException(MSG.getMsg(DbAntI18NResourceKeys.JAVA_TASK_ERROR, e), e);
}
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
new file mode 100644
index 0000000..a94f095
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
@@ -0,0 +1,217 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.core.db.upgrade;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+
+import org.rhq.core.db.DatabaseType;
+
+/**
+ * The introduction of custom alert senders brought with it the denormalization of the AlertNotification schema.
+ * Instead of the AlertNotification entity storing the notification-related data itself (through referential integrity)
+ * it has been subsumed inside of configuration objects, which are then associated back to the entity.
+ *
+ * Each custom alert sender has full control over the structure within that configuration object. This task represents
+ * the work necessary to translate the first-class notification data (previously stored in the rhq_alert_notification
+ * table itself) into appropriate configuration objects to be used by the custom senders that will be shipped with the
+ * product by default.
+ *
+ * In particular, this task handles the upgrade tasks for alert notifications setup against the following types of data:
+ *
+ * <ul>
+ * <li>RHQ Subjects</li>
+ * <li>RHQ Roles</li>
+ * <li>Direct Email Addresses</li>
+ * <li>SNMP Trap Receivers</li>
+ * <li>Resource Operations</li>
+ * </ul>
+ *
+ * @author Joseph Marques
+ */
+public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
+
+ private DatabaseType databaseType;
+ private Connection connection;
+
+ private final long NOW = System.currentTimeMillis();
+
+ @Override
+ public void execute(DatabaseType databaseType, Connection connection) throws SQLException {
+ this.databaseType = databaseType;
+ this.connection = connection;
+
+ upgradeSubjectNotifications();
+ upgradeRoleNotifications();
+ upgradeEmailNotifications();
+ upgradeSNMPNotifications();
+ upgradeOperationNotifications();
+ }
+
+ private void upgradeSubjectNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT notif.alert_definition_id, notif.subject_id "//
+ + " FROM rhq_alert_notification notif "//
+ + " WHERE notif.notification_type = 'SUBJECT' "//
+ + "ORDER BY notif.alert_definition_id";
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ String propertyName = "subjectId";
+ String senderName = "System Users";
+ String name = "User Notifications";
+
+ persist(data, propertyName, senderName, name);
+ }
+
+ private void upgradeRoleNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT notif.alert_definition_id, notif.role_id "//
+ + " FROM rhq_alert_notification notif "//
+ + " WHERE notif.notification_type = 'ROLE' "//
+ + "ORDER BY notif.alert_definition_id";
+
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ String propertyName = "roleId";
+ String senderName = "System Roles";
+ String name = "Role Notifications";
+
+ persist(data, propertyName, senderName, name);
+ }
+
+ private void upgradeEmailNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT notif.alert_definition_id, notif.email_address "//
+ + " FROM rhq_alert_notification notif "//
+ + " WHERE notif.notification_type = 'EMAIL' "//
+ + "ORDER BY notif.alert_definition_id";
+
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ String propertyName = "emailAddress";
+ String senderName = "Direct Emails";
+ String name = "Email Notifications";
+
+ persist(data, propertyName, senderName, name);
+ }
+
+ private void upgradeSNMPNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT notif.alert_definition_id, notif.snmp_host, notif.snmp_port, notif.snmp_oid "//
+ + " FROM rhq_alert_notification notif "//
+ + " WHERE notif.notification_type = 'SNMP' "//
+ + "ORDER BY notif.alert_definition_id";
+
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ for (Object[] next : data) {
+ int alertDefinitionId = ((Number) next[0]).intValue();
+ String host = (String) next[1];
+ String port = ((Number) next[2]).toString();
+ String oid = (String) next[3];
+
+ // buffer will be 0 the very first time, since definitionId is initially -1
+ int configId = persistConfiguration("host", host, "port", port, "oid", oid);
+ persistNotification(alertDefinitionId, configId, "SNMP Traps", "SNMP Notifications");
+ }
+ }
+
+ private void upgradeOperationNotifications() throws SQLException {
+ String dataMapSQL = "" //
+ + " SELECT def.id, def.operation_def_id" //
+ + " FROM rhq_alert_definition def";
+
+ List<Object[]> data = databaseType.executeSelectSql(connection, dataMapSQL);
+
+ for (Object[] next : data) {
+ int alertDefinitionId = ((Number) next[0]).intValue();
+ String operationDefinitionId = ((Number) next[1]).toString();
+
+ // buffer will be 0 the very first time, since definitionId is initially -1
+ int configId = persistConfiguration("operation-definition-id", operationDefinitionId, "selection-mode",
+ "SELF");
+ persistNotification(alertDefinitionId, configId, "Resource Operations", "Operational ");
+ }
+ }
+
+ private void persist(List<Object[]> data, String propertyName, String sender, String name) throws SQLException {
+ int definitionId = -1;
+ StringBuilder buffer = new StringBuilder();
+ for (Object[] next : data) {
+ int nextDefinitionId = ((Number) next[0]).intValue();
+ String nextData = String.valueOf(next[1]);
+ if (nextDefinitionId != definitionId) {
+ definitionId = nextDefinitionId;
+ if (buffer.length() != 0) {
+ // buffer will be 0 the very first time, since definitionId is initially -1
+ int configId = persistConfiguration(propertyName, buffer.toString());
+ persistNotification(definitionId, configId, sender, name);
+ }
+ buffer = new StringBuilder(); // reset for the next definitionId
+ } else {
+ if (buffer.length() != 0) {
+ // elements are already in the list
+ buffer.append(',');
+ }
+ buffer.append(nextData);
+ }
+ }
+ }
+
+ private int persistConfiguration(String... propertyNameValues) throws SQLException {
+ int configId = databaseType.getNextSequenceValue(connection, "rhq_config", "id");
+ String insertConfigSQL = getInsertConfigSQL(configId);
+ databaseType.executeSql(connection, insertConfigSQL);
+
+ for (int i = 0; i < propertyNameValues.length; i += 2) {
+ String propertyName = propertyNameValues[i];
+ String propertyValue = propertyNameValues[i + 1];
+
+ int propertyId = databaseType.getNextSequenceValue(connection, "rhq_config_property", "id");
+ String insertPropertySQL = getInsertPropertySQL(propertyId, configId, propertyName, propertyValue);
+ databaseType.executeSql(connection, insertPropertySQL);
+ }
+
+ return configId;
+ }
+
+ private void persistNotification(int definitionId, int configId, String sender, String name) throws SQLException {
+ int notificationId = databaseType.getNextSequenceValue(connection, "rhq_alert_notification", "id");
+ String insertNotificationSQL = getInsertNotificationSQL(notificationId, definitionId, configId, sender, name);
+
+ databaseType.executeSql(connection, insertNotificationSQL);
+ }
+
+ private String getInsertConfigSQL(int id) {
+ return "INSERT INTO rhq_config ( id, ctime, mtime )" //
+ + " VALUES ( " + id + ", " + NOW + ", " + NOW + " ) ";
+ }
+
+ private String getInsertPropertySQL(int id, int configId, String name, String value) {
+ return "INSERT INTO rhq_config_property ( id, configuration_id, name, string_value, dtype )" //
+ + " VALUES ( " + id + ", " + configId + ", '" + name + "', '" + value + "', 'property' ) ";
+ }
+
+ private String getInsertNotificationSQL(int id, int definitionId, int configId, String sender, String name) {
+ return "INSERT INTO rhq_alert_notification ( id, alert_definition_id, sender_config_id, sender_name, display_name )" //
+ + " VALUES ( " + id + ", " + definitionId + ", " + configId + ", '" + sender + "', '" + name + "' ) ";
+ }
+
+}
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
index fd438c0..4811b7d 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
@@ -30,5 +30,5 @@ import org.rhq.core.db.ant.dbupgrade.SST_JavaTask;
* @author Joseph Marques
*/
public interface DatabaseUpgradeTask {
- public void execute(Connection connection, DatabaseType type) throws SQLException;
+ public void execute(DatabaseType type, Connection connection) throws SQLException;
}
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
index 3098d97..9617057 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -79,7 +79,7 @@
<!-- required, but 0 effectively means null -->
<column name="WILL_RECOVER" required="true" default="false" type="BOOLEAN"/>
<column name="ACK_TIME" required="false" type="LONG"/>
- <column name="ACK_BY_ID" required="false" type="INTEGER" references="RHQ_SUBJECT(ID)"/>
+ <column name="ACK_SUBJECT" required="false" size="100" type="VARCHAR2"/>
<index name="RHQ_ALERT_IDX_TIME" unique="false">
<field ref="CTIME"/>
</index>
@@ -127,21 +127,17 @@
<column name="MTIME" required="true" type="LONG"/>
<column name="NAME" required="true" size="100" type="VARCHAR2"/>
<column name="DESCRIPTION" required="false" size="250" type="VARCHAR2"/>
-
</table>
<table name="RHQ_ALERT_NOTIFICATION" tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
storage-options="freelists 5" cache="true" logging="false">
<column name="ID" default="sequence-only" initial="10001"
primarykey="true" required="true" type="INTEGER"/>
- <column name="NOTIFICATION_TYPE" required="true" size="20" type="VARCHAR2"/>
<column name="ALERT_DEFINITION_ID" required="false" type="INTEGER" references="RHQ_ALERT_DEFINITION(ID)"/>
- <column name="NOTIF_TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
- <column name="ALERT_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
- <column name="ALERT_SENDER_NAME" required="false" size="100" type="VARCHAR2" /> <!-- TODO make required = true -->
- <column name="NAME" type="VARCHAR2" size="100" />
+ <column name="TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
+ <column name="SENDER_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
+ <column name="SENDER_NAME" required="true" size="100" type="VARCHAR2" />
+ <column name="DISPLAY_NAME" type="VARCHAR2" size="100" />
</table>
-
-
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index bf9b21f..047be90 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2059,28 +2059,27 @@
<schemaSpec version="2.70">
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
<!-- TODO: this needs to change to ack_subject_name -->
- <schema-addColumn table="RHQ_ALERT" column="ACK_BY_ID" columnType="INTEGER" />
-
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_SENDER_NAME" columnType="VARCHAR2" precision="100"/>
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_CONFIG_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ALERT" column="ACK_SUBJECT" precision="100" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="DISPLAY_NAME" precision="100" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" precision="100" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_AN_ALERT_CONFIG_ID_FK
- FOREIGN KEY (ALERT_CONFIG_ID)
+ ADD CONSTRAINT RHQ_ALERT_NOTIFICATION_SENDER_CONFIG_ID_FK
+ FOREIGN KEY (SENDER_CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
</schema-directSQL>
</schemaSpec>
-
<schemaSpec version="2.70.1">
<schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
<schema-directSQL>
- <statement>
+ <statement desc="Creating table RHQ_ALERT_NOTIF_TEMPL">
CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="ID" nullable="false" />
+ <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="ID" nullable="false" />
<schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" nullable="false" />
<schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" columnType="LONG" />
@@ -2089,6 +2088,61 @@
<schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" nullable="false" />
<schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" precision="250" columnType="VARCHAR2" />
</schemaSpec>
+ <schemaSpec version="2.70.2">
+ <!-- add structures for alert notification templates -->
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_ALERT_NOTIFICATION
+ ADD CONSTRAINT RHQ_ALERT_NOTIFICATION_TEMPLATE_ID_FK
+ FOREIGN KEY (TEMPLATE_ID)
+ REFERENCES RHQ_ALERT_NOTIF_TEMPL (ID)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+ <schemaSpec version="2.70.3">
+ <!-- turn first-class notification data into configuration objects for custom alert senders -->
+ <schema-alterColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" nullable="TRUE" />
+ <schema-javaTask className="CustomAlertSenderUpgradeTask" />
+ <schema-directSQL>
+ <statement desc="Removing obsolete alert notifications">
+ DELETE FROM RHQ_ALERT_NOTIFICATION WHERE NOTIFICATION_TYPE IS NOT NULL
+ </statement>
+ </schema-directSQL>
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" />
+ </schemaSpec>
+ <schemaSpec version="2.70.4">
+ <!-- remove first-class alert notification structures from definition side of the model-->
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="role_id" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
+ <schema-deleteColumn table="RHQ_ALERT_DEFINITION" column="operation_def_id" />
+ </schemaSpec>
+ <schemaSpec version="2.70.5">
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
+ </schemaSpec>
+ <schemaSpec version="2.70.6">
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
+ </schemaSpec>
+ <schemaSpec version="2.70.7">
+ <schema-directSQL>
+ <statement>
+ DROP INDEX RHQ_ALERT_IDX_ALERT
+ </statement>
+ <statement>
+ CREATE INDEX RHQ_ALERT_IDX_ALERT ON RHQ_ALERT_NOTIF_LOG (alert_id)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
<!-- RHQ Advisory Representation -->
<schemaSpec version="2.71">
@@ -2296,47 +2350,6 @@
<schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
</schemaSpec>
- <schemaSpec version="2.77">
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_CPD_NOTIF_TEMPLATE_ID_FK
- FOREIGN KEY (NOTIF_TEMPLATE_ID)
- REFERENCES RHQ_ALERT_NOTIF_TEMPL(ID)
- </statement>
- </schema-directSQL>
- </schemaSpec>
- <schemaSpec version="2.77.1">
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="role_id" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
- </schemaSpec>
- <schemaSpec version="2.77.2">
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
-
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
- </schemaSpec>
- <schemaSpec version="2.77.3">
- <schema-directSQL>
- <statement>
- DROP INDEX RHQ_ALERT_IDX_ALERT
- </statement>
- <statement>
- CREATE INDEX RHQ_ALERT_IDX_ALERT ON RHQ_ALERT_NOTIF_LOG (alert_id)
- </statement>
- </schema-directSQL>
- </schemaSpec>
-
<schemaSpec version="2.78">
<!-- RHQ_BUNDLE_TYPE -->
<schema-createSequence name="RHQ_BUNDLE_TYPE_ID_SEQ" initial="10001" />
@@ -2734,7 +2747,7 @@
</statement>
</schema-directSQL>
</schemaSpec>
-
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
index 904acce..b676c05 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
@@ -45,7 +45,6 @@ import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.rhq.core.domain.alert.notification.AlertNotificationLog;
-import org.rhq.core.domain.auth.Subject;
/**
* @author Joseph Marques
@@ -113,10 +112,10 @@ import org.rhq.core.domain.auth.Subject;
+ " WHERE condition.measurementDefinition.id = :measurementDefinitionId " //
+ " AND definition.resource.id = ( :resourceId ) " //
+ " AND ( a.ctime BETWEEN :startDate AND :endDate )"),
- @NamedQuery(name = Alert.QUERY_GET_ALERT_COUNT_FOR_SCHEDULES, query = "SELECT sched.id, count(*) " +
- " FROM Alert AS a JOIN a.alertDefinition aDef JOIN aDef.conditions condition " +
- " JOIN aDef.resource res JOIN condition.measurementDefinition mDef JOIN mDef.schedules sched" +
- " WHERE sched.definition = mDef.id AND sched.resource = res AND sched.id IN (:schedIds) "
+ @NamedQuery(name = Alert.QUERY_GET_ALERT_COUNT_FOR_SCHEDULES, query = "SELECT sched.id, count(*) "
+ + " FROM Alert AS a JOIN a.alertDefinition aDef JOIN aDef.conditions condition "
+ + " JOIN aDef.resource res JOIN condition.measurementDefinition mDef JOIN mDef.schedules sched"
+ + " WHERE sched.definition = mDef.id AND sched.resource = res AND sched.id IN (:schedIds) "
+ " AND (a.ctime BETWEEN :startDate AND :endDate)" + "GROUP BY sched.id"),
@NamedQuery(name = Alert.QUERY_FIND_BY_RESOURCE_DATED, //
query = "SELECT a " //
@@ -258,12 +257,11 @@ public class Alert implements Serializable {
@Column(name = "WILL_RECOVER", nullable = false)
private boolean willRecover;
- @Column(name ="ACK_TIME")
- private long ackTime = -1;
+ @Column(name = "ACK_TIME")
+ private long acknowledgeTime = -1;
- @JoinColumn(name = "ACK_BY_ID", referencedColumnName = "ID")
- @ManyToOne
- private Subject ackBy;
+ @Column(name = "ACK_SUBJECT")
+ private String acknowledgingSubject;
/**
* Creates a new alert. (required by EJB3 spec, but not used)
@@ -335,20 +333,20 @@ public class Alert implements Serializable {
this.triggeredOperation = triggeredOperation;
}
- public long getAckTime() {
- return ackTime;
+ public long getAcknowledgeTime() {
+ return acknowledgeTime;
}
- public void setAckTime(long ackTime) {
- this.ackTime = ackTime;
+ public void setAcknowledgeTime(long acknowledgeTime) {
+ this.acknowledgeTime = acknowledgeTime;
}
- public Subject getAckBy() {
- return ackBy;
+ public String getAcknowledgingSubject() {
+ return acknowledgingSubject;
}
- public void setAckBy(Subject ackBy) {
- this.ackBy = ackBy;
+ public void setAcknowledgingSubject(String acknowledgingSubject) {
+ this.acknowledgingSubject = acknowledgingSubject;
}
public boolean getWillRecover() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index ef7b3e9..1f14aad 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -26,15 +26,11 @@ import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
-import javax.persistence.DiscriminatorColumn;
-import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
@@ -49,9 +45,7 @@ import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.configuration.Configuration;
-@DiscriminatorColumn(name = "NOTIFICATION_TYPE", discriminatorType = DiscriminatorType.STRING)
@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQueries( {
@NamedQuery(name = AlertNotification.DELETE_BY_ID, query = "DELETE FROM AlertNotification an WHERE an.id IN ( :ids )"),
@NamedQuery(name = AlertNotification.QUERY_DELETE_BY_RESOURCES, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IN ( SELECT ad FROM AlertDefinition ad WHERE ad.resource.id IN ( :resourceIds ) )"),
@@ -80,22 +74,19 @@ public class AlertNotification implements Serializable {
@ManyToOne
private AlertDefinition alertDefinition;
- @JoinColumn(name = "NOTIF_TEMPLATE_ID")
+ @JoinColumn(name = "TEMPLATE_ID")
@ManyToOne
private AlertNotificationTemplate alertNotificationTemplate;
- @JoinColumn(name = "ALERT_CONFIG_ID", referencedColumnName = "ID")
+ @JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName = "ID")
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
private Configuration configuration;
- @Column(name = "ALERT_SENDER_NAME")
+ @Column(name = "SENDER_NAME")
private String senderName;
- @Column(name = "ALERT_ORDER")
- private int order;
-
- @Column(name = "NAME")
- private String name;
+ @Column(name = "DISPLAY_NAME")
+ private String displayName;
protected AlertNotification() {
} // JPA spec
@@ -127,8 +118,8 @@ public class AlertNotification implements Serializable {
this.alertNotificationId = alertNotificationId;
}
- public AlertNotification(String name, String sender) {
- this.name = name;
+ public AlertNotification(String displayName, String sender) {
+ this.displayName = displayName;
this.senderName = sender;
}
@@ -155,14 +146,14 @@ public class AlertNotification implements Serializable {
public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean cloneConfiguration) {
Configuration config;
- if (cloneConfiguration)
+ if (cloneConfiguration) {
config = this.configuration.deepCopy(false);
- else
+ } else {
config = this.configuration;
+ }
AlertNotification notification = new AlertNotification(alertDefinition, config);
- notification.setName(this.name);
+ notification.setDisplayName(this.displayName);
notification.setSenderName(this.senderName);
- notification.setOrder(this.order);
return notification;
}
@@ -190,20 +181,12 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public int getOrder() {
- return order;
- }
-
- public void setOrder(int order) {
- this.order = order;
- }
-
- public String getName() {
- return name;
+ public String getDisplayName() {
+ return displayName;
}
- public void setName(String name) {
- this.name = name;
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
}
public AlertNotificationTemplate getAlertNotificationTemplate() {
@@ -231,8 +214,7 @@ public class AlertNotification implements Serializable {
sb.append(", id=").append(id);
sb.append(", notificationTemplate=").append(alertNotificationTemplate);
sb.append(", senderName='").append(senderName).append('\'');
- sb.append(", order=").append(order);
- sb.append(", name='").append(name).append('\'');
+ sb.append(", displayName='").append(displayName).append('\'');
sb.append('}');
return sb.toString();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index a97374f..c02de80 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -18,6 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Window;
@@ -33,6 +40,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionLog;
@@ -46,13 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
/**
* A server-side SmartGWT DataSource for CRUD of {@link Alert}s.
*
@@ -107,7 +108,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
DataSourceTextField ctimeField = new DataSourceTextField(AlertCriteria.SORT_FIELD_CTIME, "Creation Time");
fields.add(ctimeField);
- DataSourceBooleanField boolField = new DataSourceBooleanField("ack","Ack'd");
+ DataSourceBooleanField boolField = new DataSourceBooleanField("ack", "Ack'd");
boolField.setCanSortClientOnly(true);
fields.add(boolField);
@@ -127,14 +128,17 @@ public class AlertDataSource extends RPCDataSource<Alert> {
this.alertService.deleteResourceAlerts(alertIds, new AsyncCallback<Void>() {
public void onSuccess(Void blah) {
- CoreGUI.getMessageCenter().notify(new Message("Deleted ["+ alertIds.length + "] alerts", Message.Severity.Info));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Deleted [" + alertIds.length + "] alerts", Message.Severity.Info));
System.out.println("Deleted Alerts with id's: " + Arrays.toString(alertIds) + ".");
alertsView.refresh();
}
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to delete Alerts with id's: " + Arrays.toString(alertIds), caught);
- System.err.println("Failed to delete Alerts with id's " + Arrays.toString(alertIds) + " - cause: " + caught);
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to delete Alerts with id's: " + Arrays.toString(alertIds), caught);
+ System.err.println("Failed to delete Alerts with id's " + Arrays.toString(alertIds) + " - cause: "
+ + caught);
}
});
}
@@ -189,7 +193,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
@Override
public Alert copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
@@ -200,8 +204,9 @@ public class AlertDataSource extends RPCDataSource<Alert> {
record.setAttribute("name", from.getAlertDefinition().getName());
record.setAttribute("priority", from.getAlertDefinition().getPriority().name());
record.setAttribute("ctime", DATE_TIME_FORMAT.format(new Date(from.getCtime())));
- if (from.getAckTime() >0)
- record.setAttribute("ack","true");
+ if (from.getAcknowledgeTime() > 0) {
+ record.setAttribute("ack", "true");
+ }
Set<AlertConditionLog> conditionLogs = from.getConditionLogs();
String conditionText;
@@ -231,17 +236,17 @@ public class AlertDataSource extends RPCDataSource<Alert> {
for (AlertConditionLog log : from.getConditionLogs()) {
AlertCondition condition = log.getCondition();
DataClass dc = new DataClass();
- dc.setAttribute("text",AlertFormatUtility.formatAlertConditionForDisplay(condition));
+ dc.setAttribute("text", AlertFormatUtility.formatAlertConditionForDisplay(condition));
String value = log.getValue();
if (condition.getMeasurementDefinition() != null) {
value = MeasurementConverterClient.format(Double.valueOf(log.getValue()), condition
.getMeasurementDefinition().getUnits(), true);
}
- dc.setAttribute("value",value);
+ dc.setAttribute("value", value);
conditions[i++] = dc;
}
- record.setAttribute("conditionLogs",conditions);
- record.setAttribute("conditionExpression",from.getAlertDefinition().getConditionExpression());
+ record.setAttribute("conditionLogs", conditions);
+ record.setAttribute("conditionExpression", from.getAlertDefinition().getConditionExpression());
String recoveryInfo = AlertFormatUtility.getAlertRecoveryInfo(from);
record.setAttribute("recoveryInfo", recoveryInfo);
@@ -249,23 +254,23 @@ public class AlertDataSource extends RPCDataSource<Alert> {
// Alert notification logs
DataClass[] notifications = new DataClass[from.getAlertNotificationLogs().size()];
i = 0;
- for(AlertNotificationLog log : from.getAlertNotificationLogs()) {
+ for (AlertNotificationLog log : from.getAlertNotificationLogs()) {
DataClass dc = new DataClass();
- dc.setAttribute("sender",log.getSender());
- dc.setAttribute("status",log.getResultState());
- dc.setAttribute("message",log.getMessage());
- dc.setAttribute("allEmails",log.getAllEmails());
- dc.setAttribute("badEmails",log.getBadEmails());
+ dc.setAttribute("sender", log.getSender());
+ dc.setAttribute("status", log.getResultState());
+ dc.setAttribute("message", log.getMessage());
+ dc.setAttribute("allEmails", log.getAllEmails());
+ dc.setAttribute("badEmails", log.getBadEmails());
notifications[i++] = dc;
}
- record.setAttribute("notificationLogs",notifications);
+ record.setAttribute("notificationLogs", notifications);
return record;
}
protected void executeRemove(final DSRequest request, final DSResponse response) {
- JavaScriptObject data = request.getData ();
+ JavaScriptObject data = request.getData();
ListGridRecord record = new ListGridRecord(data);
Window.alert(String.valueOf(record.getAttributeAsInt("id")));
}
@@ -283,15 +288,18 @@ public class AlertDataSource extends RPCDataSource<Alert> {
this.alertService.acknowledgeResourceAlerts(alertIds, new AsyncCallback<Void>() {
public void onSuccess(Void blah) {
- CoreGUI.getMessageCenter().notify(new Message("Acknowledged ["+ alertIds.length + "] alerts", Message.Severity.Info));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Acknowledged [" + alertIds.length + "] alerts", Message.Severity.Info));
System.out.println("Acknowledged Alerts with id's: " + Arrays.toString(alertIds) + ".");
alertsView.refresh();
}
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to acknowledge Alerts with id's: " + Arrays.toString(alertIds), caught);
- System.err.println("Failed to acknowledge Alerts with id's " + Arrays.toString(alertIds) + " - cause: " + caught);
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to acknowledge Alerts with id's: " + Arrays.toString(alertIds), caught);
+ System.err.println("Failed to acknowledge Alerts with id's " + Arrays.toString(alertIds) + " - cause: "
+ + caught);
}
});
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java
index 6043d19..a202c5b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/AckAlertAction.java
@@ -29,10 +29,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.tiles.ComponentContext;
-import org.apache.struts.tiles.actions.TilesAction;
-import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.gui.legacy.action.BaseAction;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
@@ -49,7 +46,7 @@ public class AckAlertAction extends BaseAction {
Log log = LogFactory.getLog(AckAlertAction.class);
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
+ HttpServletResponse response) throws Exception {
Subject subject = RequestUtils.getSubject(request);
AlertManagerLocal alertManager = LookupUtil.getAlertManager();
@@ -58,21 +55,21 @@ public class AckAlertAction extends BaseAction {
// pass-through the alertId and resource id
Integer alertId = new Integer(request.getParameter("a"));
request.setAttribute("a", alertId);
- params.put("a",alertId);
+ params.put("a", alertId);
Integer resourceId = new Integer(request.getParameter("id"));
- request.setAttribute("id",resourceId);
- params.put("id",resourceId);
+ request.setAttribute("id", resourceId);
+ params.put("id", resourceId);
String mode = request.getParameter("mode");
- request.setAttribute("mode",mode);
- params.put("mode",mode);
+ request.setAttribute("mode", mode);
+ params.put("mode", mode);
- alertManager.acknowledgeAlert(alertId,subject);
+ alertManager.acknowledgeAlerts(subject, new Integer[] { alertId });
log.debug("Acknowledged Alert with id " + alertId + " and user " + subject.getName());
- return returnSuccess(request,mapping,params);
+ return returnSuccess(request, mapping, params);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
index db62a94..2a9f4b3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
@@ -57,6 +57,7 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.alert.notification.AlertNotificationLog;
+import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.core.domain.alert.notification.SenderResult;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
@@ -68,9 +69,9 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.core.domain.util.StringUtils;
import org.rhq.core.server.MeasurementConverter;
import org.rhq.core.server.PersistenceUtility;
-import org.rhq.core.domain.util.StringUtils;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
@@ -87,14 +88,12 @@ import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
import org.rhq.enterprise.server.plugin.pc.alert.AlertServerPluginContainer;
-import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
import org.rhq.enterprise.server.util.LookupUtil;
-
/**
* @author Joseph Marques
* @author Ian Springer
@@ -130,7 +129,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
@javax.annotation.Resource(name = "RHQ_DS")
private DataSource rhqDs;
-
/**
* Persist a detached alert.
*
@@ -148,27 +146,31 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
/**
* Remove the alerts with the specified id's.
* @param user caller
- * @param ids primary keys of the alerts to delete
+ * @param alertIds primary keys of the alerts to delete
* @return number of alerts deleted
*/
- public int deleteAlerts(Subject user, Integer[] ids) {
- if (!authorizationManager.hasGlobalPermission(user,Permission.MANAGE_ALERTS))
- throw new PermissionException("User [" + user.getName() + "] does not have permissions to delete alerts ");
-
- int i = 0;
- for (Integer id : ids) {
- Alert alert = entityManager.find(Alert.class, id);
+ public int deleteAlerts(Subject user, Integer[] alertIds) {
+ int count = 0;
+ for (Integer nextAlertId : alertIds) {
+ Alert alert = entityManager.find(Alert.class, nextAlertId);
if (alert != null) {
-// AlertNotificationLog anl = alert.getAlertNotificationLog(); TODO is that all?
-// entityManager.remove(anl);
+ // AlertNotificationLog anl = alert.getAlertNotificationLog(); TODO is that all?
+ // entityManager.remove(anl);
+ Resource resource = alert.getAlertDefinition().getResource();
+ if (!authorizationManager.hasResourcePermission(user, Permission.MANAGE_ALERTS, resource.getId())) {
+ throw new PermissionException("User [" + user.getName()
+ + "] does not have permissions to delete alerts: " + Arrays.asList(alertIds));
+ }
+
entityManager.remove(alert); // condition logs will be removed with entity cascading
}
- i++;
+ count++;
}
- return i;
+ return count;
}
- public void deleteResourceAlerts(Subject user, Integer[] alertIds) {
+ @SuppressWarnings("unchecked")
+ private void checkAlertsPermission(Subject user, Integer[] alertIds) {
Query q = entityManager.createNamedQuery(Alert.QUERY_FIND_RESOURCES);
q.setParameter("alertIds", Arrays.asList(alertIds));
List<Resource> resources = q.getResultList();
@@ -180,9 +182,13 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
}
if (!forbiddenResources.isEmpty()) {
- throw new PermissionException("User [" + user.getName() + "] does not have permissions to delete alerts "
- + "for the following Resource(s): " + forbiddenResources);
+ throw new PermissionException("User [" + user.getName() + "] does not have permissions to manage alerts "
+ + "for the following Resource(s): " + forbiddenResources);
}
+ }
+
+ public void deleteResourceAlerts(Subject user, Integer[] alertIds) {
+ checkAlertsPermission(user, alertIds);
deleteAlerts(user, alertIds);
}
@@ -568,48 +574,33 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
/**
- * Mark the matching alert as acknowledged by the user
- * @param alertId Id of the alert to acknowledge
- * @param user user who acknowledged the alert
- */
- public void acknowledgeAlert(int alertId, Subject user) {
- Alert alert = entityManager.find(Alert.class,alertId);
- if (alert==null) {
- log.warn("Alert [ " + alertId + " ] to acknowledge was not found ");
- return;
- }
- alert.setAckBy(user);
- alert.setAckTime(System.currentTimeMillis());
- }
-
- /**
- * Acknowledge the alerts (that got fired) so that admins know who is working
- * on fixing the situation.
+ * Acknowledge the alerts (that got fired) so that admins know who is working on fixing the situation.
+ *
* @param user calling user
- * @param alertIds PKs of the alerts to ack
+ * @param alertIds PKs of the alerts to acknowledge
* @return number of alerts acknowledged
*/
public int acknowledgeAlerts(Subject user, Integer[] alertIds) {
- if (!authorizationManager.hasGlobalPermission(user, Permission.MANAGE_ALERTS)) {
- throw new PermissionException("User [" + user.getName() + "] does not have permissions to acknowledge alerts ");
- }
-
- int i=0;
- if (alertIds==null || alertIds.length==0) {
+ if (alertIds == null || alertIds.length == 0) {
log.debug("acknowledgeAlerts: no alertIds passed");
- return -1;
+ return 0;
}
- for (int id : alertIds) {
- acknowledgeAlert(id,user);
- i++;
- if (i % 50 == 0) {
- entityManager.flush();
- entityManager.clear();
- }
+ checkAlertsPermission(user, alertIds);
+ int count = 0;
+ final long NOW = System.currentTimeMillis();
+ for (int nextAlertId : alertIds) {
+ Alert alert = entityManager.find(Alert.class, nextAlertId);
+ if (alert == null) {
+ continue;
+ } else {
+ count++;
+ }
+ alert.setAcknowledgingSubject(user.getName());
+ alert.setAcknowledgeTime(NOW);
}
- return i;
+ return count;
}
public void fireAlert(int alertDefinitionId) {
@@ -634,8 +625,8 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
this.createAlert(newAlert);
log.debug("New alert identifier=" + newAlert.getId());
-// AlertNotificationLog alertNotifLog = new AlertNotificationLog(newAlert); TODO - is that all?
-// entityManager.persist(alertNotifLog);
+ // AlertNotificationLog alertNotifLog = new AlertNotificationLog(newAlert); TODO - is that all?
+ // entityManager.persist(alertNotifLog);
List<AlertConditionLog> unmatchedConditionLogs = alertConditionLogManager
.getUnmatchedLogsByAlertDefinitionId(alertDefinitionId);
@@ -694,7 +685,7 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
// Send over the new AlertSender plugins
String senderName = alertNotification.getSenderName();
- if (senderName ==null) {
+ if (senderName == null) {
log.error("Alert notification " + alertNotification + " has no sender name defined");
continue;
}
@@ -707,9 +698,9 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
SenderResult result = sender.send(alert);
if (result == null) {
- log.warn("- !! -- sender [" + senderName +
- "] did not return a SenderResult. Please fix this -- !! - ");
- alNoLo = new AlertNotificationLog(alert,senderName);
+ log.warn("- !! -- sender [" + senderName
+ + "] did not return a SenderResult. Please fix this -- !! - ");
+ alNoLo = new AlertNotificationLog(alert, senderName);
alNoLo.setMessage("Sender did not return a SenderResult, assuming failure");
} else if (result.getState() == ResultState.DEFERRED_EMAIL) {
@@ -722,20 +713,16 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
alNoLo = new AlertNotificationLog(alert, senderName, result);
}
log.info(result);
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
log.error("Sender failed: " + t.getMessage());
if (log.isDebugEnabled())
log.debug("Sender " + sender.toString() + "failed: \n", t);
- alNoLo = new AlertNotificationLog(alert, senderName,
- ResultState.FAILURE,
- "Failed with exception: " + t.getMessage());
+ alNoLo = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
+ "Failed with exception: " + t.getMessage());
}
- }
- else {
- alNoLo = new AlertNotificationLog(alert, senderName,
- ResultState.FAILURE,
- "Failed to obtain a sender with given name");
+ } else {
+ alNoLo = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
+ "Failed to obtain a sender with given name");
}
entityManager.persist(alNoLo);
alert.addAlertNotificatinLog(alNoLo);
@@ -758,23 +745,20 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
badList.add(badOne);
}
}
- if (anl.getResultState()==ResultState.FAILED_EMAIL)
- anl.setBadEmails(StringUtils.getListAsString(badList,","));
- if (anl.getResultState()==ResultState.DEFERRED_EMAIL && badList.isEmpty())
+ if (anl.getResultState() == ResultState.FAILED_EMAIL)
+ anl.setBadEmails(StringUtils.getListAsString(badList, ","));
+ if (anl.getResultState() == ResultState.DEFERRED_EMAIL && badList.isEmpty())
anl.setResultState(ResultState.SUCCESS);
}
- }
- else { // No bad addresses
+ } else { // No bad addresses
// Only set the result state to success for email sending notifications
// We must not set them if the notification failed.
for (AlertNotificationLog anl : alert.getAlertNotificationLogs()) {
- if (anl.getResultState()==ResultState.DEFERRED_EMAIL)
+ if (anl.getResultState() == ResultState.DEFERRED_EMAIL)
anl.setResultState(ResultState.SUCCESS);
}
}
-
-
} catch (Exception e) {
log.error("Failed to send all notifications for " + alert.toSimpleString(), e);
}
@@ -897,13 +881,11 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
format = AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT;
SimpleDateFormat dateFormat;
if (shortVersion)
- dateFormat= new SimpleDateFormat(
- "yy/MM/dd HH:mm:ss z");
+ dateFormat = new SimpleDateFormat("yy/MM/dd HH:mm:ss z");
else
- dateFormat= new SimpleDateFormat(
- "yyyy/MM/dd HH:mm:ss z");
- builder.append(AlertI18NFactory.getMessage(format,
- conditionCounter, prettyPrintAlertCondition(aLog.getCondition(), shortVersion), dateFormat.format(new Date(aLog.getCtime())), formattedValue));
+ dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z");
+ builder.append(AlertI18NFactory.getMessage(format, conditionCounter, prettyPrintAlertCondition(aLog
+ .getCondition(), shortVersion), dateFormat.format(new Date(aLog.getCtime())), formattedValue));
conditionCounter++;
}
@@ -928,7 +910,7 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
builder.append(condition.getName()).append(' ');
}
} else {
- if (category.getName()!=null) // this is null for e.g. availability
+ if (category.getName() != null) // this is null for e.g. availability
builder.append(condition.getName()).append(' ');
}
@@ -961,7 +943,8 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
|| (category == AlertConditionCategory.TRAIT)) {
if (shortVersion)
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT));
+ builder.append(AlertI18NFactory
+ .getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT));
else
builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED));
@@ -973,21 +956,20 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
else
propsCbEventSeverityRegexMatch = AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH;
- builder.append(AlertI18NFactory.getMessage(
- propsCbEventSeverityRegexMatch, condition.getName(),
+ builder.append(AlertI18NFactory.getMessage(propsCbEventSeverityRegexMatch, condition.getName(),
condition.getOption()));
} else {
if (shortVersion)
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT,
- condition.getName()));
+ builder.append(AlertI18NFactory.getMessage(
+ AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT, condition.getName()));
else
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY,
- condition.getName()));
+ builder.append(AlertI18NFactory.getMessage(
+ AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY, condition.getName()));
}
} else if (category == AlertConditionCategory.AVAILABILITY) {
if (shortVersion)
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT,
- condition.getOption()));
+ builder.append(AlertI18NFactory.getMessage(
+ AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT, condition.getOption()));
else
builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
condition.getOption()));
@@ -1015,7 +997,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
return builder.toString();
}
-
private void processRecovery(AlertDefinition firedDefinition) {
Subject overlord = subjectManager.getOverlord();
Integer recoveryDefinitionId = firedDefinition.getRecoveryId();
@@ -1088,7 +1069,6 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
return false; // Default is not to disable the definition
}
-
@SuppressWarnings("unchecked")
public PageList<Alert> findAlertsByCriteria(Subject subject, AlertCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
index 45deaf4..a55926a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
@@ -92,13 +92,6 @@ public interface AlertManagerLocal {
Map<Integer, Integer> getAlertCountForSchedules(long begin, long end, List<Integer> scheduleIds);
/**
- * Mark the matching alert as acknowledged by the user
- * @param alertId Id of the alert to acknowledge
- * @param user user who acknowledged the alert
- */
- void acknowledgeAlert(int alertId, Subject user);
-
- /**
* Return the plugin manager that is managing alert sender plugins
* @return The alert sender plugin manager
*/
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 224961f..8a4bb98 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -307,7 +307,7 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
entityManager.persist(configuration);
AlertNotification notif = new AlertNotification(definition);
notif.setSenderName(senderName);
- notif.setName(alertName);
+ notif.setDisplayName(alertName);
notif.setConfiguration(configuration);
entityManager.persist(notif);
definition.getAlertNotifications().add(notif);
@@ -537,38 +537,4 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
return template;
}
- /**
- * Add the passed 'transient' notifications onto the alert definitions contained. The old
- * notifications are removed.
- * This method is mainly used when migrating alerts from an old format to the current.
- * @param subject Subject of the caller
- * @param notifications list of AlertNotifications that have the alert definition id encoded in a transient field
- */
- public void mergeTransientAlertNotifications(Subject subject, List<AlertNotification> notifications) {
-
- // Clear out old notifications
- for (AlertNotification n : notifications) {
- AlertDefinition def = alertDefinitionManager.getAlertDefinitionById(subject, n.getAlertDefinitionId());
- if (def == null) {
- LOG.error("Alert Definition with id " + n.getAlertDefinitionId() + "does not exist for notification "
- + n);
- continue;
- }
- def.getAlertNotifications().clear();
- }
-
- // add the new ones
- for (AlertNotification n : notifications) {
- AlertDefinition def = alertDefinitionManager.getAlertDefinitionById(subject, n.getAlertDefinitionId());
- if (def == null)
- continue;
-
- AlertNotification alNo = new AlertNotification(def, n.getConfiguration());
- alNo.setSenderName(n.getSenderName());
- alNo.setName(n.getName());
- alNo.setOrder(n.getOrder());
- entityManager.persist(alNo);
- def.addAlertNotification(alNo);
- }
- }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
index 80c77db..56f1c20 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
@@ -113,15 +113,6 @@ public interface AlertNotificationManagerLocal {
String getBackingBeanNameForSender(String shortName);
/**
- * Add the passed 'transient' notifications onto the alert definitions contained. The old
- * notifications are removed.
- * This method is mainly used when migrating alerts from an old format to the current.
- * @param subject Subject of the caller
- * @param notifications list of AlertNotifications that have the alert definition id encoded in a transient field
- */
- void mergeTransientAlertNotifications(Subject subject, List<AlertNotification> notifications);
-
- /**
* Create a new NotificationTemplate from the passed parameters. The passed AlertNotification objects need to have the
* name and sender and any configuration properties already set; alert definitions must not be set.
* @param name name of this notification template. Must be unique
commit 144c8218afa68c76c5799a8efee3e8411e690989
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 21 20:32:59 2010 -0400
add support for launching JavaTasks which can execute arbitrary SQL against the connection used by the DBUpgrader
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
index 1b48d57..bc4edb6 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
@@ -25,10 +25,13 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
+import java.util.ArrayList;
import java.util.List;
import mazz.i18n.Logger;
+import org.rhq.core.db.ant.dbupgrade.SST_JavaTask;
+
/**
* A vendor-specific database with some vendor-specific method implementations in order to do things necessary for each
* individual type of database. This abstract class provides some default implementations; vendor-specific subclasses
@@ -356,6 +359,40 @@ public abstract class DatabaseType {
}
/**
+ * Executes the given SQL on the given connection. Use this method if you want to return the raw results
+ * for further processing. This is especially useful when used in conjunction with {@link SST_JavaTask}.
+ *
+ * @param conn the connection to the database that will execute the SQL
+ * @param sql the actual SQL to execute
+ *
+ * @throws SQLException
+ */
+ public List<Object[]> executeSelectSql(Connection conn, String sql) throws SQLException {
+ Statement ps = null;
+
+ try {
+ LOG.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, sql);
+ ps = conn.createStatement();
+
+ ResultSet resultSet = ps.executeQuery(sql);
+ ResultSetMetaData metadata = resultSet.getMetaData();
+
+ int numberColumns = metadata.getColumnCount();
+ List<Object[]> results = new ArrayList<Object[]>();
+ while (resultSet.next()) {
+ Object[] nextRow = new Object[numberColumns];
+ for (int i = 0; i < numberColumns; i++) {
+ nextRow[i] = resultSet.getObject(i + 1);
+ }
+ results.add(nextRow);
+ }
+ return results;
+ } finally {
+ closeStatement(ps);
+ }
+ }
+
+ /**
* Executes the given SQL on the given connection. Use this method if you don't care about what the results are, you
* just want to execute the SQL and know if it was successful or not.
*
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java
index c92d722..80061b8 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/DbAntI18NResourceKeys.java
@@ -202,6 +202,16 @@ public interface DbAntI18NResourceKeys {
@I18NMessage(value = "Konnte die Spalte nicht verändern. Grund: {0}", locale = "de") })
String ALTER_COLUMN_ERROR = "SchemaSpecTask.altercolumn.error";
+ @I18NMessages( {
+ @I18NMessage("Executing Java Task: class=[{0}]"),
+ @I18NMessage(value = "Führe die Java-Aufgabe: class=[{0}]", locale = "de") })
+ String JAVA_TASK_EXECUTING = "SchemaSpecTask.javaTask.executing";
+
+ @I18NMessages( {
+ @I18NMessage("Java Task Error: class=[{0}]"),
+ @I18NMessage(value = "Fehler beim Ausführen der Aufgabe [{0}]", locale = "de") })
+ String JAVA_TASK_ERROR = "SchemaSpecTask.javaTask.error";
+
@I18NMessages( { @I18NMessage("No 'jdbcUrl' attribute specified."),
@I18NMessage(value = "Es ist kein 'jdbcUrl' Attribut angegeben", locale = "de") })
String DBUPGRADE_NO_JDBC_URL = "DBUpgrader.no-jdbc-url";
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
new file mode 100644
index 0000000..b083510
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/SST_JavaTask.java
@@ -0,0 +1,101 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.core.db.ant.dbupgrade;
+
+import java.sql.Connection;
+
+import mazz.i18n.Msg;
+
+import org.apache.tools.ant.BuildException;
+
+import org.rhq.core.db.DatabaseType;
+import org.rhq.core.db.ant.DbAntI18NFactory;
+import org.rhq.core.db.ant.DbAntI18NResourceKeys;
+import org.rhq.core.db.upgrade.DatabaseUpgradeTask;
+
+/**
+ * Task that allows more complicated upgrade logic to be externalized into a Java class. The JavaTask must implement
+ * the {@link DatabaseUpgradeTask} interface, which will pass the active {@link Connection} and {@link DatabaseType}
+ * objects used by the main upgrader to it. Authors of JavaTasks are encouraged to use the helper methods provided by
+ * the {@link DatabaseType} object, which will help keep the implementation vendor agnostic with respect to the set of
+ * databases supported by {@link DBUpgrader} at the time it was written.
+ *
+ * Ant task to invoke an external JavaTask, which can perform arbitrarily DDL and DML against the database. This task
+ * accepts one required attribute:
+ *
+ * <ul>
+ * <li>className</li>
+ * </ul>
+ *
+ * @author Joseph Marques
+ */
+public class SST_JavaTask extends SchemaSpecTask {
+ private static final Msg MSG = DbAntI18NFactory.getMsg();
+
+ private String className;
+
+ /**
+ * Sets the name of the class that implements the {@link DatabaseUpgradeTask} interface. If the name is not
+ * package-prefixed, the default "org.rhq.core.db.upgrade" will be assumed.
+ *
+ * @param className
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ /**
+ * Launches the {@link DatabaseUpgradeTask} defined by the className attribute, passing the {@link Connection} and
+ * {@link DatabaseType} from the main {@link DBUpgrader}.
+ *
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() throws BuildException {
+ if (!isDBTargeted()) {
+ return;
+ }
+
+ validateAttributes();
+
+ try {
+ DatabaseType db_type = getDatabaseType();
+ Connection conn = getConnection();
+
+ if (className.indexOf(".") == -1) {
+ className = "org.rhq.core.db.upgrade." + className;
+ }
+
+ log(MSG.getMsg(DbAntI18NResourceKeys.JAVA_TASK_EXECUTING, className));
+
+ Class<?> javaTaskClass = Class.forName(className);
+ DatabaseUpgradeTask javaTask = (DatabaseUpgradeTask) javaTaskClass.newInstance();
+ javaTask.execute(conn, db_type);
+ } catch (Exception e) {
+ throw new BuildException(MSG.getMsg(DbAntI18NResourceKeys.JAVA_TASK_ERROR, e), e);
+ }
+ }
+
+ private void validateAttributes() throws BuildException {
+ if (className == null) {
+ throw new BuildException(MSG.getMsg(DbAntI18NResourceKeys.SCHEMA_SPEC_TASK_MISSING_CHILD_ELEMENT,
+ "JavaTask", "className"));
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
new file mode 100644
index 0000000..fd438c0
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DatabaseUpgradeTask.java
@@ -0,0 +1,34 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.core.db.upgrade;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.rhq.core.db.DatabaseType;
+import org.rhq.core.db.ant.dbupgrade.SST_JavaTask;
+
+/**
+ * Implement this interface if you wish to write database upgrade steps as {@link SST_JavaTask}s.
+ *
+ * @author Joseph Marques
+ */
+public interface DatabaseUpgradeTask {
+ public void execute(Connection connection, DatabaseType type) throws SQLException;
+}
diff --git a/modules/core/dbutils/src/main/resources/db-ant-tasks.properties b/modules/core/dbutils/src/main/resources/db-ant-tasks.properties
index 7a135d9..c5892a9 100644
--- a/modules/core/dbutils/src/main/resources/db-ant-tasks.properties
+++ b/modules/core/dbutils/src/main/resources/db-ant-tasks.properties
@@ -15,5 +15,6 @@ schema-alterColumn=org.rhq.core.db.ant.dbupgrade.SST_AlterColumn
schema-deleteColumn=org.rhq.core.db.ant.dbupgrade.SST_DeleteColumn
schema-dropTable=org.rhq.core.db.ant.dbupgrade.SST_DropTable
schema-directSQL=org.rhq.core.db.ant.dbupgrade.SST_DirectSQL
+schema-javaTask=org.rhq.core.db.ant.dbupgrade.SST_JavaTask
schema-createSequence=org.rhq.core.db.ant.dbupgrade.SST_CreateSequence
schema-dropSequence=org.rhq.core.db.ant.dbupgrade.SST_DropSequence
\ No newline at end of file
commit f7c53db7fa0085b412fcb9f462e2087726d8477c
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 21 16:20:59 2010 -0400
remove alert sender ordering, that feature has been removed from the release
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
index 8db8231..3098d97 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -139,7 +139,6 @@
<column name="NOTIF_TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
<column name="ALERT_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
<column name="ALERT_SENDER_NAME" required="false" size="100" type="VARCHAR2" /> <!-- TODO make required = true -->
- <column name="ALERT_ORDER" type="INTEGER" />
<column name="NAME" type="VARCHAR2" size="100" />
</table>
commit ea6db20872afb4a234604d2c6f244e872612b781
Merge: 744e7b0... 1baa393...
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Apr 23 09:58:00 2010 -0400
Merge branch 'bugfixes' of ssh://git.fedorahosted.org/git/rhq/rhq into bugfixes
commit 1baa3939383e8a78ea9f57796b47014c113b9619
Merge: 90630f8... b547a54...
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Apr 23 12:25:35 2010 +0200
Merge branch 'nav-tree-flyweights' into bugfixes
diff --cc modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
index a18ea29,29debf4..97ff9a8
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
@@@ -73,9 -72,11 +72,9 @@@ public class ResourceGroupTreeModelUIBe
}
}
- rootNode = new ResourceGroupTreeNode(parentGroup);
-
long start = System.currentTimeMillis();
long monitorId = HibernatePerformanceMonitor.get().start();
- List<Resource> resources = resourceManager.findResourcesByCompatibleGroup(EnterpriseFacesContextUtility
+ List<ResourceFlyweight> resources = resourceManager.findResourcesByCompatibleGroup(EnterpriseFacesContextUtility
.getSubject(), parentGroup.getId(), PageControl.getUnlimitedInstance());
long end = System.currentTimeMillis();
HibernatePerformanceMonitor.get().stop(monitorId, "ResourceGroupTree group resources");
diff --cc modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
index 32d60ac,1f53103..c6bbcb7
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
@@@ -89,14 -87,18 +90,26 @@@ public class ResourceGroupTreeNode impl
return level;
}
+ public ResourceGroupTreeNode getParent() {
+ return parent;
+ }
+
+ public void setParent(ResourceGroupTreeNode parent) {
+ this.parent = parent;
+ }
+
+ public String getNodeType() {
+ if (level instanceof ResourceGroup) {
+ return "ResourceGroup";
+ } else if (level instanceof AutoGroupCompositeFlyweight) {
+ return "AutoGroupComposite";
+ } else if (level instanceof ResourceFlyweight) {
+ return "Resource";
+ } else {
+ return level.getClass().getSimpleName();
+ }
+ }
+
public String toString() {
if (level instanceof ResourceGroup) {
ResourceGroup group = (ResourceGroup) level;
@@@ -124,4 -126,4 +137,4 @@@
public void addChildren(Collection<ResourceGroupTreeNode> resourceGroupTreeNodes) {
this.children.addAll(resourceGroupTreeNodes);
}
--}
++}
diff --cc modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
index 18b536f,501d3f7..7c22be6
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
@@@ -20,25 -20,28 +20,26 @@@ package org.rhq.enterprise.gui.navigati
import java.io.IOException;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletResponse;
-import javax.faces.context.FacesContext;
import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletResponse;
-import org.richfaces.component.state.TreeStateAdvisor;
-import org.richfaces.component.state.TreeState;
import org.richfaces.component.UITree;
import org.richfaces.component.html.HtmlTree;
+import org.richfaces.component.state.TreeState;
+import org.richfaces.component.state.TreeStateAdvisor;
import org.richfaces.model.TreeRowKey;
-import org.rhq.core.gui.util.FacesContextUtility;
+import org.rhq.core.domain.auth.Subject;
- import org.rhq.core.domain.resource.group.ResourceGroup;
+ import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+ import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
-import org.rhq.enterprise.gui.inventory.resource.ResourceUIBean;
-import org.rhq.enterprise.server.util.LookupUtil;
-import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.resource.cluster.ClusterKey;
import org.rhq.enterprise.server.resource.cluster.ClusterManagerLocal;
+import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
/**
* @author Greg Hinkle
@@@ -126,15 -89,15 +127,15 @@@ public class ResourceGroupTreeStateAdvi
return null;
}
- private boolean preopen(ResourceGroupTreeNode resourceTreeNode, int selectedGroupId) {
+ private boolean preopen(ResourceGroupTreeNode resourceTreeNode, ClusterKey selectedClusterKey) {
ResourceGroup currentGroup = getCurrentGroup();
if (resourceTreeNode.getData() instanceof ClusterKey) {
- if (((ClusterKey) resourceTreeNode.getData()).equals(this.selectedClusterKey)) {
+ if (((ClusterKey) resourceTreeNode.getData()).equals(selectedClusterKey)) {
return true;
}
- } else if (resourceTreeNode.getData() instanceof AutoGroupComposite) {
+ } else if (resourceTreeNode.getData() instanceof AutoGroupCompositeFlyweight) {
ClusterKey key = resourceTreeNode.getClusterKey();
- AutoGroupComposite ag = (AutoGroupComposite) resourceTreeNode.getData();
+ AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) resourceTreeNode.getData();
if (key.equals(selectedClusterKey)) {
return true;
}
@@@ -157,16 -120,44 +158,11 @@@
HtmlTree tree = (HtmlTree) e.getComponent();
TreeState state = (TreeState) ((HtmlTree) tree).getComponentState();
- try {
- tree.queueNodeExpand((TreeRowKey) tree.getRowKey());
- ResourceGroupTreeNode node = (ResourceGroupTreeNode) tree.getRowData(tree.getRowKey());
-
- if (node != null) {
- ServletContext context = (ServletContext) FacesContextUtility.getFacesContext().getExternalContext()
- .getContext();
- HttpServletResponse response = (HttpServletResponse) FacesContextUtility.getFacesContext()
- .getExternalContext().getResponse();
+ TreeRowKey<?> key = (TreeRowKey<?>) tree.getRowKey();
+ ResourceGroupTreeNode node = (ResourceGroupTreeNode) tree.getRowData(key);
- if (node != null) {
- if (node.getData() instanceof AutoGroupComposite) {
- state.setSelected(e.getOldSelection());
- }
- if (redirectTo(node) == false) { // upon redirect failure, reselect previous node
- state.setSelected(e.getOldSelection());
- }
- Subject subject = EnterpriseFacesContextUtility.getSubject();
-
- if (node.getData() instanceof ClusterKey) {
-
- ClusterManagerLocal clusterManager = LookupUtil.getClusterManager();
- ResourceGroup group = clusterManager.createAutoClusterBackingGroup(
- subject,
- (ClusterKey) node.getData(), true);
-
- String path = "/rhq/group/inventory/view.xhtml";
-
- response.sendRedirect(path + "?groupId=" + group.getId() + "&parentGroupId=" + ((ClusterKey) node.getData()).getClusterGroupId());
-
- } else if (node.getData() instanceof AutoGroupCompositeFlyweight) {
- state.setSelected(e.getOldSelection());
- FacesContext.getCurrentInstance().addMessage("leftNavGroupTreeForm:leftNavGroupTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN, "No cluster autogroup views available", null));
-
- } else if (node.getData() instanceof ResourceGroup) {
- String path = "/rhq/group/inventory/view.xhtml";
- response.sendRedirect(path + "?groupId=" + ((ResourceGroup)node.getData()).getId());
- }
- }
- } catch (Exception e1) {
++ if (node != null && !redirectTo(node)) {
+ state.setSelected(e.getOldSelection());
- FacesContext.getCurrentInstance().addMessage("leftNavGroupTreeForm:leftNavGroupTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN, "Unable to browse to selected group view: " + e1.getMessage(), null));
- e1.printStackTrace();
}
}
@@@ -188,45 -179,4 +184,45 @@@
return false;
}
+ /**
+ * @return false if there was an error redirecting to the target location
+ */
+ private boolean redirectTo(ResourceGroupTreeNode node) {
+ HttpServletResponse response = (HttpServletResponse) FacesContextUtility.getFacesContext().getExternalContext()
+ .getResponse();
+
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+
+ String path = "";
+ if (node.getData() instanceof ClusterKey) {
+
+ ClusterManagerLocal clusterManager = LookupUtil.getClusterManager();
+ ResourceGroup group = clusterManager.createAutoClusterBackingGroup(subject, (ClusterKey) node.getData(),
+ true);
+
+ path = "/rhq/group/inventory/view.xhtml";
+
+ path += ("?groupId=" + group.getId() + "&parentGroupId=" + ((ClusterKey) node.getData())
+ .getClusterGroupId());
+
- } else if (node.getData() instanceof AutoGroupComposite) {
++ } else if (node.getData() instanceof AutoGroupCompositeFlyweight) {
+ FacesContext.getCurrentInstance().addMessage("leftNavGroupTreeForm:leftNavGroupTree",
+ new FacesMessage(FacesMessage.SEVERITY_WARN, "No cluster autogroup views available", null));
-
++ return false;
+ } else if (node.getData() instanceof ResourceGroup) {
+ path = "/rhq/group/inventory/view.xhtml";
+ path += ("?groupId=" + ((ResourceGroup) node.getData()).getId());
+ }
+
+ try {
+ response.sendRedirect(path);
+ return true; // all is well in the land
+ } catch (IOException ioe) {
+ FacesContext.getCurrentInstance().addMessage(
+ "leftNavGroupTreeForm:leftNavGroupTree",
+ new FacesMessage(FacesMessage.SEVERITY_WARN, "Unable to browse to selected group view: "
+ + ioe.getMessage(), null));
+ }
+ return false; // IO error from redirect
+ }
}
diff --cc modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
index 87b57b7,9d08693..794dc61
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
@@@ -163,24 -163,24 +163,24 @@@ public class ResourceTreeModelUIBean
}
avail = avail / entries.size();
- AutoGroupComposite agc = null;
- if (rsc instanceof ResourceSubCategory) {
- agc = new AutoGroupComposite(avail, parentResource, (ResourceSubCategory) rsc, entries.size());
- } else if (rsc instanceof ResourceType) {
- boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceType) rsc).getName());
- agc = new AutoGroupComposite(avail, parentResource, (ResourceType) rsc, entries.size(),
+ AutoGroupCompositeFlyweight agc = null;
+ if (rsc instanceof ResourceSubCategoryFlyweight) {
+ agc = new AutoGroupCompositeFlyweight(avail, parentResource, (ResourceSubCategoryFlyweight) rsc, entries.size());
+ } else if (rsc instanceof ResourceTypeFlyweight) {
+ boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceTypeFlyweight) rsc).getName());
+ agc = new AutoGroupCompositeFlyweight(avail, parentResource, (ResourceTypeFlyweight) rsc, entries.size(),
isDupResourceTypeName);
}
- ResourceTreeNode node = new ResourceTreeNode(agc);
+ ResourceTreeNode node = new ResourceTreeNode(agc, parentNode);
load(node, alwaysGroup);
if (!recursivelyLocked(node)) {
parentNode.getChildren().add(node);
}
} else {
- List<Resource> entries = children.get(rsc);
- for (Resource res : entries) {
+ List<ResourceFlyweight> entries = children.get(rsc);
+ for (ResourceFlyweight res : entries) {
- ResourceTreeNode node = new ResourceTreeNode(res);
+ ResourceTreeNode node = new ResourceTreeNode(res, parentNode);
load(node, alwaysGroup);
if (!recursivelyLocked(node)) {
@@@ -251,23 -251,23 +251,23 @@@
}
avail = avail / entries.size();
- AutoGroupComposite agc = null;
- if (rsc instanceof ResourceSubCategory) {
- agc = new AutoGroupComposite(avail, compositeParent.getParentResource(),
- (ResourceSubCategory) rsc, entries.size());
- } else if (rsc instanceof ResourceType) {
- agc = new AutoGroupComposite(avail, compositeParent.getParentResource(), (ResourceType) rsc,
+ AutoGroupCompositeFlyweight agc = null;
+ if (rsc instanceof ResourceSubCategoryFlyweight) {
+ agc = new AutoGroupCompositeFlyweight(avail, compositeParent.getParentResource(),
+ (ResourceSubCategoryFlyweight) rsc, entries.size());
+ } else if (rsc instanceof ResourceTypeFlyweight) {
+ agc = new AutoGroupCompositeFlyweight(avail, compositeParent.getParentResource(), (ResourceTypeFlyweight) rsc,
entries.size(), false);
}
- ResourceTreeNode node = new ResourceTreeNode(agc);
+ ResourceTreeNode node = new ResourceTreeNode(agc, parentNode);
load(node, alwaysGroup);
if (!recursivelyLocked(node)) {
parentNode.getChildren().add(node);
}
} else {
- List<Resource> entries = children.get(rsc);
- for (Resource res : entries) {
+ List<ResourceFlyweight> entries = children.get(rsc);
+ for (ResourceFlyweight res : entries) {
- ResourceTreeNode node = new ResourceTreeNode(res);
+ ResourceTreeNode node = new ResourceTreeNode(res, parentNode);
load(node, alwaysGroup);
if (!recursivelyLocked(node)) {
parentNode.getChildren().add(node);
diff --cc modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
index 303e5a8,4ea6cb9..84579b1
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
@@@ -56,14 -59,16 +58,24 @@@ public class ResourceTreeNode implement
return level;
}
+ public ResourceTreeNode getParent() {
+ return parent;
+ }
+
+ public void setParent(ResourceTreeNode parent) {
+ this.parent = parent;
+ }
+
+ public String getNodeType() {
+ if (level instanceof AutoGroupCompositeFlyweight) {
+ return "AutoGroupComposite";
+ } else if (level instanceof ResourceFlyweight) {
+ return ((ResourceFlyweight)level).isLocked() ? "LockedResource" : "Resource";
+ } else {
+ return level.getClass().getSimpleName();
+ }
+ }
+
public String toString() {
if (level == null) {
return "";
@@@ -107,4 -117,4 +124,4 @@@
return level.hashCode();
}
--}
++}
diff --cc modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
index 97d5953,a57100c..efdc0cf
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
@@@ -100,51 -75,106 +100,10 @@@ public class ResourceTreeStateAdvisor i
HtmlTree tree = (HtmlTree) e.getComponent();
TreeState state = (TreeState) ((HtmlTree) tree).getComponentState();
- try {
- tree.queueNodeExpand((TreeRowKey) tree.getRowKey());
- ResourceTreeNode node = (ResourceTreeNode) tree.getRowData(tree.getRowKey());
-
- if (node != null) {
- ServletContext context = (ServletContext) FacesContextUtility.getFacesContext().getExternalContext()
- .getContext();
- HttpServletResponse response = (HttpServletResponse) FacesContextUtility.getFacesContext()
- .getExternalContext().getResponse();
-
- Subject subject = EnterpriseFacesContextUtility.getSubject();
-
- if (node.getData() instanceof ResourceFlyweight) {
- ResourceFlyweight flyweight = (ResourceFlyweight) node.getData();
-
- if (flyweight.isLocked()) {
- state.setSelected(e.getOldSelection());
-
- FacesContext.getCurrentInstance().addMessage(
- "leftNavTreeForm:leftNavTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN,
- "You have not been granted view access to this resource", null));
-
- return;
- } else {
- String path = FacesContextUtility.getRequest().getRequestURI();
-
- //Resource resource = this.resourceManager.getResourceById(subject, flyweight.getId());
- ResourceFacets facets = this.resourceTypeManager.getResourceFacets(flyweight.getResourceType()
- .getId());
-
- String fallbackPath = FunctionTagLibrary.getDefaultResourceTabURL();
-
- // Switching from a auto group view... default to monitor page
- if (!path.startsWith("/rhq/resource")) {
- path = fallbackPath;
- } else {
- if ((path.startsWith("/rhq/resource/configuration/") && !facets.isConfiguration())
- || (path.startsWith("/rhq/resource/content/") && !facets.isContent())
- || (path.startsWith("/rhq/resource/operation") && !facets.isOperation())
- || (path.startsWith("/rhq/resource/events") && !facets.isEvent())) {
- // This resource doesn't support those facets
- path = fallbackPath;
- } else if ((path.startsWith("/rhq/resource/configuration/view-map.xhtml") ||
- path.startsWith("/rhq/resource/configuration/edit-map.xhtml") ||
- path.startsWith("/rhq/resource/configuration/add-map.xhtml") ||
- path.startsWith("/rhq/resource/configuration/edit.xhtml") && facets.isConfiguration())) {
- path = "/rhq/resource/configuration/view.xhtml";
-
- } else if (!path.startsWith("/rhq/resource/content/view.xhtml")
- && path.startsWith("/rhq/resource/content/") && facets.isContent()) {
- path = "/rhq/resource/content/view.xhtml";
- } else if (path.startsWith("/rhq/resource/inventory/")
- && !(path.startsWith("/rhq/resource/inventory/view.xhtml")
- || (facets.isPluginConfiguration() && path
- .startsWith("/rhq/resource/inventory/view-connection.xhtml")) || path
- .startsWith("/rhq/resource/inventory/view-agent.xhtml"))) {
- path = "/rhq/resource/inventory/view.xhtml";
- } else if (path.startsWith("/rhq/resource/operation/resourceOperationHistoryDetails.xhtml")) {
- path = "/rhq/resource/operation/resourceOperationHistory.xhtml";
- } else if (path.startsWith("/rhq/resource/operation/resourceOperationScheduleDetails.xhtml")) {
- path = "/rhq/resource/operation/resourceOperationSchedules.xhtml";
- } else if (path.startsWith("/rhq/resource/monitor/response.xhtml") && !facets.isCallTime()) {
- path = fallbackPath;
- }
- }
-
- response.sendRedirect(path + "?id=" + flyweight.getId());
- }
- } else if (node.getData() instanceof AutoGroupCompositeFlyweight) {
- AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) node.getData();
-
- if (ag.getSubcategory() != null) {
- state.setSelected(e.getOldSelection());
- // this is a subcategory or subsubcategory, no page to display right now
- FacesContext.getCurrentInstance().addMessage("leftNavTreeForm:leftNavTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN, "No subcategory pages exist", null));
-
- return;
- } else {
- if (ag.getMemberCount() != node.getChildren().size()) {
- // you don't have access to every autogroup resource
- state.setSelected(e.getOldSelection());
- FacesContext.getCurrentInstance().addMessage(
- "leftNavTreeForm:leftNavTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN,
- "You must have view access to all resources in an autogroup to view it", null));
-
- return;
- } else {
- String path = "/rhq/autogroup/monitor/graphs.xhtml?parent="
- + ag.getParentResource().getId() + "&type=" + ag.getResourceType().getId();
- response.sendRedirect(path);
- }
- }
+ ResourceTreeNode node = (ResourceTreeNode) tree.getRowData(tree.getRowKey());
- if (node != null) {
- if (node.getData() instanceof LockedResource) {
- state.setSelected(e.getOldSelection());
-
- FacesContext.getCurrentInstance().addMessage(
- "leftNavTreeForm:leftNavTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN,
- "You have not been granted view access to this resource", null));
-
- return;
-
- } else if (node.getData() instanceof Resource) {
- if (redirectTo(node) == false) { // upon redirect failure, reselect previous node
- state.setSelected(e.getOldSelection());
-- }
- } else if (node.getData() instanceof AutoGroupComposite) {
- AutoGroupComposite ag = (AutoGroupComposite) node.getData();
-
- if (ag.getSubcategory() != null) {
- state.setSelected(e.getOldSelection());
- // this is a subcategory or subsubcategory, no page to display right now
- FacesContext.getCurrentInstance().addMessage("leftNavTreeForm:leftNavTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN, "No subcategory pages exist", null));
-
- return;
- } else {
- if (ag.getMemberCount() != node.getChildren().size()) {
- // you don't have access to every autogroup resource
- state.setSelected(e.getOldSelection());
- FacesContext.getCurrentInstance().addMessage(
- "leftNavTreeForm:leftNavTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN,
- "You must have view access to all resources in an autogroup to view it", null));
-
- return;
- } else {
- if (redirectTo(node) == false) { // upon redirect failure, reselect previous node
- state.setSelected(e.getOldSelection());
- }
- }
- }
-
-- }
- } catch (IOException e1) {
- e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
++ if (node != null && !redirectTo(node)) {
++ state.setSelected(e.getOldSelection());
}
}
@@@ -246,82 -286,4 +205,102 @@@
return hasMessages;
}
+ /**
+ * @return false if there was an error redirecting to the target location
+ */
+ private boolean redirectTo(ResourceTreeNode node) {
+ HttpServletResponse response = (HttpServletResponse) FacesContextUtility.getFacesContext().getExternalContext()
+ .getResponse();
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+
+ String path = "";
- if (node.getData() instanceof Resource) {
- path = FacesContextUtility.getRequest().getRequestURI();
++ if (node.getData() instanceof ResourceFlyweight) {
++ ResourceFlyweight flyweight = (ResourceFlyweight) node.getData();
++
++ if (flyweight.isLocked()) {
++ FacesContext.getCurrentInstance().addMessage(
++ "leftNavTreeForm:leftNavTree",
++ new FacesMessage(FacesMessage.SEVERITY_WARN,
++ "You have not been granted view access to this resource", null));
++
++ return false;
++ } else {
++ path = FacesContextUtility.getRequest().getRequestURI();
+
- Resource resource = this.resourceManager.getResourceById(subject, ((Resource) node.getData()).getId());
- ResourceFacets facets = this.resourceTypeManager.getResourceFacets(resource.getResourceType().getId());
++ //Resource resource = this.resourceManager.getResourceById(subject, ((Resource) node.getData()).getId());
++ ResourceFacets facets = this.resourceTypeManager.getResourceFacets(flyweight.getResourceType()
++ .getId());
+
- String fallbackPath = FunctionTagLibrary.getDefaultResourceTabURL();
++ String fallbackPath = FunctionTagLibrary.getDefaultResourceTabURL();
+
- // Switching from a auto group view... default to monitor page
- if (!path.startsWith("/rhq/resource")) {
- path = fallbackPath;
- } else {
- if ((path.startsWith("/rhq/resource/configuration/") && !facets.isConfiguration())
- || (path.startsWith("/rhq/resource/content/") && !facets.isContent())
- || (path.startsWith("/rhq/resource/operation") && !facets.isOperation())
- || (path.startsWith("/rhq/resource/events") && !facets.isEvent())) {
- // This resource doesn't support those facets
- path = fallbackPath;
- } else if ((path.startsWith("/rhq/resource/configuration/view-map.xhtml")
- || path.startsWith("/rhq/resource/configuration/edit-map.xhtml")
- || path.startsWith("/rhq/resource/configuration/add-map.xhtml") || path
- .startsWith("/rhq/resource/configuration/edit.xhtml")
- && facets.isConfiguration())) {
- path = "/rhq/resource/configuration/view.xhtml";
-
- } else if (!path.startsWith("/rhq/resource/content/view.xhtml")
- && path.startsWith("/rhq/resource/content/") && facets.isContent()) {
- path = "/rhq/resource/content/view.xhtml";
- } else if (path.startsWith("/rhq/resource/inventory/")
- && !(path.startsWith("/rhq/resource/inventory/view.xhtml")
- || (facets.isPluginConfiguration() && path
- .startsWith("/rhq/resource/inventory/view-connection.xhtml")) || path
- .startsWith("/rhq/resource/inventory/view-agent.xhtml"))) {
- path = "/rhq/resource/inventory/view.xhtml";
- } else if (path.startsWith("/rhq/resource/operation/resourceOperationHistoryDetails.xhtml")) {
- path = "/rhq/resource/operation/resourceOperationHistory.xhtml";
- } else if (path.startsWith("/rhq/resource/operation/resourceOperationScheduleDetails.xhtml")) {
- path = "/rhq/resource/operation/resourceOperationSchedules.xhtml";
- } else if (path.startsWith("/rhq/resource/monitor/response.xhtml") && !facets.isCallTime()) {
++ // Switching from a auto group view... default to monitor page
++ if (!path.startsWith("/rhq/resource")) {
+ path = fallbackPath;
++ } else {
++ if ((path.startsWith("/rhq/resource/configuration/") && !facets.isConfiguration())
++ || (path.startsWith("/rhq/resource/content/") && !facets.isContent())
++ || (path.startsWith("/rhq/resource/operation") && !facets.isOperation())
++ || (path.startsWith("/rhq/resource/events") && !facets.isEvent())) {
++ // This resource doesn't support those facets
++ path = fallbackPath;
++ } else if ((path.startsWith("/rhq/resource/configuration/view-map.xhtml")
++ || path.startsWith("/rhq/resource/configuration/edit-map.xhtml")
++ || path.startsWith("/rhq/resource/configuration/add-map.xhtml") || path
++ .startsWith("/rhq/resource/configuration/edit.xhtml")
++ && facets.isConfiguration())) {
++ path = "/rhq/resource/configuration/view.xhtml";
++
++ } else if (!path.startsWith("/rhq/resource/content/view.xhtml")
++ && path.startsWith("/rhq/resource/content/") && facets.isContent()) {
++ path = "/rhq/resource/content/view.xhtml";
++ } else if (path.startsWith("/rhq/resource/inventory/")
++ && !(path.startsWith("/rhq/resource/inventory/view.xhtml")
++ || (facets.isPluginConfiguration() && path
++ .startsWith("/rhq/resource/inventory/view-connection.xhtml")) || path
++ .startsWith("/rhq/resource/inventory/view-agent.xhtml"))) {
++ path = "/rhq/resource/inventory/view.xhtml";
++ } else if (path.startsWith("/rhq/resource/operation/resourceOperationHistoryDetails.xhtml")) {
++ path = "/rhq/resource/operation/resourceOperationHistory.xhtml";
++ } else if (path.startsWith("/rhq/resource/operation/resourceOperationScheduleDetails.xhtml")) {
++ path = "/rhq/resource/operation/resourceOperationSchedules.xhtml";
++ } else if (path.startsWith("/rhq/resource/monitor/response.xhtml") && !facets.isCallTime()) {
++ path = fallbackPath;
++ }
+ }
- }
+
- path += ("?id=" + ((Resource) node.getData()).getId());
- } else if (node.getData() instanceof AutoGroupComposite) {
- AutoGroupComposite ag = (AutoGroupComposite) node.getData();
++ path += ("?id=" + flyweight.getId());
++ }
++ } else if (node.getData() instanceof AutoGroupCompositeFlyweight) {
++ AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) node.getData();
+ if (ag.getResourceType() == null) {
+ //XXX this is a temporary measure. The subcategories will get the content page in the end.
+ FacesContext.getCurrentInstance().addMessage("leftNavTreeForm:leftNavTree",
+ new FacesMessage(FacesMessage.SEVERITY_WARN, "No subcategory page exists.", null));
+
+ return false;
++ } else if (ag.getMemberCount() != node.getChildren().size()) {
++ // you don't have access to every autogroup resource
++ FacesContext.getCurrentInstance().addMessage(
++ "leftNavTreeForm:leftNavTree",
++ new FacesMessage(FacesMessage.SEVERITY_WARN,
++ "You must have view access to all resources in an autogroup to view it", null));
++
++ return false;
+ } else {
+ path = "/rhq/autogroup/monitor/graphs.xhtml?parent=" + ag.getParentResource().getId() + "&type="
+ + ag.getResourceType().getId();
+ }
+ }
+
+ try {
+ response.sendRedirect(path);
+ return true; // all is well in the land
+ } catch (IOException ioe) {
+ FacesContext.getCurrentInstance().addMessage(
+ "leftNavTreeForm:leftNavTree",
+ new FacesMessage(FacesMessage.SEVERITY_WARN, "Unable to browse to selected resource view: "
+ + ioe.getMessage(), null));
+ }
+ return false; // IO errors from redirect
+ }
}
diff --cc modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
index 9b7130e,90a6a62..572cf4f
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
@@@ -57,9 -48,7 +57,9 @@@
ajaxSubmitSelection="true"
status="commonStatus"
icon="/images/icons/Platform_16.png"
- nodeFace="#{treeNode.data.class.simpleName}"
- nodeFace="#{treeNode.nodeType}">
++ nodeFace="#{treeNode.nodeType}"
+ eventsQueue="groupTreeQueue"
+ ignoreDupResponses="true">
<rich:recursiveTreeNodesAdaptor roots="#{ResourceGroupTreeModelUIBean.roots}"
var="groupTreeItem"
diff --cc modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
index 8a29257,c1a577e..6eb65f5
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
@@@ -56,9 -44,7 +56,9 @@@
nodeSelectListener="#{ResourceTreeStateAdvisor.nodeSelectListener}"
ajaxSubmitSelection="true"
showConnectingLines="false"
- nodeFace="#{treeNode.data.class.simpleName}"
- nodeFace="#{treeNode.nodeType}">
++ nodeFace="#{treeNode.nodeType}"
+ eventsQueue="resourceTreeQueue"
+ ignoreDupResponses="true">
<rich:recursiveTreeNodesAdaptor roots="#{ResourceTreeModelUIBean.roots}"
var="resourceTreeItem"
nodes="#{resourceTreeItem.children}" />
diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 8158d01,2e6a269..687585b
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@@ -18,8 -18,7 +18,6 @@@
*/
package org.rhq.enterprise.server.resource;
- import java.lang.reflect.Constructor;
- import java.lang.reflect.Method;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
commit 744e7b0faa1a9f6ffac3908df23754cf56f3a04b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 22 23:02:46 2010 -0400
More work on subsystem test failures
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
index 550fd11..78d2788 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateEventsSubsystemTest.java
@@ -26,20 +26,23 @@ import java.util.Random;
import java.util.Set;
import javax.persistence.EntityManager;
+import javax.transaction.Status;
import org.testng.annotations.Test;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventDefinition;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.event.EventSource;
-import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
+/**
+ * Note, plugins are registered in new transactions. for tests, this means
+ * you can't do everything in a trans and roll back at the end. You must clean up manually.
+ */
public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
@Override
@@ -49,24 +52,31 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
@Test
public void testCreateDeleteEvent() throws Exception {
-
System.out.println("= testCreateDeleteEvent");
- getTransactionManager().begin();
try {
registerPlugin("event1-1.xml");
ResourceType platform = getResourceType("events");
assert platform != null;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
Set<EventDefinition> eDefs = platform.getEventDefinitions();
assert eDefs != null;
assert eDefs.size() == 1;
EventDefinition hugo = eDefs.iterator().next();
assert hugo.getDescription().equals("One");
assert hugo.getDisplayName().equals("HugoOne");
+ getTransactionManager().rollback();
System.out.println("==> Done with v1");
registerPlugin("event1-2.xml");
platform = getResourceType("events");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
eDefs = platform.getEventDefinitions();
assert eDefs != null;
assert eDefs.size() == 2 : "Did not find 2 EventDefinitions, but " + eDefs.size();
@@ -78,11 +88,16 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
assert def.getDisplayName().equals("HugoTwo");
}
}
+ getTransactionManager().rollback();
System.out.println("==> Done with v2");
registerPlugin("event1-1.xml", "3.0");
platform = getResourceType("events");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
eDefs = platform.getEventDefinitions();
assert eDefs != null;
assert eDefs.size() == 1 : "Did not find 1 EventDefinition, but " + eDefs.size();
@@ -93,7 +108,15 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
System.out.println("==> Done with v1");
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testCreateDeleteEvent");
+ }
}
}
@@ -104,23 +127,31 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
@Test
public void testNoOpChange() throws Exception {
System.out.println("= testNoOpChange");
- getTransactionManager().begin();
try {
registerPlugin("event1-1.xml");
ResourceType platform = getResourceType("events");
assert platform != null;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
Set<EventDefinition> eDefs = platform.getEventDefinitions();
assert eDefs != null;
assert eDefs.size() == 1;
EventDefinition hugo = eDefs.iterator().next();
assert hugo.getDescription().equals("One");
assert hugo.getDisplayName().equals("HugoOne");
+ getTransactionManager().rollback();
System.out.println("==> Done with v1");
registerPlugin("event1-1.xml", "2.0");
platform = getResourceType("events");
assert platform != null;
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
eDefs = platform.getEventDefinitions();
assert eDefs != null;
assert eDefs.size() == 1;
@@ -130,9 +161,15 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
System.out.println("==> Done with v2");
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testNoOpChange");
+ }
}
-
}
@Test
@@ -142,12 +179,13 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
ResourceType platform = null;
Resource testResource = null;
+ EntityManager entityManager = null;
// prepare basic stuff
- getTransactionManager().begin();
- EntityManager entityManager = getEntityManager();
try {
registerPlugin("event1-2.xml");
+ getTransactionManager().begin();
+ entityManager = getEntityManager();
getPluginId(entityManager);
platform = getResourceType("events");
@@ -156,17 +194,12 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
testResource.setUuid("" + new Random().nextInt());
entityManager.persist(testResource);
setUpAgent(entityManager, testResource);
-
getTransactionManager().commit();
- } catch (Exception e) {
- getTransactionManager().rollback();
- throw e;
- }
- getTransactionManager().begin();
- // add event source + events
- try {
- platform = getResourceType("events");
+ getTransactionManager().begin();
+ entityManager = getEntityManager();
+ //platform = getResourceType("events");
+ platform = entityManager.find(ResourceType.class, platform.getId());
testResource = entityManager.find(Resource.class, testResource.getId());
Set<EventDefinition> eDefs = platform.getEventDefinitions();
assert eDefs.size() == 2 : "Did not find the expected 2 eventDefinitions, but " + eDefs.size();
@@ -191,24 +224,17 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
}
assert found : "Hans was not found";
getTransactionManager().commit();
- } catch (Exception e) {
- getTransactionManager().rollback();
- throw e;
- }
-
- Throwable savedThrowable = null;
- getTransactionManager().begin();
- try {
/*
* --- done with the setup ---
* Now check that the event source + events are gone.
*/
-
registerPlugin("event1-1.xml", "3.0");
platform = getResourceType("events");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
- Set<EventDefinition> eDefs = platform.getEventDefinitions();
eDefs = platform.getEventDefinitions();
assert eDefs != null;
assert eDefs.size() == 1 : "Did not find 1 EventDefinition, but " + eDefs.size();
@@ -216,40 +242,16 @@ public class UpdateEventsSubsystemTest extends UpdateSubsytemTestBase {
assert hugo.getDescription().equals("One");
assert hugo.getDisplayName().equals("HugoOne");
- } catch (Throwable t) {
- savedThrowable = t;
- } finally {
- getTransactionManager().rollback();
- }
-
- // now clean up
- try {
- getTransactionManager().begin();
-
- entityManager = getEntityManager();
- resMgr = LookupUtil.getResourceManager();
-
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
- resMgr.deleteResource(overlord, testResource.getId());
- resMgr.deleteSingleResourceInNewTransaction(overlord, testResource.getId());
-
- /* deleting the platform deletes the agent now, so ask the resMgr to do it all for us
- platform = entityManager.getReference(ResourceType.class, platform.getId());
- entityManager.remove(platform);
-
- Agent agent = entityManager.getReference(Agent.class, agentId);
- entityManager.remove(agent);
- */
-
- Plugin plugin1 = entityManager.getReference(Plugin.class, plugin1Id);
- entityManager.remove(plugin1);
-
} finally {
- getTransactionManager().commit();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
-
- if (savedThrowable != null)
- throw new Exception(savedThrowable);
-
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateNativesSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateNativesSubsystemTest.java
index 4e78fc1..a320043 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateNativesSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateNativesSubsystemTest.java
@@ -20,11 +20,18 @@ package org.rhq.enterprise.server.resource.metadata.test;
import java.util.Set;
+import javax.persistence.EntityManager;
+import javax.transaction.Status;
+
import org.testng.annotations.Test;
import org.rhq.core.domain.resource.ProcessScan;
import org.rhq.core.domain.resource.ResourceType;
+/**
+ * Note, plugins are registered in new transactions. for tests, this means
+ * you can't do everything in a trans and roll back at the end. You must clean up manually.
+ */
public class UpdateNativesSubsystemTest extends UpdateSubsytemTestBase {
@Override
@@ -39,9 +46,16 @@ public class UpdateNativesSubsystemTest extends UpdateSubsytemTestBase {
*/
@Test
public void testProcessScans() throws Exception {
- getTransactionManager().begin();
try {
- ResourceType server1 = getServer1ForConfig5(null);
+ registerPlugin("update5-v1_0.xml");
+ ResourceType platform1 = getResourceType("myPlatform5");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform1 = em.find(ResourceType.class, platform1.getId());
+
+ Set<ResourceType> servers = platform1.getChildResourceTypes();
+ assert servers.size() == 1 : "Expected to find 1 server in v1, but got " + servers.size();
+ ResourceType server1 = servers.iterator().next();
/*
* TODO check process scans as well
@@ -57,13 +71,20 @@ public class UpdateNativesSubsystemTest extends UpdateSubsytemTestBase {
assert found == 3 : "Expected to find 3 process scans in v1";
// TODO also check query
-
- getEntityManager().flush();
+ getTransactionManager().rollback();
/*
* check process scans in v2 as well
*/
- ResourceType server2 = getServer2ForConfig5(null);
+ registerPlugin("update5-v2_0.xml");
+ ResourceType platform2 = getResourceType("myPlatform5");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform2 = em.find(ResourceType.class, platform2.getId());
+ Set<ResourceType> servers2 = platform2.getChildResourceTypes();
+ assert servers2.size() == 1 : "Expected to find 1 server in v2, but got " + servers2.size();
+ ResourceType server2 = servers2.iterator().next();
+
Set<ProcessScan> scans2 = server2.getProcessScans();
assert scans2.size() == 3 : "Expected to find 3 process scans in v2, but got " + scans2.size();
found = 0;
@@ -74,13 +95,20 @@ public class UpdateNativesSubsystemTest extends UpdateSubsytemTestBase {
}
assert found == 3 : "Expected to find 3 specific process scans in v2, but got " + found;
-
- getEntityManager().flush();
+ getTransactionManager().rollback();
/*
* Now return to first version of plugin
*/
- server1 = getServer1ForConfig5("3.0");
+ registerPlugin("update5-v1_0.xml", "3.0");
+ platform1 = getResourceType("myPlatform5");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform1 = em.find(ResourceType.class, platform1.getId());
+ servers = platform1.getChildResourceTypes();
+ assert servers.size() == 1 : "Expected to find 1 server in v1, but got " + servers.size();
+ server1 = servers.iterator().next();
+
scans1 = server1.getProcessScans();
assert scans1.size() == 3 : "Expected to find 3 process scans in v1, but got " + scans1.size();
found = 0;
@@ -92,25 +120,14 @@ public class UpdateNativesSubsystemTest extends UpdateSubsytemTestBase {
assert found == 3 : "Expected to find 3 specific process scans in v1 again, but got " + found;
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testProcessScans");
+ }
}
}
-
- protected ResourceType getServer1ForConfig5(String version) throws Exception {
- registerPlugin("update5-v1_0.xml", version);
- ResourceType platform1 = getResourceType("myPlatform5");
- Set<ResourceType> servers = platform1.getChildResourceTypes();
- assert servers.size() == 1 : "Expected to find 1 server in v1, but got " + servers.size();
- ResourceType server1 = servers.iterator().next();
- return server1;
- }
-
- protected ResourceType getServer2ForConfig5(String version) throws Exception {
- registerPlugin("update5-v2_0.xml", version);
- ResourceType platform2 = getResourceType("myPlatform5");
- Set<ResourceType> servers2 = platform2.getChildResourceTypes();
- assert servers2.size() == 1 : "Expected to find 1 server in v2, but got " + servers2.size();
- ResourceType server2 = servers2.iterator().next();
- return server2;
- }
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateOperationsSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateOperationsSubsystemTest.java
index 8f0e8cc..cd36f1d 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateOperationsSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateOperationsSubsystemTest.java
@@ -22,6 +22,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.persistence.EntityManager;
+import javax.transaction.Status;
+
import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -32,8 +35,14 @@ import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.ResourceType;
+/**
+ * Note, plugins are registered in new transactions. for tests, this means
+ * you can't do everything in a trans and roll back at the end. You must clean up manually.
+ */
public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
+ private static final boolean ENABLED = true;
+
@Override
protected String getSubsystemDirectory() {
return "operation";
@@ -44,25 +53,31 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
*
* @throws Exception
*/
- @Test
+ @Test(enabled = ENABLED)
public void testOperationAndArtifactUpdates() throws Exception {
- getTransactionManager().begin();
+ System.out.println("= testOperationAndArtifactUpdates");
try {
registerPlugin("update3-v1_0.xml");
ResourceType platform1 = getResourceType("myPlatform3");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform1 = em.find(ResourceType.class, platform1.getId());
+
Set<PackageType> packageTypes = platform1.getPackageTypes();
assert packageTypes.size() == 3 : "Did not find the three expected package types in v1";
Set<OperationDefinition> ops = platform1.getOperationDefinitions();
assert ops.size() == 3 : "Did not find three expected operations in v1";
-
- getEntityManager().flush();
+ getTransactionManager().rollback();
/*
* Now deploy the changed version of the plugin
*/
registerPlugin("update3-v2_0.xml");
-
ResourceType platform2 = getResourceType("myPlatform3");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform2 = em.find(ResourceType.class, platform2.getId());
+
Set<PackageType> packageTypes2 = platform2.getPackageTypes();
assert packageTypes2.size() == 3 : "Did not find the expected three package types in v2";
Set<OperationDefinition> opDefs = platform2.getOperationDefinitions();
@@ -95,7 +110,7 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
}
assert startFound == true : "Start should be in v2";
- getEntityManager().flush();
+ getTransactionManager().rollback();
/*
* Now try the other way round
@@ -103,6 +118,10 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("update3-v1_0.xml", "3.0");
ResourceType platform3 = getResourceType("myPlatform3");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform3 = em.find(ResourceType.class, platform3.getId());
+
Set<PackageType> packageTypes3 = platform3.getPackageTypes();
assert packageTypes3.size() == 3 : "Did not find the three package types in v3";
Set<OperationDefinition> ops3 = platform3.getOperationDefinitions();
@@ -119,32 +138,48 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
}
assert rpmFound == true : "rpm should be in v3";
+
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testOperationAndArtifactUpdates");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testAddRemoveOperationWithParams() throws Exception {
System.out.println("= testAddRemoveOperationWithParams");
- getTransactionManager().begin();
try {
registerPlugin("operation1-1.xml");
ResourceType platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
Set<OperationDefinition> opDefs = platform.getOperationDefinitions();
assert opDefs != null;
assert opDefs.size() == 1;
OperationDefinition def = opDefs.iterator().next();
assert def.getName().equals("sleep");
assert def.getParametersConfigurationDefinition() == null;
+ getTransactionManager().rollback();
- getEntityManager().flush();
System.out.println("==> Done with v1");
registerPlugin("operation1-2.xml");
platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
opDefs = platform.getOperationDefinitions();
assert opDefs != null;
assert opDefs.size() == 2;
@@ -169,33 +204,47 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
conf = odef.getResultsConfigurationDefinition();
assert conf != null;
-
}
}
+ getTransactionManager().rollback();
- getEntityManager().flush();
System.out.println("==> Done with v2");
registerPlugin("operation1-1.xml", "3.0");
platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
opDefs = platform.getOperationDefinitions();
assert opDefs != null;
assert opDefs.size() == 1;
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testAddRemoveOperationWithParams");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testAddRemoveOperationWithParams2() throws Exception {
System.out.println("= testAddRemoveOperationWithParams2");
- getTransactionManager().begin();
try {
registerPlugin("operation2-1.xml");
ResourceType platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
Set<OperationDefinition> opDefs = platform.getOperationDefinitions();
assert opDefs != null;
assert opDefs.size() == 3 : "Did not find the expected 3 defs, but " + opDefs.size();
@@ -206,13 +255,20 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
found++;
}
assert found == 3 : "Did not find all 3 expected operations";
+ getTransactionManager().rollback();
System.out.println("==> Done with v1");
+
registerPlugin("operation2-1.xml");
System.out.println("==> Done with v1 (2)");
+
registerPlugin("operation2-2.xml");
platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
opDefs = platform.getOperationDefinitions();
assert opDefs != null;
assert opDefs.size() == 4 : "Did not find the expected 4 defs, but " + opDefs.size();
@@ -222,29 +278,45 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
found++;
}
assert found == 4 : "Did not find all 4 expected operations";
+ getTransactionManager().rollback();
System.out.println("==> Done with v2");
registerPlugin("operation2-1.xml", "3.0");
platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
opDefs = platform.getOperationDefinitions();
assert opDefs != null;
assert opDefs.size() == 3 : "Did not find the expected 3 defs, but " + opDefs.size();
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testAddRemoveOperationWithParams2");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testAddRemoveOperationWithGrouping() throws Exception {
System.out.println("= testAddRemoveOperationWithGrouping");
- getTransactionManager().begin();
try {
registerPlugin("operation3-1.xml");
ResourceType platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
Set<OperationDefinition> opDefs = platform.getOperationDefinitions();
assert opDefs != null;
assert opDefs.size() == 3 : "Did not find the expected 3 defs, but " + opDefs.size();
@@ -255,6 +327,7 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
found++;
}
assert found == 3 : "Did not find all 3 expected operations";
+ getTransactionManager().rollback();
System.out.println("==> Done with v1");
@@ -264,8 +337,13 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("operation3-2.xml");
platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
opDefs = platform.getOperationDefinitions();
assert opDefs != null;
+
assert opDefs.size() == 4 : "Did not find the expected 4 defs, but " + opDefs.size();
found = 0;
for (OperationDefinition def : opDefs) {
@@ -273,17 +351,31 @@ public class UpdateOperationsSubsystemTest extends UpdateSubsytemTestBase {
found++;
}
assert found == 4 : "Did not find all 4 expected operations";
+ getTransactionManager().rollback();
System.out.println("==> Done with v2");
+
registerPlugin("operation3-1.xml", "3.0");
platform = getResourceType("ops");
assert platform != null;
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
opDefs = platform.getOperationDefinitions();
assert opDefs != null;
assert opDefs.size() == 3 : "Did not find the expected 3 defs, but " + opDefs.size();
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testAddRemoveOperationWithGrouping");
+ }
}
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java
index 194e8ec..5408db8 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java
@@ -86,7 +86,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testSingleSubCategoryAddFromEmpty");
}
}
}
@@ -114,7 +114,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testSingleSubCategoryAddSibling");
}
}
}
@@ -139,7 +139,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testSingleSubCategoryReplace");
}
}
}
@@ -164,7 +164,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testSingleSubCategoryRemoveOneFromTwo");
}
}
}
@@ -189,7 +189,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testSingleSubCategoryUpdate");
}
}
}
@@ -213,7 +213,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testSingleSubCategoryRemove");
}
}
}
@@ -239,7 +239,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryReplace");
}
}
}
@@ -265,7 +265,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryAddFromEmpty");
}
}
}
@@ -291,7 +291,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryRemoveOneFromTwo");
}
}
}
@@ -317,7 +317,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryAddSibling");
}
}
}
@@ -344,7 +344,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryRemoveChild");
}
}
}
@@ -371,7 +371,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryAddChild");
}
}
}
@@ -398,7 +398,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryUpdate");
}
}
}
@@ -425,7 +425,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryAdd");
}
}
}
@@ -451,7 +451,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryCreate");
}
}
}
@@ -475,7 +475,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryRemoveAll");
}
}
}
@@ -505,7 +505,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryCreateWithServices");
}
}
}
@@ -535,7 +535,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryCreateWithServices2");
}
}
}
@@ -601,7 +601,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testNestedSubCategoryUpdateWithServices");
}
}
}
@@ -626,8 +626,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
try {
cleanupTest();
} catch (Exception e) {
- System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testRemoveService");
}
}
}
@@ -665,7 +664,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testSimpleSubCategoryCreate");
}
}
}
@@ -717,7 +716,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testSimpleSubCategoryUpdate");
}
}
}
@@ -742,7 +741,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testAddIllegalSubcategory1");
}
}
}
@@ -765,7 +764,7 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
cleanupTest();
} catch (Exception e) {
System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
- + ".testSingleSubCategoryCreate");
+ + ".testReferenceToUndefinedChildSubCategory");
}
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceTypeSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceTypeSubsystemTest.java
index 05abfeb..646c661 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceTypeSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceTypeSubsystemTest.java
@@ -21,12 +21,19 @@ package org.rhq.enterprise.server.resource.metadata.test;
import java.util.Iterator;
import java.util.Set;
+import javax.persistence.EntityManager;
+import javax.transaction.Status;
+
import org.testng.annotations.Test;
import org.rhq.core.domain.measurement.DisplayType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.resource.ResourceType;
+/**
+ * Note, plugins are registered in new transactions. for tests, this means
+ * you can't do everything in a trans and roll back at the end. You must clean up manually.
+ */
public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
@Override
@@ -41,10 +48,13 @@ public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
*/
@Test
public void testResourceTypeDeletion() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("update4-v1_0.xml");
ResourceType platform1 = getResourceType("myPlatform4");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform1 = em.find(ResourceType.class, platform1.getId());
+
Set<ResourceType> servers1 = platform1.getChildResourceTypes();
assert servers1.size() == 2 : "Expected to find 2 servers in v1";
int found = 0;
@@ -59,18 +69,28 @@ public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
}
assert found == 2 : "I did not find the expected servers in v1";
+ getTransactionManager().rollback();
registerPlugin("update4-v2_0.xml");
ResourceType platform2 = getResourceType("myPlatform4");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform2 = em.find(ResourceType.class, platform2.getId());
+
Set<ResourceType> servers2 = platform2.getChildResourceTypes();
assert servers2.size() == 1 : "Expected to find 1 servers in v2";
ResourceType server2 = servers2.iterator().next();
assert server2.getName().equals("testServer1");
Set<MeasurementDefinition> mdef = server2.getMetricDefinitions();
assert mdef.size() == 1 : "Expected one MeasurementDefinition in v2";
+ getTransactionManager().rollback();
registerPlugin("update4-v1_0.xml", "3.0");
ResourceType platform3 = getResourceType("myPlatform4");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform3 = em.find(ResourceType.class, platform3.getId());
+
Set<ResourceType> servers3 = platform3.getChildResourceTypes();
assert servers3.size() == 2 : "Expected to find 2 servers in v1/2";
found = 0;
@@ -85,8 +105,17 @@ public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
}
assert found == 2 : "I did not find the expected servers in v1/2";
+
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testResourceTypeDeletion");
+ }
}
}
@@ -94,10 +123,13 @@ public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
//@Test
public void testMoveResoureType() throws Exception {
System.out.println("testUpdatePlugin2 --- start");
- getTransactionManager().begin();
try {
registerPlugin("update2-v1_0.xml");
ResourceType platform1 = getResourceType("myPlatform");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform1 = em.find(ResourceType.class, platform1.getId());
+
assert platform1 != null : "I did not find myPlatform";
Set<MeasurementDefinition> defs = platform1.getMetricDefinitions();
assert defs.size() == 1 : "I was expecting 1 definition at platform level in v1";
@@ -115,8 +147,7 @@ public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
assert nestedDefs.size() == 1 : "Expected 1 definition within 'nestedService' in v1";
MeasurementDefinition defThree = nestedDefs.iterator().next();
int definitionId = defThree.getId(); // get the id of the definition "Three" and save it for later use
-
- getEntityManager().flush();
+ getTransactionManager().rollback();
System.out.println("testUpdatePlugin2 -- done with the first plugin version");
@@ -125,6 +156,10 @@ public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
*/
registerPlugin("update2-v2_0.xml");
ResourceType platform2 = getResourceType("myPlatform");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform2 = em.find(ResourceType.class, platform2.getId());
+
assert platform2 != null : "I did not find myPlatform";
Set<MeasurementDefinition> defs2 = platform2.getMetricDefinitions();
assert defs2.size() == 1 : "I was expecting 1 definition at platform level in v2";
@@ -164,11 +199,18 @@ public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
assert true == false : "We found an unknown type with name " + typeName;
}
}
- }
- // TODO now that we're done here, apply v1 again to also test the other direction
- finally {
- getTransactionManager().rollback();
+ // TODO now that we're done here, apply v1 again to also test the other direction
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out
+ .println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testMoveResoureType");
+ }
}
System.out.println("testUpdatePlugin2 --- end");
@@ -177,17 +219,23 @@ public class UpdateResourceTypeSubsystemTest extends UpdateSubsytemTestBase {
@Test
public void testDuplicateResourceType() throws Exception {
System.out.println("= testDuplicateResourceType");
- getTransactionManager().begin();
try {
System.out.println(" A stack trace coming out of this is expected");
- System.out.flush();
registerPlugin("duplicateResourceType.xml");
getResourceType("ops");
assert false : "We should not have hit this line";
} catch (Exception e) {
; // We expect an exception to come out of the ResourceMetadataManager
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testDuplicateResourceType");
+ }
}
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
index 783dc3b..cb3f029 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
@@ -266,12 +266,17 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
protected void cleanupTest() throws Exception {
try {
cleanupResourceType("constraintPlatform");
+ cleanupResourceType("events");
cleanupResourceType("groupDeletedPlatform");
cleanupResourceType("groupPropDeletedPlatform");
cleanupResourceType("groupPropMovedPlatform");
+ cleanupResourceType("myPlatform");
+ cleanupResourceType("myPlatform3");
+ cleanupResourceType("myPlatform4");
cleanupResourceType("myPlatform5");
//cleanupResourceType("myPlatform6");
cleanupResourceType("myPlatform7");
+ cleanupResourceType("ops");
cleanupResourceType("testApp1");
cleanupResourceType("testServer1");
cleanupResourceType("testServer2");
commit cbba6c5c5857bb685f4c3abe5af87aca8c65e113
Merge: 80ec3ec... 2bae539...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 22 20:27:54 2010 -0400
Merge branch 'master' into master-jay
commit 80ec3ec8c7ec0cc63e572008934b85848e04254c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 22 20:26:54 2010 -0400
Fix tests given new plugin registration transactioning.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java
index 73cf722..194e8ec 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateResourceSubsystemTest.java
@@ -21,59 +21,85 @@ package org.rhq.enterprise.server.resource.metadata.test;
import java.util.List;
import java.util.Set;
+import javax.persistence.EntityManager;
+import javax.transaction.Status;
+
import org.testng.annotations.Test;
import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
+/**
+ * Note, plugins are registered in new transactions. for tests, this means
+ * you can't do everything in a trans and roll back at the end. You must clean up manually.
+ */
public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
+ private static final boolean ENABLED = true;
+
@Override
protected String getSubsystemDirectory() {
return "resource";
}
- @Test
+ @Test(enabled = ENABLED)
public void testSingleSubCategoryCreate() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("one-subcat-v1_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
assertAppsSubCategory(subCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testSingleSubCategoryAddFromEmpty() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("no-subcat.xml", "1.0");
-
registerPlugin("one-subcat-v1_0.xml", "2.0");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
assertAppsSubCategory(subCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testSingleSubCategoryAddSibling() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("one-subcat-v1_0.xml", "1.0");
-
registerPlugin("two-subcat.xml", "2.0");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 2, 0);
assertAppsSubCategory(subCat);
@@ -81,264 +107,388 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
subCat = assertSubCategory(server1.getChildSubCategories(), 2, 1);
assertServicesSubCategory(subCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testSingleSubCategoryReplace() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("one-subcat-v1_0.xml");
-
registerPlugin("one-subcat-v2_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
assertServicesSubCategory(subCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testSingleSubCategoryRemoveOneFromTwo() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("two-subcat.xml", "1.0");
-
registerPlugin("one-subcat-v2_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
assertServicesSubCategory(subCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testSingleSubCategoryUpdate() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("one-subcat-v1_0.xml");
-
registerPlugin("one-subcat-v1_1.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
assertApps2SubCategory(subCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testSingleSubCategoryRemove() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("one-subcat-v1_0.xml");
-
registerPlugin("no-subcat.xml", "2.0");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
assertSubCategory(server1.getChildSubCategories(), 0, null);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryReplace() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-v1_0.xml");
-
registerPlugin("nested-subcat-v2_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 1, 0);
assertServicesSubCategory(childSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryAddFromEmpty() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("no-subcat.xml", "0.0");
-
registerPlugin("nested-subcat-v1_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 1, 0);
assertAppsSubCategory(childSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryRemoveOneFromTwo() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-2children.xml", "1.0");
-
registerPlugin("nested-subcat-v2_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 1, 0);
assertServicesSubCategory(childSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryAddSibling() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-v2_0.xml");
-
registerPlugin("nested-subcat-2children.xml", "3.0");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 2, 1);
assertAppsSubCategory(childSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryRemoveChild() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-grandchild.xml", "1.0");
-
registerPlugin("nested-subcat-v2_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 1, 0);
assertServicesSubCategory(childSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryAddChild() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-v2_0.xml");
-
registerPlugin("nested-subcat-grandchild.xml", "3.0");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 1, 0);
ResourceSubCategory grandChildSubCat = assertSubCategory(childSubCat.getChildSubCategories(), 1, 0);
assertAppsSubCategory(grandChildSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryUpdate() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-v1_0.xml");
-
registerPlugin("nested-subcat-v1_1.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 1, 0);
assertApps2SubCategory(childSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryAdd() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("one-subcat-v3_0.xml");
-
registerPlugin("nested-subcat-v1_1.xml", "4.0");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 1, 0);
assertApps2SubCategory(childSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryCreate() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-v1_1.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
ResourceSubCategory childSubCat = assertSubCategory(subCat.getChildSubCategories(), 1, 0);
assertApps2SubCategory(childSubCat);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryRemoveAll() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-v1_0.xml");
-
registerPlugin("no-subcat.xml", "2.0");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
+
assertSubCategory(server1.getChildSubCategories(), 0, null);
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryCreateWithServices() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-services-v1_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
+
Set<ResourceType> children = server1.getChildResourceTypes();
assert children.size() == 3;
@@ -348,17 +498,27 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
ResourceType apps = getResourceType("testApp1");
assertAppsSubCategory(apps.getSubCategory());
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryCreateWithServices2() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-services-v2_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
+
Set<ResourceType> children = server1.getChildResourceTypes();
assert children.size() == 2;
@@ -368,27 +528,41 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
ResourceType apps = getResourceType("testApp1");
assert apps.getSubCategory().getName().equals("applications2");
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testNestedSubCategoryUpdateWithServices() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("nested-subcat-services-v1_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
+
Set<ResourceType> children = server1.getChildResourceTypes();
assert children.size() == 3;
List<ResourceSubCategory> subCategories = server1.getChildSubCategories();
assert subCategories != null;
assert subCategories.size() == 1; // subcat with name "parent"
// TODO check for 2 children of this subcategory
+ getTransactionManager().rollback();
registerPlugin("nested-subcat-services-v2_0.xml");
-
server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
+
children = server1.getChildResourceTypes();
assert children.size() == 2 : "Expected 2 children, but got " + children.size();
subCategories = server1.getChildSubCategories(); // "testServer1"
@@ -413,45 +587,65 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
ResourceSubCategory subCategory = service2.getSubCategory(); // the subcategory attribute
// TODO the subCategory is currently not persisted to the DB, so can not be found
- subCategory = getEntityManager().find(ResourceSubCategory.class, subCategory.getId());
+ subCategory = em.find(ResourceSubCategory.class, subCategory.getId());
String name = subCategory.getName();
assert name.equals("applications2") : "Expected 'applictions2', but got " + name;
ResourceType apps = getResourceType("testApp1");
assert apps.getSubCategory().getName().equals("applications2");
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testRemoveService() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("services-v1_0.xml");
registerPlugin("services-v2_0.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
+
Set<ResourceType> children = server1.getChildResourceTypes();
assert children.size() == 2 : "Incorrect number of child resource types, should have been 2 but was ["
+ children.size() + "].";
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testSimpleSubCategoryCreate() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("test-subcategories.xml");
-
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
assert subCat.getName().equals("applications");
ResourceType server2 = getResourceType("testServer2");
+ server2 = em.find(ResourceType.class, server2.getId());
assert server2.getChildSubCategories() != null;
assert server2.getChildSubCategories().size() == 2 : "Unexpected number of subcategories ["
@@ -464,26 +658,35 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
subCat = childSubCats.get(1);
assert subCat.getName().equals("destinations");
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testSimpleSubCategoryUpdate() throws Exception {
- getTransactionManager().begin();
try {
registerPlugin("test-subcategories.xml", "1.0");
-
// pretend to be an updated plugin
registerPlugin("test-subcategories2.xml", "2.0");
-
// now test how the subcategories got updated
ResourceType server1 = getResourceType("testServer1");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ server1 = em.find(ResourceType.class, server1.getId());
ResourceSubCategory subCat = assertSubCategory(server1.getChildSubCategories(), 1, 0);
assertApps2SubCategory(subCat);
ResourceType server2 = getResourceType("testServer2");
+ server2 = em.find(ResourceType.class, server2.getId());
assert server2.getChildSubCategories() != null;
@@ -507,7 +710,15 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
subCat = childSubCats.get(1);
assert subCat.getName().equals("destinations");
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
@@ -516,36 +727,46 @@ public class UpdateResourceSubsystemTest extends UpdateSubsytemTestBase {
* expected.
* @throws Exception
*/
- @Test
+ @Test(enabled = ENABLED)
public void testAddIllegalSubcategory1() throws Exception {
- boolean noException = true;
- getTransactionManager().begin();
try {
registerPlugin("illegal-subcat-1.xml");
- // We should not come here, but have bailed out with an exception
+ fail("Exception was not thrown.");
} catch (Throwable t) {
- noException = false;
- // System.out.println(t.getMessage());
+ // expected
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
- if (noException)
- throw new Exception("MetadataManager did not throw an exception as expected.");
}
- @Test
+ @Test(enabled = ENABLED)
public void testReferenceToUndefinedChildSubCategory() throws Exception {
System.out.println("= testReferenceToUndefinedChildSubCategory");
- getTransactionManager().begin();
try {
try {
registerPlugin("undefined-child-subcat-1.xml");
fail("Exception was not thrown.");
} catch (Exception ignored) {
- Exception e = ignored;
+ // expected
}
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testSingleSubCategoryCreate");
+ }
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
index aaf541b..783dc3b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
@@ -130,6 +130,8 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
// used in UpdateMeasurementSubsystemTest
resourceTypeCriteria.fetchMetricDefinitions(true);
+ // used in several UpdateResourceSubsystemTest tests
+ resourceTypeCriteria.fetchSubCategory(true);
PageList<ResourceType> results = resourceTypeManager
.findResourceTypesByCriteria(overlord, resourceTypeCriteria);
@@ -263,16 +265,19 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
protected void cleanupTest() throws Exception {
try {
- cleanupResourceType("testServer1");
- cleanupResourceType("testServer2");
- cleanupResourceType("myPlatform5");
- //cleanupResourceType("myPlatform6");
- cleanupResourceType("myPlatform7");
- cleanupResourceType("TestServer");
cleanupResourceType("constraintPlatform");
cleanupResourceType("groupDeletedPlatform");
cleanupResourceType("groupPropDeletedPlatform");
cleanupResourceType("groupPropMovedPlatform");
+ cleanupResourceType("myPlatform5");
+ //cleanupResourceType("myPlatform6");
+ cleanupResourceType("myPlatform7");
+ cleanupResourceType("testApp1");
+ cleanupResourceType("testServer1");
+ cleanupResourceType("testServer2");
+ cleanupResourceType("testService1");
+ cleanupResourceType("testService2");
+ cleanupResourceType("TestServer");
getTransactionManager().begin();
EntityManager entityManager = getEntityManager();
commit 2bae5390b161726acda709f7299fb27fe36e1945
Merge: 8dcf947... 166fac0...
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 22 17:25:04 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 166fac0b1f937b0ec4ba0f5b78e3544dd86820e4
Merge: 69b8666... e38d846...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 22 17:01:32 2010 -0400
Merge branch 'master' into master-jay
commit 8dcf947e02849a6364a88e6d25b864df841d2a2d
Merge: e38d846... 90630f8...
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 22 17:00:20 2010 -0400
Merge branch 'bugfixes'
commit 69b8666cbf90b28ff30fa957e626726eb9c203a8
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 22 17:00:17 2010 -0400
UpdateConfigurationSubsystemTest updated to deal with new plugin
registration transaction requirements. Enabled one disabled but passing
test. Disabled testListProperty() pending further investigation into
Hibernates inablity to deal with the list of lists structure in the
resource config.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
index 2e6d94f..0dc958a 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
@@ -18,6 +18,16 @@
*/
package org.rhq.enterprise.server.resource.metadata.test;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+import javax.transaction.Status;
+
+import org.testng.annotations.Test;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -32,15 +42,8 @@ import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.configuration.definition.constraint.Constraint;
import org.rhq.core.domain.configuration.definition.constraint.FloatRangeConstraint;
import org.rhq.core.domain.configuration.definition.constraint.IntegerRangeConstraint;
-import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
-import org.testng.annotations.Test;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
/**
* Tests the updating of persisted ResourceTypes' resource and plugin ConfigurationDefinitions, which is essentially
@@ -50,6 +53,8 @@ import java.util.Set;
*/
public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
+ private static final boolean ENABLED = true;
+
@Override
protected String getSubsystemDirectory() {
return "configuration";
@@ -60,11 +65,21 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
*
* @throws Exception
*/
- @Test
+ @Test(enabled = ENABLED)
public void testUpdatePluginConfig() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
- ResourceType server1 = getServer1ForConfig5(null);
+ registerPlugin("update5-v1_0.xml", null);
+ ResourceType platform1 = getResourceType("myPlatform5");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform1 = em.find(ResourceType.class, platform1.getId());
+
+ Set<ResourceType> servers = platform1.getChildResourceTypes();
+ assert servers.size() == 1 : "Expected to find 1 server in v1, but got " + servers.size();
+ ResourceType server1 = servers.iterator().next();
ConfigurationDefinition cDef = server1.getPluginConfigurationDefinition();
assert cDef != null : "Expected to find a PluginConfigurationDefinition in v1";
List<PropertyGroupDefinition> groups1 = cDef.getGroupDefinitions();
@@ -90,18 +105,22 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
assert found == 3 : "Expected to find 3 specially named control groups in v1, but only found " + found;
// TODO check more stuff here
+ getTransactionManager().rollback();
System.out.println("-------- done with v1");
- // }
-
- getEntityManager().flush();
-
/*
* Now deploy version 2
*/
+ registerPlugin("update5-v2_0.xml", null);
+ ResourceType platform2 = getResourceType("myPlatform5");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform2 = em.find(ResourceType.class, platform2.getId());
- ResourceType server2 = getServer2ForConfig5(null);
+ Set<ResourceType> servers2 = platform2.getChildResourceTypes();
+ assert servers2.size() == 1 : "Expected to find 1 server in v2, but got " + servers2.size();
+ ResourceType server2 = servers2.iterator().next();
ConfigurationDefinition cDef2 = server2.getPluginConfigurationDefinition();
assert cDef2 != null : "Expected to find a PluginConfigurationDefinition in v2";
List<PropertyGroupDefinition> groups2 = cDef2.getGroupDefinitions();
@@ -137,86 +156,115 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
assert found == 3 : "Expected to find 3 specially named control groups in v2, but only found " + found;
// TODO check resource-config as well
+ getTransactionManager().rollback();
System.out.println("-------- done with v2");
// TODO check changing back
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testAddDeleteDefaultTemplate");
+ }
}
}
@Test(enabled = false)
public void testBZ_573034() throws Exception {
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
- getTransactionManager().begin();
- EntityManager entityMgr = getEntityManager();
-
// register plugin
- String pluginName = "BZ_573034_test_plugin";
String version1 = "1.0";
String version2 = "2.0";
registerPlugin("BZ_573034_v1.xml", version1);
// create resource with plugin configuration
- ResourceType testServerResourceType = getResourceType("TestServer", pluginName);
-
+ ResourceType testServerResourceType = getResourceType("TestServer");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ testServerResourceType = em.find(ResourceType.class, testServerResourceType.getId());
ConfigurationDefinition pluginConfigurationDef = testServerResourceType.getPluginConfigurationDefinition();
PropertyDefinition testPropertyDef = pluginConfigurationDef.getPropertyDefinitionSimple("testProperty");
-
- assertNotNull(
- "Expected plugin configuration definition to have a property definition for 'testProperty'",
- testPropertyDef
- );
-
- Agent agent = new Agent("testAgent", "localhost", 1, "", "testoken");
- entityMgr.persist(agent);
- entityMgr.flush();
-
- String resourceKey = testServerResourceType.getName() + System.currentTimeMillis();
- Resource testResource = new Resource(resourceKey, resourceKey, testServerResourceType);
- testResource.setAgent(agent);
- entityMgr.persist(testResource);
- entityMgr.flush();
-
- testResource = entityMgr.find(Resource.class, testResource.getId());
- int pluginConfigurationId = testResource.getPluginConfiguration().getId();
-
- Configuration pluginConfiguration = entityMgr.find(Configuration.class, pluginConfigurationId);
- PropertySimple testProperty = pluginConfiguration.getSimple("testProperty");
-
- assertNull(
- "Did not expect to find a value for 'testProperty' since a value has not been supplied for it yet",
- testProperty
- );
+ Configuration pluginConfiguration = null;
+ int pluginConfigurationId = 0;
+ try {
+ assertNotNull(
+ "Expected plugin configuration definition to have a property definition for 'testProperty'",
+ testPropertyDef);
+
+ String resourceKey = testServerResourceType.getName() + System.currentTimeMillis();
+ Resource testResource = new Resource(resourceKey, resourceKey, testServerResourceType);
+ testResource.setUuid("" + new Random().nextInt());
+ em.persist(testResource);
+ em.flush();
+
+ setUpAgent(em, testResource);
+
+ testResource = em.find(Resource.class, testResource.getId());
+ pluginConfigurationId = testResource.getPluginConfiguration().getId();
+
+ pluginConfiguration = em.find(Configuration.class, pluginConfigurationId);
+ PropertySimple testProperty = pluginConfiguration.getSimple("testProperty");
+
+ assertNull(
+ "Did not expect to find a value for 'testProperty' since a value has not been supplied for it yet",
+ testProperty);
+
+ getTransactionManager().commit();
+ } catch (Exception e) {
+ getTransactionManager().rollback();
+ fail("testBZ_573034:" + e);
+ }
// register new version of plugin that specifies new plugin configuration property having a default value
registerPlugin("BZ_573034_v2.xml", version2);
// verify existing resource has its plugin configuration updated with new property having default value
- testServerResourceType = getResourceType("TestServer", pluginName);
+ testServerResourceType = getResourceType("TestServer");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ testServerResourceType = em.find(ResourceType.class, testServerResourceType.getId());
pluginConfigurationDef = testServerResourceType.getPluginConfigurationDefinition();
- PropertyDefinition testPropertyWithDefaultDef =
- pluginConfigurationDef.getPropertyDefinitionSimple("testPropertyWithDefault");
+ PropertyDefinition testPropertyWithDefaultDef = pluginConfigurationDef
+ .getPropertyDefinitionSimple("testPropertyWithDefault");
assertNotNull(
"Expected updated plugin configuration definition to define the property 'testPropertyWithDefault'",
- testPropertyWithDefaultDef
- );
+ testPropertyWithDefaultDef);
- pluginConfiguration = entityMgr.find(Configuration.class, pluginConfigurationId);
+ pluginConfiguration = em.find(Configuration.class, pluginConfigurationId);
PropertySimple testPropertyWithDefault = pluginConfiguration.getSimple("testPropertyWithDefault");
assertNotNull(
"Expected to find the property 'testPropertyWithDefault' in the updated plugin configuration",
- testPropertyWithDefault
- );
+ testPropertyWithDefault);
assertEquals("Expected default value to be set", "default", testPropertyWithDefault.getStringValue());
- }
- finally {
+
getTransactionManager().rollback();
+
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testResourceConfiguration");
+ }
}
}
@@ -225,14 +273,24 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
*
* @throws Exception
*/
- @Test
+ @Test(enabled = ENABLED)
public void testResourceConfiguration() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
- ResourceType server1 = getServer1ForConfig5("1");
- ConfigurationDefinition def1 = server1.getResourceConfigurationDefinition();
+ registerPlugin("update5-v1_0.xml", "1");
+ ResourceType platform1 = getResourceType("myPlatform5");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform1 = em.find(ResourceType.class, platform1.getId());
+ Set<ResourceType> servers = platform1.getChildResourceTypes();
+ assert servers.size() == 1 : "Expected to find 1 server in v1, but got " + servers.size();
+ ResourceType server1 = servers.iterator().next();
+ ConfigurationDefinition def1 = server1.getResourceConfigurationDefinition();
List<PropertyDefinition> cpdl = def1.getNonGroupedProperties();
+
assert cpdl.size() == 3 : "Did not find 3 properties in <resource-configuration> in v1 but " + cpdl.size();
for (PropertyDefinition pd : cpdl) {
if (pd.getName().equals("jnpPort")) {
@@ -258,15 +316,22 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
+ constraints.size();
}
}
-
- getEntityManager().flush();
+ getTransactionManager().rollback();
/*
* Now check the changed plugin
*/
+ registerPlugin("update5-v2_0.xml", "2");
+ ResourceType platform2 = getResourceType("myPlatform5");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform2 = em.find(ResourceType.class, platform2.getId());
- ResourceType server2 = getServer2ForConfig5("2");
+ Set<ResourceType> servers2 = platform2.getChildResourceTypes();
+ assert servers2.size() == 1 : "Expected to find 1 server in v2, but got " + servers2.size();
+ ResourceType server2 = servers2.iterator().next();
ConfigurationDefinition def2 = server2.getResourceConfigurationDefinition();
+ def2 = getEntityManager().find(ConfigurationDefinition.class, def2.getId());
List<PropertyDefinition> cpdl2 = def2.getNonGroupedProperties();
assert cpdl2.size() == 3 : "Did not find 3 properties in <resource-configuration> in v2 but "
+ cpdl2.size();
@@ -319,15 +384,22 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
+ constraints.size();
}
}
+ getTransactionManager().rollback();
- getEntityManager().flush();
/*
* And now back to the first version
*/
- ResourceType server3 = getServer1ForConfig5("3");
- ConfigurationDefinition def3 = server3.getResourceConfigurationDefinition();
+ registerPlugin("update5-v1_0.xml", "3");
+ platform1 = getResourceType("myPlatform5");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform1 = em.find(ResourceType.class, platform1.getId());
+ servers = platform1.getChildResourceTypes();
+ assert servers.size() == 1 : "Expected to find 1 server in v1, but got " + servers.size();
+ ResourceType server3 = servers.iterator().next();
+ ConfigurationDefinition def3 = server3.getResourceConfigurationDefinition();
List<PropertyDefinition> cpdl3 = def3.getNonGroupedProperties();
assert cpdl3.size() == 3 : "Did not find 3 properties in <resource-configuration> in v3 again but "
@@ -362,27 +434,21 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
}
}
}
- } finally {
getTransactionManager().rollback();
- }
- }
- protected ResourceType getServer1ForConfig5(String version) throws Exception {
- registerPlugin("update5-v1_0.xml", version);
- ResourceType platform1 = getResourceType("myPlatform5");
- Set<ResourceType> servers = platform1.getChildResourceTypes();
- assert servers.size() == 1 : "Expected to find 1 server in v1, but got " + servers.size();
- ResourceType server1 = servers.iterator().next();
- return server1;
- }
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
- protected ResourceType getServer2ForConfig5(String version) throws Exception {
- registerPlugin("update5-v2_0.xml", version);
- ResourceType platform2 = getResourceType("myPlatform5");
- Set<ResourceType> servers2 = platform2.getChildResourceTypes();
- assert servers2.size() == 1 : "Expected to find 1 server in v2, but got " + servers2.size();
- ResourceType server2 = servers2.iterator().next();
- return server2;
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testResourceConfiguration");
+ }
+ }
}
/**
@@ -390,20 +456,38 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
*
* @throws Exception
*/
- @Test
+ @SuppressWarnings("deprecation")
+ @Test(enabled = ENABLED)
public void testConstraint() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("constraint.xml");
ResourceType platform = getResourceType("constraintPlatform");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition config = platform.getResourceConfigurationDefinition();
PropertyDefinitionSimple propDef = config.getPropertyDefinitionSimple("secureJnpPort");
Set<Constraint> constraints = propDef.getConstraints();
assert constraints.size() == 4 : "Expected to get 4 constraints, but got " + constraints.size();
assert propDef.getDefaultValue().equals("1234");
- } finally {
getTransactionManager().rollback();
+
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testConstraint");
+ }
}
}
@@ -412,12 +496,19 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
*
* @throws Exception
*/
- @Test
+ @SuppressWarnings("deprecation")
+ @Test(enabled = ENABLED)
public void testConstraint2() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("constraint.xml");
ResourceType platform = getResourceType("constraintPlatform");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition config = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefMap = config.getPropertyDefinitions();
PropertyDefinitionSimple propDef = (PropertyDefinitionSimple) propDefMap.get("secureJnpPort");
@@ -425,8 +516,19 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
assert constraints.size() == 4 : "Expected to get 4 constraints, but got " + constraints.size();
assert propDef.getDefaultValue().equals("1234");
- } finally {
getTransactionManager().rollback();
+
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testConstraint2");
+ }
}
}
@@ -435,12 +537,18 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
*
* @throws Exception
*/
- @Test(enabled = false)
+ @Test(enabled = ENABLED)
public void testConstraintMinMax() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("constraintMinMax.xml");
ResourceType platform = getResourceType("constraintPlatform");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition config = platform.getResourceConfigurationDefinition();
PropertyDefinitionSimple propDef = config.getPropertyDefinitionSimple("secureJnpPort");
Set<Constraint> constraints = propDef.getConstraints();
@@ -457,18 +565,38 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
assert frc.getMinimum() == 5.0;
}
}
- } finally {
getTransactionManager().rollback();
+
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testConstraint2");
+ }
}
}
- @Test
+ // TODO (jshaughn) For some reason this test is creating a ConfigDef that Hibernate chokes on. Need
+ // to come back and figure out why. Perhaps it's oracle specific... Also, if activated update
+ // cleanup routine in TestBase to delete myPlatform6.
+ @Test(enabled = false)
public void testListProperty() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
{ // extra block for variable scoping purposes
registerPlugin("propertyList-v1.xml");
ResourceType platform = getResourceType("myPlatform6");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
@@ -529,16 +657,19 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
assert true == false : "Unknown list-definition in v1: " + pdl.getName();
}
}
+ getTransactionManager().rollback();
}
- getEntityManager().flush();
-
/*
* Deploy v2 of the plugin
*/
{ // extra block for variable scoping purposes
registerPlugin("propertyList-v2.xml");
ResourceType platform = getResourceType("myPlatform6");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
@@ -626,21 +757,37 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
} else {
assert true == false : "Unknown list-definition in v2: " + pdl.getName();
}
+ getTransactionManager().rollback();
}
// done with v2
}
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testListProperty");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testListPropertyMinMax() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("propertyList-simple.xml");
ResourceType platform = getResourceType("myPlatform");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> properties = cd.getPropertyDefinitions();
PropertyDefinitionList a = (PropertyDefinitionList) properties.get("a");
@@ -651,18 +798,37 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
// See JBNADM-1595
// assert a.getMax()==6 : "Expected the max to be 6 but it was " + a.getMax();
// assert a.getMin()==4 : "Expected the min to be 4 but it was " + a.getMin();
- } finally {
+
getTransactionManager().rollback();
+
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testListPropertyMinMax");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testMapProperty() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
{ // extra block for variable scoping purposes
registerPlugin("propertyMap-v1.xml");
ResourceType platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
assert propDefs.size() == 5 : "Expected to find 5 properties in v1, but got " + propDefs.size();
@@ -700,10 +866,11 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
}
assert found == 5 : "Did not find the 5 desired maps in v1";
+
+ getTransactionManager().rollback();
}
System.out.println("Done with v1");
- getEntityManager().flush();
/*
* Now deploy v2
@@ -711,6 +878,10 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
{ // extra block for variable scoping purposes
registerPlugin("propertyMap-v2.xml");
ResourceType platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
assert propDefs.size() == 5 : "Expected to find 5 properties in v2, but got " + propDefs.size();
@@ -761,9 +932,20 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
}
assert found == 5 : "Did not find the 5 desired properties in v2, instead found " + found;
+
+ getTransactionManager().rollback();
}
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testMapProperty");
+ }
}
}
@@ -772,13 +954,19 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
*
* @throws Exception
*/
- @Test
+ @Test(enabled = ENABLED)
public void testChangePropertyType() throws Exception {
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
{ // extra block for variable scoping purposes
registerPlugin("propertyChanging-v1.xml");
ResourceType platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
for (PropertyDefinition def : propDefs.values()) {
@@ -798,9 +986,9 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
assert true == false : "Unknown definition : " + def.getName() + " in v1";
}
}
+ getTransactionManager().rollback();
}
- getEntityManager().flush();
/*
* Now deploy v2
*/
@@ -808,6 +996,10 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
{ // extra block for variable scoping purposes
registerPlugin("propertyChanging-v2.xml");
ResourceType platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
for (PropertyDefinition def : propDefs.values()) {
@@ -833,15 +1025,18 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
assert true == false : "Unknown definition : " + def.getName() + " in v2";
}
}
+ getTransactionManager().rollback();
}
- getEntityManager().flush();
-
/*
* Now deploy v1 again
*/{ // extra block for variable scoping purposes
registerPlugin("propertyChanging-v1.xml", "3.0"); // this is our 3rd version, but reuse v1
ResourceType platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
for (PropertyDefinition def : propDefs.values()) {
@@ -865,18 +1060,31 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
+ def.getClass().getCanonicalName();
}
}
+ getTransactionManager().rollback();
}
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testChangePropertyType");
+ }
}
+
}
/*==================================== Resource Config Tests ======================================*/
- @Test
+ @Test(enabled = ENABLED)
public void testGroupDeleted() throws Exception {
- System.out.println("= testGroupDeleted");
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("groupDeleted-v1.xml");
System.out.println("==> Done with v1");
@@ -885,14 +1093,19 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("groupDeleted-v1.xml", "3.0");
System.out.println("==> Done with v1");
} finally {
- getTransactionManager().rollback();
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testGroupDeleted");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testGroupPropDeleted() throws Exception {
- System.out.println("= testGroupPropDeleted");
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("groupPropDeleted-v1.xml");
System.out.println("==> Done with v1");
@@ -901,14 +1114,20 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("groupPropDeleted-v1.xml", "3.0");
System.out.println("==> Done with v1");
} finally {
- getTransactionManager().rollback();
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testGroupPropDeleted");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testGroupPropDeletedExt() throws Exception {
- System.out.println("= testGroupPropDeletedExt");
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("groupPropDeleted-v3.xml");
System.out.println("==> Done with v1");
@@ -917,14 +1136,20 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("groupPropDeleted-v3.xml", "5.0");
System.out.println("==> Done with v1");
} finally {
- getTransactionManager().rollback();
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testGroupPropDeletedExt");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testGroupPropMoved() throws Exception {
- System.out.println("= testGroupPropMoved");
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("groupPropMoved-v1.xml");
System.out.println("==> Done with v1");
@@ -933,42 +1158,68 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("groupPropMoved-v1.xml", "3.0");
System.out.println("==> Done with v1");
} finally {
- getTransactionManager().rollback();
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testGroupPropMoved");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testUpdateDefaultTemplate() throws Exception {
- System.out.println("=testUpdateDefaultTemplate");
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
registerPlugin("updateDefaultTemplate1.xml");
ResourceType platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
ConfigurationTemplate defaultTemplate = cd.getDefaultTemplate();
assert defaultTemplate != null;
Configuration config = defaultTemplate.getConfiguration();
PropertySimple ps = config.getSimple("six");
assert "foo".equals(ps.getStringValue()) : "Expected 'foo', but got " + ps.getStringValue();
+ getTransactionManager().rollback();
registerPlugin("updateDefaultTemplate2.xml");
platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
cd = platform.getResourceConfigurationDefinition();
defaultTemplate = cd.getDefaultTemplate();
assert defaultTemplate != null;
config = defaultTemplate.getConfiguration();
ps = config.getSimple("six");
assert "bar".equals(ps.getStringValue()) : "Expected 'bar', but got " + ps.getStringValue();
+ getTransactionManager().rollback();
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testUpdateDefaultTemplate");
+ }
}
}
- @Test
+ @Test(enabled = ENABLED)
public void testAddDeleteTemplate() throws Exception {
- System.out.println("=testAddDeleteTemplate");
- getTransactionManager().begin();
+ // Note, plugins are registered in new transactions. for tests, this means
+ // you can't do everything in a trans and roll back at the end. You must clean up
+ // manually.
try {
ResourceType platform;
ConfigurationTemplate defaultTemplate;
@@ -979,15 +1230,24 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
registerPlugin("addDeleteTemplate1.xml");
platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+
cd = platform.getResourceConfigurationDefinition();
defaultTemplate = cd.getDefaultTemplate();
assert defaultTemplate != null;
templateMap = cd.getTemplates();
assert templateMap.size() == 1 : "Expected only the 1 default template but got " + templateMap.size();
+ getTransactionManager().rollback();
+
System.out.println("Done with v1");
registerPlugin("addDeleteTemplate2.xml");
platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
cd = platform.getResourceConfigurationDefinition();
defaultTemplate = cd.getDefaultTemplate();
templateMap = cd.getTemplates();
@@ -997,11 +1257,15 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
assert template != null;
ps = template.getConfiguration().getSimple("second_one");
assert ps.getStringValue().equals("Bart") : "Expected 'Bart', but got " + ps.getStringValue();
+ getTransactionManager().rollback();
System.out.println("Done with v2");
registerPlugin("addDeleteTemplate3.xml");
platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
cd = platform.getResourceConfigurationDefinition();
defaultTemplate = cd.getDefaultTemplate();
templateMap = cd.getTemplates();
@@ -1012,19 +1276,36 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
ps = template.getConfiguration().getSimple("second_one");
assert ps.getStringValue().equals("Bart Simpson") : "Expected 'Bart Simpson', but got "
+ ps.getStringValue();
+ getTransactionManager().rollback();
+
System.out.println("Done with v3");
registerPlugin("addDeleteTemplate1.xml", "4.0"); // this is our 4th version, but reuse v1
platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
cd = platform.getResourceConfigurationDefinition();
defaultTemplate = cd.getDefaultTemplate();
templateMap = cd.getTemplates();
assert defaultTemplate != null;
assert templateMap.size() == 1 : "Expected only the 1 default template but got " + templateMap.size();
+ getTransactionManager().rollback();
+
System.out.println("Done with v1(2)");
} finally {
- getTransactionManager().rollback();
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ + ".testAddDeleteDefaultTemplate");
+ }
}
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateMeasurementSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateMeasurementSubsystemTest.java
index c1d3ef3..c5cadf4 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateMeasurementSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateMeasurementSubsystemTest.java
@@ -34,12 +34,9 @@ import org.rhq.core.domain.measurement.DisplayType;
import org.rhq.core.domain.measurement.MeasurementBaseline;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementSchedule;
-import org.rhq.core.domain.plugin.Plugin;
-import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
@@ -60,9 +57,6 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
@Test(enabled = ENABLED)
public void testUpdateMeasurementDefinitions() throws Exception {
- // cleanup previous run
- cleanupTest();
-
// Note, plugins are registered in new transactions. for tests, this means
// you can't do everything in a trans and roll back at the end. You must clean up
// manually.
@@ -134,7 +128,7 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
try {
cleanupTest();
} catch (Exception e) {
- System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ System.out.println("CANNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ ".testUpdateMeasurementDefinition");
}
}
@@ -147,8 +141,6 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
*/
@Test(enabled = ENABLED)
public void testDeleteMeasurementDefinition() throws Exception {
- // cleanup previous run
- cleanupTest();
// Note, plugins are registered in new transactions. for tests, this means
// you can't do everything in a trans and roll back at the end. You must clean up
@@ -180,7 +172,7 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
try {
cleanupTest();
} catch (Exception e) {
- System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ System.out.println("CANNOT CLEAN UP TEST: " + this.getClass().getSimpleName()
+ ".testDeleteMeasurementDefinition");
}
}
@@ -195,9 +187,6 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
@Test(enabled = ENABLED)
public void testRenameServer() throws Exception {
- // cleanup previous run
- cleanupTest();
-
Resource testResource = null;
MeasurementSchedule sched = null;
MeasurementBaseline baseline = null;
@@ -206,13 +195,12 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
// Note, plugins are registered in new transactions. for tests, this means
// you can't do everything in a trans and roll back at the end. You must clean up
// manually. Still, some work can be performed transactionally, as done below.
- getTransactionManager().begin();
-
try {
try {
registerPlugin("update6-1.xml");
ResourceType server = getResourceType("testServer1");
+ getTransactionManager().begin();
EntityManager entityManager = getEntityManager();
getPluginId(entityManager);
@@ -223,7 +211,7 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
/*
* Create a Fake Resource and a MeasurementSchedule
*/
- testResource = new Resource("-test-", "-test resource", server);
+ testResource = new Resource("-test-", "-test resource-", server);
testResource.setUuid("" + new Random().nextInt());
entityManager.persist(testResource);
@@ -250,38 +238,27 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
// Set up done, now replace the plugin with a new one.
- try {
- getTransactionManager().begin();
-
- EntityManager entityManager = getEntityManager();
- entityManager.flush();
-
- System.out.println("Done with v1");
+ System.out.println("Done with v1");
- registerPlugin("update6-2.xml");
+ registerPlugin("update6-2.xml");
- ResourceType server;
- try {
- server = getResourceType("testServer1");
- assert server == null : "testServer1 found, but should not";
- } catch (NoResultException nre) {
- ; // no issue
- }
+ ResourceType server;
+ try {
+ server = getResourceType("testServer1");
+ assert server == null : "testServer1 found, but should not";
+ } catch (NoResultException nre) {
+ ; // no issue
+ }
- server = getResourceType("testServer2");
- assert server != null : "testServer2 not found";
+ server = getResourceType("testServer2");
+ assert server != null : "testServer2 not found";
- getTransactionManager().commit();
- } catch (Throwable t) {
- getTransactionManager().rollback();
- fail("update failed: " + t);
- }
} finally {
// clean up
try {
cleanupTest();
} catch (Exception e) {
- System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testRenameServer");
+ System.out.println("CANNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testRenameServer");
}
}
}
@@ -294,21 +271,15 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
@Test(enabled = ENABLED)
public void testAddScheduleOnExistingResources() throws Exception {
- Throwable savedThrowable = null;
-
- // cleanup previous run
- cleanupTest();
-
// Note, plugins are registered in new transactions. for tests, this means
// you can't do everything in a trans and roll back at the end. You must clean up
// manually. Still, some work can be performed transactionally, as done below.
- getTransactionManager().begin();
-
try {
try {
registerPlugin("update7-1.xml");
ResourceType platform = getResourceType("myPlatform7");
+ getTransactionManager().begin();
EntityManager entityManager = getEntityManager();
getPluginId(entityManager);
@@ -333,142 +304,43 @@ public class UpdateMeasurementSubsystemTest extends UpdateSubsytemTestBase {
// Set up done, now replace the plugin with a new one.
- try {
- getTransactionManager().begin();
-
- EntityManager entityManager = getEntityManager();
- entityManager.flush();
-
- System.out.println("Done with v1");
-
- try {
- registerPlugin("update7-2.xml");
- } catch (Throwable t) {
- System.err.println(t);
- }
-
- ResourceType platform = getResourceType("myPlatform7");
- Set<MeasurementDefinition> definitions2 = platform.getMetricDefinitions();
- assert definitions2.size() == 2;
-
- List<Resource> resources = platform.getResources();
- assert resources != null;
- assert resources.size() == 1;
-
- Resource res = resources.get(0);
- Set<MeasurementSchedule> schedules = res.getSchedules();
- assert schedules != null;
- /*
- * We only expect one schedule for the freshly created metric, as the resource we
- * created earlier has no schedule attached yet (in the test).
- * In the "real world" it would get its schedules on inventory sync time.
- */
- assert schedules.size() == 1 : "Did not find the expected 1 new schedule, but: " + schedules.size();
- getTransactionManager().commit();
-
- } catch (Throwable t) {
- getTransactionManager().rollback();
- fail("update failed: " + t);
- }
- } finally {
- // clean up
- try {
- cleanupTest();
- } catch (Exception e) {
- System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testRenameServer");
- }
- }
-
- if (savedThrowable != null)
- throw new Exception(savedThrowable);
- }
-
- private void cleanupTest() throws Exception {
- try {
- cleanupResourceType("testServer1");
- cleanupResourceType("testServer2");
- cleanupResourceType("myPlatform7");
-
- getTransactionManager().begin();
- EntityManager entityManager = getEntityManager();
+ System.out.println("Done with v1");
try {
- agentId = getAgentId(entityManager);
- Agent agent = entityManager.getReference(Agent.class, agentId);
- if (null != agent) {
- entityManager.remove(agent);
- }
- } catch (Exception e) {
- // ignore, agent does not exist
+ registerPlugin("update7-2.xml");
+ } catch (Throwable t) {
+ System.err.println(t);
}
- try {
- plugin1Id = getPluginId(entityManager);
- Plugin plugin1 = entityManager.getReference(Plugin.class, plugin1Id);
- if (null != plugin1) {
- entityManager.remove(plugin1);
- }
- } catch (Exception e) {
- // ignore, plugin1 does not exist
- }
+ ResourceType platform = getResourceType("myPlatform7");
+ Set<MeasurementDefinition> definitions2 = platform.getMetricDefinitions();
+ assert definitions2.size() == 2;
- } finally {
- getTransactionManager().commit();
- }
- }
-
- private void cleanupResourceType(String rtName) throws Exception {
- ResourceType rt = getResourceType(rtName);
-
- if (null != rt) {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
- ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
-
- // delete any resources first
ResourceCriteria c = new ResourceCriteria();
- c.addFilterResourceTypeId(rt.getId());
+ c.addFilterResourceTypeId(platform.getId());
c.addFilterInventoryStatus(InventoryStatus.NEW);
- List<Resource> doomedResources = resourceManager.findResourcesByCriteria(overlord, c);
- c.addFilterInventoryStatus(InventoryStatus.DELETED);
- doomedResources.addAll(resourceManager.findResourcesByCriteria(overlord, c));
- c.addFilterInventoryStatus(InventoryStatus.UNINVENTORIED);
- doomedResources.addAll(resourceManager.findResourcesByCriteria(overlord, c));
- // invoke bulk delete on the resource to remove any dependencies not defined in the hibernate entity model
- // perform in-band and out-of-band work in quick succession
- for (Resource doomed : doomedResources) {
- List<Integer> deletedIds = resourceManager.deleteResource(overlord, doomed.getId());
- for (Integer deletedResourceId : deletedIds) {
- resourceManager.deleteSingleResourceInNewTransaction(overlord, deletedResourceId);
- }
- }
-
- // Measurement defs go away via cascade remove
+ c.fetchSchedules(true);
+ List<Resource> resources = LookupUtil.getResourceManager().findResourcesByCriteria(overlord, c);
+ assert resources != null;
+ assertEquals(1, resources.size());
+
+ Resource res = resources.get(0);
+ Set<MeasurementSchedule> schedules = res.getSchedules();
+ assert schedules != null;
/*
- Set<MeasurementDefinition> defs = server.getMetricDefinitions();
- if (defs != null) {
- Iterator<MeasurementDefinition> defIter = defs.iterator();
- while (defIter.hasNext()) {
- MeasurementDefinition def = defIter.next();
- // we can directly delete this, as there are no schdules on v2 defined.
- em.remove(def);
- defIter.remove();
- }
- }
- */
-
- getTransactionManager().begin();
- EntityManager em = getEntityManager();
-
- rt = em.find(ResourceType.class, rt.getId());
- ResourceType parent = rt.getParentResourceTypes().isEmpty() ? null : rt.getParentResourceTypes().iterator()
- .next();
- em.remove(rt);
- if (null != parent) {
- em.remove(parent);
+ * We only expect one schedule for the freshly created metric, as the resource we
+ * created earlier has no schedule attached yet (in the test).
+ * In the "real world" it would get its schedules on inventory sync time.
+ */
+ assert schedules.size() == 1 : "Did not find the expected 1 new schedule, but: " + schedules.size();
+ } finally {
+ // clean up
+ try {
+ cleanupTest();
+ } catch (Exception e) {
+ System.out.println("CANNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testRenameServer");
}
-
- getTransactionManager().commit();
}
}
-
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
index 57d0140..aaf541b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
@@ -20,12 +20,14 @@ package org.rhq.enterprise.server.resource.metadata.test;
import java.io.FileNotFoundException;
import java.net.URL;
+import java.util.List;
import java.util.Set;
import javax.ejb.EJB;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
+import javax.transaction.Status;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
@@ -36,17 +38,20 @@ import javax.xml.validation.SchemaFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeTest;
import org.rhq.core.clientapi.agent.measurement.MeasurementAgentService;
import org.rhq.core.clientapi.descriptor.DescriptorPackages;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
@@ -105,6 +110,13 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
unprepareScheduler();
}
+ @BeforeTest
+ public void beforeTest() throws Exception {
+ startTest();
+ // cleanup anything left over from a previous, interrupted run.
+ cleanupTest();
+ }
+
protected ResourceType getResourceType(String typeName) {
return getResourceType(typeName, PLUGIN_NAME);
}
@@ -116,12 +128,9 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
resourceTypeCriteria.addFilterName(typeName);
resourceTypeCriteria.addFilterPluginName(pluginName);
- resourceTypeCriteria.fetchPluginConfigurationDefinition(true);
- resourceTypeCriteria.fetchResourceConfigurationDefinition(true);
+ // used in UpdateMeasurementSubsystemTest
resourceTypeCriteria.fetchMetricDefinitions(true);
- // TODO: Fetch everything else.
-
PageList<ResourceType> results = resourceTypeManager
.findResourceTypesByCriteria(overlord, resourceTypeCriteria);
if (results.size() == 0) {
@@ -250,6 +259,99 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
public Set<Integer> getMeasurementScheduleIdsForResource(int resourceId) {
return null;
}
+ }
+ protected void cleanupTest() throws Exception {
+ try {
+ cleanupResourceType("testServer1");
+ cleanupResourceType("testServer2");
+ cleanupResourceType("myPlatform5");
+ //cleanupResourceType("myPlatform6");
+ cleanupResourceType("myPlatform7");
+ cleanupResourceType("TestServer");
+ cleanupResourceType("constraintPlatform");
+ cleanupResourceType("groupDeletedPlatform");
+ cleanupResourceType("groupPropDeletedPlatform");
+ cleanupResourceType("groupPropMovedPlatform");
+
+ getTransactionManager().begin();
+ EntityManager entityManager = getEntityManager();
+
+ try {
+ agentId = getAgentId(entityManager);
+ Agent agent = entityManager.getReference(Agent.class, agentId);
+ if (null != agent) {
+ entityManager.remove(agent);
+ }
+ } catch (Exception e) {
+ // ignore, agent does not exist
+ }
+
+ try {
+ plugin1Id = getPluginId(entityManager);
+ Plugin plugin1 = entityManager.getReference(Plugin.class, plugin1Id);
+ if (null != plugin1) {
+ entityManager.remove(plugin1);
+ }
+ } catch (Exception e) {
+ // ignore, plugin1 does not exist
+ }
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().commit();
+ }
+ }
+ }
+
+ protected void cleanupResourceType(String rtName) throws Exception {
+ try {
+ ResourceType rt = getResourceType(rtName);
+
+ if (null != rt) {
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+ ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+
+ // delete any resources first
+ ResourceCriteria c = new ResourceCriteria();
+ c.addFilterResourceTypeId(rt.getId());
+ c.addFilterInventoryStatus(InventoryStatus.NEW);
+ List<Resource> doomedResources = resourceManager.findResourcesByCriteria(overlord, c);
+ c.addFilterInventoryStatus(InventoryStatus.DELETED);
+ doomedResources.addAll(resourceManager.findResourcesByCriteria(overlord, c));
+ c.addFilterInventoryStatus(InventoryStatus.UNINVENTORIED);
+ doomedResources.addAll(resourceManager.findResourcesByCriteria(overlord, c));
+ // invoke bulk delete on the resource to remove any dependencies not defined in the hibernate entity model
+ // perform in-band and out-of-band work in quick succession
+ for (Resource doomed : doomedResources) {
+ List<Integer> deletedIds = resourceManager.deleteResource(overlord, doomed.getId());
+ for (Integer deletedResourceId : deletedIds) {
+ resourceManager.deleteSingleResourceInNewTransaction(overlord, deletedResourceId);
+ }
+ }
+
+ // Measurement defs go away via cascade remove
+
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+
+ rt = em.find(ResourceType.class, rt.getId());
+ ResourceType parent = rt.getParentResourceTypes().isEmpty() ? null : rt.getParentResourceTypes()
+ .iterator().next();
+ em.remove(rt);
+ if (null != parent) {
+ em.remove(parent);
+ }
+ }
+ } catch (Exception e) {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().rollback();
+ }
+ System.out.println("CANNOT CLEAN UP TEST (cleanupResourceType): " + e);
+ throw e;
+ } finally {
+ if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
+ getTransactionManager().commit();
+ }
+ }
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v1.xml b/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v1.xml
index cc9e547..85de1cf 100644
--- a/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v1.xml
+++ b/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v1.xml
@@ -1,4 +1,4 @@
-<plugin name="BZ_573034_test_plugin" displayName="Bug 573034 Test Plugin" package="org.rhq.plugins.mock.jboss"
+<plugin name="ResourceMetaDataManagerBeanTest" displayName="Bug 573034 Test Plugin" package="org.rhq.plugins.mock.jboss"
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
diff --git a/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v2.xml b/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v2.xml
index b31279d..15b8d74 100644
--- a/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v2.xml
+++ b/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v2.xml
@@ -1,4 +1,4 @@
-<plugin name="BZ_573034_test_plugin" displayName="Bug 573034 Test Plugin" package="org.rhq.plugins.mock.jboss"
+<plugin name="ResourceMetaDataManagerBeanTest" displayName="Bug 573034 Test Plugin" package="org.rhq.plugins.mock.jboss"
version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
commit e38d846200a6bee16b87f7e8c0fe4679ff01752a
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Apr 22 16:14:56 2010 -0400
BZ 582471: AD server fix i)disable referral follow ii)change enumeration->next method iii)added npe check for ldap bug.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
index 1f4bdd6..bd38c20 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
@@ -82,7 +82,8 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
PageControl pca = WebUtility.getPageControl(request, "a");
PageControl pcp = WebUtility.getPageControl(request, "p");
- //BZ-580127 Refactor so that all lists are initialized regardless of ldap server availability or state of filter params
+ //BZ-580127 Refactor so that all lists are initialized regardless of ldap server
+ // availability or state of filter params
List<String> pendingGroupIds = new ArrayList<String>();
Set<Map<String, String>> allGroups = new HashSet<Map<String, String>>();
PageList<LdapGroup> assignedList = new PageList<LdapGroup>();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
index 1e02587..d6fcaa7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
@@ -184,7 +184,8 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
for (int x = 0; x < baseDNs.length; x++) {
NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
- if (!answer.hasMore()) {
+ boolean ldapApiNpeFound = false;
+ if (!answer.hasMoreElements()) {//BZ:582471- ldap api bug
log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]);
// Nothing found for this DN, move to the next one if we have one.
@@ -295,7 +296,7 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
env.setProperty(Context.PROVIDER_URL, providerUrl);
// Follow referrals automatically
- env.setProperty(Context.REFERRAL, "follow");
+ env.setProperty(Context.REFERRAL, "ignore");//BZ:582471- active directory query change
return env;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
index 7766825..0478fd8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
@@ -136,7 +136,7 @@ public class LdapGroupManager {
String[] baseDNs = baseDN.split(BASEDN_DELIMITER);
for (int x = 0; x < baseDNs.length; x++) {
NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
- if (!answer.hasMore()) {
+ if (!answer.hasMoreElements()) { //BZ:582471- ldap api bug change
log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]);
// Nothing found for this DN, move to the next one if we have one.
continue;
@@ -196,9 +196,16 @@ public class LdapGroupManager {
for (int x = 0; x < baseDNs.length; x++) {
NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls);
- while (answer.hasMore()) {
+ boolean ldapApiEnumerationBugEncountered = false;
+ while ((!ldapApiEnumerationBugEncountered) && answer.hasMoreElements()) {//BZ:582471- ldap api bug change
// We use the first match
- SearchResult si = (SearchResult) answer.next();
+ SearchResult si = null;
+ try {
+ si = (SearchResult) answer.next();
+ } catch (NullPointerException npe) {
+ ldapApiEnumerationBugEncountered = true;
+ break;
+ }
Map<String, String> entry = new HashMap<String, String>();
String name = (String) si.getAttributes().get("cn").get();
Attribute desc = si.getAttributes().get("description");
@@ -216,7 +223,7 @@ public class LdapGroupManager {
log.error(message, fException);
throw new LdapFilterException(message + " " + fException.getMessage());
}
- //TODO: check for ldap connection/unavailable/etc. exception.
+ //TODO: check for ldap connection/unavailable/etc. exceptions.
else {
log.error("LDAP communication error: " + e.getMessage(), e);
throw new LdapCommunicationException(e);
@@ -258,7 +265,7 @@ public class LdapGroupManager {
env.setProperty(Context.PROVIDER_URL, providerUrl);
// Follow referrals automatically
- env.setProperty(Context.REFERRAL, "follow");
+ env.setProperty(Context.REFERRAL, "ignore"); //BZ:582471- active directory query change
return env;
}
commit 90630f8799837300a02a43a56bfa1b39a4c4e29f
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 22 15:57:48 2010 -0400
[BZ 575987] Removing reference to method for rhq-register functionality that has been removed
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
index 10cc5ad..2101515 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
@@ -89,9 +89,6 @@ public class WsResourceUtility {
resource.setVersion("1.0");
resource.setResourceType(types.get(0));
- // Register the platform
- service.registerPlatform(admin, resource, -1);
-
// Retrieve for return
ResourceCriteria criteria = objectFactory.createResourceCriteria();
criteria.setFilterName(name);
commit 24780bf536848ad9547a54f4505fe27c758695e2
Merge: 36812ce... 6e1b309...
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 22 14:58:37 2010 -0400
Merge branch 'master' into bugfixes
commit 36812ce7837b6db8a41c114bffcedc2e84b485c6
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 22 14:55:51 2010 -0400
[BZ 575987] Removing rhq-register functionality from web services api
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 23f8a11..5350c6b 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
@@ -152,8 +152,6 @@ import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.operation.GroupOperationSchedule;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.operation.ResourceOperationSchedule;
-import org.rhq.enterprise.server.registration.RegistrationException;
-import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.ResourceNotFoundException;
@@ -206,7 +204,6 @@ public class WebservicesManagerBean implements WebservicesRemote {
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
private ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();
private ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
- private RegistrationManagerLocal registrationManager = LookupUtil.getRegistrationManager();
private RoleManagerLocal roleManager = LookupUtil.getRoleManager();
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
@@ -911,19 +908,6 @@ public class WebservicesManagerBean implements WebservicesRemote {
pluginConfiguration, resourceConfiguration);
}
- public void registerPlatform(Subject subject, Resource resource, int parentId) {
- registrationManager.registerPlatform(subject, resource, parentId);
- }
-
- public void importPlatform(Subject subject, Resource resource) {
- registrationManager.importPlatform(subject, resource);
- }
-
- public void subscribePlatformToBaseRepo(Subject subject, Resource platform, String release, String version,
- String arch) throws RegistrationException {
- registrationManager.subscribePlatformToBaseRepo(subject, platform, release, version, arch);
- }
-
public void createPackageBackedResource(Subject subject, int parentResourceId, int newResourceTypeId,
String newResourceName,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 68a6691..eb05b9f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -66,6 +66,5 @@ public interface WebservicesRemote extends //
RoleManagerRemote,//
SubjectManagerRemote,//
SupportManagerRemote,//
- SystemManagerRemote, //
- RegistrationManagerRemote {
+ SystemManagerRemote {
}
commit 6e1b30927baa58b7ee02741731b6f2ffc8e3f26f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 22 11:04:11 2010 -0400
BZ 577875 - when in daemon mode, jline seems to want to gobble up console input, do not use native console libs when in daemon mode, there is no need for us to do so anyway
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index d616aea..73064b1 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -2085,7 +2085,7 @@ public class AgentMain {
LOG.warn(AgentI18NResourceKeys.NATIVE_SYSINFO_UNAVAILABLE);
}
this.loggedNativeSystemInfoUnavailableWarning = true;
- }
+ }
} else {
this.loggedNativeSystemInfoUnavailableWarning = false;
}
@@ -2722,6 +2722,7 @@ public class AgentMain {
String config_file_name = null;
boolean clean_config = false;
boolean purge_data = false;
+ AgentInputReaderFactory.ConsoleType console_type = null;
Getopt getopt = new Getopt("agent", args, sopts, lopts);
int code;
@@ -2804,7 +2805,7 @@ public class AgentMain {
}
case 'e': {
- AgentInputReaderFactory.setConsoleType(getopt.getOptarg());
+ console_type = AgentInputReaderFactory.ConsoleType.valueOf(getopt.getOptarg()); // throws IllegalArgumentException if invalid
break;
}
@@ -2849,6 +2850,12 @@ public class AgentMain {
}
}
+ if (m_daemonMode) {
+ AgentInputReaderFactory.setConsoleType(AgentInputReaderFactory.ConsoleType.java); // don't use native libs, no need and jline causes problems
+ } else if (console_type != null) {
+ AgentInputReaderFactory.setConsoleType(console_type);
+ }
+
// now that all the arguments were processed, let's load in our config (this allows the -p to come after -c)
if (clean_config) {
getPreferencesNode().removeNode();
commit 47ca444b489bd704ab67d8a083f8e228c7852868
Merge: 75f8cc4... 728a80e...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 22 08:49:57 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 87ca061f502586bba65c0ded8bb9575136d9532e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Apr 22 12:53:06 2010 +0200
BZ 582193 - left nav context menu working again. New version of RF requires parameters passed to the show() method for the contextMenu that weren't necessary before.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/entity/layout/main.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/entity/layout/main.xhtml
index e314620..aa9f90d 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/entity/layout/main.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/entity/layout/main.xhtml
@@ -56,24 +56,7 @@ id - the id of the Resource being accessed
<ui:insert name="content"><p>Default Entity Content</p></ui:insert>
</div>
</div>
- </div>
-
- <!-- Define context menu outside of the tree form so rerendering this doesn't cause tree rerendering/reloading -->
- <h:form>
- <rich:contextMenu attached="false" id="resourceMenu"
- binding="#{ResourceTreeContextMenuUIBean.menu}"
- disableDefaultMenu="false" style="z-index: 50;"
- submitMode="ajax" rendered="#{not empty param.id or not empty param.parent}" />
- <rich:contextMenu attached="false" id="autoGroupMenu"
- binding="#{AutoGroupTreeContextMenuUIBean.menu}"
- disableDefaultMenu="false" style="z-index: 50;"
- submitMode="ajax" rendered="#{not empty param.id or not empty param.parent}" />
- <rich:contextMenu attached="false" id="groupMenu"
- binding="#{ResourceGroupTreeContextMenuUIBean.menu}"
- disableDefaultMenu="false" style="z-index: 50;"
- submitMode="ajax" rendered="#{not empty param.groupId}" />
- </h:form>
-
+ </div>
</div>
<a4j:region renderRegionOnly="true" selfRendered="true">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
index 8f7e00b..9b7130e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
@@ -16,6 +16,13 @@
<f:subview id="navigationTreeView">
<ui:composition>
+ <!-- Define context menu outside of the tree form so rerendering this doesn't cause tree rerendering/reloading -->
+ <h:form>
+ <rich:contextMenu attached="false" id="groupMenu"
+ binding="#{ResourceGroupTreeContextMenuUIBean.menu}"
+ disableDefaultMenu="false" style="z-index: 50;"
+ submitMode="ajax" />
+ </h:form>
<h:form id="leftNavGroupTreeForm"> <!-- datascroll tag wants a form to be present -->
<h:panelGroup id="leftTreeHolder">
@@ -68,16 +75,10 @@
<a4j:support event="oncontextmenu" reRender="groupMenu" timeout="5000"
disableDefault="true" status="commonStatus" limitToList="true"
- ajaxSingle="true">
+ ajaxSingle="true" oncomplete="#{rich:component('groupMenu')}.show(event, {})">
<f:param name="contextGroupId" value="#{groupTreeItem.data.id}"/>
<f:param name="contextParentGroupId" value="#{groupTreeItem.data.id}"/>
-
-
- <rich:componentControl disableDefault="true" event="oncomplete" for="groupMenu"
- operation="show">
- <f:param name="contextGroupId" value="#{groupTreeItem.data.id}"/>
- </rich:componentControl>
</a4j:support>
<h:outputText value="#{groupTreeItem.data.name}" title="Right-click for more options."/>
@@ -100,15 +101,10 @@
<a4j:support event="oncontextmenu" reRender="groupMenu" timeout="5000"
disableDefault="true" status="commonStatus" limitToList="true"
- ajaxSingle="true">
+ ajaxSingle="true" oncomplete="#{rich:component('groupMenu')}.show(event, {})">
<f:param name="contextClusterKey" value="#{groupTreeItem.data.key}"/>
<f:param name="contextParentGroupId" value="#{param.parentGroupId == null ? param.groupId : param.parentGroupId}"/>
-
- <rich:componentControl disableDefault="true" event="oncomplete" for="groupMenu"
- operation="show">
- <f:param name="clusterKey" value="#{groupTreeItem.data}"/>
- </rich:componentControl>
</a4j:support>
<h:outputText value="#{groupTreeItem.members[0]}" title="Right-click for more options."/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
index 9ebf514..8a29257 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
@@ -16,6 +16,17 @@
<f:subview id="navigationTreeView">
<ui:composition>
+ <!-- Define context menu outside of the tree form so rerendering this doesn't cause tree rerendering/reloading -->
+ <h:form>
+ <rich:contextMenu attached="false" id="resourceMenu"
+ binding="#{ResourceTreeContextMenuUIBean.menu}"
+ disableDefaultMenu="false" style="z-index: 50;"
+ submitMode="ajax" />
+ <rich:contextMenu attached="false" id="autoGroupMenu"
+ binding="#{AutoGroupTreeContextMenuUIBean.menu}"
+ disableDefaultMenu="false" style="z-index: 50;"
+ submitMode="ajax" />
+ </h:form>
<h:form id="leftNavTreeForm"> <!-- tree needs a form to be present -->
<h:panelGroup id="leftTreeHolder">
@@ -60,15 +71,11 @@
<a4j:support event="oncontextmenu" reRender="autoGroupMenu" timeout="5000"
disableDefault="true" status="commonStatus" limitToList="true"
- ajaxSingle="true" rendered="#{resourceTreeItem.data.resourceType != null}">
+ ajaxSingle="true" rendered="#{resourceTreeItem.data.resourceType != null}"
+ oncomplete="#{rich:component('autoGroupMenu')}.show(event, {})">
<f:param name="contextParentResourceId" value="#{resourceTreeItem.data.parentResource.id}"/>
<f:param name="contextAutoGroupResourceTypeId" value="#{resourceTreeItem.data.resourceType.id}"/>
- <rich:componentControl disableDefault="true" event="oncomplete" for="autoGroupMenu"
- operation="show">
- <f:param value="#{resourceTreeItem.data.parentResource.id}" name="id"/>
- <f:param value="#{resourceTreeItem.data.resourceType.name}" name="type"/>
- </rich:componentControl>
</a4j:support>
<h:outputText value="#{resourceTreeItem} "
@@ -91,16 +98,8 @@
iconLeaf="/images/icons/Service_#{resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up'}_16.png">
<a4j:support event="oncontextmenu" reRender="resourceMenu" timeout="5000"
disableDefault="true" status="commonStatus" limitToList="true"
- ajaxSingle="true">
+ ajaxSingle="true" oncomplete="#{rich:component('resourceMenu')}.show(event, {})">
<f:param name="contextResourceId" value="#{resourceTreeItem.data.id}"/>
- <rich:componentControl disableDefault="true" event="oncomplete" for="resourceMenu"
- operation="show">
- <f:param value="#{resourceTreeItem.data.name}" name="name"/>
- <f:param value="#{resourceTreeItem.data.id}" name="id"/>
- <f:param value="#{resourceTreeItem.data.resourceType.name}" name="type"/>
- <f:param value="'#{resourceTreeItem.data.resourceType.operationDefinitions}'"
- name="ops"/>
- </rich:componentControl>
</a4j:support>
<h:outputText value="#{resourceTreeItem}"
styleClass="resourceLink" title="Right-click for more options."/>
commit 728a80ed5251c8aac7e0ec4a5008dcc73f1ce268
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Apr 22 11:39:53 2010 +0200
BZ 584116 - check for null context root to prevent NPE
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java
index 0c1cd91..964223f 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/WarDiscoveryHelper.java
@@ -63,7 +63,7 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility;
*/
public class WarDiscoveryHelper {
private static final Log LOG = LogFactory.getLog(WarDiscoveryHelper.class);
-
+
private static final String ROOT_WEBAPP_RT_LOG_FILE_NAME_BASE = "ROOT";
private static final String RT_LOG_FILE_NAME_SUFFIX = "_rt.log";
@@ -140,7 +140,7 @@ public class WarDiscoveryHelper {
key += ",vhost=" + vhost;
Configuration pluginConfigClone;
- pluginConfigClone = discoResDetail.getPluginConfiguration().deepCopy();
+ pluginConfigClone = discoResDetail.getPluginConfiguration().deepCopy();
String resourceName = baseResourceName + " (" + webModuleName + ")";
String resourceDescription = baseResourceDescription + " (" + webModuleName + ")";
@@ -266,7 +266,7 @@ public class WarDiscoveryHelper {
}
public static String getContextPath(String contextRoot) {
- return ((contextRoot.equals(WarComponent.ROOT_WEBAPP_CONTEXT_ROOT)) ? "/" : "/" + contextRoot);
+ return ((contextRoot == null || contextRoot.equals(WarComponent.ROOT_WEBAPP_CONTEXT_ROOT)) ? "/" : "/" + contextRoot);
}
private static void initPluginConfiguration(WarDeploymentInformation deploymentInformation, File rtLogDir,
commit 4ba4d25ddc428d53fa21a37a6e60e67582b9e88a
Merge: f3aca43... ff1fca6...
Author: Filip Drabek <fdrabek(a)dhcp-lab-136.englab.brq.redhat.com>
Date: Thu Apr 22 00:34:36 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit f3aca43b79d01ee27555d9426ec31f7a1631f8db
Author: Filip Drabek <fdrabek(a)dhcp-lab-136.englab.brq.redhat.com>
Date: Thu Apr 22 00:33:20 2010 +0200
BZ 576148 - [apache] Can't add a Virtual Host Option in the "set"
BZ 549985 - Apache: Values could not be saved for directive 'DirectoryIndex'.
BZ 576154 - [apache] IndexOutOfBoundsException while checking for config updates of ApacheIfModuleComponent
BZ 576155 - [apache] NPE during configuration update check in ApacheDirectoryComponent
BZ 576617 - [apache] ServerName not persisted with Virtual host update
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
index 903b370..537ccef 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
@@ -116,6 +116,12 @@ public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualH
private AugeasNode getNode(AugeasNode virtualHost) {
List<AugeasNode> directories = AugeasNodeSearch.getNodeByParentParams(virtualHost, IFMODULE_DIRECTIVE_NAME, position);
+ if (directories.isEmpty())
+ {
+ log.warn("Parent directive of ifmodule was probably deleted in configuration file.");
+ throw new RuntimeException("Parent directive of ifmodule was probably deleted in configuration file.");
+ }
+
return directories.get(0);
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
index 7a86201..8f715ac 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
@@ -105,6 +105,11 @@ public class ApacheIfModuleDirectoryComponent implements ResourceComponent<Apach
private AugeasNode getNode(AugeasNode virtualHost) {
List<AugeasNode> directories = AugeasNodeSearch.getNodeByParentParams(virtualHost, IFMODULE_DIRECTIVE_NAME, position);
+ if (directories.isEmpty())
+ {
+ log.warn("Parent directive of ifmodule was probably deleted in configuration file.");
+ throw new RuntimeException("Parent directive of ifmodule was probably deleted in configuration file.");
+ }
return directories.get(0);
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index 95c2bfc..87beeb9 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -159,6 +159,10 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
if (vhostsGlobInclude != null) {
pluginConfig.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, vhostsGlobInclude));
+ }else
+ {
+ if (serverConfigFile.exists())
+ pluginConfig.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, serverConfigFile.getParent()+File.separator+"*"));
}
discoveredResources.add(createResourceDetails(discoveryContext, pluginConfig, process.getProcessInfo(),
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/mappingImpl/MappingToAugeasParamPerMap.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/mappingImpl/MappingToAugeasParamPerMap.java
index 4d77ae8..a274099 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/mappingImpl/MappingToAugeasParamPerMap.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/mappingImpl/MappingToAugeasParamPerMap.java
@@ -48,7 +48,7 @@ public class MappingToAugeasParamPerMap extends ConfigurationToAugeasApacheBase{
AugeasNode listNode, int seq) throws AugeasRhqException {
String propertyName = propDef.getName();
- PropertyDefinition memberPropDef = propDef.getMemberDefinition();
+ PropertyDefinitionMap memberPropDef = (PropertyDefinitionMap)propDef.getMemberDefinition();
List<AugeasNode> nodes = tree.matchRelative(listNode, propertyName);
@@ -91,9 +91,12 @@ public class MappingToAugeasParamPerMap extends ConfigurationToAugeasApacheBase{
StringBuffer param= new StringBuffer();
for (List<PropertyMap> directive: map){
for (PropertyMap propMap : directive){
- for (Property propVal : propMap.getMap().values()){
- if (!propVal.getName().equals("_index")){
- param.append(" "+((PropertySimple) propVal).getStringValue());
+ for (String propDefMap : memberPropDef.getPropertyDefinitions().keySet())
+ {//for (Property propVal : propMap.getMap().values()){
+ Property propVal = propMap.get(propDefMap);
+ if (propVal!=null)
+ if (!propVal.getName().equals("_index")){
+ param.append(" "+((PropertySimple) propVal).getStringValue());
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/ApacheDirectiveRegExpression.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/ApacheDirectiveRegExpression.java
index 4366d6e..fa7d196 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/ApacheDirectiveRegExpression.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/ApacheDirectiveRegExpression.java
@@ -67,10 +67,10 @@ public class ApacheDirectiveRegExpression {
MAPPING_TYPE.put("IfModules",DirectiveMapping.POSITION_PROPERTY);
}
- private static final String WORD = "\"(?:[^\"\n]|\\\")*\"|'(?:[^'\n]|\\\')*'|[^'\" \t\n]+";
- private static final String WS = "[ \t]*";
- private static final String WS_MAN = "[ \t]+";
- private static final String NUM = "[0-9]+";
+ public static final String WORD = "\"(?:[^\"\n]|\\\")*\"|'(?:[^'\n]|\\\')*'|[^'\" \t\n]+";
+ public static final String WS = "[ \t]*";
+ public static final String WS_MAN = "[ \t]+";
+ public static final String NUM = "[0-9]+";
/**
* This is the map of regular expressions for each individual directive
@@ -86,7 +86,7 @@ public class ApacheDirectiveRegExpression {
+ WORD + ")" + ")?" + WS) });
DIRECTIVE_REGEX.put("ErrorDocument", new Pattern[] { Pattern.compile(WS + "(" + NUM + ")" + WS_MAN + "(" + WORD
+ ")" + WS) });
- DIRECTIVE_REGEX.put("Options", new Pattern[] {Pattern.compile(WS+"([+-]?)([a-zA-Z]+)") });
+ DIRECTIVE_REGEX.put("Options", new Pattern[] {Pattern.compile(WS+"(Add|Remove|Set)"+WS+"([a-zA-Z]+)") });
DIRECTIVE_REGEX.put("Allow", new Pattern[] { Pattern.compile("from"),
Pattern.compile("(?:" + WS_MAN + "(" + WORD + "))") });
DIRECTIVE_REGEX.put("Deny", new Pattern[] { Pattern.compile("from"),
@@ -108,14 +108,14 @@ public class ApacheDirectiveRegExpression {
DIRECTIVEREGEX_TO_AUGEAS.put("Allow", new Pattern[] { Pattern.compile("(?:" + WS_MAN + "(" + WORD + "))") });
DIRECTIVEREGEX_TO_AUGEAS.put("Deny", new Pattern[] { Pattern.compile("(?:" + WS_MAN + "(" + WORD + "))") });
DIRECTIVEREGEX_TO_AUGEAS.put("ServerAlias", new Pattern[] { Pattern.compile(WS_MAN + "(" + WORD + ")") });
- DIRECTIVEREGEX_TO_AUGEAS.put("DirectoryIndex", new Pattern[] { Pattern.compile(WS_MAN+ "(" + WORD + ")" + WS_MAN) });
+ DIRECTIVEREGEX_TO_AUGEAS.put("DirectoryIndex", new Pattern[] { Pattern.compile(WS_MAN+ "(" + WORD + ")") });
DIRECTIVEREGEX_TO_AUGEAS.put("Alias",
new Pattern[] { Pattern.compile(WS_MAN + "(" + WORD + ")" + WS_MAN + "(" + WORD + ")" + WS) });
DIRECTIVEREGEX_TO_AUGEAS.put("CustomLog", new Pattern[] { Pattern.compile(WS_MAN + "(" + WORD + ")" + "(?:" + WS_MAN + "("
+ WORD + ")" + ")?") });
DIRECTIVEREGEX_TO_AUGEAS.put("AllowOverride", new Pattern[] { Pattern
.compile(WS+"(All|None|AuthConfig|FileInfo|Indexes|Limit|Options)") });
- DIRECTIVEREGEX_TO_AUGEAS.put("Listen", new Pattern[] { Pattern.compile(WS_MAN+ "(" + WORD + ")")});
+ DIRECTIVEREGEX_TO_AUGEAS.put("Listen", new Pattern[] { Pattern.compile(WS+ "(" + WORD + ")")});
DIRECTIVEREGEX_TO_AUGEAS.put("NameVirtualHost", new Pattern[] { Pattern.compile(WS+ "(" + WORD +")" + WS) });
DIRECTIVEREGEX_TO_AUGEAS.put("ErrorDocument", new Pattern[] { Pattern.compile(WS_MAN + "(" + NUM + ")" + WS_MAN + "(" + WORD
+ ")") });
@@ -152,6 +152,7 @@ public class ApacheDirectiveRegExpression {
return result;
}
+ value = SpecificParams.prepareForConfiguration(nodeName, value);
//each regex is applied as long as it matches something
Pattern[] patterns = DIRECTIVE_REGEX.get(nodeName);
@@ -191,6 +192,8 @@ public class ApacheDirectiveRegExpression {
int startIndex = 0;
boolean updated =true;
+ params = SpecificParams.prepareForAugeas(name, params);
+
while (updated & startIndex < params.length())
updated = false;
for (Pattern pattern : patterns) {
@@ -205,15 +208,7 @@ public class ApacheDirectiveRegExpression {
startIndex = m.end();
}
}
-
- if (name.equals("Listen"))
- if (nodeParams.size()>1){
- String value = nodeParams.get(0);
- value = value+":"+nodeParams.get(1);
- nodeParams.set(0, value);
- nodeParams.remove(1);
- }
-
+
if (name.equals("Options")){
int i=0;
for (String param : nodeParams){
@@ -241,4 +236,5 @@ public class ApacheDirectiveRegExpression {
return map;
}
+
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/SpecificParams.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/SpecificParams.java
new file mode 100644
index 0000000..9d9dc33
--- /dev/null
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/mapping/SpecificParams.java
@@ -0,0 +1,126 @@
+package org.rhq.plugins.apache.mapping;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Class is used for avoid using of specific parameters which can not be used in augeas resp. in Rhq configuration.
+ * During the transformation from augeas tree to configuration and back we need to replace directive specific parameters
+ * by parameters which are understandable for RHQ configuration.
+ * @author fdrabek
+ *
+ */
+public class SpecificParams {
+
+ /**
+ * Before mapping back to cofiguration file we need to replace all configuration specific parameters
+ * by directive specific parameters.
+ *
+ * @param name Name of the directive.
+ * @param param Parameters of directive.
+ * @return directive prepared for validation without configuration specific parameters.
+ */
+ public static String prepareForAugeas(String name,String value){
+ if (name.equals("Options"))
+ {
+ StringBuilder ret = new StringBuilder();
+ Pattern pattern = Pattern.compile("[ \t]*(Add|Remove|Set)[ \t]*([a-zA-Z]+)");
+ int startIndex = 0;
+ boolean updated = true;
+ while (updated & startIndex < value.length()){
+ updated = false;
+ Matcher m = pattern.matcher(value);
+ while (m.find(startIndex)) {
+ if (m.groupCount() >0)
+ for (int i = 1; i <= m.groupCount(); i++) {
+ String val = m.group(i);
+ if (val.equals("Add"))
+ val = "+";
+ if (val.equals("Remove"))
+ val = "-";
+ if (val.equals("Set"))
+ val = "";
+ ret.append(val+ " ");
+ }
+ updated = true;
+ startIndex = m.end();
+ }
+ }
+ if (ret.length()>0)
+ ret.deleteCharAt(ret.length()-1);
+
+ return ret.toString();
+ }
+
+ if (name.equals("Listen")){
+ int i;
+ StringBuilder val = new StringBuilder(value);
+ while (val.charAt(0) == ' ' | val.charAt(0) == '\t')
+ val.deleteCharAt(0);
+
+ String [] str = val.toString().split("[ \t]+");
+
+ Pattern pat = Pattern.compile("[0-9]+");
+ StringBuilder bld = new StringBuilder();
+ for (i =0;i<str.length;i++){
+ Matcher m = pat.matcher(str[i]);
+ if (m.matches())
+ {if (i==1)
+ str[i] = ":"+str[i];
+ else
+ str[i]=" "+str[i];
+ }else
+ str[i]=" "+str[i];
+ bld.append(str[i]);
+ }
+ return bld.toString();
+ }
+
+ return value;
+
+ }
+
+ /**
+ * Before mapping back to cofiguration file we need to replace all configuration specific parameters
+ * by directive specific parameters.
+ *
+ * @param name Name of the directive.
+ * @param param Parameters of directive.
+ * @return directive prepared for validation without configuration specific parameters.
+ */
+
+ public static StringBuilder prepareForConfiguration(String name,StringBuilder value){
+ if (name.equals("Options"))
+ {
+ StringBuilder ret = new StringBuilder();
+ Pattern pattern = Pattern.compile("[ \t]*([+-]?)([a-zA-Z]+)");
+ int startIndex = 0;
+ boolean updated = true;
+ while (updated & startIndex < value.length()){
+ updated = false;
+ Matcher m = pattern.matcher(value);
+ while (m.find(startIndex)) {
+ if (m.groupCount() >0)
+ for (int i = 1; i <= m.groupCount(); i++) {
+ String val = m.group(i);
+ if (val.equals("+"))
+ val = "Add";
+ if (val.equals("-"))
+ val = "Remove";
+ if (val.equals(""))
+ val = "Set";
+ ret.append(val+ " ");
+ }
+ updated = true;
+ startIndex = m.end();
+ }
+ }
+ if (ret.length()>0)
+ ret.deleteCharAt(ret.length()-1);
+
+ return ret;
+ }
+
+ return value;
+ }
+}
diff --git a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
index 4d49c4a..94ee5d3 100644
--- a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
@@ -72,14 +72,17 @@
'>
<!ENTITY DirectoryIndex '
- <c:simple-property name="DirectoryIndex" required="false" default="index.html">
+ <c:list-property name="DirectoryIndex" required="false">
<c:description>
Sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name.
Note that the documents do not need to be relative to the directory.
</c:description>
- </c:simple-property>
-'>
-
+ <c:map-property name="DirectoryIndex">
+ <c:simple-property name="host"/>
+ <c:simple-property name="_index" required="false" description="Helper property to retain the consistent ordering inside Apache configuration files."/>
+ </c:map-property>
+ </c:list-property>
+'>
<!ENTITY DocumentRoot '
<c:simple-property name="DocumentRoot">
<c:description>
@@ -174,9 +177,9 @@
<c:map-property name="Options">
<c:simple-property name="Mode">
<c:property-options>
- <c:option value="" name="Set"/>
- <c:option value="+" name="Add"/>
- <c:option value="-" name="Remove"/>
+ <c:option value="Set" default="true"/>
+ <c:option value="Add"/>
+ <c:option value="Remove"/>
</c:property-options>
</c:simple-property>
<c:simple-property name="Option">
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/tree/impl/AbstractAugeasTree.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/tree/impl/AbstractAugeasTree.java
index 583d6b6..ba05a59 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/augeas/tree/impl/AbstractAugeasTree.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/tree/impl/AbstractAugeasTree.java
@@ -165,7 +165,7 @@ public abstract class AbstractAugeasTree implements AugeasTree {
public String summarizeAugeasError() {
String nodePrefix = "/augeas/files";
- List<String> str = moduleConfig.getIncludedGlobs();
+ List<String> str = moduleConfig.getConfigFiles();
StringBuilder builder = new StringBuilder();
for (String path : str) {
commit 75f8cc4682d42b7d2a82f8906e244d4818435b22
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 21 17:49:42 2010 -0400
A lot of DB upgrade fixes. Probably not completely right but getting
close. Runs through from 2.3.1 on Ora.
Also, removed GRP abbreviations in content schema because I couldn't stand
it.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index c596786..1a31b70 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -260,15 +260,15 @@
</constraint>
</table>
- <table name="RHQ_REPO_REPO_GRP_MAP">
+ <table name="RHQ_REPO_REPO_GROUP_MAP">
<column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
- <column name="REPO_GRP_ID" type="INTEGER" required="true" references="RHQ_REPO_GROUP"/>
+ <column name="REPO_GROUP_ID" type="INTEGER" required="true" references="RHQ_REPO_GROUP"/>
<column name="CTIME" type="LONG" required="true"/>
- <constraint name="RHQ_REPO_REPO_GRP_MAP_KEY">
+ <constraint name="RHQ_REPO_REPO_GROUP_MAP_KEY">
<primaryKey>
<field ref="REPO_ID"/>
- <field ref="REPO_GRP_ID"/>
+ <field ref="REPO_GROUP_ID"/>
</primaryKey>
</constraint>
</table>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index f812e9a..bf9b21f 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -1483,51 +1483,37 @@
</schemaSpec>
<schemaSpec version="2.60">
+ <schema-createSequence name="RHQ_RAW_CONFIG_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_RAW_CONFIG">
- CREATE TABLE RHQ_RAW_CONFIG (ID INTEGER)
+ CREATE TABLE RHQ_RAW_CONFIG (ID INTEGER PRIMARY KEY)
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_RAW_CONFIG" column="ID" columnType="INTEGER" nullable="FALSE" />
- <schema-createSequence name="RHQ_RAW_CONFIG_ID_SEQ" initial="10001" />
- <schema-directSQL>
- <statement desc="Creating primary key for RHQ_RAW_CONFIG">
- ALTER TABLE RHQ_RAW_CONFIG ADD PRIMARY KEY (ID)
- </statement>
- </schema-directSQL>
-
- <schema-addColumn table="RHQ_RAW_CONFIG" column="CONFIG_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_RAW_CONFIG" column="CONFIG_ID" columnType="INTEGER" nullable="false" />
-
- <schema-addColumn table="RHQ_RAW_CONFIG" column="PATH" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_RAW_CONFIG" column="PATH" columnType="VARCHAR2" precision="512" />
-
- <schema-addColumn table="RHQ_RAW_CONFIG" column="CONTENTS" columnType="BLOB" />
- <schema-alterColumn table="RHQ_RAW_CONFIG" column="CONTENTS" columnType="CLOB" nullable="false" />
-
- <schema-addColumn table="RHQ_RAW_CONFIG" column="SHA256" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_RAW_CONFIG" column="SHA256" columnType="VARCHAR2" precision="64" nullable="false" />
-
- <schema-addColumn table="RHQ_RAW_CONFIG" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_RAW_CONFIG" column="CTIME" columnType="LONG" nullable="false" />
-
- <schema-addColumn table="RHQ_RAW_CONFIG" column="MTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_RAW_CONFIG" column="MTIME" columnType="LONG" nullable="false" />
+ <schema-addColumn table="RHQ_RAW_CONFIG" column="CONFIG_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_RAW_CONFIG" column="CONFIG_ID" nullable="false" />
+ <schema-addColumn table="RHQ_RAW_CONFIG" column="PATH" columnType="VARCHAR2" precision="512"/>
+ <schema-addColumn table="RHQ_RAW_CONFIG" column="CONTENTS" columnType="CLOB" />
+ <schema-alterColumn table="RHQ_RAW_CONFIG" column="CONTENTS" nullable="false" />
+ <schema-addColumn table="RHQ_RAW_CONFIG" column="SHA256" columnType="VARCHAR2" precision="64"/>
+ <schema-alterColumn table="RHQ_RAW_CONFIG" column="SHA256" nullable="false" />
+ <schema-addColumn table="RHQ_RAW_CONFIG" column="CTIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_RAW_CONFIG" column="CTIME" nullable="false" />
+ <schema-addColumn table="RHQ_RAW_CONFIG" column="MTIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_RAW_CONFIG" column="MTIME" nullable="false" />
<schema-directSQL>
<statement desc="Creating RHQ_RAW_CONFIG foreign key relation to RHQ_CONFIG">
ALTER TABLE RHQ_RAW_CONFIG
- ADD CONSTRAINT RHQ_RAW_CONFIG_CONFIG_ID_FK
+ ADD CONSTRAINT RHQ_RC_CONFIG_ID_FK
FOREIGN KEY (CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
</schema-directSQL>
-
</schemaSpec>
<schemaSpec version="2.60.1">
- <schema-addColumn table="RHQ_PLUGIN" column="AMPS_VERSION" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_PLUGIN" column="AMPS_VERSION" columnType="VARCHAR2" precision="16" />
+ <schema-addColumn table="RHQ_PLUGIN" column="AMPS_VERSION" columnType="VARCHAR2" precision="16" />
</schemaSpec>
<schemaSpec version="2.60.2">
@@ -1668,9 +1654,9 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_GROUP_TYPE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_GROUP_TYPE" column="NAME" precision="200" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_REPO_GROUP_TYPE" column="NAME" precision="200" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_REPO_GROUP_TYPE" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_REPO_GROUP_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_REPO_GROUP_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
<schema-directSQL>
<statement>
INSERT INTO RHQ_REPO_GROUP_TYPE ( ID, NAME )
@@ -1686,70 +1672,51 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_GROUP" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_GROUP" column="NAME" precision="200" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_REPO_GROUP" column="NAME" precision="200" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_REPO_GROUP" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_REPO_GROUP" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_REPO_GROUP" column="REPO_GROUP_TYPE_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_REPO_GROUP" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_REPO_GROUP" column="REPO_GROUP_TYPE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_GROUP" column="REPO_GROUP_TYPE_ID" nullable="false" />
<schema-directSQL>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_GROUP
- ADD CONSTRAINT RHQ_REPO_GROUP_REPO_GROUP_TYPE_ID_FKEY
+ ADD CONSTRAINT RHQ_RG_REPO_GROUP_TYPE_ID_FK
FOREIGN KEY ( REPO_GROUP_TYPE_ID )
REFERENCES RHQ_REPO_GROUP_TYPE ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_GROUP
- ADD FOREIGN KEY ( REPO_GROUP_TYPE_ID )
- REFERENCES RHQ_REPO_GROUP_TYPE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- CREATE UNIQUE INDEX RHQ_REPO_GROUP_IDX
- ON RHQ_REPO_GROUP ( NAME, REPO_GROUP_TYPE_ID )
- </statement>
- <statement targetDBVendor="oracle">
+ <statement>
CREATE UNIQUE INDEX RHQ_REPO_GROUP_IDX
ON RHQ_REPO_GROUP ( NAME, REPO_GROUP_TYPE_ID )
</statement>
</schema-directSQL>
- <!-- RHQ_REPO_REPO_GRP_MAP -->
+ <!-- RHQ_REPO_REPO_GROUP_MAP -->
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_REPO_REPO_GRP_MAP ( REPO_ID INTEGER )
+ CREATE TABLE RHQ_REPO_REPO_GROUP_MAP ( REPO_ID INTEGER )
</statement>
</schema-directSQL>
- <schema-alterColumn table="RHQ_REPO_REPO_GRP_MAP" column="REPO_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_REPO_GRP_MAP" column="REPO_GRP_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_REPO_REPO_GRP_MAP" column="REPO_GRP_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_REPO_GRP_MAP" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_REPO_REPO_GRP_MAP" column="CTIME" nullable="false" />
+ <schema-alterColumn table="RHQ_REPO_REPO_GROUP_MAP" column="REPO_ID" nullable="false" />
+ <schema-addColumn table="RHQ_REPO_REPO_GROUP_MAP" column="REPO_GROUP_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_REPO_REPO_GROUP_MAP" column="REPO_GROUP_ID" nullable="false" />
+ <schema-addColumn table="RHQ_REPO_REPO_GROUP_MAP" column="CTIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_REPO_REPO_GROUP_MAP" column="CTIME" nullable="false" />
<schema-directSQL>
<statement>
- ALTER TABLE RHQ_REPO_REPO_GRP_MAP
- ADD CONSTRAINT RHQ_REPO_REPO_GRP_MAP_KEY
- PRIMARY KEY ( REPO_ID, REPO_GRP_ID )
+ ALTER TABLE RHQ_REPO_REPO_GROUP_MAP
+ ADD CONSTRAINT RHQ_REPO_REPO_GROUP_MAP_KEY
+ PRIMARY KEY ( REPO_ID, REPO_GROUP_ID )
</statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_REPO_REPO_GRP_MAP
- ADD CONSTRAINT RHQ_REPO_REPO_GRP_MAP_REPO_ID_FKEY
+ <statement>
+ ALTER TABLE RHQ_REPO_REPO_GROUP_MAP
+ ADD CONSTRAINT RHQ_RRGM_REPO_ID_FK
FOREIGN KEY ( REPO_ID )
REFERENCES RHQ_REPO ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_REPO_GRP_MAP
- ADD FOREIGN KEY ( REPO_ID )
- REFERENCES RHQ_REPO ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_REPO_REPO_GRP_MAP
- ADD CONSTRAINT RHQ_REPO_REPO_GRP_MAP_REPO_GRP_ID_FKEY
- FOREIGN KEY ( REPO_GRP_ID )
- REFERENCES RHQ_REPO_GROUP ( ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_REPO_GRP_MAP
- ADD FOREIGN KEY ( REPO_GRP_ID )
+ <statement>
+ ALTER TABLE RHQ_REPO_REPO_GROUP_MAP
+ ADD CONSTRAINT RHQ_RRGM_REPO_GROUP_ID_FK
+ FOREIGN KEY ( REPO_GROUP_ID )
REFERENCES RHQ_REPO_GROUP ( ID )
</statement>
</schema-directSQL>
@@ -1762,9 +1729,9 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_RELATION_TYPE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_RELATION_TYPE" column="NAME" precision="200" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_REPO_RELATION_TYPE" column="NAME" precision="200" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_REPO_RELATION_TYPE" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_REPO_RELATION_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_REPO_RELATION_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
<schema-directSQL>
<statement>
INSERT INTO
@@ -1786,33 +1753,23 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_RELATION" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_RELATION" column="RELATED_REPO_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_REPO_RELATION" column="RELATED_REPO_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_RELATION" column="RELATED_REPO_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_RELATION" column="REPO_RELATION_TYPE_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_REPO_RELATION" column="REPO_RELATION_TYPE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_RELATION" column="REPO_RELATION_TYPE_ID" nullable="false" />
<schema-directSQL>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_RELATION
- ADD CONSTRAINT RHQ_REPO_RELATION_RELATED_REPO_ID_FKEY
+ ADD CONSTRAINT RHQ_RR_RELATED_REPO_ID_FK
FOREIGN KEY ( RELATED_REPO_ID )
REFERENCES RHQ_REPO ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_RELATION
- ADD FOREIGN KEY ( RELATED_REPO_ID )
- REFERENCES RHQ_REPO ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_RELATION
- ADD CONSTRAINT RHQ_REPO_RELATION_REPO_RELATION_TYPE_ID_FKEY
+ ADD CONSTRAINT RHQ_RR_R_RELATION_TYPE_ID_FK
FOREIGN KEY ( REPO_RELATION_TYPE_ID )
REFERENCES RHQ_REPO_RELATION_TYPE ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_RELATION
- ADD FOREIGN KEY ( REPO_RELATION_TYPE_ID )
- REFERENCES RHQ_REPO_RELATION_TYPE ( ID )
- </statement>
</schema-directSQL>
<!-- RHQ_REPO_REPO_RELATION_MAP -->
@@ -1822,9 +1779,9 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_REPO_RELATION_MAP" column="REPO_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_REPO_RELATION_MAP" column="REPO_RELATION_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_REPO_REPO_RELATION_MAP" column="REPO_RELATION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_REPO_RELATION_MAP" column="REPO_RELATION_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_REPO_RELATION_MAP" column="CTIME" columnType="LONG" />
+ <schema-addColumn table="RHQ_REPO_REPO_RELATION_MAP" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_REPO_REPO_RELATION_MAP" column="CTIME" nullable="false" />
<schema-directSQL>
<statement>
@@ -1832,41 +1789,32 @@
ADD CONSTRAINT RHQ_REPO_REPO_RELATION_MAP_KEY
PRIMARY KEY ( REPO_ID, REPO_RELATION_ID )
</statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_REPO_RELATION_MAP
- ADD CONSTRAINT RHQ_REPO_REPO_RELATION_MAP_REPO_ID_FKEY
+ ADD CONSTRAINT RHQ_RRRM_REPO_ID_FK
FOREIGN KEY ( REPO_ID )
REFERENCES RHQ_REPO ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_REPO_RELATION_MAP
- ADD FOREIGN KEY ( REPO_ID )
- REFERENCES RHQ_REPO ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_REPO_RELATION_MAP
- ADD CONSTRAINT RHQ_REPO_REPO_RELATION_MAP_REPO_RELATION_ID_FKEY
+ ADD CONSTRAINT RHQ_RRRM_REPO_RELATION_ID_FK
FOREIGN KEY ( REPO_RELATION_ID )
REFERENCES RHQ_REPO_RELATION ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_REPO_RELATION_MAP
- ADD FOREIGN KEY ( REPO_RELATION_ID )
- REFERENCES RHQ_REPO_RELATION ( ID )
- </statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.61">
+ <schema-createSequence name="RHQ_DISTRIBUTION_TYPE_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement>
CREATE TABLE RHQ_DISTRIBUTION_TYPE ( ID INTEGER PRIMARY KEY )
- </statement>
+ </statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_DISTRIBUTION_TYPE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="NAME" precision="200" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="NAME" precision="200" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_DISTRIBUTION_TYPE" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
<schema-directSQL>
<statement>
INSERT INTO
@@ -1880,18 +1828,20 @@
</statement>
</schema-directSQL>
- <schema-directSQL>
+ <schema-createSequence name="RHQ_RHQ_DISTRIBUTION_ID_SEQ" initial="10001" />
+ <schema-directSQL>
<statement desc="Creating table RHQ_DISTRIBUTION">
CREATE TABLE RHQ_DISTRIBUTION ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
- <schema-addColumn table="RHQ_DISTRIBUTION" column="DISTRIBUTION_TYPE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_DISTRIBUTION" column="ID" nullable="false" />
+ <schema-addColumn table="RHQ_DISTRIBUTION" column="DISTRIBUTION_TYPE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_DISTRIBUTION" column="DISTRIBUTION_TYPE_ID" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION" column="LABEL" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_DISTRIBUTION" column="LABEL" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_DISTRIBUTION" column="LABEL" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION" column="BASE_PATH" precision="256" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_DISTRIBUTION" column="BASE_PATH" precision="256" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_DISTRIBUTION" column="BASE_PATH" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-addColumn table="RHQ_DISTRIBUTION" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_DISTRIBUTION" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
<statement>
@@ -1899,17 +1849,12 @@
</statement>
</schema-directSQL>
<schema-directSQL>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_DISTRIBUTION
- ADD CONSTRAINT RHQ_DIST_TYPE_FKEY
+ ADD CONSTRAINT RHQ_D_DISTRIBUTION_TYPE_ID_FK
FOREIGN KEY ( DISTRIBUTION_TYPE_ID )
REFERENCES RHQ_DISTRIBUTION_TYPE ( ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_DISTRIBUTION
- ADD FOREIGN KEY ( DISTRIBUTION_TYPE_ID )
- REFERENCES RHQ_DISTRIBUTION_TYPE ( ID )
- </statement>
+ </statement>
</schema-directSQL>
<schema-directSQL>
@@ -1918,55 +1863,41 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_DISTRIBUTION" column="REPO_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_DISTRIBUTION" column="DISTRIBUTION_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_REPO_DISTRIBUTION" column="DISTRIBUTION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_DISTRIBUTION" column="DISTRIBUTION_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_DISTRIBUTION" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-addColumn table="RHQ_REPO_DISTRIBUTION" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_REPO_DISTRIBUTION" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_REPO_DISTRIBUTION ADD CONSTRAINT RHQ_REPO_DIST_MAP_KEY
PRIMARY KEY ( REPO_ID, DISTRIBUTION_ID )
</statement>
-
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_DISTRIBUTION
- ADD CONSTRAINT RHQ_REPO_DIST_REPO_ID_FKEY
+ ADD CONSTRAINT RHQ_RD_REPO_ID_FK
FOREIGN KEY ( REPO_ID )
REFERENCES RHQ_REPO ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_DISTRIBUTION
- ADD FOREIGN KEY ( REPO_ID )
- REFERENCES RHQ_REPO ( ID )
- </statement>
-
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_DISTRIBUTION
- ADD CONSTRAINT RHQ_REPO_DIST_DIST_ID_FKEY
+ ADD CONSTRAINT RHQ_RD_DISTRIBUTION_ID_FK
FOREIGN KEY ( DISTRIBUTION_ID )
REFERENCES RHQ_DISTRIBUTION ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_DISTRIBUTION
- ADD FOREIGN KEY ( DISTRIBUTION_ID )
- REFERENCES RHQ_DISTRIBUTION ( ID )
- </statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.62">
<schema-alterColumn table="RHQ_CONFIG_PROP_DEF" column="NAME" columnType="VARCHAR2" precision="255" />
-
<schema-alterColumn table="RHQ_CONFIG_PROPERTY" column="NAME" columnType="VARCHAR2" precision="255" />
</schemaSpec>
<schemaSpec version="2.62.2">
- <schema-addColumn table="RHQ_CONFIG_DEF" column="CONFIG_FORMAT" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_CONFIG_DEF" column="CONFIG_FORMAT" precision="32" nullable="true" />
+ <schema-addColumn table="RHQ_CONFIG_DEF" column="CONFIG_FORMAT" columnType="VARCHAR2" precision="32" />
</schemaSpec>
<schemaSpec version="2.63">
- <schema-addColumn table="RHQ_REPO" column="IS_CANDIDATE" columnType="BOOLEAN" />
+ <schema-addColumn table="RHQ_REPO" column="IS_CANDIDATE" columnType="BOOLEAN" />
<schema-directSQL>
<statement targetDBVendor="postgresql">
@@ -1976,8 +1907,7 @@
UPDATE RHQ_REPO SET IS_CANDIDATE = 0
</statement>
</schema-directSQL>
-
- <schema-alterColumn table="RHQ_REPO" column="IS_CANDIDATE" nullable="false" />
+ <schema-alterColumn table="RHQ_REPO" column="IS_CANDIDATE" nullable="false" />
</schemaSpec>
<!-- Generic tagging support -->
@@ -1989,47 +1919,38 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_TAG" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_TAG" column="NAME" precision="200" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_TAG" column="NAME" precision="200" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_TAG" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_TAG" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_TAG" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
</schemaSpec>
<!-- Distribution Files -->
<schemaSpec version="2.65">
+ <schema-createSequence name="RHQ_DISTRIBUTION_FILE_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID INTEGER )
+ CREATE TABLE RHQ_DISTRIBUTION_FILE (ID INTEGER PRIMARY KEY)
</statement>
</schema-directSQL>
+ <schema-alterColumn table="RHQ_DISTRIBUTION_FILE" column="ID" nullable="false" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="DISTRIBUTION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_DISTRIBUTION_FILE" column="DISTRIBUTION_ID" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="RELATIVE_FILENAME" precision="256" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="RELATIVE_FILENAME" precision="256" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_DISTRIBUTION_FILE" column="RELATIVE_FILENAME" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="MD5SUM" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="MD5SUM" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_DISTRIBUTION_FILE" column="MD5SUM" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_DISTRIBUTION_FILE" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
- <statement targetDBVendor="postgresql">
- CREATE UNIQUE INDEX RHQ_DISTRIBUTION_FILE_IDX
- ON RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID, RELATIVE_FILENAME )
- </statement>
- <statement targetDBVendor="oracle">
- CREATE UNIQUE INDEX RHQ_DISTRIBUTION_FILE_IDX
- ON RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID, RELATIVE_FILENAME )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement targetDBVendor="oracle">
+ <statement>
ALTER TABLE RHQ_DISTRIBUTION_FILE
- ADD CONSTRAINT RHQ_DIST_FILE_FKEY
- FOREIGN KEY ( DISTRIBUTION_ID)
+ ADD CONSTRAINT RHQ_DF_DISTRIBUTION_ID_FK
+ FOREIGN KEY (DISTRIBUTION_ID)
REFERENCES RHQ_DISTRIBUTION ( ID )
</statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_DISTRIBUTION_FILE
- ADD CONSTRAINT RHQ_DIST_FILE_FKEY
- FOREIGN KEY ( DISTRIBUTION_ID)
- REFERENCES RHQ_DISTRIBUTION ( ID )
+ <statement>
+ CREATE UNIQUE INDEX RHQ_DISTRIBUTION_FILE_IDX
+ ON RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID, RELATIVE_FILENAME )
</statement>
</schema-directSQL>
</schemaSpec>
@@ -2042,7 +1963,7 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_TAG_MAP" column="REPO_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_TAG_MAP" column="TAG_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_REPO_TAG_MAP" column="TAG_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_TAG_MAP" column="TAG_ID" nullable="false" />
<schema-directSQL>
<statement>
@@ -2050,41 +1971,18 @@
ADD CONSTRAINT RHQ_REPO_TAG_MAP_KEY
PRIMARY KEY ( REPO_ID, TAG_ID )
</statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_TAG_MAP
- ADD CONSTRAINT RHQ_REPO_TAG_MAP_REPO_ID_FKEY
+ ADD CONSTRAINT RHQ_RTM_REPO_ID_FK
FOREIGN KEY ( REPO_ID )
REFERENCES RHQ_REPO ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_TAG_MAP
- ADD FOREIGN KEY ( REPO_ID )
- REFERENCES RHQ_REPO ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_TAG_MAP
- ADD CONSTRAINT RHQ_REPO_TAG_MAP_TAG_ID_FKEY
+ ADD CONSTRAINT RHQ_RTM_TAG_ID_FK
FOREIGN KEY ( TAG_ID )
REFERENCES RHQ_TAG ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_TAG_MAP
- ADD FOREIGN KEY ( TAG_ID )
- REFERENCES RHQ_TAG ( ID )
- </statement>
- </schema-directSQL>
- </schemaSpec>
-
- <schemaSpec version="2.68">
- <schema-createSequence name="RHQ_DISTRIBUTION_FILE_ID_SEQ" initial="10001" />
-
- <schema-addColumn table="RHQ_DISTRIBUTION_FILE" column="ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_DISTRIBUTION_FILE" column="ID" nullable="false" />
-
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_DISTRIBUTION_FILE ALTER COLUMN ID SET DEFAULT NEXTVAL('RHQ_DISTRIBUTION_FILE_ID_SEQ')
- </statement>
</schema-directSQL>
</schemaSpec>
@@ -2104,7 +2002,7 @@
<schema-directSQL>
<statement desc="Creating RHQ_PLUGIN foreign key relation to RHQ_CONFIG for plugin config">
ALTER TABLE RHQ_PLUGIN
- ADD CONSTRAINT RHQ_PLUGIN_P_CFG_ID_FKEY
+ ADD CONSTRAINT RHQ_P_PLUGIN_CONFIG_ID_FK
FOREIGN KEY (PLUGIN_CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
@@ -2115,7 +2013,7 @@
<schema-directSQL>
<statement desc="Creating RHQ_PLUGIN foreign key relation to RHQ_CONFIG for scheduled jobs">
ALTER TABLE RHQ_PLUGIN
- ADD CONSTRAINT RHQ_PLUGIN_JOBS_CFG_ID_FKEY
+ ADD CONSTRAINT RHQ_P_JOBS_CONFIG_ID_FK
FOREIGN KEY (JOBS_CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
@@ -2160,48 +2058,36 @@
<schemaSpec version="2.70">
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
+ <!-- TODO: this needs to change to ack_subject_name -->
<schema-addColumn table="RHQ_ALERT" column="ACK_BY_ID" columnType="INTEGER" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ALERT
- ADD CONSTRAINT RHQ_ALERT_SUBJECT_ID_FKEY
- FOREIGN KEY (ACK_BY_ID)
- REFERENCES RHQ_SUBJECT(ID)
- </statement>
- </schema-directSQL>
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_SENDER_NAME" columnType="VARCHAR2" />
+
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_SENDER_NAME" columnType="VARCHAR2" precision="100"/>
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="ALERT_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_ALERT_CONFIG_ID_FKEY
+ ADD CONSTRAINT RHQ_AN_ALERT_CONFIG_ID_FK
FOREIGN KEY (ALERT_CONFIG_ID)
- REFERENCES RHQ_CONFIG(ID)
+ REFERENCES RHQ_CONFIG (ID)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.70.1">
+ <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER )
- </statement>
- <statement>
- ALTER TABLE RHQ_ALERT_NOTIF_TEMPL
- ADD CONSTRAINT RHQ_ALERT_NOTIF_TEMPL_KEY
- PRIMARY KEY ( ID )
+ CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="ID" nullable="false" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" nullable="false" />
-
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" columnType="LONG" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" nullable="false" />
-
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" precision="100" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" precision="100" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" nullable="false" />
-
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" precision="250" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" precision="250" columnType="VARCHAR2" />
</schemaSpec>
<!-- RHQ Advisory Representation -->
@@ -2214,23 +2100,23 @@
</schema-directSQL>
<schema-alterColumn table="RHQ_ADVISORY" column="ID" nullable="false" columnType="INTEGER" />
- <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_REL" precision="64" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_NAME" precision="64" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_ADVISORY" column="DESCRIPTION" precision="4000" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_ADVISORY" column="SYNOPSIS" precision="4000" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_REL" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_NAME" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="DESCRIPTION" precision="4000" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="SYNOPSIS" precision="4000" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY" column="SYNOPSIS" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY" column="TOPIC" precision="4000" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_ADVISORY" column="SOLUTION" precision="4000" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_ADVISORY" column="SEVERITY" precision="64" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_ADVISORY" column="ISSUE_DATE" columnType="LONG" />
- <schema-addColumn table="RHQ_ADVISORY" column="UPDATE_DATE" columnType="LONG" />
- <schema-addColumn table="RHQ_ADVISORY" column="CTIME" columnType="LONG" />
+ <schema-addColumn table="RHQ_ADVISORY" column="TOPIC" precision="4000" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="SOLUTION" precision="4000" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="SEVERITY" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="ISSUE_DATE" columnType="LONG" />
+ <schema-addColumn table="RHQ_ADVISORY" column="UPDATE_DATE" columnType="LONG" />
+ <schema-addColumn table="RHQ_ADVISORY" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY" column="CTIME" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-addColumn table="RHQ_ADVISORY" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
@@ -2252,11 +2138,11 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="ADVISORY_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="ADVISORY_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="PACKAGE_VERSION_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
<statement>
@@ -2264,13 +2150,13 @@
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_PACKAGE
- ADD CONSTRAINT RHQ_ADVISORY_FKEY
+ ADD CONSTRAINT RHQ_AP_ADVISORY_ID_FKEY
FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_PACKAGE
- ADD CONSTRAINT RHQ_PACKAGE_VERSION_FKEY
+ ADD CONSTRAINT RHQ_AP_PACKAGE_VERSION_ID_FK
FOREIGN KEY ( PACKAGE_VERSION_ID )
REFERENCES RHQ_PACKAGE_VERSION ( ID )
</statement>
@@ -2283,7 +2169,7 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_CVE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_CVE" column="NAME" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_CVE" column="NAME" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_CVE" column="NAME" nullable="false" />
<schema-directSQL>
@@ -2292,11 +2178,11 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_CVE" column="ADVISORY_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ADVISORY_CVE" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="ADVISORY_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_CVE" column="CVE_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ADVISORY_CVE" column="CVE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="CVE_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_CVE" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-addColumn table="RHQ_ADVISORY_CVE" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
<statement>
@@ -2304,13 +2190,13 @@
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_CVE
- ADD CONSTRAINT RHQ_ADVISORY_FKEY
+ ADD CONSTRAINT RHQ_ACVE_ADVISORY_ID_FK
FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_CVE
- ADD CONSTRAINT RHQ_CVE_FKEY
+ ADD CONSTRAINT RHQ_ACVE_CVE_ID_FK
FOREIGN KEY ( CVE_ID )
REFERENCES RHQ_CVE ( ID )
</statement>
@@ -2324,11 +2210,11 @@
</schema-directSQL>
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="ADVISORY_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="ADVISORY_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="BUG_ID" PRECISION="256" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="BUG_ID" PRECISION="256" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="BUG_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
<statement>
@@ -2336,7 +2222,7 @@
</statement>
<statement>
ALTER TABLE RHQ_ADVISORY_BUGLIST
- ADD CONSTRAINT RHQ_ADVISORY_FKEY
+ ADD CONSTRAINT RHQ_AB_ADVISORY_ID_FK
FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
@@ -2348,9 +2234,9 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="REPO_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_ADVISORY" column="ADVISORY_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_REPO_ADVISORY" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="ADVISORY_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_ADVISORY" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-addColumn table="RHQ_REPO_ADVISORY" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
<statement>
@@ -2360,13 +2246,13 @@
</statement>
<statement>
ALTER TABLE RHQ_REPO_ADVISORY
- ADD CONSTRAINT RHQ_REPO_FKEY
+ ADD CONSTRAINT RHQ_RA_REPO_ID_FK
FOREIGN KEY ( REPO_ID )
REFERENCES RHQ_REPO ( ID )
</statement>
<statement>
ALTER TABLE RHQ_REPO_ADVISORY
- ADD CONSTRAINT RHQ_ADVISORY_FKEY
+ ADD CONSTRAINT RHQ_RA_ADVISORY_ID_FK
FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
@@ -2394,7 +2280,7 @@
<schema-directSQL>
<statement desc="Creating RHQ_REPO_SYNC foreign key relation to RHQ_REPO for scheduled jobs">
ALTER TABLE RHQ_REPO_SYNC
- ADD CONSTRAINT RHQ_REPO_SYNC_REPO_ID_FKEY
+ ADD CONSTRAINT RHQ_RS_REPO_ID_FKEY
FOREIGN KEY (REPO_ID)
REFERENCES RHQ_REPO (ID)
</statement>
@@ -2415,26 +2301,21 @@
<schema-directSQL>
<statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_NOTIF_TEMPL_ID_FKEY
+ ADD CONSTRAINT RHQ_CPD_NOTIF_TEMPLATE_ID_FK
FOREIGN KEY (NOTIF_TEMPLATE_ID)
REFERENCES RHQ_ALERT_NOTIF_TEMPL(ID)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.77.1">
- <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
- </schemaSpec>
- <schemaSpec version="2.77.2">
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address" />
- </schemaSpec>
- <schemaSpec version="2.77.3">
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="role_id" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
</schemaSpec>
- <schemaSpec version="2.77.4">
+ <schemaSpec version="2.77.2">
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
@@ -2445,10 +2326,10 @@
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
</schemaSpec>
- <schemaSpec version="2.77.5">
+ <schemaSpec version="2.77.3">
<schema-directSQL>
<statement>
- DROP INDEX IF EXISTS RHQ_ALERT_IDX_ALERT
+ DROP INDEX RHQ_ALERT_IDX_ALERT
</statement>
<statement>
CREATE INDEX RHQ_ALERT_IDX_ALERT ON RHQ_ALERT_NOTIF_LOG (alert_id)
@@ -2471,7 +2352,7 @@
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_TYPE foreign key relation to RHQ_RESOURCE_TYPE">
ALTER TABLE RHQ_BUNDLE_TYPE
- ADD CONSTRAINT RHQ_RESOURCE_TYPE_ID_FK
+ ADD CONSTRAINT RHQ_BT_RESOURCE_TYPE_ID_FK
FOREIGN KEY (RESOURCE_TYPE_ID)
REFERENCES RHQ_RESOURCE_TYPE (ID)
</statement>
@@ -2500,19 +2381,19 @@
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_BUNDLE_TYPE">
ALTER TABLE RHQ_BUNDLE
- ADD CONSTRAINT RHQ_BUNDLE_TYPE_ID_FK
+ ADD CONSTRAINT RHQ_B_BUNDLE_TYPE_ID_FK
FOREIGN KEY (BUNDLE_TYPE_ID)
REFERENCES RHQ_BUNDLE_TYPE (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_REPO">
ALTER TABLE RHQ_BUNDLE
- ADD CONSTRAINT RHQ_REPO_ID_FK
+ ADD CONSTRAINT RHQ_B_REPO_ID_FK
FOREIGN KEY (REPO_ID)
REFERENCES RHQ_REPO (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_PACKAGE_TYPE">
ALTER TABLE RHQ_BUNDLE
- ADD CONSTRAINT RHQ_PACKAGE_TYPE_ID_FK
+ ADD CONSTRAINT RHQ_B_PACKAGE_TYPE_ID_FK
FOREIGN KEY (PACKAGE_TYPE_ID)
REFERENCES RHQ_PACKAGE_TYPE (ID)
</statement>
@@ -2544,13 +2425,13 @@
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_BUNDLE">
ALTER TABLE RHQ_BUNDLE_VERSION
- ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ ADD CONSTRAINT RHQ_BV_BUNDLE_ID_FK
FOREIGN KEY (BUNDLE_ID)
REFERENCES RHQ_BUNDLE (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_CONFIG_DEF">
ALTER TABLE RHQ_BUNDLE_VERSION
- ADD CONSTRAINT RHQ_CONFIG_DEF_ID_FK
+ ADD CONSTRAINT RHQ_BV_CONFIG_DEF_ID_FK
FOREIGN KEY (CONFIG_DEF_ID)
REFERENCES RHQ_CONFIG_DEF (ID)
</statement>
@@ -2574,13 +2455,13 @@
</statement>
<statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_BUNDLE_VERSION">
ALTER TABLE RHQ_BUNDLE_VERSION_REPO
- ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ ADD CONSTRAINT RHQ_BVR_BUNDLE_VERSION_ID_FK
FOREIGN KEY (BUNDLE_VERSION_ID)
REFERENCES RHQ_BUNDLE_VERSION (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_REPO">
ALTER TABLE RHQ_BUNDLE_VERSION_REPO
- ADD CONSTRAINT RHQ_REPO_ID_FK
+ ADD CONSTRAINT RHQ_BVR_REPO_ID_FK
FOREIGN KEY (REPO_ID)
REFERENCES RHQ_REPO (ID)
</statement>
@@ -2602,13 +2483,13 @@
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_BUNDLE_VERSION">
ALTER TABLE RHQ_BUNDLE_FILE
- ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ ADD CONSTRAINT RHQ_BF_BUNDLE_VERSION_ID_FK
FOREIGN KEY (BUNDLE_VERSION_ID)
REFERENCES RHQ_BUNDLE_VERSION (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE_VERSION">
ALTER TABLE RHQ_BUNDLE_FILE
- ADD CONSTRAINT RHQ_PACKAGE_VERSION_ID_FK
+ ADD CONSTRAINT RHQ_BF_PACKAGE_VERSION_ID_FK
FOREIGN KEY (PACKAGE_VERSION_ID)
REFERENCES RHQ_PACKAGE_VERSION (ID)
</statement>
@@ -2638,13 +2519,13 @@
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_DEPLOY foreign key relation to RHQ_CONFIG">
ALTER TABLE RHQ_BUNDLE_DEPLOY
- ADD CONSTRAINT RHQ_CONFIG_ID_FK
+ ADD CONSTRAINT RHQ_BD_CONFIG_ID_FK
FOREIGN KEY (CONFIG_ID)
REFERENCES RHQ_CONFIG (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_DEPLOY foreign key relation to RHQ_BUNDLE_VERSION">
ALTER TABLE RHQ_BUNDLE_DEPLOY
- ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ ADD CONSTRAINT RHQ_BD_BUNDLE_VERSION_ID_FK
FOREIGN KEY (BUNDLE_VERSION_ID)
REFERENCES RHQ_BUNDLE_VERSION (ID)
</statement>
@@ -2664,8 +2545,8 @@
<schema-alterColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="GROUP_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="GROUP_ID" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="BUNDLE_DEPLOY_DEF_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="BUNDLE_DEPLOY_DEF_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="BUNDLE_DEPLOY_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="BUNDLE_DEPLOY_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="STATUS" columnType="VARCHAR2" precision="16" />
<schema-alterColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="STATUS" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="ERROR_MESSAGE" columnType="LONGVARCHAR" />
@@ -2678,14 +2559,14 @@
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_GROUP_DEPLOY foreign key relation to RHQ_RESOURCE_GROUP">
ALTER TABLE RHQ_BUNDLE_GROUP_DEPLOY
- ADD CONSTRAINT RHQ_RESOURCE_GROUP_ID_FK
+ ADD CONSTRAINT RHQ_BGD_RESOURCE_GROUP_ID_FK
FOREIGN KEY (GROUP_ID)
REFERENCES RHQ_RESOURCE_GROUP (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_GROUP_DEPLOY foreign key relation to RHQ_BUNDLE_DEPLOY">
ALTER TABLE RHQ_BUNDLE_GROUP_DEPLOY
- ADD CONSTRAINT RHQ_BUNDLE_DEPLOY_ID_FK
- FOREIGN KEY (BUNDLE_DEPLOY_DEF_ID)
+ ADD CONSTRAINT RHQ_BGD_BUNDLE_DEPLOY_ID_FK
+ FOREIGN KEY (BUNDLE_DEPLOY_ID)
REFERENCES RHQ_BUNDLE_DEPLOY (ID)
</statement>
</schema-directSQL>
@@ -2713,25 +2594,25 @@
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_RES_DEPLOY foreign key relation to BUNDLE_DEPLOY">
ALTER TABLE RHQ_BUNDLE_RES_DEPLOY
- ADD CONSTRAINT RHQ_BUNDLE_DEPLOY_ID_FK
+ ADD CONSTRAINT RHQ_BRD_BUNDLE_DEPLOY_ID_FK
FOREIGN KEY (BUNDLE_DEPLOY_ID)
REFERENCES RHQ_BUNDLE_DEPLOY (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_RES_DEPLOY foreign key relation to RESOURCE">
ALTER TABLE RHQ_BUNDLE_RES_DEPLOY
- ADD CONSTRAINT RHQ_RESOURCE_ID_FK
+ ADD CONSTRAINT RHQ_BRD_RESOURCE_ID_FK
FOREIGN KEY (RESOURCE_ID)
REFERENCES RHQ_RESOURCE (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_DEPLOY foreign key relation to RHQ_BUNDLE_GROUP_DEPLOY">
ALTER TABLE RHQ_BUNDLE_RES_DEPLOY
- ADD CONSTRAINT RHQ_BUNDLE_GROUP_DEPLOY_ID_FK
+ ADD CONSTRAINT RHQ_BRD_B_GROUP_DEPLOY_ID_FK
FOREIGN KEY (BUNDLE_GROUP_DEPLOY_ID)
REFERENCES RHQ_BUNDLE_GROUP_DEPLOY (ID)
</statement>
<statement desc="Creating RHQ_BUNDLE_RES_DEPLOY unique constraint on def-resource mapping">
CREATE UNIQUE INDEX RHQ_BUNDLE_RES_DEPLOY_MAP_IX
- ON RHQ_BUNDLE_RES_DEPLOY (BUNDLE_DEPLOY_DEF_ID, RESOURCE_ID)
+ ON RHQ_BUNDLE_RES_DEPLOY (BUNDLE_DEPLOY_ID, RESOURCE_ID)
</statement>
</schema-directSQL>
@@ -2752,11 +2633,11 @@
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_STATUS" columnType="VARCHAR2" precision="16" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_STATUS" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_MESSAGE" columnType="LONGVARCHAR" />
+ <schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_MESSAGE" columnType="LONGVARCHAR" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_RES_DEP_HIST foreign key relation to BUNDLE_DEPLOY">
ALTER TABLE RHQ_BUNDLE_RES_DEP_HIST
- ADD CONSTRAINT RHQ_BUNDLE_RES_DEPLOY_ID_FK
+ ADD CONSTRAINT RHQ_BRDH_B_RES_DEPLOY_ID_FK
FOREIGN KEY (BUNDLE_RES_DEPLOY_ID)
REFERENCES RHQ_BUNDLE_RES_DEPLOY (ID)
</statement>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroup.java
index 0c254f9..9a06210 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroup.java
@@ -44,7 +44,7 @@ import javax.persistence.Table;
@Entity
@IdClass(RepoRepoGroupPK.class)
-@Table(name = "RHQ_REPO_REPO_GRP_MAP")
+@Table(name = "RHQ_REPO_REPO_GROUP_MAP")
public class RepoRepoGroup implements Serializable {
private static final long serialVersionUID = 1L;
@@ -61,7 +61,7 @@ public class RepoRepoGroup implements Serializable {
@Id
@ManyToOne
- @JoinColumn(name = "REPO_GRP_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ @JoinColumn(name = "REPO_GROUP_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
private RepoGroup repoGroup;
@Column(name = "CTIME", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroupPK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroupPK.java
index a1a5d48..135dac1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroupPK.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoGroupPK.java
@@ -46,7 +46,7 @@ public class RepoRepoGroupPK implements Serializable {
@ManyToOne
private Repo repo;
- @JoinColumn(name = "REPO_GRP_ID", referencedColumnName = "ID", nullable = false)
+ @JoinColumn(name = "REPO_GROUP_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne
private RepoGroup repoGroup;
commit ff1fca683ff4e57274583ff1d90447025197b52b
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Wed Apr 21 16:25:39 2010 -0400
update root pom to use new Nexus JBoss public repo; remove JBoss repo from any sub-poms that declared it, since they should inherit that from the root pom; specify old/deprecated JBoss repo where needed; some misc Maven dep tweaks
(cherry picked from commit 8707fad20442d2f9bdb2073a35f3adab74015428)
diff --git a/modules/cli-tests/pom.xml b/modules/cli-tests/pom.xml
index 98ef27a..72bca97 100644
--- a/modules/cli-tests/pom.xml
+++ b/modules/cli-tests/pom.xml
@@ -114,6 +114,7 @@
</plugins>
</build>
+
<profiles>
<!-- Unlike most of RHQ, this module requires JDK6, so replace the Java 5 bootclasspath that was added to the compiler args by the root POM with a bootclasspath based on the java.home sysprop (which should be Java 6 or later if the enforcer plugin did its job). -->
@@ -142,25 +143,4 @@
</profiles>
- <repositories>
- <repository>
- <id>jboss-snapshots</id>
- <name>JBoss Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>jboss-plugins-snapshots</id>
- <name>JBoss Plugin Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
</project>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index be7c74d..404c4d4 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -404,6 +404,19 @@
<repositories>
+
+ <!-- This is needed for the old version of Hibernate that we use. -->
+ <repository>
+ <id>jboss-deprecated-repository</id>
+ <name>JBoss Deprecated Maven Repository</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ </repository>
+
<repository>
<id>codehaus</id>
<name>codehaus</name>
diff --git a/modules/core/plugindoc/pom.xml b/modules/core/plugindoc/pom.xml
index 4d6fe6c..eeb7e81 100644
--- a/modules/core/plugindoc/pom.xml
+++ b/modules/core/plugindoc/pom.xml
@@ -90,6 +90,7 @@
</dependencies>
+
<build>
<plugins>
@@ -118,4 +119,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 82b73a5..7aad64c 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -96,4 +96,5 @@
</profiles>
-</project>
\ No newline at end of file
+</project>
+
diff --git a/modules/enterprise/gui/portal-war/pom.xml b/modules/enterprise/gui/portal-war/pom.xml
index a3e31e3..6a8c7ad 100644
--- a/modules/enterprise/gui/portal-war/pom.xml
+++ b/modules/enterprise/gui/portal-war/pom.xml
@@ -191,9 +191,11 @@
</dependency>
<dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.3.1</version>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.3.1_spec</artifactId>
+ <!-- The Sun javamail jar isn't available from a public repo due to licensing issues,
+ so use the Geronimo one instead. -->
+ <version>1.3</version>
<scope>provided</scope> <!-- by JBossAS -->
</dependency>
@@ -587,6 +589,20 @@
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
</repository>
+
+ <!-- This is needed for the org.jvnet:inflector dep.
+ TODO: Publish the inflector artifact to the JBoss 3rd party repo. -->
+ <repository>
+ <id>jboss-deprecated-repository</id>
+ <name>JBoss Deprecated Maven Repository</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ </repository>
+
</repositories>
</project>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 2d0e38a..6e9b09c 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -153,9 +153,11 @@
</dependency>
<dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.3.1</version>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.3.1_spec</artifactId>
+ <!-- The Sun javamail jar isn't available from a public repo due to licensing issues,
+ so use the Geronimo one instead. -->
+ <version>1.3</version>
<scope>provided</scope> <!-- by JBossAS -->
</dependency>
diff --git a/modules/enterprise/server/plugins/alert-email/pom.xml b/modules/enterprise/server/plugins/alert-email/pom.xml
index 9caf370..ad4a632 100644
--- a/modules/enterprise/server/plugins/alert-email/pom.xml
+++ b/modules/enterprise/server/plugins/alert-email/pom.xml
@@ -23,10 +23,13 @@
</properties>
<dependencies>
+
<dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.3.1</version>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.3.1_spec</artifactId>
+ <!-- The Sun javamail jar isn't available from a public repo due to licensing issues,
+ so use the Geronimo one instead. -->
+ <version>1.3</version>
<scope>provided</scope> <!-- by JBossAS -->
</dependency>
diff --git a/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml b/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
index c1d4eae..bab2df7 100644
--- a/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
+++ b/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
@@ -355,18 +355,4 @@
</plugins>
</build>
- <repositories>
-<!--
- <repository>
- <id>jboss-snapshots</id>
- <name>JBoss Snapshot Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
- </repository>
--->
- </repositories>
-
</project>
diff --git a/modules/plugins/JBossOSGi/pom.xml b/modules/plugins/JBossOSGi/pom.xml
index 355e152..fa6dde6 100644
--- a/modules/plugins/JBossOSGi/pom.xml
+++ b/modules/plugins/JBossOSGi/pom.xml
@@ -160,30 +160,6 @@
</profiles>
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </repository>
- <!-- TODO add your own maven repositories here (if needed) -->
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </pluginRepository>
- </pluginRepositories>
-
-
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
@@ -237,4 +213,4 @@
<!-- TODO add your dependencies here -->
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/modules/plugins/hardware/pom.xml b/modules/plugins/hardware/pom.xml
index 43c582d..9050b7e 100644
--- a/modules/plugins/hardware/pom.xml
+++ b/modules/plugins/hardware/pom.xml
@@ -70,26 +70,4 @@
</plugins>
</build>
- <repositories>
- <repository>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
-
</project>
diff --git a/modules/plugins/hudson/pom.xml b/modules/plugins/hudson/pom.xml
index 2454b97..de89333 100644
--- a/modules/plugins/hudson/pom.xml
+++ b/modules/plugins/hudson/pom.xml
@@ -76,26 +76,5 @@
</plugins>
</build>
- <repositories>
- <repository>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
-
</project>
+
diff --git a/modules/plugins/irc/pom.xml b/modules/plugins/irc/pom.xml
index 30dcae2..02e34cd 100644
--- a/modules/plugins/irc/pom.xml
+++ b/modules/plugins/irc/pom.xml
@@ -6,15 +6,15 @@
<modelVersion>4.0.0</modelVersion>
- <parent>
+ <parent>
<artifactId>rhq-plugins-parent</artifactId>
<groupId>org.rhq</groupId>
<version>3.0.0-SNAPSHOT</version>
- </parent>
+ </parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-irc-plugin</artifactId>
- <packaging>jar</packaging>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-irc-plugin</artifactId>
+ <packaging>jar</packaging>
<name>RHQ IRC Server Plugin</name>
<description>Remote monitoring of IRC repos</description>
@@ -34,8 +34,6 @@
</configuration>
</plugin>
-
-
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
@@ -150,30 +148,6 @@
</profiles>
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </repository>
- <!-- TODO add your own maven repositories here (if needed) -->
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </pluginRepository>
- </pluginRepositories>
-
-
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
@@ -183,29 +157,28 @@
<dependency>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-domain</artifactId>
- <version>${rhq.version}</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-plugin-api</artifactId>
- <version>${rhq.version}</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-native-system</artifactId>
- <version>${rhq.version}</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
- <!-- TODO add your dependencies here -->
<dependency>
<groupId>pircbot</groupId>
<artifactId>pircbot</artifactId>
<version>1.4.2</version>
- </dependency>
-
+ </dependency>
</dependencies>
+
</project>
diff --git a/modules/plugins/jboss-as-5/pom.xml b/modules/plugins/jboss-as-5/pom.xml
index 71e31b1..5533c33 100644
--- a/modules/plugins/jboss-as-5/pom.xml
+++ b/modules/plugins/jboss-as-5/pom.xml
@@ -633,17 +633,6 @@
</profiles>
- <repositories>
- <repository>
- <id>jboss-snapshots</id>
- <name>JBoss Snapshot Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
- </repository>
- </repositories>
<reporting>
<plugins>
diff --git a/modules/plugins/jboss-cache-v3/pom.xml b/modules/plugins/jboss-cache-v3/pom.xml
index 223253e..b3846fa 100644
--- a/modules/plugins/jboss-cache-v3/pom.xml
+++ b/modules/plugins/jboss-cache-v3/pom.xml
@@ -563,19 +563,6 @@
</profiles>
- <repositories>
-
- <repository>
- <id>jboss-snapshots</id>
- <name>JBoss Snapshot Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
- </repository>
-
- </repositories>
<reporting>
<plugins>
diff --git a/modules/plugins/kickstart/pom.xml b/modules/plugins/kickstart/pom.xml
index a235ca5..bc182b3 100644
--- a/modules/plugins/kickstart/pom.xml
+++ b/modules/plugins/kickstart/pom.xml
@@ -110,25 +110,4 @@
</profile>
</profiles>
- <!--<repositories>
- <repository>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>-->
</project>
diff --git a/modules/plugins/nss/pom.xml b/modules/plugins/nss/pom.xml
index 2c6b06d..47b015b 100644
--- a/modules/plugins/nss/pom.xml
+++ b/modules/plugins/nss/pom.xml
@@ -183,25 +183,4 @@
</profile>
</profiles>
- <repositories>
- <repository>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
</project>
diff --git a/modules/plugins/onewire/pom.xml b/modules/plugins/onewire/pom.xml
index 7bfced6..bd59655 100644
--- a/modules/plugins/onewire/pom.xml
+++ b/modules/plugins/onewire/pom.xml
@@ -155,27 +155,6 @@
</profiles>
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </pluginRepository>
- </pluginRepositories>
<dependencies>
<dependency>
diff --git a/modules/plugins/script2/pom.xml b/modules/plugins/script2/pom.xml
index 2ae47bc..038ce5c 100644
--- a/modules/plugins/script2/pom.xml
+++ b/modules/plugins/script2/pom.xml
@@ -148,38 +148,12 @@
</profiles>
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </repository>
- <!-- TODO add your own maven repositories here (if needed) -->
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </pluginRepository>
- </pluginRepositories>
-
-
<dependencies>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>1.4.0</version>
</dependency>
-
- <!-- TODO add your dependencies here -->
-
</dependencies>
+
</project>
diff --git a/modules/plugins/services/pom.xml b/modules/plugins/services/pom.xml
index 3ef276d..525335c 100644
--- a/modules/plugins/services/pom.xml
+++ b/modules/plugins/services/pom.xml
@@ -140,27 +140,6 @@
</profile>
</profiles>
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </pluginRepository>
- </pluginRepositories>
<dependencies>
<dependency>
@@ -256,5 +235,6 @@
<systemPath>/usr/lib/libmatthew-java/unix.jar</systemPath>
</dependency>
- </dependencies>
+ </dependencies>
+
</project>
diff --git a/modules/plugins/snmptrapd/pom.xml b/modules/plugins/snmptrapd/pom.xml
index 3265757..2d9d715 100644
--- a/modules/plugins/snmptrapd/pom.xml
+++ b/modules/plugins/snmptrapd/pom.xml
@@ -154,27 +154,8 @@
</profile>
</profiles>
+
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </pluginRepository>
- </pluginRepositories>
<dependencies>
<dependency>
<groupId>org.rhq</groupId>
diff --git a/modules/plugins/twitter/pom.xml b/modules/plugins/twitter/pom.xml
index 63e472f..e299efa 100644
--- a/modules/plugins/twitter/pom.xml
+++ b/modules/plugins/twitter/pom.xml
@@ -133,27 +133,6 @@
</profile>
</profiles>
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- </pluginRepository>
- </pluginRepositories>
<dependencies>
<dependency>
@@ -179,11 +158,12 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>net.homeip.yusuke</groupId>
<artifactId>twitter4j</artifactId>
<version>2.0.9</version>
</dependency>
-
</dependencies>
+
</project>
diff --git a/pom.xml b/pom.xml
index 7b5f32d..9dab40a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -817,6 +817,7 @@
</plugins>
<!-- To allow deploying release artifacts to SVN and snapshot artifacts to HTTP/Dav. -->
+<!--
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
@@ -839,44 +840,61 @@
<version>1.0-beta-2</version>
</extension>
</extensions>
-
+-->
</build>
<repositories>
- <repository>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+<!--
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+-->
+ </repository>
</repositories>
<pluginRepositories>
- <pluginRepository>
- <id>jboss</id>
- <name>JBoss Plugin Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </pluginRepository>
+ <pluginRepository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+<!--
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+-->
+ </pluginRepository>
</pluginRepositories>
<distributionManagement>
- <repository>
- <!-- Copy the distribution jar file to a local checkout of the JBoss repository.
- This variable can be set in ~/.m2/settings.xml or $M2_HOME/conf/settings.xml. -->
- <id>repository.jboss.org</id>
- <url>file://${maven.repository.root}</url>
- </repository>
<snapshotRepository>
- <id>jboss-snapshots</id>
- <name>JBoss Snapshot Repository</name>
- <url>dav:https://snapshots.jboss.org/maven2/</url>
+ <id>jboss-snapshots-repository</id>
+ <name>JBoss Snapshots Repository</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
+
+ <repository>
+ <id>jboss-releases-repository</id>
+ <name>JBoss Releases Repository</name>
+ <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
+ </repository>
+
</distributionManagement>
<modules>
commit 343b11b833a5b1cc3eba6d2c4d94879ceb0f3c0d
Merge: 1d654e0... 89d7cef...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 21 15:25:43 2010 -0400
Merge branch 'master' into master-jay
commit 1d654e0039216351a31c429d86b01d90bb0fcd36
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 21 15:24:46 2010 -0400
Revert "Add <support> tag to plugin descriptor to mark that the resource type"
This reverts commit 3e3da3591f87d4cc0efb9e5188f954948b81c49b.
Conflicts:
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index b589e16..686b16b 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -442,7 +442,6 @@ public class PluginMetadataParser {
// 8) Artifacts
// 9) Child subcategories
// 10) Bundle Type
- // 11) SupportFacet
String classLoaderTypeString = resourceDescriptor.getClassLoader();
if (classLoaderTypeString == null) {
@@ -528,8 +527,6 @@ public class PluginMetadataParser {
resourceType.setBundleType(new BundleType(typeName, resourceType));
}
- resourceType.setSupportsSupportFacet(resourceDescriptor.getSupport() != null);
-
} catch (InvalidPluginDescriptorException e) {
// TODO: Should we be storing these for viewing in server? Breaking deployment? What?
throw e;
diff --git a/modules/core/client-api/src/main/resources/rhq-plugin.xsd b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
index e5ee978..6225b8e 100644
--- a/modules/core/client-api/src/main/resources/rhq-plugin.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
@@ -555,15 +555,7 @@
<xs:element ref="rhq:event" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="rhq:content" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="resource-configuration" type="config:configuration" minOccurs="0"/>
- <xs:element name="support" type="rhq:support" minOccurs="0" maxOccurs="1">
- <xs:annotation>
- <xs:documentation>
- Declares that the resource component implements the SupportFacet.
- </xs:documentation>
- </xs:annotation>
- </xs:element>
<xs:element ref="rhq:help" minOccurs="0" maxOccurs="1" />
-
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="singleton" use="optional" type="xs:boolean" default="false">
@@ -645,8 +637,6 @@
<xs:attribute name="type" type="xs:string"/>
</xs:complexType>
- <xs:complexType name="support">
- </xs:complexType>
<!-- PLATFORM -->
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
index f8a1e35..2f25ff1 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
@@ -13,7 +13,6 @@
<column name="CREATE_DELETE_POLICY" type="VARCHAR2" size="16" required="true"/>
<column name="SINGLETON" type="BOOLEAN" required="true"/>
<column name="SUPPORTS_MANUAL_ADD" type="BOOLEAN" required="true"/>
- <column name="SUPPORTS_SUPPORT_FACET" type="BOOLEAN" required="true"/>
<column name="DESCRIPTION" type="VARCHAR2" size="1000"/>
<column name="PLUGIN" type="VARCHAR2" size="100"/>
<column name="CTIME" type="LONG"/>
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 d2ab444..9a779ba 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
@@ -22,6 +22,10 @@
*/
package org.rhq.core.domain.resource;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
@@ -173,7 +177,7 @@ import org.rhq.core.domain.util.Summary;
+ " (SELECT COUNT(operationDef) FROM rt.operationDefinitions operationDef)," // operation
+ " (SELECT COUNT(packageType) FROM rt.packageTypes packageType)," // content
+ " (SELECT COUNT(metricDef) FROM rt.metricDefinitions metricDef WHERE metricDef.dataType = 3)," // calltime
- + " rt.supportsSupportFacet" // support
+ + " (SELECT COUNT(propDef) FROM rt.pluginConfigurationDefinition pluginConfig JOIN pluginConfig.propertyDefinitions propDef WHERE propDef.name = 'snapshotLogEnabled')" // support
+ " ) " //
+ " FROM ResourceType rt " //
+ " WHERE ( rt.id = :resourceTypeId OR :resourceTypeId IS NULL )"),
@@ -302,9 +306,6 @@ public class ResourceType implements Serializable, Comparable<ResourceType> {
@Column(name = "SUPPORTS_MANUAL_ADD", nullable = false)
private boolean supportsManualAdd;
- @Column(name = "SUPPORTS_SUPPORT_FACET", nullable = false)
- private boolean supportsSupportFacet;
-
@Column(name = "SINGLETON", nullable = false)
private boolean singleton;
@@ -513,14 +514,6 @@ public class ResourceType implements Serializable, Comparable<ResourceType> {
this.supportsManualAdd = supportsManualAdd;
}
- public boolean isSupportsSupportFacet() {
- return supportsSupportFacet;
- }
-
- public void setSupportsSupportFacet(boolean supportsSupportFacet) {
- this.supportsSupportFacet = supportsSupportFacet;
- }
-
public String getDescription() {
return this.description;
}
@@ -817,86 +810,87 @@ public class ResourceType implements Serializable, Comparable<ResourceType> {
+ this.plugin + /*", parents=" + parents +*/"]";
}
- /*
- TODO: GWT
- public void writeExternal(ObjectOutput out) throws IOException {
- ExternalizableStrategy.Subsystem strategy = ExternalizableStrategy.getStrategy();
- out.writeChar(strategy.id());
-
- if (ExternalizableStrategy.Subsystem.REMOTEAPI == strategy) {
- writeExternalRemote(out);
- } else if (ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION == strategy) {
- EntitySerializer.writeExternalRemote(this, out);
- } else {
- writeExternalAgent(out);
- }
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- char c = in.readChar();
- if (ExternalizableStrategy.Subsystem.REMOTEAPI.id() == c) {
- readExternalRemote(in);
- } else if (ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION.id() == c) {
- EntitySerializer.readExternalRemote(this, in);
- } else {
- readExternalAgent(in);
- }
- }
- public void writeExternalAgent(ObjectOutput out) throws IOException {
- out.writeUTF(this.name);
- out.writeUTF(this.plugin);
- }
-
- public void readExternalAgent(ObjectInput in) throws IOException, ClassNotFoundException {
- this.name = in.readUTF();
- this.plugin = in.readUTF();
+/*
+TODO: GWT
+ public void writeExternal(ObjectOutput out) throws IOException {
+ ExternalizableStrategy.Subsystem strategy = ExternalizableStrategy.getStrategy();
+ out.writeChar(strategy.id());
+
+ if (ExternalizableStrategy.Subsystem.REMOTEAPI == strategy) {
+ writeExternalRemote(out);
+ } else if (ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION == strategy) {
+ EntitySerializer.writeExternalRemote(this, out);
+ } else {
+ writeExternalAgent(out);
}
+ }
- public void writeExternalRemote(ObjectOutput out) throws IOException {
- out.writeInt(this.id);
- out.writeUTF(this.name);
- out.writeUTF((null == this.description) ? "" : this.description);
- out.writeObject(this.category);
- out.writeObject(this.creationDataType);
- out.writeObject(this.createDeletePolicy);
- out.writeBoolean(this.supportsManualAdd);
- out.writeBoolean(this.singleton);
- out.writeUTF(this.plugin);
- out.writeLong(this.ctime);
- out.writeLong(this.mtime);
- out.writeObject(this.subCategory);
- out.writeObject(this.bundleType);
- out.writeObject((null == childResourceTypes) ? null : new LinkedHashSet<ResourceType>(childResourceTypes));
- out.writeObject((null == parentResourceTypes) ? null : new LinkedHashSet<ResourceType>(parentResourceTypes));
- out.writeObject(pluginConfigurationDefinition);
- out.writeObject(resourceConfigurationDefinition);
- out.writeObject((null == metricDefinitions) ? null
- : new LinkedHashSet<MeasurementDefinition>(metricDefinitions));
- out.writeObject((null == eventDefinitions) ? null : new LinkedHashSet<EventDefinition>(eventDefinitions));
- out.writeObject((null == operationDefinitions) ? null : new LinkedHashSet<OperationDefinition>(
- operationDefinitions));
- out.writeObject((null == processScans) ? null : new LinkedHashSet<ProcessScan>(processScans));
- out.writeObject((null == packageTypes) ? null : new LinkedHashSet<PackageType>(packageTypes));
- out.writeObject((null == subCategories) ? null : new LinkedHashSet<ResourceSubCategory>(subCategories));
- out.writeObject((null == resources) ? null : new LinkedHashSet<Resource>(resources));
- out.writeObject((null == productVersions) ? null : new LinkedHashSet<ProductVersion>(productVersions));
- // not supplied by remote: helpText
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ char c = in.readChar();
+ if (ExternalizableStrategy.Subsystem.REMOTEAPI.id() == c) {
+ readExternalRemote(in);
+ } else if (ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION.id() == c) {
+ EntitySerializer.readExternalRemote(this, in);
+ } else {
+ readExternalAgent(in);
}
+ }
- public void readExternalRemote(ObjectInput in) throws IOException, ClassNotFoundException {
- this.id = in.readInt();
- this.name = in.readUTF();
- this.description = in.readUTF();
- this.category = (ResourceCategory) in.readObject();
- this.creationDataType = (ResourceCreationDataType) in.readObject();
- this.createDeletePolicy = (CreateDeletePolicy) in.readObject();
- this.supportsManualAdd = in.readBoolean();
- this.singleton = in.readBoolean();
- this.plugin = in.readUTF();
- this.ctime = in.readLong();
- this.mtime = in.readLong();
- }
- */
+ public void writeExternalAgent(ObjectOutput out) throws IOException {
+ out.writeUTF(this.name);
+ out.writeUTF(this.plugin);
+ }
+
+ public void readExternalAgent(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.name = in.readUTF();
+ this.plugin = in.readUTF();
+ }
+
+ public void writeExternalRemote(ObjectOutput out) throws IOException {
+ out.writeInt(this.id);
+ out.writeUTF(this.name);
+ out.writeUTF((null == this.description) ? "" : this.description);
+ out.writeObject(this.category);
+ out.writeObject(this.creationDataType);
+ out.writeObject(this.createDeletePolicy);
+ out.writeBoolean(this.supportsManualAdd);
+ out.writeBoolean(this.singleton);
+ out.writeUTF(this.plugin);
+ out.writeLong(this.ctime);
+ out.writeLong(this.mtime);
+ out.writeObject(this.subCategory);
+ out.writeObject(this.bundleType);
+ out.writeObject((null == childResourceTypes) ? null : new LinkedHashSet<ResourceType>(childResourceTypes));
+ out.writeObject((null == parentResourceTypes) ? null : new LinkedHashSet<ResourceType>(parentResourceTypes));
+ out.writeObject(pluginConfigurationDefinition);
+ out.writeObject(resourceConfigurationDefinition);
+ out.writeObject((null == metricDefinitions) ? null
+ : new LinkedHashSet<MeasurementDefinition>(metricDefinitions));
+ out.writeObject((null == eventDefinitions) ? null : new LinkedHashSet<EventDefinition>(eventDefinitions));
+ out.writeObject((null == operationDefinitions) ? null : new LinkedHashSet<OperationDefinition>(
+ operationDefinitions));
+ out.writeObject((null == processScans) ? null : new LinkedHashSet<ProcessScan>(processScans));
+ out.writeObject((null == packageTypes) ? null : new LinkedHashSet<PackageType>(packageTypes));
+ out.writeObject((null == subCategories) ? null : new LinkedHashSet<ResourceSubCategory>(subCategories));
+ out.writeObject((null == resources) ? null : new LinkedHashSet<Resource>(resources));
+ out.writeObject((null == productVersions) ? null : new LinkedHashSet<ProductVersion>(productVersions));
+ // not supplied by remote: helpText
+ }
+
+ public void readExternalRemote(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.id = in.readInt();
+ this.name = in.readUTF();
+ this.description = in.readUTF();
+ this.category = (ResourceCategory) in.readObject();
+ this.creationDataType = (ResourceCreationDataType) in.readObject();
+ this.createDeletePolicy = (CreateDeletePolicy) in.readObject();
+ this.supportsManualAdd = in.readBoolean();
+ this.singleton = in.readBoolean();
+ this.plugin = in.readUTF();
+ this.ctime = in.readLong();
+ this.mtime = in.readLong();
+ }
+*/
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceFacets.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceFacets.java
index 85905b5..cc3cb50 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceFacets.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceFacets.java
@@ -67,7 +67,7 @@ public class ResourceFacets implements Serializable {
}
public ResourceFacets(int resourceTypeId, Number measurement, Number event, Number pluginConfiguration,
- Number configuration, Number operation, Number content, Number callTime, boolean support) {
+ Number configuration, Number operation, Number content, Number callTime, Number support) {
this.resourceTypeId = resourceTypeId;
this.measurement = measurement.intValue() != 0;
this.event = event.intValue() != 0;
@@ -76,7 +76,7 @@ public class ResourceFacets implements Serializable {
this.operation = operation.intValue() != 0;
this.content = content.intValue() != 0;
this.callTime = callTime.intValue() != 0;
- this.support = support;
+ this.support = support.intValue() != 0;
initEnum();
}
diff --git a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
index ca642eb..c2ddc8d 100644
--- a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
@@ -240,8 +240,6 @@
</configuration>
</content>
- <support/>
-
<help>
<![CDATA[
<h3>Binding to IP addresses</h3>
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index 734a28f..45af5ba 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -613,8 +613,6 @@
</c:simple-property>
</c:group>
</resource-configuration>
-
- <support/>
<server name="RHQ Agent JVM"
description="JVM of the Management Agent"
commit 89d7cef9ab988fde3ec63d4de2d7f8965e707e61
Merge: 48423a9... 2049830...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 21 21:23:47 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 48423a9d953413272ad7861306898a6ef9a4dfda
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 21 21:20:42 2010 +0200
BZ 579529: use -eq instead of == to support 'standard' /bin/sh
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh
index d3fd715..e436d87 100755
--- a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh
+++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh
@@ -155,7 +155,7 @@ fi
JAVA="$RHQ_SERVER_JAVA_EXE_FILE_PATH"
export JAVA
-if [ $# == 0 ]
+if [ $# -eq 0 ]
then
echo "Usage generate-db-password <password>"
exit 1
commit 93efdce776ba617a695b4f58a1b70e6b51440d9e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 21 15:16:57 2010 -0400
Revert "Fix some queries - addendum to <support> tag work."
This reverts commit db03988259111050f74e8df8a2cca9363244148d.
The support tag stuff was not supposed to go in.
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 0e0fc55..d2ab444 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
@@ -188,7 +188,7 @@ import org.rhq.core.domain.util.Summary;
@NamedNativeQueries( {
// TODO: Add authz conditions to the below query.
@NamedNativeQuery(name = ResourceType.QUERY_FIND_CHILDREN_BY_CATEGORY, query = "" //
- + "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, crt.supports_manual_add, crt.supports_support_facet, crt.description, crt.plugin, crt.ctime, crt.mtime, crt.subcategory_id, crt.plugin_config_def_id, crt.res_config_def_id "
+ + "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, crt.supports_manual_add, crt.description, crt.plugin, crt.ctime, crt.mtime, crt.subcategory_id, crt.plugin_config_def_id, crt.res_config_def_id "
+ "FROM RHQ_resource_type crt, RHQ_resource res, RHQ_resource_type rt, RHQ_resource_type_parents rtp "
+ "WHERE res.id = ? "
+ "AND res.resource_type_id = rt.id "
@@ -198,7 +198,7 @@ import org.rhq.core.domain.util.Summary;
+
// "ORDER BY crt.name " +
"UNION "
- + "SELECT DISTINCT crt2.id, crt2.name, crt2.category, crt2.creation_data_type, crt2.create_delete_policy, crt2.singleton, crt2.supports_manual_add, crt2.supports_support_facet, crt2.description, crt2.plugin, crt2.ctime, crt2.mtime, crt2.subcategory_id, crt2.plugin_config_def_id, crt2.res_config_def_id "
+ + "SELECT DISTINCT crt2.id, crt2.name, crt2.category, crt2.creation_data_type, crt2.create_delete_policy, crt2.singleton, crt2.supports_manual_add, crt2.description, crt2.plugin, crt2.ctime, crt2.mtime, crt2.subcategory_id, crt2.plugin_config_def_id, crt2.res_config_def_id "
+ "FROM RHQ_resource_type crt2 " + "WHERE 1 = "
+ "(SELECT COUNT(res2.id) "
+ "FROM RHQ_resource res2, RHQ_resource_type rt2 "
@@ -209,7 +209,7 @@ import org.rhq.core.domain.util.Summary;
+ "FROM RHQ_resource_type_parents rtp2 "
+ "WHERE rtp2.resource_type_id = crt2.id) " + "AND crt2.category = ? " + " ) ORDER BY name", resultSetMapping = ResourceType.MAPPING_FIND_CHILDREN_BY_CATEGORY),
@NamedNativeQuery(name = ResourceType.QUERY_FIND_CHILDREN_BY_CATEGORY_admin, query = "" //
- + "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, crt.supports_manual_add, crt.supports_support_facet, crt.description, crt.plugin, crt.ctime, crt.mtime, crt.subcategory_id, crt.plugin_config_def_id, crt.res_config_def_id "
+ + "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, crt.supports_manual_add, crt.description, crt.plugin, crt.ctime, crt.mtime, crt.subcategory_id, crt.plugin_config_def_id, crt.res_config_def_id "
+ "FROM RHQ_resource_type crt, RHQ_resource res, RHQ_resource_type rt, RHQ_resource_type_parents rtp "
+ "WHERE res.id = ? "
+ "AND res.resource_type_id = rt.id "
@@ -219,7 +219,7 @@ import org.rhq.core.domain.util.Summary;
+
// "ORDER BY crt.name " +
"UNION "
- + "(SELECT DISTINCT crt2.id, crt2.name, crt2.category, crt2.creation_data_type, crt2.create_delete_policy, crt2.singleton, crt2.supports_manual_add, crt2.supports_support_facet, crt2.description, crt2.plugin, crt2.ctime, crt2.mtime, crt2.subcategory_id, crt2.plugin_config_def_id, crt2.res_config_def_id "
+ + "(SELECT DISTINCT crt2.id, crt2.name, crt2.category, crt2.creation_data_type, crt2.create_delete_policy, crt2.singleton, crt2.supports_manual_add, crt2.description, crt2.plugin, crt2.ctime, crt2.mtime, crt2.subcategory_id, crt2.plugin_config_def_id, crt2.res_config_def_id "
+ "FROM RHQ_resource_type crt2 " + "WHERE 1 = "
+ "(SELECT COUNT(res2.id) "
+ "FROM RHQ_resource res2, RHQ_resource_type rt2 "
commit e4689aecd3198c18147bdcaf7b1e9c731752deaf
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Apr 21 14:46:23 2010 -0400
[BZ 544353] Fixing UI bean code so stale values are not used when creating a new group def
NewGroupDefinitionGeneralPropertiesUIBean and EditGroupDefinitionGeneralPropertiesUIBean
both stick an attribute in the session to indicate that particular fields should be
cached and reused. Part of the problem was that both beans were using the same attribute
name. The other part of the problem is that during group creation, the marker attribute
was not getting removed from the session, and the absence of the marker indicates that
any cached values should not be used.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
index 28d166b..09837ec 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
@@ -42,7 +42,7 @@ public class EditGroupDefinitionGeneralPropertiesUIBean {
private static final String OUTCOME_SUCCESS = "success";
private static final String OUTCOME_FAILURE = "failure";
- private static final String TEMPORARY_EDIT_MARKER = "temporaryGroupDef-Marker";
+ private static final String TEMPORARY_EDIT_MARKER = "temporaryEditGroupDef-Marker";
private static final String TEMPORARY_EXPRESSION_ATTRIBUTE = "temporaryGroupDefExpr";
private static final String TEMPORARY_NAME_ATTRIBUTE = "temporaryGroupDefName";
private static final String TEMPORARY_DESCRIPTION_ATTRIBUTE = "temporaryGroupDefDescription";
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
index ee37492..ef3c90d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
@@ -35,7 +35,7 @@ public class NewGroupDefinitionGeneralPropertiesUIBean {
private static final String OUTCOME_FAILURE = "failure";
private static final String OUTCOME_CANCEL = "cancel";
- private static final String TEMPORARY_CREATE_MARKER = "temporaryGroupDef-Marker";
+ private static final String TEMPORARY_CREATE_MARKER = "temporaryCreateGroupDef-Marker";
private static final String TEMPORARY_NAME_ATTRIBUTE = "temporaryGroupDefName";
private static final String TEMPORARY_DESCRIPTION_ATTRIBUTE = "temporaryGroupDefDescription";
private static final String TEMPORARY_RECURSIVE_ATTRIBUTE = "temporaryGroupDefRecursive";
@@ -73,14 +73,14 @@ public class NewGroupDefinitionGeneralPropertiesUIBean {
}
public String create() {
+ HttpSession session = FacesContextUtility.getRequest().getSession();
+
try {
GroupDefinition groupDefinition = new GroupDefinition(this.name);
groupDefinition.setDescription(this.description);
groupDefinition.setRecursive(this.recursive);
- HttpSession session = FacesContextUtility.getRequest().getSession();
-
session.setAttribute(TEMPORARY_CREATE_MARKER, "marker");
session.setAttribute(TEMPORARY_NAME_ATTRIBUTE, name);
session.setAttribute(TEMPORARY_DESCRIPTION_ATTRIBUTE, description);
@@ -99,6 +99,8 @@ public class NewGroupDefinitionGeneralPropertiesUIBean {
return OUTCOME_FAILURE;
}
+ session.setAttribute(TEMPORARY_CREATE_MARKER, null);
+
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
"Definition created successfully. Add conditions below.");
return OUTCOME_SUCCESS;
commit 2049830272a637543ff73e7b8605d0b432d1170d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Apr 21 14:05:40 2010 -0400
fix whitespace:
* replace tabs with spaces
* removing trailing spaces on lines
* respect author-chosen alignment/positions for SQL statements
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 1f06393..f812e9a 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -17,18 +17,22 @@
Update Version: ${target.schema.version}
</echo>
- <dbupgrade jdbcUrl="${jdbc.url}" jdbcUser="${jdbc.user}" jdbcPassword="${jdbc.password}" valueColumn="PROPERTY_VALUE"
-table="RHQ_SYSTEM_CONFIG" keyColumn="PROPERTY_KEY" keyMatch="DB_SCHEMA_VERSION" targetSchemaVersion="${target.schema.version}">
+ <dbupgrade jdbcUrl="${jdbc.url}"
+ jdbcUser="${jdbc.user}"
+ jdbcPassword="${jdbc.password}"
+ valueColumn="PROPERTY_VALUE"
+ table="RHQ_SYSTEM_CONFIG"
+ keyColumn="PROPERTY_KEY"
+ keyMatch="DB_SCHEMA_VERSION"
+ targetSchemaVersion="${target.schema.version}">
<schemaSpec version="2.0">
<!-- Empty initial schema to avoid install failure on default latest schema version -->
</schemaSpec>
<schemaSpec version="2.1">
- <!--
- Keep the columnType VARCHAR2, but increase size; (see note for RHQ_ALERT_CONDITION table in alert-schema.xml for more
-info)
- -->
+ <!-- Keep the columnType VARCHAR2, but increase size;
+ (see note for RHQ_ALERT_CONDITION table in alert-schema.xml for more ifo) -->
<schema-alterColumn table="RHQ_ALERT_CONDITION" column="OPTION_STATUS" columnType="VARCHAR2" precision="256" />
</schemaSpec>
@@ -47,8 +51,7 @@ info)
<schema-addColumn table="RHQ_PACKAGE_TYPE" column="SUPPORTS_ARCHITECTURE" columnType="BOOLEAN" />
<schema-directSQL>
- <statement targetDBVendor="postgresql" desc="Updating existing package types with default for SUPPORTS_ARCHITECTURE
-flag">
+ <statement targetDBVendor="postgresql" desc="Updating existing package types with default for SUPPORTS_ARCHITECTURE flag">
UPDATE RHQ_PACKAGE_TYPE SET SUPPORTS_ARCHITECTURE = FALSE
</statement>
<statement targetDBVendor="oracle" desc="Updating existing package types with default for SUPPORTS_ARCHITECTURE flag">
@@ -268,11 +271,11 @@ flag">
FOREIGN KEY (SERVER_ID)
REFERENCES RHQ_SERVER (ID)
</statement>
- </schema-directSQL>
- <schema-addColumn table="RHQ_FAILOVER_DETAILS" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_FAILOVER_DETAILS" column="CTIME" nullable="FALSE" />
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_FAILOVER_DETAILS" column="CTIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_FAILOVER_DETAILS" column="CTIME" nullable="FALSE" />
- </schemaSpec>
+ </schemaSpec>
<schemaSpec version="2.7">
<schema-addColumn table="RHQ_AGENT" column="STATUS" columnType="INTEGER" />
@@ -334,8 +337,7 @@ flag">
<schema-addColumn table="RHQ_SERVER" column="TRANSPORT_PARAMS" columnType="VARCHAR2" precision="512" />
<schema-directSQL>
- <statement desc="Updating existing servers with default
-TRANSPORT_PARAMS=/jboss-remoting-servlet-invoker/ServerInvokerServlet">
+ <statement desc="Updating existing servers with default TRANSPORT_PARAMS=/jboss-remoting-servlet-invoker/ServerInvokerServlet">
UPDATE RHQ_SERVER SET TRANSPORT_PARAMS = '/jboss-remoting-servlet-invoker/ServerInvokerServlet'
</statement>
</schema-directSQL>
@@ -2145,16 +2147,14 @@ TRANSPORT_PARAMS=/jboss-remoting-servlet-invoker/ServerInvokerServlet">
<statement desc="Dropping unique index on RHQ_PLUGIN (NAME)">
DROP INDEX RHQ_PLUGIN_NAME_IDX
</statement>
- <statement desc="Creating unique index on RHQ_PLUGIN (NAME, DEPLOYMENT) so server plugin names need not be unique with
-agent plugins">
+ <statement desc="Creating unique index on RHQ_PLUGIN (NAME, DEPLOYMENT) so server plugin names need not be unique with agent plugins">
CREATE UNIQUE INDEX RHQ_PLUGIN_NAME_DEPLOY_IDX ON RHQ_PLUGIN (NAME, DEPLOYMENT)
</statement>
</schema-directSQL>
</schemaSpec>
<schemaSpec version="2.69.3">
- <!-- add the new column that indicates what type of plugin this is (e.g. alert, generic, content) - for server plugins only
--->
+ <!-- add the new column that indicates what type of plugin this is (e.g. alert, generic, content) - for server plugins only -->
<schema-addColumn table="RHQ_PLUGIN" column="PTYPE" columnType="VARCHAR2" precision="200" />
</schemaSpec>
@@ -2410,51 +2410,51 @@ agent plugins">
<schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
</schemaSpec>
- <schemaSpec version="2.77">
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER" />
- <schema-directSQL>
- <statement>
+ <schemaSpec version="2.77">
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement>
ALTER TABLE RHQ_ALERT_NOTIFICATION
ADD CONSTRAINT RHQ_NOTIF_TEMPL_ID_FKEY
FOREIGN KEY (NOTIF_TEMPLATE_ID)
REFERENCES RHQ_ALERT_NOTIF_TEMPL(ID)
</statement>
- </schema-directSQL>
- </schemaSpec>
- <schemaSpec version="2.77.1">
- <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
- </schemaSpec>
- <schemaSpec version="2.77.2">
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address" />
- </schemaSpec>
- <schemaSpec version="2.77.3">
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="role_id" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
- </schemaSpec>
- <schemaSpec version="2.77.4">
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
- <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
-
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
- </schemaSpec>
- <schemaSpec version="2.77.5">
- <schema-directSQL>
- <statement>
+ </schema-directSQL>
+ </schemaSpec>
+ <schemaSpec version="2.77.1">
+ <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
+ </schemaSpec>
+ <schemaSpec version="2.77.2">
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address" />
+ </schemaSpec>
+ <schemaSpec version="2.77.3">
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="role_id" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
+ </schemaSpec>
+ <schemaSpec version="2.77.4">
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
+ <schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
+
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
+ <schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
+ </schemaSpec>
+ <schemaSpec version="2.77.5">
+ <schema-directSQL>
+ <statement>
DROP INDEX IF EXISTS RHQ_ALERT_IDX_ALERT
</statement>
- <statement>
+ <statement>
CREATE INDEX RHQ_ALERT_IDX_ALERT ON RHQ_ALERT_NOTIF_LOG (alert_id)
</statement>
- </schema-directSQL>
- </schemaSpec>
+ </schema-directSQL>
+ </schemaSpec>
<schemaSpec version="2.78">
<!-- RHQ_BUNDLE_TYPE -->
@@ -2490,11 +2490,11 @@ agent plugins">
<schema-alterColumn table="RHQ_BUNDLE" column="ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE" column="NAME" columnType="VARCHAR2" precision="200" />
<schema-alterColumn table="RHQ_BUNDLE" column="NAME" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
+ <schema-addColumn table="RHQ_BUNDLE" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
<schema-addColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE" column="PACKAGE_TYPE_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_BUNDLE" column="PACKAGE_TYPE_ID" nullable="FALSE" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="PACKAGE_TYPE_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE" column="REPO_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE" column="REPO_ID" nullable="FALSE" />
<schema-directSQL>
@@ -2535,10 +2535,10 @@ agent plugins">
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION_ORDER" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION_ORDER" nullable="FALSE" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION_ORDER" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="CLOB" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_VERSION" column="CONFIG_DEF_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="CONFIG_DEF_ID" columnType="INTEGER" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
<schema-directSQL>
@@ -2556,7 +2556,7 @@ agent plugins">
</statement>
<statement desc="Creating RHQ_BUNDLE_VERSION unique constraint">
CREATE UNIQUE INDEX RHQ_BUNDLE_VERSION_UNIQUE ON RHQ_BUNDLE_VERSION (bundle_id, name, version)
- </statement>
+ </statement>
</schema-directSQL>
<!-- RHQ_BUNDLE_VERSION_REPO -->
@@ -2597,7 +2597,7 @@ agent plugins">
<schema-addColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" nullable="FALSE" />
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" nullable="FALSE" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_BUNDLE_VERSION">
@@ -2615,7 +2615,7 @@ agent plugins">
</schema-directSQL>
<!-- RHQ_BUNDLE_DEPLOY -->
- <schema-createSequence name="RHQ_BUNDLE_DEPLOY_ID_SEQ" initial="10001" />
+ <schema-createSequence name="RHQ_BUNDLE_DEPLOY_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_DEPLOY">
CREATE TABLE RHQ_BUNDLE_DEPLOY ( ID INTEGER PRIMARY KEY )
@@ -2626,7 +2626,7 @@ agent plugins">
<schema-alterColumn table="RHQ_BUNDLE_DEPLOY" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOY" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOY" column="INSTALL_DIR" columnType="VARCHAR2" precision="256" />
- <schema-alterColumn table="RHQ_BUNDLE_DEPLOY" column="INSTALL_DIR" nullable="FALSE" />
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOY" column="INSTALL_DIR" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOY" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_DEPLOY" column="CTIME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_DEPLOY" column="MTIME" columnType="LONG" />
@@ -2652,10 +2652,10 @@ agent plugins">
CREATE UNIQUE INDEX RHQ_BUNDLE_DEPLOY_UNIQUE
ON RHQ_BUNDLE_DEPLOY (bundle_version_id, name, install_dir)
</statement>
- </schema-directSQL>
+ </schema-directSQL>
<!-- RHQ_BUNDLE_GROUP_DEPLOY -->
- <schema-createSequence name="RHQ_BUNDLE_GROUP_DEPLOY_ID_SEQ" initial="10001" />
+ <schema-createSequence name="RHQ_BUNDLE_GROUP_DEPLOY_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_GROUP_DEPLOY">
CREATE TABLE RHQ_BUNDLE_GROUP_DEPLOY ( ID INTEGER PRIMARY KEY )
@@ -2705,10 +2705,10 @@ agent plugins">
<schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="IS_CURRENT" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="IS_CURRENT" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="STATUS" columnType="VARCHAR2" precision="16" />
- <schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="STATUS" nullable="FALSE" />
+ <schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="STATUS" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEPLOY" column="CTIME" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="BUNDLE_GROUP_DEPLOY_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_BUNDLE_RES_DEPLOY" column="BUNDLE_GROUP_DEPLOY_ID" columnType="INTEGER" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_RES_DEPLOY foreign key relation to BUNDLE_DEPLOY">
@@ -2736,7 +2736,7 @@ agent plugins">
</schema-directSQL>
<!-- RHQ_BUNDLE_RES_DEP_HIST -->
- <schema-createSequence name="RHQ_BUNDLE_RES_DEP_HIST_ID_SEQ" initial="10001" />
+ <schema-createSequence name="RHQ_BUNDLE_RES_DEP_HIST_ID_SEQ" initial="10001" />
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_RES_DEP_HIST">
CREATE TABLE RHQ_BUNDLE_RES_DEP_HIST ( ID INTEGER PRIMARY KEY )
@@ -2752,7 +2752,7 @@ agent plugins">
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_STATUS" columnType="VARCHAR2" precision="16" />
<schema-alterColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_STATUS" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_MESSAGE" columnType="LONGVARCHAR" />
+ <schema-addColumn table="RHQ_BUNDLE_RES_DEP_HIST" column="AUDIT_MESSAGE" columnType="LONGVARCHAR" />
<schema-directSQL>
<statement desc="Creating RHQ_BUNDLE_RES_DEP_HIST foreign key relation to BUNDLE_DEPLOY">
ALTER TABLE RHQ_BUNDLE_RES_DEP_HIST
@@ -2763,9 +2763,9 @@ agent plugins">
</schema-directSQL>
</schemaSpec>
- <schemaSpec version="2.79">
- <schema-directSQL>
- <statement desc="Normalizing resource group descriptions">
+ <schemaSpec version="2.79">
+ <schema-directSQL>
+ <statement desc="Normalizing resource group descriptions">
UPDATE RHQ_RESOURCE_GROUP SET DESCRIPTION = NULL WHERE DESCRIPTION = ''
</statement>
</schema-directSQL>
@@ -2781,42 +2781,39 @@ agent plugins">
<statement desc="Creating primary key for RHQ_SAVED_SEARCH">
ALTER TABLE RHQ_SAVED_SEARCH ADD PRIMARY KEY ( ID )
</statement>
- </schema-directSQL>
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
- <schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="NAME" columnType="VARCHAR2" precision="200" />
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="PATTERN" columnType="VARCHAR2" precision="1000" />
- <schema-alterColumn table="RHQ_SAVED_SEARCH" column="PATTERN" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="PATTERN" columnType="VARCHAR2" precision="1000" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="PATTERN" nullable="FALSE" />
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="JPQL_TRANSLATION" columnType="VARCHAR2" precision="4000" />
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" nullable="FALSE" />
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="RESULT_COUNT" columnType="LONG" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="JPQL_TRANSLATION" columnType="VARCHAR2" precision="4000" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="RESULT_COUNT" columnType="LONG" />
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
- <schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
- <schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
<schema-directSQL>
<statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Platforms'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
- VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0,
-1, true)
+ VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, true)
</statement>
<statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Platforms'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
- VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0,
-1, 1)
+ VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, 1)
</statement>
</schema-directSQL>
<schema-directSQL>
<statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Servers'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
- VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1,
-true)
+ VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, true)
</statement>
<statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Servers'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
@@ -2842,16 +2839,14 @@ true)
</schema-directSQL>
</schemaSpec>
- <schemaSpec version="2.83">
- <!-- The following constraint change shortens the constraint name < 30 chars for Oracle. -->
- <schema-directSQL>
+ <schemaSpec version="2.83">
+ <!-- The following constraint change shortens the constraint name < 30 chars for Oracle. -->
+ <schema-directSQL>
<statement targetDBVendor="postgresql" desc="Dropping RHQ_SUBJECT_ROLE_LDAP_MAP constraint RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY.">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP DROP CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY;
</statement>
- <!-- There is no PL/SQL update for ora dbs as the problematic statement could never be created on oracle, so nothing to
-fix. -->
- <statement targetDBVendor="postgresql" desc="Creating new RHQ_SUBJECT_ROLE_LDAP_MAP constraint
-RHQ_SUBJECT_ROLE_LDAP_MAP_KEY">
+ <!-- There is no PL/SQL update for ora dbs as the problematic statement could never be created on oracle, so nothing to fix. -->
+ <statement targetDBVendor="postgresql" desc="Creating new RHQ_SUBJECT_ROLE_LDAP_MAP constraint RHQ_SUBJECT_ROLE_LDAP_MAP_KEY">
ALTER TABLE RHQ_SUBJECT_ROLE_LDAP_MAP
ADD CONSTRAINT RHQ_SUBJECT_ROLE_LDAP_MAP_KEY
PRIMARY KEY ( SUBJECT_ID, ROLE_ID )
commit a24312caf50dd9b4e8d1c62b7413d0abf529f8d3
Merge: 3b7062e... 28f22ea...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 21 12:26:59 2010 -0400
Merge branch 'gwt' into master-jay
commit 3b7062ede45de87b23e8bf38cac80ba87cfd455c
Merge: b0017e4... 57b3884...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 21 12:26:46 2010 -0400
Merge branch 'master' into master-jay
commit b0017e4bd7b2cc7bec5822db49c34b5798549efa
Merge: ec47389... caf7bf8...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 9 14:53:50 2010 -0400
Merge branch 'master' into master-jay
Conflicts:
etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
etc/eclipse-tools/maven/RHQ Maven Build - Dev Profile With DBSetup.launch
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
diff --cc etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
index 0000000,84ca310..5309e62
mode 000000,100644..100644
--- a/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
+++ b/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
@@@ -1,0 -1,11 +1,15 @@@
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+ <launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+ <stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/>
+ <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+ <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+ <listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+ </listAttribute>
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
++<<<<<<< HEAD:etc/eclipse-tools/maven/RHQ Maven Build - DBSetup.launch
++<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Ddbsetup install"/>
++=======
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Ddbsetup -Ddb=test install"/>
++>>>>>>> master:etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/core/dbutils}"/>
+ </launchConfiguration>
commit ec47389af05bfe5c8e80d80d6e09b14ea957a46c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 9 14:51:17 2010 -0400
LT commit
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup.launch b/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup.launch
index cbdb64f..a454234 100644
--- a/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup.launch
+++ b/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup.launch
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
-<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/>
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Ddbsetup install"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/core/dbutils}"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Ddbsetup install"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/core/dbutils}"/>
+</launchConfiguration>
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - Dev Profile With DBSetup.launch b/etc/eclipse-tools/maven/RHQ Maven Build - Dev Profile With DBSetup.launch
index 5e3141c..3839767 100644
--- a/etc/eclipse-tools/maven/RHQ Maven Build - Dev Profile With DBSetup.launch
+++ b/etc/eclipse-tools/maven/RHQ Maven Build - Dev Profile With DBSetup.launch
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
-<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/>
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Pdev -Ddbsetup install"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq}"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Pdev -Ddbsetup install"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq}"/>
+</launchConfiguration>
commit fea5226552ff985202c0d19583439566b20c572e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 9 14:49:18 2010 -0400
[BZ 580243]
Add the ability to manually add a resource to the remote API.
Add the typical annotations to the DiscoveryBossRemote methods for WS
enablement.
Remove extraneous annotations from WSMgrBean
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index 8864505..9c90dcb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -44,10 +44,10 @@ import org.jetbrains.annotations.Nullable;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.discovery.InvalidPluginConfigurationClientException;
import org.rhq.core.clientapi.server.discovery.InvalidInventoryReportException;
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
import org.rhq.core.domain.resource.Agent;
@@ -164,14 +164,14 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
return syncInfo;
}
-
@RequiredPermission(Permission.MANAGE_INVENTORY)
public Map<Resource, List<Resource>> getQueuedPlatformsAndServers(Subject user, PageControl pc) {
return getQueuedPlatformsAndServers(user, EnumSet.of(InventoryStatus.NEW), pc);
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
- public Map<Resource, List<Resource>> getQueuedPlatformsAndServers(Subject user, EnumSet<InventoryStatus> statuses, PageControl pc) {
+ public Map<Resource, List<Resource>> getQueuedPlatformsAndServers(Subject user, EnumSet<InventoryStatus> statuses,
+ PageControl pc) {
// pc.initDefaultOrderingField("res.ctime", PageOrdering.DESC); // this is set in getQueuedPlatforms,
// maps a platform to a list of child servers
@@ -188,7 +188,6 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
return queuedResources;
}
-
@RequiredPermission(Permission.MANAGE_INVENTORY)
@SuppressWarnings("unchecked")
public PageList<Resource> getQueuedPlatforms(Subject user, EnumSet<InventoryStatus> statuses, PageControl pc) {
@@ -301,6 +300,25 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
}
+ public Resource manuallyAddResource(Subject subject, int resourceTypeId, int parentResourceId,
+ Configuration pluginConfiguration) throws Exception {
+
+ Resource result = null;
+
+ try {
+ ResourceType resourceType = this.resourceTypeManager.getResourceTypeById(subject, resourceTypeId);
+ // the subsequent call to manuallyAddResource requires a detached ResourceType param so clear
+ entityManager.clear();
+ MergeResourceResponse response = manuallyAddResource(subject, resourceType, parentResourceId,
+ pluginConfiguration);
+ result = this.resourceManager.getResourceById(subject, response.getResourceId());
+ } catch (Exception e) {
+ throw new Exception(e.getMessage());
+ }
+
+ return result;
+ }
+
@NotNull
public MergeResourceResponse manuallyAddResource(Subject user, ResourceType resourceType, int parentResourceId,
Configuration pluginConfiguration) throws InvalidPluginConfigurationClientException, PluginContainerException {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java
index c29833f..01394b9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java
@@ -45,7 +45,7 @@ import org.rhq.core.domain.util.PageList;
* The boss interface to the discovery subsystem.
*/
@Local
-public interface DiscoveryBossLocal {
+public interface DiscoveryBossLocal extends DiscoveryBossRemote {
/**
* When agents send up results from their discovery components (which notifies the server about newly discovered
* resources), this method will eventually be called in order to process those inventory reports.
@@ -71,7 +71,6 @@ public interface DiscoveryBossLocal {
*/
Map<Resource, List<Resource>> getQueuedPlatformsAndServers(Subject user, PageControl pc);
-
/**
* Like the above method, but can find ignored, commited or both
* @param user
@@ -79,7 +78,8 @@ public interface DiscoveryBossLocal {
* @param pc
* @return
*/
- Map<Resource, List<Resource>> getQueuedPlatformsAndServers(Subject user, EnumSet<InventoryStatus> statuses, PageControl pc);
+ Map<Resource, List<Resource>> getQueuedPlatformsAndServers(Subject user, EnumSet<InventoryStatus> statuses,
+ PageControl pc);
/**
* This returns all platform resources that either have the given status themselves or one or more of their child
@@ -176,17 +176,4 @@ public interface DiscoveryBossLocal {
* <code>false</code> if the Resource was not in inventory
*/
boolean updateResourceVersion(int resourceId, String version);
-
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- //
- // The following are shared with the Remote Interface
- //
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
- void importResources(Subject subject, Integer[] resourceIds);
-
- void ignoreResources(Subject subject, Integer[] resourceIds);
-
- void unignoreResources(Subject subject, Integer[] resourceIds);
-
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossRemote.java
index 6a94ecf..fee8c5d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossRemote.java
@@ -19,19 +19,80 @@
package org.rhq.enterprise.server.discovery;
import javax.ejb.Remote;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.server.system.ServerVersion;
/**
* The remote boss interface to the discovery subsystem.
*/
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(targetNamespace = ServerVersion.namespace)
@Remote
public interface DiscoveryBossRemote {
- void importResources(Subject subject, Integer[] resourceIds);
+ /**
+ * Analogous to the GUI feature Import Resources in the auto discovery queue. Note, to query for
+ * Resources with a specific InnventryStatus see {@link ResourceManagerRemote.findResourcesByCriteria(ResourceCriteria)}
+ *
+ * @param subject
+ * @param resourceIds
+ */
+ void importResources( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceIds") Integer[] resourceIds);
+
+ /**
+ * Analogous to the GUI feature Ignore Resources in the auto discovery queue. Note, to query for
+ * Resources with a specific InnventryStatus see {@link ResourceManagerRemote.findResourcesByCriteria(ResourceCriteria)}
+ *
+ * @param subject
+ * @param resourceIds
+ */
+ void ignoreResources( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceIds") Integer[] resourceIds);
- void ignoreResources(Subject subject, Integer[] resourceIds);
+ /**
+ * Analogous to the GUI feature Unignore Resources in the auto discovery queue. Note, to query for
+ * Resources with a specific InnventryStatus see {@link ResourceManagerRemote.findResourcesByCriteria(ResourceCriteria)}
+ *
+ * @param subject
+ * @param resourceIds
+ */
+ void unignoreResources( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceIds") Integer[] resourceIds);
- void unignoreResources(Subject subject, Integer[] resourceIds);
+ /**
+ * Manually Add the resource of the specified type to inventory using the specified plugin configuration (i.e.
+ * connection properties). This will not only create a new resource, but it will also ensure the resource component
+ * is activated (and thus connects to the managed resource).
+ *
+ * @param subject the user making the request
+ * @param resourceTypeId the type of resource to be manually discovered
+ * @param parentResourceId the id of the resource that will be the parent of the manually discovered resource
+ * @param pluginConfiguration the properties that should be used to connect to the underlying managed resource
+ *
+ * @return The resource. Note that the resource may have existed already if given the provided pluginConfiguration
+ * leads to a previously defined resource.
+ *
+ * @throws Exception if connecting to the underlying managed resource failed due to invalid plugin configuration or
+ * if the manual discovery fails for any reason.
+ */
+ @NotNull
+ Resource manuallyAddResource( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceTypeId") int resourceTypeId, //
+ @WebParam(name = "parentResourceId") int parentResourceId, //
+ @WebParam(name = "pluginConfiguration") Configuration pluginConfiguration) //
+ throws Exception;
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 344b5d9..23f8a11 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
@@ -29,7 +29,6 @@ import java.util.Map;
import java.util.Set;
import javax.ejb.Stateless;
-import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -216,83 +215,73 @@ public class WebservicesManagerBean implements WebservicesRemote {
//ADVISORYMANAGER: BEGIN ------------------------------------------
- public Advisory createAdvisory(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") String advisory, @WebParam(name = "advisoryType") String advisoryType,
- @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException {
- return advisoryManager.createAdvisory(user, advisory, advisoryType, advisoryName);
+ public Advisory createAdvisory(Subject subject, String advisory, String advisoryType, String advisoryName)
+ throws AdvisoryException {
+ return advisoryManager.createAdvisory(subject, advisory, advisoryType, advisoryName);
}
- public CVE createCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cvename") String cvename)
- throws AdvisoryException {
- return advisoryManager.createCVE(user, cvename);
+ public CVE createCVE(Subject subject, String cvename) throws AdvisoryException {
+ return advisoryManager.createCVE(subject, cvename);
}
- public AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") Advisory advisory, @WebParam(name = "cve") CVE cve) throws AdvisoryException {
- return advisoryManager.createAdvisoryCVE(user, advisory, cve);
+ public AdvisoryCVE createAdvisoryCVE(Subject subject, Advisory advisory, CVE cve) throws AdvisoryException {
+ return advisoryManager.createAdvisoryCVE(subject, advisory, cve);
}
- public AdvisoryPackage createAdvisoryPackage(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") Advisory advisory, @WebParam(name = "pkg") PackageVersion pkg)
+ public AdvisoryPackage createAdvisoryPackage(Subject subject, Advisory advisory, PackageVersion pkg)
throws AdvisoryException {
- return advisoryManager.createAdvisoryPackage(user, advisory, pkg);
+ return advisoryManager.createAdvisoryPackage(subject, advisory, pkg);
}
- public CVE getCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
- return advisoryManager.getCVE(user, cveId);
+ public CVE getCVE(Subject subject, int cveId) {
+ return advisoryManager.getCVE(subject, cveId);
}
- public void deleteCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
- advisoryManager.deleteCVE(user, cveId);
+ public void deleteCVE(Subject subject, int cveId) {
+ advisoryManager.deleteCVE(subject, cveId);
}
- public void deleteAdvisoryCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "advId") int advId) {
- advisoryManager.deleteAdvisoryCVE(user, advId);
+ public void deleteAdvisoryCVE(Subject subject, int advId) {
+ advisoryManager.deleteAdvisoryCVE(subject, advId);
}
- public void deleteAdvisoryByAdvId(@WebParam(name = "subject") Subject subject, @WebParam(name = "advId") int advId) {
+ public void deleteAdvisoryByAdvId(Subject subject, int advId) {
advisoryManager.deleteAdvisoryByAdvId(subject, advId);
}
- public Advisory getAdvisoryByName(@WebParam(name = "advlabel") String advlabel) {
+ public Advisory getAdvisoryByName(String advlabel) {
return advisoryManager.getAdvisoryByName(advlabel);
}
- public List<AdvisoryPackage> findPackageByAdvisory(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId, @WebParam(name = "pc") PageControl pc) {
+ public List<AdvisoryPackage> findPackageByAdvisory(Subject subject, int advId, PageControl pc) {
return advisoryManager.findPackageByAdvisory(subject, advId, pc);
}
- public PackageVersion findPackageVersionByPkgId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "rpmName") String rpmName, @WebParam(name = "pc") PageControl pc) {
+ public PackageVersion findPackageVersionByPkgId(Subject subject, String rpmName, PageControl pc) {
return advisoryManager.findPackageVersionByPkgId(subject, rpmName, pc);
}
- public PageList<AdvisoryCVE> getAdvisoryCVEByAdvId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId, @WebParam(name = "pc") PageControl pc) {
+ public PageList<AdvisoryCVE> getAdvisoryCVEByAdvId(Subject subject, int advId, PageControl pc) {
return advisoryManager.getAdvisoryCVEByAdvId(subject, advId, pc);
}
- public List<AdvisoryBuglist> getAdvisoryBuglistByAdvId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId) {
+ public List<AdvisoryBuglist> getAdvisoryBuglistByAdvId(Subject subject, int advId) {
return advisoryManager.getAdvisoryBuglistByAdvId(subject, advId);
}
- public void deleteAdvisoryBugList(@WebParam(name = "subject") Subject overlord, @WebParam(name = "advId") int id) {
+ public void deleteAdvisoryBugList(Subject overlord, int id) {
advisoryManager.deleteAdvisoryBugList(overlord, id);
}
- public void deleteAdvisoryPackage(@WebParam(name = "subject") Subject user, @WebParam(name = "advId") int advId) {
- advisoryManager.deleteAdvisoryPackage(user, advId);
+ public void deleteAdvisoryPackage(Subject subject, int advId) {
+ advisoryManager.deleteAdvisoryPackage(subject, advId);
}
- public AdvisoryPackage findAdvisoryPackage(@WebParam(name = "subject") Subject overlord,
- @WebParam(name = "advId") int advId, @WebParam(name = "pkgVerId") int pkgVerId) {
+ public AdvisoryPackage findAdvisoryPackage(Subject overlord, int advId, int pkgVerId) {
return advisoryManager.findAdvisoryPackage(overlord, advId, pkgVerId);
}
- public AdvisoryBuglist getAdvisoryBuglist(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId, @WebParam(name = "buginfo") String buginfo) {
+ public AdvisoryBuglist getAdvisoryBuglist(Subject subject, int advId, String buginfo) {
return advisoryManager.getAdvisoryBuglist(subject, advId, buginfo);
}
@@ -646,8 +635,8 @@ public class WebservicesManagerBean implements WebservicesRemote {
return contentManager.getBackingPackageForResource(subject, resourceId);
}
- public byte[] getPackageBytes(Subject user, int resourceId, int installedPackageId) {
- return contentManager.getPackageBytes(user, resourceId, installedPackageId);
+ public byte[] getPackageBytes(Subject subject, int resourceId, int installedPackageId) {
+ return contentManager.getPackageBytes(subject, resourceId, installedPackageId);
}
//CONTENTMANAGER: END ----------------------------------
@@ -676,44 +665,45 @@ public class WebservicesManagerBean implements WebservicesRemote {
discoveryBoss.unignoreResources(subject, resourceIds);
}
+ public Resource manuallyAddResource(Subject subject, int resourceTypeId, int parentResourceId,
+ Configuration pluginConfiguration) throws Exception {
+ return discoveryBoss.manuallyAddResource(subject, resourceTypeId, parentResourceId, pluginConfiguration);
+ }
+
//DISCOVERYBOSS: END ------------------------------------
//DISTRIBUTION: START ------------------------------------
- public DistributionType getDistributionTypeByName(@WebParam(name = "name") String name) {
+ public DistributionType getDistributionTypeByName(String name) {
return distributionManager.getDistributionTypeByName(name);
}
- public void deleteDistributionFilesByDistId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "distid") int distid) {
+ public void deleteDistributionFilesByDistId(Subject subject, int distid) {
distributionManager.deleteDistributionByDistId(subject, distid);
}
- public List<DistributionFile> getDistributionFilesByDistId(@WebParam(name = "distid") int distid) {
+ public List<DistributionFile> getDistributionFilesByDistId(int distid) {
return distributionManager.getDistributionFilesByDistId(distid);
}
- public Distribution getDistributionByPath(@WebParam(name = "basepath") String basepath) {
+ public Distribution getDistributionByPath(String basepath) {
return distributionManager.getDistributionByPath(basepath);
}
- public Distribution getDistributionByLabel(@WebParam(name = "kslabel") String kslabel) {
+ public Distribution getDistributionByLabel(String kslabel) {
return distributionManager.getDistributionByLabel(kslabel);
}
- public void deleteDistributionByDistId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "distId") int distId) throws Exception {
+ public void deleteDistributionByDistId(Subject subject, int distId) throws Exception {
distributionManager.deleteDistributionByDistId(subject, distId);
}
- public void deleteDistributionTypeByName(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "name") String name) {
+ public void deleteDistributionTypeByName(Subject subject, String name) {
distributionManager.deleteDistributionTypeByName(subject, name);
}
- public Distribution createDistribution(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "kslabel") String kslabel, @WebParam(name = "basepath") String basepath,
- @WebParam(name = "disttype") DistributionType disttype) throws DistributionException {
+ public Distribution createDistribution(Subject subject, String kslabel, String basepath, DistributionType disttype)
+ throws DistributionException {
return distributionManager.createDistribution(subject, kslabel, basepath, disttype);
}
@@ -929,9 +919,9 @@ public class WebservicesManagerBean implements WebservicesRemote {
registrationManager.importPlatform(subject, resource);
}
- public void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
- throws RegistrationException {
- registrationManager.subscribePlatformToBaseRepo(user, platform, release, version, arch);
+ public void subscribePlatformToBaseRepo(Subject subject, Resource platform, String release, String version,
+ String arch) throws RegistrationException {
+ registrationManager.subscribePlatformToBaseRepo(subject, platform, release, version, arch);
}
public void createPackageBackedResource(Subject subject, int parentResourceId, int newResourceTypeId,
commit b547a54aba7436a604b14694517bad30bbda56fc
Merge: d803feb... 2e5f9e8...
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Apr 9 09:55:08 2010 +0200
BZ 577294 - fixing the nav tree high memory usage by limiting the number of views stored in users' sessions as well as minimizing the size of the tree stored in the session.
commit 2e5f9e820a93a775e180169fd23badd1f807fe52
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Apr 8 15:25:35 2010 +0200
Increasing the max number of views in session to 2.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
index 1b9a873..4dac9ca 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
@@ -41,11 +41,11 @@
<!-- Making sure we don't overload the session with too much data. -->
<context-param>
<param-name>com.sun.faces.numberOfViewsInSession</param-name>
- <param-value>1</param-value>
+ <param-value>2</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfLogicalViews</param-name>
- <param-value>1</param-value>
+ <param-value>2</param-value>
</context-param>
<!-- flags for debugging during development -->
commit d2ca0267995044dbff1eee2ae3ca650b2cbbdec1
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Apr 6 16:52:56 2010 +0200
Refactoring out the construct() methods from the *Flyweight types into the cache and making th flyweights publicly constructible. This enables reuse of the flyweights but still encourages the use of the proper methods to put the data into the cache.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/FlyweightCache.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/FlyweightCache.java
index 801836e..a68b1bf 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/FlyweightCache.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/FlyweightCache.java
@@ -26,9 +26,20 @@ package org.rhq.core.domain.resource.flyweight;
import java.util.HashMap;
import java.util.Map;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.ResourceAvailability;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceSubCategory;
+import org.rhq.core.domain.resource.ResourceType;
+
/**
* A helper object to hold the cached instances of the flyweights.
* The keys in the maps are ids, values are the objects themselves.
+ * <p>
+ * The <code>construct*</code> methods are provided to correctly initialize
+ * instances of the flyweight types in the cache instance from a minimal set
+ * of data.
*
* @author Lukas Krejci
*/
@@ -48,5 +59,195 @@ public class FlyweightCache {
public Map<Integer, ResourceSubCategoryFlyweight> getSubCategories() {
return subCategories;
+ }
+
+ /**
+ * @see #constructResource(int, String, String, Integer, int, AvailabilityType)
+ *
+ * @param original the resource
+ * @return the initialized resource flyweight
+ */
+ public ResourceFlyweight constructResource(Resource original) {
+ int id = original.getId();
+ String name = original.getName();
+ String uuid = original.getUuid();
+ String resourceKey = original.getResourceKey();
+ Resource parent = original.getParentResource();
+ ResourceType type = original.getResourceType();
+ ResourceAvailability avail = original.getCurrentAvailability();
+
+ return constructResource(id, name, uuid, resourceKey, parent != null ? parent.getId() : null, type.getId(),
+ avail != null ? avail.getAvailabilityType() : null);
+ }
+
+ /**
+ * Constructs a fully initialized instance of the resource flyweight.
+ * The resource type, sub-category and parent are looked up
+ * in this cache instance. If not found, new instances are created and added
+ * to this cache.
+ * <p>
+ * Note that if the parentId is not null and not found in this cache, a new flyweight
+ * is created for the parent, initialized only with the id.
+ * <p>
+ * The type is supposed to exist in this cache already. If it doesn't, no type is assigned
+ * to the returned resource flyweight.
+ * <p>
+ * If a corresponding flyweight for the provided resource id is already found in this cache,
+ * it is refreshed with the data provided to this call.
+ *
+ * @param id the resource id
+ * @param name the resource name
+ * @param uuid the resource uuid
+ * @param resourceKey the resource key
+ * @param parentId the id of the parent resource
+ * @param typeId the id of the resource type
+ * @param currentAvailability the availability of the resource
+ * @return the initialized resource flyweight
+ */
+ public ResourceFlyweight constructResource(int id, String name, String uuid, String resourceKey, Integer parentId,
+ int typeId, AvailabilityType currentAvailability) {
+
+ ResourceFlyweight ret = getResources().get(id);
+ if (ret == null) {
+ ret = new ResourceFlyweight();
+ getResources().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+ ret.setUuid(uuid);
+ ret.setResourceKey(resourceKey);
+ ret.setCurrentAvailability(new ResourceAvailabilityFlyweight(ret, currentAvailability));
+
+ if (parentId != null) {
+ ResourceFlyweight parent = getResources().get(parentId);
+ if (parent == null) {
+ parent = constructResource(parentId, null, null, null, null, -1, null);
+ }
+ parent.getChildResources().add(ret);
+ ret.setParentResource(parent);
+ } else {
+ ResourceFlyweight previousParent = ret.getParentResource();
+ if (previousParent != null) {
+ previousParent.getChildResources().remove(ret);
+ }
+ ret.setParentResource(null);
+ }
+
+ ret.setResourceType(getResourceTypes().get(typeId));
+
+ return ret;
+ }
+
+ /**
+ * @see #constructSubCategory(int, String, Integer, FlyweightCache)
+ *
+ * @param original
+ * @return a fully initialized resource sub category flyweight
+ */
+ public ResourceSubCategoryFlyweight constructSubCategory(ResourceSubCategory original) {
+ int id = original.getId();
+ String name = original.getName();
+ ResourceSubCategory parent = original.getParentSubCategory();
+ Integer parentId = parent != null ? parent.getId() : null;
+ String parentName = parent != null ? parent.getName() : null;
+
+ return constructSubCategory(id, name, parentId, parentName);
+ }
+
+ /**
+ * An existing sub category is first looked up in this cache. If there already is a flyweight
+ * instance in this cache, its properties are updated with the provided values, otherwise a new instance
+ * is put in this cache.
+ * <p>
+ * If parent sub category id is not null but a corresponding flyweight doesn't exist in this cache yet,
+ * a new instance is put in this cache initialized with the parent id and name.
+ *
+ * @param id
+ * @param name
+ * @param parentSubCategoryId
+ * @param parentSubCategoryName
+ * @param cache
+ * @return a fully initialized resource sub category flyweight
+ */
+ public ResourceSubCategoryFlyweight constructSubCategory(int id, String name, Integer parentSubCategoryId,
+ String parentSubCategoryName) {
+ ResourceSubCategoryFlyweight ret = getSubCategories().get(id);
+
+ if (ret == null) {
+ ret = new ResourceSubCategoryFlyweight();
+ getSubCategories().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+
+ if (parentSubCategoryId != null) {
+ ResourceSubCategoryFlyweight parent = getSubCategories().get(parentSubCategoryId);
+ if (parent == null) {
+ parent = constructSubCategory(parentSubCategoryId, parentSubCategoryName, null, null);
+ }
+ ret.setParentSubCategory(parent);
+ } else {
+ ret.setParentSubCategory(null);
+ }
+
+ return ret;
}
+
+ /**
+ * @see #construct(int, String, String, ResourceCategory, Integer, FlyweightCache)
+ *
+ * @param original the original resource type
+ * @return a fully initialized resource type flyweight
+ */
+ public ResourceTypeFlyweight constructResourceType(ResourceType original) {
+ int id = original.getId();
+ String name = original.getName();
+ String plugin = original.getPlugin();
+ ResourceCategory category = original.getCategory();
+ ResourceSubCategory subCategory = original.getSubCategory();
+
+ return constructResourceType(id, name, plugin, category, subCategory != null ? subCategory.getId() : null);
+ }
+
+ /**
+ * Constructs a fully initialized resource type flyweight.
+ * If a flyweight instance is found in the cache under the provided id, a new instance
+ * is *NOT* created but rather the properties of that existing instance are updated with
+ * the provided values.
+ * <p>
+ * The subcategory is supposed to exist in the cache. If it doesn't the subcategory of the
+ * returned resource type flyweight is set to null.
+ *
+ * @param id the resource type id
+ * @param name the resource type name
+ * @param plugin the resource type plugin
+ * @param category the resource type category
+ * @param subCategory the id of the resource type sub category or null
+ * @param cache the flyweight cache
+ * @return
+ */
+ public ResourceTypeFlyweight constructResourceType(int id, String name, String plugin, ResourceCategory category,
+ Integer subCategory) {
+
+ ResourceTypeFlyweight ret = getResourceTypes().get(id);
+
+ if (ret == null) {
+ ret = new ResourceTypeFlyweight();
+ getResourceTypes().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+ ret.setPlugin(plugin);
+ ret.setCategory(category);
+ if (subCategory != null) {
+ ret.setSubCategory(getSubCategories().get(subCategory));
+ } else {
+ ret.setSubCategory(null);
+ }
+
+ return ret;
+ }
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceFlyweight.java
index c56c7eb..219c2b3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceFlyweight.java
@@ -27,11 +27,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.ResourceAvailability;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-
/**
* Contains only a minimal subset of properties of a Resource that are needed for display
* purposes.
@@ -52,87 +47,7 @@ public class ResourceFlyweight implements Serializable {
private boolean locked;
private List<ResourceFlyweight> childResources;
- /**
- * @see #construct(int, String, String, Integer, int, AvailabilityType, FlyweightCache)
- *
- * @param original the resource
- * @param cache the cached flyweights
- * @return the initialized resource flyweight
- */
- public static ResourceFlyweight construct(Resource original, FlyweightCache cache) {
- int id = original.getId();
- String name = original.getName();
- String uuid = original.getUuid();
- String resourceKey = original.getResourceKey();
- Resource parent = original.getParentResource();
- ResourceType type = original.getResourceType();
- ResourceAvailability avail = original.getCurrentAvailability();
-
- return construct(id, name, uuid, resourceKey, parent != null ? parent.getId() : null, type.getId(),
- avail != null ? avail.getAvailabilityType() : null, cache);
- }
-
- /**
- * Constructs a fully initialized instance of the resource flyweight.
- * The resource type, sub-category and parent are looked up
- * in the provided cache. If not found, new instances are created and added
- * to the cache.
- * <p>
- * Note that if the parentId is not null and not found in the cache, a new flyweight
- * is created for the parent, initialized only with the id.
- * <p>
- * The type is supposed to exist in the cache already. If it doesn't, no type is assigned
- * to the returned resource flyweight.
- * <p>
- * If a corresponding flyweight for the provided resource id is already found in the cache,
- * it is refreshed with the data provided to this call.
- *
- * @param id the resource id
- * @param name the resource name
- * @param uuid the resoure uuid
- * @param resourceKey the resource key
- * @param parentId the id of the parent resource
- * @param typeId the id of the resource type
- * @param currentAvailability the availability of the resource
- * @param cache the cached flyweights
- * @return
- */
- public static ResourceFlyweight construct(int id, String name, String uuid, String resourceKey, Integer parentId,
- int typeId, AvailabilityType currentAvailability, FlyweightCache cache) {
-
- ResourceFlyweight ret = cache.getResources().get(id);
- if (ret == null) {
- ret = new ResourceFlyweight();
- cache.getResources().put(id, ret);
- }
-
- ret.setId(id);
- ret.setName(name);
- ret.setUuid(uuid);
- ret.setResourceKey(resourceKey);
- ret.setCurrentAvailability(new ResourceAvailabilityFlyweight(ret, currentAvailability));
-
- if (parentId != null) {
- ResourceFlyweight parent = cache.getResources().get(parentId);
- if (parent == null) {
- parent = construct(parentId, null, null, null, null, -1, null, cache);
- }
- parent.getChildResources().add(ret);
- ret.setParentResource(parent);
- } else {
- ResourceFlyweight previousParent = ret.getParentResource();
- if (previousParent != null) {
- previousParent.getChildResources().remove(ret);
- }
- ret.setParentResource(null);
- }
-
- ret.setResourceType(cache.getResourceTypes().get(typeId));
-
- return ret;
- }
-
- private ResourceFlyweight() {
+ public ResourceFlyweight() {
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceSubCategoryFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceSubCategoryFlyweight.java
index 530cda2..b30880f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceSubCategoryFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceSubCategoryFlyweight.java
@@ -25,8 +25,6 @@ package org.rhq.core.domain.resource.flyweight;
import java.io.Serializable;
-import org.rhq.core.domain.resource.ResourceSubCategory;
-
/**
* Flyweight representation of a resource sub category. Only id, name and parent are preserved.
*
@@ -40,64 +38,7 @@ public class ResourceSubCategoryFlyweight implements Serializable {
private String name;
private ResourceSubCategoryFlyweight parentSubCategory;
- /**
- * @see #construct(int, String, Integer, FlyweightCache)
- *
- * @param original
- * @param cache
- * @return
- */
- public static ResourceSubCategoryFlyweight construct(ResourceSubCategory original, FlyweightCache cache) {
- int id = original.getId();
- String name = original.getName();
- ResourceSubCategory parent = original.getParentSubCategory();
- Integer parentId = parent != null ? parent.getId() : null;
- String parentName = parent != null ? parent.getName() : null;
-
- return construct(id, name, parentId, parentName, cache);
- }
-
- /**
- * An existing sub category is first looked up in the cache. If there already is a flyweight
- * instance in the cache, its properties are updated with the provided values, otherwise a new instance
- * is put in the cache.
- * <p>
- * If parent sub category id is not null but a corresponding flyweight doesn't exist in the cache yet,
- * a new instance is put in the cache initialized with the parent id and name.
- *
- * @param id
- * @param name
- * @param parentSubCategoryId
- * @param parentSubCategoryName
- * @param cache
- * @return
- */
- public static ResourceSubCategoryFlyweight construct(int id, String name, Integer parentSubCategoryId,
- String parentSubCategoryName, FlyweightCache cache) {
- ResourceSubCategoryFlyweight ret = cache.getSubCategories().get(id);
-
- if (ret == null) {
- ret = new ResourceSubCategoryFlyweight();
- cache.getSubCategories().put(id, ret);
- }
-
- ret.setId(id);
- ret.setName(name);
-
- if (parentSubCategoryId != null) {
- ResourceSubCategoryFlyweight parent = cache.getSubCategories().get(parentSubCategoryId);
- if (parent == null) {
- parent = construct(parentSubCategoryId, parentSubCategoryName, null, null, cache);
- }
- ret.setParentSubCategory(parent);
- } else {
- ret.setParentSubCategory(null);
- }
-
- return ret;
- }
-
- private ResourceSubCategoryFlyweight() {
+ public ResourceSubCategoryFlyweight() {
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceTypeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceTypeFlyweight.java
index 76c4a30..3accee8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceTypeFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceTypeFlyweight.java
@@ -26,8 +26,6 @@ package org.rhq.core.domain.resource.flyweight;
import java.io.Serializable;
import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceSubCategory;
-import org.rhq.core.domain.resource.ResourceType;
/**
* A flyweight representation of the resource type intended for the display purposes.
@@ -44,64 +42,7 @@ public class ResourceTypeFlyweight implements Serializable {
private ResourceCategory category;
private ResourceSubCategoryFlyweight subCategory;
- /**
- * @see #construct(int, String, String, ResourceCategory, Integer, FlyweightCache)
- *
- * @param original the original resource type
- * @param cache the cache of flyweights
- * @return a fully initialized resource type flyweight
- */
- public static ResourceTypeFlyweight construct(ResourceType original, FlyweightCache cache) {
- int id = original.getId();
- String name = original.getName();
- String plugin = original.getPlugin();
- ResourceCategory category = original.getCategory();
- ResourceSubCategory subCategory = original.getSubCategory();
-
- return construct(id, name, plugin, category, subCategory != null ? subCategory.getId() : null, cache);
- }
-
- /**
- * Constructs a fully initialized resource type flyweight.
- * If a flyweight instance is found in the cache under the provided id, a new instance
- * is *NOT* created but rather the properties of that existing instance are updated with
- * the provided values.
- * <p>
- * The subcategory is supposed to exist in the cache. If it doesn't the subcategory of the
- * returned resource type flyweight is set to null.
- *
- * @param id the resource type id
- * @param name the resource type name
- * @param plugin the resource type plugin
- * @param category the resource type category
- * @param subCategory the id of the resource type sub category or null
- * @param cache the flyweight cache
- * @return
- */
- public static ResourceTypeFlyweight construct(int id, String name, String plugin, ResourceCategory category,
- Integer subCategory, FlyweightCache cache) {
-
- ResourceTypeFlyweight ret = cache.getResourceTypes().get(id);
-
- if (ret == null) {
- ret = new ResourceTypeFlyweight();
- cache.getResourceTypes().put(id, ret);
- }
-
- ret.setId(id);
- ret.setName(name);
- ret.setPlugin(plugin);
- ret.setCategory(category);
- if (subCategory != null) {
- ret.setSubCategory(cache.getSubCategories().get(subCategory));
- } else {
- ret.setSubCategory(null);
- }
-
- return ret;
- }
-
- private ResourceTypeFlyweight() {
+ public ResourceTypeFlyweight() {
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index c57238c..0d3e2a9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -1858,14 +1858,14 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
if (subCategoryId != null) {
//we don't need the reference to the sub category here. We need it just in the cache.
- ResourceSubCategoryFlyweight.construct(subCategoryId, subCategoryName, parentSubCategoryId, parentSubCategoryName, flyweightCache);
+ flyweightCache.constructSubCategory(subCategoryId, subCategoryName, parentSubCategoryId, parentSubCategoryName);
}
//we don't need the resource type reference here, only in the cache
- ResourceTypeFlyweight.construct(typeId, typeName, typePlugin, typeCategory, subCategoryId, flyweightCache);
+ flyweightCache.constructResourceType(typeId, typeName, typePlugin, typeCategory, subCategoryId);
- ResourceFlyweight resourceFlyweight = ResourceFlyweight.construct(
- resourceId, resourceName, resourceUuid, resourceKey, parentId, typeId, availType, flyweightCache);
+ ResourceFlyweight resourceFlyweight = flyweightCache.constructResource(
+ resourceId, resourceName, resourceUuid, resourceKey, parentId, typeId, availType);
resources.add(resourceFlyweight);
}
commit 694c0003ee651bf82c1030e2ee3141e1370ac9c1
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Apr 2 21:30:13 2010 +0200
removing stale imports... it now even compiles! :)
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
index 184bfc5..9d08693 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
@@ -32,14 +32,10 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceSubCategory;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.LockedResource;
import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
import org.rhq.core.domain.resource.flyweight.ResourceSubCategoryFlyweight;
import org.rhq.core.domain.resource.flyweight.ResourceTypeFlyweight;
-import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
index d067061..a57100c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
@@ -32,13 +32,10 @@ import org.richfaces.component.state.TreeStateAdvisor;
import org.richfaces.model.TreeRowKey;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.composite.LockedResource;
import org.rhq.core.domain.resource.composite.ResourceFacets;
import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
-import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
commit 21b3ae036219dacde0d74c7cd4126820c99d8ceb
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Apr 2 15:16:14 2010 +0200
Not sure if it ever happens that a group tree node directly contains a resource, but the UI is suggesting that so add that possibility to the nodeType property.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
index ec1e2dc..1f53103 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.navigation.group;
import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.util.sort.HumaneStringComparator;
import org.rhq.enterprise.server.resource.cluster.ClusterKey;
@@ -91,6 +92,8 @@ public class ResourceGroupTreeNode implements Comparable<ResourceGroupTreeNode>
return "ResourceGroup";
} else if (level instanceof AutoGroupCompositeFlyweight) {
return "AutoGroupComposite";
+ } else if (level instanceof ResourceFlyweight) {
+ return "Resource";
} else {
return level.getClass().getSimpleName();
}
commit 47969f17b9fdb3d3efcb0ef0cda2442249af47c2
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Apr 2 12:27:35 2010 +0200
changing the package of the flyweight classes from ...domain.resource.hierarchy to ...domain.resource.flyweight
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java
new file mode 100644
index 0000000..b779a63
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java
@@ -0,0 +1,162 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.flyweight;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+
+/**
+ * @see AutoGroupComposite
+ *
+ * @author Lukas Krejci
+ */
+public class AutoGroupCompositeFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Double availability;
+ private ResourceTypeFlyweight resourceType;
+ private ResourceSubCategoryFlyweight subcategory;
+ private long memberCount;
+ private int depth;
+ private boolean mainResource;
+ private ResourceFlyweight parentResource;
+ private String name;
+
+ private List<ResourceFlyweight> resources;
+
+ public AutoGroupCompositeFlyweight(AutoGroupCompositeFlyweight other) {
+ super();
+
+ if (other == null) {
+ return; // Throw exception?
+ }
+
+ this.availability = other.availability;
+ this.resourceType = other.resourceType;
+ this.subcategory = other.subcategory;
+ this.memberCount = other.memberCount;
+ this.depth = other.depth;
+ this.mainResource = other.mainResource;
+ this.parentResource = other.parentResource;
+ this.resources = new ArrayList<ResourceFlyweight>();
+ if (other.resources != null) {
+ this.resources.addAll(other.resources);
+ }
+ this.name = other.name;
+ }
+
+ public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
+ ResourceTypeFlyweight resourceType, long memberCount) {
+ this(availability, parentResource, resourceType, memberCount, false);
+ }
+
+ public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
+ ResourceTypeFlyweight resourceType, long memberCount, boolean isDuplicateResourceTypeName) {
+ this.availability = availability;
+ this.parentResource = parentResource;
+ this.resourceType = resourceType;
+ this.memberCount = memberCount;
+ if (isDuplicateResourceTypeName) {
+ this.name = String.format("%s (%s plugin)", this.resourceType.getName(), this.resourceType.getPlugin());
+ } else {
+ this.name = this.resourceType.getName();
+ }
+ }
+
+ public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
+ ResourceSubCategoryFlyweight subcategory, long memberCount) {
+ this.availability = availability;
+ this.parentResource = parentResource;
+ this.subcategory = subcategory;
+ this.memberCount = memberCount;
+ this.name = this.subcategory.getName();
+ }
+
+ public Double getAvailability() {
+ return availability;
+ }
+
+ public ResourceTypeFlyweight getResourceType() {
+ return resourceType;
+ }
+
+ public long getMemberCount() {
+ return memberCount;
+ }
+
+ public void setResources(List<ResourceFlyweight> resources) {
+ this.resources = resources;
+ }
+
+ public ResourceSubCategoryFlyweight getSubcategory() {
+ return subcategory;
+ }
+
+ public ResourceFlyweight getParentResource() {
+ return parentResource;
+ }
+
+ public void setParentResource(ResourceFlyweight parentResource) {
+ this.parentResource = parentResource;
+ }
+
+ public List<ResourceFlyweight> getResources() {
+ return resources;
+ }
+
+ public int getDepth() {
+ return depth;
+ }
+
+ public void setDepth(int depth) {
+ this.depth = depth;
+ }
+
+ public int increaseDepth(int increment) {
+ depth += increment;
+ return depth;
+ }
+
+ public boolean isMainResource() {
+ return mainResource;
+ }
+
+ public void setMainResource(boolean mainResource) {
+ this.mainResource = mainResource;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return "AutoGroupCompositeFlyweight[" + ((this.resourceType != null) ? "Resource: " : "Subcategory: ")
+ + "name=" + this.name + ", members=" + this.memberCount + ", availability=" + this.availability + "]";
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/FlyweightCache.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/FlyweightCache.java
new file mode 100644
index 0000000..801836e
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/FlyweightCache.java
@@ -0,0 +1,52 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.flyweight;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A helper object to hold the cached instances of the flyweights.
+ * The keys in the maps are ids, values are the objects themselves.
+ *
+ * @author Lukas Krejci
+ */
+public class FlyweightCache {
+
+ private Map<Integer, ResourceFlyweight> resources = new HashMap<Integer, ResourceFlyweight>();
+ private Map<Integer, ResourceTypeFlyweight> resourceTypes = new HashMap<Integer, ResourceTypeFlyweight>();
+ private Map<Integer, ResourceSubCategoryFlyweight> subCategories = new HashMap<Integer, ResourceSubCategoryFlyweight>();
+
+ public Map<Integer, ResourceFlyweight> getResources() {
+ return resources;
+ }
+
+ public Map<Integer, ResourceTypeFlyweight> getResourceTypes() {
+ return resourceTypes;
+ }
+
+ public Map<Integer, ResourceSubCategoryFlyweight> getSubCategories() {
+ return subCategories;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceAvailabilityFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceAvailabilityFlyweight.java
new file mode 100644
index 0000000..8965304
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceAvailabilityFlyweight.java
@@ -0,0 +1,111 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.flyweight;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.ResourceAvailability;
+
+/**
+ * This is basically a copy of {@link ResourceAvailability} class, but is linked to the
+ * {@link ResourceFlyweight} instead of Resource. This enables us to retain the same API
+ * for the flyweights as for the original domain entities.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceAvailabilityFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private ResourceFlyweight resource;
+ private int resourceId;
+ private AvailabilityType availabilityType;
+
+ public ResourceAvailabilityFlyweight(ResourceFlyweight resource, AvailabilityType type) {
+ this.resource = resource;
+ this.resourceId = resource.getId();
+ this.availabilityType = type;
+ }
+
+ public ResourceFlyweight getResource() {
+ return resource;
+ }
+
+ public void setResource(ResourceFlyweight resource) {
+ this.resource = resource;
+ }
+
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(int resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public AvailabilityType getAvailabilityType() {
+ return availabilityType;
+ }
+
+ public void setAvailabilityType(AvailabilityType availabilityType) {
+ this.availabilityType = availabilityType;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + ((availabilityType == null) ? 0 : availabilityType.hashCode());
+ result = (prime * result) + resourceId;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null || !(obj instanceof ResourceAvailabilityFlyweight)) {
+ return false;
+ }
+
+ final ResourceAvailabilityFlyweight other = (ResourceAvailabilityFlyweight) obj;
+
+ if (resourceId != other.resourceId) {
+ return false;
+ }
+
+ if (availabilityType == null) {
+ if (other.availabilityType != null) {
+ return false;
+ }
+ } else if (!availabilityType.equals(other.availabilityType)) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceFlyweight.java
new file mode 100644
index 0000000..c56c7eb
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceFlyweight.java
@@ -0,0 +1,233 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.flyweight;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.ResourceAvailability;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ * Contains only a minimal subset of properties of a Resource that are needed for display
+ * purposes.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private ResourceFlyweight parentResource;
+ private String uuid;
+ private int id;
+ private String name;
+ private String resourceKey;
+ private ResourceAvailabilityFlyweight currentAvailability;
+ private ResourceTypeFlyweight resourceType;
+ private boolean locked;
+ private List<ResourceFlyweight> childResources;
+
+ /**
+ * @see #construct(int, String, String, Integer, int, AvailabilityType, FlyweightCache)
+ *
+ * @param original the resource
+ * @param cache the cached flyweights
+ * @return the initialized resource flyweight
+ */
+ public static ResourceFlyweight construct(Resource original, FlyweightCache cache) {
+ int id = original.getId();
+ String name = original.getName();
+ String uuid = original.getUuid();
+ String resourceKey = original.getResourceKey();
+ Resource parent = original.getParentResource();
+ ResourceType type = original.getResourceType();
+ ResourceAvailability avail = original.getCurrentAvailability();
+
+ return construct(id, name, uuid, resourceKey, parent != null ? parent.getId() : null, type.getId(),
+ avail != null ? avail.getAvailabilityType() : null, cache);
+ }
+
+ /**
+ * Constructs a fully initialized instance of the resource flyweight.
+ * The resource type, sub-category and parent are looked up
+ * in the provided cache. If not found, new instances are created and added
+ * to the cache.
+ * <p>
+ * Note that if the parentId is not null and not found in the cache, a new flyweight
+ * is created for the parent, initialized only with the id.
+ * <p>
+ * The type is supposed to exist in the cache already. If it doesn't, no type is assigned
+ * to the returned resource flyweight.
+ * <p>
+ * If a corresponding flyweight for the provided resource id is already found in the cache,
+ * it is refreshed with the data provided to this call.
+ *
+ * @param id the resource id
+ * @param name the resource name
+ * @param uuid the resoure uuid
+ * @param resourceKey the resource key
+ * @param parentId the id of the parent resource
+ * @param typeId the id of the resource type
+ * @param currentAvailability the availability of the resource
+ * @param cache the cached flyweights
+ * @return
+ */
+ public static ResourceFlyweight construct(int id, String name, String uuid, String resourceKey, Integer parentId,
+ int typeId, AvailabilityType currentAvailability, FlyweightCache cache) {
+
+ ResourceFlyweight ret = cache.getResources().get(id);
+ if (ret == null) {
+ ret = new ResourceFlyweight();
+ cache.getResources().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+ ret.setUuid(uuid);
+ ret.setResourceKey(resourceKey);
+ ret.setCurrentAvailability(new ResourceAvailabilityFlyweight(ret, currentAvailability));
+
+ if (parentId != null) {
+ ResourceFlyweight parent = cache.getResources().get(parentId);
+ if (parent == null) {
+ parent = construct(parentId, null, null, null, null, -1, null, cache);
+ }
+ parent.getChildResources().add(ret);
+ ret.setParentResource(parent);
+ } else {
+ ResourceFlyweight previousParent = ret.getParentResource();
+ if (previousParent != null) {
+ previousParent.getChildResources().remove(ret);
+ }
+ ret.setParentResource(null);
+ }
+
+ ret.setResourceType(cache.getResourceTypes().get(typeId));
+
+ return ret;
+ }
+
+ private ResourceFlyweight() {
+
+ }
+
+ public ResourceFlyweight getParentResource() {
+ return parentResource;
+ }
+
+ public void setParentResource(ResourceFlyweight parent) {
+ this.parentResource = parent;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getResourceKey() {
+ return resourceKey;
+ }
+
+ public void setResourceKey(String resourceKey) {
+ this.resourceKey = resourceKey;
+ }
+
+ public ResourceAvailabilityFlyweight getCurrentAvailability() {
+ return currentAvailability;
+ }
+
+ public void setCurrentAvailability(ResourceAvailabilityFlyweight currentAvailability) {
+ this.currentAvailability = currentAvailability;
+ }
+
+ public ResourceTypeFlyweight getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(ResourceTypeFlyweight resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public List<ResourceFlyweight> getChildResources() {
+ if (childResources == null) {
+ childResources = new ArrayList<ResourceFlyweight>();
+ }
+ return childResources;
+ }
+
+ public boolean isLocked() {
+ return locked;
+ }
+
+ public void setLocked(boolean locked) {
+ this.locked = locked;
+ }
+
+ @Override
+ public int hashCode() {
+ return ((uuid != null) ? uuid.hashCode() : 0);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if ((o == null) || !(o instanceof ResourceFlyweight)) {
+ return false;
+ }
+
+ final ResourceFlyweight resource = (ResourceFlyweight) o;
+
+ if ((uuid != null) ? (!uuid.equals(resource.uuid)) : (resource.uuid != null)) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceSubCategoryFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceSubCategoryFlyweight.java
new file mode 100644
index 0000000..530cda2
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceSubCategoryFlyweight.java
@@ -0,0 +1,154 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.flyweight;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.resource.ResourceSubCategory;
+
+/**
+ * Flyweight representation of a resource sub category. Only id, name and parent are preserved.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceSubCategoryFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int id;
+ private String name;
+ private ResourceSubCategoryFlyweight parentSubCategory;
+
+ /**
+ * @see #construct(int, String, Integer, FlyweightCache)
+ *
+ * @param original
+ * @param cache
+ * @return
+ */
+ public static ResourceSubCategoryFlyweight construct(ResourceSubCategory original, FlyweightCache cache) {
+ int id = original.getId();
+ String name = original.getName();
+ ResourceSubCategory parent = original.getParentSubCategory();
+ Integer parentId = parent != null ? parent.getId() : null;
+ String parentName = parent != null ? parent.getName() : null;
+
+ return construct(id, name, parentId, parentName, cache);
+ }
+
+ /**
+ * An existing sub category is first looked up in the cache. If there already is a flyweight
+ * instance in the cache, its properties are updated with the provided values, otherwise a new instance
+ * is put in the cache.
+ * <p>
+ * If parent sub category id is not null but a corresponding flyweight doesn't exist in the cache yet,
+ * a new instance is put in the cache initialized with the parent id and name.
+ *
+ * @param id
+ * @param name
+ * @param parentSubCategoryId
+ * @param parentSubCategoryName
+ * @param cache
+ * @return
+ */
+ public static ResourceSubCategoryFlyweight construct(int id, String name, Integer parentSubCategoryId,
+ String parentSubCategoryName, FlyweightCache cache) {
+ ResourceSubCategoryFlyweight ret = cache.getSubCategories().get(id);
+
+ if (ret == null) {
+ ret = new ResourceSubCategoryFlyweight();
+ cache.getSubCategories().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+
+ if (parentSubCategoryId != null) {
+ ResourceSubCategoryFlyweight parent = cache.getSubCategories().get(parentSubCategoryId);
+ if (parent == null) {
+ parent = construct(parentSubCategoryId, parentSubCategoryName, null, null, cache);
+ }
+ ret.setParentSubCategory(parent);
+ } else {
+ ret.setParentSubCategory(null);
+ }
+
+ return ret;
+ }
+
+ private ResourceSubCategoryFlyweight() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ResourceSubCategoryFlyweight getParentSubCategory() {
+ return parentSubCategory;
+ }
+
+ public void setParentSubCategory(ResourceSubCategoryFlyweight parentSubCategory) {
+ this.parentSubCategory = parentSubCategory;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof ResourceSubCategoryFlyweight)) {
+ return false;
+ }
+
+ ResourceSubCategoryFlyweight that = (ResourceSubCategoryFlyweight) o;
+
+ if (!name.equals(that.getName())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ result = name.hashCode();
+
+ return result;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceTypeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceTypeFlyweight.java
new file mode 100644
index 0000000..76c4a30
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/ResourceTypeFlyweight.java
@@ -0,0 +1,173 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.flyweight;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceSubCategory;
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ * A flyweight representation of the resource type intended for the display purposes.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceTypeFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int id;
+ private String name;
+ private String plugin;
+ private ResourceCategory category;
+ private ResourceSubCategoryFlyweight subCategory;
+
+ /**
+ * @see #construct(int, String, String, ResourceCategory, Integer, FlyweightCache)
+ *
+ * @param original the original resource type
+ * @param cache the cache of flyweights
+ * @return a fully initialized resource type flyweight
+ */
+ public static ResourceTypeFlyweight construct(ResourceType original, FlyweightCache cache) {
+ int id = original.getId();
+ String name = original.getName();
+ String plugin = original.getPlugin();
+ ResourceCategory category = original.getCategory();
+ ResourceSubCategory subCategory = original.getSubCategory();
+
+ return construct(id, name, plugin, category, subCategory != null ? subCategory.getId() : null, cache);
+ }
+
+ /**
+ * Constructs a fully initialized resource type flyweight.
+ * If a flyweight instance is found in the cache under the provided id, a new instance
+ * is *NOT* created but rather the properties of that existing instance are updated with
+ * the provided values.
+ * <p>
+ * The subcategory is supposed to exist in the cache. If it doesn't the subcategory of the
+ * returned resource type flyweight is set to null.
+ *
+ * @param id the resource type id
+ * @param name the resource type name
+ * @param plugin the resource type plugin
+ * @param category the resource type category
+ * @param subCategory the id of the resource type sub category or null
+ * @param cache the flyweight cache
+ * @return
+ */
+ public static ResourceTypeFlyweight construct(int id, String name, String plugin, ResourceCategory category,
+ Integer subCategory, FlyweightCache cache) {
+
+ ResourceTypeFlyweight ret = cache.getResourceTypes().get(id);
+
+ if (ret == null) {
+ ret = new ResourceTypeFlyweight();
+ cache.getResourceTypes().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+ ret.setPlugin(plugin);
+ ret.setCategory(category);
+ if (subCategory != null) {
+ ret.setSubCategory(cache.getSubCategories().get(subCategory));
+ } else {
+ ret.setSubCategory(null);
+ }
+
+ return ret;
+ }
+
+ private ResourceTypeFlyweight() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPlugin() {
+ return plugin;
+ }
+
+ public void setPlugin(String plugin) {
+ this.plugin = plugin;
+ }
+
+ public ResourceCategory getCategory() {
+ return category;
+ }
+
+ public void setCategory(ResourceCategory resourceCategory) {
+ this.category = resourceCategory;
+ }
+
+ public ResourceSubCategoryFlyweight getSubCategory() {
+ return subCategory;
+ }
+
+ public void setSubCategory(ResourceSubCategoryFlyweight subCategory) {
+ this.subCategory = subCategory;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || !(obj instanceof ResourceTypeFlyweight))
+ return false;
+ ResourceTypeFlyweight that = (ResourceTypeFlyweight) obj;
+ if (!this.name.equals(that.name))
+ return false;
+ if (this.plugin != null ? !this.plugin.equals(that.plugin) : that.plugin != null)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ if (name != null && this.plugin != null) {
+ result = this.name.hashCode();
+ result = 31 * result + (this.plugin != null ? plugin.hashCode() : 0);
+ } else {
+ result = 31 * id;
+ }
+ return result;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/AutoGroupCompositeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/AutoGroupCompositeFlyweight.java
deleted file mode 100644
index 5371eec..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/AutoGroupCompositeFlyweight.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.domain.resource.hierarchy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
-
-/**
- * @see AutoGroupComposite
- *
- * @author Lukas Krejci
- */
-public class AutoGroupCompositeFlyweight implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private Double availability;
- private ResourceTypeFlyweight resourceType;
- private ResourceSubCategoryFlyweight subcategory;
- private long memberCount;
- private int depth;
- private boolean mainResource;
- private ResourceFlyweight parentResource;
- private String name;
-
- private List<ResourceFlyweight> resources;
-
- public AutoGroupCompositeFlyweight(AutoGroupCompositeFlyweight other) {
- super();
-
- if (other == null) {
- return; // Throw exception?
- }
-
- this.availability = other.availability;
- this.resourceType = other.resourceType;
- this.subcategory = other.subcategory;
- this.memberCount = other.memberCount;
- this.depth = other.depth;
- this.mainResource = other.mainResource;
- this.parentResource = other.parentResource;
- this.resources = new ArrayList<ResourceFlyweight>();
- if (other.resources != null) {
- this.resources.addAll(other.resources);
- }
- this.name = other.name;
- }
-
- public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
- ResourceTypeFlyweight resourceType, long memberCount) {
- this(availability, parentResource, resourceType, memberCount, false);
- }
-
- public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
- ResourceTypeFlyweight resourceType, long memberCount, boolean isDuplicateResourceTypeName) {
- this.availability = availability;
- this.parentResource = parentResource;
- this.resourceType = resourceType;
- this.memberCount = memberCount;
- if (isDuplicateResourceTypeName) {
- this.name = String.format("%s (%s plugin)", this.resourceType.getName(), this.resourceType.getPlugin());
- } else {
- this.name = this.resourceType.getName();
- }
- }
-
- public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
- ResourceSubCategoryFlyweight subcategory, long memberCount) {
- this.availability = availability;
- this.parentResource = parentResource;
- this.subcategory = subcategory;
- this.memberCount = memberCount;
- this.name = this.subcategory.getName();
- }
-
- public Double getAvailability() {
- return availability;
- }
-
- public ResourceTypeFlyweight getResourceType() {
- return resourceType;
- }
-
- public long getMemberCount() {
- return memberCount;
- }
-
- public void setResources(List<ResourceFlyweight> resources) {
- this.resources = resources;
- }
-
- public ResourceSubCategoryFlyweight getSubcategory() {
- return subcategory;
- }
-
- public ResourceFlyweight getParentResource() {
- return parentResource;
- }
-
- public void setParentResource(ResourceFlyweight parentResource) {
- this.parentResource = parentResource;
- }
-
- public List<ResourceFlyweight> getResources() {
- return resources;
- }
-
- public int getDepth() {
- return depth;
- }
-
- public void setDepth(int depth) {
- this.depth = depth;
- }
-
- public int increaseDepth(int increment) {
- depth += increment;
- return depth;
- }
-
- public boolean isMainResource() {
- return mainResource;
- }
-
- public void setMainResource(boolean mainResource) {
- this.mainResource = mainResource;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return "AutoGroupCompositeFlyweight[" + ((this.resourceType != null) ? "Resource: " : "Subcategory: ")
- + "name=" + this.name + ", members=" + this.memberCount + ", availability=" + this.availability + "]";
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/FlyweightCache.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/FlyweightCache.java
deleted file mode 100644
index ce49aee..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/FlyweightCache.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.domain.resource.hierarchy;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A helper object to hold the cached instances of the flyweights.
- * The keys in the maps are ids, values are the objects themselves.
- *
- * @author Lukas Krejci
- */
-public class FlyweightCache {
-
- private Map<Integer, ResourceFlyweight> resources = new HashMap<Integer, ResourceFlyweight>();
- private Map<Integer, ResourceTypeFlyweight> resourceTypes = new HashMap<Integer, ResourceTypeFlyweight>();
- private Map<Integer, ResourceSubCategoryFlyweight> subCategories = new HashMap<Integer, ResourceSubCategoryFlyweight>();
-
- public Map<Integer, ResourceFlyweight> getResources() {
- return resources;
- }
-
- public Map<Integer, ResourceTypeFlyweight> getResourceTypes() {
- return resourceTypes;
- }
-
- public Map<Integer, ResourceSubCategoryFlyweight> getSubCategories() {
- return subCategories;
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
deleted file mode 100644
index 9282f0c..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.domain.resource.hierarchy;
-
-import java.io.Serializable;
-
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.ResourceAvailability;
-
-/**
- * This is basically a copy of {@link ResourceAvailability} class, but is linked to the
- * {@link ResourceFlyweight} instead of Resource. This enables us to retain the same API
- * for the flyweights as for the original domain entities.
- *
- * @author Lukas Krejci
- */
-public class ResourceAvailabilityFlyweight implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private ResourceFlyweight resource;
- private int resourceId;
- private AvailabilityType availabilityType;
-
- public ResourceAvailabilityFlyweight(ResourceFlyweight resource, AvailabilityType type) {
- this.resource = resource;
- this.resourceId = resource.getId();
- this.availabilityType = type;
- }
-
- public ResourceFlyweight getResource() {
- return resource;
- }
-
- public void setResource(ResourceFlyweight resource) {
- this.resource = resource;
- }
-
- public int getResourceId() {
- return resourceId;
- }
-
- public void setResourceId(int resourceId) {
- this.resourceId = resourceId;
- }
-
- public AvailabilityType getAvailabilityType() {
- return availabilityType;
- }
-
- public void setAvailabilityType(AvailabilityType availabilityType) {
- this.availabilityType = availabilityType;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = (prime * result) + ((availabilityType == null) ? 0 : availabilityType.hashCode());
- result = (prime * result) + resourceId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null || !(obj instanceof ResourceAvailabilityFlyweight)) {
- return false;
- }
-
- final ResourceAvailabilityFlyweight other = (ResourceAvailabilityFlyweight) obj;
-
- if (resourceId != other.resourceId) {
- return false;
- }
-
- if (availabilityType == null) {
- if (other.availabilityType != null) {
- return false;
- }
- } else if (!availabilityType.equals(other.availabilityType)) {
- return false;
- }
-
- return true;
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
deleted file mode 100644
index 25b4240..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.domain.resource.hierarchy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.ResourceAvailability;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-
-/**
- * Contains only a minimal subset of properties of a Resource that are needed for display
- * purposes.
- *
- * @author Lukas Krejci
- */
-public class ResourceFlyweight implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private ResourceFlyweight parentResource;
- private String uuid;
- private int id;
- private String name;
- private String resourceKey;
- private ResourceAvailabilityFlyweight currentAvailability;
- private ResourceTypeFlyweight resourceType;
- private boolean locked;
- private List<ResourceFlyweight> childResources;
-
- /**
- * @see #construct(int, String, String, Integer, int, AvailabilityType, FlyweightCache)
- *
- * @param original the resource
- * @param cache the cached flyweights
- * @return the initialized resource flyweight
- */
- public static ResourceFlyweight construct(Resource original, FlyweightCache cache) {
- int id = original.getId();
- String name = original.getName();
- String uuid = original.getUuid();
- String resourceKey = original.getResourceKey();
- Resource parent = original.getParentResource();
- ResourceType type = original.getResourceType();
- ResourceAvailability avail = original.getCurrentAvailability();
-
- return construct(id, name, uuid, resourceKey, parent != null ? parent.getId() : null, type.getId(),
- avail != null ? avail.getAvailabilityType() : null, cache);
- }
-
- /**
- * Constructs a fully initialized instance of the resource flyweight.
- * The resource type, sub-category and parent are looked up
- * in the provided cache. If not found, new instances are created and added
- * to the cache.
- * <p>
- * Note that if the parentId is not null and not found in the cache, a new flyweight
- * is created for the parent, initialized only with the id.
- * <p>
- * The type is supposed to exist in the cache already. If it doesn't, no type is assigned
- * to the returned resource flyweight.
- * <p>
- * If a corresponding flyweight for the provided resource id is already found in the cache,
- * it is refreshed with the data provided to this call.
- *
- * @param id the resource id
- * @param name the resource name
- * @param uuid the resoure uuid
- * @param resourceKey the resource key
- * @param parentId the id of the parent resource
- * @param typeId the id of the resource type
- * @param currentAvailability the availability of the resource
- * @param cache the cached flyweights
- * @return
- */
- public static ResourceFlyweight construct(int id, String name, String uuid, String resourceKey, Integer parentId,
- int typeId, AvailabilityType currentAvailability, FlyweightCache cache) {
-
- ResourceFlyweight ret = cache.getResources().get(id);
- if (ret == null) {
- ret = new ResourceFlyweight();
- cache.getResources().put(id, ret);
- }
-
- ret.setId(id);
- ret.setName(name);
- ret.setUuid(uuid);
- ret.setResourceKey(resourceKey);
- ret.setCurrentAvailability(new ResourceAvailabilityFlyweight(ret, currentAvailability));
-
- if (parentId != null) {
- ResourceFlyweight parent = cache.getResources().get(parentId);
- if (parent == null) {
- parent = construct(parentId, null, null, null, null, -1, null, cache);
- }
- parent.getChildResources().add(ret);
- ret.setParentResource(parent);
- } else {
- ResourceFlyweight previousParent = ret.getParentResource();
- if (previousParent != null) {
- previousParent.getChildResources().remove(ret);
- }
- ret.setParentResource(null);
- }
-
- ret.setResourceType(cache.getResourceTypes().get(typeId));
-
- return ret;
- }
-
- private ResourceFlyweight() {
-
- }
-
- public ResourceFlyweight getParentResource() {
- return parentResource;
- }
-
- public void setParentResource(ResourceFlyweight parent) {
- this.parentResource = parent;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getResourceKey() {
- return resourceKey;
- }
-
- public void setResourceKey(String resourceKey) {
- this.resourceKey = resourceKey;
- }
-
- public ResourceAvailabilityFlyweight getCurrentAvailability() {
- return currentAvailability;
- }
-
- public void setCurrentAvailability(ResourceAvailabilityFlyweight currentAvailability) {
- this.currentAvailability = currentAvailability;
- }
-
- public ResourceTypeFlyweight getResourceType() {
- return resourceType;
- }
-
- public void setResourceType(ResourceTypeFlyweight resourceType) {
- this.resourceType = resourceType;
- }
-
- public List<ResourceFlyweight> getChildResources() {
- if (childResources == null) {
- childResources = new ArrayList<ResourceFlyweight>();
- }
- return childResources;
- }
-
- public boolean isLocked() {
- return locked;
- }
-
- public void setLocked(boolean locked) {
- this.locked = locked;
- }
-
- @Override
- public int hashCode() {
- return ((uuid != null) ? uuid.hashCode() : 0);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if ((o == null) || !(o instanceof ResourceFlyweight)) {
- return false;
- }
-
- final ResourceFlyweight resource = (ResourceFlyweight) o;
-
- if ((uuid != null) ? (!uuid.equals(resource.uuid)) : (resource.uuid != null)) {
- return false;
- }
-
- return true;
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
deleted file mode 100644
index 83b0698..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * 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, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.domain.resource.hierarchy;
-
-import java.io.Serializable;
-
-import org.rhq.core.domain.resource.ResourceSubCategory;
-
-/**
- * Flyweight representation of a resource sub category. Only id, name and parent are preserved.
- *
- * @author Lukas Krejci
- */
-public class ResourceSubCategoryFlyweight implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private int id;
- private String name;
- private ResourceSubCategoryFlyweight parentSubCategory;
-
- /**
- * @see #construct(int, String, Integer, FlyweightCache)
- *
- * @param original
- * @param cache
- * @return
- */
- public static ResourceSubCategoryFlyweight construct(ResourceSubCategory original, FlyweightCache cache) {
- int id = original.getId();
- String name = original.getName();
- ResourceSubCategory parent = original.getParentSubCategory();
- Integer parentId = parent != null ? parent.getId() : null;
- String parentName = parent != null ? parent.getName() : null;
-
- return construct(id, name, parentId, parentName, cache);
- }
-
- /**
- * An existing sub category is first looked up in the cache. If there already is a flyweight
- * instance in the cache, its properties are updated with the provided values, otherwise a new instance
- * is put in the cache.
- * <p>
- * If parent sub category id is not null but a corresponding flyweight doesn't exist in the cache yet,
- * a new instance is put in the cache initialized with the parent id and name.
- *
- * @param id
- * @param name
- * @param parentSubCategoryId
- * @param parentSubCategoryName
- * @param cache
- * @return
- */
- public static ResourceSubCategoryFlyweight construct(int id, String name, Integer parentSubCategoryId,
- String parentSubCategoryName, FlyweightCache cache) {
- ResourceSubCategoryFlyweight ret = cache.getSubCategories().get(id);
-
- if (ret == null) {
- ret = new ResourceSubCategoryFlyweight();
- cache.getSubCategories().put(id, ret);
- }
-
- ret.setId(id);
- ret.setName(name);
-
- if (parentSubCategoryId != null) {
- ResourceSubCategoryFlyweight parent = cache.getSubCategories().get(parentSubCategoryId);
- if (parent == null) {
- parent = construct(parentSubCategoryId, parentSubCategoryName, null, null, cache);
- }
- ret.setParentSubCategory(parent);
- } else {
- ret.setParentSubCategory(null);
- }
-
- return ret;
- }
-
- private ResourceSubCategoryFlyweight() {
-
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public ResourceSubCategoryFlyweight getParentSubCategory() {
- return parentSubCategory;
- }
-
- public void setParentSubCategory(ResourceSubCategoryFlyweight parentSubCategory) {
- this.parentSubCategory = parentSubCategory;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (!(o instanceof ResourceSubCategoryFlyweight)) {
- return false;
- }
-
- ResourceSubCategoryFlyweight that = (ResourceSubCategoryFlyweight) o;
-
- if (!name.equals(that.getName())) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result;
- result = name.hashCode();
-
- return result;
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
deleted file mode 100644
index 7695abd..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.domain.resource.hierarchy;
-
-import java.io.Serializable;
-
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceSubCategory;
-import org.rhq.core.domain.resource.ResourceType;
-
-/**
- * A flyweight representation of the resource type intended for the display purposes.
- *
- * @author Lukas Krejci
- */
-public class ResourceTypeFlyweight implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private int id;
- private String name;
- private String plugin;
- private ResourceCategory category;
- private ResourceSubCategoryFlyweight subCategory;
-
- /**
- * @see #construct(int, String, String, ResourceCategory, Integer, FlyweightCache)
- *
- * @param original the original resource type
- * @param cache the cache of flyweights
- * @return a fully initialized resource type flyweight
- */
- public static ResourceTypeFlyweight construct(ResourceType original, FlyweightCache cache) {
- int id = original.getId();
- String name = original.getName();
- String plugin = original.getPlugin();
- ResourceCategory category = original.getCategory();
- ResourceSubCategory subCategory = original.getSubCategory();
-
- return construct(id, name, plugin, category, subCategory != null ? subCategory.getId() : null, cache);
- }
-
- /**
- * Constructs a fully initialized resource type flyweight.
- * If a flyweight instance is found in the cache under the provided id, a new instance
- * is *NOT* created but rather the properties of that existing instance are updated with
- * the provided values.
- * <p>
- * The subcategory is supposed to exist in the cache. If it doesn't the subcategory of the
- * returned resource type flyweight is set to null.
- *
- * @param id the resource type id
- * @param name the resource type name
- * @param plugin the resource type plugin
- * @param category the resource type category
- * @param subCategory the id of the resource type sub category or null
- * @param cache the flyweight cache
- * @return
- */
- public static ResourceTypeFlyweight construct(int id, String name, String plugin, ResourceCategory category,
- Integer subCategory, FlyweightCache cache) {
-
- ResourceTypeFlyweight ret = cache.getResourceTypes().get(id);
-
- if (ret == null) {
- ret = new ResourceTypeFlyweight();
- cache.getResourceTypes().put(id, ret);
- }
-
- ret.setId(id);
- ret.setName(name);
- ret.setPlugin(plugin);
- ret.setCategory(category);
- if (subCategory != null) {
- ret.setSubCategory(cache.getSubCategories().get(subCategory));
- } else {
- ret.setSubCategory(null);
- }
-
- return ret;
- }
-
- private ResourceTypeFlyweight() {
-
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getPlugin() {
- return plugin;
- }
-
- public void setPlugin(String plugin) {
- this.plugin = plugin;
- }
-
- public ResourceCategory getCategory() {
- return category;
- }
-
- public void setCategory(ResourceCategory resourceCategory) {
- this.category = resourceCategory;
- }
-
- public ResourceSubCategoryFlyweight getSubCategory() {
- return subCategory;
- }
-
- public void setSubCategory(ResourceSubCategoryFlyweight subCategory) {
- this.subCategory = subCategory;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !(obj instanceof ResourceTypeFlyweight))
- return false;
- ResourceTypeFlyweight that = (ResourceTypeFlyweight) obj;
- if (!this.name.equals(that.name))
- return false;
- if (this.plugin != null ? !this.plugin.equals(that.plugin) : that.plugin != null)
- return false;
- return true;
- }
-
- @Override
- public int hashCode() {
- int result;
- if (name != null && this.plugin != null) {
- result = this.name.hashCode();
- result = 31 * result + (this.plugin != null ? plugin.hashCode() : 0);
- } else {
- result = 31 * id;
- }
- return result;
- }
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
index 01533e6..29debf4 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
@@ -28,10 +28,10 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
-import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.navigation.resource.ResourceTreeModelUIBean;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
index fcddacf..ec1e2dc 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
@@ -18,8 +18,8 @@
*/
package org.rhq.enterprise.gui.navigation.group;
+import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
import org.rhq.core.util.sort.HumaneStringComparator;
import org.rhq.enterprise.server.resource.cluster.ClusterKey;
import org.rhq.enterprise.gui.navigation.resource.ResourceTreeNode;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
index a2ee947..501d3f7 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
@@ -32,9 +32,9 @@ import org.richfaces.component.html.HtmlTree;
import org.richfaces.model.TreeRowKey;
import org.rhq.core.gui.util.FacesContextUtility;
+import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.inventory.resource.ResourceUIBean;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
index bbb3ab5..184bfc5 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
@@ -34,11 +34,12 @@ import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.LockedResource;
+import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceSubCategoryFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceTypeFlyweight;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
-import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
-import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
-import org.rhq.core.domain.resource.hierarchy.ResourceSubCategoryFlyweight;
-import org.rhq.core.domain.resource.hierarchy.ResourceTypeFlyweight;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
index 6a4ecfa..4ea6cb9 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
@@ -24,9 +24,9 @@ import java.util.TreeSet;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
+import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
-import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
-import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.util.sort.HumaneStringComparator;
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
index 460fc78..d067061 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
@@ -36,9 +36,9 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.composite.LockedResource;
import org.rhq.core.domain.resource.composite.ResourceFacets;
+import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
-import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
-import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 5af7898..c57238c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -97,12 +97,12 @@ import org.rhq.core.domain.resource.composite.ResourceInstallCount;
import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult;
import org.rhq.core.domain.resource.composite.ResourceParentFlyweight;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
+import org.rhq.core.domain.resource.flyweight.FlyweightCache;
+import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceSubCategoryFlyweight;
+import org.rhq.core.domain.resource.flyweight.ResourceTypeFlyweight;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
-import org.rhq.core.domain.resource.hierarchy.FlyweightCache;
-import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
-import org.rhq.core.domain.resource.hierarchy.ResourceSubCategoryFlyweight;
-import org.rhq.core.domain.resource.hierarchy.ResourceTypeFlyweight;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.server.PersistenceUtility;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
index 3c0ee69..c88413f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
@@ -45,9 +45,9 @@ import org.rhq.core.domain.resource.composite.ResourceIdFlyWeight;
import org.rhq.core.domain.resource.composite.ResourceInstallCount;
import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
+import org.rhq.core.domain.resource.flyweight.ResourceFlyweight;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
-import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.IntExtractor;
commit 30bbb512cc211c97b230cf114babbad9b2860b86
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Apr 2 12:08:39 2010 +0200
making the constructors private so that the construct() methods are the only way to instantiate a flyweight that needs to be put in a cache...
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
index fc83c9d..25b4240 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
@@ -132,27 +132,10 @@ public class ResourceFlyweight implements Serializable {
return ret;
}
- public ResourceFlyweight() {
+ private ResourceFlyweight() {
}
- /**
- * Constructs a new flyweight from the resource.
- * Note that this does *NOT* initialize the parentResource, resourceType properties as that would create new instances of those
- * types which might not be what the user of this constructor wanted.
- *
- * @param resource
- */
- public ResourceFlyweight(Resource resource) {
- setId(resource.getId());
- setName(resource.getName());
- setUuid(resource.getUuid());
- setResourceKey(resource.getResourceKey());
- ResourceAvailability avail = resource.getCurrentAvailability();
- setCurrentAvailability(new ResourceAvailabilityFlyweight(this, avail != null ? avail.getAvailabilityType()
- : null));
- }
-
public ResourceFlyweight getParentResource() {
return parentResource;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
index 1604700..83b0698 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
@@ -97,20 +97,10 @@ public class ResourceSubCategoryFlyweight implements Serializable {
return ret;
}
- public ResourceSubCategoryFlyweight() {
+ private ResourceSubCategoryFlyweight() {
}
- /**
- * Initializes only id and name properties.
- *
- * @param subCategory
- */
- public ResourceSubCategoryFlyweight(ResourceSubCategory subCategory) {
- setId(subCategory.getId());
- setName(subCategory.getName());
- }
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
index 4aa4476..7695abd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
@@ -101,24 +101,10 @@ public class ResourceTypeFlyweight implements Serializable {
return ret;
}
- public ResourceTypeFlyweight() {
+ private ResourceTypeFlyweight() {
}
- /**
- * Creates a new instance of the resource type flyweight from the resource type itself.
- * Note that the subCategory property isn't initialized because that would require a new
- * instance to be constructed which might not be what the user intended.
- *
- * @param resourceType
- */
- public ResourceTypeFlyweight(ResourceType resourceType) {
- setId(resourceType.getId());
- setName(resourceType.getName());
- setPlugin(resourceType.getPlugin());
- setCategory(resourceType.getCategory());
- }
-
public int getId() {
return id;
}
commit 700af4231995c3405791c796406719aa8085570c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Apr 1 17:30:26 2010 +0200
Adding the viewsInSession limits to web.xml to prevent storing multiple versions of the resource tree in memory.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
index af8568a..1b9a873 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
@@ -38,6 +38,16 @@
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
+ <!-- Making sure we don't overload the session with too much data. -->
+ <context-param>
+ <param-name>com.sun.faces.numberOfViewsInSession</param-name>
+ <param-value>1</param-value>
+ </context-param>
+ <context-param>
+ <param-name>com.sun.faces.numberOfLogicalViews</param-name>
+ <param-value>1</param-value>
+ </context-param>
+
<!-- flags for debugging during development -->
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
commit 20e28873ae9b4fceae68353cab0213a04887dc33
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Mar 30 13:09:55 2010 +0200
Don't I hate instanceof checks? Especially when there's so many that one is easily overlooked? ;)
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
index 3214424..bbb3ab5 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
@@ -169,7 +169,7 @@ public class ResourceTreeModelUIBean {
AutoGroupCompositeFlyweight agc = null;
if (rsc instanceof ResourceSubCategoryFlyweight) {
agc = new AutoGroupCompositeFlyweight(avail, parentResource, (ResourceSubCategoryFlyweight) rsc, entries.size());
- } else if (rsc instanceof ResourceType) {
+ } else if (rsc instanceof ResourceTypeFlyweight) {
boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceTypeFlyweight) rsc).getName());
agc = new AutoGroupCompositeFlyweight(avail, parentResource, (ResourceTypeFlyweight) rsc, entries.size(),
isDupResourceTypeName);
commit 7d9dee638d1d718ae230a56d780fcb49e1341790
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Mar 30 12:07:23 2010 +0200
Removing now obsolete LockedResource
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/LockedResource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/LockedResource.java
deleted file mode 100644
index 750a8c2..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/LockedResource.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.core.domain.resource.composite;
-
-import org.rhq.core.domain.resource.Resource;
-
-/**
- * Reduced access version of the Resource object.
- * Signifies to the client that the user has no true
- * visibility to this resource.
- *
- * @author Greg Hinkle
- */
-public class LockedResource extends Resource {
-
- public LockedResource() {
- }
-
-
- public LockedResource(Resource resource) {
- setParentResource(resource.getParentResource());
- setChildResources(resource.getChildResources());
- setResourceType(resource.getResourceType());
- setId(resource.getId());
- setUuid(resource.getUuid());
- setName(getResourceType().getName() + " (locked)");
- setCurrentAvailability(resource.getCurrentAvailability());
- }
-
- @Override
- public String toString() {
- return getResourceType().toString() + "(locked)";
- }
-}
\ No newline at end of file
commit 732cc646e48fbeb84de3db19a8a926ad361e645f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Mar 30 12:07:11 2010 +0200
Cleanup of the imports
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
index 66e9207..9282f0c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
@@ -37,6 +37,8 @@ import org.rhq.core.domain.measurement.ResourceAvailability;
*/
public class ResourceAvailabilityFlyweight implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private ResourceFlyweight resource;
private int resourceId;
private AvailabilityType availabilityType;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
index dee570b..01533e6 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
@@ -28,11 +28,8 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.domain.util.PageControl;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index cfea11f..5af7898 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -18,8 +18,6 @@
*/
package org.rhq.enterprise.server.resource;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,7 +29,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
-import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -91,7 +88,6 @@ import org.rhq.core.domain.resource.ResourceErrorType;
import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
-import org.rhq.core.domain.resource.composite.LockedResource;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
import org.rhq.core.domain.resource.composite.ResourceComposite;
commit 0a713a1f11594d646aff72b6437e4f43261ab4f9
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Mar 30 12:00:04 2010 +0200
making the group tree work with the flyweights
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
index c48cff1..fcddacf 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeNode.java
@@ -18,8 +18,8 @@
*/
package org.rhq.enterprise.gui.navigation.group;
-import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
import org.rhq.core.util.sort.HumaneStringComparator;
import org.rhq.enterprise.server.resource.cluster.ClusterKey;
import org.rhq.enterprise.gui.navigation.resource.ResourceTreeNode;
@@ -86,12 +86,22 @@ public class ResourceGroupTreeNode implements Comparable<ResourceGroupTreeNode>
return level;
}
+ public String getNodeType() {
+ if (level instanceof ResourceGroup) {
+ return "ResourceGroup";
+ } else if (level instanceof AutoGroupCompositeFlyweight) {
+ return "AutoGroupComposite";
+ } else {
+ return level.getClass().getSimpleName();
+ }
+ }
+
public String toString() {
if (level instanceof ResourceGroup) {
ResourceGroup group = (ResourceGroup) level;
return group.getName();
- } else if (level instanceof AutoGroupComposite) {
- AutoGroupComposite ag = (AutoGroupComposite) level;
+ } else if (level instanceof AutoGroupCompositeFlyweight) {
+ AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) level;
if (ag.getResourceType() != null) {
return ag.getResourceType().getName();
} else if (ag.getSubcategory() != null) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
index 37b8143..a2ee947 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeStateAdvisor.java
@@ -34,6 +34,7 @@ import org.richfaces.model.TreeRowKey;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.inventory.resource.ResourceUIBean;
@@ -94,9 +95,9 @@ public class ResourceGroupTreeStateAdvisor implements TreeStateAdvisor {
if (((ClusterKey) resourceTreeNode.getData()).equals(this.selectedClusterKey)) {
return true;
}
- } else if (resourceTreeNode.getData() instanceof AutoGroupComposite) {
+ } else if (resourceTreeNode.getData() instanceof AutoGroupCompositeFlyweight) {
ClusterKey key = resourceTreeNode.getClusterKey();
- AutoGroupComposite ag = (AutoGroupComposite) resourceTreeNode.getData();
+ AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) resourceTreeNode.getData();
if (key.equals(selectedClusterKey)) {
return true;
}
@@ -142,7 +143,7 @@ public class ResourceGroupTreeStateAdvisor implements TreeStateAdvisor {
response.sendRedirect(path + "?groupId=" + group.getId() + "&parentGroupId=" + ((ClusterKey) node.getData()).getClusterGroupId());
- } else if (node.getData() instanceof AutoGroupComposite) {
+ } else if (node.getData() instanceof AutoGroupCompositeFlyweight) {
state.setSelected(e.getOldSelection());
FacesContext.getCurrentInstance().addMessage("leftNavGroupTreeForm:leftNavGroupTree",
new FacesMessage(FacesMessage.SEVERITY_WARN, "No cluster autogroup views available", null));
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
index c894523..90a6a62 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/navigation/GroupTree.xhtml
@@ -48,7 +48,7 @@
ajaxSubmitSelection="true"
status="commonStatus"
icon="/images/icons/Platform_16.png"
- nodeFace="#{treeNode.data.class.simpleName}">
+ nodeFace="#{treeNode.nodeType}">
<rich:recursiveTreeNodesAdaptor roots="#{ResourceGroupTreeModelUIBean.roots}"
var="groupTreeItem"
commit c17c151429876d049321094c1a966126f216e75b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Mar 29 19:30:31 2010 +0200
Making the nav tree using the flyweights actually work.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
index 55231cd..66e9207 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
@@ -70,4 +70,40 @@ public class ResourceAvailabilityFlyweight implements Serializable {
public void setAvailabilityType(AvailabilityType availabilityType) {
this.availabilityType = availabilityType;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + ((availabilityType == null) ? 0 : availabilityType.hashCode());
+ result = (prime * result) + resourceId;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null || !(obj instanceof ResourceAvailabilityFlyweight)) {
+ return false;
+ }
+
+ final ResourceAvailabilityFlyweight other = (ResourceAvailabilityFlyweight) obj;
+
+ if (resourceId != other.resourceId) {
+ return false;
+ }
+
+ if (availabilityType == null) {
+ if (other.availabilityType != null) {
+ return false;
+ }
+ } else if (!availabilityType.equals(other.availabilityType)) {
+ return false;
+ }
+
+ return true;
+ }
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
index b91351c..fc83c9d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
@@ -116,8 +116,8 @@ public class ResourceFlyweight implements Serializable {
ResourceFlyweight parent = cache.getResources().get(parentId);
if (parent == null) {
parent = construct(parentId, null, null, null, null, -1, null, cache);
- parent.getChildResources().add(ret);
}
+ parent.getChildResources().add(ret);
ret.setParentResource(parent);
} else {
ResourceFlyweight previousParent = ret.getParentResource();
@@ -224,15 +224,27 @@ public class ResourceFlyweight implements Serializable {
this.locked = locked;
}
+ @Override
public int hashCode() {
- return id;
+ return ((uuid != null) ? uuid.hashCode() : 0);
}
+ @Override
public boolean equals(Object o) {
- if (!(o instanceof ResourceFlyweight)) {
+ if (this == o) {
+ return true;
+ }
+
+ if ((o == null) || !(o instanceof ResourceFlyweight)) {
return false;
}
-
- return id == ((ResourceFlyweight)o).getId();
- }
+
+ final ResourceFlyweight resource = (ResourceFlyweight) o;
+
+ if ((uuid != null) ? (!uuid.equals(resource.uuid)) : (resource.uuid != null)) {
+ return false;
+ }
+
+ return true;
+ }
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
index b43da5c..1604700 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
@@ -134,4 +134,31 @@ public class ResourceSubCategoryFlyweight implements Serializable {
public void setParentSubCategory(ResourceSubCategoryFlyweight parentSubCategory) {
this.parentSubCategory = parentSubCategory;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof ResourceSubCategoryFlyweight)) {
+ return false;
+ }
+
+ ResourceSubCategoryFlyweight that = (ResourceSubCategoryFlyweight) o;
+
+ if (!name.equals(that.getName())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ result = name.hashCode();
+
+ return result;
+ }
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
index 1493dd9..4aa4476 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
@@ -158,4 +158,30 @@ public class ResourceTypeFlyweight implements Serializable {
public void setSubCategory(ResourceSubCategoryFlyweight subCategory) {
this.subCategory = subCategory;
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || !(obj instanceof ResourceTypeFlyweight))
+ return false;
+ ResourceTypeFlyweight that = (ResourceTypeFlyweight) obj;
+ if (!this.name.equals(that.name))
+ return false;
+ if (this.plugin != null ? !this.plugin.equals(that.plugin) : that.plugin != null)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ if (name != null && this.plugin != null) {
+ result = this.name.hashCode();
+ result = 31 * result + (this.plugin != null ? plugin.hashCode() : 0);
+ } else {
+ result = 31 * id;
+ }
+ return result;
+ }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
index 8151f0a..3214424 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
@@ -246,7 +246,7 @@ public class ResourceTreeModelUIBean {
for (Object rsc : children.keySet()) {
if (rsc != null
&& (rsc instanceof ResourceSubCategoryFlyweight || ((children.get(rsc).size() > 1 || (alwaysGroup && children
- .get(rsc).size() == 1)) && ((AutoGroupComposite) parentNode.getData()).getSubcategory() != null))) {
+ .get(rsc).size() == 1)) && ((AutoGroupCompositeFlyweight) parentNode.getData()).getSubcategory() != null))) {
double avail = 0;
List<ResourceFlyweight> entries = children.get(rsc);
for (ResourceFlyweight res : entries) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
index a848358..6a4ecfa 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
@@ -25,6 +25,8 @@ import java.util.TreeSet;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.util.sort.HumaneStringComparator;
/**
@@ -57,17 +59,32 @@ public class ResourceTreeNode implements Comparable<ResourceTreeNode> {
return level;
}
+ public String getNodeType() {
+ if (level instanceof AutoGroupCompositeFlyweight) {
+ return "AutoGroupComposite";
+ } else if (level instanceof ResourceFlyweight) {
+ return ((ResourceFlyweight)level).isLocked() ? "LockedResource" : "Resource";
+ } else {
+ return level.getClass().getSimpleName();
+ }
+ }
+
public String toString() {
if (level == null) {
return "";
}
- if (level instanceof AutoGroupComposite) {
- AutoGroupComposite composite = ((AutoGroupComposite) level);
+ if (level instanceof AutoGroupCompositeFlyweight) {
+ AutoGroupCompositeFlyweight composite = ((AutoGroupCompositeFlyweight) level);
return composite.getName();
} else if (level instanceof ResourceWithAvailability) {
return ((ResourceWithAvailability) level).getResource().getName();
- } else if (level instanceof Resource) {
- return ((Resource) level).getName();
+ } else if (level instanceof ResourceFlyweight) {
+ ResourceFlyweight fly = (ResourceFlyweight) level;
+ String name = fly.getName();
+ if (fly.isLocked()) {
+ name += " (locked)";
+ }
+ return name;
}
return level.toString();
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
index 18554d3..460fc78 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
@@ -37,6 +37,8 @@ import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.composite.LockedResource;
import org.rhq.core.domain.resource.composite.ResourceFacets;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
@@ -88,63 +90,65 @@ public class ResourceTreeStateAdvisor implements TreeStateAdvisor {
Subject subject = EnterpriseFacesContextUtility.getSubject();
- if (node.getData() instanceof LockedResource) {
- state.setSelected(e.getOldSelection());
-
- FacesContext.getCurrentInstance().addMessage(
- "leftNavTreeForm:leftNavTree",
- new FacesMessage(FacesMessage.SEVERITY_WARN,
- "You have not been granted view access to this resource", null));
-
- return;
-
- } else if (node.getData() instanceof Resource) {
- String path = FacesContextUtility.getRequest().getRequestURI();
+ if (node.getData() instanceof ResourceFlyweight) {
+ ResourceFlyweight flyweight = (ResourceFlyweight) node.getData();
+
+ if (flyweight.isLocked()) {
+ state.setSelected(e.getOldSelection());
+
+ FacesContext.getCurrentInstance().addMessage(
+ "leftNavTreeForm:leftNavTree",
+ new FacesMessage(FacesMessage.SEVERITY_WARN,
+ "You have not been granted view access to this resource", null));
+
+ return;
+ } else {
+ String path = FacesContextUtility.getRequest().getRequestURI();
- Resource resource = this.resourceManager.getResourceById(subject, ((Resource) node.getData())
- .getId());
- ResourceFacets facets = this.resourceTypeManager.getResourceFacets(resource.getResourceType()
- .getId());
+ //Resource resource = this.resourceManager.getResourceById(subject, flyweight.getId());
+ ResourceFacets facets = this.resourceTypeManager.getResourceFacets(flyweight.getResourceType()
+ .getId());
- String fallbackPath = FunctionTagLibrary.getDefaultResourceTabURL();
+ String fallbackPath = FunctionTagLibrary.getDefaultResourceTabURL();
- // Switching from a auto group view... default to monitor page
- if (!path.startsWith("/rhq/resource")) {
- path = fallbackPath;
- } else {
- if ((path.startsWith("/rhq/resource/configuration/") && !facets.isConfiguration())
- || (path.startsWith("/rhq/resource/content/") && !facets.isContent())
- || (path.startsWith("/rhq/resource/operation") && !facets.isOperation())
- || (path.startsWith("/rhq/resource/events") && !facets.isEvent())) {
- // This resource doesn't support those facets
- path = fallbackPath;
- } else if ((path.startsWith("/rhq/resource/configuration/view-map.xhtml") ||
- path.startsWith("/rhq/resource/configuration/edit-map.xhtml") ||
- path.startsWith("/rhq/resource/configuration/add-map.xhtml") ||
- path.startsWith("/rhq/resource/configuration/edit.xhtml") && facets.isConfiguration())) {
- path = "/rhq/resource/configuration/view.xhtml";
-
- } else if (!path.startsWith("/rhq/resource/content/view.xhtml")
- && path.startsWith("/rhq/resource/content/") && facets.isContent()) {
- path = "/rhq/resource/content/view.xhtml";
- } else if (path.startsWith("/rhq/resource/inventory/")
- && !(path.startsWith("/rhq/resource/inventory/view.xhtml")
- || (facets.isPluginConfiguration() && path
- .startsWith("/rhq/resource/inventory/view-connection.xhtml")) || path
- .startsWith("/rhq/resource/inventory/view-agent.xhtml"))) {
- path = "/rhq/resource/inventory/view.xhtml";
- } else if (path.startsWith("/rhq/resource/operation/resourceOperationHistoryDetails.xhtml")) {
- path = "/rhq/resource/operation/resourceOperationHistory.xhtml";
- } else if (path.startsWith("/rhq/resource/operation/resourceOperationScheduleDetails.xhtml")) {
- path = "/rhq/resource/operation/resourceOperationSchedules.xhtml";
- } else if (path.startsWith("/rhq/resource/monitor/response.xhtml") && !facets.isCallTime()) {
+ // Switching from a auto group view... default to monitor page
+ if (!path.startsWith("/rhq/resource")) {
path = fallbackPath;
+ } else {
+ if ((path.startsWith("/rhq/resource/configuration/") && !facets.isConfiguration())
+ || (path.startsWith("/rhq/resource/content/") && !facets.isContent())
+ || (path.startsWith("/rhq/resource/operation") && !facets.isOperation())
+ || (path.startsWith("/rhq/resource/events") && !facets.isEvent())) {
+ // This resource doesn't support those facets
+ path = fallbackPath;
+ } else if ((path.startsWith("/rhq/resource/configuration/view-map.xhtml") ||
+ path.startsWith("/rhq/resource/configuration/edit-map.xhtml") ||
+ path.startsWith("/rhq/resource/configuration/add-map.xhtml") ||
+ path.startsWith("/rhq/resource/configuration/edit.xhtml") && facets.isConfiguration())) {
+ path = "/rhq/resource/configuration/view.xhtml";
+
+ } else if (!path.startsWith("/rhq/resource/content/view.xhtml")
+ && path.startsWith("/rhq/resource/content/") && facets.isContent()) {
+ path = "/rhq/resource/content/view.xhtml";
+ } else if (path.startsWith("/rhq/resource/inventory/")
+ && !(path.startsWith("/rhq/resource/inventory/view.xhtml")
+ || (facets.isPluginConfiguration() && path
+ .startsWith("/rhq/resource/inventory/view-connection.xhtml")) || path
+ .startsWith("/rhq/resource/inventory/view-agent.xhtml"))) {
+ path = "/rhq/resource/inventory/view.xhtml";
+ } else if (path.startsWith("/rhq/resource/operation/resourceOperationHistoryDetails.xhtml")) {
+ path = "/rhq/resource/operation/resourceOperationHistory.xhtml";
+ } else if (path.startsWith("/rhq/resource/operation/resourceOperationScheduleDetails.xhtml")) {
+ path = "/rhq/resource/operation/resourceOperationSchedules.xhtml";
+ } else if (path.startsWith("/rhq/resource/monitor/response.xhtml") && !facets.isCallTime()) {
+ path = fallbackPath;
+ }
}
- }
- response.sendRedirect(path + "?id=" + ((Resource) node.getData()).getId());
- } else if (node.getData() instanceof AutoGroupComposite) {
- AutoGroupComposite ag = (AutoGroupComposite) node.getData();
+ response.sendRedirect(path + "?id=" + flyweight.getId());
+ }
+ } else if (node.getData() instanceof AutoGroupCompositeFlyweight) {
+ AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) node.getData();
if (ag.getSubcategory() != null) {
state.setSelected(e.getOldSelection());
@@ -220,8 +224,8 @@ public class ResourceTreeStateAdvisor implements TreeStateAdvisor {
return Boolean.TRUE;
} else {
Object data = ((ResourceTreeNode) tree.getRowData(key)).getData();
- if (data instanceof Resource) {
- if (((Resource) data).getResourceType().getCategory() == ResourceCategory.PLATFORM)
+ if (data instanceof ResourceFlyweight) {
+ if (((ResourceFlyweight) data).getResourceType().getCategory() == ResourceCategory.PLATFORM)
return Boolean.TRUE;
}
}
@@ -230,12 +234,12 @@ public class ResourceTreeStateAdvisor implements TreeStateAdvisor {
}
private boolean preopen(ResourceTreeNode resourceTreeNode, int selectedResourceId, int selectedAGTypeId) {
- if (resourceTreeNode.getData() instanceof Resource && selectedAGTypeId == 0) {
- if (((Resource) resourceTreeNode.getData()).getId() == selectedResourceId) {
+ if (resourceTreeNode.getData() instanceof ResourceFlyweight && selectedAGTypeId == 0) {
+ if (((ResourceFlyweight) resourceTreeNode.getData()).getId() == selectedResourceId) {
return true;
}
- } else if (resourceTreeNode.getData() instanceof AutoGroupComposite) {
- AutoGroupComposite ag = (AutoGroupComposite) resourceTreeNode.getData();
+ } else if (resourceTreeNode.getData() instanceof AutoGroupCompositeFlyweight) {
+ AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) resourceTreeNode.getData();
if (ag.getParentResource().getId() == selectedResourceId && ag.getResourceType() != null
&& ag.getResourceType().getId() == selectedAGTypeId) {
return true;
@@ -259,8 +263,8 @@ public class ResourceTreeStateAdvisor implements TreeStateAdvisor {
ResourceTreeNode node = (ResourceTreeNode) tree.getRowData(tree.getRowKey());
if (this.selecteAGTypeId > 0) {
- if (node.getData() instanceof AutoGroupComposite) {
- AutoGroupComposite ag = (AutoGroupComposite) node.getData();
+ if (node.getData() instanceof AutoGroupCompositeFlyweight) {
+ AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) node.getData();
if (ag.getParentResource() != null && ag.getResourceType() != null
&& String.valueOf(ag.getParentResource().getId()).equals(parent)
&& String.valueOf(ag.getResourceType().getId()).equals(type)) {
@@ -268,8 +272,8 @@ public class ResourceTreeStateAdvisor implements TreeStateAdvisor {
}
}
}
- if (node.getData() instanceof Resource) {
- if (String.valueOf(((Resource) node.getData()).getId()).equals(id)) {
+ if (node.getData() instanceof ResourceFlyweight) {
+ if (String.valueOf(((ResourceFlyweight) node.getData()).getId()).equals(id)) {
return Boolean.TRUE;
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
index 85d9ab4..c1a577e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
@@ -44,7 +44,7 @@
nodeSelectListener="#{ResourceTreeStateAdvisor.nodeSelectListener}"
ajaxSubmitSelection="true"
showConnectingLines="false"
- nodeFace="#{treeNode.data.class.simpleName}">
+ nodeFace="#{treeNode.nodeType}">
<rich:recursiveTreeNodesAdaptor roots="#{ResourceTreeModelUIBean.roots}"
var="resourceTreeItem"
nodes="#{resourceTreeItem.children}" />
@@ -95,8 +95,6 @@
<f:param value="#{resourceTreeItem.data.name}" name="name"/>
<f:param value="#{resourceTreeItem.data.id}" name="id"/>
<f:param value="#{resourceTreeItem.data.resourceType.name}" name="type"/>
- <f:param value="'#{resourceTreeItem.data.resourceType.operationDefinitions}'"
- name="ops"/>
</rich:componentControl>
</a4j:support>
<h:outputText value="#{resourceTreeItem}"
commit 90924d83ea9e1303559698038a497868dbf08435
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Mar 29 16:03:18 2010 +0200
Changing the return type of findResourcesByAgent and findResourcesByCompatibleGroup to return List<ResourceFlyweight>.
This should dramatically reduce the memory usage under high server load.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/AutoGroupCompositeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/AutoGroupCompositeFlyweight.java
new file mode 100644
index 0000000..5371eec
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/AutoGroupCompositeFlyweight.java
@@ -0,0 +1,162 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.hierarchy;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+
+/**
+ * @see AutoGroupComposite
+ *
+ * @author Lukas Krejci
+ */
+public class AutoGroupCompositeFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Double availability;
+ private ResourceTypeFlyweight resourceType;
+ private ResourceSubCategoryFlyweight subcategory;
+ private long memberCount;
+ private int depth;
+ private boolean mainResource;
+ private ResourceFlyweight parentResource;
+ private String name;
+
+ private List<ResourceFlyweight> resources;
+
+ public AutoGroupCompositeFlyweight(AutoGroupCompositeFlyweight other) {
+ super();
+
+ if (other == null) {
+ return; // Throw exception?
+ }
+
+ this.availability = other.availability;
+ this.resourceType = other.resourceType;
+ this.subcategory = other.subcategory;
+ this.memberCount = other.memberCount;
+ this.depth = other.depth;
+ this.mainResource = other.mainResource;
+ this.parentResource = other.parentResource;
+ this.resources = new ArrayList<ResourceFlyweight>();
+ if (other.resources != null) {
+ this.resources.addAll(other.resources);
+ }
+ this.name = other.name;
+ }
+
+ public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
+ ResourceTypeFlyweight resourceType, long memberCount) {
+ this(availability, parentResource, resourceType, memberCount, false);
+ }
+
+ public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
+ ResourceTypeFlyweight resourceType, long memberCount, boolean isDuplicateResourceTypeName) {
+ this.availability = availability;
+ this.parentResource = parentResource;
+ this.resourceType = resourceType;
+ this.memberCount = memberCount;
+ if (isDuplicateResourceTypeName) {
+ this.name = String.format("%s (%s plugin)", this.resourceType.getName(), this.resourceType.getPlugin());
+ } else {
+ this.name = this.resourceType.getName();
+ }
+ }
+
+ public AutoGroupCompositeFlyweight(Double availability, ResourceFlyweight parentResource,
+ ResourceSubCategoryFlyweight subcategory, long memberCount) {
+ this.availability = availability;
+ this.parentResource = parentResource;
+ this.subcategory = subcategory;
+ this.memberCount = memberCount;
+ this.name = this.subcategory.getName();
+ }
+
+ public Double getAvailability() {
+ return availability;
+ }
+
+ public ResourceTypeFlyweight getResourceType() {
+ return resourceType;
+ }
+
+ public long getMemberCount() {
+ return memberCount;
+ }
+
+ public void setResources(List<ResourceFlyweight> resources) {
+ this.resources = resources;
+ }
+
+ public ResourceSubCategoryFlyweight getSubcategory() {
+ return subcategory;
+ }
+
+ public ResourceFlyweight getParentResource() {
+ return parentResource;
+ }
+
+ public void setParentResource(ResourceFlyweight parentResource) {
+ this.parentResource = parentResource;
+ }
+
+ public List<ResourceFlyweight> getResources() {
+ return resources;
+ }
+
+ public int getDepth() {
+ return depth;
+ }
+
+ public void setDepth(int depth) {
+ this.depth = depth;
+ }
+
+ public int increaseDepth(int increment) {
+ depth += increment;
+ return depth;
+ }
+
+ public boolean isMainResource() {
+ return mainResource;
+ }
+
+ public void setMainResource(boolean mainResource) {
+ this.mainResource = mainResource;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return "AutoGroupCompositeFlyweight[" + ((this.resourceType != null) ? "Resource: " : "Subcategory: ")
+ + "name=" + this.name + ", members=" + this.memberCount + ", availability=" + this.availability + "]";
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/FlyweightCache.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/FlyweightCache.java
new file mode 100644
index 0000000..ce49aee
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/FlyweightCache.java
@@ -0,0 +1,52 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.hierarchy;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A helper object to hold the cached instances of the flyweights.
+ * The keys in the maps are ids, values are the objects themselves.
+ *
+ * @author Lukas Krejci
+ */
+public class FlyweightCache {
+
+ private Map<Integer, ResourceFlyweight> resources = new HashMap<Integer, ResourceFlyweight>();
+ private Map<Integer, ResourceTypeFlyweight> resourceTypes = new HashMap<Integer, ResourceTypeFlyweight>();
+ private Map<Integer, ResourceSubCategoryFlyweight> subCategories = new HashMap<Integer, ResourceSubCategoryFlyweight>();
+
+ public Map<Integer, ResourceFlyweight> getResources() {
+ return resources;
+ }
+
+ public Map<Integer, ResourceTypeFlyweight> getResourceTypes() {
+ return resourceTypes;
+ }
+
+ public Map<Integer, ResourceSubCategoryFlyweight> getSubCategories() {
+ return subCategories;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
new file mode 100644
index 0000000..55231cd
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceAvailabilityFlyweight.java
@@ -0,0 +1,73 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.hierarchy;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.ResourceAvailability;
+
+/**
+ * This is basically a copy of {@link ResourceAvailability} class, but is linked to the
+ * {@link ResourceFlyweight} instead of Resource. This enables us to retain the same API
+ * for the flyweights as for the original domain entities.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceAvailabilityFlyweight implements Serializable {
+
+ private ResourceFlyweight resource;
+ private int resourceId;
+ private AvailabilityType availabilityType;
+
+ public ResourceAvailabilityFlyweight(ResourceFlyweight resource, AvailabilityType type) {
+ this.resource = resource;
+ this.resourceId = resource.getId();
+ this.availabilityType = type;
+ }
+
+ public ResourceFlyweight getResource() {
+ return resource;
+ }
+
+ public void setResource(ResourceFlyweight resource) {
+ this.resource = resource;
+ }
+
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(int resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public AvailabilityType getAvailabilityType() {
+ return availabilityType;
+ }
+
+ public void setAvailabilityType(AvailabilityType availabilityType) {
+ this.availabilityType = availabilityType;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
new file mode 100644
index 0000000..b91351c
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceFlyweight.java
@@ -0,0 +1,238 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.hierarchy;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.ResourceAvailability;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ * Contains only a minimal subset of properties of a Resource that are needed for display
+ * purposes.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private ResourceFlyweight parentResource;
+ private String uuid;
+ private int id;
+ private String name;
+ private String resourceKey;
+ private ResourceAvailabilityFlyweight currentAvailability;
+ private ResourceTypeFlyweight resourceType;
+ private boolean locked;
+ private List<ResourceFlyweight> childResources;
+
+ /**
+ * @see #construct(int, String, String, Integer, int, AvailabilityType, FlyweightCache)
+ *
+ * @param original the resource
+ * @param cache the cached flyweights
+ * @return the initialized resource flyweight
+ */
+ public static ResourceFlyweight construct(Resource original, FlyweightCache cache) {
+ int id = original.getId();
+ String name = original.getName();
+ String uuid = original.getUuid();
+ String resourceKey = original.getResourceKey();
+ Resource parent = original.getParentResource();
+ ResourceType type = original.getResourceType();
+ ResourceAvailability avail = original.getCurrentAvailability();
+
+ return construct(id, name, uuid, resourceKey, parent != null ? parent.getId() : null, type.getId(),
+ avail != null ? avail.getAvailabilityType() : null, cache);
+ }
+
+ /**
+ * Constructs a fully initialized instance of the resource flyweight.
+ * The resource type, sub-category and parent are looked up
+ * in the provided cache. If not found, new instances are created and added
+ * to the cache.
+ * <p>
+ * Note that if the parentId is not null and not found in the cache, a new flyweight
+ * is created for the parent, initialized only with the id.
+ * <p>
+ * The type is supposed to exist in the cache already. If it doesn't, no type is assigned
+ * to the returned resource flyweight.
+ * <p>
+ * If a corresponding flyweight for the provided resource id is already found in the cache,
+ * it is refreshed with the data provided to this call.
+ *
+ * @param id the resource id
+ * @param name the resource name
+ * @param uuid the resoure uuid
+ * @param resourceKey the resource key
+ * @param parentId the id of the parent resource
+ * @param typeId the id of the resource type
+ * @param currentAvailability the availability of the resource
+ * @param cache the cached flyweights
+ * @return
+ */
+ public static ResourceFlyweight construct(int id, String name, String uuid, String resourceKey, Integer parentId,
+ int typeId, AvailabilityType currentAvailability, FlyweightCache cache) {
+
+ ResourceFlyweight ret = cache.getResources().get(id);
+ if (ret == null) {
+ ret = new ResourceFlyweight();
+ cache.getResources().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+ ret.setUuid(uuid);
+ ret.setResourceKey(resourceKey);
+ ret.setCurrentAvailability(new ResourceAvailabilityFlyweight(ret, currentAvailability));
+
+ if (parentId != null) {
+ ResourceFlyweight parent = cache.getResources().get(parentId);
+ if (parent == null) {
+ parent = construct(parentId, null, null, null, null, -1, null, cache);
+ parent.getChildResources().add(ret);
+ }
+ ret.setParentResource(parent);
+ } else {
+ ResourceFlyweight previousParent = ret.getParentResource();
+ if (previousParent != null) {
+ previousParent.getChildResources().remove(ret);
+ }
+ ret.setParentResource(null);
+ }
+
+ ret.setResourceType(cache.getResourceTypes().get(typeId));
+
+ return ret;
+ }
+
+ public ResourceFlyweight() {
+
+ }
+
+ /**
+ * Constructs a new flyweight from the resource.
+ * Note that this does *NOT* initialize the parentResource, resourceType properties as that would create new instances of those
+ * types which might not be what the user of this constructor wanted.
+ *
+ * @param resource
+ */
+ public ResourceFlyweight(Resource resource) {
+ setId(resource.getId());
+ setName(resource.getName());
+ setUuid(resource.getUuid());
+ setResourceKey(resource.getResourceKey());
+ ResourceAvailability avail = resource.getCurrentAvailability();
+ setCurrentAvailability(new ResourceAvailabilityFlyweight(this, avail != null ? avail.getAvailabilityType()
+ : null));
+ }
+
+ public ResourceFlyweight getParentResource() {
+ return parentResource;
+ }
+
+ public void setParentResource(ResourceFlyweight parent) {
+ this.parentResource = parent;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getResourceKey() {
+ return resourceKey;
+ }
+
+ public void setResourceKey(String resourceKey) {
+ this.resourceKey = resourceKey;
+ }
+
+ public ResourceAvailabilityFlyweight getCurrentAvailability() {
+ return currentAvailability;
+ }
+
+ public void setCurrentAvailability(ResourceAvailabilityFlyweight currentAvailability) {
+ this.currentAvailability = currentAvailability;
+ }
+
+ public ResourceTypeFlyweight getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(ResourceTypeFlyweight resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public List<ResourceFlyweight> getChildResources() {
+ if (childResources == null) {
+ childResources = new ArrayList<ResourceFlyweight>();
+ }
+ return childResources;
+ }
+
+ public boolean isLocked() {
+ return locked;
+ }
+
+ public void setLocked(boolean locked) {
+ this.locked = locked;
+ }
+
+ public int hashCode() {
+ return id;
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof ResourceFlyweight)) {
+ return false;
+ }
+
+ return id == ((ResourceFlyweight)o).getId();
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
new file mode 100644
index 0000000..b43da5c
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceSubCategoryFlyweight.java
@@ -0,0 +1,137 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.hierarchy;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.resource.ResourceSubCategory;
+
+/**
+ * Flyweight representation of a resource sub category. Only id, name and parent are preserved.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceSubCategoryFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int id;
+ private String name;
+ private ResourceSubCategoryFlyweight parentSubCategory;
+
+ /**
+ * @see #construct(int, String, Integer, FlyweightCache)
+ *
+ * @param original
+ * @param cache
+ * @return
+ */
+ public static ResourceSubCategoryFlyweight construct(ResourceSubCategory original, FlyweightCache cache) {
+ int id = original.getId();
+ String name = original.getName();
+ ResourceSubCategory parent = original.getParentSubCategory();
+ Integer parentId = parent != null ? parent.getId() : null;
+ String parentName = parent != null ? parent.getName() : null;
+
+ return construct(id, name, parentId, parentName, cache);
+ }
+
+ /**
+ * An existing sub category is first looked up in the cache. If there already is a flyweight
+ * instance in the cache, its properties are updated with the provided values, otherwise a new instance
+ * is put in the cache.
+ * <p>
+ * If parent sub category id is not null but a corresponding flyweight doesn't exist in the cache yet,
+ * a new instance is put in the cache initialized with the parent id and name.
+ *
+ * @param id
+ * @param name
+ * @param parentSubCategoryId
+ * @param parentSubCategoryName
+ * @param cache
+ * @return
+ */
+ public static ResourceSubCategoryFlyweight construct(int id, String name, Integer parentSubCategoryId,
+ String parentSubCategoryName, FlyweightCache cache) {
+ ResourceSubCategoryFlyweight ret = cache.getSubCategories().get(id);
+
+ if (ret == null) {
+ ret = new ResourceSubCategoryFlyweight();
+ cache.getSubCategories().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+
+ if (parentSubCategoryId != null) {
+ ResourceSubCategoryFlyweight parent = cache.getSubCategories().get(parentSubCategoryId);
+ if (parent == null) {
+ parent = construct(parentSubCategoryId, parentSubCategoryName, null, null, cache);
+ }
+ ret.setParentSubCategory(parent);
+ } else {
+ ret.setParentSubCategory(null);
+ }
+
+ return ret;
+ }
+
+ public ResourceSubCategoryFlyweight() {
+
+ }
+
+ /**
+ * Initializes only id and name properties.
+ *
+ * @param subCategory
+ */
+ public ResourceSubCategoryFlyweight(ResourceSubCategory subCategory) {
+ setId(subCategory.getId());
+ setName(subCategory.getName());
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ResourceSubCategoryFlyweight getParentSubCategory() {
+ return parentSubCategory;
+ }
+
+ public void setParentSubCategory(ResourceSubCategoryFlyweight parentSubCategory) {
+ this.parentSubCategory = parentSubCategory;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
new file mode 100644
index 0000000..1493dd9
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/hierarchy/ResourceTypeFlyweight.java
@@ -0,0 +1,161 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.resource.hierarchy;
+
+import java.io.Serializable;
+
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceSubCategory;
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ * A flyweight representation of the resource type intended for the display purposes.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceTypeFlyweight implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int id;
+ private String name;
+ private String plugin;
+ private ResourceCategory category;
+ private ResourceSubCategoryFlyweight subCategory;
+
+ /**
+ * @see #construct(int, String, String, ResourceCategory, Integer, FlyweightCache)
+ *
+ * @param original the original resource type
+ * @param cache the cache of flyweights
+ * @return a fully initialized resource type flyweight
+ */
+ public static ResourceTypeFlyweight construct(ResourceType original, FlyweightCache cache) {
+ int id = original.getId();
+ String name = original.getName();
+ String plugin = original.getPlugin();
+ ResourceCategory category = original.getCategory();
+ ResourceSubCategory subCategory = original.getSubCategory();
+
+ return construct(id, name, plugin, category, subCategory != null ? subCategory.getId() : null, cache);
+ }
+
+ /**
+ * Constructs a fully initialized resource type flyweight.
+ * If a flyweight instance is found in the cache under the provided id, a new instance
+ * is *NOT* created but rather the properties of that existing instance are updated with
+ * the provided values.
+ * <p>
+ * The subcategory is supposed to exist in the cache. If it doesn't the subcategory of the
+ * returned resource type flyweight is set to null.
+ *
+ * @param id the resource type id
+ * @param name the resource type name
+ * @param plugin the resource type plugin
+ * @param category the resource type category
+ * @param subCategory the id of the resource type sub category or null
+ * @param cache the flyweight cache
+ * @return
+ */
+ public static ResourceTypeFlyweight construct(int id, String name, String plugin, ResourceCategory category,
+ Integer subCategory, FlyweightCache cache) {
+
+ ResourceTypeFlyweight ret = cache.getResourceTypes().get(id);
+
+ if (ret == null) {
+ ret = new ResourceTypeFlyweight();
+ cache.getResourceTypes().put(id, ret);
+ }
+
+ ret.setId(id);
+ ret.setName(name);
+ ret.setPlugin(plugin);
+ ret.setCategory(category);
+ if (subCategory != null) {
+ ret.setSubCategory(cache.getSubCategories().get(subCategory));
+ } else {
+ ret.setSubCategory(null);
+ }
+
+ return ret;
+ }
+
+ public ResourceTypeFlyweight() {
+
+ }
+
+ /**
+ * Creates a new instance of the resource type flyweight from the resource type itself.
+ * Note that the subCategory property isn't initialized because that would require a new
+ * instance to be constructed which might not be what the user intended.
+ *
+ * @param resourceType
+ */
+ public ResourceTypeFlyweight(ResourceType resourceType) {
+ setId(resourceType.getId());
+ setName(resourceType.getName());
+ setPlugin(resourceType.getPlugin());
+ setCategory(resourceType.getCategory());
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPlugin() {
+ return plugin;
+ }
+
+ public void setPlugin(String plugin) {
+ this.plugin = plugin;
+ }
+
+ public ResourceCategory getCategory() {
+ return category;
+ }
+
+ public void setCategory(ResourceCategory resourceCategory) {
+ this.category = resourceCategory;
+ }
+
+ public ResourceSubCategoryFlyweight getSubCategory() {
+ return subCategory;
+ }
+
+ public void setSubCategory(ResourceSubCategoryFlyweight subCategory) {
+ this.subCategory = subCategory;
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
index 6970a46..dee570b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/group/ResourceGroupTreeModelUIBean.java
@@ -33,6 +33,8 @@ import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.navigation.resource.ResourceTreeModelUIBean;
@@ -77,7 +79,7 @@ public class ResourceGroupTreeModelUIBean {
long start = System.currentTimeMillis();
long monitorId = HibernatePerformanceMonitor.get().start();
- List<Resource> resources = resourceManager.findResourcesByCompatibleGroup(EnterpriseFacesContextUtility
+ List<ResourceFlyweight> resources = resourceManager.findResourcesByCompatibleGroup(EnterpriseFacesContextUtility
.getSubject(), parentGroup.getId(), PageControl.getUnlimitedInstance());
long end = System.currentTimeMillis();
HibernatePerformanceMonitor.get().stop(monitorId, "ResourceGroupTree group resources");
@@ -98,7 +100,7 @@ public class ResourceGroupTreeModelUIBean {
log.debug("Constructed tree in " + (end - start));
}
- private ResourceGroupTreeNode load(ResourceGroup group, List<Resource> resources, List<Integer> members) {
+ private ResourceGroupTreeNode load(ResourceGroup group, List<ResourceFlyweight> resources, List<Integer> members) {
Set<ResourceTreeNode> memberNodes = new HashSet<ResourceTreeNode>();
@@ -121,8 +123,8 @@ public class ResourceGroupTreeModelUIBean {
for (ResourceTreeNode node : childNode.getChildren()) {
Object level = node.getData();
- if (level instanceof AutoGroupComposite) {
- AutoGroupComposite agc = (AutoGroupComposite) level;
+ if (level instanceof AutoGroupCompositeFlyweight) {
+ AutoGroupCompositeFlyweight agc = (AutoGroupCompositeFlyweight) level;
Object key = agc.getResourceType() != null ? agc.getResourceType() : agc.getSubcategory();
ResourceGroupTreeNode childGroupNode = children.get(key);
@@ -133,9 +135,8 @@ public class ResourceGroupTreeModelUIBean {
childGroupNode.addMember(node);
childGroupNode.setClusterKey(parentNode.getClusterKey());
- } else if (level instanceof ResourceWithAvailability) {
- } else if (level instanceof Resource) {
- Resource res = (Resource) level;
+ } else if (level instanceof ResourceFlyweight) {
+ ResourceFlyweight res = (ResourceFlyweight) level;
ClusterKey parentKey = parentNode.getClusterKey();
ClusterKey key = null;
if (parentKey == null) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
index 730802a..8151f0a 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
@@ -34,8 +34,11 @@ import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.LockedResource;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+import org.rhq.core.domain.resource.hierarchy.AutoGroupCompositeFlyweight;
+import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
+import org.rhq.core.domain.resource.hierarchy.ResourceSubCategoryFlyweight;
+import org.rhq.core.domain.resource.hierarchy.ResourceTypeFlyweight;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
@@ -82,7 +85,7 @@ public class ResourceTreeModelUIBean {
start = System.currentTimeMillis();
monitorId = HibernatePerformanceMonitor.get().start();
- List<Resource> resources = resourceManager.findResourcesByAgent(user, agent.getId(), PageControl
+ List<ResourceFlyweight> resources = resourceManager.findResourcesByAgent(user, agent.getId(), PageControl
.getUnlimitedInstance());
end = System.currentTimeMillis();
HibernatePerformanceMonitor.get().stop(monitorId, "ResourceTree agent resource");
@@ -96,9 +99,9 @@ public class ResourceTreeModelUIBean {
log.debug("Constructed tree in " + (end - start));
}
- public static ResourceTreeNode load(int rootId, List<Resource> resources, boolean alwaysGroup) {
- Resource found = null;
- for (Resource res : resources) {
+ public static ResourceTreeNode load(int rootId, List<ResourceFlyweight> resources, boolean alwaysGroup) {
+ ResourceFlyweight found = null;
+ for (ResourceFlyweight res : resources) {
if (res.getId() == rootId) {
found = res;
}
@@ -111,11 +114,11 @@ public class ResourceTreeModelUIBean {
public static void load(ResourceTreeNode parentNode, boolean alwaysGroup) {
- if (parentNode.getData() instanceof Resource) {
- Resource parentResource = (Resource) parentNode.getData();
+ if (parentNode.getData() instanceof ResourceFlyweight) {
+ ResourceFlyweight parentResource = (ResourceFlyweight) parentNode.getData();
- Map<Object, List<Resource>> children = new HashMap<Object, List<Resource>>();
- for (Resource res : parentResource.getChildResources()) {
+ Map<Object, List<ResourceFlyweight>> children = new HashMap<Object, List<ResourceFlyweight>>();
+ for (ResourceFlyweight res : parentResource.getChildResources()) {
if (res.getResourceType().getSubCategory() != null) {
// These are children that have subcategories
// Split them by if they are a sub-sub category or just a category
@@ -123,7 +126,7 @@ public class ResourceTreeModelUIBean {
if (children.containsKey(res.getResourceType().getSubCategory())) {
children.get(res.getResourceType().getSubCategory()).add(res);
} else {
- ArrayList<Resource> list = new ArrayList<Resource>();
+ ArrayList<ResourceFlyweight> list = new ArrayList<ResourceFlyweight>();
list.add(res);
children.put(res.getResourceType().getSubCategory(), list);
}
@@ -131,7 +134,7 @@ public class ResourceTreeModelUIBean {
if (children.containsKey(res.getResourceType().getSubCategory().getParentSubCategory())) {
children.get(res.getResourceType().getSubCategory().getParentSubCategory()).add(res);
} else {
- ArrayList<Resource> list = new ArrayList<Resource>();
+ ArrayList<ResourceFlyweight> list = new ArrayList<ResourceFlyweight>();
list.add(res);
children.put(res.getResourceType().getSubCategory().getParentSubCategory(), list);
}
@@ -142,7 +145,7 @@ public class ResourceTreeModelUIBean {
if (children.containsKey(res.getResourceType())) {
children.get(res.getResourceType()).add(res);
} else {
- ArrayList<Resource> list = new ArrayList<Resource>();
+ ArrayList<ResourceFlyweight> list = new ArrayList<ResourceFlyweight>();
list.add(res);
children.put(res.getResourceType(), list);
}
@@ -154,21 +157,21 @@ public class ResourceTreeModelUIBean {
for (Object rsc : children.keySet()) {
if (rsc != null
- && (rsc instanceof ResourceSubCategory || children.get(rsc).size() > 1 || (alwaysGroup && children
+ && (rsc instanceof ResourceSubCategoryFlyweight || children.get(rsc).size() > 1 || (alwaysGroup && children
.get(rsc).size() == 1))) {
double avail = 0;
- List<Resource> entries = children.get(rsc);
- for (Resource res : entries) {
+ List<ResourceFlyweight> entries = children.get(rsc);
+ for (ResourceFlyweight res : entries) {
avail += res.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP ? 1 : 0;
}
avail = avail / entries.size();
- AutoGroupComposite agc = null;
- if (rsc instanceof ResourceSubCategory) {
- agc = new AutoGroupComposite(avail, parentResource, (ResourceSubCategory) rsc, entries.size());
+ AutoGroupCompositeFlyweight agc = null;
+ if (rsc instanceof ResourceSubCategoryFlyweight) {
+ agc = new AutoGroupCompositeFlyweight(avail, parentResource, (ResourceSubCategoryFlyweight) rsc, entries.size());
} else if (rsc instanceof ResourceType) {
- boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceType) rsc).getName());
- agc = new AutoGroupComposite(avail, parentResource, (ResourceType) rsc, entries.size(),
+ boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceTypeFlyweight) rsc).getName());
+ agc = new AutoGroupCompositeFlyweight(avail, parentResource, (ResourceTypeFlyweight) rsc, entries.size(),
isDupResourceTypeName);
}
ResourceTreeNode node = new ResourceTreeNode(agc);
@@ -178,8 +181,8 @@ public class ResourceTreeModelUIBean {
parentNode.getChildren().add(node);
}
} else {
- List<Resource> entries = children.get(rsc);
- for (Resource res : entries) {
+ List<ResourceFlyweight> entries = children.get(rsc);
+ for (ResourceFlyweight res : entries) {
ResourceTreeNode node = new ResourceTreeNode(res);
load(node, alwaysGroup);
@@ -193,12 +196,12 @@ public class ResourceTreeModelUIBean {
} else {
// #####################################################################################
- AutoGroupComposite compositeParent = (AutoGroupComposite) parentNode.getData();
+ AutoGroupCompositeFlyweight compositeParent = (AutoGroupCompositeFlyweight) parentNode.getData();
- Map<Object, List<Resource>> children = new HashMap<Object, List<Resource>>();
- log.trace("composite parent" + compositeParent);
+ Map<Object, List<ResourceFlyweight>> children = new HashMap<Object, List<ResourceFlyweight>>();
+ log.debug("composite parent" + compositeParent);
if (compositeParent != null) {
- for (Resource res : compositeParent.getParentResource().getChildResources()) {
+ for (ResourceFlyweight res : compositeParent.getParentResource().getChildResources()) {
if (compositeParent.getSubcategory() != null) {
// parent is a sub category
if (res.getResourceType().getSubCategory() != null
@@ -210,7 +213,7 @@ public class ResourceTreeModelUIBean {
if (children.containsKey(res.getResourceType().getSubCategory())) {
children.get(res.getResourceType().getSubCategory()).add(res);
} else {
- ArrayList<Resource> list = new ArrayList<Resource>();
+ ArrayList<ResourceFlyweight> list = new ArrayList<ResourceFlyweight>();
list.add(res);
children.put(res.getResourceType().getSubCategory(), list);
}
@@ -220,7 +223,7 @@ public class ResourceTreeModelUIBean {
if (children.containsKey(res.getResourceType())) {
children.get(res.getResourceType()).add(res);
} else {
- ArrayList<Resource> list = new ArrayList<Resource>();
+ ArrayList<ResourceFlyweight> list = new ArrayList<ResourceFlyweight>();
list.add(res);
children.put(res.getResourceType(), list);
}
@@ -231,7 +234,7 @@ public class ResourceTreeModelUIBean {
if (children.containsKey(res.getResourceType())) {
children.get(res.getResourceType()).add(res);
} else {
- ArrayList<Resource> list = new ArrayList<Resource>();
+ ArrayList<ResourceFlyweight> list = new ArrayList<ResourceFlyweight>();
list.add(res);
children.put(res.getResourceType(), list);
}
@@ -242,21 +245,21 @@ public class ResourceTreeModelUIBean {
for (Object rsc : children.keySet()) {
if (rsc != null
- && (rsc instanceof ResourceSubCategory || ((children.get(rsc).size() > 1 || (alwaysGroup && children
+ && (rsc instanceof ResourceSubCategoryFlyweight || ((children.get(rsc).size() > 1 || (alwaysGroup && children
.get(rsc).size() == 1)) && ((AutoGroupComposite) parentNode.getData()).getSubcategory() != null))) {
double avail = 0;
- List<Resource> entries = children.get(rsc);
- for (Resource res : entries) {
+ List<ResourceFlyweight> entries = children.get(rsc);
+ for (ResourceFlyweight res : entries) {
avail += res.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP ? 1 : 0;
}
avail = avail / entries.size();
- AutoGroupComposite agc = null;
- if (rsc instanceof ResourceSubCategory) {
- agc = new AutoGroupComposite(avail, compositeParent.getParentResource(),
- (ResourceSubCategory) rsc, entries.size());
- } else if (rsc instanceof ResourceType) {
- agc = new AutoGroupComposite(avail, compositeParent.getParentResource(), (ResourceType) rsc,
+ AutoGroupCompositeFlyweight agc = null;
+ if (rsc instanceof ResourceSubCategoryFlyweight) {
+ agc = new AutoGroupCompositeFlyweight(avail, compositeParent.getParentResource(),
+ (ResourceSubCategoryFlyweight) rsc, entries.size());
+ } else if (rsc instanceof ResourceTypeFlyweight) {
+ agc = new AutoGroupCompositeFlyweight(avail, compositeParent.getParentResource(), (ResourceTypeFlyweight) rsc,
entries.size(), false);
}
ResourceTreeNode node = new ResourceTreeNode(agc);
@@ -265,8 +268,8 @@ public class ResourceTreeModelUIBean {
parentNode.getChildren().add(node);
}
} else {
- List<Resource> entries = children.get(rsc);
- for (Resource res : entries) {
+ List<ResourceFlyweight> entries = children.get(rsc);
+ for (ResourceFlyweight res : entries) {
ResourceTreeNode node = new ResourceTreeNode(res);
load(node, alwaysGroup);
if (!recursivelyLocked(node)) {
@@ -279,14 +282,10 @@ public class ResourceTreeModelUIBean {
}
public static boolean recursivelyLocked(ResourceTreeNode node) {
- if (node.getData() instanceof LockedResource) {
-
- } else if (node.getData() instanceof Resource) {
+ if (node.getData() instanceof ResourceFlyweight && !((ResourceFlyweight) node.getData()).isLocked()) {
return false;
- } else if (node.getData() instanceof AutoGroupComposite) {
-
}
-
+
boolean allLocked = true;
for (ResourceTreeNode child : node.getChildren()) {
if (!recursivelyLocked(child))
@@ -320,14 +319,14 @@ public class ResourceTreeModelUIBean {
this.nodeTitle = nodeTitle;
}
- private static Set<String> getDuplicateResourceTypeNames(Map<Object, List<Resource>> children, boolean alwaysGroup) {
+ private static Set<String> getDuplicateResourceTypeNames(Map<Object, List<ResourceFlyweight>> children, boolean alwaysGroup) {
Set<String> resourceTypeNames = new HashSet();
Set<String> dupResourceTypeNames = new HashSet();
for (Object rsc : children.keySet()) {
if (rsc != null
- && (rsc instanceof ResourceType && (children.get(rsc).size() > 1 || (alwaysGroup && children.get(rsc)
+ && (rsc instanceof ResourceTypeFlyweight && (children.get(rsc).size() > 1 || (alwaysGroup && children.get(rsc)
.size() == 1)))) {
- String resourceTypeName = ((ResourceType) rsc).getName();
+ String resourceTypeName = ((ResourceTypeFlyweight) rsc).getName();
if (resourceTypeNames.contains(resourceTypeName)) {
dupResourceTypeNames.add(resourceTypeName);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index a31de91..cfea11f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -103,6 +103,10 @@ import org.rhq.core.domain.resource.composite.ResourceParentFlyweight;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+import org.rhq.core.domain.resource.hierarchy.FlyweightCache;
+import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
+import org.rhq.core.domain.resource.hierarchy.ResourceSubCategoryFlyweight;
+import org.rhq.core.domain.resource.hierarchy.ResourceTypeFlyweight;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.server.PersistenceUtility;
@@ -1770,7 +1774,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
@SuppressWarnings("unchecked")
- public List<Resource> findResourcesByAgent(Subject user, int agentId, PageControl unlimitedInstance) {
+ public List<ResourceFlyweight> findResourcesByAgent(Subject user, int agentId, PageControl unlimitedInstance) {
// Note: I didn't put these queries in as named queries since they have very specific prefeching
// for this use case.
@@ -1795,7 +1799,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
reportingQuery.setParameter("inventoryStatus", InventoryStatus.COMMITTED);
List<Object[]> reportingQueryResults = reportingQuery.getResultList();
- List<Resource> resources = getFlyWeightObjectGraphFromReportingQueryResults(reportingQueryResults);
+ List<ResourceFlyweight> resources = getFlyWeightObjectGraphFromReportingQueryResults(reportingQueryResults);
if (!authorizationManager.isInventoryManager(user)) {
String authorizationQueryString = "" //
@@ -1818,54 +1822,20 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
HashSet<Integer> visibleIdSet = new HashSet<Integer>(visibleResources);
- ListIterator<Resource> iter = resources.listIterator();
+ ListIterator<ResourceFlyweight> iter = resources.listIterator();
while (iter.hasNext()) {
- Resource res = iter.next();
-
- if (!visibleIdSet.contains(res.getId())) {
- Resource replacement = new LockedResource(res);
- if (res.getParentResource() != null) {
- Resource parent = res.getParentResource();
- parent.removeChildResource(res);
- parent.addChildResource(replacement);
- }
- iter.set(replacement);
- }
+ ResourceFlyweight res = iter.next();
+ res.setLocked(!visibleIdSet.contains(res.getId()));
}
}
return resources;
}
- private <T> T getFlyWeight(int id, String name, Map<Integer, T> cache, Class<T> clazz) {
- if (cache.containsKey(id)) {
- return cache.get(id);
- }
- try {
- Constructor<T> noargConstructor = clazz.getConstructor();
- T flyWeight = noargConstructor.newInstance();
-
- Method setIdMethod = clazz.getMethod("setId", Integer.TYPE);
- setIdMethod.invoke(flyWeight, id);
+ private List<ResourceFlyweight> getFlyWeightObjectGraphFromReportingQueryResults(List<Object[]> reportQueryResults) {
+ List<ResourceFlyweight> resources = new ArrayList<ResourceFlyweight>();
- Method setNameMethod = clazz.getMethod("setName", String.class);
- setNameMethod.invoke(flyWeight, name);
-
- cache.put(id, flyWeight);
- return flyWeight;
- } catch (Throwable t) {
- log.equals(t);
- throw new IllegalArgumentException("Class " + clazz.getSimpleName()
- + " needs a no-arg constructor, as well as setId(int) and setName(String) methods");
- }
- }
-
- private List<Resource> getFlyWeightObjectGraphFromReportingQueryResults(List<Object[]> reportQueryResults) {
- List<Resource> resources = new ArrayList<Resource>();
-
- Map<Integer, Resource> flyWeightResourceCache = new HashMap<Integer, Resource>();
- Map<Integer, ResourceType> flyWeightTypeCache = new HashMap<Integer, ResourceType>();
- Map<Integer, ResourceSubCategory> flyWeightSubCategoryCache = new HashMap<Integer, ResourceSubCategory>();
+ FlyweightCache flyweightCache = new FlyweightCache();
for (Object[] prefetched : reportQueryResults) {
// casts
int i = 0;
@@ -1890,45 +1860,25 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
Integer parentSubCategoryId = (Integer) prefetched[i++];
String parentSubCategoryName = (String) prefetched[i++];
- // object graph
- Resource flyWeightResource = getFlyWeight(resourceId, resourceName, flyWeightResourceCache, Resource.class);
- flyWeightResource.setUuid(resourceUuid);
- flyWeightResource.setResourceKey(resourceKey);
-
- if (parentId != null) {
- Resource flyWeightParent = getFlyWeight(parentId, parentName, flyWeightResourceCache, Resource.class);
- flyWeightResource.setParentResource(flyWeightParent);
- flyWeightParent.addChildResource(flyWeightResource);
- }
-
- ResourceAvailability currentAvail = new ResourceAvailability(flyWeightResource, availType);
- flyWeightResource.setCurrentAvailability(currentAvail);
-
- ResourceType flyWeightType = getFlyWeight(typeId, typeName, flyWeightTypeCache, ResourceType.class);
- flyWeightType.setPlugin(typePlugin);
- flyWeightType.setCategory(typeCategory);
- flyWeightResource.setResourceType(flyWeightType);
-
if (subCategoryId != null) {
- ResourceSubCategory flyWeightSubCategory = getFlyWeight(subCategoryId, subCategoryName,
- flyWeightSubCategoryCache, ResourceSubCategory.class);
- flyWeightType.setSubCategory(flyWeightSubCategory);
-
- if (parentSubCategoryId != null) {
- ResourceSubCategory flyWeightParentSubCategory = getFlyWeight(parentSubCategoryId,
- parentSubCategoryName, flyWeightSubCategoryCache, ResourceSubCategory.class);
- flyWeightSubCategory.setParentSubCategory(flyWeightParentSubCategory);
- }
+ //we don't need the reference to the sub category here. We need it just in the cache.
+ ResourceSubCategoryFlyweight.construct(subCategoryId, subCategoryName, parentSubCategoryId, parentSubCategoryName, flyweightCache);
}
-
- resources.add(flyWeightResource);
+
+ //we don't need the resource type reference here, only in the cache
+ ResourceTypeFlyweight.construct(typeId, typeName, typePlugin, typeCategory, subCategoryId, flyweightCache);
+
+ ResourceFlyweight resourceFlyweight = ResourceFlyweight.construct(
+ resourceId, resourceName, resourceUuid, resourceKey, parentId, typeId, availType, flyweightCache);
+
+ resources.add(resourceFlyweight);
}
return resources;
}
@SuppressWarnings("unchecked")
- public List<Resource> findResourcesByCompatibleGroup(Subject user, int compatibleGroupId, PageControl pageControl) {
+ public List<ResourceFlyweight> findResourcesByCompatibleGroup(Subject user, int compatibleGroupId, PageControl pageControl) {
// Note: I didn't put these queries in as named queries since they have very specific pre-fetching
// for this use case.
@@ -1954,43 +1904,34 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
reportingQuery.setParameter("inventoryStatus", InventoryStatus.COMMITTED);
List<Object[]> reportingQueryResults = reportingQuery.getResultList();
- List<Resource> resources = getFlyWeightObjectGraphFromReportingQueryResults(reportingQueryResults);
-
- if (false) { //!authorizationManager.isInventoryManager(user)) {
- String authorizationQueryString = "" //
- + " SELECT res.id \n" //
- + " FROM Resource res " //
- + " WHERE res.inventoryStatus = :inventoryStatus " //
- + " AND (res.id IN (SELECT rr.id FROM Resource rr JOIN rr.explicitGroups g WHERE g.id = :groupId)\n"
- + " OR res.id IN (SELECT rr.id FROM Resource rr JOIN rr.parentResource.explicitGroups g WHERE g.id = :groupId)\n"
- + " OR res.id IN (SELECT rr.id FROM Resource rr JOIN rr.parentResource.parentResource.explicitGroups g WHERE g.id = :groupId)\n"
- + " OR res.id IN (SELECT rr.id FROM Resource rr JOIN rr.parentResource.parentResource.parentResource.explicitGroups g WHERE g.id = :groupId)\n"
- + " OR res.id IN (SELECT rr.id FROM Resource rr JOIN rr.parentResource.parentResource.parentResource.parentResource.explicitGroups g WHERE g.id = :groupId)) \n"
- + " AND res.id IN (SELECT rr.id FROM Resource rr JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s WHERE s = :subject)";
-
- Query authorizationQuery = entityManager.createQuery(authorizationQueryString);
- authorizationQuery.setParameter("groupId", compatibleGroupId);
- authorizationQuery.setParameter("inventoryStatus", InventoryStatus.COMMITTED);
- authorizationQuery.setParameter("subject", user);
- List<Integer> visibleResources = authorizationQuery.getResultList();
-
- HashSet<Integer> visibleIdSet = new HashSet<Integer>(visibleResources);
-
- ListIterator<Resource> iter = resources.listIterator();
- while (iter.hasNext()) {
- Resource res = iter.next();
-
- if (!visibleIdSet.contains(res.getId())) {
- Resource replacement = new LockedResource(res);
- if (res.getParentResource() != null) {
- Resource parent = res.getParentResource();
- parent.removeChildResource(res);
- parent.addChildResource(replacement);
- }
- iter.set(replacement);
- }
- }
- }
+ List<ResourceFlyweight> resources = getFlyWeightObjectGraphFromReportingQueryResults(reportingQueryResults);
+
+// if (false) { //!authorizationManager.isInventoryManager(user)) {
+// String authorizationQueryString = "" //
+// + " SELECT res.id \n" //
+// + " FROM Resource res " //
+// + " WHERE res.inventoryStatus = :inventoryStatus " //
+// + " AND (res.id IN (SELECT rr.id FROM Resource rr JOIN rr.explicitGroups g WHERE g.id = :groupId)\n"
+// + " OR res.id IN (SELECT rr.id FROM Resource rr JOIN rr.parentResource.explicitGroups g WHERE g.id = :groupId)\n"
+// + " OR res.id IN (SELECT rr.id FROM Resource rr JOIN rr.parentResource.parentResource.explicitGroups g WHERE g.id = :groupId)\n"
+// + " OR res.id IN (SELECT rr.id FROM Resource rr JOIN rr.parentResource.parentResource.parentResource.explicitGroups g WHERE g.id = :groupId)\n"
+// + " OR res.id IN (SELECT rr.id FROM Resource rr JOIN rr.parentResource.parentResource.parentResource.parentResource.explicitGroups g WHERE g.id = :groupId)) \n"
+// + " AND res.id IN (SELECT rr.id FROM Resource rr JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s WHERE s = :subject)";
+//
+// Query authorizationQuery = entityManager.createQuery(authorizationQueryString);
+// authorizationQuery.setParameter("groupId", compatibleGroupId);
+// authorizationQuery.setParameter("inventoryStatus", InventoryStatus.COMMITTED);
+// authorizationQuery.setParameter("subject", user);
+// List<Integer> visibleResources = authorizationQuery.getResultList();
+//
+// HashSet<Integer> visibleIdSet = new HashSet<Integer>(visibleResources);
+//
+// ListIterator<ResourceFlyweight> iter = resources.listIterator();
+// while (iter.hasNext()) {
+// ResourceFlyweight res = iter.next();
+// res.setLocked(!visibleIdSet.contains(res.getId()));
+// }
+// }
return resources;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
index 233629c..3c0ee69 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
@@ -47,6 +47,7 @@ import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
+import org.rhq.core.domain.resource.hierarchy.ResourceFlyweight;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.IntExtractor;
@@ -408,9 +409,9 @@ public interface ResourceManagerLocal {
* @param pageControl the filter for the resources
* @return the list of all resources on a platform
*/
- List<Resource> findResourcesByAgent(Subject user, int agentId, PageControl pageControl);
+ List<ResourceFlyweight> findResourcesByAgent(Subject user, int agentId, PageControl pageControl);
- List<Resource> findResourcesByCompatibleGroup(Subject user, int compatibleGroupId, PageControl pageControl);
+ List<ResourceFlyweight> findResourcesByCompatibleGroup(Subject user, int compatibleGroupId, PageControl pageControl);
ResourceAvailabilitySummary getAvailabilitySummary(Subject user, int resourceId);
commit db03988259111050f74e8df8a2cca9363244148d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 7 11:34:02 2010 -0400
Fix some queries - addendum to <support> tag work.
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 d2ab444..0e0fc55 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
@@ -188,7 +188,7 @@ import org.rhq.core.domain.util.Summary;
@NamedNativeQueries( {
// TODO: Add authz conditions to the below query.
@NamedNativeQuery(name = ResourceType.QUERY_FIND_CHILDREN_BY_CATEGORY, query = "" //
- + "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, crt.supports_manual_add, crt.description, crt.plugin, crt.ctime, crt.mtime, crt.subcategory_id, crt.plugin_config_def_id, crt.res_config_def_id "
+ + "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, crt.supports_manual_add, crt.supports_support_facet, crt.description, crt.plugin, crt.ctime, crt.mtime, crt.subcategory_id, crt.plugin_config_def_id, crt.res_config_def_id "
+ "FROM RHQ_resource_type crt, RHQ_resource res, RHQ_resource_type rt, RHQ_resource_type_parents rtp "
+ "WHERE res.id = ? "
+ "AND res.resource_type_id = rt.id "
@@ -198,7 +198,7 @@ import org.rhq.core.domain.util.Summary;
+
// "ORDER BY crt.name " +
"UNION "
- + "SELECT DISTINCT crt2.id, crt2.name, crt2.category, crt2.creation_data_type, crt2.create_delete_policy, crt2.singleton, crt2.supports_manual_add, crt2.description, crt2.plugin, crt2.ctime, crt2.mtime, crt2.subcategory_id, crt2.plugin_config_def_id, crt2.res_config_def_id "
+ + "SELECT DISTINCT crt2.id, crt2.name, crt2.category, crt2.creation_data_type, crt2.create_delete_policy, crt2.singleton, crt2.supports_manual_add, crt2.supports_support_facet, crt2.description, crt2.plugin, crt2.ctime, crt2.mtime, crt2.subcategory_id, crt2.plugin_config_def_id, crt2.res_config_def_id "
+ "FROM RHQ_resource_type crt2 " + "WHERE 1 = "
+ "(SELECT COUNT(res2.id) "
+ "FROM RHQ_resource res2, RHQ_resource_type rt2 "
@@ -209,7 +209,7 @@ import org.rhq.core.domain.util.Summary;
+ "FROM RHQ_resource_type_parents rtp2 "
+ "WHERE rtp2.resource_type_id = crt2.id) " + "AND crt2.category = ? " + " ) ORDER BY name", resultSetMapping = ResourceType.MAPPING_FIND_CHILDREN_BY_CATEGORY),
@NamedNativeQuery(name = ResourceType.QUERY_FIND_CHILDREN_BY_CATEGORY_admin, query = "" //
- + "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, crt.supports_manual_add, crt.description, crt.plugin, crt.ctime, crt.mtime, crt.subcategory_id, crt.plugin_config_def_id, crt.res_config_def_id "
+ + "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, crt.supports_manual_add, crt.supports_support_facet, crt.description, crt.plugin, crt.ctime, crt.mtime, crt.subcategory_id, crt.plugin_config_def_id, crt.res_config_def_id "
+ "FROM RHQ_resource_type crt, RHQ_resource res, RHQ_resource_type rt, RHQ_resource_type_parents rtp "
+ "WHERE res.id = ? "
+ "AND res.resource_type_id = rt.id "
@@ -219,7 +219,7 @@ import org.rhq.core.domain.util.Summary;
+
// "ORDER BY crt.name " +
"UNION "
- + "(SELECT DISTINCT crt2.id, crt2.name, crt2.category, crt2.creation_data_type, crt2.create_delete_policy, crt2.singleton, crt2.supports_manual_add, crt2.description, crt2.plugin, crt2.ctime, crt2.mtime, crt2.subcategory_id, crt2.plugin_config_def_id, crt2.res_config_def_id "
+ + "(SELECT DISTINCT crt2.id, crt2.name, crt2.category, crt2.creation_data_type, crt2.create_delete_policy, crt2.singleton, crt2.supports_manual_add, crt2.supports_support_facet, crt2.description, crt2.plugin, crt2.ctime, crt2.mtime, crt2.subcategory_id, crt2.plugin_config_def_id, crt2.res_config_def_id "
+ "FROM RHQ_resource_type crt2 " + "WHERE 1 = "
+ "(SELECT COUNT(res2.id) "
+ "FROM RHQ_resource res2, RHQ_resource_type rt2 "
commit f4fd9fb513bd0b259c32cdea0d807e41b5140a00
Merge: 012de24... b0e2aaf...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 6 17:15:00 2010 -0400
Merge branch 'master' into master-jay
commit 012de24fd8078bb605b620b3ab57163a5dfcb1df
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 6 17:12:58 2010 -0400
Added ability for bundle component to add deployment audits as it performs
the deployment
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentAction.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentAction.java
index 10edfe5..f43cb04 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentAction.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentAction.java
@@ -33,7 +33,7 @@ public enum BundleDeploymentAction {
DEPLOYMENT, // The actual deployment of the bundle: IN_PROGRESS | FAILURE | SUCCESS
DEPLOYMENT_REQUESTED, // request processed: FAILURE | SUCCESS
DEPLOYMENT_SCHEDULED, // request schedules: FAILURE | SUCCESS
+ DEPLOYMENT_STEP, // A supplemental message at any point in the process: NO_CHANGE
FILE_DOWNLOAD, // The file download preceding actualy deployment: IN_PROGRESS | FAILURE | SUCCESS
- LOG, // A supplemental log message at any point in the process: NO_CHANGE
POLICY_CHECK_FAIL
}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java
index 741efc3..0972322 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java
@@ -23,7 +23,7 @@ import java.io.File;
import java.io.Serializable;
import java.util.Map;
-import org.rhq.core.domain.bundle.BundleDeployDefinition;
+import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.content.PackageVersion;
/**
@@ -34,9 +34,9 @@ import org.rhq.core.domain.content.PackageVersion;
public class BundleDeployRequest implements Serializable {
private static final long serialVersionUID = 1L;
- private File bundleFilesLocation;
- private BundleDeployDefinition bundleDeployDefinition;
+ private BundleDeployment bundleDeployment;
private BundleManagerProvider bundleManagerProvider;
+ private File bundleFilesLocation;
private Map<PackageVersion, File> packageVersionFiles;
public BundleDeployRequest() {
@@ -70,12 +70,12 @@ public class BundleDeployRequest implements Serializable {
this.packageVersionFiles = packageVersionFiles;
}
- public BundleDeployDefinition getBundleDeployDefinition() {
- return this.bundleDeployDefinition;
+ public BundleDeployment getBundleDeployment() {
+ return bundleDeployment;
}
- public void setBundleDeployDefinition(BundleDeployDefinition bundleDeployDefinition) {
- this.bundleDeployDefinition = bundleDeployDefinition;
+ public void setBundleDeployment(BundleDeployment bundleDeployment) {
+ this.bundleDeployment = bundleDeployment;
}
public BundleManagerProvider getBundleManagerProvider() {
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
index d06561f..b1564d6 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
@@ -22,6 +22,9 @@ package org.rhq.core.pluginapi.bundle;
import java.io.OutputStream;
import java.util.List;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleDeploymentAction;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.content.PackageVersion;
@@ -32,7 +35,17 @@ import org.rhq.core.domain.content.PackageVersion;
*/
public interface BundleManagerProvider {
/**
- * Bndle plugins call back into this manager to obtain the bundle files that belong to a given bundle version.
+ * Bundle plugins call back into this manager to add progressive auditing of a deployment.
+ *
+ * @param bundleVersion
+ * @return the bundle files that are associated with the given bundle
+ * @throws Exception
+ */
+ void auditDeployment(BundleDeployment deployment, BundleDeploymentAction action, BundleDeploymentStatus status,
+ String message) throws Exception;
+
+ /**
+ * Bundle plugins call back into this manager to obtain the bundle files that belong to a given bundle version.
*
* @param bundleVersion
* @return the bundle files that are associated with the given bundle
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 141695c..0d646a7 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
@@ -145,7 +145,7 @@ public class BundleManager extends AgentService implements BundleAgentService, B
BundleDeployRequest deployRequest = new BundleDeployRequest();
deployRequest.setBundleManagerProvider(this);
- deployRequest.setBundleDeployDefinition(bundleDeployDef);
+ deployRequest.setBundleDeployment(deployment);
deployRequest.setBundleFilesLocation(bundleFilesDir);
deployRequest.setPackageVersionFiles(downloadedFiles);
BundleDeployResult result = bundlePluginComponent.deployBundle(deployRequest);
@@ -161,6 +161,15 @@ public class BundleManager extends AgentService implements BundleAgentService, B
return response;
}
+ public void auditDeployment(BundleDeployment deployment, BundleDeploymentAction action,
+ BundleDeploymentStatus status, String message) {
+ if (null == status) {
+ status = BundleDeploymentStatus.NOCHANGE;
+ }
+ BundleDeploymentHistory history = new BundleDeploymentHistory("Bundle Plugin", action, status, message);
+ getBundleServerService().addDeploymentHistory(deployment.getId(), history);
+ }
+
/**
* Downloads the bundle's files into the bundle plugin's tmp directory and returns that tmp directory.
*
@@ -190,8 +199,8 @@ public class BundleManager extends AgentService implements BundleAgentService, B
packageFile.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(packageFile);
try {
- auditDeployment(deployment, BundleDeploymentAction.LOG, BundleDeploymentStatus.NOCHANGE,
- "Downloading [" + packageVersion + "]");
+ auditDeployment(deployment, BundleDeploymentAction.DEPLOYMENT_STEP,
+ BundleDeploymentStatus.NOCHANGE, "Downloading [" + packageVersion + "]");
long size = getFileContent(packageVersion, fos);
if (packageVersion.getFileSize() != null && size != packageVersion.getFileSize().longValue()) {
log.warn("Downloaded bundle file [" + packageVersion + "] but its size was [" + size
@@ -218,15 +227,6 @@ public class BundleManager extends AgentService implements BundleAgentService, B
auditDeployment(deployment, BundleDeploymentAction.DEPLOYMENT, status, message);
}
- private void auditDeployment(BundleDeployment deployment, BundleDeploymentAction action,
- BundleDeploymentStatus status, String message) {
- if (null == status) {
- status = BundleDeploymentStatus.NOCHANGE;
- }
- BundleDeploymentHistory history = new BundleDeploymentHistory("Bundle Plugin", action, status, message);
- getBundleServerService().addDeploymentHistory(deployment.getId(), history);
- }
-
/**
* Checks to see if the package file's hash matches that of the given package version.
* If the file doesn't exist or the hash doesn't match, an exception is thrown.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index 053f98c..8738e8f 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -620,7 +620,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assertTrue(size > 0);
String auditMessage = "BundleTest-Message";
bundleManager.addBundleDeploymentHistory(overlord, bd.getId(), new BundleDeploymentHistory(overlord.getName(),
- BundleDeploymentAction.LOG, BundleDeploymentStatus.NOCHANGE, auditMessage));
+ BundleDeploymentAction.DEPLOYMENT_STEP, BundleDeploymentStatus.NOCHANGE, auditMessage));
bds = bundleManager.findBundleDeploymentsByCriteria(overlord, c);
assertEquals(1, bds.size());
assertEquals(bd.getId(), bds.get(0).getId());
@@ -635,7 +635,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
}
}
assertNotNull(newHistory);
- assertEquals(BundleDeploymentAction.LOG, newHistory.getAuditAction());
+ assertEquals(BundleDeploymentAction.DEPLOYMENT_STEP, newHistory.getAuditAction());
assertEquals(BundleDeploymentStatus.NOCHANGE, newHistory.getAuditStatus());
}
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 f523be1..607536f 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
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.bundle.ant.AntLauncher;
import org.rhq.bundle.ant.BundleAntProject;
import org.rhq.core.domain.bundle.BundleDeployDefinition;
+import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
@@ -75,7 +76,8 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
public BundleDeployResult deployBundle(BundleDeployRequest request) {
BundleDeployResult result = new BundleDeployResult();
try {
- BundleDeployDefinition bundleDeployDef = request.getBundleDeployDefinition();
+ BundleDeployment bundleDeployment = request.getBundleDeployment();
+ BundleDeployDefinition bundleDeployDef = bundleDeployment.getBundleDeployDefinition();
BundleVersion bundleVersion = bundleDeployDef.getBundleVersion();
String recipe = bundleVersion.getRecipe();
diff --git a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
index 07c48fc..7923adc 100644
--- a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
+++ b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
@@ -34,6 +34,7 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleDeployDefinition;
+import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.configuration.Configuration;
@@ -95,7 +96,7 @@ public class AntBundlePluginComponentTest {
BundleDeployRequest request = new BundleDeployRequest();
request.setBundleFilesLocation(tmpDir);
- request.setBundleDeployDefinition(deployDef);
+ request.setBundleDeployment(new BundleDeployment(deployDef, null));
BundleDeployResult results = plugin.deployBundle(request);
@@ -132,7 +133,7 @@ public class AntBundlePluginComponentTest {
BundleDeployRequest request = new BundleDeployRequest();
request.setBundleFilesLocation(tmpDir);
- request.setBundleDeployDefinition(deployDef);
+ request.setBundleDeployment(new BundleDeployment(deployDef, null));
BundleDeployResult results = plugin.deployBundle(request);
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 9536665..b3fa317 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
@@ -23,6 +23,9 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.bundle.filetemplate.recipe.RecipeParser;
import org.rhq.core.domain.bundle.BundleDeployDefinition;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleDeploymentAction;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
@@ -55,7 +58,8 @@ public class FileTemplateBundlePluginServerComponent implements ResourceComponen
public BundleDeployResult deployBundle(BundleDeployRequest request) {
BundleDeployResult result = new BundleDeployResult();
try {
- BundleDeployDefinition bundleDeployDef = request.getBundleDeployDefinition();
+ BundleDeployment bundleDeployment = request.getBundleDeployment();
+ BundleDeployDefinition bundleDeployDef = bundleDeployment.getBundleDeployDefinition();
BundleVersion bundleVersion = bundleDeployDef.getBundleVersion();
// process the recipe
@@ -64,14 +68,27 @@ public class FileTemplateBundlePluginServerComponent implements ResourceComponen
ProcessingRecipeContext recipeContext = new ProcessingRecipeContext(recipe, request
.getPackageVersionFiles(), this.resourceContext.getSystemInformation(), request
.getBundleFilesLocation().getAbsolutePath());
+
+ request.getBundleManagerProvider()
+ .auditDeployment(
+ bundleDeployment,
+ BundleDeploymentAction.DEPLOYMENT_STEP,
+ BundleDeploymentStatus.NOCHANGE,
+ "setting replacement variable values using [" + bundleDeployDef.getConfiguration().toString(true)
+ + "]");
recipeContext.setReplacementVariableValues(bundleDeployDef.getConfiguration());
+
parser.setReplaceReplacementVariables(true);
- parser.parseRecipe(recipeContext);
+ request.getBundleManagerProvider().auditDeployment(bundleDeployment,
+ BundleDeploymentAction.DEPLOYMENT_STEP, BundleDeploymentStatus.NOCHANGE,
+ "Parsing Recipe using context [" + recipeContext + "]");
+ parser.parseRecipe(recipeContext);
} catch (Throwable t) {
log.error("Failed to deploy bundle [" + request + "]", t);
result.setErrorMessage(t);
}
+
return result;
}
}
commit d936d6a0c34f2b56a140189ea0a85a2e96bf9476
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 6 17:05:47 2010 -0400
Allow leading spaces in recipe command line
diff --git a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
index 620723a..a02a82b 100644
--- a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
+++ b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
@@ -93,8 +93,9 @@ public class RecipeParser {
}
protected void parseRecipeCommandLine(RecipeContext context, String line) throws Exception {
+ line = (null == line) ? line : line.trim();
// ignore blank lines or comment lines that start with #
- if (line == null || line.trim().length() == 0 || line.startsWith("#")) {
+ if (null == line || line.length() == 0 || line.startsWith("#")) {
return;
}
commit 3e3da3591f87d4cc0efb9e5188f954948b81c49b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 6 17:05:11 2010 -0400
Add <support> tag to plugin descriptor to mark that the resource type
provides support snapshots.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index 686b16b..b589e16 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -442,6 +442,7 @@ public class PluginMetadataParser {
// 8) Artifacts
// 9) Child subcategories
// 10) Bundle Type
+ // 11) SupportFacet
String classLoaderTypeString = resourceDescriptor.getClassLoader();
if (classLoaderTypeString == null) {
@@ -527,6 +528,8 @@ public class PluginMetadataParser {
resourceType.setBundleType(new BundleType(typeName, resourceType));
}
+ resourceType.setSupportsSupportFacet(resourceDescriptor.getSupport() != null);
+
} catch (InvalidPluginDescriptorException e) {
// TODO: Should we be storing these for viewing in server? Breaking deployment? What?
throw e;
diff --git a/modules/core/client-api/src/main/resources/rhq-plugin.xsd b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
index 6225b8e..e5ee978 100644
--- a/modules/core/client-api/src/main/resources/rhq-plugin.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
@@ -555,7 +555,15 @@
<xs:element ref="rhq:event" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="rhq:content" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="resource-configuration" type="config:configuration" minOccurs="0"/>
+ <xs:element name="support" type="rhq:support" minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Declares that the resource component implements the SupportFacet.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element ref="rhq:help" minOccurs="0" maxOccurs="1" />
+
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="singleton" use="optional" type="xs:boolean" default="false">
@@ -637,6 +645,8 @@
<xs:attribute name="type" type="xs:string"/>
</xs:complexType>
+ <xs:complexType name="support">
+ </xs:complexType>
<!-- PLATFORM -->
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 9e8e258..58c9124 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.82</db.schema.version>
+ <db.schema.version>2.83</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
index 2f25ff1..f8a1e35 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/inventory-schema.xml
@@ -13,6 +13,7 @@
<column name="CREATE_DELETE_POLICY" type="VARCHAR2" size="16" required="true"/>
<column name="SINGLETON" type="BOOLEAN" required="true"/>
<column name="SUPPORTS_MANUAL_ADD" type="BOOLEAN" required="true"/>
+ <column name="SUPPORTS_SUPPORT_FACET" type="BOOLEAN" required="true"/>
<column name="DESCRIPTION" type="VARCHAR2" size="1000"/>
<column name="PLUGIN" type="VARCHAR2" size="100"/>
<column name="CTIME" type="LONG"/>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index c27a2a1..7b0421d 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3059,6 +3059,32 @@
</statement>
</schema-directSQL>
</schemaSpec>
+
+ <schemaSpec version="2.83">
+ <schema-addColumn table="RHQ_RESOURCE_TYPE" column="SUPPORTS_SUPPORT_FACET" columnType="BOOLEAN" />
+
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql">
+ UPDATE RHQ_RESOURCE_TYPE SET SUPPORTS_SUPPORT_FACET = FALSE
+ </statement>
+ <statement targetDBVendor="oracle">
+ UPDATE RHQ_RESOURCE_TYPE SET SUPPORTS_SUPPORT_FACET = 0
+ </statement>
+ <statement targetDBVendor="postgresql">
+ update RHQ_RESOURCE_TYPE set SUPPORTS_SUPPORT_FACET = true where exists
+ (select cd.id from RHQ_CONFIG_DEF cd inner join RHQ_CONFIG_PROP_DEF pd on cd.id=pd.config_def_id
+ where RHQ_RESOURCE_TYPE.PLUGIN_CONFIG_DEF_ID=cd.id and pd.name='snapshotLogEnabled')
+ </statement>
+ <statement targetDBVendor="oracle">
+ update RHQ_RESOURCE_TYPE set SUPPORTS_SUPPORT_FACET = 1 where exists
+ (select cd.id from RHQ_CONFIG_DEF cd inner join RHQ_CONFIG_PROP_DEF pd on cd.id=pd.config_def_id
+ where RHQ_RESOURCE_TYPE.PLUGIN_CONFIG_DEF_ID=cd.id and pd.name='snapshotLogEnabled')
+ </statement>
+ </schema-directSQL>
+
+ <schema-alterColumn table="RHQ_RESOURCE_TYPE" column="SUPPORTS_SUPPORT_FACET" nullable="false" />
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
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 9a779ba..d2ab444 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
@@ -22,10 +22,6 @@
*/
package org.rhq.core.domain.resource;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
@@ -177,7 +173,7 @@ import org.rhq.core.domain.util.Summary;
+ " (SELECT COUNT(operationDef) FROM rt.operationDefinitions operationDef)," // operation
+ " (SELECT COUNT(packageType) FROM rt.packageTypes packageType)," // content
+ " (SELECT COUNT(metricDef) FROM rt.metricDefinitions metricDef WHERE metricDef.dataType = 3)," // calltime
- + " (SELECT COUNT(propDef) FROM rt.pluginConfigurationDefinition pluginConfig JOIN pluginConfig.propertyDefinitions propDef WHERE propDef.name = 'snapshotLogEnabled')" // support
+ + " rt.supportsSupportFacet" // support
+ " ) " //
+ " FROM ResourceType rt " //
+ " WHERE ( rt.id = :resourceTypeId OR :resourceTypeId IS NULL )"),
@@ -306,6 +302,9 @@ public class ResourceType implements Serializable, Comparable<ResourceType> {
@Column(name = "SUPPORTS_MANUAL_ADD", nullable = false)
private boolean supportsManualAdd;
+ @Column(name = "SUPPORTS_SUPPORT_FACET", nullable = false)
+ private boolean supportsSupportFacet;
+
@Column(name = "SINGLETON", nullable = false)
private boolean singleton;
@@ -514,6 +513,14 @@ public class ResourceType implements Serializable, Comparable<ResourceType> {
this.supportsManualAdd = supportsManualAdd;
}
+ public boolean isSupportsSupportFacet() {
+ return supportsSupportFacet;
+ }
+
+ public void setSupportsSupportFacet(boolean supportsSupportFacet) {
+ this.supportsSupportFacet = supportsSupportFacet;
+ }
+
public String getDescription() {
return this.description;
}
@@ -810,87 +817,86 @@ public class ResourceType implements Serializable, Comparable<ResourceType> {
+ this.plugin + /*", parents=" + parents +*/"]";
}
+ /*
+ TODO: GWT
+ public void writeExternal(ObjectOutput out) throws IOException {
+ ExternalizableStrategy.Subsystem strategy = ExternalizableStrategy.getStrategy();
+ out.writeChar(strategy.id());
-/*
-TODO: GWT
- public void writeExternal(ObjectOutput out) throws IOException {
- ExternalizableStrategy.Subsystem strategy = ExternalizableStrategy.getStrategy();
- out.writeChar(strategy.id());
-
- if (ExternalizableStrategy.Subsystem.REMOTEAPI == strategy) {
- writeExternalRemote(out);
- } else if (ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION == strategy) {
- EntitySerializer.writeExternalRemote(this, out);
- } else {
- writeExternalAgent(out);
+ if (ExternalizableStrategy.Subsystem.REMOTEAPI == strategy) {
+ writeExternalRemote(out);
+ } else if (ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION == strategy) {
+ EntitySerializer.writeExternalRemote(this, out);
+ } else {
+ writeExternalAgent(out);
+ }
}
- }
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- char c = in.readChar();
- if (ExternalizableStrategy.Subsystem.REMOTEAPI.id() == c) {
- readExternalRemote(in);
- } else if (ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION.id() == c) {
- EntitySerializer.readExternalRemote(this, in);
- } else {
- readExternalAgent(in);
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ char c = in.readChar();
+ if (ExternalizableStrategy.Subsystem.REMOTEAPI.id() == c) {
+ readExternalRemote(in);
+ } else if (ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION.id() == c) {
+ EntitySerializer.readExternalRemote(this, in);
+ } else {
+ readExternalAgent(in);
+ }
+ }
+
+ public void writeExternalAgent(ObjectOutput out) throws IOException {
+ out.writeUTF(this.name);
+ out.writeUTF(this.plugin);
+ }
+
+ public void readExternalAgent(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.name = in.readUTF();
+ this.plugin = in.readUTF();
+ }
+
+ public void writeExternalRemote(ObjectOutput out) throws IOException {
+ out.writeInt(this.id);
+ out.writeUTF(this.name);
+ out.writeUTF((null == this.description) ? "" : this.description);
+ out.writeObject(this.category);
+ out.writeObject(this.creationDataType);
+ out.writeObject(this.createDeletePolicy);
+ out.writeBoolean(this.supportsManualAdd);
+ out.writeBoolean(this.singleton);
+ out.writeUTF(this.plugin);
+ out.writeLong(this.ctime);
+ out.writeLong(this.mtime);
+ out.writeObject(this.subCategory);
+ out.writeObject(this.bundleType);
+ out.writeObject((null == childResourceTypes) ? null : new LinkedHashSet<ResourceType>(childResourceTypes));
+ out.writeObject((null == parentResourceTypes) ? null : new LinkedHashSet<ResourceType>(parentResourceTypes));
+ out.writeObject(pluginConfigurationDefinition);
+ out.writeObject(resourceConfigurationDefinition);
+ out.writeObject((null == metricDefinitions) ? null
+ : new LinkedHashSet<MeasurementDefinition>(metricDefinitions));
+ out.writeObject((null == eventDefinitions) ? null : new LinkedHashSet<EventDefinition>(eventDefinitions));
+ out.writeObject((null == operationDefinitions) ? null : new LinkedHashSet<OperationDefinition>(
+ operationDefinitions));
+ out.writeObject((null == processScans) ? null : new LinkedHashSet<ProcessScan>(processScans));
+ out.writeObject((null == packageTypes) ? null : new LinkedHashSet<PackageType>(packageTypes));
+ out.writeObject((null == subCategories) ? null : new LinkedHashSet<ResourceSubCategory>(subCategories));
+ out.writeObject((null == resources) ? null : new LinkedHashSet<Resource>(resources));
+ out.writeObject((null == productVersions) ? null : new LinkedHashSet<ProductVersion>(productVersions));
+ // not supplied by remote: helpText
}
- }
- public void writeExternalAgent(ObjectOutput out) throws IOException {
- out.writeUTF(this.name);
- out.writeUTF(this.plugin);
- }
-
- public void readExternalAgent(ObjectInput in) throws IOException, ClassNotFoundException {
- this.name = in.readUTF();
- this.plugin = in.readUTF();
- }
-
- public void writeExternalRemote(ObjectOutput out) throws IOException {
- out.writeInt(this.id);
- out.writeUTF(this.name);
- out.writeUTF((null == this.description) ? "" : this.description);
- out.writeObject(this.category);
- out.writeObject(this.creationDataType);
- out.writeObject(this.createDeletePolicy);
- out.writeBoolean(this.supportsManualAdd);
- out.writeBoolean(this.singleton);
- out.writeUTF(this.plugin);
- out.writeLong(this.ctime);
- out.writeLong(this.mtime);
- out.writeObject(this.subCategory);
- out.writeObject(this.bundleType);
- out.writeObject((null == childResourceTypes) ? null : new LinkedHashSet<ResourceType>(childResourceTypes));
- out.writeObject((null == parentResourceTypes) ? null : new LinkedHashSet<ResourceType>(parentResourceTypes));
- out.writeObject(pluginConfigurationDefinition);
- out.writeObject(resourceConfigurationDefinition);
- out.writeObject((null == metricDefinitions) ? null
- : new LinkedHashSet<MeasurementDefinition>(metricDefinitions));
- out.writeObject((null == eventDefinitions) ? null : new LinkedHashSet<EventDefinition>(eventDefinitions));
- out.writeObject((null == operationDefinitions) ? null : new LinkedHashSet<OperationDefinition>(
- operationDefinitions));
- out.writeObject((null == processScans) ? null : new LinkedHashSet<ProcessScan>(processScans));
- out.writeObject((null == packageTypes) ? null : new LinkedHashSet<PackageType>(packageTypes));
- out.writeObject((null == subCategories) ? null : new LinkedHashSet<ResourceSubCategory>(subCategories));
- out.writeObject((null == resources) ? null : new LinkedHashSet<Resource>(resources));
- out.writeObject((null == productVersions) ? null : new LinkedHashSet<ProductVersion>(productVersions));
- // not supplied by remote: helpText
- }
-
- public void readExternalRemote(ObjectInput in) throws IOException, ClassNotFoundException {
- this.id = in.readInt();
- this.name = in.readUTF();
- this.description = in.readUTF();
- this.category = (ResourceCategory) in.readObject();
- this.creationDataType = (ResourceCreationDataType) in.readObject();
- this.createDeletePolicy = (CreateDeletePolicy) in.readObject();
- this.supportsManualAdd = in.readBoolean();
- this.singleton = in.readBoolean();
- this.plugin = in.readUTF();
- this.ctime = in.readLong();
- this.mtime = in.readLong();
- }
-*/
+ public void readExternalRemote(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.id = in.readInt();
+ this.name = in.readUTF();
+ this.description = in.readUTF();
+ this.category = (ResourceCategory) in.readObject();
+ this.creationDataType = (ResourceCreationDataType) in.readObject();
+ this.createDeletePolicy = (CreateDeletePolicy) in.readObject();
+ this.supportsManualAdd = in.readBoolean();
+ this.singleton = in.readBoolean();
+ this.plugin = in.readUTF();
+ this.ctime = in.readLong();
+ this.mtime = in.readLong();
+ }
+ */
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceFacets.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceFacets.java
index cc3cb50..85905b5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceFacets.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceFacets.java
@@ -67,7 +67,7 @@ public class ResourceFacets implements Serializable {
}
public ResourceFacets(int resourceTypeId, Number measurement, Number event, Number pluginConfiguration,
- Number configuration, Number operation, Number content, Number callTime, Number support) {
+ Number configuration, Number operation, Number content, Number callTime, boolean support) {
this.resourceTypeId = resourceTypeId;
this.measurement = measurement.intValue() != 0;
this.event = event.intValue() != 0;
@@ -76,7 +76,7 @@ public class ResourceFacets implements Serializable {
this.operation = operation.intValue() != 0;
this.content = content.intValue() != 0;
this.callTime = callTime.intValue() != 0;
- this.support = support.intValue() != 0;
+ this.support = support;
initEnum();
}
diff --git a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
index c2ddc8d..ca642eb 100644
--- a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
@@ -240,6 +240,8 @@
</configuration>
</content>
+ <support/>
+
<help>
<![CDATA[
<h3>Binding to IP addresses</h3>
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index 45af5ba..734a28f 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -613,6 +613,8 @@
</c:simple-property>
</c:group>
</resource-configuration>
+
+ <support/>
<server name="RHQ Agent JVM"
description="JVM of the Management Agent"
14 years, 1 month
[rhq] Branch 'gwt' - 2 commits - modules/common modules/enterprise modules/plugins
by ips
modules/common/ant-bundle/pom.xml | 13 +++++
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java | 15 ++----
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java | 15 ++++++
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java | 24 +++-------
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java | 4 -
modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java | 13 ++---
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java | 14 +++--
7 files changed, 59 insertions(+), 39 deletions(-)
New commits:
commit e3f54d7a3cdea5a893e55a9e162a85f6d24a5181
Merge: 684d9f4... 0f08d69...
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Apr 26 17:36:58 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit 684d9f4d9ccf41ac7d0196cd175454d10b30b10a
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Apr 26 17:36:29 2010 -0400
fix some compile errors; move rhq.deploy.* sysprop name constants to their own class
diff --git a/modules/common/ant-bundle/pom.xml b/modules/common/ant-bundle/pom.xml
index ea97681..6349d81 100644
--- a/modules/common/ant-bundle/pom.xml
+++ b/modules/common/ant-bundle/pom.xml
@@ -1,4 +1,6 @@
-<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>
@@ -102,6 +104,15 @@
<descriptor>src/main/scripts/assembly.xml</descriptor>
</descriptors>
</configuration>
+ <executions>
+ <execution>
+ <id>assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
index 273c1ab..cc9525c 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
@@ -67,7 +67,6 @@ public class AntLauncher {
public BundleAntProject executeBundleDeployFile(File buildFile, String targetName, Properties properties,
File logFile, boolean logStdOut)
throws InvalidBuildFileException {
-
parseBundleDeployFile(buildFile);
BundleAntProject project = new BundleAntProject();
@@ -76,12 +75,6 @@ public class AntLauncher {
project.init();
project.setBaseDir(buildFile.getParentFile());
- project.setUserProperty(MagicNames.ANT_FILE,
- buildFile.getAbsolutePath());
- project.setUserProperty(MagicNames.ANT_FILE_TYPE,
- MagicNames.ANT_FILE_TYPE_FILE);
- ProjectHelper.configureProject(project, buildFile);
-
PrintWriter logFileOutput = null;
try {
logFileOutput = new PrintWriter(new FileOutputStream(logFile, true));
@@ -90,10 +83,15 @@ public class AntLauncher {
for (Map.Entry<Object, Object> property : properties.entrySet()) {
// On the assumption that these properties will be slurped in via Properties.load we
// need to escape backslashes to have them treated as literals
- project.setProperty(property.getKey().toString(), property.getValue().toString().replace("\\",
+ project.setUserProperty(property.getKey().toString(), property.getValue().toString().replace("\\",
"\\\\"));
}
}
+ project.setUserProperty(MagicNames.ANT_FILE,
+ buildFile.getAbsolutePath());
+ project.setUserProperty(MagicNames.ANT_FILE_TYPE,
+ MagicNames.ANT_FILE_TYPE_FILE);
+ ProjectHelper.configureProject(project, buildFile);
// notice we are adding the listener after we set the properties - we do not want the
// the properties echoed out in the log (in case they contain sensitive passwords)
@@ -172,7 +170,6 @@ public class AntLauncher {
}
private Properties buildTaskDefProperties(ClassLoader classLoader) throws IOException {
-
Set<String> customTaskDefs = new HashSet<String>(1);
customTaskDefs.add(ANTCONTRIB_ANT_TASKS);
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
new file mode 100644
index 0000000..822fd84
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
@@ -0,0 +1,15 @@
+package org.rhq.bundle.ant;
+
+/**
+ * @author Ian Springer
+ */
+public class DeployPropertyNames {
+ /** System property that should always be available to ant scripts - it's the location where the deployment should be installed */
+ public static final String DEPLOY_DIR = "rhq.deploy.dir";
+
+ /** System property that should always be available to ant scripts - it's the ID of the bundle deployment */
+ public static final String DEPLOY_ID = "rhq.deploy.id";
+
+ private DeployPropertyNames() {
+ }
+}
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
index 06d14d8..3d863ab 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
@@ -20,6 +20,7 @@ package org.rhq.bundle.ant.task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.rhq.bundle.ant.DeployPropertyNames;
import java.io.File;
import java.util.Hashtable;
@@ -28,12 +29,6 @@ import java.util.Hashtable;
* @author Ian Springer
*/
public class BundleTask extends AbstractBundleTask {
- // System property that should always be available to ant scripts - it's the location where the deployment should be installed
- public static final String DEPLOY_DIR_PROP = "rhq.deploy.dir";
-
- // System property that should always be available to ant scripts - it's the ID of the bundle deployment
- public static final String DEPLOY_ID_PROP = "rhq.deploy.id";
-
private String name;
private String version;
private String description;
@@ -55,34 +50,33 @@ public class BundleTask extends AbstractBundleTask {
Hashtable projectProps = getProject().getProperties();
// Make sure the requires System properties are defined and valid.
- String deployDir = (String) projectProps.get(DEPLOY_DIR_PROP);
+ String deployDir = (String) projectProps.get(DeployPropertyNames.DEPLOY_DIR);
if (deployDir == null) {
- throw new BuildException("Required property [" + DEPLOY_DIR_PROP + "] was not specified.");
+ throw new BuildException("Required property [" + DeployPropertyNames.DEPLOY_DIR + "] was not specified.");
}
File deployDirFile = new File(deployDir);
if (!deployDirFile.isAbsolute()) {
- throw new BuildException("Value of property [" + DEPLOY_DIR_PROP + "] (" + deployDirFile
+ throw new BuildException("Value of property [" + DeployPropertyNames.DEPLOY_DIR + "] (" + deployDirFile
+ ") is not an absolute path.");
}
getProject().setDeployDir(deployDirFile);
- log(DEPLOY_DIR_PROP + "=\"" + deployDir + "\"", Project.MSG_DEBUG);
+ log(DeployPropertyNames.DEPLOY_DIR + "=\"" + deployDir + "\"", Project.MSG_DEBUG);
- String deploymentIdStr = (String) projectProps.get(DEPLOY_ID_PROP);
+ String deploymentIdStr = (String) projectProps.get(DeployPropertyNames.DEPLOY_ID);
if (deploymentIdStr == null) {
- throw new BuildException("Required property [" + DEPLOY_ID_PROP + "] was not specified.");
+ throw new BuildException("Required property [" + DeployPropertyNames.DEPLOY_ID + "] was not specified.");
}
int deploymentId;
try {
deploymentId = Integer.parseInt(deploymentIdStr);
} catch (Exception e) {
- throw new BuildException("Value of property [" + DEPLOY_ID_PROP + "] (" + deploymentIdStr
+ throw new BuildException("Value of property [" + DeployPropertyNames.DEPLOY_ID + "] (" + deploymentIdStr
+ ") is not valid.", e);
}
getProject().setDeploymentId(deploymentId);
- log(DEPLOY_ID_PROP + "=\"" + deploymentId + "\"", Project.MSG_DEBUG);
+ log(DeployPropertyNames.DEPLOY_ID + "=\"" + deploymentId + "\"", Project.MSG_DEBUG);
log("Executing Ant script for bundle '" + this.name + "' version " + this.version + "...");
-
}
public String getDescription() {
diff --git a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
index e484ca5..2c98845 100644
--- a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
@@ -121,8 +121,8 @@ public class AntLauncherTest {
private Properties createInputProperties(String resourcePath) throws IOException {
Properties inputProps = new Properties();
- inputProps.setProperty(AntLauncher.DEPLOY_DIR_PROP, DEPLOY_DIR.getPath());
- inputProps.setProperty(AntLauncher.DEPLOY_ID_PROP, "100");
+ inputProps.setProperty(DeployPropertyNames.DEPLOY_DIR, DEPLOY_DIR.getPath());
+ inputProps.setProperty(DeployPropertyNames.DEPLOY_ID, "100");
InputStream inputStream = this.getClass().getResourceAsStream(resourcePath);
try {
inputProps.load(inputStream);
diff --git a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
index 8920bef..9301abd 100644
--- a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.enterprise.server.plugins.ant;
import java.io.ByteArrayInputStream;
@@ -55,21 +54,21 @@ public class AntBundleServerPluginComponent implements ServerPluginComponent, Bu
this.tmpDirectory = new File(this.context.getTemporaryDirectory(), "ant-bundle-server-plugin");
this.tmpDirectory.mkdirs();
if (!this.tmpDirectory.exists() || !this.tmpDirectory.isDirectory()) {
- throw new Exception("Failed to create tmp dir [" + this.tmpDirectory + "] - cannot process ant bundles");
+ throw new Exception("Failed to create tmp dir [" + this.tmpDirectory + "] - cannot process Ant bundles");
}
- log.debug("The ant bundle plugin has been initialized: " + this);
+ log.debug("The Ant bundle plugin has been initialized: " + this);
}
public void start() {
- log.debug("The ant bundle plugin has started: " + this);
+ log.debug("The Ant bundle plugin has started: " + this);
}
public void stop() {
- log.debug("The ant bundle plugin has stopped: " + this);
+ log.debug("The Ant bundle plugin has stopped: " + this);
}
public void shutdown() {
- log.debug("The ant bundle plugin has been shut down: " + this);
+ log.debug("The Ant bundle plugin has been shut down: " + this);
}
public RecipeParseResults parseRecipe(String recipe) throws Exception {
@@ -90,7 +89,7 @@ public class AntBundleServerPluginComponent implements ServerPluginComponent, Bu
// parse, but do not execute, the Ant script
AntLauncher antLauncher = new AntLauncher();
- BundleAntProject project = antLauncher.executeBundleDeployFile(recipeFile, null, null, null, logFile, false);
+ BundleAntProject project = antLauncher.parseBundleDeployFile(recipeFile);
// obtain the parse results
deploymentProps = new DeploymentProperties(0, project.getBundleName(),
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 657a440..6f9d206 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
@@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.bundle.ant.AntLauncher;
import org.rhq.bundle.ant.BundleAntProject;
+import org.rhq.bundle.ant.DeployPropertyNames;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleVersion;
@@ -58,15 +59,17 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
private File tmpDirectory;
public void start(ResourceContext context) throws Exception {
- resourceContext = context;
+ this.resourceContext = context;
this.tmpDirectory = new File(context.getTemporaryDirectory(), "ant-bundle-plugin");
this.tmpDirectory.mkdirs();
if (!this.tmpDirectory.exists() || !this.tmpDirectory.isDirectory()) {
throw new Exception("Failed to create tmp dir [" + this.tmpDirectory + "] - cannot process Ant bundles.");
}
+ return;
}
public void stop() {
+ return;
}
public AvailabilityType getAvailability() {
@@ -98,10 +101,10 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
throw new IllegalStateException("Bundle deployment does not specify install dir: "
+ bundleDeployment);
}
- antProps.setProperty(AntLauncher.DEPLOY_DIR_PROP, installDir);
+ antProps.setProperty(DeployPropertyNames.DEPLOY_DIR, installDir);
int deploymentId = bundleDeployment.getId();
- antProps.setProperty(AntLauncher.DEPLOY_ID_PROP, Integer.toString(deploymentId));
+ antProps.setProperty(DeployPropertyNames.DEPLOY_ID, Integer.toString(deploymentId));
Map<String, String> sysFacts = SystemInfoFactory.fetchTemplateEngine().getTokens();
for (Map.Entry<String, String> fact : sysFacts.entrySet()) {
@@ -125,9 +128,10 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
}
}
- // parse & execute, the ant script
+ // parse & execute the Ant script
AntLauncher antLauncher = new AntLauncher();
- BundleAntProject project = antLauncher.executeBundleDeployFile(recipeFile, null, null, antProps, logFile, true);
+ BundleAntProject project = antLauncher.executeBundleDeployFile(recipeFile, null, antProps, logFile,
+ true);
} catch (Throwable t) {
if (log.isDebugEnabled()) {
try {
14 years, 1 month
[rhq] 2 commits - modules/core modules/enterprise
by Joseph Marques
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java | 36 +++++-----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java | 5 +
4 files changed, 26 insertions(+), 21 deletions(-)
New commits:
commit d3cc735b22ba4548e5eef68b1dae73bf51335649
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 17:00:14 2010 -0400
BZ-562816: fix for stack trace when trying to edit general properties or conditions for an alert definition
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index afa5671..5a3aeba 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -448,8 +448,7 @@ public class AlertDefinition implements Serializable {
Set<AlertNotification> copiedNotifications = new HashSet<AlertNotification>();
for (AlertNotification oldNotification : new HashSet<AlertNotification>(alertDef.getAlertNotifications())) {
- AlertNotification newNotification = oldNotification.copy(copyIds);
- newNotification.setAlertDefinition(this);
+ AlertNotification newNotification = new AlertNotification(oldNotification, copyIds);
copiedNotifications.add(newNotification);
}
this.removeAllAlertNotifications();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index 1f14aad..1a7be46 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -79,7 +79,7 @@ public class AlertNotification implements Serializable {
private AlertNotificationTemplate alertNotificationTemplate;
@JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName = "ID")
- @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
+ @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
private Configuration configuration;
@Column(name = "SENDER_NAME")
@@ -108,6 +108,17 @@ public class AlertNotification implements Serializable {
this.configuration = config.deepCopy();
}
+ public AlertNotification(AlertNotification source, boolean copyIds) {
+ if (copyIds) {
+ this.id = source.id;
+ this.configuration = source.configuration;
+ } else {
+ this.configuration = source.configuration.deepCopy(false);
+ }
+ this.displayName = source.displayName;
+ this.senderName = source.senderName;
+ }
+
/**
* Constructor only for transient usage
* @param alertDefinitionId
@@ -136,31 +147,22 @@ public class AlertNotification implements Serializable {
this.alertDefinition = alertDefinition;
}
- public AlertNotification copy(boolean copyIds) {
- AlertNotification results = copy();
- if (copyIds) {
- results.id = this.id;
- }
- return results;
- }
-
- public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean cloneConfiguration) {
+ public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean copyIds) {
Configuration config;
- if (cloneConfiguration) {
- config = this.configuration.deepCopy(false);
- } else {
+ if (copyIds) {
config = this.configuration;
+ } else {
+ config = this.configuration.deepCopy(false);
}
AlertNotification notification = new AlertNotification(alertDefinition, config);
+ if (copyIds) {
+ notification.id = this.id;
+ }
notification.setDisplayName(this.displayName);
notification.setSenderName(this.senderName);
return notification;
}
- protected AlertNotification copy() {
- return new AlertNotification(this.alertDefinition, this.configuration);
- }
-
public void prepareForOrphanDelete() {
this.alertDefinition = null;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 8a4bb98..0e7682a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -393,7 +393,8 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
def.getAlertNotifications().clear();
for (AlertNotification notif : template.getNotifications()) {
- AlertNotification notification = notif.copyWithAlertDefintion(def, true);
+ AlertNotification notification = new AlertNotification(notif, true);
+ notification.setAlertDefinition(notif.getAlertDefinition());
entityManager.persist(notification.getConfiguration());
entityManager.persist(notification);
def.addAlertNotification(notification); // Attach a copy, as the ones in the template should not be shared
commit deef32fd46d29fa6bf9145ac360c9b1d59b2826a
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 16:28:38 2010 -0400
only print statistics for saved search result count recalculation if updates were non-zero
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
index a1e53b3..0e015e3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -80,7 +80,10 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
+ next.getPattern() + "']");
}
}
- LOG.info("Statistics: updated " + updated + " in " + totalMillis + " ms (" + errors + " errors)");
+ if (updated > 0) {
+ // only print non-zero stats
+ LOG.info("Statistics: updated " + updated + " in " + totalMillis + " ms (" + errors + " errors)");
+ }
}
private List<SavedSearch> getSavedSearchesNeedingRecomputation() {
14 years, 1 month
[rhq] Branch 'gwt' - modules/core
by mazz
modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java | 7
modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java | 39 ++++
modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java | 97 ++++++----
modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java | 38 ++-
modules/core/util/src/test/java/org/rhq/core/util/updater/UpdaterZipTest.java | 95 +++++----
5 files changed, 182 insertions(+), 94 deletions(-)
New commits:
commit 0f08d69b83c562d55f6ec0b1532e7a3ce57e9bce
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 26 16:53:18 2010 -0400
change of plans - all internally stored paths should be normalized using /
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
index 6c36c34..a93d96a 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
@@ -231,6 +231,11 @@ public class DeployDifferences {
* @return the converted path that is to be used to store in the internal sets.
*/
public String convertPath(String path) {
- return new File(path).getPath(); // makes sure e.g. the file separators are correct for this platform
+ if (File.separatorChar != '/') {
+ if (path != null) {
+ path = path.replace(File.separatorChar, '/');
+ }
+ }
+ return path;
}
}
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java
index bbbc511..5945abe 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java
@@ -287,6 +287,8 @@ public class FileHashcodeMap extends TreeMap<String, String> {
path = fileOrDir.getAbsolutePath().substring(rootPath.length() + 1);
}
+ path = convertPath(path);
+
// if this path is one the caller wants us to ignore, then return immediately
if (ignoreRegex != null && ignoreRegex.matcher(path).matches()) {
ignored.add(path);
@@ -344,4 +346,41 @@ public class FileHashcodeMap extends TreeMap<String, String> {
return unknowns;
}
+
+ @Override
+ public String put(String key, String value) {
+ return super.put(convertPath(key), value);
+ }
+
+ @Override
+ public String get(Object key) {
+ return super.get(convertPath((String) key));
+ }
+
+ @Override
+ public String remove(Object key) {
+ return super.remove(convertPath((String) key));
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return super.containsKey(convertPath((String) key));
+ }
+
+ /**
+ * Converts the path to the form that will be stored internally.
+ *
+ * @param path a filepath to be converted
+ *
+ * @return the converted path that is to be used to store in the internal sets.
+ */
+ public String convertPath(String path) {
+ if (File.separatorChar != '/') {
+ if (path != null) {
+ path = path.replace(File.separatorChar, '/');
+ }
+ }
+
+ return path;
+ }
}
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
index 53e6755..c87f829 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
@@ -45,6 +45,11 @@ import org.rhq.core.util.stream.StreamUtil;
@Test
public class DeployerTest {
+ // earlier we supported windows separators in the map, but i think we want to always support /
+ // this constant is here in case I want to move back to supporting windows paths explicitly
+ // we'd do this by "fileSeparator = File.separator;"
+ private static final String fileSeparator = "/";
+
private TemplateEngine templateEngine;
private String javaVersion;
@@ -215,14 +220,14 @@ public class DeployerTest {
final File metadir = new File(tmpDir, ".rhqdeployments");
final String file0 = "file0";
- final String file1 = "dir1" + File.separator + "file1";
- final String file2 = "dir1" + File.separator + "file2";
- final String file3 = "dir2" + File.separator + "file3";
- final String file4 = "dir3" + File.separator + "dir4" + File.separator + "file4";
+ final String file1 = "dir1" + fileSeparator + "file1";
+ final String file2 = "dir1" + fileSeparator + "file2";
+ final String file3 = "dir2" + fileSeparator + "file3";
+ final String file4 = "dir3" + fileSeparator + "dir4" + fileSeparator + "file4";
final String fileA = "fileA";
- final String fileB = "dir1" + File.separator + "fileB";
- final String fileC = "dir2" + File.separator + "fileC";
- final String file999 = "dir1" + File.separator + "file999";
+ final String fileB = "dir1" + fileSeparator + "fileB";
+ final String fileC = "dir2" + fileSeparator + "fileC";
+ final String file999 = "dir1" + fileSeparator + "file999";
try {
if (ignore) {
@@ -292,19 +297,47 @@ public class DeployerTest {
// TODO if this test is running on windows, we need to FileUtil.stripDriveLetter from the updater?absolute vars
boolean isWindows = File.separatorChar == '\\';
- String updaterBabsoluteBackupTo1 = new File(metadir, "1/ext-backup/" + updaterBabsolute.getAbsolutePath())
- .getAbsolutePath();
- String updaterBabsoluteBackupTo2 = new File(metadir, "2/ext-backup/" + updaterBabsolute.getAbsolutePath())
- .getAbsolutePath();
+ String updaterBabsoluteBackupTo1;
+ String updaterBabsoluteBackupTo2;
if (!isWindows) {
+ updaterBabsoluteBackupTo1 = new File(metadir, "1/ext-backup/" + updaterBabsolute.getAbsolutePath())
+ .getAbsolutePath();
+ updaterBabsoluteBackupTo2 = new File(metadir, "2/ext-backup/" + updaterBabsolute.getAbsolutePath())
+ .getAbsolutePath();
assert new File(updaterBabsoluteBackupTo1).exists() : "missing updateB.txt backup";
+ } else {
+ StringBuilder str = new StringBuilder(updaterBabsolute.getAbsolutePath());
+ String driveLetter = FileUtil.stripDriveLetter(str);
+ if (driveLetter != null) {
+ driveLetter = "_" + driveLetter + fileSeparator;
+ } else {
+ driveLetter = "";
+ }
+ updaterBabsoluteBackupTo1 = new File(metadir, "1/ext-backup/" + driveLetter + str.toString())
+ .getAbsolutePath();
+ updaterBabsoluteBackupTo2 = new File(metadir, "2/ext-backup/" + driveLetter + str.toString())
+ .getAbsolutePath();
}
- String updaterAabsoluteBackupTo1 = new File(metadir, "1/ext-backup/" + updaterAabsolute.getAbsolutePath())
- .getAbsolutePath();
- String updaterAabsoluteBackupTo2 = new File(metadir, "2/ext-backup/" + updaterAabsolute.getAbsolutePath())
- .getAbsolutePath();
+ String updaterAabsoluteBackupTo1;
+ String updaterAabsoluteBackupTo2;
if (!isWindows) {
+ updaterAabsoluteBackupTo1 = new File(metadir, "1/ext-backup/" + updaterAabsolute.getAbsolutePath())
+ .getAbsolutePath();
+ updaterAabsoluteBackupTo2 = new File(metadir, "2/ext-backup/" + updaterAabsolute.getAbsolutePath())
+ .getAbsolutePath();
assert new File(updaterAabsoluteBackupTo1).exists() : "missing updateA.txt backup";
+ } else {
+ StringBuilder str = new StringBuilder(updaterAabsolute.getAbsolutePath());
+ String driveLetter = FileUtil.stripDriveLetter(str);
+ if (driveLetter != null) {
+ driveLetter = "_" + driveLetter + fileSeparator;
+ } else {
+ driveLetter = "";
+ }
+ updaterAabsoluteBackupTo1 = new File(metadir, "1/ext-backup/" + driveLetter + str.toString())
+ .getAbsolutePath();
+ updaterAabsoluteBackupTo2 = new File(metadir, "2/ext-backup/" + driveLetter + str.toString())
+ .getAbsolutePath();
}
assert !(new File(tmpDir, file0).exists()) : "file0 should be deleted";
@@ -514,22 +547,22 @@ public class DeployerTest {
FileHashcodeMap map = FileHashcodeMap.generateFileHashcodeMap(destDir, null, null);
assert map.size() == 13 : map;
assert listener.getAddedFiles().size() == 13 : listener;
- String f = "dir1" + File.separator + "file1";
+ String f = "dir1" + fileSeparator + "file1";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir1" + File.separator + "file2";
+ f = "dir1" + fileSeparator + "file2";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir2" + File.separator + "file3";
+ f = "dir2" + fileSeparator + "file3";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir3" + File.separator + "dir4" + File.separator + "file4";
+ f = "dir3" + fileSeparator + "dir4" + fileSeparator + "file4";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
@@ -539,12 +572,12 @@ public class DeployerTest {
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir1" + File.separator + "fileB";
+ f = "dir1" + fileSeparator + "fileB";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir2" + File.separator + "fileC";
+ f = "dir2" + fileSeparator + "fileC";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
@@ -554,28 +587,28 @@ public class DeployerTest {
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir100" + File.separator + "file100";
+ f = "dir100" + fileSeparator + "file100";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir100" + File.separator + "file200";
+ f = "dir100" + fileSeparator + "file200";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir100" + File.separator + "fileBBB";
+ f = "dir100" + fileSeparator + "fileBBB";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dirA" + File.separator + "rawA.txt";
+ f = "dirA" + fileSeparator + "rawA.txt";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert MessageDigestGenerator.getDigestString(testRawFileA).equals(map.get(f)) : "should have same hash, we didn't realize this one";
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir100" + File.separator + "rawB.txt";
+ f = "dir100" + fileSeparator + "rawB.txt";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
@@ -608,22 +641,22 @@ public class DeployerTest {
FileHashcodeMap map = FileHashcodeMap.generateFileHashcodeMap(destDir, null, null);
assert map.size() == 7 : map;
assert listener.getAddedFiles().size() == 7 : listener;
- String f = "dir1" + File.separator + "file1";
+ String f = "dir1" + fileSeparator + "file1";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir1" + File.separator + "file2";
+ f = "dir1" + fileSeparator + "file2";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir2" + File.separator + "file3";
+ f = "dir2" + fileSeparator + "file3";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir3" + File.separator + "dir4" + File.separator + "file4";
+ f = "dir3" + fileSeparator + "dir4" + fileSeparator + "file4";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
@@ -633,12 +666,12 @@ public class DeployerTest {
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir1" + File.separator + "fileB";
+ f = "dir1" + fileSeparator + "fileB";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
assert listener.getAddedFiles().contains(f) : listener;
- f = "dir2" + File.separator + "fileC";
+ f = "dir2" + fileSeparator + "fileC";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
index 611764e..324d46c 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
@@ -40,6 +40,12 @@ import org.rhq.core.util.stream.StreamUtil;
@Test
public class FileHashcodeMapTest {
+
+ // earlier we supported windows separators in the map, but i think we want to always support /
+ // this constant is here in case I want to move back to supporting windows paths explicitly
+ // we'd do this by "fileSeparator = File.separator;"
+ private static final String fileSeparator = "/";
+
public void testError() throws Exception {
try {
FileHashcodeMap.generateFileHashcodeMap(new File("this/should/not/exist"), null, null);
@@ -148,16 +154,16 @@ public class FileHashcodeMapTest {
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
assert currentMap.containsKey("test3.txt") : currentMap;
- assert currentMap.containsKey("subdir" + File.separator + "test4.txt") : currentMap;
+ assert currentMap.containsKey("subdir" + fileSeparator + "test4.txt") : currentMap;
assert !currentMap.get("test1.txt").equals(originalMap.get("test1.txt")) : currentMap + ":" + originalMap;
assert currentMap.get("test2.txt").equals(FileHashcodeMap.DELETED_FILE_HASHCODE) : currentMap;
assert currentMap.get("test3.txt").equals(MessageDigestGenerator.getDigestString(testFile3)) : currentMap;
- assert currentMap.get("subdir" + File.separator + "test4.txt").equals(
+ assert currentMap.get("subdir" + fileSeparator + "test4.txt").equals(
MessageDigestGenerator.getDigestString(testFile4)) : currentMap;
assert currentMap.getAdditions().size() == 2;
assert currentMap.getAdditions().get("test3.txt").equals(currentMap.get("test3.txt"));
- assert currentMap.getAdditions().get("subdir" + File.separator + "test4.txt").equals(
- currentMap.get("subdir" + File.separator + "test4.txt"));
+ assert currentMap.getAdditions().get("subdir" + fileSeparator + "test4.txt").equals(
+ currentMap.get("subdir" + fileSeparator + "test4.txt"));
assert currentMap.getDeletions().size() == 1;
assert currentMap.getDeletions().get("test2.txt").equals(currentMap.get("test2.txt"));
assert currentMap.getChanges().size() == 1;
@@ -177,19 +183,19 @@ public class FileHashcodeMapTest {
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
assert currentMap.containsKey("test3.txt") : currentMap;
- assert currentMap.containsKey("subdir" + File.separator + "test4.txt") : currentMap;
+ assert currentMap.containsKey("subdir" + fileSeparator + "test4.txt") : currentMap;
assert currentMap.containsKey(absPathFile.getAbsolutePath()) : currentMap;
assert !currentMap.get("test1.txt").equals(originalMap.get("test1.txt")) : currentMap + ":" + originalMap;
assert currentMap.get("test2.txt").equals(FileHashcodeMap.DELETED_FILE_HASHCODE) : currentMap;
assert currentMap.get("test3.txt").equals(MessageDigestGenerator.getDigestString(testFile3)) : currentMap;
- assert currentMap.get("subdir" + File.separator + "test4.txt").equals(
+ assert currentMap.get("subdir" + fileSeparator + "test4.txt").equals(
MessageDigestGenerator.getDigestString(testFile4)) : currentMap;
assert currentMap.get(absPathFile.getAbsolutePath()).equals(originalMap.get(absPathFile.getAbsolutePath())) : currentMap
+ ":" + originalMap;
assert currentMap.getAdditions().size() == 2;
assert currentMap.getAdditions().get("test3.txt").equals(currentMap.get("test3.txt"));
- assert currentMap.getAdditions().get("subdir" + File.separator + "test4.txt").equals(
- currentMap.get("subdir" + File.separator + "test4.txt"));
+ assert currentMap.getAdditions().get("subdir" + fileSeparator + "test4.txt").equals(
+ currentMap.get("subdir" + fileSeparator + "test4.txt"));
assert currentMap.getDeletions().size() == 1;
assert currentMap.getDeletions().get("test2.txt").equals(currentMap.get("test2.txt"));
assert currentMap.getChanges().size() == 1;
@@ -205,19 +211,19 @@ public class FileHashcodeMapTest {
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
assert currentMap.containsKey("test3.txt") : currentMap;
- assert currentMap.containsKey("subdir" + File.separator + "test4.txt") : currentMap;
+ assert currentMap.containsKey("subdir" + fileSeparator + "test4.txt") : currentMap;
assert currentMap.containsKey(absPathFile.getAbsolutePath()) : currentMap;
assert !currentMap.get("test1.txt").equals(originalMap.get("test1.txt")) : currentMap + ":" + originalMap;
assert currentMap.get("test2.txt").equals(FileHashcodeMap.DELETED_FILE_HASHCODE) : currentMap;
assert currentMap.get("test3.txt").equals(MessageDigestGenerator.getDigestString(testFile3)) : currentMap;
- assert currentMap.get("subdir" + File.separator + "test4.txt").equals(
+ assert currentMap.get("subdir" + fileSeparator + "test4.txt").equals(
MessageDigestGenerator.getDigestString(testFile4)) : currentMap;
assert !currentMap.get(absPathFile.getAbsolutePath())
.equals(originalMap.get(absPathFile.getAbsolutePath())) : currentMap + ":" + originalMap;
assert currentMap.getAdditions().size() == 2;
assert currentMap.getAdditions().get("test3.txt").equals(currentMap.get("test3.txt"));
- assert currentMap.getAdditions().get("subdir" + File.separator + "test4.txt").equals(
- currentMap.get("subdir" + File.separator + "test4.txt"));
+ assert currentMap.getAdditions().get("subdir" + fileSeparator + "test4.txt").equals(
+ currentMap.get("subdir" + fileSeparator + "test4.txt"));
assert currentMap.getDeletions().size() == 1;
assert currentMap.getDeletions().get("test2.txt").equals(currentMap.get("test2.txt"));
assert currentMap.getChanges().size() == 2;
@@ -235,18 +241,18 @@ public class FileHashcodeMapTest {
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
assert currentMap.containsKey("test3.txt") : currentMap;
- assert currentMap.containsKey("subdir" + File.separator + "test4.txt") : currentMap;
+ assert currentMap.containsKey("subdir" + fileSeparator + "test4.txt") : currentMap;
assert currentMap.containsKey(absPathFile.getAbsolutePath()) : currentMap;
assert !currentMap.get("test1.txt").equals(originalMap.get("test1.txt")) : currentMap + ":" + originalMap;
assert currentMap.get("test2.txt").equals(FileHashcodeMap.DELETED_FILE_HASHCODE) : currentMap;
assert currentMap.get("test3.txt").equals(MessageDigestGenerator.getDigestString(testFile3)) : currentMap;
- assert currentMap.get("subdir" + File.separator + "test4.txt").equals(
+ assert currentMap.get("subdir" + fileSeparator + "test4.txt").equals(
MessageDigestGenerator.getDigestString(testFile4)) : currentMap;
assert currentMap.get(absPathFile.getAbsolutePath()).equals(FileHashcodeMap.DELETED_FILE_HASHCODE) : currentMap;
assert currentMap.getAdditions().size() == 2;
assert currentMap.getAdditions().get("test3.txt").equals(currentMap.get("test3.txt"));
- assert currentMap.getAdditions().get("subdir" + File.separator + "test4.txt").equals(
- currentMap.get("subdir" + File.separator + "test4.txt"));
+ assert currentMap.getAdditions().get("subdir" + fileSeparator + "test4.txt").equals(
+ currentMap.get("subdir" + fileSeparator + "test4.txt"));
assert currentMap.getDeletions().size() == 2;
assert currentMap.getDeletions().get("test2.txt").equals(currentMap.get("test2.txt"));
assert currentMap.getDeletions().get(absPathFile.getAbsolutePath()).equals(
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/UpdaterZipTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/UpdaterZipTest.java
index 61da454..b9574d3 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/UpdaterZipTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/UpdaterZipTest.java
@@ -41,6 +41,11 @@ import org.rhq.core.util.file.FileUtil;
@Test
public class UpdaterZipTest {
+ // earlier we supported windows separators in the map, but i think we want to always support /
+ // this constant is here in case I want to move back to supporting windows paths explicitly
+ // we'd do this by "fileSeparator = File.separator;"
+ private static final String fileSeparator = "/";
+
private TemplateEngine templateEngine;
private String javaVersion;
@@ -61,21 +66,21 @@ public class UpdaterZipTest {
File testZipFile = new File("target/test-classes/updater-test2.zip");
Set<String> skip = new HashSet<String>();
- skip.add("dir2" + File.separator + "file3");
- skip.add("dir3" + File.separator + "dir4" + File.separator + "file4");
+ skip.add("dir2" + fileSeparator + "file3");
+ skip.add("dir3" + fileSeparator + "dir4" + fileSeparator + "file4");
skip.add("fileA");
- skip.add("dir1" + File.separator + "fileB");
- skip.add("dir2" + File.separator + "fileC");
+ skip.add("dir1" + fileSeparator + "fileB");
+ skip.add("dir2" + fileSeparator + "fileC");
ExtractorZipFileVisitor visitorNoRealize = new ExtractorZipFileVisitor(tmpDir, null, templateEngine, skip,
null);
ZipUtil.walkZipFile(testZipFile, visitorNoRealize);
FileHashcodeMap mapRaw = visitorNoRealize.getFileHashcodeMap();
assert mapRaw.size() == 2 : mapRaw + ": all but 2 files in test jar should be skipped";
- String f = "dir1" + File.separator + "file1";
+ String f = "dir1" + fileSeparator + "file1";
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
- f = "dir1" + File.separator + "file2";
+ f = "dir1" + fileSeparator + "file2";
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
@@ -98,19 +103,19 @@ public class UpdaterZipTest {
FileHashcodeMap mapRaw = visitorNoRealize.getFileHashcodeMap();
assert mapRaw.size() == 7 : mapRaw;
- String f = "dir1" + File.separator + "file1";
+ String f = "dir1" + fileSeparator + "file1";
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
- f = "dir1" + File.separator + "file2";
+ f = "dir1" + fileSeparator + "file2";
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
- f = "dir2" + File.separator + "file3";
+ f = "dir2" + fileSeparator + "file3";
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
- f = "dir3" + File.separator + "dir4" + File.separator + "file4";
+ f = "dir3" + fileSeparator + "dir4" + fileSeparator + "file4";
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
@@ -118,11 +123,11 @@ public class UpdaterZipTest {
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
- f = "dir1" + File.separator + "fileB";
+ f = "dir1" + fileSeparator + "fileB";
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
- f = "dir2" + File.separator + "fileC";
+ f = "dir2" + fileSeparator + "fileC";
assert mapRaw.containsKey(f) : mapRaw;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(mapRaw.get(f));
@@ -138,23 +143,23 @@ public class UpdaterZipTest {
assert diff.getRealizedFiles().size() == 2 : diff;
assert diff.getRealizedFiles().containsKey("fileA") : diff;
- assert diff.getRealizedFiles().containsKey("dir1" + File.separator + "fileB") : diff;
+ assert diff.getRealizedFiles().containsKey("dir1" + fileSeparator + "fileB") : diff;
FileHashcodeMap map = visitor.getFileHashcodeMap();
assert map.size() == 7 : map;
- f = "dir1" + File.separator + "file1";
+ f = "dir1" + fileSeparator + "file1";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
- f = "dir1" + File.separator + "file2";
+ f = "dir1" + fileSeparator + "file2";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
- f = "dir2" + File.separator + "file3";
+ f = "dir2" + fileSeparator + "file3";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
- f = "dir3" + File.separator + "dir4" + File.separator + "file4";
+ f = "dir3" + fileSeparator + "dir4" + fileSeparator + "file4";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
@@ -162,25 +167,25 @@ public class UpdaterZipTest {
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
- f = "dir1" + File.separator + "fileB";
+ f = "dir1" + fileSeparator + "fileB";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
- f = "dir2" + File.separator + "fileC";
+ f = "dir2" + fileSeparator + "fileC";
assert map.containsKey(f) : map;
assert new File(tmpDir, f).exists();
assert MessageDigestGenerator.getDigestString(new File(tmpDir, f)).equals(map.get(f));
// check that our unrealized files between the two walks are the same
- assert map.get("dir1" + File.separator + "file1").equals(mapRaw.get("dir1" + File.separator + "file1"));
- assert map.get("dir1" + File.separator + "file2").equals(mapRaw.get("dir1" + File.separator + "file2"));
- assert map.get("dir2" + File.separator + "file3").equals(mapRaw.get("dir2" + File.separator + "file3"));
- assert map.get("dir3" + File.separator + "dir4" + File.separator + "file4").equals(
- mapRaw.get("dir3" + File.separator + "dir4" + File.separator + "file4"));
+ assert map.get("dir1" + fileSeparator + "file1").equals(mapRaw.get("dir1" + fileSeparator + "file1"));
+ assert map.get("dir1" + fileSeparator + "file2").equals(mapRaw.get("dir1" + fileSeparator + "file2"));
+ assert map.get("dir2" + fileSeparator + "file3").equals(mapRaw.get("dir2" + fileSeparator + "file3"));
+ assert map.get("dir3" + fileSeparator + "dir4" + fileSeparator + "file4").equals(
+ mapRaw.get("dir3" + fileSeparator + "dir4" + fileSeparator + "file4"));
// check that our realized files have different hashcodes from their unrealized forms
assert !map.get("fileA").equals(mapRaw.get("fileA"));
- assert !map.get("dir1" + File.separator + "fileB").equals(mapRaw.get("dir1" + File.separator + "fileB"));
+ assert !map.get("dir1" + fileSeparator + "fileB").equals(mapRaw.get("dir1" + fileSeparator + "fileB"));
} finally {
FileUtil.purge(tmpDir, true);
}
@@ -193,13 +198,13 @@ public class UpdaterZipTest {
ZipUtil.walkZipFile(testZipFile, visitorNoRealize);
FileHashcodeMap mapNoRealize = visitorNoRealize.getFileHashcodeMap();
assert mapNoRealize.size() == 7 : mapNoRealize;
- assert mapNoRealize.containsKey("dir1" + File.separator + "file1") : mapNoRealize;
- assert mapNoRealize.containsKey("dir1" + File.separator + "file2") : mapNoRealize;
- assert mapNoRealize.containsKey("dir2" + File.separator + "file3") : mapNoRealize;
- assert mapNoRealize.containsKey("dir3" + File.separator + "dir4" + File.separator + "file4") : mapNoRealize;
+ assert mapNoRealize.containsKey("dir1" + fileSeparator + "file1") : mapNoRealize;
+ assert mapNoRealize.containsKey("dir1" + fileSeparator + "file2") : mapNoRealize;
+ assert mapNoRealize.containsKey("dir2" + fileSeparator + "file3") : mapNoRealize;
+ assert mapNoRealize.containsKey("dir3" + fileSeparator + "dir4" + fileSeparator + "file4") : mapNoRealize;
assert mapNoRealize.containsKey("fileA") : mapNoRealize;
- assert mapNoRealize.containsKey("dir1" + File.separator + "fileB") : mapNoRealize;
- assert mapNoRealize.containsKey("dir2" + File.separator + "fileC") : mapNoRealize;
+ assert mapNoRealize.containsKey("dir1" + fileSeparator + "fileB") : mapNoRealize;
+ assert mapNoRealize.containsKey("dir2" + fileSeparator + "fileC") : mapNoRealize;
Pattern filesToRealizeRegex = Pattern.compile("(fileA)|(dir1.fileB)"); // '.' in place of file separator to support running test on windows & unix
InMemoryZipFileVisitor visitor = new InMemoryZipFileVisitor(filesToRealizeRegex, templateEngine);
@@ -207,31 +212,31 @@ public class UpdaterZipTest {
FileHashcodeMap map = visitor.getFileHashcodeMap();
assert map.size() == 7 : map;
- assert map.containsKey("dir1" + File.separator + "file1") : map;
- assert map.containsKey("dir1" + File.separator + "file2") : map;
- assert map.containsKey("dir2" + File.separator + "file3") : map;
- assert map.containsKey("dir3" + File.separator + "dir4" + File.separator + "file4") : map;
+ assert map.containsKey("dir1" + fileSeparator + "file1") : map;
+ assert map.containsKey("dir1" + fileSeparator + "file2") : map;
+ assert map.containsKey("dir2" + fileSeparator + "file3") : map;
+ assert map.containsKey("dir3" + fileSeparator + "dir4" + fileSeparator + "file4") : map;
assert map.containsKey("fileA") : map;
- assert map.containsKey("dir1" + File.separator + "fileB") : map;
- assert map.containsKey("dir2" + File.separator + "fileC") : map;
+ assert map.containsKey("dir1" + fileSeparator + "fileB") : map;
+ assert map.containsKey("dir2" + fileSeparator + "fileC") : map;
// check that our unrealized files between the two walks are the same
- assert map.get("dir1" + File.separator + "file1").equals(mapNoRealize.get("dir1" + File.separator + "file1"));
- assert map.get("dir1" + File.separator + "file2").equals(mapNoRealize.get("dir1" + File.separator + "file2"));
- assert map.get("dir2" + File.separator + "file3").equals(mapNoRealize.get("dir2" + File.separator + "file3"));
- assert map.get("dir3" + File.separator + "dir4" + File.separator + "file4").equals(
- mapNoRealize.get("dir3" + File.separator + "dir4" + File.separator + "file4"));
+ assert map.get("dir1" + fileSeparator + "file1").equals(mapNoRealize.get("dir1" + fileSeparator + "file1"));
+ assert map.get("dir1" + fileSeparator + "file2").equals(mapNoRealize.get("dir1" + fileSeparator + "file2"));
+ assert map.get("dir2" + fileSeparator + "file3").equals(mapNoRealize.get("dir2" + fileSeparator + "file3"));
+ assert map.get("dir3" + fileSeparator + "dir4" + fileSeparator + "file4").equals(
+ mapNoRealize.get("dir3" + fileSeparator + "dir4" + fileSeparator + "file4"));
// check that our realized files have different hashcodes from their unrealized forms
assert !map.get("fileA").equals(mapNoRealize.get("fileA"));
- assert !map.get("dir1" + File.separator + "fileB").equals(mapNoRealize.get("dir1" + File.separator + "fileB"));
+ assert !map.get("dir1" + fileSeparator + "fileB").equals(mapNoRealize.get("dir1" + fileSeparator + "fileB"));
}
public void testRealize() throws Exception {
File testZipFile = new File("target/test-classes/updater-test2.zip");
InMemoryZipEntryRealizer realizer = new InMemoryZipEntryRealizer(testZipFile, templateEngine);
String fileA = realizer.realize("fileA");
- String fileB = realizer.realize("dir1" + File.separator + "fileB");
+ String fileB = realizer.realize("dir1" + fileSeparator + "fileB");
assert fileA != null;
assert fileB != null;
assert fileA.contains("this is fileA") : fileA;
@@ -248,7 +253,7 @@ public class UpdaterZipTest {
File testZipFile = new File("target/test-classes/updater-test2.zip");
InMemoryZipEntryRealizer realizer = new InMemoryZipEntryRealizer(testZipFile, null); // notice a null template engine
String fileA = realizer.realize("fileA");
- String fileB = realizer.realize("dir1" + File.separator + "fileB");
+ String fileB = realizer.realize("dir1" + fileSeparator + "fileB");
assert fileA != null;
assert fileB != null;
assert fileA.contains("this is fileA") : fileA;
14 years, 1 month
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java | 60 +++++-----
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java | 7 -
3 files changed, 39 insertions(+), 33 deletions(-)
New commits:
commit 9937c0a8336afcf18245fe8614ad3fe413d178bc
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 15:52:28 2010 -0400
fix failure unit tests for saved searches subsystem
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
index 2cb808c..97f44dd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
@@ -31,7 +31,7 @@ public class SearchAssistManager {
private static List<String> booleanOperators = Arrays.asList("and", "or", "|");
private Subject subject;
- private AbstractSearchAssistant completor;
+ private SearchSubsystem searchSubsystem;
/*
* states:
@@ -278,10 +278,11 @@ public class SearchAssistManager {
public SearchAssistManager(Subject subject, SearchSubsystem searchSubsystem) {
this.subject = subject;
- this.completor = getAutoCompletor(searchSubsystem);
+ this.searchSubsystem = searchSubsystem;
+
}
- protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchSubsystem) {
+ protected AbstractSearchAssistant getSearchAssistant() {
if (searchSubsystem == SearchSubsystem.RESOURCE) {
return new ResourceSearchAssistant();
} else {
@@ -290,8 +291,8 @@ public class SearchAssistManager {
}
public List<String> getAllContexts() {
- List<String> results = new ArrayList<String>(completor.getSimpleContexts());
- for (String parameterized : completor.getParameterizedContexts()) {
+ List<String> results = new ArrayList<String>(getSearchAssistant().getSimpleContexts());
+ for (String parameterized : getSearchAssistant().getParameterizedContexts()) {
results.add(parameterized + "[");
}
return results;
@@ -299,7 +300,7 @@ public class SearchAssistManager {
public List<SearchSuggestion> getSuggestions(String expression, int caretPos) {
//List<SearchSuggestion> simple = getSimpleSuggestions(expression, caretPos);
- List<SearchSuggestion> advanced = getAdvancedSuggestions(expression, caretPos, SearchSuggestion.Kind.Advanced);
+ List<SearchSuggestion> advanced = getAdvancedSuggestions(expression, caretPos);
List<SearchSuggestion> userSavedSearches = getUserSavedSearchSuggestions(expression);
List<SearchSuggestion> globalSavedSearches = getGlobalSavedSearchSuggestions(expression);
@@ -313,11 +314,12 @@ public class SearchAssistManager {
}
public List<SearchSuggestion> getSimpleSuggestions(String expression, int caretPos) {
+ AbstractSearchAssistant completor = getSearchAssistant();
+
List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
for (String nextContext : completor.getSimpleContexts()) {
String intermediateExpression = nextContext + "=" + expression;
- List<SearchSuggestion> suggestions = getAdvancedSuggestions(intermediateExpression, caretPos,
- SearchSuggestion.Kind.Simple);
+ List<SearchSuggestion> suggestions = getAdvancedSuggestions(intermediateExpression, caretPos);
results.addAll(suggestions);
}
Collections.sort(results);
@@ -328,8 +330,9 @@ public class SearchAssistManager {
}
}
- public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos,
- SearchSuggestion.Kind targetKind) {
+ public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos) {
+ AbstractSearchAssistant completor = getSearchAssistant();
+
debug("getAdvancedSuggestions: START");
long id = HibernatePerformanceMonitor.get().start();
SearchTermAssistant assistant = new SearchTermAssistant(expression, caretPos);
@@ -339,7 +342,7 @@ public class SearchAssistManager {
if (tokens.length == 0) {
debug("getAdvancedSuggestions: no terms");
- return convert(getAllContexts(), targetKind); // no terms yet defined
+ return convert(getAllContexts()); // no terms yet defined
}
String beforeCaret = assistant.getFragmentBeforeCaret();
@@ -352,26 +355,26 @@ public class SearchAssistManager {
if (parsed.context.equals("")) {
if (tokens.length == 1) {
debug("getAdvancedSuggestions: no terms yet, suggesting contexts");
- return convert(getAllContexts(), targetKind);
+ return convert(getAllContexts());
} else if (isBooleanTerm(assistant.getPreviousToken())) {
debug("getAdvancedSuggestions: previous term was boolean, suggesting contexts");
- return convert(getAllContexts(), targetKind);
+ return convert(getAllContexts());
} else {
debug("getAdvancedSuggestions: previous term was not boolean, suggesting boolean");
- return convert(booleanOperators, targetKind);
+ return convert(booleanOperators);
}
} else if (isBooleanTerm(parsed.context)) {
debug("getAdvancedSuggestions: beforeCaret is whole boolean operator");
- return convert(getAllContexts(), targetKind); // TODO: should we tell user to type a space first?
+ return convert(getAllContexts()); // TODO: should we tell user to type a space first?
} else {
// check if this context is complete or not
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is simple context, wants operator");
- return convert(pad(parsed.context, comparisonOperators, ""), targetKind);
+ return convert(pad(parsed.context, comparisonOperators, ""));
}
if (completor.getParameterizedContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is parameterized context, wants open bracket");
- return convert(Arrays.asList(parsed.context + "["), targetKind);
+ return convert(Arrays.asList(parsed.context + "["));
}
debug("getAdvancedSuggestions: search term wants context completion");
@@ -386,12 +389,11 @@ public class SearchAssistManager {
startsWithContexts.add(context + "[");
}
}
- return convert(startsWithContexts, targetKind);
+ return convert(startsWithContexts);
}
case PARAM:
debug("getAdvancedSuggestions: param state");
- return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"),
- targetKind);
+ return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"));
case OPERATOR:
debug("getAdvancedSuggestions: operator state");
if (comparisonOperators.contains(parsed.operator)) {
@@ -399,11 +401,11 @@ public class SearchAssistManager {
List<String> valueSuggestions = pad("\"", completor.getValues(parsed.context, parsed.param, ""), "\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions,
- ""), targetKind);
+ ""));
}
}
@@ -416,9 +418,9 @@ public class SearchAssistManager {
debug("getAdvancedSuggestions: providing suggestions for comparison operators");
if (completor.getSimpleContexts().contains(parsed.context)) {
- return convert(pad(parsed.context, operatorSuggestions, ""), targetKind);
+ return convert(pad(parsed.context, operatorSuggestions, ""));
} else {
- return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""));
}
case VALUE:
debug("getAdvancedSuggestions: value state");
@@ -426,11 +428,10 @@ public class SearchAssistManager {
"\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
- return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""),
- targetKind);
+ return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""));
}
default:
return Collections.emptyList();
@@ -440,6 +441,7 @@ public class SearchAssistManager {
public List<SearchSuggestion> getUserSavedSearchSuggestions(String expression) {
SavedSearchCriteria criteria = new SavedSearchCriteria();
criteria.addFilterSubjectId(subject.getId());
+ criteria.addFilterSearchContext(searchSubsystem);
if (expression != null && expression.trim().equals("")) {
criteria.addFilterName(expression);
}
@@ -494,10 +496,10 @@ public class SearchAssistManager {
return false;
}
- private List<SearchSuggestion> convert(List<String> suggestions, SearchSuggestion.Kind targetKind) {
+ private List<SearchSuggestion> convert(List<String> suggestions) {
List<SearchSuggestion> results = new ArrayList<SearchSuggestion>(suggestions.size());
for (String suggestion : suggestions) {
- results.add(new SearchSuggestion(targetKind, suggestion));
+ results.add(new SearchSuggestion(Kind.Advanced, suggestion));
}
return results;
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
index 5d51d10..0a28dee 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
@@ -36,7 +36,7 @@ public class GenericSearchAssistTest extends AbstractEJB3Test {
}
count++;
- List<SearchSuggestion> results = new TestAutoCompletionManager().getSuggestions(expression,
+ List<SearchSuggestion> results = new TestAutoCompletionManager().getAdvancedSuggestions(expression,
expression.length());
List<String> expectedResults = Arrays.asList(expected.split(" "));
@@ -51,7 +51,8 @@ public class GenericSearchAssistTest extends AbstractEJB3Test {
}
System.out.println("Tested " + count + " expressions for assist");
} catch (Exception e) {
- System.out.println("Error testing single line RHQL: " + e);
+ System.out.println("Error testing GenericSearchAssistTest: " + e);
+ e.printStackTrace(System.out);
throw e;
} finally {
if (reader != null) {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
index 28a11a7..704146b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
@@ -9,6 +9,7 @@ import java.util.Map;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.enterprise.server.search.assist.AbstractSearchAssistant;
import org.rhq.enterprise.server.search.execution.SearchAssistManager;
+import org.rhq.enterprise.server.util.LookupUtil;
public class TestAutoCompletionManager extends SearchAssistManager {
public static class TestAutoCompletor extends AbstractSearchAssistant {
@@ -61,10 +62,12 @@ public class TestAutoCompletionManager extends SearchAssistManager {
}
public TestAutoCompletionManager() {
- super(null, null);
+ super(LookupUtil.getSubjectManager().getOverlord(), null);
}
- protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchContext) {
+ @Override
+ protected AbstractSearchAssistant getSearchAssistant() {
return new TestAutoCompletor();
+
}
}
14 years, 1 month
[rhq] Branch 'gwt' - 2 commits - modules/core
by mazz
modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java | 32 ++++++++++
modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java | 2
2 files changed, 33 insertions(+), 1 deletion(-)
New commits:
commit 47171a3a2e6ac628f3cda1d28568fde928b34183
Merge: f2738a0... 03050ca...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 26 15:25:35 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit f2738a00a56701e92def176127591351ed5fc9bc
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 26 15:25:25 2010 -0400
add more APIs to diff object to help avoid adding/removing/checking for wrong paths
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
index 86b6e54..6c36c34 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
@@ -61,6 +61,14 @@ public class DeployDifferences {
}
}
+ public void removeIgnoredFile(String path) {
+ this.ignoredFiles.remove(convertPath(path));
+ }
+
+ public boolean containsIgnoredFile(String path) {
+ return this.ignoredFiles.contains(convertPath(path));
+ }
+
public void addDeletedFile(String path) {
this.deletedFiles.add(convertPath(path));
}
@@ -71,6 +79,14 @@ public class DeployDifferences {
}
}
+ public void removeDeletedFile(String path) {
+ this.deletedFiles.remove(convertPath(path));
+ }
+
+ public boolean containsDeletedFile(String path) {
+ return this.deletedFiles.contains(convertPath(path));
+ }
+
public void addAddedFile(String path) {
this.addedFiles.add(convertPath(path));
}
@@ -81,6 +97,14 @@ public class DeployDifferences {
}
}
+ public void removeAddedFile(String path) {
+ this.addedFiles.remove(convertPath(path));
+ }
+
+ public boolean containsAddedFile(String path) {
+ return this.addedFiles.contains(convertPath(path));
+ }
+
public void addChangedFile(String path) {
this.changedFiles.add(convertPath(path));
}
@@ -91,6 +115,14 @@ public class DeployDifferences {
}
}
+ public void removeChangedFile(String path) {
+ this.changedFiles.remove(convertPath(path));
+ }
+
+ public boolean containsChangedFile(String path) {
+ return this.changedFiles.contains(convertPath(path));
+ }
+
public void addBackedUpFile(String originalPath, String backupPath) {
this.backedUpFiles.put(convertPath(originalPath), convertPath(backupPath));
}
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
index 83cb09b..4ffc883 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
@@ -277,7 +277,7 @@ public class Deployer {
if (newFileNotScannedFile.exists()) {
currentFilesToBackup.add(newFileNotScanned);
if (diff != null) {
- diff.getAddedFiles().remove(diff.convertPath(newFileNotScanned));
+ diff.removeAddedFile(newFileNotScanned);
diff.addChangedFile(newFileNotScanned);
}
}
14 years, 1 month
[rhq] Branch 'gwt' - 2 commits - modules/common modules/enterprise modules/plugins
by ips
modules/common/ant-bundle/pom.xml | 58
modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd | 98
modules/common/ant-bundle/src/main/assembly/bin/envset.cmd | 131 +
modules/common/ant-bundle/src/main/assembly/bin/lcp.bat | 31
modules/common/ant-bundle/src/main/assembly/bin/rhq-ant | 333 +++
modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd | 93
modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd | 60
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java | 240 +-
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntMain.java | 1085 ++++++++++
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java | 42
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java | 24
modules/common/ant-bundle/src/main/scripts/assembly.xml | 46
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java | 14
modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java | 2
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java | 2
15 files changed, 2102 insertions(+), 157 deletions(-)
New commits:
commit 03050ca636ab6ca9b73c9c20bfad497101e37bc2
Merge: 5b13457... f1f9fa7...
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Apr 26 15:19:05 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit 5b13457f168d67a9f57a2f4e174aa0befc1881e3
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Apr 26 15:18:35 2010 -0400
RHQ Ant command line wrapper + Maven assembly
diff --git a/modules/common/ant-bundle/pom.xml b/modules/common/ant-bundle/pom.xml
index eb05dc6..ea97681 100644
--- a/modules/common/ant-bundle/pom.xml
+++ b/modules/common/ant-bundle/pom.xml
@@ -28,20 +28,37 @@
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>rhq-core-native-system</artifactId>
<version>${project.version}</version>
- <scope>provided</scope>
<exclusions>
<exclusion>
- <groupId>org.hyperic</groupId>
- <artifactId>sigar</artifactId>
+ <groupId>org.hyperic</groupId>
+ <artifactId>sigar</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hyperic</groupId>
+ <artifactId>sigar-dist</artifactId>
</exclusion>
- <exclusion>
- <groupId>org.hyperic</groupId>
- <artifactId>sigar-dist</artifactId>
- </exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.0.jboss</version>
+ </dependency>
<dependency>
<groupId>org.apache.ant</groupId>
@@ -60,8 +77,33 @@
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>1.9.5</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/scripts/assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd b/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd
new file mode 100644
index 0000000..0460266
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd
@@ -0,0 +1,98 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+'@echo off'
+call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
+call SysLoadFuncs
+
+/* Prepare the parameters for later use */
+parse arg argv
+mode = ''
+args = ''
+opts = ''
+cp = ''
+lcp = ''
+
+do i = 1 to words(argv)
+ param = word(argv, i)
+ select
+ when param='-lcp' then mode = 'l'
+ when param='-cp' | param='-classpath' then mode = 'c'
+ when abbrev('-opts', param, 4) then mode = 'o'
+ when abbrev('-args', param, 4) then mode = 'a'
+ otherwise
+ select
+ when mode = 'a' then args = space(args param, 1)
+ when mode = 'c' then cp = space(cp param, 1)
+ when mode = 'l' then lcp = space(lcp param, 1)
+ when mode = 'o' then opts = space(opts param, 1)
+ otherwise
+ say 'Option' param 'ignored'
+ end
+ end
+end
+
+env="OS2ENVIRONMENT"
+antconf = _getenv_('antconf' 'antconf.cmd')
+runrc = _getenv_('runrc')
+interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC'
+ANT_HOME = value('ANT_HOME',,env)
+JAVA_HOME = value('JAVA_HOME',,env)
+classpath = value('CLASSPATH',,env)
+classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS")
+if classes \= '' then classpath = prepend(classpath classes)
+classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS")
+if classes \= '' then classpath = prepend(classpath classes)
+
+classpath = prepend(classpath ANT_HOME || '\lib\ant-launcher.jar')
+'SET CLASSPATH=' || classpath
+
+/* Setting classpathes, options and arguments */
+envset = _getenv_('envset')
+if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"'
+if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"'
+if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"'
+if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"'
+
+exit 0
+
+addpath: procedure
+parse arg path elem
+if elem = '' then do
+ if path\='' & right(path, 1)\=';' then path = path || ';'
+ return path
+end
+if substr(path, length(path)) = ';' then glue = ''
+else glue = ';'
+if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';'
+return path
+
+prepend: procedure
+parse arg path elem
+if elem = '' then do
+ if path\='' & right(path, 1)\=';' then path = path || ';'
+ return path
+end
+if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path
+return path
+
+_getenv_: procedure expose env
+parse arg envar default
+if default = '' then default = envar
+var = value(translate(envar),,env)
+if var = '' then var = default
+return var
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd b/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd
new file mode 100644
index 0000000..3149be4
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd
@@ -0,0 +1,131 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+SET environment variables
+First optional parameter:
+ ; parameters are considered parts of a path variable, semicolons are
+ appended to each element if not already present
+ -D parameters are properties for Java or Makefile etc., -D will be
+ prepended and the parameters will be separated by a space
+ =D the same as above but equal sign is not required
+ , parameters should be comma separated in the environment variable
+ - parameters should be separated by the next parameter
+ Other values mean that the first parameter is missing and the environment
+ variable will be set to the space separated parameters
+
+Second parameter: name of the environment variable
+
+Next parameters: values
+; implies that the equal sign is considered a part of the parameter and is
+not interpreted
+
+-D requires parameters in the form name=value. If the equal sign is not found,
+the parameters are changed to name=expanded_name
+
+Other options have optional equal sign. If it is found, only the part after
+the equal sign will be oprionally expanded.
+
+If the parameter is the minus sign, the next parameter will not be expanded.
+If the parameter is a single dot, it will be replaced with the value of the
+environment variable as it existed before envset was invoked.
+
+For other parameters the batch looks for the environment variable with the
+same name (in uppercase). If it is found, it forms the expanded_name. If
+the environment variable with such a name does not exist, the expanded_name
+will hold the parameter name without case conversion.
+*/
+
+parse arg mode envar args
+
+equal = 0
+sep = ' '
+
+/* Parse command line parameters */
+select
+ when mode='-' then do
+ sep = envar
+ parse var args envar args
+ end
+ when mode=';' then do
+ sep = ''
+ equal = -1
+ end
+ when mode='-D' then equal = 1
+ when mode='=D' then mode = '-D'
+ when mode=',' then sep = ','
+otherwise
+ args = envar args
+ envar = mode
+ mode = ''
+end
+
+env = 'OS2ENVIRONMENT'
+envar = translate(envar)
+orig = value(envar,,env)
+newval = ''
+expand = 1
+
+/* for each parameter... */
+do i = 1 to words(args)
+ if expand > 0 & word(args, i) = '-' then expand = 0
+ else call addval word(args, i)
+end
+
+/* Optionally enclose path variable by quotes */
+if mode = ';' & pos(' ', newval) > 0 then newval = '"' || newval || '"'
+
+/* Set the new value, 'SET' cannot be used since it does not allow '=' */
+x = value(envar, newval, env)
+exit 0
+
+addval: procedure expose sep equal orig expand newval mode env
+parse arg var
+
+if var = '.' then expvar = orig
+else do
+ if equal >= 0 then do
+ parse var var name '=' val
+ if val = '' then var = name
+ else var = val
+ end
+ if expand = 0 then expvar = var
+ else expvar = value(translate(var),,env)
+ if expvar = '' then expvar = var
+ if equal >= 0 then do
+ if val = '' then do
+ parse var expvar key '=' val
+ if val <> '' then name = key
+ else do
+ if equal > 0 then val = key
+ else name = key
+ end
+ end
+ else val = expvar
+ if pos(' ', val) > 0 | pos('=', val) > 0 then val = '"' || val || '"'
+ if val = '' then expvar = name
+ else expvar = name || '=' || val
+ end
+ if mode = '-D' then expvar = '-D' || expvar
+ if mode = ';' then do
+ if right(expvar, 1) <> ';' then expvar = expvar || ';'
+ end
+end
+
+if newval = '' then newval = expvar
+else newval = newval || sep || expvar
+expand = 1
+return
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat b/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat
new file mode 100644
index 0000000..dc7e9bf
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat
@@ -0,0 +1,31 @@
+REM
+REM Licensed to the Apache Software Foundation (ASF) under one or more
+REM contributor license agreements. See the NOTICE file distributed with
+REM this work for additional information regarding copyright ownership.
+REM The ASF licenses this file to You under the Apache License, Version 2.0
+REM (the "License"); you may not use this file except in compliance with
+REM the License. You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+REM
+REM
+
+set _CLASSPATHCOMPONENT=%1
+if ""%1""=="""" goto gotAllArgs
+shift
+
+:argCheck
+if ""%1""=="""" goto gotAllArgs
+set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1
+shift
+goto argCheck
+
+:gotAllArgs
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%_CLASSPATHCOMPONENT%
+
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant b/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant
new file mode 100755
index 0000000..86690fe
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant
@@ -0,0 +1,333 @@
+#! /bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Extract launch and ant arguments, (see details below).
+ant_exec_args=
+no_config=false
+use_jikes_default=false
+ant_exec_debug=false
+show_help=false
+for arg in "$@" ; do
+ if [ "$arg" = "--noconfig" ] ; then
+ no_config=true
+ elif [ "$arg" = "--usejikes" ] ; then
+ use_jikes_default=true
+ elif [ "$arg" = "--execdebug" ] ; then
+ ant_exec_debug=true
+ elif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ] ; then
+ show_help=true
+ ant_exec_args="$ant_exec_args -h"
+ else
+ if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then
+ show_help=true
+ fi
+ ant_exec_args="$ant_exec_args \"$arg\""
+ fi
+done
+
+# Source/default ant configuration
+if $no_config ; then
+ rpm_mode=false
+ usejikes=$use_jikes_default
+else
+ # load system-wide ant configuration (ONLY if RHQ_ANT_HOME has NOT been set)
+ if [ -z "$RHQ_ANT_HOME" ]; then
+ if [ -f "/etc/rhq-ant.conf" ] ; then
+ . /etc/rhq-ant.conf
+ fi
+ fi
+
+ # load user ant configuration
+ if [ -f "$HOME/.rhq/rhq-ant.conf" ] ; then
+ . $HOME/.rhq/rhq-ant.conf
+ fi
+
+ # provide default configuration values
+ if [ -z "$rpm_mode" ] ; then
+ rpm_mode=false
+ fi
+ if [ -z "$usejikes" ] ; then
+ usejikes=$use_jikes_default
+ fi
+fi
+
+# Setup Java environment in rpm mode
+if $rpm_mode ; then
+ if [ -f /usr/share/java-utils/java-functions ] ; then
+ . /usr/share/java-utils/java-functions
+ set_jvm
+ set_javacmd
+ fi
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false;
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ Darwin*) darwin=true
+ if [ -z "$JAVA_HOME" ] ; then
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+ fi
+ ;;
+ MINGW*) mingw=true ;;
+esac
+
+if [ -z "$RHQ_ANT_HOME" -o ! -d "$RHQ_ANT_HOME" ] ; then
+ ## resolve links - $0 may be a link to ant's home
+ PRG="$0"
+ progname=`basename "$0"`
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+ done
+
+ RHQ_ANT_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ RHQ_ANT_HOME=`cd "$RHQ_ANT_HOME" > /dev/null && pwd`
+fi
+
+# For Cygwin and Mingw, ensure paths are in UNIX format before
+# anything is touched
+if $cygwin ; then
+ [ -n "$RHQ_ANT_HOME" ] &&
+ RHQ_ANT_HOME=`cygpath --unix "$RHQ_ANT_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+if $mingw ; then
+ [ -n "$RHQ_ANT_HOME" ] &&
+ RHQ_ANT_HOME="`(cd "$RHQ_ANT_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+fi
+
+# set ANT_LIB location
+ANT_LIB="${RHQ_ANT_HOME}/lib"
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ elif [ -x "$JAVA_HOME/jre/bin/java" ] ; then
+ JAVACMD="$JAVA_HOME/jre/bin/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD=`which java 2> /dev/null `
+ if [ -z "$JAVACMD" ] ; then
+ JAVACMD=java
+ fi
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly."
+ echo " We cannot execute $JAVACMD"
+ exit 1
+fi
+
+# Build local classpath using just the launcher in non-rpm mode or
+# use the Jpackage helper in rpm mode with basic and default jars
+# specified in the ant.conf configuration. Because the launcher is
+# used, libraries linked in RHQ_ANT_HOME/lib will also be included, but this
+# is discouraged as it is not java-version safe. A user should
+# request optional jars and their dependencies via the OPT_JAR_LIST
+# variable
+if $rpm_mode && [ -x /usr/bin/build-classpath ] ; then
+ LOCALCLASSPATH="$(/usr/bin/build-classpath ant ant-launcher jaxp_parser_impl xml-commons-apis)"
+
+ # If no optional jars have been specified then build the default list
+ if [ -z "$OPT_JAR_LIST" ] ; then
+ for file in /etc/ant.d/*; do
+ if [ -f "$file" ]; then
+ case "$file" in
+ *~) ;;
+ *#*) ;;
+ *.rpmsave) ;;
+ *.rpmnew) ;;
+ *)
+ for dep in `cat "$file"`; do
+ case "$OPT_JAR_LIST" in
+ *"$dep"*) ;;
+ *) OPT_JAR_LIST="$OPT_JAR_LIST${OPT_JAR_LIST:+ }$dep"
+ esac
+ done
+ esac
+ fi
+ done
+ fi
+
+ # If the user requested to try to add some other jars to the classpath
+ if [ -n "$OPT_JAR_LIST" ] ; then
+ _OPTCLASSPATH="$(/usr/bin/build-classpath $OPT_JAR_LIST 2> /dev/null)"
+ if [ -n "$_OPTCLASSPATH" ] ; then
+ LOCALCLASSPATH="$LOCALCLASSPATH:$_OPTCLASSPATH"
+ fi
+ fi
+
+ # Explicitly add javac path to classpath, assume JAVA_HOME set
+ # properly in rpm mode
+ if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
+ LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
+ fi
+ if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
+ LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
+ fi
+
+ # if CLASSPATH_OVERRIDE env var is set, LOCALCLASSPATH will be
+ # user CLASSPATH first and ant-found jars after.
+ # In that case, the user CLASSPATH will override ant-found jars
+ #
+ # if CLASSPATH_OVERRIDE is not set, we'll have the normal behaviour
+ # with ant-found jars first and user CLASSPATH after
+ if [ -n "$CLASSPATH" ] ; then
+ # merge local and specified classpath
+ if [ -z "$LOCALCLASSPATH" ] ; then
+ LOCALCLASSPATH="$CLASSPATH"
+ elif [ -n "$CLASSPATH_OVERRIDE" ] ; then
+ LOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH"
+ else
+ LOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH"
+ fi
+
+ # remove class path from launcher -cp option
+ CLASSPATH=""
+ fi
+else
+ # not using rpm_mode; use launcher to determine classpaths
+ if [ -z "$LOCALCLASSPATH" ] ; then
+ LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
+ else
+ LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
+ fi
+fi
+
+if [ -n "$JAVA_HOME" ] ; then
+ # OSX hack to make Ant work with jikes
+ if $darwin ; then
+ OSXHACK="${JAVA_HOME}/../Classes"
+ if [ -d "${OSXHACK}" ] ; then
+ for i in "${OSXHACK}"/*.jar
+ do
+ JIKESPATH="$JIKESPATH:$i"
+ done
+ fi
+ fi
+fi
+
+# Allow Jikes support (off by default)
+if $usejikes; then
+ ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"
+fi
+
+# For Cygwin, switch paths to appropriate format before running java
+# For PATHs convert to unix format first, then to windows format to ensure
+# both formats are supported. Probably this will fail on directories with ;
+# in the name in the path. Let's assume that paths containing ; are more
+# rare than windows style paths on cygwin.
+if $cygwin; then
+ if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
+ format=mixed
+ else
+ format=windows
+ fi
+ [ -n "$RHQ_ANT_HOME" ] && RHQ_ANT_HOME=`cygpath --$format "$RHQ_ANT_HOME"`
+ ANT_LIB=`cygpath --$format "$ANT_LIB"`
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
+ LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`
+ LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`
+ if [ -n "$CLASSPATH" ] ; then
+ CP_TEMP=`cygpath --path --unix "$CLASSPATH"`
+ CLASSPATH=`cygpath --path --$format "$CP_TEMP"`
+ fi
+ CYGHOME=`cygpath --$format "$HOME"`
+fi
+
+# Show script help if requested
+if $show_help ; then
+ echo $0 '[script options] [options] [target [target2 [target3] ..]]'
+ echo 'Script Options:'
+ echo ' --help, --h print this message and ant help'
+ echo ' --noconfig suppress sourcing of /etc/ant.conf,'
+ echo ' $HOME/.ant/ant.conf, and $HOME/.antrc'
+ echo ' configuration files'
+ echo ' --usejikes enable use of jikes by default, unless'
+ echo ' set explicitly in configuration files'
+ echo ' --execdebug print ant exec line generated by this'
+ echo ' launch script'
+ echo ' '
+fi
+# add a second backslash to variables terminated by a backslash under cygwin
+if $cygwin; then
+ case "$RHQ_ANT_HOME" in
+ *\\ )
+ RHQ_ANT_HOME="$RHQ_ANT_HOME\\"
+ ;;
+ esac
+ case "$CYGHOME" in
+ *\\ )
+ CYGHOME="$CYGHOME\\"
+ ;;
+ esac
+ case "$JIKESPATH" in
+ *\\ )
+ JIKESPATH="$JIKESPATH\\"
+ ;;
+ esac
+ case "$LOCALCLASSPATH" in
+ *\\ )
+ LOCALCLASSPATH="$LOCALCLASSPATH\\"
+ ;;
+ esac
+ case "$CLASSPATH" in
+ *\\ )
+ CLASSPATH="$CLASSPATH\\"
+ ;;
+ esac
+fi
+# Execute ant using eval/exec to preserve spaces in paths,
+# java options, and ant args
+ant_sys_opts=
+if [ -n "$CYGHOME" ]; then
+ if [ -n "$JIKESPATH" ]; then
+ ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\" -Dcygwin.user.home=\"$CYGHOME\""
+ else
+ ant_sys_opts="-Dcygwin.user.home=\"$CYGHOME\""
+ fi
+else
+ if [ -n "$JIKESPATH" ]; then
+ ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
+ fi
+fi
+ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$RHQ_ANT_HOME\" -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -main org.rhq.bundle.ant.AntMain -cp \"$CLASSPATH\""
+if $ant_exec_debug ; then
+ echo $ant_exec_command $ant_exec_args
+fi
+eval $ant_exec_command "$ant_exec_args"
+
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd b/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd
new file mode 100644
index 0000000..70665c0
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd
@@ -0,0 +1,93 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Run ant
+*/
+
+'@echo off'
+parse arg mode envarg '::' antarg
+
+if mode\='.' & mode\='..' & mode\='/' then do
+ envarg = mode envarg
+ mode = ''
+end
+
+if antarg = '' then do
+ antarg = envarg
+ envarg = ''
+end
+
+x = setlocal()
+
+env="OS2ENVIRONMENT"
+antenv = _getenv_('antenv')
+if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"'
+
+if mode = '' then mode = _getenv_('ANT_MODE' '..')
+if mode \= '/' then do
+ runrc = _getenv_('runrc')
+ antrc = _getenv_('antrc' 'antrc.cmd')
+ if mode = '..' then mode = '-r'
+ else mode = ''
+ interpret 'call "' || runrc || '"' antrc '"' || mode || '"'
+end
+
+if _testenv_() = 0 then do
+ say 'Ant environment is not set properly'
+ x = endlocal()
+ exit 16
+end
+
+settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME
+
+java = _getenv_('javacmd' 'java')
+opts = value('ANT_OPTS',,env)
+args = value('ANT_ARGS',,env)
+lcp = value('LOCALCLASSPATH',,env)
+cp = value('CLASSPATH',,env)
+if value('ANT_USE_CP',,env) \= '' then do
+ if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';'
+ lcp = lcp || cp
+ 'SET CLASSPATH='
+end
+if lcp\='' then lcp = '-classpath' lcp
+
+cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg
+launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists')
+if launcher = '' then entry = 'org.apache.tools.ant.Main'
+else entry = 'org.apache.tools.ant.launch.Launcher'
+java opts lcp entry settings args antarg
+
+x = endlocal()
+
+return rc
+
+_testenv_: procedure expose env ANT_HOME JAVA_HOME
+ANT_HOME = value('ANT_HOME',,env)
+if ANT_HOME = '' then return 0
+JAVA_HOME = value('JAVA_HOME',,env)
+if JAVA_HOME = '' then return 0
+cp = translate(value('CLASSPATH',,env))
+if pos(translate(ANT_HOME), cp) = 0 then return 0
+if pos(translate(JAVA_HOME), cp) = 0 then return 0
+return 1
+
+_getenv_: procedure expose env
+parse arg envar default
+if default = '' then default = envar
+var = value(translate(envar),,env)
+if var = '' then var = default
+return var
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd b/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd
new file mode 100644
index 0000000..34b4f5d
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd
@@ -0,0 +1,60 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Run RC file, name is in the first arg, second arg is either PATH
+ ENV or -r or nothing
+*/
+
+parse arg name path rest
+
+if name = '' then do
+ say 'RC file name is missing'
+ exit 1
+end
+
+if rest \= '' then do
+ say 'Too many parameters'
+ exit 1
+end
+
+call runit name path
+exit 0
+
+runit: procedure
+parse arg name path dir
+
+if path \= '' & path \= '-r' then do
+ dir = value(translate(path),,'OS2ENVIRONMENT')
+ if dir = '' then return
+ dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */
+end
+
+if dir = '' then dir = directory()
+
+if path = '-r' then do /* recursive call */
+ subdir = filespec('path', dir)
+ if subdir \= '\' then do
+ subdir = left(subdir, length(subdir)-1)
+ call runit name path filespec('drive', dir) || subdir
+ end
+end
+
+/* Look for the file and run it */
+if right(dir, 1) \= '\' then dir = dir || '\'
+rcfile = stream(dir || name, 'c', 'query exists')
+if rcfile \= '' then interpret 'call "' || rcfile || '"'
+
+return
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
index bfa52bb..273c1ab 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
@@ -22,23 +22,12 @@
*/
package org.rhq.bundle.ant;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Vector;
+import java.io.*;
+import java.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Target;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.UnknownElement;
+import org.apache.tools.ant.*;
import org.apache.tools.ant.helper.AntXMLContext;
import org.apache.tools.ant.helper.ProjectHelper2;
@@ -48,71 +37,59 @@ import org.rhq.bundle.ant.task.InputPropertyTask;
/**
* This object enables you to invoke an Ant script within the running VM. You can fully run the script
- * or you can ask that the script just be parsed but no tasks execute.
+ * or you can ask that the script just be parsed and validated but no tasks executed.
*
* @author John Mazzitelli
* @author Ian Springer
*/
-public class AntLauncher {
- // system property that should always be available to ant scripts - its the location where the deployment should be installed
- public static final String DEPLOY_DIR_PROP = "rhq.deploy.dir";
+public class AntLauncher {
+ // "out of box" we will provide the ant contrib optional tasks (from ant-contrib.jar)
+ private static final String ANTCONTRIB_ANT_TASKS = "net/sf/antcontrib/antcontrib.properties";
- // system property that should always be available to ant scripts - its ID of the bundle deployment
- public static final String DEPLOY_ID_PROP = "rhq.deploy.id";
+ // "out of box" we will provide the liquibase tasks (from liquibase-core.jar)
+ private static final String LIQUIBASE_ANT_TASKS = "liquibasetasks.properties";
- // "out of box" we will provide the antcontrib optional tasks
- private static final String ANTCONTRIB_ANT_TASKS = "net/sf/antcontrib/antcontrib.properties";
+ // private constant ProjectHelper2.REFID_CONTEXT value
+ private static final String REFID_CONTEXT = "ant.parsing.context";
private final Log log = LogFactory.getLog(AntLauncher.class);
/**
* Launches Ant and parses the given build file and optionally executes it.
*
- * @param buildFile the build file that Ant will run
+ * @param buildFile the path to the build file (i.e. rhq-deploy.xml)
* @param targetName the target to run, <code>null</code> will run the default target
- * @param customTaskDefs the properties files found in classloader that contains all the taskdef definitions
* @param properties set of properties to set for the Ant task to access
* @param logFile where Ant messages will be logged
* @param logStdOut if <code>true</code>, log messages will be sent to stdout as well as the log file
- * @param execute if <code>true</code> the Ant script will be parsed and executed; otherwise, it will only be
- * parsed and validated
- *
- * @throws RuntimeException
+ * @return the bundle Ant project containing information about the specified build file
*/
- public BundleAntProject startAnt(File buildFile, String targetName, Set<String> customTaskDefs,
- Properties properties, File logFile, boolean logStdOut, boolean execute) {
+ public BundleAntProject executeBundleDeployFile(File buildFile, String targetName, Properties properties,
+ File logFile, boolean logStdOut)
+ throws InvalidBuildFileException {
+
+ parseBundleDeployFile(buildFile);
+
+ BundleAntProject project = new BundleAntProject();
+ ClassLoader classLoader = getClass().getClassLoader();
+ project.setCoreLoader(classLoader);
+ project.init();
+ project.setBaseDir(buildFile.getParentFile());
+
+ project.setUserProperty(MagicNames.ANT_FILE,
+ buildFile.getAbsolutePath());
+ project.setUserProperty(MagicNames.ANT_FILE_TYPE,
+ MagicNames.ANT_FILE_TYPE_FILE);
+ ProjectHelper.configureProject(project, buildFile);
PrintWriter logFileOutput = null;
-
try {
logFileOutput = new PrintWriter(new FileOutputStream(logFile, true));
- ClassLoader classLoader = getClass().getClassLoader();
-
- if (customTaskDefs == null) {
- customTaskDefs = new HashSet<String>(1);
- }
- customTaskDefs.add(ANTCONTRIB_ANT_TASKS); // we always want to provide these
-
- Properties taskDefs = new Properties();
- for (String customTaskDef : customTaskDefs) {
- InputStream taskDefsStream = classLoader.getResourceAsStream(customTaskDef);
- try {
- taskDefs.load(taskDefsStream);
- } finally {
- taskDefsStream.close();
- }
- }
-
- BundleAntProject project = new BundleAntProject();
- project.setCoreLoader(classLoader);
- project.init();
- project.setBaseDir(buildFile.getParentFile());
-
if (properties != null) {
for (Map.Entry<Object, Object> property : properties.entrySet()) {
// On the assumption that these properties will be slurped in via Properties.load we
- // need to escape backslashes to have them treated as literals
+ // need to escape backslashes to have them treated as literals
project.setProperty(property.getKey().toString(), property.getValue().toString().replace("\\",
"\\\\"));
}
@@ -126,93 +103,91 @@ public class AntLauncher {
project.addBuildListener(new LoggerAntBuildListener(targetName, stdout, Project.MSG_INFO));
}
- for (Map.Entry<Object, Object> taskDef : taskDefs.entrySet()) {
- project.addTaskDefinition(taskDef.getKey().toString(), Class.forName(taskDef.getValue().toString(),
- true, classLoader));
- }
+ // Add tasks defs for the Ant tasks that we bundle, so user won't have to explicitly declare them in their
+ // build file.
+ addTaskDefsForBundledTasks(project);
- class AllOrNothingTarget extends Target {
- public boolean doNothing = true;
+ // First execute the implicit target, which contains all tasks defined in the build file outside of any
+ // targets.
+ project.executeTarget("");
- @Override
- public void execute() throws BuildException {
- if (!doNothing) {
- super.execute();
- }
- }
+ // Now execute the target the user actually specified.
+ project.executeTarget((targetName == null) ? project.getDefaultTarget() : targetName);
+
+ return project;
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot run Ant on build file [" + buildFile + "]. Cause: " + e, e);
+ } finally {
+ if (logFileOutput != null) {
+ logFileOutput.close();
}
- AllOrNothingTarget allOrNothingTarget = new AllOrNothingTarget();
- allOrNothingTarget.setName("");
- allOrNothingTarget.setProject(project);
+ }
+ }
- AntXMLContext context = new AntXMLContext(project);
- context.setImplicitTarget(allOrNothingTarget);
- context.getTargets().clear();
- context.getTargets().addElement(context.getImplicitTarget());
+ public BundleAntProject parseBundleDeployFile(File buildFile) throws InvalidBuildFileException {
+ ClassLoader classLoader = getClass().getClassLoader();
- String REFID_CONTEXT = "ant.parsing.context"; // private constant ProjectHelper2.REFID_CONTEXT value
- project.addReference(REFID_CONTEXT, context);
- project.addReference(ProjectHelper2.REFID_TARGETS, context.getTargets());
+ BundleAntProject project = new BundleAntProject();
+ project.setCoreLoader(classLoader);
+ project.init();
+ project.setBaseDir(buildFile.getParentFile());
- ProjectHelper2 helper = new ProjectHelper2();
- try {
- helper.parse(project, buildFile);
- } catch (BuildException e) {
- throw new InvalidBuildFileException("Failed to parse bundle Ant build file.", e);
- }
+ AllOrNothingTarget allOrNothingTarget = new AllOrNothingTarget(true);
+ allOrNothingTarget.setName("");
+ allOrNothingTarget.setProject(project);
- validateAndPreprocess(project);
+ AntXMLContext context = new AntXMLContext(project);
+ context.setImplicitTarget(allOrNothingTarget);
+ context.getTargets().clear();
+ context.getTargets().addElement(context.getImplicitTarget());
- log.debug("==================== PARSED BUNDLE ANT BUILD FILE ====================");
- log.debug(" Bundle Name: " + project.getBundleName());
- log.debug(" Bundle Version: " + project.getBundleVersion());
- log.debug(" Bundle Description: " + project.getBundleDescription());
- log.debug(" Deployment Configuration: " + project.getConfiguration().toString(true));
- log.debug("======================================================================");
+ project.addReference(REFID_CONTEXT, context);
+ project.addReference(ProjectHelper2.REFID_TARGETS, context.getTargets());
- if (execute) {
- // parse it again, this time, allowing the implicit target to be executed
- allOrNothingTarget.doNothing = false;
- helper.parse(project, buildFile);
+ ProjectHelper2 helper = new ProjectHelper2();
+ try {
+ helper.parse(project, buildFile);
+ } catch (BuildException e) {
+ throw new InvalidBuildFileException("Failed to parse bundle Ant build file.", e);
+ }
- // make sure the requires system properties are defined and valid
- String deployDir = properties.getProperty(DEPLOY_DIR_PROP);
- if (deployDir == null) {
- throw new BuildException("Required property [" + DEPLOY_DIR_PROP + "] was not specified.");
- }
- File deployDirFile = new File(deployDir);
- if (!deployDirFile.isAbsolute()) {
- throw new BuildException("Value of property [" + DEPLOY_DIR_PROP + "] (" + deployDirFile
- + ") is not an absolute path.");
- }
- project.setDeployDir(deployDirFile);
+ validateAndPreprocess(project);
- String deploymentIdStr = properties.getProperty(DEPLOY_ID_PROP);
- if (deploymentIdStr == null) {
- throw new BuildException("Required property [" + DEPLOY_ID_PROP + "] was not specified.");
- }
- int deploymentId;
- try {
- deploymentId = Integer.parseInt(deploymentIdStr);
- } catch (Exception e) {
- throw new BuildException("Value of property [" + DEPLOY_ID_PROP + "] (" + deploymentIdStr
- + ") is not valid.", e);
- }
- project.setDeploymentId(deploymentId);
+ log.debug("==================== PARSED BUNDLE ANT BUILD FILE ====================");
+ log.debug(" Bundle Name: " + project.getBundleName());
+ log.debug(" Bundle Version: " + project.getBundleVersion());
+ log.debug(" Bundle Description: " + project.getBundleDescription());
+ log.debug(" Deployment Config Def: " + project.getConfigurationDefinition().getPropertyDefinitions().values());
+ log.debug("======================================================================");
- // now we can execute the ant script
- project.executeTarget((targetName == null) ? project.getDefaultTarget() : targetName);
- }
+ return project;
+ }
- return project;
+ private void addTaskDefsForBundledTasks(BundleAntProject project) throws IOException, ClassNotFoundException {
+ Properties taskDefs = buildTaskDefProperties(project.getCoreLoader());
+ for (Map.Entry<Object, Object> taskDef : taskDefs.entrySet()) {
+ project.addTaskDefinition(taskDef.getKey().toString(), Class.forName(taskDef.getValue().toString(),
+ true, project.getCoreLoader()));
+ }
+ }
- } catch (Exception e) {
- throw new RuntimeException("Cannot run Ant on build file [" + buildFile + "]. Cause: " + e, e);
- } finally {
- if (logFileOutput != null) {
- logFileOutput.close();
+ private Properties buildTaskDefProperties(ClassLoader classLoader) throws IOException {
+
+ Set<String> customTaskDefs = new HashSet<String>(1);
+
+ customTaskDefs.add(ANTCONTRIB_ANT_TASKS);
+ customTaskDefs.add(LIQUIBASE_ANT_TASKS);
+
+ Properties taskDefProps = new Properties();
+ for (String customTaskDef : customTaskDefs) {
+ InputStream taskDefsStream = classLoader.getResourceAsStream(customTaskDef);
+ try {
+ taskDefProps.load(taskDefsStream);
+ } finally {
+ taskDefsStream.close();
}
}
+ return taskDefProps;
}
private void validateAndPreprocess(BundleAntProject project) throws InvalidBuildFileException {
@@ -273,4 +248,19 @@ public class AntLauncher {
return task;
}
}
+
+ class AllOrNothingTarget extends Target {
+ public boolean doNothing = true;
+
+ AllOrNothingTarget(boolean doNothing) {
+ this.doNothing = doNothing;
+ }
+
+ @Override
+ public void execute() throws BuildException {
+ if (!doNothing) {
+ super.execute();
+ }
+ }
+ }
}
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntMain.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntMain.java
new file mode 100644
index 0000000..34177b0
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntMain.java
@@ -0,0 +1,1085 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.rhq.bundle.ant;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.tools.ant.*;
+import org.apache.tools.ant.input.DefaultInputHandler;
+import org.apache.tools.ant.input.InputHandler;
+import org.apache.tools.ant.util.ClasspathUtils;
+import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.ProxySetup;
+
+/**
+ * Command line entry point into RHQ Ant. This class is entered
+ * via the canonical `public static void main` entry point and
+ * reads the command line arguments. It then assembles and
+ * executes an RHQ Ant project (rhq-bundle.xml).
+ * <p>
+ * <b>NOTE:</b> This is a modified copy of the
+ * org.apache.tools.ant.Main class from Ant 1.8.0.
+ */
+public class AntMain implements org.apache.tools.ant.launch.AntMain {
+
+ /**
+ * A Set of args are are handled by the launcher and should
+ * not be seen by Main.
+ */
+ private static final Set LAUNCH_COMMANDS = new HashSet();
+ static {
+ LAUNCH_COMMANDS.add("-lib");
+ LAUNCH_COMMANDS.add("-cp");
+ LAUNCH_COMMANDS.add("-noclasspath");
+ LAUNCH_COMMANDS.add("--noclasspath");
+ LAUNCH_COMMANDS.add("-nouserlib");
+ LAUNCH_COMMANDS.add("-main");
+ }
+
+ /** The build file name. {@value} (RHQ: changed from build.xml) */
+ private static final String BUILD_FILE_NAME = "rhq-bundle.xml";
+
+ /** Our current message output status. Follows Project.MSG_XXX. */
+ private int msgOutputLevel = Project.MSG_INFO;
+
+ /** File that we are using for configuration. */
+ private File buildFile; /* null */
+
+ /** Stream to use for logging. */
+ private static PrintStream out = System.out;
+
+ /** Stream that we are using for logging error messages. */
+ private static PrintStream err = System.err;
+
+ /** The build targets. */
+ private Vector targets = new Vector();
+
+ /** Set of properties that can be used by tasks. */
+ private Properties definedProps = new Properties();
+
+ /** Names of classes to add as listeners to project. */
+ private Vector listeners = new Vector(1);
+
+ /** File names of property files to load on startup. */
+ private Vector propertyFiles = new Vector(1);
+
+ /** Indicates whether this build is to support interactive input */
+ private boolean allowInput = true;
+
+ /** keep going mode */
+ private boolean keepGoingMode = false;
+
+ /**
+ * The Ant logger class. There may be only one logger. It will have
+ * the right to use the 'out' PrintStream. The class must implements the
+ * BuildLogger interface.
+ */
+ private String loggerClassname = null;
+
+ /**
+ * The Ant InputHandler class. There may be only one input
+ * handler.
+ */
+ private String inputHandlerClassname = null;
+
+ /**
+ * Whether or not output to the log is to be unadorned.
+ */
+ private boolean emacsMode = false;
+
+ /**
+ * Whether or not this instance has successfully been
+ * constructed and is ready to run.
+ */
+ private boolean readyToRun = false;
+
+ /**
+ * Whether or not we should only parse and display the project help
+ * information.
+ */
+ private boolean projectHelp = false;
+
+ /**
+ * Whether or not a logfile is being used. This is used to
+ * check if the output streams must be closed.
+ */
+ private static boolean isLogFileUsed = false;
+
+ /**
+ * optional thread priority
+ */
+ private Integer threadPriority = null;
+
+ /**
+ * proxy flag: default is false
+ */
+ private boolean proxy = false;
+
+ /**
+ * Prints the message of the Throwable if it (the message) is not
+ * <code>null</code>.
+ *
+ * @param t Throwable to print the message of.
+ * Must not be <code>null</code>.
+ */
+ private static void printMessage(Throwable t) {
+ String message = t.getMessage();
+ if (message != null) {
+ System.err.println(message);
+ }
+ }
+
+ /**
+ * Creates a new instance of this class using the
+ * arguments specified, gives it any extra user properties which have been
+ * specified, and then runs the build using the classloader provided.
+ *
+ * @param args Command line arguments. Must not be <code>null</code>.
+ * @param additionalUserProperties Any extra properties to use in this
+ * build. May be <code>null</code>, which is the equivalent to
+ * passing in an empty set of properties.
+ * @param coreLoader Classloader used for core classes. May be
+ * <code>null</code> in which case the system classloader is used.
+ */
+ public static void start(String[] args, Properties additionalUserProperties,
+ ClassLoader coreLoader) {
+ Main m = new Main();
+ m.startAnt(args, additionalUserProperties, coreLoader);
+ }
+
+ /**
+ * Start Ant
+ * @param args command line args
+ * @param additionalUserProperties properties to set beyond those that
+ * may be specified on the args list
+ * @param coreLoader - not used
+ *
+ * @since Ant 1.6
+ */
+ public void startAnt(String[] args, Properties additionalUserProperties,
+ ClassLoader coreLoader) {
+ try {
+ Diagnostics.validateVersion();
+ processArgs(args);
+ } catch (Throwable exc) {
+ handleLogfile();
+ printMessage(exc);
+ exit(1);
+ return;
+ }
+
+ if (additionalUserProperties != null) {
+ for (Enumeration e = additionalUserProperties.keys();
+ e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ String property = additionalUserProperties.getProperty(key);
+ definedProps.put(key, property);
+ }
+ }
+
+ // expect the worst
+ int exitCode = 1;
+ try {
+ try {
+ runBuild(coreLoader);
+ exitCode = 0;
+ } catch (ExitStatusException ese) {
+ exitCode = ese.getStatus();
+ if (exitCode != 0) {
+ throw ese;
+ }
+ }
+ } catch (BuildException be) {
+ if (err != System.err) {
+ printMessage(be);
+ }
+ } catch (Throwable exc) {
+ exc.printStackTrace();
+ printMessage(exc);
+ } finally {
+ handleLogfile();
+ }
+ exit(exitCode);
+ }
+
+ /**
+ * This operation is expected to call {@link System#exit(int)}, which
+ * is what the base version does.
+ * However, it is possible to do something else.
+ * @param exitCode code to exit with
+ */
+ protected void exit(int exitCode) {
+ System.exit(exitCode);
+ }
+
+ /**
+ * Close logfiles, if we have been writing to them.
+ *
+ * @since Ant 1.6
+ */
+ private static void handleLogfile() {
+ if (isLogFileUsed) {
+ FileUtils.close(out);
+ FileUtils.close(err);
+ }
+ }
+
+ /**
+ * Command line entry point. This method kicks off the building
+ * of a project object and executes a build using either a given
+ * target or the default target.
+ *
+ * @param args Command line arguments. Must not be <code>null</code>.
+ */
+ public static void main(String[] args) {
+ start(args, null, null);
+ }
+
+ /**
+ * Constructor used when creating Main for later arg processing
+ * and startup
+ */
+ public AntMain() {
+ }
+
+ /**
+ * Sole constructor, which parses and deals with command line
+ * arguments.
+ *
+ * @param args Command line arguments. Must not be <code>null</code>.
+ *
+ * @exception BuildException if the specified build file doesn't exist
+ * or is a directory.
+ *
+ * @deprecated since 1.6.x
+ */
+ protected AntMain(String[] args) throws BuildException {
+ processArgs(args);
+ }
+
+ /**
+ * Process command line arguments.
+ * When ant is started from Launcher, launcher-only arguments do not get
+ * passed through to this routine.
+ *
+ * @param args the command line arguments.
+ *
+ * @since Ant 1.6
+ */
+ private void processArgs(String[] args) {
+ String searchForThis = null;
+ boolean searchForFile = false;
+ PrintStream logTo = null;
+
+ // cycle through given args
+
+ boolean justPrintUsage = false;
+ boolean justPrintVersion = false;
+ boolean justPrintDiagnostics = false;
+
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i];
+
+ if (arg.equals("-help") || arg.equals("-h")) {
+ justPrintUsage = true;
+ } else if (arg.equals("-version")) {
+ justPrintVersion = true;
+ } else if (arg.equals("-diagnostics")) {
+ justPrintDiagnostics = true;
+ } else if (arg.equals("-quiet") || arg.equals("-q")) {
+ msgOutputLevel = Project.MSG_WARN;
+ } else if (arg.equals("-verbose") || arg.equals("-v")) {
+ msgOutputLevel = Project.MSG_VERBOSE;
+ } else if (arg.equals("-debug") || arg.equals("-d")) {
+ msgOutputLevel = Project.MSG_DEBUG;
+ } else if (arg.equals("-noinput")) {
+ allowInput = false;
+ } else if (arg.equals("-logfile") || arg.equals("-l")) {
+ try {
+ File logFile = new File(args[i + 1]);
+ i++;
+ logTo = new PrintStream(new FileOutputStream(logFile));
+ isLogFileUsed = true;
+ } catch (IOException ioe) {
+ String msg = "Cannot write on the specified log file. "
+ + "Make sure the path exists and you have write "
+ + "permissions.";
+ throw new BuildException(msg);
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ String msg = "You must specify a log file when "
+ + "using the -log argument";
+ throw new BuildException(msg);
+ }
+ } else if (arg.equals("-listener")) {
+ i = handleArgListener(args, i);
+ } else if (arg.startsWith("-D")) {
+ i = handleArgDefine(args, i);
+ } else if (arg.equals("-logger")) {
+ i = handleArgLogger(args, i);
+ } else if (arg.equals("-inputhandler")) {
+ i = handleArgInputHandler(args, i);
+ } else if (arg.equals("-emacs") || arg.equals("-e")) {
+ emacsMode = true;
+ } else if (arg.equals("-projecthelp") || arg.equals("-p")) {
+ // set the flag to display the targets and quit
+ projectHelp = true;
+ } else if (arg.startsWith("-propertyfile")) {
+ i = handleArgPropertyFile(args, i);
+ } else if (arg.equals("-k") || arg.equals("-keep-going")) {
+ keepGoingMode = true;
+ } else if (arg.equals("-nice")) {
+ i = handleArgNice(args, i);
+ } else if (LAUNCH_COMMANDS.contains(arg)) {
+ //catch script/ant mismatch with a meaningful message
+ //we could ignore it, but there are likely to be other
+ //version problems, so we stamp down on the configuration now
+ String msg = "Ant's Main method is being handed "
+ + "an option " + arg + " that is only for the launcher class."
+ + "\nThis can be caused by a version mismatch between "
+ + "the ant script/.bat file and Ant itself.";
+ throw new BuildException(msg);
+ } else if (arg.equals("-autoproxy")) {
+ proxy = true;
+ } else if (arg.startsWith("-")) {
+ // we don't have any more args to recognize!
+ String msg = "Unknown argument: " + arg;
+ System.err.println(msg);
+ printUsage();
+ throw new BuildException("");
+ } else {
+ // if it's no other arg, it may be the target
+ targets.addElement(arg);
+ }
+ }
+
+ if (msgOutputLevel >= Project.MSG_VERBOSE || justPrintVersion) {
+ printVersion(msgOutputLevel);
+ }
+
+ if (justPrintUsage || justPrintVersion || justPrintDiagnostics) {
+ if (justPrintUsage) {
+ printUsage();
+ }
+ if (justPrintDiagnostics) {
+ Diagnostics.doReport(System.out, msgOutputLevel);
+ }
+ return;
+ }
+
+ // RHQ: The build file is not configurable - it's always ./rhq-bundle.xml.
+ buildFile = new File(BUILD_FILE_NAME);
+
+ // make sure buildfile exists
+ if (!buildFile.exists()) {
+ System.out.println("Buildfile: " + buildFile + " does not exist!");
+ throw new BuildException("Build failed");
+ }
+
+ // make sure it's not a directory (this falls into the ultra
+ // paranoid lets check everything category
+
+ if (buildFile.isDirectory()) {
+ System.out.println("What? Buildfile: " + buildFile + " is a dir!");
+ throw new BuildException("Build failed");
+ }
+
+ // Normalize buildFile for re-import detection
+ buildFile =
+ FileUtils.getFileUtils().normalize(buildFile.getAbsolutePath());
+
+ // Load the property files specified by -propertyfile
+ loadPropertyFiles();
+
+ if (msgOutputLevel >= Project.MSG_INFO) {
+ System.out.println("Buildfile: " + buildFile);
+ }
+
+ if (logTo != null) {
+ out = logTo;
+ err = logTo;
+ System.setOut(out);
+ System.setErr(err);
+ }
+ readyToRun = true;
+ }
+
+ // --------------------------------------------------------
+ // Methods for handling the command line arguments
+ // --------------------------------------------------------
+
+ /** Handle -listener argument */
+ private int handleArgListener(String[] args, int pos) {
+ try {
+ listeners.addElement(args[pos + 1]);
+ pos++;
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ String msg = "You must specify a classname when "
+ + "using the -listener argument";
+ throw new BuildException(msg);
+ }
+ return pos;
+ }
+
+ /** Handler -D argument */
+ private int handleArgDefine(String[] args, int argPos) {
+ /* Interestingly enough, we get to here when a user
+ * uses -Dname=value. However, in some cases, the OS
+ * goes ahead and parses this out to args
+ * {"-Dname", "value"}
+ * so instead of parsing on "=", we just make the "-D"
+ * characters go away and skip one argument forward.
+ *
+ * I don't know how to predict when the JDK is going
+ * to help or not, so we simply look for the equals sign.
+ */
+ String arg = args[argPos];
+ String name = arg.substring(2, arg.length());
+ String value = null;
+ int posEq = name.indexOf("=");
+ if (posEq > 0) {
+ value = name.substring(posEq + 1);
+ name = name.substring(0, posEq);
+ } else if (argPos < args.length - 1) {
+ value = args[++argPos];
+ } else {
+ throw new BuildException("Missing value for property "
+ + name);
+ }
+ definedProps.put(name, value);
+ return argPos;
+ }
+
+ /** Handle the -logger argument. */
+ private int handleArgLogger(String[] args, int pos) {
+ if (loggerClassname != null) {
+ throw new BuildException(
+ "Only one logger class may be specified.");
+ }
+ try {
+ loggerClassname = args[++pos];
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ throw new BuildException(
+ "You must specify a classname when using the -logger argument");
+ }
+ return pos;
+ }
+
+ /** Handle the -inputhandler argument. */
+ private int handleArgInputHandler(String[] args, int pos) {
+ if (inputHandlerClassname != null) {
+ throw new BuildException("Only one input handler class may "
+ + "be specified.");
+ }
+ try {
+ inputHandlerClassname = args[++pos];
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ throw new BuildException("You must specify a classname when"
+ + " using the -inputhandler"
+ + " argument");
+ }
+ return pos;
+ }
+
+ /** Handle the -propertyfile argument. */
+ private int handleArgPropertyFile(String[] args, int pos) {
+ try {
+ propertyFiles.addElement(args[++pos]);
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ String msg = "You must specify a property filename when "
+ + "using the -propertyfile argument";
+ throw new BuildException(msg);
+ }
+ return pos;
+ }
+
+ /** Handle the -nice argument. */
+ private int handleArgNice(String[] args, int pos) {
+ try {
+ threadPriority = Integer.decode(args[++pos]);
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ throw new BuildException(
+ "You must supply a niceness value (1-10)"
+ + " after the -nice option");
+ } catch (NumberFormatException e) {
+ throw new BuildException("Unrecognized niceness value: "
+ + args[pos]);
+ }
+
+ if (threadPriority.intValue() < Thread.MIN_PRIORITY
+ || threadPriority.intValue() > Thread.MAX_PRIORITY) {
+ throw new BuildException(
+ "Niceness value is out of the range 1-10");
+ }
+ return pos;
+ }
+
+ // --------------------------------------------------------
+ // other methods
+ // --------------------------------------------------------
+
+ /** Load the property files specified by -propertyfile */
+ private void loadPropertyFiles() {
+ for (int propertyFileIndex = 0;
+ propertyFileIndex < propertyFiles.size();
+ propertyFileIndex++) {
+ String filename
+ = (String) propertyFiles.elementAt(propertyFileIndex);
+ Properties props = new Properties();
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(filename);
+ props.load(fis);
+ } catch (IOException e) {
+ System.out.println("Could not load property file "
+ + filename + ": " + e.getMessage());
+ } finally {
+ FileUtils.close(fis);
+ }
+
+ // ensure that -D properties take precedence
+ Enumeration propertyNames = props.propertyNames();
+ while (propertyNames.hasMoreElements()) {
+ String name = (String) propertyNames.nextElement();
+ if (definedProps.getProperty(name) == null) {
+ definedProps.put(name, props.getProperty(name));
+ }
+ }
+ }
+ }
+
+ /**
+ * Helper to get the parent file for a given file.
+ * <p>
+ * Added to simulate File.getParentFile() from JDK 1.2.
+ * @deprecated since 1.6.x
+ *
+ * @param file File to find parent of. Must not be <code>null</code>.
+ * @return Parent file or null if none
+ */
+ private File getParentFile(File file) {
+ File parent = file.getParentFile();
+
+ if (parent != null && msgOutputLevel >= Project.MSG_VERBOSE) {
+ System.out.println("Searching in " + parent.getAbsolutePath());
+ }
+
+ return parent;
+ }
+
+ /**
+ * Executes the build. If the constructor for this instance failed
+ * (e.g. returned after issuing a warning), this method returns
+ * immediately.
+ *
+ * @param coreLoader The classloader to use to find core classes.
+ * May be <code>null</code>, in which case the
+ * system classloader is used.
+ *
+ * @exception BuildException if the build fails
+ */
+ private void runBuild(ClassLoader coreLoader) throws BuildException {
+
+ if (!readyToRun) {
+ return;
+ }
+
+ // RHQ: We use our own special Project subclass that adds a few extra bundle-related fields.
+ final Project project = new BundleAntProject();
+ project.setCoreLoader(coreLoader);
+
+ Throwable error = null;
+
+ try {
+ addBuildListeners(project);
+ addInputHandler(project);
+
+ PrintStream savedErr = System.err;
+ PrintStream savedOut = System.out;
+ InputStream savedIn = System.in;
+
+ // use a system manager that prevents from System.exit()
+ SecurityManager oldsm = null;
+ oldsm = System.getSecurityManager();
+
+ //SecurityManager can not be installed here for backwards
+ //compatibility reasons (PD). Needs to be loaded prior to
+ //ant class if we are going to implement it.
+ //System.setSecurityManager(new NoExitSecurityManager());
+ try {
+ if (allowInput) {
+ project.setDefaultInputStream(System.in);
+ }
+ System.setIn(new DemuxInputStream(project));
+ System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
+ System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
+
+
+ if (!projectHelp) {
+ project.fireBuildStarted();
+ }
+
+ // set the thread priorities
+ if (threadPriority != null) {
+ try {
+ project.log("Setting Ant's thread priority to "
+ + threadPriority, Project.MSG_VERBOSE);
+ Thread.currentThread().setPriority(threadPriority.intValue());
+ } catch (SecurityException swallowed) {
+ //we cannot set the priority here.
+ project.log("A security manager refused to set the -nice value");
+ }
+ }
+
+
+ project.init();
+
+ // set user-define properties
+ Enumeration e = definedProps.keys();
+ while (e.hasMoreElements()) {
+ String arg = (String) e.nextElement();
+ String value = (String) definedProps.get(arg);
+ project.setUserProperty(arg, value);
+ }
+
+ project.setUserProperty(MagicNames.ANT_FILE,
+ buildFile.getAbsolutePath());
+ project.setUserProperty(MagicNames.ANT_FILE_TYPE,
+ MagicNames.ANT_FILE_TYPE_FILE);
+
+ project.setKeepGoingMode(keepGoingMode);
+ if (proxy) {
+ //proxy setup if enabled
+ ProxySetup proxySetup = new ProxySetup(project);
+ proxySetup.enableProxies();
+ }
+
+ ProjectHelper.configureProject(project, buildFile);
+
+ if (projectHelp) {
+ printDescription(project);
+ printTargets(project, msgOutputLevel > Project.MSG_INFO);
+ return;
+ }
+
+ // make sure that we have a target to execute
+ if (targets.size() == 0) {
+ if (project.getDefaultTarget() != null) {
+ targets.addElement(project.getDefaultTarget());
+ }
+ }
+
+ project.executeTargets(targets);
+ } finally {
+ // put back the original security manager
+ //The following will never eval to true. (PD)
+ if (oldsm != null) {
+ System.setSecurityManager(oldsm);
+ }
+
+ System.setOut(savedOut);
+ System.setErr(savedErr);
+ System.setIn(savedIn);
+ }
+ } catch (RuntimeException exc) {
+ error = exc;
+ throw exc;
+ } catch (Error e) {
+ error = e;
+ throw e;
+ } finally {
+ if (!projectHelp) {
+ try {
+ project.fireBuildFinished(error);
+ } catch (Throwable t) {
+ // yes, I know it is bad style to catch Throwable,
+ // but if we don't, we lose valuable information
+ System.err.println("Caught an exception while logging the"
+ + " end of the build. Exception was:");
+ t.printStackTrace();
+ if (error != null) {
+ System.err.println("There has been an error prior to"
+ + " that:");
+ error.printStackTrace();
+ }
+ throw new BuildException(t);
+ }
+ } else if (error != null) {
+ project.log(error.toString(), Project.MSG_ERR);
+ }
+ }
+ }
+
+ /**
+ * Adds the listeners specified in the command line arguments,
+ * along with the default listener, to the specified project.
+ *
+ * @param project The project to add listeners to.
+ * Must not be <code>null</code>.
+ */
+ protected void addBuildListeners(Project project) {
+
+ // Add the default listener
+ project.addBuildListener(createLogger());
+
+ for (int i = 0; i < listeners.size(); i++) {
+ String className = (String) listeners.elementAt(i);
+ BuildListener listener =
+ (BuildListener) ClasspathUtils.newInstance(className,
+ Main.class.getClassLoader(), BuildListener.class);
+ project.setProjectReference(listener);
+
+ project.addBuildListener(listener);
+ }
+ }
+
+ /**
+ * Creates the InputHandler and adds it to the project.
+ *
+ * @param project the project instance.
+ *
+ * @exception BuildException if a specified InputHandler
+ * implementation could not be loaded.
+ */
+ private void addInputHandler(Project project) throws BuildException {
+ InputHandler handler = null;
+ if (inputHandlerClassname == null) {
+ handler = new DefaultInputHandler();
+ } else {
+ handler = (InputHandler) ClasspathUtils.newInstance(
+ inputHandlerClassname, Main.class.getClassLoader(),
+ InputHandler.class);
+ project.setProjectReference(handler);
+ }
+ project.setInputHandler(handler);
+ }
+
+ // XXX: (Jon Skeet) Any reason for writing a message and then using a bare
+ // RuntimeException rather than just using a BuildException here? Is it
+ // in case the message could end up being written to no loggers (as the
+ // loggers could have failed to be created due to this failure)?
+ /**
+ * Creates the default build logger for sending build events to the ant
+ * log.
+ *
+ * @return the logger instance for this build.
+ */
+ private BuildLogger createLogger() {
+ BuildLogger logger = null;
+ if (loggerClassname != null) {
+ try {
+ logger = (BuildLogger) ClasspathUtils.newInstance(
+ loggerClassname, Main.class.getClassLoader(),
+ BuildLogger.class);
+ } catch (BuildException e) {
+ System.err.println("The specified logger class "
+ + loggerClassname
+ + " could not be used because " + e.getMessage());
+ throw new RuntimeException();
+ }
+ } else {
+ logger = new DefaultLogger();
+ }
+
+ logger.setMessageOutputLevel(msgOutputLevel);
+ logger.setOutputPrintStream(out);
+ logger.setErrorPrintStream(err);
+ logger.setEmacsMode(emacsMode);
+
+ return logger;
+ }
+
+ /**
+ * Prints the usage information for this class to <code>System.out</code>.
+ */
+ private static void printUsage() {
+ String lSep = System.getProperty("line.separator");
+ StringBuilder msg = new StringBuilder();
+ msg.append("rhq-ant [options] [target [target2 [target3] ...]]" + lSep);
+ msg.append("Options: " + lSep);
+ msg.append(" -help, -h print this message" + lSep);
+ msg.append(" -projecthelp, -p print project help information" + lSep);
+ msg.append(" -version print the version information and exit" + lSep);
+ msg.append(" -diagnostics print information that might be helpful to" + lSep);
+ msg.append(" diagnose or report problems." + lSep);
+ msg.append(" -quiet, -q be extra quiet" + lSep);
+ msg.append(" -verbose, -v be extra verbose" + lSep);
+ msg.append(" -debug, -d print debugging information" + lSep);
+ msg.append(" -emacs, -e produce logging information without adornments"
+ + lSep);
+ msg.append(" -lib <path> specifies a path to search for jars and classes"
+ + lSep);
+ msg.append(" -logfile <file> use given file for log" + lSep);
+ msg.append(" -l <file> ''" + lSep);
+ msg.append(" -logger <classname> the class which is to perform logging" + lSep);
+ msg.append(" -listener <classname> add an instance of class as a project listener"
+ + lSep);
+ msg.append(" -noinput do not allow interactive input" + lSep);
+ msg.append(" -D<property>=<value> use value for given property" + lSep);
+ msg.append(" -keep-going, -k execute all targets that do not depend" + lSep);
+ msg.append(" on failed target(s)" + lSep);
+ msg.append(" -propertyfile <name> load all properties from file with -D" + lSep);
+ msg.append(" properties taking precedence" + lSep);
+ msg.append(" -inputhandler <class> the class which will handle input requests" + lSep);
+ msg.append(" -nice number A niceness value for the main thread:" + lSep
+ + " 1 (lowest) to 10 (highest); 5 is the default"
+ + lSep);
+ msg.append(" -nouserlib Run ant without using the jar files from" + lSep
+ + " ${user.home}/.ant/lib" + lSep);
+ msg.append(" -noclasspath Run ant without using CLASSPATH" + lSep);
+ msg.append(" -autoproxy Java1.5+: use the OS proxy settings"
+ + lSep);
+ msg.append(" -main <class> override Ant's normal entry point");
+ System.out.println(msg);
+ }
+
+ /**
+ * Prints the Ant version information to <code>System.out</code>.
+ *
+ * @exception BuildException if the version information is unavailable
+ */
+ private static void printVersion(int logLevel) throws BuildException {
+ // RHQ: TODO: Print RHQ version.
+ System.out.println(getAntVersion());
+ }
+
+ /**
+ * Cache of the Ant version information when it has been loaded.
+ */
+ private static String antVersion = null;
+
+ /**
+ * Returns the Ant version information, if available. Once the information
+ * has been loaded once, it's cached and returned from the cache on future
+ * calls.
+ *
+ * @return the Ant version information as a String
+ * (always non-<code>null</code>)
+ *
+ * @exception BuildException if the version information is unavailable
+ */
+ public static synchronized String getAntVersion() throws BuildException {
+ if (antVersion == null) {
+ try {
+ Properties props = new Properties();
+ InputStream in =
+ Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt");
+ props.load(in);
+ in.close();
+
+ StringBuffer msg = new StringBuffer();
+ msg.append("Apache Ant version ");
+ msg.append(props.getProperty("VERSION"));
+ msg.append(" compiled on ");
+ msg.append(props.getProperty("DATE"));
+ antVersion = msg.toString();
+ } catch (IOException ioe) {
+ throw new BuildException("Could not load the version information:"
+ + ioe.getMessage());
+ } catch (NullPointerException npe) {
+ throw new BuildException("Could not load the version information.");
+ }
+ }
+ return antVersion;
+ }
+
+ /**
+ * Prints the description of a project (if there is one) to
+ * <code>System.out</code>.
+ *
+ * @param project The project to display a description of.
+ * Must not be <code>null</code>.
+ */
+ private static void printDescription(Project project) {
+ if (project.getDescription() != null) {
+ project.log(project.getDescription());
+ }
+ }
+
+ /**
+ * Targets in imported files with a project name
+ * and not overloaded by the main build file will
+ * be in the target map twice. This method
+ * removes the duplicate target.
+ * @param targets the targets to filter.
+ * @return the filtered targets.
+ */
+ private static Map removeDuplicateTargets(Map targets) {
+ Map locationMap = new HashMap();
+ for (Iterator i = targets.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ String name = (String) entry.getKey();
+ Target target = (Target) entry.getValue();
+ Target otherTarget =
+ (Target) locationMap.get(target.getLocation());
+ // Place this entry in the location map if
+ // a) location is not in the map
+ // b) location is in map, but it's name is longer
+ // (an imported target will have a name. prefix)
+ if (otherTarget == null
+ || otherTarget.getName().length() > name.length()) {
+ locationMap.put(
+ target.getLocation(), target); // Smallest name wins
+ }
+ }
+ Map ret = new HashMap();
+ for (Iterator i = locationMap.values().iterator(); i.hasNext();) {
+ Target target = (Target) i.next();
+ ret.put(target.getName(), target);
+ }
+ return ret;
+ }
+
+ /**
+ * Prints a list of all targets in the specified project to
+ * <code>System.out</code>, optionally including subtargets.
+ *
+ * @param project The project to display a description of.
+ * Must not be <code>null</code>.
+ * @param printSubTargets Whether or not subtarget names should also be
+ * printed.
+ */
+ private static void printTargets(Project project, boolean printSubTargets) {
+ // find the target with the longest name
+ int maxLength = 0;
+ Map ptargets = removeDuplicateTargets(project.getTargets());
+ String targetName;
+ String targetDescription;
+ Target currentTarget;
+ // split the targets in top-level and sub-targets depending
+ // on the presence of a description
+ Vector topNames = new Vector();
+ Vector topDescriptions = new Vector();
+ Vector subNames = new Vector();
+
+ for (Iterator i = ptargets.values().iterator(); i.hasNext();) {
+ currentTarget = (Target) i.next();
+ targetName = currentTarget.getName();
+ if (targetName.equals("")) {
+ continue;
+ }
+ targetDescription = currentTarget.getDescription();
+ // maintain a sorted list of targets
+ if (targetDescription == null) {
+ int pos = findTargetPosition(subNames, targetName);
+ subNames.insertElementAt(targetName, pos);
+ } else {
+ int pos = findTargetPosition(topNames, targetName);
+ topNames.insertElementAt(targetName, pos);
+ topDescriptions.insertElementAt(targetDescription, pos);
+ if (targetName.length() > maxLength) {
+ maxLength = targetName.length();
+ }
+ }
+ }
+
+ printTargets(project, topNames, topDescriptions, "Main targets:",
+ maxLength);
+ //if there were no main targets, we list all subtargets
+ //as it means nothing has a description
+ if (topNames.size() == 0) {
+ printSubTargets = true;
+ }
+ if (printSubTargets) {
+ printTargets(project, subNames, null, "Other targets:", 0);
+ }
+
+ String defaultTarget = project.getDefaultTarget();
+ if (defaultTarget != null && !"".equals(defaultTarget)) {
+ // shouldn't need to check but...
+ project.log("Default target: " + defaultTarget);
+ }
+ }
+
+ /**
+ * Searches for the correct place to insert a name into a list so as
+ * to keep the list sorted alphabetically.
+ *
+ * @param names The current list of names. Must not be <code>null</code>.
+ * @param name The name to find a place for.
+ * Must not be <code>null</code>.
+ *
+ * @return the correct place in the list for the given name
+ */
+ private static int findTargetPosition(Vector names, String name) {
+ int res = names.size();
+ for (int i = 0; i < names.size() && res == names.size(); i++) {
+ if (name.compareTo((String) names.elementAt(i)) < 0) {
+ res = i;
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Writes a formatted list of target names to <code>System.out</code>
+ * with an optional description.
+ *
+ *
+ * @param project the project instance.
+ * @param names The names to be printed.
+ * Must not be <code>null</code>.
+ * @param descriptions The associated target descriptions.
+ * May be <code>null</code>, in which case
+ * no descriptions are displayed.
+ * If non-<code>null</code>, this should have
+ * as many elements as <code>names</code>.
+ * @param heading The heading to display.
+ * Should not be <code>null</code>.
+ * @param maxlen The maximum length of the names of the targets.
+ * If descriptions are given, they are padded to this
+ * position so they line up (so long as the names really
+ * <i>are</i> shorter than this).
+ */
+ private static void printTargets(Project project, Vector names,
+ Vector descriptions, String heading,
+ int maxlen) {
+ // now, start printing the targets and their descriptions
+ String lSep = System.getProperty("line.separator");
+ // got a bit annoyed that I couldn't find a pad function
+ String spaces = " ";
+ while (spaces.length() <= maxlen) {
+ spaces += spaces;
+ }
+ StringBuffer msg = new StringBuffer();
+ msg.append(heading + lSep + lSep);
+ for (int i = 0; i < names.size(); i++) {
+ msg.append(" ");
+ msg.append(names.elementAt(i));
+ if (descriptions != null) {
+ msg.append(
+ spaces.substring(0, maxlen - ((String) names.elementAt(i)).length() + 2));
+ msg.append(descriptions.elementAt(i));
+ }
+ msg.append(lSep);
+ }
+ project.log(msg.toString(), Project.MSG_WARN);
+ }
+}
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
index 7daa6ef..06d14d8 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/BundleTask.java
@@ -19,11 +19,21 @@
package org.rhq.bundle.ant.task;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+import java.io.File;
+import java.util.Hashtable;
/**
* @author Ian Springer
*/
public class BundleTask extends AbstractBundleTask {
+ // System property that should always be available to ant scripts - it's the location where the deployment should be installed
+ public static final String DEPLOY_DIR_PROP = "rhq.deploy.dir";
+
+ // System property that should always be available to ant scripts - it's the ID of the bundle deployment
+ public static final String DEPLOY_ID_PROP = "rhq.deploy.id";
+
private String name;
private String version;
private String description;
@@ -32,7 +42,7 @@ public class BundleTask extends AbstractBundleTask {
public void maybeConfigure() throws BuildException {
// The below call will init the attribute fields.
super.maybeConfigure();
-
+
validateAttributes();
getProject().setBundleName(this.name);
@@ -42,7 +52,37 @@ public class BundleTask extends AbstractBundleTask {
@Override
public void execute() throws BuildException {
+ Hashtable projectProps = getProject().getProperties();
+
+ // Make sure the requires System properties are defined and valid.
+ String deployDir = (String) projectProps.get(DEPLOY_DIR_PROP);
+ if (deployDir == null) {
+ throw new BuildException("Required property [" + DEPLOY_DIR_PROP + "] was not specified.");
+ }
+ File deployDirFile = new File(deployDir);
+ if (!deployDirFile.isAbsolute()) {
+ throw new BuildException("Value of property [" + DEPLOY_DIR_PROP + "] (" + deployDirFile
+ + ") is not an absolute path.");
+ }
+ getProject().setDeployDir(deployDirFile);
+ log(DEPLOY_DIR_PROP + "=\"" + deployDir + "\"", Project.MSG_DEBUG);
+
+ String deploymentIdStr = (String) projectProps.get(DEPLOY_ID_PROP);
+ if (deploymentIdStr == null) {
+ throw new BuildException("Required property [" + DEPLOY_ID_PROP + "] was not specified.");
+ }
+ int deploymentId;
+ try {
+ deploymentId = Integer.parseInt(deploymentIdStr);
+ } catch (Exception e) {
+ throw new BuildException("Value of property [" + DEPLOY_ID_PROP + "] (" + deploymentIdStr
+ + ") is not valid.", e);
+ }
+ getProject().setDeploymentId(deploymentId);
+ log(DEPLOY_ID_PROP + "=\"" + deploymentId + "\"", Project.MSG_DEBUG);
+
log("Executing Ant script for bundle '" + this.name + "' version " + this.version + "...");
+
}
public String getDescription() {
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java
index 5ad10ed..53df7c9 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java
@@ -27,7 +27,6 @@ import java.util.regex.Pattern;
import org.apache.tools.ant.BuildException;
-import org.rhq.bundle.ant.AntLauncher;
import org.rhq.bundle.ant.type.ArchiveType;
import org.rhq.bundle.ant.type.FileSet;
import org.rhq.bundle.ant.type.FileType;
@@ -61,13 +60,20 @@ public class DeployTask extends AbstractBundleTask {
@Override
public void execute() throws BuildException {
- int deploymentId = getDeploymentId();
+ int deploymentId = getProject().getDeploymentId();
DeploymentProperties deploymentProps = new DeploymentProperties(deploymentId, getProject().getBundleName(),
getProject().getBundleVersion(), getProject().getBundleDescription());
File deployDir = getProject().getDeployDir();
TemplateEngine templateEngine = createTemplateEngine();
- log("Deploying files " + this.files + "...");
- log("Deploying archives " + this.archives + "...");
+ if (this.files.isEmpty() && this.archives.isEmpty()) {
+ throw new BuildException("You must specify at least one file to deploy via nested rhq:file and/or rhq:archive elements.");
+ }
+ if (!this.files.isEmpty()) {
+ log("Deploying files " + this.files + "...");
+ }
+ if (!this.archives.isEmpty()) {
+ log("Deploying archives " + this.archives + "...");
+ }
Deployer deployer = new Deployer(deploymentProps, this.archives, this.files, deployDir, this.replacePattern,
templateEngine, this.ignorePattern);
try {
@@ -75,7 +81,7 @@ public class DeployTask extends AbstractBundleTask {
deployer.deploy(diff);
} catch (Exception e) {
throw new BuildException("Failed to deploy bundle '" + getProject().getBundleName() + "' version "
- + getProject().getBundleVersion() + ".", e);
+ + getProject().getBundleVersion() + ": " + e, e);
}
return;
}
@@ -119,14 +125,6 @@ public class DeployTask extends AbstractBundleTask {
this.replacePattern = getPattern(fileSets);
}
- private int getDeploymentId() {
- String deploymentIdStr = getProject().getProperty(AntLauncher.DEPLOY_ID_PROP);
- if (deploymentIdStr == null) {
- return 0;
- }
- return Integer.parseInt(deploymentIdStr);
- }
-
private TemplateEngine createTemplateEngine() {
TemplateEngine templateEngine = SystemInfoFactory.fetchTemplateEngine();
// Add the deployment props to the template engine's tokens.
diff --git a/modules/common/ant-bundle/src/main/scripts/assembly.xml b/modules/common/ant-bundle/src/main/scripts/assembly.xml
new file mode 100644
index 0000000..cc7871a
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/scripts/assembly.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+
+ <id></id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>${project.build.finalName}</baseDirectory>
+
+ <fileSets>
+
+ <fileSet>
+ <directory>src/main/assembly</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>bin/rhq-ant</exclude>
+ </excludes>
+ </fileSet>
+
+ <fileSet>
+ <directory>src/main/assembly</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>bin/rhq-ant</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+
+</assembly>
+
diff --git a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
index 357265f..e484ca5 100644
--- a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
@@ -56,9 +56,7 @@ public class AntLauncherTest {
public void testParse() throws Exception {
AntLauncher ant = new AntLauncher();
- Properties inputProps = createInputProperties("/test-bundle-v1-input.properties");
- BundleAntProject project = ant.startAnt(getBuildXml("test-bundle-v1.xml"), "unnecessary-target", null,
- inputProps, this.logFile, true, false);
+ BundleAntProject project = ant.parseBundleDeployFile(getBuildXml("test-bundle-v1.xml"));
assert project != null;
/*Map<String, String> bundleFiles = project.getBundleFiles();
assert bundleFiles != null;
@@ -77,8 +75,8 @@ public class AntLauncherTest {
AntLauncher ant = new AntLauncher();
Properties inputProps = createInputProperties("/test-bundle-v1-input.properties");
- BundleAntProject project = ant.startAnt(getBuildXml("test-bundle-v1.xml"), "deploy", null, inputProps,
- this.logFile, true, true);
+ BundleAntProject project = ant.executeBundleDeployFile(getBuildXml("test-bundle-v1.xml"), "deploy", inputProps,
+ this.logFile, true);
/*Map<String, String> bundleFiles = project.getBundleFiles();
assert bundleFiles != null;
assert bundleFiles.size() == 2 : bundleFiles;
@@ -92,7 +90,7 @@ public class AntLauncherTest {
assert propDef.getType() == PropertySimpleType.INTEGER;
Configuration config = project.getConfiguration();
- assert config.getProperties().size() == 1;
+ assert config.getProperties().size() == 1 : config.getProperties();
assert "10000".equals(config.getSimpleValue("listener.port", null)) : config.getProperties();
}
@@ -102,8 +100,8 @@ public class AntLauncherTest {
AntLauncher ant = new AntLauncher();
Properties inputProps = createInputProperties("/test-bundle-v2-input.properties");
- BundleAntProject project = ant.startAnt(getBuildXml("test-bundle-v2.xml"), "deploy", null, inputProps,
- this.logFile, true, true);
+ BundleAntProject project = ant.executeBundleDeployFile(getBuildXml("test-bundle-v2.xml"), "deploy", inputProps,
+ this.logFile, true);
/*Map<String, String> bundleFiles = project.getBundleFiles();
assert bundleFiles != null;
assert bundleFiles.size() == 2 : bundleFiles;
diff --git a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
index 7e4b35a..8920bef 100644
--- a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
@@ -90,7 +90,7 @@ public class AntBundleServerPluginComponent implements ServerPluginComponent, Bu
// parse, but do not execute, the Ant script
AntLauncher antLauncher = new AntLauncher();
- BundleAntProject project = antLauncher.startAnt(recipeFile, null, null, null, logFile, false, false);
+ BundleAntProject project = antLauncher.executeBundleDeployFile(recipeFile, null, null, null, logFile, false);
// obtain the parse results
deploymentProps = new DeploymentProperties(0, project.getBundleName(),
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 27bdef1..657a440 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
@@ -127,7 +127,7 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
// parse & execute, the ant script
AntLauncher antLauncher = new AntLauncher();
- BundleAntProject project = antLauncher.startAnt(recipeFile, null, null, antProps, logFile, true, true);
+ BundleAntProject project = antLauncher.executeBundleDeployFile(recipeFile, null, null, antProps, logFile, true);
} catch (Throwable t) {
if (log.isDebugEnabled()) {
try {
14 years, 1 month
[rhq] Branch 'gwt' - modules/core
by mazz
modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java | 34 +++++++++-
modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java | 6 -
2 files changed, 36 insertions(+), 4 deletions(-)
New commits:
commit f1f9fa78ae06337df9789779bac25e107da68888
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 26 14:56:59 2010 -0400
store the paths in the differences object in the platform specific form
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
index a5f8b9a..86b6e54 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
@@ -24,6 +24,7 @@
package org.rhq.core.util.updater;
import java.io.File;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -54,18 +55,42 @@ public class DeployDifferences {
this.ignoredFiles.add(convertPath(path));
}
+ public void addIgnoredFiles(Collection<String> paths) {
+ for (String path : paths) {
+ addIgnoredFile(path);
+ }
+ }
+
public void addDeletedFile(String path) {
this.deletedFiles.add(convertPath(path));
}
+ public void addDeletedFiles(Collection<String> paths) {
+ for (String path : paths) {
+ addDeletedFile(path);
+ }
+ }
+
public void addAddedFile(String path) {
this.addedFiles.add(convertPath(path));
}
+ public void addAddedFiles(Collection<String> paths) {
+ for (String path : paths) {
+ addAddedFile(path);
+ }
+ }
+
public void addChangedFile(String path) {
this.changedFiles.add(convertPath(path));
}
+ public void addChangedFiles(Collection<String> paths) {
+ for (String path : paths) {
+ addChangedFile(path);
+ }
+ }
+
public void addBackedUpFile(String originalPath, String backupPath) {
this.backedUpFiles.put(convertPath(originalPath), convertPath(backupPath));
}
@@ -166,7 +191,14 @@ public class DeployDifferences {
return str.toString();
}
- private String convertPath(String path) {
+ /**
+ * Converts the path to the form that will be stored internally.
+ *
+ * @param path a filepath to be converted
+ *
+ * @return the converted path that is to be used to store in the internal sets.
+ */
+ public String convertPath(String path) {
return new File(path).getPath(); // makes sure e.g. the file separators are correct for this platform
}
}
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
index b8589eb..83cb09b 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
@@ -173,7 +173,7 @@ public class Deployer {
// this is an initial deployment, so we know every file is new - tell our diff about them all
if (diff != null) {
- diff.getAddedFiles().addAll(newFileHashcodeMap.keySet());
+ diff.addAddedFiles(newFileHashcodeMap.keySet());
}
debug("Initial deployment finished.");
@@ -202,7 +202,7 @@ public class Deployer {
}
if (diff != null) {
- diff.getIgnoredFiles().addAll(current.getIgnored());
+ diff.addIgnoredFiles(current.getIgnored());
for (Map.Entry<String, String> entry : current.entrySet()) {
String currentPath = entry.getKey();
String currentHashcode = entry.getValue();
@@ -277,7 +277,7 @@ public class Deployer {
if (newFileNotScannedFile.exists()) {
currentFilesToBackup.add(newFileNotScanned);
if (diff != null) {
- diff.getAddedFiles().remove(newFileNotScanned);
+ diff.getAddedFiles().remove(diff.convertPath(newFileNotScanned));
diff.addChangedFile(newFileNotScanned);
}
}
14 years, 1 month
[rhq] Branch 'gwt' - modules/core
by mazz
modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java | 19 ++++++----
1 file changed, 12 insertions(+), 7 deletions(-)
New commits:
commit 0013a652178f8bd6f18699dae9f5133a83d011f1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 26 14:39:34 2010 -0400
make sure we store paths in platform specific way
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
index 4146bcd..a5f8b9a 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeployDifferences.java
@@ -23,6 +23,7 @@
package org.rhq.core.util.updater;
+import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -50,31 +51,31 @@ public class DeployDifferences {
private final Map<String, String> errors = new HashMap<String, String>();
public void addIgnoredFile(String path) {
- this.ignoredFiles.add(path);
+ this.ignoredFiles.add(convertPath(path));
}
public void addDeletedFile(String path) {
- this.deletedFiles.add(path);
+ this.deletedFiles.add(convertPath(path));
}
public void addAddedFile(String path) {
- this.addedFiles.add(path);
+ this.addedFiles.add(convertPath(path));
}
public void addChangedFile(String path) {
- this.changedFiles.add(path);
+ this.changedFiles.add(convertPath(path));
}
public void addBackedUpFile(String originalPath, String backupPath) {
- this.backedUpFiles.put(originalPath, backupPath);
+ this.backedUpFiles.put(convertPath(originalPath), convertPath(backupPath));
}
public void addRealizedFile(String path, String content) {
- this.realizedFiles.put(path, content);
+ this.realizedFiles.put(convertPath(path), content);
}
public void addError(String path, String errorMsg) {
- this.errors.put(path, errorMsg);
+ this.errors.put(convertPath(path), errorMsg);
}
/**
@@ -164,4 +165,8 @@ public class DeployDifferences {
str.append("errors=").append(this.errors);
return str.toString();
}
+
+ private String convertPath(String path) {
+ return new File(path).getPath(); // makes sure e.g. the file separators are correct for this platform
+ }
}
14 years, 1 month