[rhq] Branch 'gwt' - 3 commits - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java | 117 +++++-----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 36 +++
3 files changed, 98 insertions(+), 57 deletions(-)
New commits:
commit 7258569515eaf7cfa3021a487faa49ae8ff8dd41
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 26 13:42:53 2010 -0400
this new test breaks - it illustrates our problem with packages ignoring classification
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 163e9c6..5990e61 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
@@ -525,6 +525,42 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
}
@Test(enabled = TESTS_ENABLED)
+ public void testAddBundleFilesToDifferentBundles() throws Exception {
+ Bundle b1 = createBundle("one");
+ assertNotNull(b1);
+ BundleVersion bv1 = createBundleVersion(b1.getName(), "1.0", b1);
+ assertNotNull(bv1);
+ BundleFile b1f1 = bundleManager.addBundleFileViaByteArray(overlord, bv1.getId(), TEST_PREFIX + "-file1", "1.0",
+ null, "Bundle #1 File # 1".getBytes(), false);
+
+ // create a second bundle but create file of the same name as above
+ Bundle b2 = createBundle("two");
+ assertNotNull(b2);
+ BundleVersion bv2 = createBundleVersion(b2.getName(), "1.0", b2);
+ assertNotNull(bv2);
+ BundleFile b2f1 = bundleManager.addBundleFileViaByteArray(overlord, bv2.getId(), TEST_PREFIX + "-file1", "1.0",
+ null, "Bundle #2 File # 1".getBytes(), false);
+
+ BundleFileCriteria bfc = new BundleFileCriteria();
+ bfc.addFilterBundleVersionId(bv1.getId());
+ PageList<BundleFile> bundleFiles = bundleManager.findBundleFilesByCriteria(overlord, bfc);
+ assert bundleFiles.size() == 1 : bundleFiles;
+ assert bundleFiles.get(0).getId() == b1f1.getId() : bundleFiles;
+
+ bfc = new BundleFileCriteria();
+ bfc.addFilterBundleVersionId(bv2.getId());
+ bundleFiles = bundleManager.findBundleFilesByCriteria(overlord, bfc);
+ assert bundleFiles.size() == 1 : bundleFiles;
+ assert bundleFiles.get(0).getId() == b2f1.getId() : bundleFiles;
+
+ assert b1f1.getId() != b2f1.getId() : "should have been different bundle files";
+ assert b1f1.getPackageVersion().getId() != b2f1.getPackageVersion().getId() : "should be different PV";
+ assert b1f1.getPackageVersion().getGeneralPackage().getId() == b2f1.getPackageVersion().getGeneralPackage()
+ .getId() : "package IDs should be different";
+ assert b1f1.getPackageVersion().getGeneralPackage().equals(b2f1.getPackageVersion().getGeneralPackage()) : "should be different packages";
+ }
+
+ @Test(enabled = TESTS_ENABLED)
public void testCreateBundleDeploymentDef() throws Exception {
Bundle b1 = createBundle("one");
assertNotNull(b1);
commit 845c8f1b513eb481667fe6a0c3b7d9955bb931e9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 26 13:42:25 2010 -0400
simplify the upload step, the icon still isn't redrawing when it should though
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
index 6f18f04..1d67a73 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
@@ -27,8 +27,6 @@ import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.UploadItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
@@ -48,6 +46,10 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
private final BundleVersion bundleVersion;
private final String name;
private final boolean showNameLabel;
+ private final FormItemIcon iconLoading;
+ private final FormItemIcon iconGreen;
+ private final FormItemIcon iconRed;
+ private final FormItemIcon iconGrey;
public BundleFileUploadForm(BundleVersion bundleVersion, String name, boolean showNameLabel,
Boolean isAlreadyUploaded) {
@@ -60,6 +62,26 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
setEncoding(Encoding.MULTIPART);
setAction(GWT.getModuleBaseURL() + "/BundleFileUploadServlet");
+
+ iconLoading = new FormItemIcon();
+ iconLoading.setSrc("ajax-loader.gif");
+ iconLoading.setWidth(16);
+ iconLoading.setHeight(16);
+
+ iconGreen = new FormItemIcon();
+ iconGreen.setSrc("/images/icons/availability_green_16.png");
+ iconGreen.setWidth(16);
+ iconGreen.setHeight(16);
+
+ iconRed = new FormItemIcon();
+ iconRed.setSrc("/images/icons/availability_red_16.png");
+ iconRed.setWidth(16);
+ iconRed.setHeight(16);
+
+ iconGrey = new FormItemIcon();
+ iconGrey.setSrc("/images/icons/availability_grey_16.png");
+ iconGrey.setWidth(16);
+ iconGrey.setHeight(16);
}
public BundleVersion getBundleVersion() {
@@ -86,10 +108,15 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
@Override
public void submitForm() {
- icon.setShowIcons(true);
- uploadButton.setDisabled(true);
- markForRedraw();
- super.submitForm();
+ Object value = bundleUploadItem.getValue();
+ if (value == null || value.toString().length() == 0) {
+ icon.setIcons(iconRed);
+ icon.setTooltip("Please select a file to upload");
+ } else {
+ icon.setIcons(iconLoading);
+ icon.setTooltip("Loading...");
+ super.submitForm();
+ }
}
@Override
@@ -117,7 +144,6 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
uploadButton = new ButtonItem("Upload");
uploadButton.setStartRow(false);
uploadButton.setEndRow(false);
- uploadButton.setDisabled(true);
uploadButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
submitForm();
@@ -127,28 +153,19 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
icon = new StaticTextItem("icon");
icon.setStartRow(false);
icon.setShowTitle(false);
-
- FormItemIcon loadingIcon = new FormItemIcon();
- loadingIcon.setSrc("ajax-loader.gif");
- loadingIcon.setWidth(16);
- loadingIcon.setHeight(16);
- icon.setIcons(loadingIcon);
- icon.setShowIcons(false);
-
- bundleUploadItem.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent changeEvent) {
- if (uploadResults != null) {
- retrievalStatus(uploadResults.booleanValue());
- } else {
- uploadButton.setDisabled(false);
- icon.setShowIcons(false);
- }
- }
- });
-
if (uploadResults != null) {
- retrievalStatus(uploadResults.booleanValue());
+ if (uploadResults.booleanValue()) {
+ icon.setIcons(iconGreen);
+ icon.setTooltip("Bundle file has already been uploaded");
+ } else {
+ icon.setIcons(iconRed);
+ icon.setTooltip("Bundle file upload has previously failed");
+ }
+ } else {
+ icon.setIcons(iconGrey);
+ icon.setTooltip("Select a file to upload, then click the 'Upload' button or 'Next'");
}
+ icon.setShowIcons(true);
setItems(sessionIdField, bundleVersionIdField, nameField, versionField, bundleUploadItem, uploadButton, icon);
@@ -156,43 +173,31 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
public void onSubmitComplete(DynamicFormSubmitCompleteEvent event) {
String results = event.getResults();
if (!results.contains("Failed to upload bundle file")) {
- CoreGUI.getMessageCenter().notify(new Message("Uploaded bundle file successfully", Severity.Info));
- retrievalStatus(true);
+ uploadResults = Boolean.TRUE;
+ icon.setIcons(iconGreen);
+ icon.setTooltip("Uploaded bundle file successfully");
+ CoreGUI.getMessageCenter().notify(
+ new Message("Uploaded bundle file successfully", results, Severity.Info));
+ markForRedraw();
} else {
- CoreGUI.getMessageCenter().notify(new Message("Bundle file upload failed", Severity.Error));
- retrievalStatus(false);
+ uploadResults = Boolean.FALSE;
+ icon.setIcons(iconRed);
+ icon.setTooltip("Bundle file upload failed");
+ CoreGUI.getMessageCenter()
+ .notify(new Message("Bundle file upload failed", results, Severity.Error));
+ markForRedraw();
}
}
});
addFormSubmitFailedHandler(new FormSubmitFailedHandler() {
public void onFormSubmitFailed(FormSubmitFailedEvent event) {
- CoreGUI.getMessageCenter().notify(new Message("Bundle file upload failed", Severity.Error));
- retrievalStatus(false);
+ uploadResults = Boolean.FALSE;
+ icon.setIcons(iconRed);
+ icon.setTooltip("Bundle file upload failed");
+ CoreGUI.getMessageCenter().notify(new Message("Bundle file upload request failed", Severity.Error));
+ markForRedraw();
}
});
}
-
- /**
- * Call this when the last file retrieval status is known. <code>true</code> means successful,
- * <code>false</code> means an error occurred.
- * @param ok status
- */
- private void retrievalStatus(boolean ok) {
- uploadResults = Boolean.valueOf(ok);
-
- if (uploadButton != null) {
- FormItemIcon loadedIcon = new FormItemIcon();
- if (ok) {
- loadedIcon.setSrc("/images/icons/availability_green_16.png");
- } else {
- loadedIcon.setSrc("/images/icons/availability_red_16.png");
- }
- loadedIcon.setWidth(16);
- loadedIcon.setHeight(16);
- icon.setIcons(loadedIcon);
- icon.setShowIcons(true);
- uploadButton.setDisabled(uploadResults);
- }
- }
}
commit b1c8bfca1422d74c48b50d69dd902507007b8d45
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 26 13:41:55 2010 -0400
need to use the return obj from merge
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index 8d19ad2..7b41da0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -361,7 +361,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// set the PackageVersion's filename to the bundleFile name, it's left null by default
packageVersion.setFileName(name);
- entityManager.merge(packageVersion);
+ packageVersion = entityManager.merge(packageVersion);
// Create the mapping between the Bundle's Repo and the BundleFile's PackageVersion
Repo repo = bundle.getRepo();
14 years, 1 month
[rhq] Branch 'gwt' - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 29 +++++-----
1 file changed, 15 insertions(+), 14 deletions(-)
New commits:
commit 9941c387a8863aefbe5e80906098c749336b7993
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 26 10:50:56 2010 -0400
get the 'logged in as' message area formatted a bit better
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index caf4ffb..e134f04 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -22,9 +22,11 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.Hyperlink;
-import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
@@ -39,7 +41,7 @@ public class MenuBarView extends VLayout {
private AboutModalWindow aboutModalWindow;
- public static final String[] SECTIONS = {"Dashboard", "Demo", "Inventory", "Bundles", "Administration"};
+ public static final String[] SECTIONS = { "Dashboard", "Demo", "Inventory", "Bundles", "Administration" };
private String selected = "Dashboard";
@@ -65,14 +67,12 @@ public class MenuBarView extends VLayout {
protected void onDraw() {
super.onDraw();
-
ToolStrip topStrip = new ToolStrip();
topStrip.setHeight(34);
topStrip.setWidth100();
topStrip.setBackgroundImage("header/header_bg.png");
topStrip.setMembersMargin(20);
-
this.aboutModalWindow = new AboutModalWindow();
Img logo = new Img("header/rhq_logo_28px.png", 80, 28);
logo.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
@@ -82,7 +82,6 @@ public class MenuBarView extends VLayout {
});
topStrip.addMember(logo);
-
linksPane = new HTMLFlow();
linksPane.setContents(setupLinks());
@@ -90,12 +89,15 @@ public class MenuBarView extends VLayout {
topStrip.addMember(new LayoutSpacer());
- topStrip.addMember(new HTMLFlow("Logged in as " + CoreGUI.getSessionSubject().getName()));
-
- topStrip.addMember(new Hyperlink("Help", "Help"));
- topStrip.addMember(new Hyperlink("Preferences", "Preferences"));
- topStrip.addMember(new Hyperlink("Log Out", "LogOut"));
-
+ HLayout helpLayout = new HLayout();
+ Label loggedInAs = new Label("Logged in as " + CoreGUI.getSessionSubject().getName());
+ loggedInAs.setValign(VerticalAlignment.CENTER);
+ helpLayout.addMember(loggedInAs);
+ helpLayout.addMember(new Hyperlink("Help", "Help"));
+ helpLayout.addMember(new Hyperlink("Preferences", "Preferences"));
+ helpLayout.addMember(new Hyperlink("Log Out", "LogOut"));
+ helpLayout.setLayoutAlign(VerticalAlignment.CENTER);
+ topStrip.addMember(helpLayout);
/* DynamicForm links = new DynamicForm();
links.setNumCols(SECTIONS.length * 2);
@@ -128,9 +130,9 @@ public class MenuBarView extends VLayout {
markForRedraw();
}
-
private String setupLinks() {
- StringBuilder headerString = new StringBuilder("<table style=\"height: 34px;\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
+ StringBuilder headerString = new StringBuilder(
+ "<table style=\"height: 34px;\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
boolean first = true;
for (String section : SECTIONS) {
@@ -144,7 +146,6 @@ public class MenuBarView extends VLayout {
styleClass += "Selected";
}
-
headerString.append("<td class=\"" + styleClass + "\" onclick=\"document.location='#" + section + "'\" >");
headerString.append(section);
headerString.append("</td>\n");
14 years, 1 month
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java | 8 +-------
modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java | 2 +-
2 files changed, 2 insertions(+), 8 deletions(-)
New commits:
commit 1e8fb58daad6cf30d410480714e8b3fe93e41551
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 26 14:29:48 2010 +0100
Fix an omission and clean up
diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
index 3b47e95..6f6235a 100644
--- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
+++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
@@ -768,19 +768,13 @@ public class ConfigurationBean {
Class clazz = SecureIdentityLoginModule.class;
Method m = clazz.getDeclaredMethod("encode",String.class);
m.setAccessible(true);
- String res = (String) m.invoke(lm,"rhqadmin");
+ String res = (String) m.invoke(lm,password);
return res;
} catch (Exception e) {
throw new Exception("Encoding db password failed: " , e);
}
}
- private boolean isWindows() {
- String osName = System.getProperty("os.name").toLowerCase(Locale.US);
-
- return osName.indexOf("windows") > -1;
- }
-
private Properties getConfigurationAsProperties(List<PropertyItemWithValue> config) {
Properties props = new Properties();
diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java
index 5af10d0..425dc01 100644
--- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java
+++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java
@@ -529,7 +529,7 @@ public class ServerInformation {
return deployDirectory;
}
- protected File getBinDirectory() {
+ private File getBinDirectory() {
if (binDirectory == null) {
MBeanServer mbs = getMBeanServer();
ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
14 years, 1 month
[rhq] Branch 'gwt' - 8 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 14
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 51 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployDefinition.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java | 19
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeployment.java | 291 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeploymentStatus.java | 47 +
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java | 14
modules/enterprise/remoting/scripts/src/test/script/org/rhq/enterprise/remoting/cli/test_bundleManager.js | 47 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 63 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java | 15
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 8
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 8
13 files changed, 598 insertions(+), 15 deletions(-)
New commits:
commit a4843f881ec94bdfe97a44f6284d6b12b0bb2b01
Merge: 3b74570... aac77c4...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Mar 26 09:27:00 2010 -0400
Merge branch 'gwt' into gwt-jay
commit aac77c4667585187cb1b24b769a36f628ec8cd1d
Merge: c319887... 7afbfa9...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Mar 26 09:26:26 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit 3b745709e4be143524270f8f9825ab134228e4f6
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Mar 26 09:25:42 2010 -0400
Initial support for bundle group deployment. Needs more work around group
status tracking and possibly fault tolerance.
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 309c3cb..f3bdf49 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -570,6 +570,17 @@
</index>
</table>
+ <table name="RHQ_BUNDLE_GROUP_DEPLOY">
+ <column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
+ <column name="GROUP_ID" type="INTEGER" required="true" references="RHQ_RESOURCE_GROUP"/>
+ <column name="BUNDLE_DEPLOY_DEF_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY_DEF" />
+ <column name="STATUS" type="VARCHAR2" required="true" size="16"/>
+ <column name="ERROR_MESSAGE" type="LONGVARCHAR" required="false"/>
+ <column name="SUBJECT_NAME" type="VARCHAR2" required="true" size="255"/>
+ <column name="CTIME" type="LONG" required="true"/>
+ <column name="MTIME" type="LONG" required="true"/>
+ </table>
+
<!-- Represents a bundle version that is deployed on a platform resource -->
<table name="RHQ_BUNDLE_DEPLOY">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
@@ -584,17 +595,6 @@
</index>
</table>
- <table name="RHQ_BUNDLE_GROUP_DEPLOY">
- <column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
- <column name="GROUP_ID" type="INTEGER" required="true" references="RHQ_RESOURCE_GROUP"/>
- <column name="BUNDLE_DEPLOY_DEF_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY_DEF" />
- <column name="STATUS" type="VARCHAR2" required="true" size="16"/>
- <column name="ERROR_MESSAGE" type="LONGVARCHAR" required="false"/>
- <column name="SUBJECT_NAME" type="VARCHAR2" required="true" size="255"/>
- <column name="CTIME" type="LONG" required="true"/>
- <column name="MTIME" type="LONG" required="true"/>
- </table>
-
<table name="RHQ_BUNDLE_DEPLOY_HIST">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="BUNDLE_DEPLOY_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY" />
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployDefinition.java
index 5c11287..8f642ea 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployDefinition.java
@@ -103,6 +103,9 @@ public class BundleDeployDefinition implements Serializable {
@OneToMany(mappedBy = "bundleDeployDefinition", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<BundleDeployment> deployments = new ArrayList<BundleDeployment>();
+ @OneToMany(mappedBy = "bundleDeployDefinition", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+ private List<BundleGroupDeployment> groupDeployments = new ArrayList<BundleGroupDeployment>();
+
public BundleDeployDefinition() {
// for JPA use
}
@@ -212,6 +215,19 @@ public class BundleDeployDefinition implements Serializable {
this.deployments = deployments;
}
+ public List<BundleGroupDeployment> getGroupDeployments() {
+ return groupDeployments;
+ }
+
+ public void addGroupDeployment(BundleGroupDeployment bundleGroupDeployment) {
+ this.groupDeployments.add(bundleGroupDeployment);
+ bundleGroupDeployment.setBundleDeployDefinition(this);
+ }
+
+ public void setGroupDeployments(List<BundleGroupDeployment> groupDeployments) {
+ this.groupDeployments = groupDeployments;
+ }
+
@Override
public String toString() {
return "BundleDeployDefinition[id=" + id + ", name=" + name + "]";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeployment.java
index 8f27723..8a0365f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeployment.java
@@ -26,7 +26,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@@ -58,11 +57,11 @@ public class BundleGroupDeployment implements Serializable {
private int id;
@JoinColumn(name = "GROUP_ID", referencedColumnName = "ID")
- @ManyToOne(cascade = { CascadeType.REMOVE })
+ @ManyToOne
private ResourceGroup group;
@JoinColumn(name = "BUNDLE_DEPLOY_DEF_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
+ @ManyToOne
protected BundleDeployDefinition bundleDeployDefinition;
@Column(name = "STATUS", nullable = false)
@@ -81,7 +80,7 @@ public class BundleGroupDeployment implements Serializable {
@Column(name = "MTIME", nullable = false)
protected long modifiedTime = System.currentTimeMillis();
- @OneToMany(mappedBy = "bundleGroupDeployment", fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
+ @OneToMany(mappedBy = "bundleGroupDeployment", fetch = FetchType.LAZY)
private List<BundleDeployment> bundleDeployments = new ArrayList<BundleDeployment>();
// For JPA
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index 9eae8e6..3c8c5c5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -404,10 +404,10 @@ public class ResourceGroup extends Group {
// by primary key which will also put the configuration updates in chronological order
private List<AbstractGroupConfigurationUpdate> configurationUpdates = new ArrayList<AbstractGroupConfigurationUpdate>();
- @OneToMany(mappedBy = "group", cascade = { CascadeType.ALL })
+ @OneToMany(mappedBy = "group", cascade = { CascadeType.REMOVE })
@OrderBy
- // by primary key which will also put the operation histories in chronological order
- private List<BundleGroupDeployment> bundleDeployments = new ArrayList<BundleGroupDeployment>();
+ // by primary key which will also put the bundle deployments in chronological order
+ private List<BundleGroupDeployment> bundleGroupDeployments = new ArrayList<BundleGroupDeployment>();
@JoinColumn(name = "GROUP_DEFINITION_ID", referencedColumnName = "ID", nullable = true)
@ManyToOne
@@ -554,12 +554,12 @@ public class ResourceGroup extends Group {
this.configurationUpdates = configurationUpdates;
}
- public List<BundleGroupDeployment> getBundleDeployments() {
- return bundleDeployments;
+ public List<BundleGroupDeployment> getBundleGroupDeployments() {
+ return bundleGroupDeployments;
}
- public void setBundleDeployments(List<BundleGroupDeployment> bundleDeployments) {
- this.bundleDeployments = bundleDeployments;
+ public void setBundleGroupDeployments(List<BundleGroupDeployment> bundleGroupDeployments) {
+ this.bundleGroupDeployments = bundleGroupDeployments;
}
public GroupDefinition getGroupDefinition() {
diff --git a/modules/enterprise/remoting/scripts/src/test/script/org/rhq/enterprise/remoting/cli/test_bundleManager.js b/modules/enterprise/remoting/scripts/src/test/script/org/rhq/enterprise/remoting/cli/test_bundleManager.js
index 76e3f74..34986f1 100644
--- a/modules/enterprise/remoting/scripts/src/test/script/org/rhq/enterprise/remoting/cli/test_bundleManager.js
+++ b/modules/enterprise/remoting/scripts/src/test/script/org/rhq/enterprise/remoting/cli/test_bundleManager.js
@@ -26,7 +26,7 @@
* said platform.
*/
-var TestsEnabled = true;
+var TestsEnabled = false;
var bundleName = 'testScriptBundle';
@@ -82,6 +82,51 @@ function testDeployment() {
cleanupTestBundle();
}
+function testGroupDeployment() {
+// if ( !TestsEnabled ) {
+// return;
+// }
+
+ // delete the test bundle if it exists
+ cleanupTestBundle();
+
+ // create the test bundle
+ var testBundle = BundleManager.createBundle( bundleName, bundleName, getBundleType() );
+
+ // define the recipe for bundleVersion 1.0
+ var recipe = "file -s testBundle.war -d <%bundleTest.deployHome%>/group/testBundle.war"
+
+ // create bundleVersion 1.0
+ var testBundleVersion = BundleManager.createBundleVersion( testBundle.getId(), bundleName, bundleName, null, recipe);
+
+ // add the single bundleFile, the test war file
+ var fileBytes = scriptUtil.getFileBytes("./src/test/resources/testBundle.war");
+ var bundleFile = BundleManager.addBundleFileViaByteArray(testBundleVersion.getId(), "testBundle.war",
+ "1.0", null, fileBytes, false);
+
+ // create the config, setting the required properties from the recipe
+ var config = new Configuration();
+ var property = new PropertySimple("bundleTest.deployHome", "/tmp/bundle-test");
+ config.put( property );
+
+ // create a deploy def using the above config
+ var testDeployDef = BundleManager.createBundleDeployDefinition(testBundleVersion.getId(), "Deployment Test", "Deployment Test of testBundle WAR", config, false, -1, false);
+
+ // Find a target platform group
+ var rgc = new ResourceGroupCriteria();
+ rgc.addFilterName("platforms"); // wINdows, lINux
+ var groups = ResourceGroupManager.findResourceGroupsByCriteria(rgc);
+ Assert.assertTrue( groups.size() > 0 );
+ var groupId = groups.get(0).getId();
+
+ var bgd = BundleManager.scheduleBundleGroupDeployment(testDeployDef.getId(), groupId);
+ Assert.assertNotNull( bgd );
+
+ // delete the test bundle if it exists (after allowing agent audit messages to complete)
+ sleep( 5000 );
+ cleanupTestBundle();
+}
+
function getBundleType() {
var types = BundleManager.getAllBundleTypes();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index fe4cca4..8d19ad2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -458,7 +458,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// The BundleDeployment record must exist in the db before the agent request because the agent may try to
// add History to it during immediate deployments., so create and persist it (requires a new trans).
BundleDeployment deployment = bundleManager.createBundleDeployment(subject, deployDef.getId(), resourceId,
- bundleGroupDeployment.getId());
+ (null == bundleGroupDeployment) ? 0 : bundleGroupDeployment.getId());
// make sure the deployment contains the info required by the schedule service
BundleVersion bundleVersion = entityManager.find(BundleVersion.class, deployDef.getBundleVersion().getId());
@@ -516,10 +516,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
/*
- * we need to create and persist the group deployment entity in a new transaction before the rest of the
- * processing of this method; if we try to create and attach the deployment children
- * to the parent before this is persisted we'll get StaleStateExceptions
- * from Hibernate because of our use of flush/clear (we're trying to update it before it actually exists)
+ * we need to create the group deployment entity in a new transaction before the rest of the
+ * processing of this method; the individual deployments need to reference it.
*/
BundleGroupDeployment bundleGroupDeployment = new BundleGroupDeployment(subject.getName(), deployDef,
resourceGroup);
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 c975d38..163e9c6 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
@@ -40,6 +40,7 @@ import org.rhq.core.domain.bundle.BundleDeployDefinition;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentHistory;
import org.rhq.core.domain.bundle.BundleFile;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
@@ -152,6 +153,13 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
for (Object removeMe : doomed) {
em.remove(em.getReference(BundleFile.class, ((BundleFile) removeMe).getId()));
}
+ // remove any orphaned bgds
+ q = em.createQuery("SELECT bgd FROM BundleGroupDeployment bgd WHERE bgd.bundleDeployDefinition.name LIKE '"
+ + TEST_PREFIX + "%'");
+ doomed = q.getResultList();
+ for (Object removeMe : doomed) {
+ em.remove(em.getReference(BundleGroupDeployment.class, ((BundleGroupDeployment) removeMe).getId()));
+ }
// remove any orphaned bds
q = em.createQuery("SELECT bd FROM BundleDeployment bd WHERE bd.bundleDeployDefinition.name LIKE '"
+ TEST_PREFIX + "%'");
commit 7ef0eb7296676fd02a713d327b16413f8be9cb3f
Merge: b58b413... c319887...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 24 16:30:37 2010 -0400
Merge branch 'gwt' into gwt-jay
commit c3198879d399d8edbb9e6a8879d84855d7c35780
Merge: d3e8405... 99ac8e8...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 24 16:30:08 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit b58b413fbaa08657c3df2127e085aa3ee0f438f2
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 24 16:29:30 2010 -0400
Work on infra for bundle group deploy
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 178013b..309c3cb 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -576,8 +576,7 @@
<column name="BUNDLE_DEPLOY_DEF_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY_DEF" />
<column name="RESOURCE_ID" type="INTEGER" required="true" references="RHQ_RESOURCE" />
<column name="CTIME" type="LONG" required="true"/>
- <!-- for group history -->
- <column name="GROUP_ID" type="INTEGER" required="false" references="RHQ_RESOURCE_GROUP"/>
+ <column name="BUNDLE_GROUP_DEPLOY_ID" type="INTEGER" required="false" references="RHQ_BUNDLE_GROUP_DEPLOY"/>
<index name="RHQ_DEPLOY_DEF_RESOURCE_IDX" unique="true">
<field ref="BUNDLE_DEPLOY_DEF_ID"/>
@@ -585,6 +584,17 @@
</index>
</table>
+ <table name="RHQ_BUNDLE_GROUP_DEPLOY">
+ <column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
+ <column name="GROUP_ID" type="INTEGER" required="true" references="RHQ_RESOURCE_GROUP"/>
+ <column name="BUNDLE_DEPLOY_DEF_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY_DEF" />
+ <column name="STATUS" type="VARCHAR2" required="true" size="16"/>
+ <column name="ERROR_MESSAGE" type="LONGVARCHAR" required="false"/>
+ <column name="SUBJECT_NAME" type="VARCHAR2" required="true" size="255"/>
+ <column name="CTIME" type="LONG" required="true"/>
+ <column name="MTIME" type="LONG" required="true"/>
+ </table>
+
<table name="RHQ_BUNDLE_DEPLOY_HIST">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="BUNDLE_DEPLOY_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY" />
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 da47976..18db292 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2819,7 +2819,7 @@
<!-- RHQ_BUNDLE_DEPLOY_HIST -->
<schema-directSQL>
<statement desc="Creating table RHQ_BUNDLE_DEPLOY_HIST">
- CREATE TABLE RHQ_BUNDLE_DEPLOY_HIST ( ID INTEGER )
+ CREATE TABLE RHQ_BUNDLE_DEPLOY_HIST ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_BUNDLE_DEPLOY_HIST" column="ID" nullable="FALSE" />
@@ -2899,7 +2899,50 @@
</schemaSpec>
<schemaSpec version="2.78.5">
- <schema-addColumn table="RHQ_BUNDLE_DEPLOY" column="RESOURCE_GROUP_ID" columnType="INTEGER" />
+ <!-- RHQ_BUNDLE_GROUP_DEPLOY -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_GROUP_DEPLOY">
+ CREATE TABLE RHQ_BUNDLE_GROUP_DEPLOY ( ID INTEGER PRIMARY KEY )
+ </statement>
+ </schema-directSQL>
+ <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="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" />
+ <schema-addColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="SUBJECT_NAME" columnType="VARCHAR2" precision="255" />
+ <schema-alterColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="SUBJECT_NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="CTIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="CTIME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="MTIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_BUNDLE_GROUP_DEPLOY" column="MTIME" nullable="FALSE" />
+ <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_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_DEF">
+ ALTER TABLE RHQ_BUNDLE_GROUP_DEPLOY
+ ADD CONSTRAINT RHQ_BUNDLE_DEPLOY_DEF_FK
+ FOREIGN KEY (BUNDLE_DEPLOY_DEF_ID)
+ REFERENCES RHQ_BUNDLE_DEPLOY_DEF (ID)
+ </statement>
+ </schema-directSQL>
+
+ <schema-addColumn table="RHQ_BUNDLE_DEPLOY" column="BUNDLE_GROUP_DEPLOY_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOY foreign key relation to RHQ_BUNDLE_GROUP_DEPLOY">
+ ALTER TABLE RHQ_BUNDLE_DEPLOY
+ ADD CONSTRAINT RHQ_BUNDLE_GROUP_DEPLOY_FK
+ FOREIGN KEY (BUNDLE_GROUP_DEPLOY_ID)
+ REFERENCES RHQ_BUNDLE_GROUP_DEPLOY (ID)
+ </statement>
+ </schema-directSQL>
</schemaSpec>
<schemaSpec version="2.79">
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
index 45389af..4bb964d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -80,6 +80,10 @@ public class BundleDeployment implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
private Resource resource;
+ @JoinColumn(name = "BUNDLE_GROUP_DEPLOY_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne
+ private BundleGroupDeployment bundleGroupDeployment;
+
@Column(name = "CTIME")
private Long ctime = -1L;
@@ -94,6 +98,13 @@ public class BundleDeployment implements Serializable {
this.resource = resource;
}
+ public BundleDeployment(BundleDeployDefinition bundleDeploymentDef, Resource resource,
+ BundleGroupDeployment bundleGroupDeployment) {
+ this.bundleDeployDefinition = bundleDeploymentDef;
+ this.resource = resource;
+ this.bundleGroupDeployment = bundleGroupDeployment;
+ }
+
public BundleDeployDefinition getBundleDeployDefinition() {
return bundleDeployDefinition;
}
@@ -140,6 +151,14 @@ public class BundleDeployment implements Serializable {
this.histories.add(history);
}
+ public BundleGroupDeployment getBundleGroupDeployment() {
+ return bundleGroupDeployment;
+ }
+
+ public void setBundleGroupDeployment(BundleGroupDeployment bundleGroupDeployment) {
+ this.bundleGroupDeployment = bundleGroupDeployment;
+ }
+
@Override
public String toString() {
StringBuilder str = new StringBuilder("BundleDeployment: ");
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeployment.java
new file mode 100644
index 0000000..8f27723
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeployment.java
@@ -0,0 +1,292 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.bundle;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+
+@Entity
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_GROUP_DEPLOY_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_GROUP_DEPLOY")
+public class BundleGroupDeployment implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @GeneratedValue(generator = "SEQ", strategy = GenerationType.AUTO)
+ @Id
+ private int id;
+
+ @JoinColumn(name = "GROUP_ID", referencedColumnName = "ID")
+ @ManyToOne(cascade = { CascadeType.REMOVE })
+ private ResourceGroup group;
+
+ @JoinColumn(name = "BUNDLE_DEPLOY_DEF_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
+ protected BundleDeployDefinition bundleDeployDefinition;
+
+ @Column(name = "STATUS", nullable = false)
+ @Enumerated(EnumType.STRING)
+ protected BundleGroupDeploymentStatus status;
+
+ @Column(name = "ERROR_MESSAGE")
+ protected String errorMessage;
+
+ @Column(name = "SUBJECT_NAME")
+ protected String subjectName;
+
+ @Column(name = "CTIME", nullable = false)
+ protected long createdTime = System.currentTimeMillis();
+
+ @Column(name = "MTIME", nullable = false)
+ protected long modifiedTime = System.currentTimeMillis();
+
+ @OneToMany(mappedBy = "bundleGroupDeployment", fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
+ private List<BundleDeployment> bundleDeployments = new ArrayList<BundleDeployment>();
+
+ // For JPA
+ public BundleGroupDeployment() {
+ }
+
+ public BundleGroupDeployment(String subjectName, BundleDeployDefinition bundleDeployDefinition, ResourceGroup group) {
+ this.subjectName = subjectName;
+ this.bundleDeployDefinition = bundleDeployDefinition;
+ this.group = group;
+ this.status = BundleGroupDeploymentStatus.INPROGRESS;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * The status of the request which indicates that the request is either still in progress, or it has completed and
+ * either succeeded or failed.
+ *
+ * @return the request status
+ */
+ public BundleGroupDeploymentStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(BundleGroupDeploymentStatus status) {
+ this.status = status;
+ }
+
+ public ResourceGroup getGroup() {
+ return group;
+ }
+
+ public void setGroup(ResourceGroup group) {
+ this.group = group;
+ }
+
+ public BundleDeployDefinition getBundleDeployDefinition() {
+ return bundleDeployDefinition;
+ }
+
+ public void setBundleDeployDefinition(BundleDeployDefinition bundleDeployDefinition) {
+ this.bundleDeployDefinition = bundleDeployDefinition;
+ }
+
+ /**
+ * If not <code>null</code>, this is an error message (possibly a full stack trace) to indicate the overall error
+ * that occurred when the configuration update failed. This will normally be <code>null</code> unless the
+ * {@link #getStatus() status} indicates a {@link BundleGroupDeploymentStatus#FAILURE}.
+ *
+ * @return overall error that occurred
+ */
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /**
+ * Calling this method with a non-<code>null</code> error message implies that the request's status is
+ * {@link ConfigurationUpdateStatus#FAILURE}. The inverse is <i>not</i> true - that is, if you set the error message
+ * to <code>null</code>, the status is left as-is; it will not assume that a <code>null</code> error message means
+ * the status is successful.
+ *
+ * @param errorMessage
+ */
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+
+ if (this.errorMessage != null) {
+ setStatus(BundleGroupDeploymentStatus.FAILURE);
+ }
+ }
+
+ /**
+ * For auditing purposes, this method tells you the username of the person that created the request. This is not a
+ * relationship to an actual Subject because we want to maintain the audit trail, even if a Subject has been deleted
+ * from the database.
+ *
+ * @return the actual name string of the submitter of the request
+ */
+ public String getSubjectName() {
+ return subjectName;
+ }
+
+ /**
+ * The time this entity was originally created; in other words, when the request was originally made.
+ *
+ * @return creation time
+ */
+ public long getCreatedTime() {
+ return this.createdTime;
+ }
+
+ /**
+ * The time this entity was last modified. This is the last time the status was updated. If the status has never
+ * been updated, this will be the {@link #getCreatedTime() created time}.
+ *
+ * @return last modified time
+ */
+ public long getModifiedTime() {
+ return this.modifiedTime;
+ }
+
+ public List<BundleDeployment> getBundleDeployments() {
+ return bundleDeployments;
+ }
+
+ public void setBundleDeployments(List<BundleDeployment> bundleDeployments) {
+ this.bundleDeployments = bundleDeployments;
+ }
+
+ public void addBundleDeployment(BundleDeployment bundleDeployment) {
+ bundleDeployment.setBundleGroupDeployment(this);
+ this.bundleDeployments.add(bundleDeployment);
+ }
+
+ /**
+ * The duration of the configuration update request which simply is the difference between the
+ * {@link #getCreatedTime()} and the {@link #getModifiedTime()}. If the request hasn't completed yet, this will be
+ * the difference between the current time and the created time.
+ *
+ * @return the duration of time that the request took or is taking to complete
+ */
+ public long getDuration() {
+ long start = this.createdTime;
+ long end;
+ if ((status == null) || (status == BundleGroupDeploymentStatus.INPROGRESS)) {
+ end = System.currentTimeMillis();
+ } else {
+ end = this.modifiedTime;
+ }
+
+ return end - start;
+ }
+
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = (PRIME * result) + (int) (createdTime ^ (createdTime >>> 32));
+ result = (PRIME * result) + ((subjectName == null) ? 0 : subjectName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || !(obj instanceof BundleGroupDeployment)) {
+ return false;
+ }
+
+ final BundleGroupDeployment other = (BundleGroupDeployment) obj;
+
+ if (this.createdTime != other.createdTime) {
+ return false;
+ }
+
+ if (this.subjectName == null) {
+ if (other.subjectName != null) {
+ return false;
+ }
+ } else if (!this.subjectName.equals(other.subjectName)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @PrePersist
+ void onPersist() {
+ // don't set createdTime - we use it in equals/hashCode - it is already set at instantiation time
+ this.modifiedTime = System.currentTimeMillis();
+ }
+
+ @PreUpdate
+ void onUpdate() {
+ this.modifiedTime = System.currentTimeMillis();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder("BundleGroupDeployment [");
+ str.append("id=").append(this.id);
+ str.append(", status=").append(this.status);
+ str.append(", resourceGroup=").append(this.group);
+ str.append(", deployDef=").append(this.getBundleDeployDefinition());
+ str.append(", subjectName=").append(this.subjectName);
+ str.append(", createdTime=").append(this.createdTime);
+ str.append(", modifiedTime=").append(this.modifiedTime);
+
+ String err = this.errorMessage;
+ if ((err != null) && (err.indexOf('\n') > -1)) {
+ err = err.substring(0, err.indexOf('\n')) + "...";
+ }
+ str.append(", errorMessage=").append(err);
+ str.append(']');
+
+ return str.toString();
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeploymentStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeploymentStatus.java
new file mode 100644
index 0000000..94f9113
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroupDeploymentStatus.java
@@ -0,0 +1,47 @@
+/*
+ * 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.bundle;
+
+/**
+ * Simple statuses for Bundle Group Deploy requests. When a request is first initiated, it will be considered in the
+ * {@link #INPROGRESS} state. When the request has completed, it will have been either a {@link #SUCCESS} or
+ * {@link #FAILURE}.
+ *
+ * @author Jay Shaughnessy
+ */
+public enum BundleGroupDeploymentStatus {
+ INPROGRESS("In Progress"), //
+ SUCCESS("Success"), //
+ FAILURE("Failure"), //
+ NOCHANGE("No Change");
+
+ private String displayName;
+
+ BundleGroupDeploymentStatus(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String toString() {
+ return displayName;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/GroupBundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/GroupBundleDeployment.java
deleted file mode 100644
index 67ad13f..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/GroupBundleDeployment.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.core.domain.bundle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.CascadeType;
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-
-import org.rhq.core.domain.resource.group.ResourceGroup;
-
-@DiscriminatorValue("group")
-@Entity
-public class GroupBundleDeployment extends BundleDeployment {
-
- private static final long serialVersionUID = 1L;
-
- @JoinColumn(name = "GROUP_ID", referencedColumnName = "ID")
- @ManyToOne
- private ResourceGroup group;
-
- @OneToMany(mappedBy = "groupBundleHistory", cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
- private List<BundleDeployment> bundleDeployments = new ArrayList<BundleDeployment>();
-
- protected GroupBundleDeployment() {
- }
-
- public ResourceGroup getGroup() {
- return group;
- }
-
- public void setGroup(ResourceGroup group) {
- this.group = group;
- }
-
- public List<BundleDeployment> getBundleDeployments() {
- return bundleDeployments;
- }
-
- public void setBundleDeployments(List<BundleDeployment> bundleDeployments) {
- this.bundleDeployments = bundleDeployments;
- }
-
- public void addBundleDeployments(BundleDeployment bundleDeployment) {
- this.bundleDeployments.add(bundleDeployment);
- }
-
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index 7a10422..9eae8e6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -55,7 +55,7 @@ import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.authz.Role;
-import org.rhq.core.domain.bundle.GroupBundleDeployment;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.configuration.group.AbstractGroupConfigurationUpdate;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.resource.Resource;
@@ -407,7 +407,7 @@ public class ResourceGroup extends Group {
@OneToMany(mappedBy = "group", cascade = { CascadeType.ALL })
@OrderBy
// by primary key which will also put the operation histories in chronological order
- private List<GroupBundleDeployment> bundleDeployments = new ArrayList<GroupBundleDeployment>();
+ private List<BundleGroupDeployment> bundleDeployments = new ArrayList<BundleGroupDeployment>();
@JoinColumn(name = "GROUP_DEFINITION_ID", referencedColumnName = "ID", nullable = true)
@ManyToOne
@@ -554,11 +554,11 @@ public class ResourceGroup extends Group {
this.configurationUpdates = configurationUpdates;
}
- public List<GroupBundleDeployment> getBundleDeployments() {
+ public List<BundleGroupDeployment> getBundleDeployments() {
return bundleDeployments;
}
- public void setBundleDeployments(List<GroupBundleDeployment> bundleDeployments) {
+ public void setBundleDeployments(List<BundleGroupDeployment> bundleDeployments) {
this.bundleDeployments = bundleDeployments;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index bab247a..8e6e479 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -50,6 +50,7 @@ import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentAction;
import org.rhq.core.domain.bundle.BundleDeploymentHistory;
import org.rhq.core.domain.bundle.BundleFile;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
@@ -67,6 +68,7 @@ import org.rhq.core.domain.criteria.BundleFileCriteria;
import org.rhq.core.domain.criteria.BundleVersionCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.NumberUtil;
import org.rhq.enterprise.server.RHQConstants;
@@ -431,25 +433,32 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return (PackageType) packageTypeQuery.getSingleResult();
}
- @RequiredPermission(Permission.MANAGE_INVENTORY)
public BundleDeployment scheduleBundleDeployment(Subject subject, int bundleDeployDefinitionId, int resourceId)
throws Exception {
-
BundleDeployDefinition deployDef = entityManager.find(BundleDeployDefinition.class, bundleDeployDefinitionId);
if (null == deployDef) {
throw new IllegalArgumentException("Invalid bundleDeployDefinitionId: " + bundleDeployDefinitionId);
}
+
Resource resource = (Resource) entityManager.find(Resource.class, resourceId);
if (null == resource) {
throw new IllegalArgumentException("Invalid resourceId (Resource does not exist): " + resourceId);
}
+ return scheduleBundleDeployment(subject, deployDef, resource, null);
+ }
+
+ private BundleDeployment scheduleBundleDeployment(Subject subject, BundleDeployDefinition deployDef,
+ Resource resource, BundleGroupDeployment bundleGroupDeployment) throws Exception {
+
+ int resourceId = resource.getId();
AgentClient agentClient = agentManager.getAgentClient(resourceId);
BundleAgentService bundleAgentService = agentClient.getBundleAgentService();
// The BundleDeployment record must exist in the db before the agent request because the agent may try to
// add History to it during immediate deployments., so create and persist it (requires a new trans).
- BundleDeployment deployment = bundleManager.createBundleDeployment(subject, deployDef.getId(), resourceId);
+ BundleDeployment deployment = bundleManager.createBundleDeployment(subject, deployDef.getId(), resourceId,
+ bundleGroupDeployment.getId());
// make sure the deployment contains the info required by the schedule service
BundleVersion bundleVersion = entityManager.find(BundleVersion.class, deployDef.getBundleVersion().getId());
@@ -492,10 +501,44 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return deployment;
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public BundleGroupDeployment scheduleBundleGroupDeployment(Subject subject, int bundleDeployDefinitionId,
+ int resourceGroupId) throws Exception {
+
+ BundleDeployDefinition deployDef = entityManager.find(BundleDeployDefinition.class, bundleDeployDefinitionId);
+ if (null == deployDef) {
+ throw new IllegalArgumentException("Invalid bundleDeployDefinitionId: " + bundleDeployDefinitionId);
+ }
+ ResourceGroup resourceGroup = (ResourceGroup) entityManager.find(ResourceGroup.class, resourceGroupId);
+ if (null == resourceGroup) {
+ throw new IllegalArgumentException("Invalid resourceGroupId (ResourceGroup does not exist): "
+ + resourceGroupId);
+ }
+
+ /*
+ * we need to create and persist the group deployment entity in a new transaction before the rest of the
+ * processing of this method; if we try to create and attach the deployment children
+ * to the parent before this is persisted we'll get StaleStateExceptions
+ * from Hibernate because of our use of flush/clear (we're trying to update it before it actually exists)
+ */
+ BundleGroupDeployment bundleGroupDeployment = new BundleGroupDeployment(subject.getName(), deployDef,
+ resourceGroup);
+ bundleGroupDeployment = bundleManager.createBundleGroupDeployment(bundleGroupDeployment);
+
+ // Create and persist updates for each of the group members.
+ for (Resource resource : resourceGroup.getExplicitResources()) {
+ BundleDeployment bundleDeployment = scheduleBundleDeployment(subject, deployDef, resource,
+ bundleGroupDeployment);
+ bundleGroupDeployment.addBundleDeployment(bundleDeployment);
+ }
+
+ return bundleGroupDeployment;
+ }
+
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@RequiredPermission(Permission.MANAGE_INVENTORY)
- public BundleDeployment createBundleDeployment(Subject subject, int bundleDeployDefinitionId, int resourceId)
- throws Exception {
+ public BundleDeployment createBundleDeployment(Subject subject, int bundleDeployDefinitionId, int resourceId,
+ int bundleGroupDeploymentId) throws Exception {
BundleDeployDefinition deployDef = entityManager.find(BundleDeployDefinition.class, bundleDeployDefinitionId);
if (null == deployDef) {
@@ -506,12 +549,22 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
throw new IllegalArgumentException("Invalid resourceId (Resource does not exist): " + resourceId);
}
- BundleDeployment deployment = new BundleDeployment(deployDef, resource);
+ BundleGroupDeployment bundleGroupDeployment = (BundleGroupDeployment) entityManager.find(
+ BundleGroupDeployment.class, bundleGroupDeploymentId);
+
+ BundleDeployment deployment = new BundleDeployment(deployDef, resource, bundleGroupDeployment);
entityManager.persist(deployment);
return deployment;
}
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public BundleGroupDeployment createBundleGroupDeployment(BundleGroupDeployment bundleGroupDeployment)
+ throws Exception {
+ entityManager.persist(bundleGroupDeployment);
+ return bundleGroupDeployment;
+ }
+
@RequiredPermission(Permission.MANAGE_INVENTORY)
public Set<String> getBundleVersionFilenames(Subject subject, int bundleVersionId, boolean withoutBundleFileOnly)
throws Exception {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
index fc4d224..b265f0e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
@@ -25,6 +25,7 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentHistory;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
/**
@@ -65,11 +66,17 @@ public interface BundleManagerLocal extends BundleManagerRemote {
BundleType createBundleType(Subject subject, String name, int resourceTypeId) throws Exception;
/**
- * This is typically not called directly, typically deployBundle() is called externally. This executes
- * in a New Transaction and supports deployBundle.
+ * This is typically not called directly, typically scheduleBundleDeployment() is called externally. This executes
+ * in a New Transaction and supports scheduleBundleDeployment.
*/
- BundleDeployment createBundleDeployment(Subject subject, int bundleDeployDefinitionId, int resourceId)
- throws Exception;
+ BundleDeployment createBundleDeployment(Subject subject, int bundleDeployDefinitionId, int resourceId,
+ int bundleGroupDeploymentId) throws Exception;
+
+ /**
+ * This is typically not called directly, typically scheduleBundleGroupDeployment() is called externally.
+ * This executes in a New Transaction and supports scheduleBundleGroupDeployment.
+ */
+ BundleGroupDeployment createBundleGroupDeployment(BundleGroupDeployment bundleGroupDeployment) throws Exception;
// added here because the same method in @Remote was commented out to bypass a WSProvide issue
Map<String, Boolean> getAllBundleVersionFilenames(Subject subject, int bundleVersionId) throws Exception;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
index b3a84ff..6184a6c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
@@ -33,6 +33,7 @@ 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.BundleFile;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
@@ -296,4 +297,23 @@ public interface BundleManagerRemote {
@WebParam(name = "bundleDeployDefinitionId") int bundleDeployDefinitionId, //
@WebParam(name = "resourceId") int resourceId) throws Exception;
+ /**
+ * Deploy the bundle as described in the provided deploy definition to all of the resources in the
+ * specified resource group.
+ * Deployment is asynchronous so return of this method does not indicate deployments are complete. The
+ * returned BundleGroupDeployment can be used to track the history of the deployments.
+ *
+ * TODO: Add the scheduling capability, currently it's Immediate.
+ *
+ * @param subject must be InventoryManager
+ * @param bundleDeployDefinitionId the BundleDeployDefinition being used to guide the deployments
+ * @param resourceGroupId the target resourceGroup (must exist), typically platforms, for the deployments
+ * @return the BundleGroupDeployment created to track the deployments.
+ * @throws Exception
+ */
+ @WebMethod
+ BundleGroupDeployment scheduleBundleGroupDeployment( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "bundleDeployDefinitionId") int bundleDeployDefinitionId, //
+ @WebParam(name = "resourceGroupId") int resourceGroupId) throws Exception;
}
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 6521e5b..06b59c6 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
@@ -42,6 +42,7 @@ 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.BundleFile;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
@@ -425,7 +426,12 @@ public class WebservicesManagerBean implements WebservicesRemote {
return bundleManager.scheduleBundleDeployment(subject, bundleDeployDefinitionId, resourceId);
}
- //BUNDLEMANAGER: END ----------------------------------
+ public BundleGroupDeployment scheduleBundleGroupDeployment(Subject subject, int bundleDeployDefinitionId,
+ int resourceGroupId) throws Exception {
+ return bundleManager.scheduleBundleGroupDeployment(subject, bundleDeployDefinitionId, resourceGroupId);
+ }
+
+ //BUNDLEMANAGER: END ----------------------------------
//CALLTIMEDATAMANAGER: BEGIN ----------------------------------
public PageList<CallTimeDataComposite> findCallTimeDataForResource(Subject subject, int scheduleId, long beginTime,
commit d3e840578d34c8de89352e6502aa7227cfa58165
Merge: 0212483... 89d3004...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Mar 23 17:03:54 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit 02124836fdb9776037c4c184262493553694200b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Mar 23 17:02:07 2010 -0400
Some stuff for group bundle deploy
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 75675ef..178013b 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -575,7 +575,9 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="BUNDLE_DEPLOY_DEF_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_DEPLOY_DEF" />
<column name="RESOURCE_ID" type="INTEGER" required="true" references="RHQ_RESOURCE" />
- <column name="CTIME" type="LONG" required="true"/>
+ <column name="CTIME" type="LONG" required="true"/>
+ <!-- for group history -->
+ <column name="GROUP_ID" type="INTEGER" required="false" references="RHQ_RESOURCE_GROUP"/>
<index name="RHQ_DEPLOY_DEF_RESOURCE_IDX" unique="true">
<field ref="BUNDLE_DEPLOY_DEF_ID"/>
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 2b8848f..da47976 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2898,7 +2898,11 @@
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION_ORDER" nullable="FALSE" />
</schemaSpec>
- <schemaSpec version="2.79">
+ <schemaSpec version="2.78.5">
+ <schema-addColumn table="RHQ_BUNDLE_DEPLOY" column="RESOURCE_GROUP_ID" columnType="INTEGER" />
+ </schemaSpec>
+
+ <schemaSpec version="2.79">
<schema-directSQL>
<statement desc="Normalizing resource group descriptions">
UPDATE RHQ_RESOURCE_GROUP SET DESCRIPTION = NULL WHERE DESCRIPTION = ''
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/GroupBundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/GroupBundleDeployment.java
new file mode 100644
index 0000000..67ad13f
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/GroupBundleDeployment.java
@@ -0,0 +1,73 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.bundle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+
+import org.rhq.core.domain.resource.group.ResourceGroup;
+
+@DiscriminatorValue("group")
+@Entity
+public class GroupBundleDeployment extends BundleDeployment {
+
+ private static final long serialVersionUID = 1L;
+
+ @JoinColumn(name = "GROUP_ID", referencedColumnName = "ID")
+ @ManyToOne
+ private ResourceGroup group;
+
+ @OneToMany(mappedBy = "groupBundleHistory", cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
+ private List<BundleDeployment> bundleDeployments = new ArrayList<BundleDeployment>();
+
+ protected GroupBundleDeployment() {
+ }
+
+ public ResourceGroup getGroup() {
+ return group;
+ }
+
+ public void setGroup(ResourceGroup group) {
+ this.group = group;
+ }
+
+ public List<BundleDeployment> getBundleDeployments() {
+ return bundleDeployments;
+ }
+
+ public void setBundleDeployments(List<BundleDeployment> bundleDeployments) {
+ this.bundleDeployments = bundleDeployments;
+ }
+
+ public void addBundleDeployments(BundleDeployment bundleDeployment) {
+ this.bundleDeployments.add(bundleDeployment);
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index 63f229c..7a10422 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -55,6 +55,7 @@ import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.bundle.GroupBundleDeployment;
import org.rhq.core.domain.configuration.group.AbstractGroupConfigurationUpdate;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.resource.Resource;
@@ -403,6 +404,11 @@ public class ResourceGroup extends Group {
// by primary key which will also put the configuration updates in chronological order
private List<AbstractGroupConfigurationUpdate> configurationUpdates = new ArrayList<AbstractGroupConfigurationUpdate>();
+ @OneToMany(mappedBy = "group", cascade = { CascadeType.ALL })
+ @OrderBy
+ // by primary key which will also put the operation histories in chronological order
+ private List<GroupBundleDeployment> bundleDeployments = new ArrayList<GroupBundleDeployment>();
+
@JoinColumn(name = "GROUP_DEFINITION_ID", referencedColumnName = "ID", nullable = true)
@ManyToOne
private GroupDefinition groupDefinition;
@@ -548,6 +554,14 @@ public class ResourceGroup extends Group {
this.configurationUpdates = configurationUpdates;
}
+ public List<GroupBundleDeployment> getBundleDeployments() {
+ return bundleDeployments;
+ }
+
+ public void setBundleDeployments(List<GroupBundleDeployment> bundleDeployments) {
+ this.bundleDeployments = bundleDeployments;
+ }
+
public GroupDefinition getGroupDefinition() {
return groupDefinition;
}
14 years, 1 month
[rhq] Branch 'bugfixes' - 8 commits - modules/core modules/enterprise modules/test-utils
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java | 4
modules/enterprise/server/jar/pom.xml | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 6
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java | 145 ++++++++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java | 90 +++++-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java | 8
modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v1.xml | 12
modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v2.xml | 12
modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java | 39 ++
modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java | 15 -
10 files changed, 319 insertions(+), 18 deletions(-)
New commits:
commit 413a2fc213eb85c2a160063fb2703f5a59e1b7d6
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Mar 26 09:15:11 2010 -0400
Updating assertPropertyMatches() to allow you to specify properties to exclude from comparison
diff --git a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
index f37f11c..c86114e 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
@@ -25,13 +25,16 @@ package org.rhq.test;
import static org.testng.Assert.*;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
public class AssertUtils {
/**
* Verifies that all public, accessible properties of the two objects are equal. This method might be used when you
- * want to compare two objects without using their <code>equals()</code> methods or when do not implement <code>
+ * want to compare two objects without using their <code>equals()</code> methods or when they do not implement <code>
* equals()</code>.
*
* @param expected The expected object to compare against. Should be non-null.
@@ -40,12 +43,39 @@ public class AssertUtils {
* @param <T> The type of the objects to be compared
*/
public static <T> void assertPropertiesMatch(T expected, T actual, String msg) {
+ assertPropertiesMatch(msg, expected, actual, Collections.<String>emptyList());
+ }
+
+ /**
+ * @param msg An error message
+ * @param expected The expected object to compare against. Should be non-null.
+ * @param actual The actual object to be compared. Should be non-null.
+ * @param ignoredProperties A list of property names to exclude from comparison.
+ * @param <T> The type of the objects to be compared.
+ */
+ public static <T> void assertPropertiesMatch(String msg, T expected, T actual, String... ignoredProperties) {
+ assertPropertiesMatch(msg, expected, actual, Arrays.asList(ignoredProperties));
+ }
+
+ /**
+ * Verifies that all public, accessible properties of the two objects are equal, excluding those specified in the
+ * <code>ignoredProperties</code> argument. This method might be used when you want to compare two objects without
+ * using their <code>equals()</code> methods or when they do not implement <code>equals</code>.
+ *
+ * @param msg An error message
+ * @param expected The expected object to compare against. Should be non-null.
+ * @param actual The actual object to be compared. Should be non-null.
+ * @param ignoredProperties A list of property names to exclude from comparison.
+ * @param <T> The type of the objects to be compared.
+ */
+ public static <T> void assertPropertiesMatch(String msg, T expected, T actual, List<String> ignoredProperties) {
assertNotNull(expected, "Expected object should not be null");
assertNotNull(actual, "Actual object should not be null");
PropertyMatcher<T> matcher = new PropertyMatcher<T>();
matcher.setExpected(expected);
matcher.setActual(actual);
+ matcher.setIgnoredProperties(ignoredProperties);
MatchResult result = matcher.execute();
diff --git a/modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java b/modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java
index 6352be5..8d9b3cc 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java
@@ -25,8 +25,11 @@ package org.rhq.test;
import org.apache.commons.beanutils.PropertyUtils;
-import java.util.Map;
import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
public class PropertyMatcher<T> {
@@ -34,6 +37,8 @@ public class PropertyMatcher<T> {
private T actual;
+ private Set<String> ignoredProperties = new HashSet<String>();
+
public void setExpected(T expected) {
this.expected = expected;
}
@@ -42,6 +47,10 @@ public class PropertyMatcher<T> {
this.actual = actual;
}
+ public void setIgnoredProperties(Collection<String> ignoredProperties) {
+ this.ignoredProperties.addAll(ignoredProperties);
+ }
+
public MatchResult execute() {
try {
Map<String, ?> expectedProps = PropertyUtils.describe(expected);
@@ -55,6 +64,10 @@ public class PropertyMatcher<T> {
Object expectedValue = expectedProps.get(name);
Object actualValue = actualProps.get(name);
+ if (ignoredProperties.contains(name)) {
+ continue;
+ }
+
if (!propertyEquals(expectedValue, actualValue)) {
isMatch = false;
details.append("expected." + name + " = " + expectedValue + "\n");
commit 80e99b140eb0b6bbca3f1cea6c9422238d909775
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Mar 26 09:14:29 2010 -0400
Adding another test and cleaning up persistence logic
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
index b414497..6b7ec13 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
@@ -84,11 +84,7 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
private ConfigurationDefinition createAndSaveConfigurationDef(String file) throws Exception {
ConfigurationDefinition configurationDef = loadPluginConfigurationFromFile(file);
-
entityMgr.persist(configurationDef);
- entityMgr.flush();
- entityMgr.clear();
-
return configurationDef;
}
@@ -118,7 +114,7 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
void assertPropertyDefinitionMatches(String msg, PropertyDefinitionSimple expected,
PropertyDefinitionSimple actual) {
- AssertUtils.assertPropertiesMatch(expected, actual, msg);
+ AssertUtils.assertPropertiesMatch(msg, expected, actual, "id", "configurationDefinition");
}
@Test
@@ -138,4 +134,12 @@ public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
assertPropertyDefinitionMatches("Existing ungrouped property defs should be updated", expected, actual);
}
+ @Test
+ public void propertyDefNotInNewConfigurationDefShouldBeRemovedFromConfigurationDef() throws Exception {
+ assertNull(
+ "A property def in the original configuration def that is removed in the new configuration def should be deleted",
+ originalConfigurationDef.getPropertyDefinitionSimple("propertyToBeRemoved")
+ );
+ }
+
}
commit 3bce4eac0c9dc9a994f0e1ca5a943f07db9465ff
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Mar 26 08:59:56 2010 -0400
[BZ 573034] Removing unncessary call to EntityManager.remove() and EntityManager.flush()
Removing the unncessary calls to EntityManager.remove() and EntityManager.flush() when a property
definition is being removed. The call to EntityManager.remove() is unncessary because the
property definition is first removed from the configuration definition and the association
from configuration definition to property definition cascades all operations, including
deletes.
The call to EntityManager.remove() was causing an exception in
ConfigurationMetadataManagerBeanTest that reported that you cannot call EntityManager.remove()
on a detached entity. I am not clear why that this failed in the test but works in production
code; however, I tested the change in this commit against a running server and it seemed
to work fine. I redeployed a plugin with properties removed and those property definitions
were successfully removed from the database.
Lastly, I did review http://jira.rhq-project.org/browse/RHQ-575 before making the change
and have proceeded with caution in light of the comments in the jira.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 41a1a6f..3e8653c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -247,6 +247,8 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
// properties = new ArrayList<Property>(properties);
// properties.add(ps);
// existConf.setProperties(properties);
+ Property property = ps.deepCopy(false);
+ existConf.put(property);
}
}
}
@@ -282,10 +284,8 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
for (PropertyDefinition def : definitionsToDelete) {
existingDefinition.getPropertyDefinitions().remove(def.getName());
- existingProperties.remove(def); // does not operate on original list!!
- entityManager.remove(def);
+ existingProperties.remove(def); // does not operate on original list!!
}
- entityManager.flush();
}
/**
commit 877e33b93ab3c4e6edd8e8c94e432c2cc1b5faa2
Merge: bcb345d... 6345fd4...
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Mar 25 16:04:47 2010 -0400
Merge branch 'bugfixes' of ssh://git.fedorahosted.org/git/rhq/rhq into bugfixes
commit bcb345db7762fa0102e64a1e884d25be3ea9d32f
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Mar 25 16:02:54 2010 -0400
Initial commit for ConfigurationMetadataManagerBeanTest.
These tests are data-driven tests that are intended to verify that a configuration definition
is updated correctly. The data sources being used are plugin descriptor files.
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 1123ff8..bfb4d67 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -70,6 +70,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>test-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- 3rd Party Deps -->
<dependency>
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
new file mode 100644
index 0000000..b414497
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
@@ -0,0 +1,141 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.server.configuration.metadata;
+
+import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
+import org.rhq.core.clientapi.descriptor.DescriptorPackages;
+import org.rhq.core.clientapi.descriptor.configuration.ConfigurationDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.server.resource.metadata.test.UpdateSubsytemTestBase;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.test.AssertUtils;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.util.ValidationEventCollector;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import java.io.FileNotFoundException;
+import java.net.URL;
+
+public class ConfigurationMetadataManagerBeanTest extends AbstractEJB3Test {
+
+ ConfigurationMetadataManagerLocal configurationMetadataMgr;
+
+ EntityManager entityMgr;
+
+ ConfigurationDefinition originalConfigurationDef;
+
+ ConfigurationDefinition newConfigurationDef;
+
+ @BeforeClass
+ public void setupClass() throws Exception {
+ String pluginFileBaseName = "configuration_metadata_manager_bean_test";
+ String version1 = pluginFileBaseName + "_v1.xml";
+ String version2 = pluginFileBaseName + "_v2.xml";
+
+ getTransactionManager().begin();
+ entityMgr = getEntityManager();
+
+ configurationMetadataMgr = LookupUtil.getConfigurationMetadataManager();
+
+ originalConfigurationDef = createAndSaveConfigurationDef(version1);
+ newConfigurationDef = loadPluginConfigurationFromFile(version2);
+
+ configurationMetadataMgr.updateConfigurationDefinition(newConfigurationDef, originalConfigurationDef);
+ }
+
+ @AfterClass
+ public void tearDownClass() throws Exception {
+ getTransactionManager().rollback();
+ }
+
+ private ConfigurationDefinition createAndSaveConfigurationDef(String file) throws Exception {
+ ConfigurationDefinition configurationDef = loadPluginConfigurationFromFile(file);
+
+ entityMgr.persist(configurationDef);
+ entityMgr.flush();
+ entityMgr.clear();
+
+ return configurationDef;
+ }
+
+ private ConfigurationDefinition loadPluginConfigurationFromFile(String file) throws Exception {
+ PluginDescriptor pluginDescriptor = loadPluginDescriptor(file);
+ ConfigurationDescriptor configurationDescriptor = pluginDescriptor.getServers().get(0).getPluginConfiguration();
+ return ConfigurationMetadataParser.parse("test", configurationDescriptor);
+ }
+
+ private PluginDescriptor loadPluginDescriptor(String file) throws Exception {
+ URL pluginDescriptorURL = getClass().getResource(file);
+ if (pluginDescriptorURL == null) {
+ throw new FileNotFoundException("File " + file + " not found");
+ }
+
+ JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
+ URL pluginSchemaURL = this.getClass().getClassLoader().getResource("rhq-plugin.xsd");
+ Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(pluginSchemaURL);
+
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ unmarshaller.setEventHandler(vec);
+ unmarshaller.setSchema(pluginSchema);
+
+ return (PluginDescriptor) unmarshaller.unmarshal(pluginDescriptorURL.openStream());
+ }
+
+ void assertPropertyDefinitionMatches(String msg, PropertyDefinitionSimple expected,
+ PropertyDefinitionSimple actual) {
+ AssertUtils.assertPropertiesMatch(expected, actual, msg);
+ }
+
+ @Test
+ public void newUngroupedPropertyDefsShouldBeAddedToConfigurationDef() throws Exception {
+ PropertyDefinitionSimple expected = newConfigurationDef.getPropertyDefinitionSimple("bar");
+ PropertyDefinitionSimple actual = originalConfigurationDef.getPropertyDefinitionSimple("bar");
+
+ assertPropertyDefinitionMatches("New ungrouped property defs shoould be added to the configuration definition",
+ expected, actual);
+ }
+
+ @Test
+ public void existingUngroupedPropertyDefShouldBeUpdated() throws Exception {
+ PropertyDefinitionSimple expected = newConfigurationDef.getPropertyDefinitionSimple("foo");
+ PropertyDefinitionSimple actual = originalConfigurationDef.getPropertyDefinitionSimple("foo");
+
+ assertPropertyDefinitionMatches("Existing ungrouped property defs should be updated", expected, actual);
+ }
+
+}
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 39a018d..cc9e547 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
@@ -5,7 +5,7 @@
xmlns:c="urn:xmlns:rhq-configuration">
<server name="TestServer">
<plugin-configuration>
- <c:simple-property name="testProperty"/>
+ <c:simple-property name="testProperty" required="true" default="default"/>
</plugin-configuration>
</server>
</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 d5ff5c5..b31279d 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
@@ -6,7 +6,7 @@
<server name="TestServer">
<plugin-configuration>
<c:simple-property name="testProperty"/>
- <c:simple-property name="testPropertyWithDefault" default="default"/>
+ <c:simple-property name="testPropertyWithDefault" required="true" default="default"/>
</plugin-configuration>
</server>
</plugin>
commit 920b55c11c6e4977d3837db68d5efb6a336820e2
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Mar 25 16:01:19 2010 -0400
Fixing type for resourceTypeId filter. It was a string and should be an int.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index 84c9ce5..7df33f5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -47,7 +47,7 @@ public class ResourceCriteria extends Criteria {
private InventoryStatus filterInventoryStatus = InventoryStatus.COMMITTED; // default
private String filterVersion;
private String filterDescription;
- private String filterResourceTypeId; // needs overrides
+ private Integer filterResourceTypeId; // needs overrides
private String filterResourceTypeName; // needs overrides
private ResourceCategory filterResourceCategory; // needs overrides
private String filterPluginName; // needs overrides
@@ -138,7 +138,7 @@ public class ResourceCriteria extends Criteria {
this.filterDescription = filterDescription;
}
- public void addFilterResourceTypeId(String filterResourceTypeId) {
+ public void addFilterResourceTypeId(Integer filterResourceTypeId) {
this.filterResourceTypeId = filterResourceTypeId;
}
commit 5f465271ffdfd586ed6531078264d010bbb5e957
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Mar 25 16:00:01 2010 -0400
Adding assertions to handle null inputs for assertPropertiesMatch().
diff --git a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
index b9bf46d..f37f11c 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
@@ -34,12 +34,15 @@ public class AssertUtils {
* want to compare two objects without using their <code>equals()</code> methods or when do not implement <code>
* equals()</code>.
*
- * @param expected The expected object to compare against
- * @param actual The actual object to be compared
+ * @param expected The expected object to compare against. Should be non-null.
+ * @param actual The actual object to be compared. Should be non-null.
* @param msg An error message
* @param <T> The type of the objects to be compared
*/
public static <T> void assertPropertiesMatch(T expected, T actual, String msg) {
+ assertNotNull(expected, "Expected object should not be null");
+ assertNotNull(actual, "Actual object should not be null");
+
PropertyMatcher<T> matcher = new PropertyMatcher<T>();
matcher.setExpected(expected);
matcher.setActual(actual);
commit 71dad11d58a2642bf0707b63a6c479b802b10859
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Mar 24 12:08:40 2010 -0400
[BZ 573034] Adding test to reproduce the bug
The registers a plugin and then creates a resource of the resource type specified in the
plugin. A new version of the plugin is deployed having a new plugin configuration property
that specifies a default value. The test then checks that the resource's plugin configuration
picks up the new property and it is set to the specified default value.
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 c2579ca..f67eb3e 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,12 +18,6 @@
*/
package org.rhq.enterprise.server.resource.metadata.test;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-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;
@@ -38,7 +32,15 @@ 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;
public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
@@ -138,6 +140,80 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
}
}
+ @Test
+ public void testBZ_573034() throws Exception {
+ 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);
+
+ 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
+ );
+
+ // 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);
+
+ pluginConfigurationDef = testServerResourceType.getPluginConfigurationDefinition();
+ PropertyDefinition testPropertyWithDefaultDef =
+ pluginConfigurationDef.getPropertyDefinitionSimple("testPropertyWithDefault");
+
+ assertNotNull(
+ "Expected updated plugin configuration definition to define the property 'testPropertyWithDefault'",
+ testPropertyWithDefaultDef
+ );
+
+ pluginConfiguration = entityMgr.find(Configuration.class, pluginConfigurationId);
+ PropertySimple testPropertyWithDefault = pluginConfiguration.getSimple("testPropertyWithDefault");
+
+ assertNotNull(
+ "Expected to find the property 'testPropertyWithDefault' in the updated plugin configuration",
+ testPropertyWithDefault
+ );
+ assertEquals("Expected default value to be set", "default", testPropertyWithDefault.getStringValue());
+ }
+ finally {
+ getTransactionManager().rollback();
+ }
+ }
+
/**
* Tests the behaviour wrt <resource-configuration> entries
*
@@ -353,7 +429,7 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
*
* @throws Exception
*/
- @Test
+ @Test(enabled = false)
public void testConstraintMinMax() throws Exception {
getTransactionManager().begin();
try {
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 f4b614f..673dd5f 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
@@ -104,17 +104,21 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
@SuppressWarnings("unchecked")
protected ResourceType getResourceType(String typeName) {
+ return getResourceType(typeName, PLUGIN_NAME);
+ }
+
+ protected ResourceType getResourceType(String typeName, String pluginName) {
Query q1 = getEntityManager().createQuery("Select rt from ResourceType rt");
List<ResourceType> types = q1.getResultList();
Query q = getEntityManager().createNamedQuery(ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN);
- q.setParameter("name", typeName).setParameter("plugin", PLUGIN_NAME);
+ q.setParameter("name", typeName).setParameter("plugin", pluginName);
try {
ResourceType type = (ResourceType) q.getSingleResult();
return type;
} catch (NoResultException nre) {
throw new NoResultException("==== Failed to lookup ResourceType [" + typeName + "] from Plugin ["
- + PLUGIN_NAME + "] - found: " + types);
+ + pluginName + "] - found: " + types);
}
}
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
new file mode 100644
index 0000000..39a018d
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v1.xml
@@ -0,0 +1,12 @@
+<plugin name="BZ_573034_test_plugin" 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"
+ xmlns:c="urn:xmlns:rhq-configuration">
+ <server name="TestServer">
+ <plugin-configuration>
+ <c:simple-property name="testProperty"/>
+ </plugin-configuration>
+ </server>
+</plugin>
+
\ No newline at end of file
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
new file mode 100644
index 0000000..d5ff5c5
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/resources/test/metadata/configuration/BZ_573034_v2.xml
@@ -0,0 +1,12 @@
+<plugin name="BZ_573034_test_plugin" 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"
+ xmlns:c="urn:xmlns:rhq-configuration">
+ <server name="TestServer">
+ <plugin-configuration>
+ <c:simple-property name="testProperty"/>
+ <c:simple-property name="testPropertyWithDefault" default="default"/>
+ </plugin-configuration>
+ </server>
+</plugin>
14 years, 1 month
[rhq] 5 commits - modules/enterprise
by Heiko W. Rupp
modules/enterprise/gui/installer-war/pom.xml | 17 -
modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java | 60 +++
modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java | 25 +
modules/enterprise/server/container-lib/pom.xml | 7
modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java | 144 ++++++++
modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat | 112 ++++++
modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh | 165 ++++++++++
modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml | 22 +
modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej | 9
modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej | 13
modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej | 9
modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej | 9
12 files changed, 547 insertions(+), 45 deletions(-)
New commits:
commit a32db89465af384df8d30b3667f4f545d9893105
Merge: 9f3981b... 002b86a...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 26 13:50:03 2010 +0100
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 9f3981b21e128316ff39cbd5fe54e998e9002af4
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 26 13:49:55 2010 +0100
First cut of a Windows script to generate the passwords.
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat
new file mode 100644
index 0000000..3b85102
--- /dev/null
+++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat
@@ -0,0 +1,112 @@
+@echo off
+
+rem ===========================================================================
+rem RHQ Server Windows Generate db password script
+rem
+rem This file is used to execute the generate a new encrypted db password.
+rem
+rem This script is customizable by setting the following environment variables:
+rem
+rem RHQ_SERVER_DEBUG - If this is defined, the script will emit debug
+rem messages.
+rem If not set or set to "false", debug is turned off.
+rem
+rem RHQ_SERVER_HOME - Defines where the Server's home install directory is.
+rem If not defined, it will be assumed to be the parent
+rem directory of the directory where this script lives.
+rem
+rem RHQ_SERVER_JAVA_HOME - The location of the JRE that the Server will
+rem use. This will be ignored if
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
+rem If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are
+rem not set, the Server's embedded JRE will be used.
+rem
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
+rem executable to use. If this is set,
+rem RHQ_SERVER_JAVA_HOME is ignored.
+rem If this is not set, then
+rem %RHQ_SERVER_JAVA_HOME%\bin\java.exe
+rem is used. If this and
+rem RHQ_SERVER_JAVA_HOME are not set, the
+rem Server's embedded JRE will be used.
+rem
+rem
+rem Note that you cannot define custom Java VM parameters or command line
+rem arguments to pass to the RHQ Server run.sh. If you wish to pass in
+rem specific arguments, modify the rhq-server-wrapper.conf file.
+rem
+rem If the embedded JRE is to be used but is not available, the fallback
+rem JRE to be used will be determined by the JAVA_HOME environment variable.
+rem
+rem ===========================================================================
+
+setlocal
+
+rem if debug variable is set, it is assumed to be on, unless its value is false
+if "%RHQ_SERVER_DEBUG%" == "false" (
+ set RHQ_SERVER_DEBUG=
+)
+
+rem ----------------------------------------------------------------------
+rem Change directory so the current directory is the Server home.
+rem ----------------------------------------------------------------------
+
+set RHQ_SERVER_BIN_DIR_PATH=%~dp0
+
+if not defined RHQ_SERVER_HOME (
+ cd "%RHQ_SERVER_BIN_DIR_PATH%\.."
+) else (
+ cd "%RHQ_SERVER_HOME%" || (
+ echo Cannot go to the RHQ_SERVER_HOME directory: %RHQ_SERVER_HOME%
+ exit /B 1
+ )
+)
+
+set RHQ_SERVER_HOME=%CD%
+
+if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_HOME: %RHQ_SERVER_HOME%
+
+rem ----------------------------------------------------------------------
+rem Find the Java executable and verify we have a VM available.
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
+ if not defined RHQ_SERVER_JAVA_HOME call :prepare_embedded_jre
+)
+
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH set RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_HOME%\bin\java.exe
+
+if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_JAVA_HOME: %RHQ_SERVER_JAVA_HOME%
+if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_JAVA_EXE_FILE_PATH: %RHQ_SERVER_JAVA_EXE_FILE_PATH%
+
+if not exist "%RHQ_SERVER_JAVA_EXE_FILE_PATH%" (
+ echo There is no JVM available.
+ echo Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately.
+ exit /B 1
+)
+
+set _JB_DIR = %RHQ_SERVER_HOME%\jbossas
+%RHQ_SERVER_JAVA_EXE_FILE_PATH% -cp %_JB_DIR%\lib\jboss-common.jar;%_JB_DIR%\lib\jboss-jmx.jar;%_JB_DIR%\server\default\lib\jbosssx.jar;%_JB_DIR%\server\default\lib\jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule %1
+
+
+goto :done
+
+rem ----------------------------------------------------------------------
+rem CALL subroutine that prepares to use the embedded JRE
+rem ----------------------------------------------------------------------
+
+:prepare_embedded_jre
+set RHQ_SERVER_JAVA_HOME=%RHQ_SERVER_HOME%\jre
+if defined RHQ_SERVER_DEBUG echo Using the embedded JRE
+if not exist "%RHQ_SERVER_JAVA_HOME%" (
+ if defined RHQ_SERVER_DEBUG echo No embedded JRE found - will try to use JAVA_HOME: %JAVA_HOME%
+ set RHQ_SERVER_JAVA_HOME=%JAVA_HOME%
+)
+goto :eof
+
+rem ----------------------------------------------------------------------
+rem CALL subroutine that exits this script normally
+rem ----------------------------------------------------------------------
+
+:done
+endlocal
commit 73626e4146d1acf382dca898748227475755afec
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 26 13:42:37 2010 +0100
Fix comments
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 c515e4c..d3fd715 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
@@ -6,20 +6,12 @@
# processname: java
# =============================================================================
-# RHQ Server UNIX Startup Script
+# RHQ Server UNIX Generate db password script
#
-# This file is used to execute the RHQ Server on a UNIX platform as part of
-# the platform's bootup sequence or as a foreground console process.
-# Run this script without any command line options for the syntax help.
+# This file is used to execute the generate a new encrypted db password.
#
# This script is customizable by setting the following environment variables:
#
-# Note that if this script is to be used as an init.d script, you must set
-# RHQ_SERVER_HOME so this script knows where to find the Server installation.
-#
-# RHQ_SERVER_DEBUG - If this is defined, the script will emit debug
-# messages. If this is not defined or set to "false"
-# debug messages are not emitted.
#
# RHQ_SERVER_HOME - Defines where the server's home install directory is.
# If not defined, it will be assumed to be the parent
@@ -40,44 +32,9 @@
# RHQ_SERVER_JAVA_HOME are not set, the
# Server's embedded JRE will be used.
#
-# RHQ_SERVER_JAVA_OPTS - Java VM command line options to be
-# passed into the Server's VM. If this is not defined
-# this script will pass in a default set of options.
-# If this is set, it completely overrides the
-# Server's defaults. If you only want to add options
-# to the Server's defaults, then you will want to
-# use RHQ_SERVER_ADDITIONAL_JAVA_OPTS instead.
-#
-# RHQ_SERVER_ADDITIONAL_JAVA_OPTS - additional Java VM command line options
-# to be passed into the Server's VM. This
-# is added to RHQ_SERVER_JAVA_OPTS; it
-# is mainly used to augment the Server's
-# default set of options. This can be
-# left unset if it is not needed.
-#
-# RHQ_SERVER_CMDLINE_OPTS - If this is defined, these are the command line
-# arguments that will be passed to the RHQ Server
-# JBossAS run.sh. If you only want to add options
-# to the Server's defaults, then you will want to
-# use RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS instead.
-#
-# RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS - additional command line arguments to
-# be passed to the RHQ Server JBossAS
-# run.sh. This is added to
-# RHQ_SERVER_CMDLINE_OPTS; it is mainly
-# used to augment the Server's default
-# set of options. This can be left unset
-# if it is not needed.
-#
-# RHQ_SERVER_PIDFILE_DIR - a full path to a writable directory where this
-# script can write its pidfile to.
-# If not defined, this defaults to the Server's
-# bin directory.
-#
# If the embedded JRE is to be used but is not available, the fallback
# JRE to be used will be determined by the JAVA_HOME environment variable.
#
-# This script calls run.sh when starting the underlying JBossAS server.
# =============================================================================
# ----------------------------------------------------------------------
@@ -88,11 +45,6 @@
# RHQ_SERVER_DEBUG=true
# JAVA_HOME=/path/to/java/installation
# RHQ_SERVER_JAVA_EXE_FILE_PATH=/path/directly/to/java/executable
-# RHQ_SERVER_JAVA_OPTS=VM options
-# RHQ_SERVER_ADDITIONAL_JAVA_OPTS=additional VM options
-# RHQ_SERVER_CMDLINE_OPTS=run.sh options
-# RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS=additional run.sh options
-
# ----------------------------------------------------------------------
# Make sure we unset any lingering JBossAS environment variables that
# were set in the user's environment. This might happen if the user
commit ec5d610a0c9849073bba5547bd2464e0a7004796
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 26 12:34:23 2010 +0100
BZ 535601 - Optimize the generate password script
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 6c170b3..c515e4c 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
@@ -1,9 +1,213 @@
#!/bin/sh
-# the sleep is important to prevent a race condition when called from the installer
-sleep 2
+# chkconfig: 2345 92 26
+# description: Starts and stops the RHQ Server
+#
+# processname: java
-# We stand in $RHQ/bin when called from the installer
-cd ../jbossas/
+# =============================================================================
+# RHQ Server UNIX Startup Script
+#
+# This file is used to execute the RHQ Server on a UNIX platform as part of
+# the platform's bootup sequence or as a foreground console process.
+# Run this script without any command line options for the syntax help.
+#
+# This script is customizable by setting the following environment variables:
+#
+# Note that if this script is to be used as an init.d script, you must set
+# RHQ_SERVER_HOME so this script knows where to find the Server installation.
+#
+# RHQ_SERVER_DEBUG - If this is defined, the script will emit debug
+# messages. If this is not defined or set to "false"
+# debug messages are not emitted.
+#
+# RHQ_SERVER_HOME - Defines where the server's home install directory is.
+# If not defined, it will be assumed to be the parent
+# directory of the directory where this script lives.
+#
+# RHQ_SERVER_JAVA_HOME - The location of the JRE that the server will
+# use. This will be ignored if
+# RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
+# If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are
+# not set, the Server's embedded JRE will be used.
+#
+# RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
+# executable to use. If this is set,
+# RHQ_SERVER_JAVA_HOME is ignored.
+# If this is not set, then
+# $RHQ_SERVER_JAVA_HOME/bin/java
+# is used. If this and
+# RHQ_SERVER_JAVA_HOME are not set, the
+# Server's embedded JRE will be used.
+#
+# RHQ_SERVER_JAVA_OPTS - Java VM command line options to be
+# passed into the Server's VM. If this is not defined
+# this script will pass in a default set of options.
+# If this is set, it completely overrides the
+# Server's defaults. If you only want to add options
+# to the Server's defaults, then you will want to
+# use RHQ_SERVER_ADDITIONAL_JAVA_OPTS instead.
+#
+# RHQ_SERVER_ADDITIONAL_JAVA_OPTS - additional Java VM command line options
+# to be passed into the Server's VM. This
+# is added to RHQ_SERVER_JAVA_OPTS; it
+# is mainly used to augment the Server's
+# default set of options. This can be
+# left unset if it is not needed.
+#
+# RHQ_SERVER_CMDLINE_OPTS - If this is defined, these are the command line
+# arguments that will be passed to the RHQ Server
+# JBossAS run.sh. If you only want to add options
+# to the Server's defaults, then you will want to
+# use RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS instead.
+#
+# RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS - additional command line arguments to
+# be passed to the RHQ Server JBossAS
+# run.sh. This is added to
+# RHQ_SERVER_CMDLINE_OPTS; it is mainly
+# used to augment the Server's default
+# set of options. This can be left unset
+# if it is not needed.
+#
+# RHQ_SERVER_PIDFILE_DIR - a full path to a writable directory where this
+# script can write its pidfile to.
+# If not defined, this defaults to the Server's
+# bin directory.
+#
+# If the embedded JRE is to be used but is not available, the fallback
+# JRE to be used will be determined by the JAVA_HOME environment variable.
+#
+# This script calls run.sh when starting the underlying JBossAS server.
+# =============================================================================
-java -cp lib/jboss-common.jar:lib/jboss-jmx.jar:server/default/lib/jbosssx.jar:server/default/lib/jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule $*
+# ----------------------------------------------------------------------
+# Environment variables you can set to customize the launch of the RHQ Server.
+# ----------------------------------------------------------------------
+
+# RHQ_SERVER_HOME=/path/to/server/home
+# RHQ_SERVER_DEBUG=true
+# JAVA_HOME=/path/to/java/installation
+# RHQ_SERVER_JAVA_EXE_FILE_PATH=/path/directly/to/java/executable
+# RHQ_SERVER_JAVA_OPTS=VM options
+# RHQ_SERVER_ADDITIONAL_JAVA_OPTS=additional VM options
+# RHQ_SERVER_CMDLINE_OPTS=run.sh options
+# RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS=additional run.sh options
+
+# ----------------------------------------------------------------------
+# Make sure we unset any lingering JBossAS environment variables that
+# were set in the user's environment. This might happen if the user
+# has an external JBossAS configured.
+# ----------------------------------------------------------------------
+
+unset JBOSS_HOME
+unset RUN_CONF
+unset JAVAC_JAR
+unset JBOSS_CLASSPATH
+
+# ----------------------------------------------------------------------
+# Dumps a message iff debug mode is enabled
+# ----------------------------------------------------------------------
+
+debug_msg ()
+{
+ # if debug variable is set, it is assumed to be on, unless its value is false
+ if [ "x$RHQ_SERVER_DEBUG" != "x" ]; then
+ if [ "$RHQ_SERVER_DEBUG" != "false" ]; then
+ echo $1
+ fi
+ fi
+}
+
+
+# ----------------------------------------------------------------------
+# Determine what specific platform we are running on.
+# Set some platform-specific variables.
+# ----------------------------------------------------------------------
+
+case "`uname`" in
+ CYGWIN*) _CYGWIN=true
+ ;;
+ Darwin*) _DARWIN=true
+ ;;
+ SunOS*) _SOLARIS=true
+ ;;
+ AIX*) _AIX=true
+ ;;
+esac
+
+# ----------------------------------------------------------------------
+# Determine the RHQ Server installation directory.
+# If RHQ_SERVER_HOME is not defined, we will assume we are running
+# directly from the server installation's bin directory.
+# ----------------------------------------------------------------------
+
+if [ -z "$RHQ_SERVER_HOME" ]; then
+ _DOLLARZERO=`readlink "$0" 2>/dev/null || echo "$0"`
+ RHQ_SERVER_HOME=`dirname "$_DOLLARZERO"`/..
+else
+ if [ ! -d "$RHQ_SERVER_HOME" ]; then
+ echo "ERROR! RHQ_SERVER_HOME is not pointing to a valid directory"
+ echo "RHQ_SERVER_HOME: $RHQ_SERVER_HOME"
+ exit 1
+ fi
+fi
+
+cd "$RHQ_SERVER_HOME"
+RHQ_SERVER_HOME=`pwd`
+
+debug_msg "RHQ_SERVER_HOME: $RHQ_SERVER_HOME"
+
+if [ ! -f "${RHQ_SERVER_HOME}/jbossas/bin/run.jar" ]; then
+ echo "ERROR! RHQ_SERVER_HOME is not pointing to a valid RHQ Server"
+ echo "Missing ${RHQ_SERVER_HOME}/jbossas/bin/run.jar"
+ exit 1
+fi
+
+# ----------------------------------------------------------------------
+# if we are on a Mac and JAVA_HOME is not set, then set it to /usr
+# as this is the default location.
+# ----------------------------------------------------------------------
+if [ -z "$JAVA_HOME" ]; then
+ if [ -n "$_DARWIN" ]; then
+ debug_msg "Running on Mac OS X, setting JAVA_HOME to /usr"
+ JAVA_HOME=/usr
+ fi
+fi
+
+
+# ----------------------------------------------------------------------
+# Find the Java executable and verify we have a VM available
+# ----------------------------------------------------------------------
+
+if [ -z "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then
+ if [ -z "$RHQ_SERVER_JAVA_HOME" ]; then
+ RHQ_SERVER_JAVA_HOME="${RHQ_SERVER_HOME}/jre"
+ debug_msg "Using the embedded JRE"
+ if [ ! -d "$RHQ_SERVER_JAVA_HOME" ]; then
+ debug_msg "No embedded JRE found - will try to use JAVA_HOME: $JAVA_HOME"
+ RHQ_SERVER_JAVA_HOME="$JAVA_HOME"
+ fi
+ fi
+ debug_msg "RHQ_SERVER_JAVA_HOME: $RHQ_SERVER_JAVA_HOME"
+ RHQ_SERVER_JAVA_EXE_FILE_PATH="${RHQ_SERVER_JAVA_HOME}/bin/java"
+fi
+debug_msg "RHQ_SERVER_JAVA_EXE_FILE_PATH: $RHQ_SERVER_JAVA_EXE_FILE_PATH"
+
+if [ ! -f "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then
+ echo "There is no JVM available."
+ echo "Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately."
+ exit 1
+fi
+
+# run.sh will use JAVA as the full java command
+JAVA="$RHQ_SERVER_JAVA_EXE_FILE_PATH"
+export JAVA
+
+if [ $# == 0 ]
+then
+ echo "Usage generate-db-password <password>"
+ exit 1
+fi
+
+_JB_DIR=${RHQ_SERVER_HOME}/jbossas
+$JAVA -cp $_JB_DIR/lib/jboss-common.jar:$_JB_DIR/lib/jboss-jmx.jar:$_JB_DIR/server/default/lib/jbosssx.jar:$_JB_DIR/server/default/lib/jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule $*
commit 1cda39acf128b40df403e212469c8f683875d11e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 26 12:15:11 2010 +0100
BZ 535601 - encrypt the db password by default when installing the server.
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 6c9121b..b500fb1 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -25,7 +25,7 @@
<war.dir>${basedir}/target/${final.name}</war.dir>
<!-- plugin versions -->
- <jetty-jspc-maven-plugin.version>7.0.1.v20091125</jetty-jspc-maven-plugin.version>
+ <jetty-jspc-maven-plugin.version>7.0.1.v20091125</jetty-jspc-maven-plugin.version>
<product.shortName>RHQ</product.shortName>
<product.name>RHQ</product.name>
@@ -90,6 +90,21 @@
</dependency>
<dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbosssx</artifactId>
+ <version>4.2.3.GA</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>jboss.jbossas.core-libs</groupId>
+ <artifactId>jboss-jca</artifactId>
+ <version>4.2.2.GA</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
index bca6381..3b47e95 100644
--- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
+++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java
@@ -18,6 +18,12 @@
*/
package org.rhq.enterprise.installer;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.sql.Connection;
import java.sql.Statement;
@@ -36,14 +42,16 @@ import mazz.i18n.Msg;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.resource.security.SecureIdentityLoginModule;
+
import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.installer.i18n.InstallerI18NResourceKeys;
/**
- * Responisible for taking the settings the user selects in the installer window and saves them
+ * Responsible for taking the settings the user selects in the installer window and saves them
* as the server's initial configuration.
- *
+ *
* @author John Mazzitelli
* @author Jay Shaughnessy
*/
@@ -195,7 +203,7 @@ public class ConfigurationBean {
* so the caller will not see any of the hidden properties in the returned list.
*
* @return current server settings, minus database related settings and hidden settings.
- *
+ *
* @see #getDatabaseConfiguration()
* @see #getConfiguration()
*/
@@ -218,7 +226,7 @@ public class ConfigurationBean {
* Loads in the server's current configuration and returns only the database related properties.
*
* @return current database settings
- *
+ *
* @see #getNonDatabaseConfiguration()
* @see #getConfiguration()
*/
@@ -240,7 +248,7 @@ public class ConfigurationBean {
* Checks to see if the server has been preconfigured and should be auto-installed. If <code>true</code>
* is returned, the installer webapp should not be needed to install the server and the installer should
* immediately begin the installation process.
- *
+ *
* @return <code>true</code> if auto-install should occur; <code>false</code> means the user needs to use
* the installer GUI before the installation can begin
*/
@@ -475,7 +483,7 @@ public class ConfigurationBean {
path = path.replace('\\', '/'); // in case we are on windows, we still want forward slashes
return path;
} catch (Exception e) {
- throw new RuntimeException(e); // this should never happen unless the file system is out of wack
+ throw new RuntimeException(e); // this should never happen unless the file system is out of wack
}
}
@@ -722,6 +730,17 @@ public class ConfigurationBean {
// Ensure the install server info is up to date and stored in the DB
serverInfo.storeServer(configurationAsProperties, haServer);
+ // encode database password and set updated properties
+ String pass = configurationAsProperties.getProperty(ServerProperties.PROP_DATABASE_PASSWORD);
+ pass = encryptPassword(pass);
+ configurationAsProperties.setProperty(ServerProperties.PROP_DATABASE_PASSWORD,pass);
+
+ serverInfo.setServerProperties(configurationAsProperties);
+
+ // We have changed the password of the database connection, so we need to
+ // tell the login config about it
+ serverInfo.restartLoginConfig();
+
// build a keystore whose cert has a CN of this server's public endpoint address
serverInfo.createKeystore(haServer);
@@ -739,6 +758,29 @@ public class ConfigurationBean {
return StartPageResults.SUCCESS;
}
+ private String encryptPassword(String password) throws Exception {
+
+ // We need to do some mumbo jumbo, as the interesting method is private
+ // in SecureIdentityLoginModule
+
+ try {
+ SecureIdentityLoginModule lm = new SecureIdentityLoginModule();
+ Class clazz = SecureIdentityLoginModule.class;
+ Method m = clazz.getDeclaredMethod("encode",String.class);
+ m.setAccessible(true);
+ String res = (String) m.invoke(lm,"rhqadmin");
+ return res;
+ } catch (Exception e) {
+ throw new Exception("Encoding db password failed: " , e);
+ }
+ }
+
+ private boolean isWindows() {
+ String osName = System.getProperty("os.name").toLowerCase(Locale.US);
+
+ return osName.indexOf("windows") > -1;
+ }
+
private Properties getConfigurationAsProperties(List<PropertyItemWithValue> config) {
Properties props = new Properties();
@@ -839,7 +881,7 @@ public class ConfigurationBean {
this.haServerName = serverName;
- // try pulling info from the database for this server name
+ // try pulling info from the database for this server name
if (isRegisteredServers()) {
Properties configurationAsProperties = getConfigurationAsProperties(configuration);
setHaServer(serverInfo.getServerDetail(configurationAsProperties, serverName));
@@ -881,10 +923,10 @@ public class ConfigurationBean {
/**
* This method will set the HA Server information based solely on the server configuration
* properties. It does not rely on any database access.
- *
+ *
* This is used by the auto-installation process - see {@link AutoInstallServlet}.
*
- * @throws Exception
+ * @throws Exception
*/
public void setHaServerFromPropertiesOnly() throws Exception {
diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java
index 0896ace..5af10d0 100644
--- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java
+++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java
@@ -49,6 +49,8 @@ import org.apache.tools.ant.helper.ProjectHelper2;
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.security.auth.login.XMLLoginConfig;
+import org.jboss.security.auth.login.XMLLoginConfigMBean;
import org.jboss.system.server.ServerConfig;
import org.rhq.core.db.DatabaseType;
@@ -128,7 +130,7 @@ public class ServerInformation {
/**
* Call this when you need to confirm that the database is supported.
- *
+ *
* @param props set of properties where the connection information is found
*
* @throws Exception if the database is not supported
@@ -208,7 +210,7 @@ public class ServerInformation {
* data/tables and recreated.</p>
*
* @param props
- *
+ *
* @throws Exception if failed to create the new schema for some reason
*/
public void createNewDatabaseSchema(Properties props) throws Exception {
@@ -246,7 +248,7 @@ public class ServerInformation {
* occur.</p>
*
* @param props
- *
+ *
* @throws Exception if the upgrade failed for some reason
*/
public void upgradeExistingDatabaseSchema(Properties props) throws Exception {
@@ -527,7 +529,7 @@ public class ServerInformation {
return deployDirectory;
}
- private File getBinDirectory() {
+ protected File getBinDirectory() {
if (binDirectory == null) {
MBeanServer mbs = getMBeanServer();
ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
@@ -788,8 +790,8 @@ public class ServerInformation {
* Clean up messages in the JMS message table. Make sure you call this when no other Servers
* are communicating with the database, otherwise, its possible in-flight messages will get lost
* or go into a bad state.
- *
- * @param props
+ *
+ * @param props
*/
public void cleanJmsTables(Properties props) {
@@ -818,6 +820,17 @@ public class ServerInformation {
}
}
+ public void restartLoginConfig() throws Exception {
+
+ MBeanServer mbs = getMBeanServer();
+ ObjectName name = ObjectNameFactory.create("jboss.security:service=XMLLoginConfig");
+ Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name,XMLLoginConfigMBean.class,false);
+
+ XMLLoginConfigMBean conf = (XMLLoginConfigMBean) mbean;
+ conf.stop();
+ conf.start();
+ }
+
public static class Server {
public static final String DEFAULT_AFFINITY_GROUP = "";
public static final int DEFAULT_ENDPOINT_PORT = 7080;
diff --git a/modules/enterprise/server/container-lib/pom.xml b/modules/enterprise/server/container-lib/pom.xml
index cd58ba5..2c98817 100644
--- a/modules/enterprise/server/container-lib/pom.xml
+++ b/modules/enterprise/server/container-lib/pom.xml
@@ -40,6 +40,13 @@
<scope>provided</scope> <!-- by JBossAS -->
</dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbosssx</artifactId>
+ <version>4.2.3.GA</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
</dependencies>
<profiles>
diff --git a/modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java b/modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java
index 72083b5..3c87183 100644
--- a/modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java
+++ b/modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java
@@ -23,11 +23,22 @@ import java.beans.PropertyEditorManager;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.Method;
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Properties;
-
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.SecretKeySpec;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
@@ -42,12 +53,14 @@ import javax.transaction.xa.XAResource;
import com.arjuna.ats.jta.recovery.XAResourceRecovery;
import org.jboss.logging.Logger;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
/**
* This is an enhanced version of JBossTM's AppServerJDBCXARecovery implementation.
* The only thing this implementation does differently is it becomes tolerant of
* the times when the data source is not yet deployed.
- *
+ *
* This provides recovery for compliant JDBC drivers accessed via datasources deployed in JBossAS 4.2
* It is not meant to be db driver specific.
*
@@ -100,6 +113,8 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery {
if (parameter == null)
return false;
+ retrieveData(parameter, _DELIMITER);
+
// don't create the datasource yet, we'll do it lazily. Just keep its id.
_dataSourceId = parameter;
@@ -150,6 +165,13 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery {
MBeanServerConnection server = (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor");
ObjectName objectName = new ObjectName("jboss.jca:name=" + _dataSourceId
+ ",service=ManagedConnectionFactory");
+
+ if(_username !=null && _password !=null)
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal(_username));
+ SecurityAssociation.setCredential(_password);
+ }
+
String className = (String) server.invoke(objectName, "getManagedConnectionFactoryAttribute",
new Object[] { "XADataSourceClass" }, new String[] { "java.lang.String" });
log.debug("AppServerJDBCXARecovery datasource classname = " + className);
@@ -158,6 +180,29 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery {
// debug disabled due to security paranoia - it may log datasource password in cleartext.
// log.debug("AppServerJDBCXARecovery.result="+properties);
+ ObjectName txCmObjectName = new ObjectName("jboss.jca:name=" +_dataSourceId + ",service=XATxCM");
+ String securityDomainName = (String) server.getAttribute(txCmObjectName, "SecurityDomainJndiName");
+ log.debug("Security domain name associated with JCA ConnectionManager jboss.jca:name=" +_dataSourceId + ",service=XATxCM"+" is:"+securityDomainName);
+
+ if(securityDomainName != null && !securityDomainName.equals(""))
+ {
+ ObjectName _objectName = new ObjectName("jboss.security:service=XMLLoginConfig");
+ String config = (String)server.invoke(_objectName, "displayAppConfig", new Object[] {securityDomainName}, new String[] {"java.lang.String"});
+ String loginModuleClass = getValueForLoginModuleClass(config);
+ _dbUsername = getValueForKey(config, _USERNAME);
+ String _encryptedPassword = getValueForKey(config, _PASSWORD);
+ if (loginModuleClass.trim().equals("org.jboss.resource.security.SecureIdentityLoginModule"))
+ {
+ _dbPassword = new String (decode(_encryptedPassword));
+ }
+ else if (loginModuleClass.trim().equals("org.jboss.resource.security.JaasSecurityDomainIdentityLoginModule"))
+ {
+ String jaasSecurityDomain = getValueForKey(config, "jaasSecurityDomain");
+ _dbPassword = new String (decodePBE(server, _encryptedPassword, jaasSecurityDomain));
+ }
+ _encrypted = true;
+ }
+
try {
_dataSource = getXADataSource(className, properties);
_supportsIsValidMethod = true; // assume it does; we'll lazily check the first time we try to connect
@@ -230,7 +275,15 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery {
}
}
- _connection = _dataSource.getXAConnection();
+ // Check if the password is encrypted, the criteria should be the existence of <security-domain>EncryptDBPassword</security-domain>
+ // in the -ds.xml file.
+
+ if(!_encrypted) {
+ _connection = _dataSource.getXAConnection();
+ }
+ else {
+ _connection = _dataSource.getXAConnection(_dbUsername, _dbPassword);
+ }
_connection.addConnectionEventListener(_connectionEventListener);
log.debug("Created new XAConnection");
}
@@ -305,13 +358,98 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery {
return xads;
}
+ public void retrieveData(String parameter,String delimiter)
+ {
+ StringTokenizer st = new StringTokenizer(parameter,delimiter);
+ while (st.hasMoreTokens())
+ {
+ String data = st.nextToken();
+ if(data.length()>9)
+ {
+ if(_USERNAME.equalsIgnoreCase(data.substring(0,8)))
+ {
+ _username =data.substring(9);
+ }
+ if(_PASSWORD.equalsIgnoreCase(data.substring(0,8)))
+ {
+ _password =data.substring(9);
+ }
+ if(_JNDINAME.equalsIgnoreCase(data.substring(0,8)))
+ {
+ _dataSourceId=data.substring(9);
+ }
+ }
+ }
+
+ if(_dataSourceId == null && parameter != null && parameter.indexOf('=') == -1) {
+ // try to fallback to old parameter format where only the dataSourceId is given, without jndiname= prefix
+ _dataSourceId = parameter;
+ }
+ }
+
+ private String getValueForKey(String config, String key)
+ {
+ Pattern usernamePattern = Pattern.compile("(name=" + key + ", value=)(.*)(</li>)");
+ Matcher m = usernamePattern.matcher(config);
+ if(m.find())
+ {
+ return m.group(2);
+ }
+ return "";
+ }
+
+ private String getValueForLoginModuleClass(String config)
+ {
+ Pattern usernamePattern = Pattern.compile("(" + _MODULE + ":)(.*)");
+ Matcher m = usernamePattern.matcher(config);
+ if(m.find())
+ {
+ return m.group(2);
+ }
+ return "";
+ }
+
+ private static String decode(String secret) throws NoSuchPaddingException, NoSuchAlgorithmException,
+ InvalidKeyException, BadPaddingException, IllegalBlockSizeException
+ {
+ byte[] kbytes = "jaas is the way".getBytes();
+ SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish");
+
+ BigInteger n = new BigInteger(secret, 16);
+ byte[] encoding = n.toByteArray();
+
+ Cipher cipher = Cipher.getInstance("Blowfish");
+ cipher.init(Cipher.DECRYPT_MODE, key);
+ byte[] decode = cipher.doFinal(encoding);
+ return new String(decode);
+ }
+
+ private static String decodePBE(MBeanServerConnection server, String password, String jaasSecurityDomain) throws Exception
+ {
+ byte[] secret = (byte[]) server.invoke(new ObjectName(jaasSecurityDomain), "decode64", new Object[] {password}, new String[] {"java.lang.String"});
+ return new String(secret, "UTF-8");
+ }
+
+
private boolean _supportsIsValidMethod;
private XAConnection _connection;
private XADataSource _dataSource;
private LocalConnectionEventListener _connectionEventListener;
private boolean _hasMoreResources;
+ private boolean _encrypted;
private String _dataSourceId;
+ private String _username;
+ private String _password;
+ private String _dbUsername;
+ private String _dbPassword;
+
+ private final String _JNDINAME = "jndiname";
+ private final String _USERNAME = "username";
+ private final String _PASSWORD = "password";
+ private final String _MODULE = "LoginModule Class";
+ private final String _DELIMITER = ",";
+
private Logger log = org.jboss.logging.Logger.getLogger(AppServerJDBCXARecovery.class);
}
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
new file mode 100755
index 0000000..6c170b3
--- /dev/null
+++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# the sleep is important to prevent a race condition when called from the installer
+sleep 2
+
+# We stand in $RHQ/bin when called from the installer
+cd ../jbossas/
+
+java -cp lib/jboss-common.jar:lib/jboss-jmx.jar:server/default/lib/jbosssx.jar:server/default/lib/jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule $*
diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml
index 256d419..8f6ca6d 100644
--- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml
+++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml
@@ -14,6 +14,28 @@
</authentication>
</application-policy>
+<!-- security domains for encrypted dataseouce passwords -->
+ <application-policy name = "XADSRealm">
+ <authentication>
+ <login-module code = "org.jboss.resource.security.SecureIdentityLoginModule"
+ flag = "required">
+ <module-option name = "username">${rhq.server.database.user-name}</module-option>
+ <module-option name = "password">${rhq.server.database.password}</module-option>
+ <module-option name = "managedConnectionFactoryName">jboss.jca:service=XATxCM,name=RHQDS</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+ <application-policy name = "NONXADSRealm">
+ <authentication>
+ <login-module code = "org.jboss.resource.security.SecureIdentityLoginModule"
+ flag = "required">
+ <module-option name = "username">${rhq.server.database.user-name}</module-option>
+ <module-option name = "password">${rhq.server.database.password}</module-option>
+ <module-option name = "managedConnectionFactoryName">jboss.jca:service=NoTxCM,name=NoTxRHQDS</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
<!-- Security domain for JBossMQ -->
<application-policy name = "jbossmq">
<authentication>
diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej
index e6f18ac..612e0c1 100644
--- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej
+++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej
@@ -7,16 +7,14 @@
<xa-datasource>
<jndi-name>RHQDS</jndi-name>
<xa-datasource-class>${rhq.server.database.xa-datasource-class}</xa-datasource-class>
- <xa-datasource-property name="User">${rhq.server.database.user-name}</xa-datasource-property>
- <xa-datasource-property name="Password">${rhq.server.database.password}</xa-datasource-property>
<xa-datasource-property name="URL">${rhq.server.database.connection-url}</xa-datasource-property>
<no-tx-separate-pools/>
<track-connection-by-tx/>
<isSameRM-override-value>false</isSameRM-override-value>
+
+ <security-domain>XADSRealm</security-domain>
- <user-name>${rhq.server.database.user-name}</user-name>
- <password>${rhq.server.database.password}</password>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
@@ -31,8 +29,7 @@
<jndi-name>NoTxRHQDS</jndi-name>
<connection-url>${rhq.server.database.connection-url}</connection-url>
<driver-class>${rhq.server.database.driver-class}</driver-class>
- <user-name>${rhq.server.database.user-name}</user-name>
- <password>${rhq.server.database.password}</password>
+ <security-domain>NONXADSRealm</security-domain>
<connection-property name="char.encoding">UTF-8</connection-property>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<min-pool-size>2</min-pool-size>
diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej
index 2197386..5559b83 100644
--- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej
+++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej
@@ -7,8 +7,6 @@
<xa-datasource>
<jndi-name>RHQDS</jndi-name>
<xa-datasource-class>${rhq.server.database.xa-datasource-class}</xa-datasource-class>
- <xa-datasource-property name="User">${rhq.server.database.user-name}</xa-datasource-property>
- <xa-datasource-property name="Password">${rhq.server.database.password}</xa-datasource-property>
<xa-datasource-property name="URL">${rhq.server.database.connection-url}</xa-datasource-property>
<xa-datasource-property name="ConnectionProperties">SetBigStringTryClob=true</xa-datasource-property>
@@ -18,10 +16,10 @@
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
-
<track-connection-by-tx/>
- <user-name>${rhq.server.database.user-name}</user-name>
- <password>${rhq.server.database.password}</password>
+
+ <security-domain>XADSRealm</security-domain>
+
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
@@ -43,8 +41,9 @@
<jndi-name>NoTxRHQDS</jndi-name>
<connection-url>${rhq.server.database.connection-url}</connection-url>
<driver-class>${rhq.server.database.driver-class}</driver-class>
- <user-name>${rhq.server.database.user-name}</user-name>
- <password>${rhq.server.database.password}</password>
+
+ <security-domain>NONXADSRealm</security-domain>
+
<connection-property name="char.encoding">UTF-8</connection-property>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<min-pool-size>2</min-pool-size>
diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej
index 242bfce..2a71733 100644
--- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej
+++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej
@@ -7,15 +7,13 @@
<xa-datasource>
<jndi-name>RHQDS</jndi-name>
<xa-datasource-class>${rhq.server.database.xa-datasource-class}</xa-datasource-class>
- <xa-datasource-property name="User">${rhq.server.database.user-name}</xa-datasource-property>
- <xa-datasource-property name="Password">${rhq.server.database.password}</xa-datasource-property>
<xa-datasource-property name="ServerName">${rhq.server.database.server-name}</xa-datasource-property>
<xa-datasource-property name="PortNumber">${rhq.server.database.port}</xa-datasource-property>
<xa-datasource-property name="DatabaseName">${rhq.server.database.db-name}</xa-datasource-property>
+
+ <security-domain>XADSRealm</security-domain>
<track-connection-by-tx/>
- <user-name>${rhq.server.database.user-name}</user-name>
- <password>${rhq.server.database.password}</password>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
@@ -30,8 +28,7 @@
<jndi-name>NoTxRHQDS</jndi-name>
<connection-url>${rhq.server.database.connection-url}</connection-url>
<driver-class>${rhq.server.database.driver-class}</driver-class>
- <user-name>${rhq.server.database.user-name}</user-name>
- <password>${rhq.server.database.password}</password>
+ <security-domain>NONXADSRealm</security-domain>
<connection-property name="char.encoding">UTF-8</connection-property>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<min-pool-size>2</min-pool-size>
diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej
index 61ccc08..c79418f 100644
--- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej
+++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej
@@ -7,8 +7,6 @@
<xa-datasource>
<jndi-name>RHQDS</jndi-name>
<xa-datasource-class>${rhq.server.database.xa-datasource-class}</xa-datasource-class>
- <xa-datasource-property name="User">${rhq.server.database.user-name}</xa-datasource-property>
- <xa-datasource-property name="Password">${rhq.server.database.password}</xa-datasource-property>
<xa-datasource-property name="ServerName">${rhq.server.database.server-name}</xa-datasource-property>
<xa-datasource-property name="PortNumber">${rhq.server.database.port}</xa-datasource-property>
<xa-datasource-property name="DatabaseName">${rhq.server.database.db-name}</xa-datasource-property>
@@ -24,9 +22,7 @@
<xa-datasource-property name="XaEmulation">true</xa-datasource-property>
-->
-
- <user-name>${rhq.server.database.user-name}</user-name>
- <password>${rhq.server.database.password}</password>
+ <security-domain>XADSRealm</security-domain>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
@@ -43,8 +39,7 @@
<jndi-name>NoTxRHQDS</jndi-name>
<connection-url>${rhq.server.database.connection-url}</connection-url>
<driver-class>${rhq.server.database.driver-class}</driver-class>
- <user-name>${rhq.server.database.user-name}</user-name>
- <password>${rhq.server.database.password}</password>
+ <security-domain>NONXADSRealm</security-domain>
<track-connection-by-tx></track-connection-by-tx>
14 years, 1 month
[rhq] Branch 'gwt' - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java | 110 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java | 110 +++++++---
2 files changed, 150 insertions(+), 70 deletions(-)
New commits:
commit 7afbfa9b13b12e4d362c918571a35f88c118b9d9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 26 03:43:20 2010 -0400
bundle file upload step in wizard works and looks nicer now
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java
index 793cd5a..e241771 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java
@@ -18,21 +18,22 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.create;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.events.FormSubmitFailedEvent;
import com.smartgwt.client.widgets.form.events.FormSubmitFailedHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.components.upload.BundleFileUploadForm;
import org.rhq.enterprise.gui.coregui.client.components.upload.DynamicFormHandler;
import org.rhq.enterprise.gui.coregui.client.components.upload.DynamicFormSubmitCompleteEvent;
@@ -45,25 +46,24 @@ public class BundleUploadDataStep implements WizardStep {
private final AbstractBundleCreateWizard wizard;
private final BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService();
- private DynamicForm form;
+ private ArrayList<BundleFileUploadForm> uploadForms;
public BundleUploadDataStep(AbstractBundleCreateWizard bundleCreationWizard) {
this.wizard = bundleCreationWizard;
}
public Canvas getCanvas() {
- form = new DynamicForm();
-
- final VLayout layout = new VLayout();
- layout.setMargin(Integer.valueOf(20));
- layout.setAlign(Alignment.CENTER);
+ final VLayout mainLayout = new VLayout();
+ mainLayout.setMargin(Integer.valueOf(20));
+ mainLayout.setWidth100();
+ mainLayout.setHeight(10);
bundleServer.getAllBundleVersionFilenames(this.wizard.getBundleVersion().getId(),
new AsyncCallback<HashMap<String, Boolean>>() {
public void onSuccess(HashMap<String, Boolean> result) {
wizard.setAllBundleFilesStatus(result);
- prepareForm(layout);
+ prepareForm(mainLayout);
}
public void onFailure(Throwable caught) {
@@ -72,8 +72,7 @@ public class BundleUploadDataStep implements WizardStep {
}
});
- form.addChild(layout);
- return form;
+ return mainLayout;
}
public boolean nextPage() {
@@ -88,61 +87,82 @@ public class BundleUploadDataStep implements WizardStep {
if (wizard.getAllBundleFilesStatus() == null) {
return false;
}
+
+ boolean needToUpload = false;
+ for (BundleFileUploadForm uploadForm : this.uploadForms) {
+ if (uploadForm.getUploadResults() == null) {
+ uploadForm.submitForm();
+ needToUpload = true;
+ }
+ }
+ if (needToUpload) {
+ return false;
+ }
+
if (wizard.getAllBundleFilesStatus().containsValue(Boolean.FALSE)) {
return false;
}
return true;
}
- private void prepareForm(VLayout layout) {
+ private void prepareForm(VLayout mainLayout) {
// if there are no files to upload, immediately skip this step
final HashMap<String, Boolean> allFilesStatus = wizard.getAllBundleFilesStatus();
if (allFilesStatus != null && allFilesStatus.size() == 0) {
- // TODO: do something to tell the user they don't have to do anything for this step
+ HeaderLabel label = new HeaderLabel("No files need to be uploaded for this bundle");
+ label.setWidth100();
+ mainLayout.addMember(label);
+ uploadForms = null;
return;
}
- for (Map.Entry<String, Boolean> entry : allFilesStatus.entrySet()) {
- HLayout formLayout = new HLayout();
- layout.addMember(formLayout);
+ uploadForms = new ArrayList<BundleFileUploadForm>();
+ for (Map.Entry<String, Boolean> entry : allFilesStatus.entrySet()) {
String fileToBeUploaded = entry.getKey();
Boolean isAlreadyUploaded = entry.getValue();
- if (isAlreadyUploaded) {
- Label nameLabel = new Label(fileToBeUploaded + ": ");
- formLayout.addMember(nameLabel);
- Img img = new Img("/images/icons/availability_green_16.png", 16, 16);
- formLayout.addMember(img);
- } else {
- final BundleFileUploadForm uploadForm = new BundleFileUploadForm(this.wizard.getBundleVersion(),
- fileToBeUploaded);
- uploadForm.addFormHandler(new DynamicFormHandler() {
- public void onSubmitComplete(DynamicFormSubmitCompleteEvent event) {
- String results = event.getResults();
- if (!results.contains("Failed to upload bundle file")) {
- uploadForm.retrievalStatus(true);
- allFilesStatus.put(uploadForm.getName(), Boolean.TRUE);
- } else {
- uploadForm.retrievalStatus(false);
- allFilesStatus.put(uploadForm.getName(), Boolean.FALSE);
- CoreGUI.getMessageCenter().notify(
- new Message("Failed to upload bundle file", results, Message.Severity.Error));
- }
- }
- });
- uploadForm.addFormSubmitFailedHandler(new FormSubmitFailedHandler() {
- public void onFormSubmitFailed(FormSubmitFailedEvent event) {
- uploadForm.retrievalStatus(false);
+ HLayout indivLayout = new HLayout();
+ indivLayout.setWidth100();
+ indivLayout.setAutoHeight();
+
+ Label nameLabel = new Label(fileToBeUploaded + ": ");
+ nameLabel.setWidth("*");
+ nameLabel.setAlign(Alignment.RIGHT);
+ nameLabel.setLayoutAlign(VerticalAlignment.CENTER);
+ indivLayout.addMember(nameLabel);
+
+ final BundleFileUploadForm uploadForm = new BundleFileUploadForm(this.wizard.getBundleVersion(),
+ fileToBeUploaded, false, (isAlreadyUploaded) ? Boolean.TRUE : null);
+ uploadForm.setWidth("75%");
+ indivLayout.addMember(uploadForm);
+
+ uploadForm.addFormHandler(new DynamicFormHandler() {
+ public void onSubmitComplete(DynamicFormSubmitCompleteEvent event) {
+ String results = event.getResults();
+ if (!results.contains("Failed to upload bundle file")) {
+ allFilesStatus.put(uploadForm.getName(), Boolean.TRUE);
+ } else {
allFilesStatus.put(uploadForm.getName(), Boolean.FALSE);
CoreGUI.getMessageCenter().notify(
- new Message("Failed to upload file", null, Message.Severity.Error));
+ new Message("Failed to upload bundle file", results, Message.Severity.Error));
}
- });
+ }
+ });
+ uploadForm.addFormSubmitFailedHandler(new FormSubmitFailedHandler() {
+ public void onFormSubmitFailed(FormSubmitFailedEvent event) {
+ allFilesStatus.put(uploadForm.getName(), Boolean.FALSE);
+ CoreGUI.getMessageCenter().notify(
+ new Message("Failed to upload file", null, Message.Severity.Error));
+ }
+ });
- formLayout.addMember(uploadForm);
- }
+ uploadForms.add(uploadForm);
+
+ mainLayout.addMember(indivLayout);
}
+
+ return;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
index a0c6add..6f18f04 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleFileUploadForm.java
@@ -20,9 +20,12 @@ package org.rhq.enterprise.gui.coregui.client.components.upload;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.types.Encoding;
+import com.smartgwt.client.widgets.form.events.FormSubmitFailedEvent;
+import com.smartgwt.client.widgets.form.events.FormSubmitFailedHandler;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.UploadItem;
import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
@@ -36,18 +39,25 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
public class BundleFileUploadForm extends DynamicCallbackForm {
- private ButtonItem uploadButton;
private UploadItem bundleUploadItem;
+ private ButtonItem uploadButton;
+ private StaticTextItem icon;
+
+ private Boolean uploadResults;
- private BundleVersion bundleVersion;
- private String name;
+ private final BundleVersion bundleVersion;
+ private final String name;
+ private final boolean showNameLabel;
+
+ public BundleFileUploadForm(BundleVersion bundleVersion, String name, boolean showNameLabel,
+ Boolean isAlreadyUploaded) {
- public BundleFileUploadForm(BundleVersion bundleVersion, String name) {
super(name);
this.bundleVersion = bundleVersion;
this.name = name;
+ this.showNameLabel = showNameLabel;
+ this.uploadResults = isAlreadyUploaded; // null if unknown, false if error during previous upload attempt, true if already uploaded before
- setNumCols(8);
setEncoding(Encoding.MULTIPART);
setAction(GWT.getModuleBaseURL() + "/BundleFileUploadServlet");
}
@@ -65,6 +75,23 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
return name;
}
+ /**
+ * Returns true if the file was successfully uploaded, false if an error occurred.
+ * Returns null if this upload form has not be submitted yet (see {@link #submitForm()}).
+ * @return status of the upload request
+ */
+ public Boolean getUploadResults() {
+ return uploadResults;
+ }
+
+ @Override
+ public void submitForm() {
+ icon.setShowIcons(true);
+ uploadButton.setDisabled(true);
+ markForRedraw();
+ super.submitForm();
+ }
+
@Override
protected void onDraw() {
super.onDraw();
@@ -81,58 +108,91 @@ public class BundleFileUploadForm extends DynamicCallbackForm {
HiddenItem versionField = new HiddenItem("version");
versionField.setValue("1.0");
- setNumCols(4);
+ setNumCols(7);
- bundleUploadItem = new UploadItem("bundleFile", name);
+ bundleUploadItem = new UploadItem("bundleFileUploadItem", name);
bundleUploadItem.setEndRow(false);
+ bundleUploadItem.setShowTitle(showNameLabel);
uploadButton = new ButtonItem("Upload");
uploadButton.setStartRow(false);
+ uploadButton.setEndRow(false);
uploadButton.setDisabled(true);
-
- bundleUploadItem.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent changeEvent) {
- uploadButton.setDisabled(false);
- }
- });
-
uploadButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- uploadButton.setShowIcons(true);
- markForRedraw();
submitForm();
}
});
+ icon = new StaticTextItem("icon");
+ icon.setStartRow(false);
+ icon.setShowTitle(false);
+
FormItemIcon loadingIcon = new FormItemIcon();
loadingIcon.setSrc("ajax-loader.gif");
loadingIcon.setWidth(16);
loadingIcon.setHeight(16);
- uploadButton.setIcons(loadingIcon);
- uploadButton.setShowIcons(false);
+ icon.setIcons(loadingIcon);
+ icon.setShowIcons(false);
+
+ bundleUploadItem.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent changeEvent) {
+ if (uploadResults != null) {
+ retrievalStatus(uploadResults.booleanValue());
+ } else {
+ uploadButton.setDisabled(false);
+ icon.setShowIcons(false);
+ }
+ }
+ });
+
+ if (uploadResults != null) {
+ retrievalStatus(uploadResults.booleanValue());
+ }
- setItems(sessionIdField, bundleVersionIdField, nameField, versionField, bundleUploadItem, uploadButton);
+ setItems(sessionIdField, bundleVersionIdField, nameField, versionField, bundleUploadItem, uploadButton, icon);
+
+ addFormHandler(new DynamicFormHandler() {
+ public void onSubmitComplete(DynamicFormSubmitCompleteEvent event) {
+ String results = event.getResults();
+ if (!results.contains("Failed to upload bundle file")) {
+ CoreGUI.getMessageCenter().notify(new Message("Uploaded bundle file successfully", Severity.Info));
+ retrievalStatus(true);
+ } else {
+ CoreGUI.getMessageCenter().notify(new Message("Bundle file upload failed", Severity.Error));
+ retrievalStatus(false);
+ }
+ }
+ });
+
+ addFormSubmitFailedHandler(new FormSubmitFailedHandler() {
+ public void onFormSubmitFailed(FormSubmitFailedEvent event) {
+ CoreGUI.getMessageCenter().notify(new Message("Bundle file upload failed", Severity.Error));
+ retrievalStatus(false);
+ }
+ });
}
/**
- * Call this when the file retrieval finished. <code>true</code> means successful,
+ * Call this when the last file retrieval status is known. <code>true</code> means successful,
* <code>false</code> means an error occurred.
* @param ok status
*/
- public void retrievalStatus(boolean ok) {
+ private void retrievalStatus(boolean ok) {
+ uploadResults = Boolean.valueOf(ok);
+
if (uploadButton != null) {
FormItemIcon loadedIcon = new FormItemIcon();
if (ok) {
loadedIcon.setSrc("/images/icons/availability_green_16.png");
- CoreGUI.getMessageCenter().notify(new Message("Uploaded bundle file successfully", Severity.Info));
} else {
loadedIcon.setSrc("/images/icons/availability_red_16.png");
- CoreGUI.getMessageCenter().notify(new Message("Bundle file upload failed", Severity.Error));
}
loadedIcon.setWidth(16);
loadedIcon.setHeight(16);
- uploadButton.setIcons(loadedIcon);
- uploadButton.setShowIcons(true);
+ icon.setIcons(loadedIcon);
+ icon.setShowIcons(true);
+ uploadButton.setDisabled(uploadResults);
}
}
}
14 years, 1 month
[rhq] 2 commits - modules/enterprise
by Joseph Marques
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java | 7 +
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java | 21 +++-
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java | 48 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java | 32 +++++-
5 files changed, 102 insertions(+), 9 deletions(-)
New commits:
commit 002b86ac0fc42f69e390a5f51ea104a7afbd8369
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Mar 26 03:13:34 2010 -0400
improve logging to capture some simple rules and thresholds to indicate performance issues
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java
index 17247dc..22aaccb 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java
@@ -62,10 +62,27 @@ public class FaceletRedirectionViewHandler extends FaceletViewHandler {
public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
long monitorId = HibernatePerformanceMonitor.get().start();
super.renderView(context, viewToRender);
- HibernatePerformanceMonitor.get().stop(monitorId, "URL " + viewToRender.getViewId());
+ HibernatePerformanceMonitor.get().stop(monitorId, "URL " + getURL(viewToRender));
}
- protected void handleRnderException(FacesContext context, Exception ex) throws IOException, ELException,
+ private String getURL(UIViewRoot viewToRender) {
+ StringBuilder results = new StringBuilder(viewToRender.getViewId());
+
+ boolean first = true;
+ for (Map.Entry<String, Object> urlParam : viewToRender.getAttributes().entrySet()) {
+ if (first) {
+ results.append('?');
+ } else {
+ results.append('&');
+ }
+ results.append(urlParam.getKey() + "=" + urlParam.getValue());
+ }
+
+ return results.toString();
+ }
+
+ @Override
+ protected void handleRenderException(FacesContext context, Exception ex) throws IOException, ELException,
FacesException {
try {
if (context.getViewRoot().getViewId().equals("/rhq/common/error.xhtml")) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java
index 8b6c03c..6299947 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java
@@ -13,6 +13,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
+import org.rhq.enterprise.server.util.HibernatePerformanceMonitor;
public class WebUserTrackingFilter extends BaseFilter {
@@ -23,6 +24,8 @@ public class WebUserTrackingFilter extends BaseFilter {
ServletException {
HttpServletRequest request = (HttpServletRequest) req;
+ HibernatePerformanceMonitor.get().zeroStats();
+
// only record GET requests, resubmitting to POST pages is dangerous
String method = request.getMethod();
if (method.equals("GET")) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java
index 1215cb0..848a067 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java
@@ -18,14 +18,20 @@
*/
package org.rhq.enterprise.server.util;
+import java.lang.management.ManagementFactory;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
+import javax.management.MBeanServer;
import javax.persistence.EntityManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.stat.QueryStatistics;
+import org.hibernate.stat.Statistics;
+
+import org.rhq.core.domain.util.PersistenceUtility;
/**
* @author Joseph Marques
@@ -45,6 +51,15 @@ public class HibernatePerformanceMonitor {
return singleton;
}
+ public void zeroStats() {
+ if (log.isDebugEnabled()) {
+ EntityManager entityManager = LookupUtil.getEntityManager();
+ MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ Statistics stats = PersistenceUtility.getStatisticsService(entityManager, platformMBeanServer);
+ stats.clear();
+ }
+ }
+
public long start() {
if (log.isDebugEnabled()) {
EntityManager entityManager = LookupUtil.getEntityManager();
@@ -61,11 +76,38 @@ public class HibernatePerformanceMonitor {
if (log.isDebugEnabled()) {
HibernateStatisticsStopWatch watch = watches.remove(id);
if (watch == null) {
- // could happen if debugging was turned on and the start() call was already skipped
- return;
+ return; // could happen if debugging was turned on and the start() call was already skipped
}
watch.stop();
- log.debug(watch.toString() + (logPrefix == null ? "(unknown)" : " for " + logPrefix + " "));
+
+ String cause = "";
+ if (watch.getQueryExecutions() != 0) {
+ if ((watch.getConnects() / (double) (watch.getEntityLoads() + watch.getQueryExecutions())) >= 5.0) {
+ cause = "(N+1 issue?) ";// might indicate need for LEFT JOIN FETCHes
+ }
+ if ((watch.getTransations() / (double) watch.getQueryExecutions()) >= 5.0) {
+ cause = "(xaction nesting?) "; // might indicate excessive @REQUIRES_NEW
+ } else if (watch.getTransations() > 10) {
+ cause = "(too many xactions?";
+ }
+ }
+ if (watch.getTime() > 3000) {
+ cause = "(slowness?) "; // might indicate inefficient query or table contention
+ }
+
+ String callingContext = " for " + (logPrefix == null ? "(unknown)" : logPrefix);
+ log.debug(watch.toString() + cause + callingContext);
+
+ if (logPrefix.contains("URL")) {
+ String[] queries = watch.getStats().getQueries();
+ for (int i = 0; i < queries.length; i++) {
+ String query = queries[i];
+ QueryStatistics queryStats = watch.getStats().getQueryStatistics(query);
+ log.debug("queryString[" + i + "]=" + queries[i]);
+ log.debug("queryStats[" + i + "=" + queryStats);
+ }
+ //watch.getStats().logSummary();
+ }
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java
index 5ca8470..7eb62da 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java
@@ -34,10 +34,10 @@ public class HibernateStatisticsStopWatch {
private Statistics stats;
- long queryExecutions;
- long transations;
- long entityLoads;
- long connects;
+ long queryExecutions; // Get global number of executed queries
+ long transations; // The number of transactions we know to have completed
+ long entityLoads; // Get global number of entity loads
+ long connects; // Get the global number of connections asked by the sessions
long time;
public HibernateStatisticsStopWatch(EntityManager entityManager) {
@@ -61,6 +61,30 @@ public class HibernateStatisticsStopWatch {
time += System.currentTimeMillis();
}
+ public Statistics getStats() {
+ return stats;
+ }
+
+ public long getQueryExecutions() {
+ return queryExecutions;
+ }
+
+ public long getTransations() {
+ return transations;
+ }
+
+ public long getEntityLoads() {
+ return entityLoads;
+ }
+
+ public long getConnects() {
+ return connects;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
public String toString() {
return "HibernateStats" //
+ "[ queries=" + queryExecutions //
commit d0d27d83e1e961d591b674e7c4a80e6adf2981e8
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Mar 26 03:11:37 2010 -0400
BZ 577109 - fix for partial-page requests not properly recovering from view exceptions
during the authentication action, test whether we've "bookmarked" an ajax request;
if so, redirect to the URLs in the web user preferences stored by WebUserTrackingFilter;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java
index 62e9518..c314189 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java
@@ -145,6 +145,13 @@ public class AuthenticateUserAction extends TilesAction {
if ((url == null) || url.equals("/Logout.do")) {
url = URL_DASHBOARD;
}
+ if (url.toLowerCase().indexOf("ajax") != -1) {
+ // we can't return to a URL that was a partial page request
+ // because the view no longer exists, and will blow up.
+ // instead, redirect back to the last saved URL
+ url = webUser.getWebPreferences().getLastVisitedURL(2);
+ System.out.println("Bypassing partial-page with " + url);
+ }
af = new ActionForward(url);
}
14 years, 1 month
[rhq] Branch 'gwt' - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java | 66 +++-------
1 file changed, 24 insertions(+), 42 deletions(-)
New commits:
commit 22bafe51d32a5f7ccacb0d5523c30b7b5ac2516c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 25 17:05:43 2010 -0400
fix summary tab view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index 7a483e6..4d7575e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -23,8 +23,8 @@ import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
@@ -39,8 +39,8 @@ public class BundleView extends VLayout {
private Label message = new Label("Select a bundle...");
private VLayout canvas;
private HeaderLabel headerLabel;
- private Label descriptionValue;
- private Label latestVersionValue;
+ private StaticTextItem descriptionItem;
+ private StaticTextItem latestVersionItem;
public BundleView() {
super();
@@ -87,42 +87,24 @@ public class BundleView extends VLayout {
private Tab createSummaryTab() {
Tab summaryTab = new Tab("Summary");
- VLayout top = new VLayout();
- top.setAutoHeight();
- top.setPadding(20);
- top.setWidth100();
-
- HLayout descriptionBox = new HLayout();
- descriptionBox.setWidth100();
- descriptionBox.setExtraSpace(10);
- Label descriptionLabel = new Label("Description:");
- descriptionLabel.setWidth("10%");
- descriptionLabel.setAlign(Alignment.LEFT);
- descriptionLabel.setWrap(false);
- descriptionValue = new Label("");
- descriptionValue.setWidth("90%");
- descriptionValue.setAlign(Alignment.LEFT);
- descriptionBox.addMember(descriptionLabel);
- descriptionBox.addMember(descriptionValue);
- top.addMember(descriptionBox);
- top.addMember(new LayoutSpacer());
-
- HLayout versionBox = new HLayout();
- versionBox.setWidth100();
- versionBox.setExtraSpace(10);
- Label versionLabel = new Label("Latest Version:");
- versionLabel.setWidth("10%");
- versionLabel.setAlign(Alignment.LEFT);
- versionLabel.setWrap(false);
- latestVersionValue = new Label("");
- latestVersionValue.setWidth("90%");
- latestVersionValue.setAlign(Alignment.LEFT);
- versionBox.addMember(versionLabel);
- versionBox.addMember(latestVersionValue);
- top.addMember(versionBox);
- top.addMember(new LayoutSpacer());
-
- summaryTab.setPane(top);
+ DynamicForm form = new DynamicForm();
+ form.setPadding(10);
+
+ descriptionItem = new StaticTextItem("description", "Description");
+ descriptionItem.setTitleAlign(Alignment.LEFT);
+ descriptionItem.setAlign(Alignment.LEFT);
+ descriptionItem.setWrap(false);
+ descriptionItem.setValue("");
+
+ latestVersionItem = new StaticTextItem("latestVersion", "Latest Version");
+ latestVersionItem.setTitleAlign(Alignment.LEFT);
+ latestVersionItem.setAlign(Alignment.LEFT);
+ latestVersionItem.setWrap(false);
+ latestVersionItem.setValue("");
+
+ form.setFields(descriptionItem, latestVersionItem);
+ summaryTab.setPane(form);
+
return summaryTab;
}
@@ -132,8 +114,8 @@ public class BundleView extends VLayout {
if (bundleBeingViewed != object.getBundleId()) {
headerLabel.setContents(object.getBundleName());
- latestVersionValue.setContents(object.getLatestVersion());
- descriptionValue.setContents(object.getBundleDescription());
+ latestVersionItem.setValue(object.getLatestVersion());
+ descriptionItem.setValue(object.getBundleDescription());
}
try {
14 years, 1 month
[rhq] Branch 'gwt' - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java | 108 ++--------
1 file changed, 30 insertions(+), 78 deletions(-)
New commits:
commit b8614fbcfe231944e59e9d1be8dde1274ec879c3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 25 16:57:23 2010 -0400
i think i finally got the summary page to look like its supposed to now
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java
index 3822718..ffa143a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java
@@ -21,10 +21,8 @@ package org.rhq.enterprise.gui.coregui.client.bundle.create;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.LayoutSpacer;
-import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
@@ -41,94 +39,48 @@ public class BundleSummaryStep implements WizardStep {
public Canvas getCanvas() {
- VLayout top = new VLayout();
- top.setAutoHeight();
- top.setPadding(20);
- top.setWidth100();
+ DynamicForm form = new DynamicForm();
+ form.setNumCols(2);
- HLayout bundleTypeBox = new HLayout();
- bundleTypeBox.setWidth100();
- bundleTypeBox.setExtraSpace(10);
- Label bundleTypeLabel = new Label("Type:");
- bundleTypeLabel.setWidth("10%");
+ StaticTextItem bundleTypeLabel = new StaticTextItem("bundleType", "Type");
+ bundleTypeLabel.setTitleAlign(Alignment.LEFT);
bundleTypeLabel.setAlign(Alignment.LEFT);
bundleTypeLabel.setWrap(false);
- Label bundleTypeValue = new Label(wizard.getBundleType().getName());
- bundleTypeValue.setWidth("90%");
- bundleTypeValue.setAlign(Alignment.LEFT);
- bundleTypeBox.addMember(bundleTypeLabel);
- bundleTypeBox.addMember(bundleTypeValue);
- top.addMember(bundleTypeBox);
-
- HLayout nameBox = new HLayout();
- nameBox.setWidth100();
- nameBox.setExtraSpace(10);
- Label nameLabel = new Label("Name:");
- nameLabel.setWidth("10%");
+ bundleTypeLabel.setValue(wizard.getBundleType().getName());
+
+ StaticTextItem nameLabel = new StaticTextItem("name", "Name");
+ nameLabel.setTitleAlign(Alignment.LEFT);
nameLabel.setAlign(Alignment.LEFT);
nameLabel.setWrap(false);
- Label nameValue = new Label(wizard.getBundleName());
- nameValue.setWidth("90%");
- nameValue.setAlign(Alignment.LEFT);
- nameBox.addMember(nameLabel);
- nameBox.addMember(nameValue);
- top.addMember(nameBox);
- top.addMember(new LayoutSpacer());
-
- HLayout versionBox = new HLayout();
- versionBox.setWidth100();
- versionBox.setExtraSpace(10);
- Label versionLabel = new Label("Version:");
- versionLabel.setWidth("10%");
+ nameLabel.setValue(wizard.getBundleName());
+
+ StaticTextItem versionLabel = new StaticTextItem("Version");
+ versionLabel.setTitleAlign(Alignment.LEFT);
+ versionLabel.setTitleAlign(Alignment.LEFT);
versionLabel.setAlign(Alignment.LEFT);
versionLabel.setWrap(false);
- Label versionValue = new Label(wizard.getBundleVersionString());
- versionValue.setWidth("90%");
- versionValue.setAlign(Alignment.LEFT);
- versionBox.addMember(versionLabel);
- versionBox.addMember(versionValue);
- top.addMember(versionBox);
- top.addMember(new LayoutSpacer());
-
- HLayout descriptionBox = new HLayout();
- descriptionBox.setWidth100();
- descriptionBox.setExtraSpace(10);
- Label descriptionLabel = new Label("Description:");
- descriptionLabel.setWidth("10%");
+ versionLabel.setValue(wizard.getBundleVersionString());
+
+ StaticTextItem descriptionLabel = new StaticTextItem("Description");
+ descriptionLabel.setTitleAlign(Alignment.LEFT);
descriptionLabel.setAlign(Alignment.LEFT);
descriptionLabel.setWrap(false);
- Label descriptionValue = new Label(wizard.getBundleDescription());
- descriptionValue.setWidth("90%");
- descriptionValue.setAlign(Alignment.LEFT);
- descriptionBox.addMember(descriptionLabel);
- descriptionBox.addMember(descriptionValue);
- top.addMember(descriptionBox);
- top.addMember(new LayoutSpacer());
-
- HLayout filesBox = new HLayout();
- filesBox.setWidth100();
- filesBox.setExtraSpace(10);
- Label filesLabel = new Label("Files:");
- filesLabel.setWidth("10%");
+ descriptionLabel.setValue(wizard.getBundleDescription());
+
+ StaticTextItem filesLabel = new StaticTextItem("Files");
+ filesLabel.setTitleVAlign(VerticalAlignment.TOP);
+ filesLabel.setTitleAlign(Alignment.LEFT);
filesLabel.setAlign(Alignment.LEFT);
- filesLabel.setValign(VerticalAlignment.TOP);
filesLabel.setWrap(false);
- VLayout filesValues = new VLayout();
- filesValues.setWidth("90%");
- filesValues.setAutoHeight();
+ StringBuilder filesValueStr = new StringBuilder();
for (String filename : wizard.getAllBundleFilesStatus().keySet()) {
- Label fileNameValue = new Label(filename);
- fileNameValue.setAlign(Alignment.LEFT);
- fileNameValue.setValign(VerticalAlignment.TOP);
- fileNameValue.setWrap(false);
- fileNameValue.setHeight(10);
- filesValues.addMember(fileNameValue);
+ filesValueStr.append(filename + "<br/>\n");
}
- filesBox.addMember(filesLabel);
- filesBox.addMember(filesValues);
- top.addMember(filesBox);
+ filesLabel.setValue(filesValueStr.toString());
+
+ form.setFields(bundleTypeLabel, nameLabel, versionLabel, descriptionLabel, filesLabel);
- return top;
+ return form;
}
public boolean nextPage() {
14 years, 1 month