[rhq] Branch 'release-3.0.0' - modules/enterprise
by lkrejci
modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp | 8 +++++---
modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp | 6 ++++--
2 files changed, 9 insertions(+), 5 deletions(-)
New commits:
commit fafae32f2077a6f0836ba92d440ab4c4cd143765
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 23 12:56:34 2010 +0100
BZ 665215 - xml-escaping the stacktraces to protect against XSS via malicious code inserted into the exception messages.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
index 915510d..ad0bb72 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/common/Error.jsp
@@ -62,10 +62,12 @@ int randomNum=(int)(Math.random()*1000);
</c:if>
<c:catch>
- <c:if test="${not empty exception}">
- <div id="exception<%= randomNum %>" style="visibility:hidden"><%=StringUtil.getStackTrace(exception)%></div>
+ <c:if test="${not empty exception}">
+ <c:set var="stacktrace"><%=StringUtil.getStackTrace(exception)%></c:set>
+ <div id="exception<%= randomNum %>" style="visibility:hidden"><c:out value="${stacktrace}" /></div>
<c:if test="${not empty root}">
- <div id="root<%= randomNum %>" style="visibility:hidden"><%=StringUtil.getStackTrace(root)%></div>
+ <c:set var="rootStacktrace"><%=StringUtil.getStackTrace(root)%></c:set>
+ <div id="root<%= randomNum %>" style="visibility:hidden"><c:out value="${rootStacktrace}" /></div>
</c:if>
</c:if>
</c:catch>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
index c35fa67..1c3e8be 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/common/GenericError.jsp
@@ -120,8 +120,10 @@ if (exception != null) {
while (exception != null) {
%>
- <div id="exceptionMessage<%=i%>" style="visibility:hidden"><%=exception.getLocalizedMessage()%></div>
- <div id="exception<%=i++%>" style="visibility:hidden"><%=StringUtil.getFirstStackTrace(exception)%></div>
+ <c:set var="message"><%=exception.getLocalizedMessage()%></c:set>
+ <c:set var="stacktrace"><%=StringUtil.getFirstStackTrace(exception)%></c:set>
+ <div id="exceptionMessage<%=i%>" style="visibility:hidden"><c:out value="${message}" /></div>
+ <div id="exception<%=i++%>" style="visibility:hidden"><c:out value="${stacktrace}" /></div>
<%
exception = exception.getCause();
}
13 years, 4 months
[rhq] modules/common modules/core modules/plugins
by mazz
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/AuditTask.java | 120 ++++++++++
modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml | 4
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java | 45 +++
modules/common/ant-bundle/src/test/resources/test-audit-input.properties | 1
modules/common/ant-bundle/src/test/resources/test-audit.properties | 3
modules/common/ant-bundle/src/test/resources/test-bundle-audit.xml | 39 +++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java | 3
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java | 37 +++
8 files changed, 249 insertions(+), 3 deletions(-)
New commits:
commit 65c741a60042218f7ab290b4795b563c9be2c77e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Dec 23 06:03:04 2010 -0500
BZ 649318 add new rhq:audit task that lets the recipe author be able to send up custom audit trail entries
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/AuditTask.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/AuditTask.java
new file mode 100644
index 0000000..af0e60b
--- /dev/null
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/AuditTask.java
@@ -0,0 +1,120 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.bundle.ant.task;
+
+import java.util.Date;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * The rhq:audit task is a way recipe authors can add their own audit messages to the stream
+ * of audit messages that the server gets to see how the progress went with the provisioning of a bundle.
+ *
+ * <rhq:audit status='SUCCESS|WARN|FAILURE' action="My Step" info="summary info" message="intermediate details">
+ * long details here
+ * </rhq:audit>
+ *
+ * @author John Mazzitelli
+ */
+public class AuditTask extends AbstractBundleTask {
+ private String status = "SUCCESS"; // must match one of SUCCESS, WARN, or FAILURE (see BundleResourceDeploymentHistory.Status)
+ private String action = null;
+ private String info = null;
+ private String message = "";
+ private String details = "";
+
+ @Override
+ public void maybeConfigure() throws BuildException {
+ super.maybeConfigure(); // inits the attribute fields
+ validateAttributes();
+ }
+
+ @Override
+ public void execute() throws BuildException {
+ // this will log a message with a very specific format that is understood
+ // by the agent-side build listener's messageLogged method:
+ // org.rhq.plugins.ant.DeploymentAuditorBuildListener.messageLogged(BuildEvent)
+ // RHQ_AUDIT_MESSAGE___<status>___<action>___<info>___<message>___<details>
+ StringBuilder str = new StringBuilder("RHQ_AUDIT_MESSAGE___");
+ str.append(this.status);
+ str.append("___");
+ str.append((this.action != null) ? this.action : "Audit Message");
+ str.append("___");
+ str.append((this.info != null) ? this.info : "Timestamp: " + new Date().toString());
+ str.append("___");
+ str.append(this.message);
+ str.append("___");
+ str.append(this.details);
+ getProject().log(str.toString(), Project.MSG_INFO);
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public String getInfo() {
+ return info;
+ }
+
+ public void setInfo(String info) {
+ this.info = info;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = (message != null) ? message : "";
+ }
+
+ /**
+ * Set a multiline message.
+ * @param msg the CDATA text to append to the message text
+ */
+ public void addText(String msg) {
+ if (msg != null) {
+ this.details += getProject().replaceProperties(msg);
+ }
+ }
+
+ protected void validateAttributes() throws BuildException {
+ if (this.status == null) {
+ this.status = "SUCCESS";
+ } else if (!this.status.equalsIgnoreCase("SUCCESS") && !this.status.equalsIgnoreCase("FAILURE")
+ && !this.status.equalsIgnoreCase("WARN")) {
+ throw new BuildException("The 'result' attribute must be either 'SUCCESS', 'WARN' or 'FAILURE'");
+ }
+ this.status = this.status.toUpperCase();
+ }
+
+}
\ No newline at end of file
diff --git a/modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml b/modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml
index fee46ef..010077e 100644
--- a/modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml
+++ b/modules/common/ant-bundle/src/main/resources/org/rhq/bundle/antlib.xml
@@ -17,5 +17,7 @@
<typedef name="ignore" classname="org.rhq.bundle.ant.type.IgnoreType"/>
<typedef name="fileset" classname="org.rhq.bundle.ant.type.FileSet"/>
<typedef name="system-service" classname="org.rhq.bundle.ant.type.SystemServiceType"/>
-
+
+ <!-- audit task used to send custom audit messages to server -->
+ <taskdef name="audit" classname="org.rhq.bundle.ant.task.AuditTask"/>
</antlib>
diff --git a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
index 2c41874..772c3e5 100644
--- a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
@@ -140,6 +140,7 @@ public class AntLauncherTest {
assert propDef.getDescription().equals("This is where the product will listen for incoming messages");
assert propDef.isRequired();
+ // make sure our test infrastruction setup the input properties correctly
Configuration config = project.getConfiguration();
assert config.getProperties().size() == 1 : config.getProperties();
assert "10000".equals(config.getSimpleValue("listener.port", null)) : config.getProperties();
@@ -193,6 +194,7 @@ public class AntLauncherTest {
assert propDef.getDescription().equals("This is where the product will listen for incoming messages");
assert propDef.isRequired();
+ // make sure our test infrastruction setup the input properties correctly
Configuration config = project.getConfiguration();
assert config.getProperties().size() == 1;
assert "20000".equals(config.getSimpleValue("listener.port", null)) : config.getProperties();
@@ -249,6 +251,7 @@ public class AntLauncherTest {
assert propDef.getDescription().equals("This is where the product will listen for incoming messages");
assert propDef.isRequired();
+ // make sure our test infrastruction setup the input properties correctly
Configuration config = project.getConfiguration();
assert config.getProperties().size() == 1;
assert "20000".equals(config.getSimpleValue("listener.port", null)) : config.getProperties();
@@ -431,6 +434,48 @@ public class AntLauncherTest {
}
}
+ // this doesn't verify the audit messages getting emitted are correct
+ // but it does verify the audit tag getting processed correctly.
+ // you have to look at the test logs to see the audit messages
+ // TODO: write a ant build listener to listen for this messages, parse them and verify they are correct
+ // this test should then ask the listener at the end if everything was OK and assert false if not
+ public void testAuditMessages() throws Exception {
+ // We want to test a fresh install, so make sure the deploy dir doesn't pre-exist.
+ FileUtil.purge(DEPLOY_DIR, true);
+
+ AntLauncher ant = new AntLauncher();
+ Properties inputProps = createInputProperties("/test-audit-input.properties");
+ List<BuildListener> buildListeners = createBuildListeners();
+
+ BundleAntProject project = ant.executeBundleDeployFile(getBuildXml("test-bundle-audit.xml"), inputProps,
+ buildListeners);
+ assert project != null;
+ Set<String> bundleFiles = project.getBundleFileNames();
+ assert bundleFiles != null;
+ assert bundleFiles.size() == 1 : bundleFiles;
+ assert bundleFiles.contains("test-audit.properties") : bundleFiles;
+
+ // sanity check - make sure our recipe defined this property
+ ConfigurationDefinition configDef = project.getConfigurationDefinition();
+ assert configDef.getPropertyDefinitions().size() == 1 : configDef.getPropertyDefinitions();
+ PropertyDefinitionSimple propDef = configDef.getPropertyDefinitionSimple("listener.port");
+ assert propDef != null;
+
+ // make sure our test infrastruction setup the input properties correctly
+ Configuration config = project.getConfiguration();
+ assert config.getProperties().size() == 1 : config.getProperties();
+ assert "777".equals(config.getSimpleValue("listener.port", null)) : config.getProperties();
+
+ String preinstallTargetExecuted = (String) project.getProperties().get("preinstallTargetExecuted");
+ assert preinstallTargetExecuted.equals("1a");
+ String postinstallTargetExecuted = (String) project.getProperties().get("postinstallTargetExecuted");
+ assert postinstallTargetExecuted.equals("1b");
+
+ assert new File(DEPLOY_DIR, "test-audit.properties").exists() : "missing file";
+ assert readPropsFile(new File(DEPLOY_DIR, "test-audit.properties")).getProperty("my.listener.port").equals(
+ "777");
+ }
+
private List<BuildListener> createBuildListeners() {
List<BuildListener> buildListeners = new ArrayList<BuildListener>();
DefaultLogger logger = new DefaultLogger();
diff --git a/modules/common/ant-bundle/src/test/resources/test-audit-input.properties b/modules/common/ant-bundle/src/test/resources/test-audit-input.properties
new file mode 100644
index 0000000..aaa7499
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/test-audit-input.properties
@@ -0,0 +1 @@
+listener.port=777
diff --git a/modules/common/ant-bundle/src/test/resources/test-audit.properties b/modules/common/ant-bundle/src/test/resources/test-audit.properties
new file mode 100644
index 0000000..4dc4374
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/test-audit.properties
@@ -0,0 +1,3 @@
+my.listener.port=@@listener.port(a)@
+one.property=wot
+two.property=gorilla?
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-audit.xml b/modules/common/ant-bundle/src/test/resources/test-bundle-audit.xml
new file mode 100644
index 0000000..687c4ba
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-audit.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+
+<project name="test-bundle" default="main" xmlns:rhq="antlib:org.rhq.bundle">
+
+ <rhq:bundle name="audit-test" version="1">
+
+ <rhq:input-property name="listener.port" type="integer"/>
+
+ <rhq:deployment-unit name="test" preinstallTarget="preinstall" postinstallTarget="postinstall">
+ <rhq:file name="test-audit.properties" destinationFile="test-audit.properties" replace="true"/>
+ </rhq:deployment-unit>
+
+ </rhq:bundle>
+
+ <target name="main"/>
+
+ <target name="preinstall">
+ <property name="preinstallTargetExecuted" value="1a"/>
+ <rhq:audit status="success" action="action1" info="info1" message="message1">
+ preinstall successful message with port "${listener.port}" !
+ </rhq:audit>
+ <rhq:audit status="failure" action="action2" info="info2" message="message2">
+ preinstall failure message here!
+ </rhq:audit>
+ <rhq:audit status="warn" action="action3" info="info3" message="message3">
+ preinstall warn message here!
+ </rhq:audit>
+ </target>
+
+ <target name="postinstall">
+ <property name="postinstallTargetExecuted" value="1b"/>
+ <rhq:audit />
+ <rhq:audit status="SUCCESS" />
+ <rhq:audit status="WARN" action="actionA" />
+ <rhq:audit status="FAILURE" action="actionB" info="infoB" />
+ <rhq:audit status="SUCCESS" action="actionC" info="infoC" message="messageC" />
+ </target>
+
+</project>
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
index eb00b26..b7f28fc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
@@ -228,7 +228,8 @@ public class BundleResourceDeploymentHistory implements Serializable {
FILE_ADD("File Add"), //
FILE_CHANGE("File Change"), //
FILE_DOWNLOAD("File Download"), //
- FILE_REMOVE("File Remove");
+ FILE_REMOVE("File Remove"), //
+ AUDIT_MESSAGE("Audit Message");
private String displayName;
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
index 7f41de8..b8476b9 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
@@ -22,12 +22,16 @@
*/
package org.rhq.plugins.ant;
+import java.util.Date;
+
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.util.StringUtils;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Category;
+import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Status;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
/**
@@ -71,6 +75,38 @@ public class DeploymentAuditorBuildListener implements BuildListener {
}
public void messageLogged(BuildEvent event) {
+ // this will see if this is an audit message (e.g. <rhq:audit>) and if so, send it up to the server
+ // see org.rhq.bundle.ant.task.AuditTask.execute()
+ // RHQ_AUDIT_MESSAGE___<status>___<action>___<info>___<message>___<details>
+
+ try {
+ Status status = Status.SUCCESS;
+ String action = "Audit Message";
+ String info = "Recipe Audit Message";
+ String message = new Date().toString();
+ String details = null;
+ BundleResourceDeployment deployment = this.bundleResourceDeployment;
+ Category category = Category.AUDIT_MESSAGE;
+
+ String[] eventStrings = event.getMessage().split("___");
+ int index = 0;
+ if (eventStrings[index++].equals("RHQ_AUDIT_MESSAGE")) {
+ try {
+ String statusStr = eventStrings[index++];
+ status = Status.valueOf(statusStr.toUpperCase());
+ action = eventStrings[index++];
+ info = eventStrings[index++];
+ message = eventStrings[index++];
+ details = eventStrings[index++];
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // the message didn't have all the info, just skip looking for the rest and log what we have
+ }
+ }
+
+ this.bundleManagerProvider.auditDeployment(deployment, action, info, category, status, message, details);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
return;
}
@@ -101,7 +137,6 @@ public class DeploymentAuditorBuildListener implements BuildListener {
return msg.toString();
}
- @SuppressWarnings( { "ThrowableResultOfMethodCallIgnored" })
private static String createMessage(String action, BuildEvent event) {
StringBuilder msg = new StringBuilder(action);
13 years, 4 months
[rhq] modules/common modules/core
by mazz
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java | 4
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java | 61 +-
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java | 20
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java | 19
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java | 272 +++++++++-
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java | 156 +++++
modules/common/ant-bundle/src/test/resources/file.zip |binary
modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-input.properties | 1
modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-with-replace.xml | 21
modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives.xml | 14
modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java | 134 ++++
modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java | 32 -
modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java | 28 -
modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java | 62 +-
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java | 51 -
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java | 51 -
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java | 62 +-
17 files changed, 807 insertions(+), 181 deletions(-)
New commits:
commit d31fc63f7d6ea1116ef1884941ed869213fe3600
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Dec 23 03:59:41 2010 -0500
BZ 638730 - ant bundle deployment now supports provisioning archive files in exploded or compressed form
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
index 4e7d3bf..b7705e1 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
@@ -6,7 +6,7 @@ package org.rhq.bundle.ant;
public class DeployPropertyNames {
/** System property that should always be available to Ant scripts - it's the location where the deployment should be installed */
public static final String DEPLOY_DIR = "rhq.deploy.dir";
-
+
/** System property that should always be available to Ant scripts - it's the ID of the bundle deployment */
public static final String DEPLOY_ID = "rhq.deploy.id";
@@ -32,7 +32,7 @@ public class DeployPropertyNames {
* Optional deploy property - if true, this is a dry run or preview (that is, it should log what steps would occur
* but not actually perform any of the steps); if not specified, the default is false
*/
- public static final Object DEPLOY_DRY_RUN = "rhq.deploy.dryRun";
+ public static final String DEPLOY_DRY_RUN = "rhq.deploy.dryRun";
private DeployPropertyNames() {
}
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
index cea5df4..44daf4c 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
@@ -1,21 +1,22 @@
package org.rhq.bundle.ant.type;
-import org.apache.tools.ant.types.DataType;
-import org.rhq.bundle.ant.BundleAntProject;
-
import java.io.File;
import java.util.List;
import java.util.regex.Pattern;
+import org.apache.tools.ant.types.DataType;
+
+import org.rhq.bundle.ant.BundleAntProject;
+
/**
*
*/
public abstract class AbstractBundleType extends DataType {
@Override
public BundleAntProject getProject() {
- return (BundleAntProject)super.getProject();
+ return (BundleAntProject) super.getProject();
}
-
+
protected static Pattern getPattern(List<FileSet> fileSets) {
if (fileSets == null || fileSets.isEmpty()) {
return null;
@@ -45,25 +46,7 @@ public abstract class AbstractBundleType extends DataType {
firstIncludePattern = false;
}
regex.append("(");
- for (int i = 0; i < includePattern.length(); i++) {
- char c = includePattern.charAt(i);
- if (c == '?') {
- regex.append('.');
- } else if (c == '*') {
- if (i + 1 < includePattern.length()) {
- char c2 = includePattern.charAt(++i);
- if (c2 == '*') {
- regex.append(".*");
- i++;
- continue;
- }
- }
- regex.append("[^/]*");
- } else {
- regex.append(c);
- }
- // TODO: Escape backslashes.
- }
+ buildIncludePatternRegex(includePattern, regex);
regex.append(")");
}
}
@@ -71,4 +54,34 @@ public abstract class AbstractBundleType extends DataType {
}
return Pattern.compile(regex.toString());
}
+
+ /**
+ * Builds a regex expression for a single include pattern.
+ *
+ * @param includePattern the single include pattern to build a regex for
+ * @param regex appends all regex characters to this regex string
+ */
+ protected static void buildIncludePatternRegex(String includePattern, StringBuilder regex) {
+ for (int i = 0; i < includePattern.length(); i++) {
+ char c = includePattern.charAt(i);
+ if (c == '?') {
+ regex.append('.');
+ } else if (c == '*') {
+ if (i + 1 < includePattern.length()) {
+ char c2 = includePattern.charAt(i + 1);
+ if (c2 == '*') {
+ regex.append(".*");
+ i += 2;
+ continue;
+ }
+ }
+ regex.append("[^/]*");
+ } else if (c == '.') {
+ regex.append("\\.");
+ } else {
+ regex.append(c);
+ }
+ // TODO: Escape backslashes.
+ }
+ }
}
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java
index 19aaaf6..d531801 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java
@@ -25,15 +25,18 @@ package org.rhq.bundle.ant.type;
import java.util.List;
import java.util.regex.Pattern;
+import org.apache.tools.ant.BuildException;
+
/**
- * An archive file to be exploded during the bundle deployment. Can optionally contain a rhq:replace child element
- * that specifies the set of files that contain template variables (e.g. @@http.port(a)@) which need to be replaced with
- * the value of the corresponding property.
+ * An archive file to be exploded during the bundle deployment (it could remain compressed if exploded="false" is specified)
+ * Can optionally contain a rhq:replace child element that specifies the set of files that contain
+ * template variables (e.g. @@http.port(a)@) which need to be replaced with the value of the corresponding property.
*
* @author Ian Springer
*/
public class ArchiveType extends AbstractFileType {
private Pattern replacePattern;
+ private String exploded = Boolean.TRUE.toString();
public void addConfigured(ReplaceType replace) {
List<FileSet> fileSets = replace.getFileSets();
@@ -43,4 +46,15 @@ public class ArchiveType extends AbstractFileType {
public Pattern getReplacePattern() {
return replacePattern;
}
+
+ public String getExploded() {
+ return exploded;
+ }
+
+ public void setExploded(String exploded) {
+ if (!Boolean.TRUE.toString().equalsIgnoreCase(exploded) && !Boolean.FALSE.toString().equalsIgnoreCase(exploded)) {
+ throw new BuildException("'exploded' attribute must be 'true' or 'false': " + exploded);
+ }
+ this.exploded = exploded;
+ }
}
\ No newline at end of file
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
index 3727adb..31a52bc 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
@@ -51,6 +51,7 @@ public class DeploymentUnitType extends AbstractBundleType {
private Map<File, File> files = new LinkedHashMap<File, File>();
private Set<File> rawFilesToReplace = new LinkedHashSet<File>();
private Set<File> archives = new LinkedHashSet<File>();
+ private Map<File, Boolean> archivesExploded = new HashMap<File, Boolean>();
private Map<File, Pattern> archiveReplacePatterns = new HashMap<File, Pattern>();
private SystemServiceType systemService;
private Pattern ignorePattern;
@@ -98,8 +99,9 @@ public class DeploymentUnitType extends AbstractBundleType {
Project.MSG_VERBOSE);
}
- DeploymentData deploymentData = new DeploymentData(deploymentProps, this.archives, this.files, deployDir,
- this.archiveReplacePatterns, this.rawFilesToReplace, templateEngine, this.ignorePattern, willManageRootDir);
+ DeploymentData deploymentData = new DeploymentData(deploymentProps, this.archives, this.files, getProject()
+ .getBaseDir(), deployDir, this.archiveReplacePatterns, this.rawFilesToReplace, templateEngine,
+ this.ignorePattern, willManageRootDir, this.archivesExploded);
Deployer deployer = new Deployer(deploymentData);
try {
DeployDifferences diffs = getProject().getDeployDifferences();
@@ -181,6 +183,17 @@ public class DeploymentUnitType extends AbstractBundleType {
return archives;
}
+ /**
+ * Returns a map keyed on {@link #getArchives() archive names} whose values
+ * are either true or false, where true means the archive is to be deployed exploded
+ * and false means the archive should be deployed in compressed form.
+ *
+ * @return map showing how an archive should be deployed in its final form
+ */
+ public Map<File, Boolean> getArchivesExploded() {
+ return archivesExploded;
+ }
+
public String getPreinstallTarget() {
return preinstallTarget;
}
@@ -231,6 +244,8 @@ public class DeploymentUnitType extends AbstractBundleType {
if (replacePattern != null) {
this.archiveReplacePatterns.put(archive.getSource(), replacePattern);
}
+ Boolean exploded = Boolean.valueOf(archive.getExploded());
+ this.archivesExploded.put(archive.getSource(), exploded);
}
public void addConfigured(IgnoreType ignore) {
diff --git a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
index a9edfc1..2c41874 100644
--- a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
@@ -23,6 +23,7 @@
package org.rhq.bundle.ant;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -30,18 +31,25 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.updater.DeploymentsMetadata;
+import org.rhq.core.util.updater.FileHashcodeMap;
/**
* @author John Mazzitelli
@@ -50,6 +58,14 @@ import org.rhq.core.util.file.FileUtil;
@Test
public class AntLauncherTest {
private static final File DEPLOY_DIR = new File("target/test-ant-bundle").getAbsoluteFile();
+ private static final String ANT_BASEDIR = "target/test-classes";
+
+ private int deploymentId;
+
+ @BeforeClass
+ public void beforeClass() {
+ deploymentId = 0;
+ }
@AfterClass
public void afterClass() {
@@ -135,17 +151,12 @@ public class AntLauncherTest {
assert new File(DEPLOY_DIR, "subdir/test.properties").exists() : "missing file";
assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() : "missing archived bundle file";
+ assert new File(DEPLOY_DIR, "archived-subdir/archived-file-in-subdir.properties").exists() : "missing subdir archive file";
assert unrelatedFile.exists() : "unrelated file was removed during the install";
- }
-
- private List<BuildListener> createBuildListeners() {
- List<BuildListener> buildListeners = new ArrayList<BuildListener>();
- DefaultLogger logger = new DefaultLogger();
- logger.setMessageOutputLevel(Project.MSG_DEBUG);
- logger.setOutputPrintStream(System.out);
- logger.setErrorPrintStream(System.err);
- buildListeners.add(logger);
- return buildListeners;
+ assert readPropsFile(new File(DEPLOY_DIR, "subdir/test.properties")).getProperty("junk.listener.port").equals(
+ "10000");
+ assert readPropsFile(new File(DEPLOY_DIR, "archived-subdir/archived-file-in-subdir.properties")).getProperty(
+ "templatized.variable").equals("10000");
}
@Test(dependsOnMethods = "testInstall")
@@ -193,7 +204,12 @@ public class AntLauncherTest {
assert new File(DEPLOY_DIR, "subdir/test.properties").exists() : "missing file";
assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() : "missing archived bundle file";
+ assert new File(DEPLOY_DIR, "archived-subdir/archived-file-in-subdir.properties").exists() : "missing subdir archive file";
assert !unrelatedFile.exists() : "we are managing root dir so unrelated file should be removed during upgrade";
+ assert readPropsFile(new File(DEPLOY_DIR, "subdir/test.properties")).getProperty("junk.listener.port").equals(
+ "20000");
+ assert readPropsFile(new File(DEPLOY_DIR, "archived-subdir/archived-file-in-subdir.properties")).getProperty(
+ "templatized.variable").equals("20000");
}
public void testUpgradeNoManageRootDir() throws Exception {
@@ -244,25 +260,223 @@ public class AntLauncherTest {
assert new File(DEPLOY_DIR, "subdir/test.properties").exists() : "missing file";
assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() : "missing archived bundle file";
+ assert new File(DEPLOY_DIR, "archived-subdir/archived-file-in-subdir.properties").exists() : "missing subdir archive file";
assert unrelatedFile.exists() : "we are NOT managing root dir so unrelated file should NOT be removed during upgrade";
+ assert readPropsFile(new File(DEPLOY_DIR, "subdir/test.properties")).getProperty("junk.listener.port").equals(
+ "20000");
+ assert readPropsFile(new File(DEPLOY_DIR, "archived-subdir/archived-file-in-subdir.properties")).getProperty(
+ "templatized.variable").equals("20000");
+ }
+
+ public void testInstallCompressedZipNoDryRun() throws Exception {
+ testInstallCompressedZip(false);
+ }
+
+ public void testInstallCompressedZipDryRun() throws Exception {
+ testInstallCompressedZip(true);
+ }
+
+ private void testInstallCompressedZip(boolean dryRun) throws Exception {
+ // We want to test a fresh install, so make sure the deploy dir doesn't pre-exist.
+ FileUtil.purge(DEPLOY_DIR, true);
+
+ AntLauncher ant = new AntLauncher();
+ Properties inputProps = createInputProperties("/test-bundle-compressed-archives-input.properties", dryRun);
+ List<BuildListener> buildListeners = createBuildListeners();
+
+ BundleAntProject project = ant.executeBundleDeployFile(getBuildXml("test-bundle-compressed-archives.xml"),
+ inputProps, buildListeners);
+ assert project != null;
+ Set<String> bundleFiles = project.getBundleFileNames();
+ assert bundleFiles != null;
+ assert bundleFiles.size() == 1 : bundleFiles;
+ assert bundleFiles.contains("file.zip") : bundleFiles;
+
+ assert project.getBundleName().equals("test compressed archive files");
+ assert project.getBundleVersion().equals("1.0");
+ assert project.getBundleDescription() == null;
+
+ // while we are here, let's see that we have 0 config props
+ ConfigurationDefinition configDef = project.getConfigurationDefinition();
+ assert configDef.getPropertyDefinitions().size() == 0 : configDef.getPropertyDefinitions();
+ Configuration config = project.getConfiguration();
+ assert config.getProperties().size() == 0 : config.getProperties();
+
+ if (!dryRun) {
+ assert new File(DEPLOY_DIR, "file.zip").exists() : "should be here, we told it to stay compressed";
+ } else {
+ assert !new File(DEPLOY_DIR, "file.zip").exists() : "dry run - should not be here";
+ }
+
+ assert !new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() : "should not have exploded this";
+ assert !new File(DEPLOY_DIR, "archived-subdir/archived-file-in-subdir.properties").exists() : "should not have exploded this";
+ assert !new File(DEPLOY_DIR, "archived-subdir").isDirectory() : "should not still have the exploded dir";
+
+ DeploymentsMetadata dm = new DeploymentsMetadata(DEPLOY_DIR);
+ if (!dryRun) {
+ FileHashcodeMap fhm = dm.getCurrentDeploymentFileHashcodes();
+ assert !fhm.containsKey("archived-bundle-file.txt") : "should not have metadata - this is inside the compressed zip";
+ assert !fhm.containsKey("archived-subdir/archived-file-in-subdir.properties") : "should not have metadata - this is inside the compressed zip";
+ assert fhm.containsKey("file.zip") : "should have metadata for this - we didn't explode it, we just have this compressed file";
+
+ // test that we created the zip OK. Note that our test did not do any file replacing/realization of templates
+ final String[] templateVarValue = new String[] { null };
+ final Integer[] entries = new Integer[] { 0 };
+ ZipUtil.walkZipFile(new File(DEPLOY_DIR, "file.zip"), new ZipUtil.ZipEntryVisitor() {
+ @Override
+ public boolean visit(ZipEntry entry, ZipInputStream stream) throws Exception {
+ if (entry.getName().equals("archived-subdir/archived-file-in-subdir.properties")) {
+ Properties props = new Properties();
+ props.load(stream);
+ templateVarValue[0] = props.getProperty("templatized.variable");
+ }
+ if (!entry.isDirectory()) {
+ entries[0] = Integer.valueOf(entries[0].intValue() + 1);
+ }
+ return true;
+ }
+ });
+ assert templateVarValue[0] != null && templateVarValue[0].equals("@@listener.port(a)@") : templateVarValue[0];
+ assert entries[0].intValue() == 2 : entries[0]; // we only counted the file entries
+ } else {
+ try {
+ dm.getCurrentDeploymentFileHashcodes();
+ assert false : "this was a dry run, we should not have written our metadata to the filesystem";
+ } catch (Exception e) {
+ // expected
+ }
+ }
+ }
+
+ public void testInstallCompressedZipWithTemplatizedFilesNoDryRun() throws Exception {
+ testInstallCompressedZipWithTemplatizedFiles(false);
+ }
+
+ public void testInstallCompressedZipWithTemplatizedFilesDryRun() throws Exception {
+ testInstallCompressedZipWithTemplatizedFiles(true);
+ }
+
+ private void testInstallCompressedZipWithTemplatizedFiles(boolean dryRun) throws Exception {
+ // We want to test a fresh install, so make sure the deploy dir doesn't pre-exist.
+ FileUtil.purge(DEPLOY_DIR, true);
+
+ AntLauncher ant = new AntLauncher();
+ Properties inputProps = createInputProperties("/test-bundle-compressed-archives-input.properties", dryRun);
+ List<BuildListener> buildListeners = createBuildListeners();
+
+ BundleAntProject project = ant.executeBundleDeployFile(
+ getBuildXml("test-bundle-compressed-archives-with-replace.xml"), inputProps, buildListeners);
+ assert project != null;
+ Set<String> bundleFiles = project.getBundleFileNames();
+ assert bundleFiles != null;
+ assert bundleFiles.size() == 1 : bundleFiles;
+ assert bundleFiles.contains("file.zip") : bundleFiles;
+
+ assert project.getBundleName().equals("test compressed archive files");
+ assert project.getBundleVersion().equals("1.0");
+ assert project.getBundleDescription() == null;
+
+ // we have one property that we use to realize our content
+ ConfigurationDefinition configDef = project.getConfigurationDefinition();
+ assert configDef.getPropertyDefinitions().size() == 1 : configDef.getPropertyDefinitions();
+ PropertyDefinitionSimple propDef = configDef.getPropertyDefinitionSimple("listener.port");
+ assert propDef != null;
+ assert propDef.getType() == PropertySimpleType.INTEGER;
+ assert propDef.getDefaultValue() == null : "recipe didn't define a default for our property";
+ assert propDef.getDescription() == null : "recipe didn't define a description for our property";
+ assert propDef.isRequired() : "recipe didn't make the property required, but the default should be required";
+
+ if (!dryRun) {
+ assert new File(DEPLOY_DIR, "file.zip").exists() : "should be here, we told it to stay compressed";
+ } else {
+ assert !new File(DEPLOY_DIR, "file.zip").exists() : "this was a dry run, should not be here";
+ }
+ assert !new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() : "should not have exploded this";
+ assert !new File(DEPLOY_DIR, "archived-subdir/archived-file-in-subdir.properties").exists() : "should not have exploded this";
+ assert !new File(DEPLOY_DIR, "archived-subdir").isDirectory() : "should not still have the exploded dir";
+
+ DeploymentsMetadata dm = new DeploymentsMetadata(DEPLOY_DIR);
+ if (!dryRun) {
+ FileHashcodeMap fhm = dm.getCurrentDeploymentFileHashcodes();
+ assert !fhm.containsKey("archived-bundle-file.txt") : "should not have metadata - this is inside the compressed zip";
+ assert !fhm.containsKey("archived-subdir/archived-file-in-subdir.properties") : "should not have metadata - this is inside the compressed zip";
+ assert fhm.containsKey("file.zip") : "should have metadata for this - we didn't explode it, we just have this compressed file";
+
+ // test that the file in the zip is realized
+ final String[] templateVarValue = new String[] { null };
+ final Integer[] entries = new Integer[] { 0 };
+ ZipUtil.walkZipFile(new File(DEPLOY_DIR, "file.zip"), new ZipUtil.ZipEntryVisitor() {
+ @Override
+ public boolean visit(ZipEntry entry, ZipInputStream stream) throws Exception {
+ if (entry.getName().equals("archived-subdir/archived-file-in-subdir.properties")) {
+ Properties props = new Properties();
+ props.load(stream);
+ templateVarValue[0] = props.getProperty("templatized.variable");
+ }
+ if (!entry.isDirectory()) {
+ entries[0] = Integer.valueOf(entries[0].intValue() + 1);
+ }
+ return true;
+ }
+ });
+ assert templateVarValue[0] != null && templateVarValue[0].equals("12345") : templateVarValue[0];
+ assert entries[0].intValue() == 2 : entries[0]; // we only counted the file entries
+ } else {
+ try {
+ dm.getCurrentDeploymentFileHashcodes();
+ assert false : "this was a dry run, we should not have written our metadata to the filesystem";
+ } catch (Exception e) {
+ // expected
+ }
+ }
+ }
+
+ private List<BuildListener> createBuildListeners() {
+ List<BuildListener> buildListeners = new ArrayList<BuildListener>();
+ DefaultLogger logger = new DefaultLogger();
+ logger.setMessageOutputLevel(Project.MSG_DEBUG);
+ logger.setOutputPrintStream(System.out);
+ logger.setErrorPrintStream(System.err);
+ buildListeners.add(logger);
+ return buildListeners;
}
private Properties createInputProperties(String resourcePath) throws IOException {
+ return createInputProperties(resourcePath, false);
+ }
+
+ private Properties createInputProperties(String resourcePath, boolean dryRun) throws IOException {
Properties inputProps = new Properties();
inputProps.setProperty(DeployPropertyNames.DEPLOY_DIR, DEPLOY_DIR.getPath());
- inputProps.setProperty(DeployPropertyNames.DEPLOY_ID, "100");
+ inputProps.setProperty(DeployPropertyNames.DEPLOY_ID, String.valueOf(++this.deploymentId));
inputProps.setProperty(DeployPropertyNames.DEPLOY_PHASE, DeploymentPhase.INSTALL.name());
- InputStream inputStream = this.getClass().getResourceAsStream(resourcePath);
+ if (dryRun) {
+ inputProps.setProperty(DeployPropertyNames.DEPLOY_DRY_RUN, Boolean.TRUE.toString());
+ }
+ if (resourcePath != null) {
+ InputStream inputStream = this.getClass().getResourceAsStream(resourcePath);
+ try {
+ inputProps.load(inputStream);
+ } finally {
+ inputStream.close();
+ }
+ }
+ return inputProps;
+ }
+
+ private Properties readPropsFile(File propFile) throws Exception {
+ Properties props = new Properties();
+ InputStream inputStream = new FileInputStream(propFile);
try {
- inputProps.load(inputStream);
+ props.load(inputStream);
} finally {
inputStream.close();
}
- return inputProps;
+ return props;
}
private File getBuildXml(String name) throws Exception {
- File file = new File("target/test-classes", name);
+ File file = new File(ANT_BASEDIR, name);
assert file.exists() : "The test Ant build script doesn't exist: " + file.getAbsolutePath();
return file;
}
@@ -286,4 +500,32 @@ public class AntLauncherTest {
File destFile = new File(destDir, fileName);
return writeFile(content, destFile);
}
+
+ private File createZip(String[] content, File destDir, String zipName, String[] entryName) throws Exception {
+ FileOutputStream stream = null;
+ ZipOutputStream out = null;
+
+ try {
+ destDir.mkdirs();
+ File zipFile = new File(destDir, zipName);
+ stream = new FileOutputStream(zipFile);
+ out = new ZipOutputStream(stream);
+
+ assert content.length == entryName.length;
+ for (int i = 0; i < content.length; i++) {
+ ZipEntry zipAdd = new ZipEntry(entryName[i]);
+ zipAdd.setTime(System.currentTimeMillis());
+ out.putNextEntry(zipAdd);
+ out.write(content[i].getBytes());
+ }
+ return zipFile;
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ if (stream != null) {
+ stream.close();
+ }
+ }
+ }
}
diff --git a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
new file mode 100644
index 0000000..8757540
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
@@ -0,0 +1,156 @@
+/*
+ * 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.bundle.ant.type;
+
+import java.util.regex.Pattern;
+
+import org.testng.annotations.Test;
+
+@Test
+public class AbstractBundleTypeTest {
+ public void testGetPattern() {
+ Pattern regex;
+
+ regex = assertIncludePatternRegex("easy.txt", "easy\\.txt", "easy.txt");
+ assert !regex.matcher("easyXtxt").matches() : "should not have matched, is the . escaped?";
+ assert !regex.matcher("Xeasy.txt").matches();
+ assert !regex.matcher("easy.txtX").matches();
+ assert !regex.matcher("/easy.txt").matches();
+ assert !regex.matcher("easy.txt/").matches();
+
+ regex = assertIncludePatternRegex("another.one/easy.txt", "another\\.one/easy\\.txt", "another.one/easy.txt");
+ assert !regex.matcher("anotherXone/easyXtxt").matches() : "should not have matched, is the . escaped?";
+ assert !regex.matcher("another.one/easy.txtX").matches();
+ assert !regex.matcher("another.one/easy.txt/X").matches();
+ assert !regex.matcher("Xanother.one/easy.txt").matches();
+ assert !regex.matcher("X/another.one/easy.txt").matches();
+ assert !regex.matcher("/another.one/easy.txt").matches();
+ assert !regex.matcher("another.one/easy.txt/").matches();
+
+ regex = assertIncludePatternRegex("*.properties", "[^/]*\\.properties", "any.properties");
+ assert !regex.matcher("anyXproperties").matches() : "should not have matched, is the . escaped?";
+ assert regex.matcher("with space.properties").matches();
+ assert !regex.matcher("subdir/any.properties").matches();
+ assert !regex.matcher("any.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("a*b.properties", "a[^/]*b\\.properties", "a123b.properties");
+ assert !regex.matcher("a123bXproperties").matches() : "should not have matched, is the . escaped?";
+ assert regex.matcher("a b.properties").matches();
+ assert regex.matcher("ab.properties").matches();
+ assert !regex.matcher("subdir/a123b.properties").matches();
+ assert !regex.matcher("a123b.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("/*.properties", "/[^/]*\\.properties", "/any.properties");
+ assert !regex.matcher("/anyXproperties").matches() : "should not have matched, is the . escaped?";
+ assert regex.matcher("/with space.properties").matches();
+ assert !regex.matcher("subdir/any.properties").matches();
+ assert !regex.matcher("/any.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("?.properties", ".\\.properties", "a.properties");
+ assert !regex.matcher("aXproperties").matches() : "should not have matched, is the . escaped?";
+ assert !regex.matcher("ab.properties").matches();
+ assert regex.matcher(" .properties").matches();
+ assert !regex.matcher(".properties").matches();
+ assert !regex.matcher("subdir/a.properties").matches();
+ assert !regex.matcher("a.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("a?b.properties", "a.b\\.properties", "aNb.properties");
+ assert !regex.matcher("aNbXproperties").matches() : "should not have matched, is the . escaped?";
+ assert regex.matcher("a b.properties").matches();
+ assert !regex.matcher("ab.properties").matches();
+ assert !regex.matcher("subdir/aNb.properties").matches();
+ assert !regex.matcher("aNb.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("/?.properties", "/.\\.properties", "/a.properties");
+ assert !regex.matcher("/aXproperties").matches() : "should not have matched, is the . escaped?";
+ assert !regex.matcher("/ab.properties").matches();
+ assert regex.matcher("/ .properties").matches();
+ assert !regex.matcher("/.properties").matches();
+ assert !regex.matcher("subdir/a.properties").matches();
+ assert !regex.matcher("/a.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("file*.xml", "file[^/]*\\.xml", "fileANY.xml");
+ assert !regex.matcher("fileANYXxml").matches() : "should not have matched, is the . escaped?";
+ assert regex.matcher("fileWITH SPACE.xml").matches();
+ assert !regex.matcher("subdir/fileANY.xml").matches();
+ assert !regex.matcher("fileANY.xml/foo").matches();
+ assert regex.matcher("file.xml").matches();
+
+ regex = assertIncludePatternRegex("*/*.properties", "[^/]*/[^/]*\\.properties", "aaa/bbb.properties");
+ assert !regex.matcher("aaa/bbbXproperties").matches() : "should not have matched, is the . escaped?";
+ assert !regex.matcher("bbb.properties").matches();
+ assert regex.matcher("subdir1/abc.properties").matches();
+ assert !regex.matcher("subdir2/subdir1/abc.properties").matches();
+ assert !regex.matcher("subdir1/abc.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("*/*/*.properties", "[^/]*/[^/]*/[^/]*\\.properties",
+ "aaa/bbb/ccc.properties");
+ assert !regex.matcher("aaa/bbb/cccXproperties").matches() : "should not have matched, is the . escaped?";
+ assert !regex.matcher("ccc.properties").matches();
+ assert !regex.matcher("bbb/ccc.properties").matches();
+ assert !regex.matcher("toomany/aaa/bbb/ccc.properties").matches();
+ assert !regex.matcher("aaa/bbb/ccc.properties/foo").matches();
+
+ // ** = any level, including root level
+ regex = assertIncludePatternRegex("**/*.properties", ".*[^/]*\\.properties", "aaa/bbb/ccc.properties");
+ assert !regex.matcher("aaa/bbb/cccXproperties").matches() : "should not have matched, is the . escaped?";
+ assert regex.matcher("bbb.properties").matches();
+ assert regex.matcher("subdir1/abc.properties").matches();
+ assert regex.matcher("subdir2/subdir1/abc.properties").matches();
+ assert !regex.matcher("subdir1/abc.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("abc/**/*.properties", "abc/.*[^/]*\\.properties", "abc/aaa/bbb.properties");
+ assert !regex.matcher("abc/aaa/bbbXproperties").matches() : "should not have matched, is the . escaped?";
+ assert !regex.matcher("bbb.properties").matches();
+ assert regex.matcher("abc/aaa.properties").matches();
+ assert regex.matcher("abc/aaa/bbb/ccc.properties").matches();
+ assert !regex.matcher("abc/aaa/bbb/ccc.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("abc/**/xyz/*.properties", "abc/.*xyz/[^/]*\\.properties",
+ "abc/aaa/xyz/bbb.properties");
+ assert !regex.matcher("abc/aaa/xyz/bbbXproperties").matches() : "should not have matched, is the . escaped?";
+ assert !regex.matcher("bbb.properties").matches();
+ assert regex.matcher("abc/xyz/ccc.properties").matches();
+ assert regex.matcher("abc/aaa/bbb/xyz/ccc.properties").matches();
+ assert !regex.matcher("abc/aaa/bbb/xyz/ccc.properties/foo").matches();
+ }
+
+ /**
+ * @param patternToTest the include pattern to test - this is the string in the ant script like "*.properties"
+ * @param expectedRegex this is the regex pattern that we expect to result from the patternToTest
+ * @param valueToTest this is a value that should match the expectedRegex
+ * @return the compiled Pattern, for further testing by the caller
+ */
+ private Pattern assertIncludePatternRegex(String patternToTest, String expectedRegex, String valueToTest) {
+ StringBuilder regex = new StringBuilder();
+ AbstractBundleType.buildIncludePatternRegex(patternToTest, regex);
+ assert regex.toString().equals(expectedRegex) : "Tested={" + patternToTest + "}; Expected={" + expectedRegex
+ + "}; Actual={" + regex + "}";
+
+ assert Pattern.compile(regex.toString()).matcher(valueToTest).matches() : "The ExpectedRegex {" + expectedRegex
+ + "} did not match the ValueToTest {" + valueToTest + "} - this unit test does not appear valid";
+
+ return Pattern.compile(regex.toString());
+ }
+}
diff --git a/modules/common/ant-bundle/src/test/resources/file.zip b/modules/common/ant-bundle/src/test/resources/file.zip
index 922658a..969a6c1 100644
Binary files a/modules/common/ant-bundle/src/test/resources/file.zip and b/modules/common/ant-bundle/src/test/resources/file.zip differ
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-input.properties b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-input.properties
new file mode 100644
index 0000000..b66ba1d
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-input.properties
@@ -0,0 +1 @@
+listener.port = 12345
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-with-replace.xml b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-with-replace.xml
new file mode 100644
index 0000000..ea4255a
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-with-replace.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<project name="test-bundle" default="main" xmlns:rhq="antlib:org.rhq.bundle">
+
+ <rhq:bundle name="test compressed archive files" version="1.0">
+
+ <rhq:input-property name="listener.port" type="integer"/>
+
+ <rhq:deployment-unit name="appserver">
+ <rhq:archive name="file.zip" exploded="false">
+ <rhq:replace>
+ <rhq:fileset includes="**/*.foo"/>
+ <rhq:fileset includes="**/*.properties"/>
+ </rhq:replace>
+ </rhq:archive>
+ </rhq:deployment-unit>
+
+ </rhq:bundle>
+
+ <target name="main"/>
+</project>
\ No newline at end of file
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives.xml b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives.xml
new file mode 100644
index 0000000..a35b6ac
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<project name="test-bundle" default="main" xmlns:rhq="antlib:org.rhq.bundle">
+
+ <rhq:bundle name="test compressed archive files" version="1.0">
+
+ <rhq:deployment-unit name="appserver">
+ <rhq:archive name="file.zip" exploded="false"/>
+ </rhq:deployment-unit>
+
+ </rhq:bundle>
+
+ <target name="main"/>
+</project>
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
index 5116631..652bcda 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
@@ -35,6 +35,7 @@ import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -566,22 +567,76 @@ public class Deployer {
boolean dryRun) throws Exception {
// NOTE: right now, this only adds to the "realized" set of files is diff, no need to track "added" or "changed" here
-
FileHashcodeMap newFileHashCodeMap = new FileHashcodeMap();
+ // get information about the source dir - will be needed if we were told to not explode a zip
+ String sourceDirAbsPath = this.deploymentData.getSourceDir().getAbsolutePath();
+ int sourceDirLength = sourceDirAbsPath.length();
+
// extract all zip files
ExtractorZipFileVisitor visitor;
for (File zipFile : this.deploymentData.getZipFiles()) {
- debug("Extracting zip [", zipFile, "] entries. dryRun=", dryRun);
+ Boolean exploded = this.deploymentData.getZipsExploded().get(zipFile);
+ if (exploded == null) {
+ exploded = Boolean.TRUE; // the default is to explode the archive
+ }
+
+ debug("Extracting zip [", zipFile, "] entries. exploded=", exploded, ", dryRun=", dryRun);
Pattern realizeRegex = null;
if (this.deploymentData.getZipEntriesToRealizeRegex() != null) {
realizeRegex = this.deploymentData.getZipEntriesToRealizeRegex().get(zipFile);
}
- visitor = new ExtractorZipFileVisitor(this.deploymentData.getDestinationDir(), realizeRegex,
- this.deploymentData.getTemplateEngine(), currentFilesToLeaveAlone.keySet(), diff, dryRun);
- ZipUtil.walkZipFile(zipFile, visitor);
- newFileHashCodeMap.putAll(visitor.getFileHashcodeMap());
+
+ if (exploded.booleanValue()) {
+ // EXPLODED
+ visitor = new ExtractorZipFileVisitor(this.deploymentData.getDestinationDir(), realizeRegex,
+ this.deploymentData.getTemplateEngine(), currentFilesToLeaveAlone.keySet(), diff, dryRun);
+ ZipUtil.walkZipFile(zipFile, visitor);
+ newFileHashCodeMap.putAll(visitor.getFileHashcodeMap()); // exploded into individual files
+ } else {
+ // COMPRESSED
+
+ // Note: there is a requirement that all zip files must be located in the sourceDir - this is why. We need
+ // the path of the zip relative to the source dir so we can copy it to the same relative location
+ // under the destination dir. Without doing this, if the zip is in a subdirectory, we won't know where to
+ // put it under the destination dir.
+ String zipRelativePath = zipFile.getAbsolutePath().substring(sourceDirLength);
+ if (zipRelativePath.startsWith("/") || zipRelativePath.startsWith("\\")) {
+ zipRelativePath = zipRelativePath.substring(1);
+ }
+ File compressedFile = new File(this.deploymentData.getDestinationDir(), zipRelativePath);
+
+ if (this.deploymentData.getTemplateEngine() != null && realizeRegex != null) {
+ // we need to explode it to perform the realization of templatized variables
+ // TODO: can we do this in another tmp location and build the zip in the dest dir?
+ visitor = new ExtractorZipFileVisitor(this.deploymentData.getDestinationDir(), realizeRegex,
+ this.deploymentData.getTemplateEngine(), currentFilesToLeaveAlone.keySet(), diff, dryRun);
+ ZipUtil.walkZipFile(zipFile, visitor);
+ // we have to compress the file again - our new compressed file will have the new realized files in them
+ if (!dryRun) {
+ createZipFile(compressedFile, this.deploymentData.getDestinationDir(), visitor
+ .getFileHashcodeMap());
+ }
+ }
+
+ // Copy the archive to the destination dir if we need to. Generate its hashcode and add it to the new file hashcode map
+ MessageDigestGenerator hashcodeGenerator = new MessageDigestGenerator();
+ String compressedFileHashcode;
+ if (!dryRun) {
+ if (!compressedFile.exists()) {
+ if (compressedFile.getParentFile() != null) {
+ compressedFile.getParentFile().mkdirs();
+ }
+ FileUtil.copyFile(zipFile, compressedFile);
+ }
+ compressedFileHashcode = hashcodeGenerator.calcDigestString(compressedFile);
+ } else {
+ // use source zip for hash - should be the same as the would-be compressed file since we aren't realizing files in it
+ compressedFileHashcode = hashcodeGenerator.calcDigestString(zipFile);
+ }
+ newFileHashCodeMap.put(zipRelativePath, compressedFileHashcode);
+ }
}
// copy all raw files
@@ -681,6 +736,73 @@ public class Deployer {
}
/**
+ * Create a zip file by adding all the files found in the file hashcode map. The
+ * relative paths found in the map's key set are relative to the rootDir directory.
+ * The files are stored in the given zipFile.
+ *
+ * @param zipFile where to zip up all the files
+ * @param rootDir all relative file paths are relative to this root directory
+ * @param fileHashcodeMap the key set tells us all the files that need to be zipped up
+ *
+ * @throws Exception
+ */
+ private void createZipFile(File zipFile, File rootDir, FileHashcodeMap fileHashcodeMap) throws Exception {
+ if (zipFile.getParentFile() != null) {
+ zipFile.getParentFile().mkdirs();
+ }
+
+ Set<File> childrenOfRootToDelete = new HashSet<File>();
+
+ ZipOutputStream zos = null;
+ try {
+ zos = new ZipOutputStream(new FileOutputStream(zipFile));
+
+ for (String relativeFileToZip : fileHashcodeMap.keySet()) {
+ File fileToZip = new File(rootDir, relativeFileToZip);
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(fileToZip);
+ ZipEntry zipEntry = new ZipEntry(relativeFileToZip);
+ zos.putNextEntry(zipEntry);
+ StreamUtil.copy(fis, zos, false);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+
+ // Remember the location to delete it later. To speed up the deletes, we only remember
+ // the locations of the direct children under the rootDir. Since we know all zip content
+ // is located under those locations, we'll recursively delete everything under those
+ // rootDir children. We obviously can't delete everything under rootDir because there
+ // could be files in there not related to our zip file.
+ File childOfRoot = fileToZip;
+ while (childOfRoot != null) {
+ File parent = childOfRoot.getParentFile();
+ if (parent.equals(rootDir)) {
+ childrenOfRootToDelete.add(childOfRoot);
+ break;
+ } else {
+ childOfRoot = parent;
+ }
+ }
+ }
+ }
+
+ } finally {
+ if (zos != null) {
+ zos.close();
+ }
+ }
+
+ // we are done zipping up all files, delete all the individual files that are exploded that are now in the zip
+ for (File childOfRootToDelete : childrenOfRootToDelete) {
+ FileUtil.purge(childOfRootToDelete, true);
+ }
+
+ return;
+ }
+
+ /**
* Performs in-memory-only calculations to determine where new files would go and what
* their new hashcodes would be.
*
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
index b1fac47..e81fbaa 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
@@ -43,11 +43,13 @@ public class DeploymentData {
private final Set<File> zipFiles;
private final Map<File, File> rawFiles;
private final File destinationDir;
+ private final File sourceDir;
private final Map<File, Pattern> zipEntriesToRealizeRegex;
private final Set<File> rawFilesToRealize;
private final TemplateEngine templateEngine;
private final Pattern ignoreRegex;
private final boolean manageRootDir;
+ private final Map<File, Boolean> zipsExploded;
/**
* Constructors that prepares this object with the data that is necessary in order to deploy archive/file content
@@ -60,6 +62,7 @@ public class DeploymentData {
* in which case they are relative to destDir and can have subdirectories and/or a different filename
* than what the file is named currently)
* @param destinationDir the root directory where the content is to be deployed
+ * @param sourceDir the root directory where the source files (zips and raw files) are located
* @param zipEntriesToRealizeRegex the patterns of files (whose paths are relative to destDir) that
* must have replacement variables within them replaced with values
* obtained via the given template engine. The key is the name of the zip file
@@ -77,34 +80,45 @@ public class DeploymentData {
* The purpose of this is to be able to write files to an existing directory that has other
* unrelated files in it that need to remain intact. e.g. the deploy/ directory of JBossAS.
* Note: regardless of this setting, all subdirectories under the root dir will be managed.
+ * @param zipsExploded if not <code>null</code>, this is a map keyed on zip files whose values indicate
+ * if the zips should be exploded (true) or remain compressed after the deployment
+ * is finished (false). If a zip file is not found in this map, true is the default.
*/
public DeploymentData(DeploymentProperties deploymentProps, Set<File> zipFiles, Map<File, File> rawFiles,
- File destinationDir, Map<File, Pattern> zipEntriesToRealizeRegex, Set<File> rawFilesToRealize,
- TemplateEngine templateEngine, Pattern ignoreRegex, boolean manageRootDir) {
+ File sourceDir, File destinationDir, Map<File, Pattern> zipEntriesToRealizeRegex, Set<File> rawFilesToRealize,
+ TemplateEngine templateEngine, Pattern ignoreRegex, boolean manageRootDir, Map<File, Boolean> zipsExploded) {
if (deploymentProps == null) {
throw new IllegalArgumentException("deploymentProps == null");
}
if (destinationDir == null) {
- throw new IllegalArgumentException("destDir == null");
+ throw new IllegalArgumentException("destinationDir == null");
+ }
+ if (sourceDir == null) {
+ throw new IllegalArgumentException("sourceDir == null");
}
if (zipFiles == null) {
- zipFiles = new HashSet<File>();
+ zipFiles = new HashSet<File>(0);
}
if (rawFiles == null) {
- rawFiles = new HashMap<File, File>();
+ rawFiles = new HashMap<File, File>(0);
}
if ((zipFiles.size() == 0) && (rawFiles.size() == 0)) {
throw new IllegalArgumentException("zipFiles/rawFiles are empty - nothing to do");
}
+ if (zipsExploded == null) {
+ zipsExploded = new HashMap<File, Boolean>(0);
+ }
this.deploymentProps = deploymentProps;
this.zipFiles = zipFiles;
this.rawFiles = rawFiles;
this.destinationDir = destinationDir;
+ this.sourceDir = sourceDir;
this.ignoreRegex = ignoreRegex;
this.manageRootDir = manageRootDir;
+ this.zipsExploded = zipsExploded;
// if there is nothing to realize or we have no template engine to obtain replacement values, then we null things out
if (templateEngine == null || (zipEntriesToRealizeRegex == null && rawFilesToRealize == null)) {
@@ -136,6 +150,10 @@ public class DeploymentData {
return destinationDir;
}
+ public File getSourceDir() {
+ return sourceDir;
+ }
+
public Map<File, Pattern> getZipEntriesToRealizeRegex() {
return zipEntriesToRealizeRegex;
}
@@ -155,4 +173,8 @@ public class DeploymentData {
public boolean isManageRootDir() {
return manageRootDir;
}
+
+ public Map<File, Boolean> getZipsExploded() {
+ return zipsExploded;
+ }
}
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
index 5f0fca6..69d6d53 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
@@ -255,8 +255,8 @@ public class DeployerTest {
File destDir = tmpDir;
Map<File, Pattern> filesToRealizeRegex1 = new HashMap<File, Pattern>(1);
filesToRealizeRegex1.put(testZipFile1, realizeRegex);
- DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, filesToRealizeRegex1,
- null, templateEngine, ignoreRegex, true);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir,
+ filesToRealizeRegex1, null, templateEngine, ignoreRegex, true, null);
Deployer deployer = new Deployer(dd);
diff = new DeployDifferences();
@@ -291,8 +291,8 @@ public class DeployerTest {
rawFiles.put(testRawFileB, updaterBabsolute); // raw file to absolute path
Map<File, Pattern> filesToRealizeRegex2 = new HashMap<File, Pattern>(1);
filesToRealizeRegex2.put(testZipFile2, realizeRegex);
- dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, filesToRealizeRegex2, null,
- templateEngine, ignoreRegex, true);
+ dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir, filesToRealizeRegex2, null,
+ templateEngine, ignoreRegex, true, null);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -419,8 +419,8 @@ public class DeployerTest {
rawFiles = new HashMap<File, File>(2);
rawFiles.put(testRawFileA, updaterAabsolute); // source raw file to absolute path
rawFiles.put(testRawFileBChange1, updaterBabsolute); // source raw file to absolute path
- dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, filesToRealizeRegex2, null,
- templateEngine, ignoreRegex, true);
+ dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir, filesToRealizeRegex2, null,
+ templateEngine, ignoreRegex, true, null);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -459,8 +459,8 @@ public class DeployerTest {
rawFiles = new HashMap<File, File>(2);
rawFiles.put(testRawFileAChange, updaterAabsolute); // source raw file to absolute path
rawFiles.put(testRawFileBChange2, updaterBabsolute); // source raw file to absolute path
- dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, filesToRealizeRegex2, null,
- templateEngine, ignoreRegex, true);
+ dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir, filesToRealizeRegex2, null,
+ templateEngine, ignoreRegex, true, null);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -525,8 +525,8 @@ public class DeployerTest {
Pattern ignoreRegex = null;
Set<File> realizeRawFiles1 = new HashSet<File>(1);
realizeRawFiles1.add(testRawFileB);
- DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, null,
- realizeRawFiles1, templateEngine, ignoreRegex, true);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir, null,
+ realizeRawFiles1, templateEngine, ignoreRegex, true, null);
Deployer deployer = new Deployer(dd);
DeployDifferences diff = new DeployDifferences();
FileHashcodeMap map = deployer.deploy(diff);
@@ -579,8 +579,8 @@ public class DeployerTest {
realizeRawFiles1.add(testZipFile1);
realizeRawFiles1.add(testZipFile2);
realizeRawFiles1.add(testRawFileB);
- DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, null,
- realizeRawFiles1, templateEngine, ignoreRegex, true);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir, null,
+ realizeRawFiles1, templateEngine, ignoreRegex, true, null);
Deployer deployer = new Deployer(dd);
DeployDifferences listener = new DeployDifferences();
deployer.deploy(listener);
@@ -677,8 +677,8 @@ public class DeployerTest {
Map<File, Pattern> realizeRegex1 = new HashMap<File, Pattern>(1);
realizeRegex1.put(testZipFile1, filesToRealizeRegex);
- DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, realizeRegex1, null,
- templateEngine, ignoreRegex, true);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir, realizeRegex1,
+ null, templateEngine, ignoreRegex, true, null);
Deployer deployer = new Deployer(dd);
DeployDifferences listener = new DeployDifferences();
deployer.deploy(listener);
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
index 88d2731..4ef558b 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
@@ -101,8 +101,8 @@ public class ManageRootDirTest {
this.originalZipFiles = new HashSet<File>(1);
this.originalZipFiles.add(originalZipFile);
this.originalDeployProps = new DeploymentProperties(1, "simple", "1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles, null, deployDir, null, null,
- null, null, false);
+ DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles, null, tmpDir, deployDir, null,
+ null, null, null, false, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = new File(deployDir, originalFileName);
@@ -241,8 +241,8 @@ public class ManageRootDirTest {
this.originalZipFiles = new HashSet<File>(1);
this.originalZipFiles.add(originalZipFile);
this.originalDeployProps = new DeploymentProperties(1, "simple", "1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles, null, deployDir, null, null,
- null, null, false);
+ DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles, null, tmpDir, deployDir, null,
+ null, null, null, false, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
assert new File(this.deployDir, origFileName1).exists();
@@ -261,7 +261,8 @@ public class ManageRootDirTest {
new String[] { newFileName1, newFileName2 });
HashSet<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null, false);
+ dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null, null, false,
+ null);
deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap = deployer.deploy(this.diff);
assert new File(this.deployDir, newFileName1).exists();
@@ -275,8 +276,8 @@ public class ManageRootDirTest {
}
private void baseX_X_X(boolean dryRun) throws Exception {
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
- null, false);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, tmpDir, deployDir, null, null,
+ null, null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -319,8 +320,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -367,8 +368,8 @@ public class ManageRootDirTest {
String newHashcode = MessageDigestGenerator.getDigestString(newContent);
writeFile(newContent, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
- null, false);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, tmpDir, deployDir, null, null,
+ null, null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -417,8 +418,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -467,8 +468,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -531,8 +532,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -594,8 +595,8 @@ public class ManageRootDirTest {
String inTheWayHashcode = MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -650,8 +651,8 @@ public class ManageRootDirTest {
private void baseNoCurrent(boolean dryRun) throws Exception {
assert this.currentFile.delete() : "Failed to delete the current file, cannot prepare the test";
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
- null, false);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, tmpDir, deployDir, null, null,
+ null, null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -702,8 +703,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -767,8 +768,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -842,8 +843,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff); // no dry run - we need to do this to force backup file creation
@@ -883,7 +884,8 @@ public class ManageRootDirTest {
DeploymentProperties v1Duplicate = new DeploymentProperties();
v1Duplicate.putAll(this.originalDeployProps);
v1Duplicate.setDeploymentId(3); // this is the same as v1, but it needs a unique deployment ID
- dd = new DeploymentData(v1Duplicate, originalZipFiles, null, deployDir, null, null, null, null, false);
+ dd = new DeploymentData(v1Duplicate, originalZipFiles, null, tmpDir, deployDir, null, null, null, null, false,
+ null);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
@@ -933,8 +935,8 @@ public class ManageRootDirTest {
Pattern iRegex = Pattern.compile(".*ignoreSubdir.*"); // this matches the subdirectory name, thus everything under it is ignored
assert ignoredFile.exists() : "for some reason we couldn't create our test file; cannot know if clean worked";
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, iRegex,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ iRegex, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff, true, dryRun); // note: clean is true
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java
index 16275ef..6b6bcdf 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java
@@ -92,8 +92,8 @@ public class SimpleDeployerRawFileTest {
this.sourceRawFiles = new HashMap<File, File>(1);
this.sourceRawFiles.put(sourceRawFile, new File(extDir, originalFileName)); // note we name it different than the source file
this.originalDeployProps = new DeploymentProperties(1, "simple", "1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, null, sourceRawFiles, deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(originalDeployProps, null, sourceRawFiles, tmpDir, deployDir, null,
+ null, null, null, true, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = sourceRawFiles.get(sourceRawFile);
@@ -206,8 +206,8 @@ public class SimpleDeployerRawFileTest {
}
private void baseX_X_X(boolean dryRun) throws Exception {
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -249,8 +249,8 @@ public class SimpleDeployerRawFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -296,8 +296,8 @@ public class SimpleDeployerRawFileTest {
String newHashcode = MessageDigestGenerator.getDigestString(newContent);
writeFile(newContent, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -345,8 +345,8 @@ public class SimpleDeployerRawFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -394,8 +394,8 @@ public class SimpleDeployerRawFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -458,8 +458,8 @@ public class SimpleDeployerRawFileTest {
File newDestRawFile = new File(extDir, newFileName);
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -521,8 +521,8 @@ public class SimpleDeployerRawFileTest {
String inTheWayHashcode = MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -582,8 +582,8 @@ public class SimpleDeployerRawFileTest {
private void baseNoCurrent(boolean dryRun) throws Exception {
assert this.currentFile.delete() : "Failed to delete the current file, cannot prepare the test";
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -634,8 +634,8 @@ public class SimpleDeployerRawFileTest {
File newDestRawFile = new File(extDir, newFileName);
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -699,8 +699,8 @@ public class SimpleDeployerRawFileTest {
File newDestRawFile = new File(extDir, newFileName);
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -773,8 +773,8 @@ public class SimpleDeployerRawFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff); // no dry run - we need to do this to force backup file creation
@@ -813,7 +813,8 @@ public class SimpleDeployerRawFileTest {
DeploymentProperties v1Duplicate = new DeploymentProperties();
v1Duplicate.putAll(this.originalDeployProps);
v1Duplicate.setDeploymentId(3); // this is the same as v1, but it needs a unique deployment ID
- dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, deployDir, null, null, null, null, true);
+ dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, tmpDir, deployDir, null, null, null, null, true,
+ null);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java
index 5a0f842..148aa08 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java
@@ -90,8 +90,8 @@ public class SimpleDeployerRawRelativeFileTest {
this.sourceRawFiles = new HashMap<File, File>(1);
this.sourceRawFiles.put(sourceRawFile, new File(originalFileName)); // RELATIVE! note we name it different than the source file
this.originalDeployProps = new DeploymentProperties(1, "simple", "1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, null, sourceRawFiles, deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(originalDeployProps, null, sourceRawFiles, tmpDir, deployDir, null,
+ null, null, null, true, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = sourceRawFiles.get(sourceRawFile);
@@ -205,8 +205,8 @@ public class SimpleDeployerRawRelativeFileTest {
}
private void baseX_X_X(boolean dryRun) throws Exception {
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -248,8 +248,8 @@ public class SimpleDeployerRawRelativeFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -295,8 +295,8 @@ public class SimpleDeployerRawRelativeFileTest {
String newHashcode = MessageDigestGenerator.getDigestString(newContent);
writeFile(newContent, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -344,8 +344,8 @@ public class SimpleDeployerRawRelativeFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -393,8 +393,8 @@ public class SimpleDeployerRawRelativeFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -457,8 +457,8 @@ public class SimpleDeployerRawRelativeFileTest {
File newDestRawFile = new File(newFileName); // RELATIVE!
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -520,8 +520,8 @@ public class SimpleDeployerRawRelativeFileTest {
String inTheWayHashcode = MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -580,8 +580,8 @@ public class SimpleDeployerRawRelativeFileTest {
private void baseNoCurrent(boolean dryRun) throws Exception {
assert this.currentFileWithAbsolutePath.delete() : "Failed to delete the current file, cannot prepare the test";
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -632,8 +632,8 @@ public class SimpleDeployerRawRelativeFileTest {
File newDestRawFile = new File(newFileName); // RELATIVE!
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -697,8 +697,8 @@ public class SimpleDeployerRawRelativeFileTest {
File newDestRawFile = new File(newFileName); // RELATIVE!
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -771,8 +771,8 @@ public class SimpleDeployerRawRelativeFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff); // no dry run - we need to do this to force backup file creation
@@ -811,7 +811,8 @@ public class SimpleDeployerRawRelativeFileTest {
DeploymentProperties v1Duplicate = new DeploymentProperties();
v1Duplicate.putAll(this.originalDeployProps);
v1Duplicate.setDeploymentId(3); // this is the same as v1, but it needs a unique deployment ID
- dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, deployDir, null, null, null, null, true);
+ dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, tmpDir, deployDir, null, null, null, null, true,
+ null);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java
index 712a984..f875576 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java
@@ -86,8 +86,8 @@ public class SimpleDeployerTest {
this.originalZipFiles = new HashSet<File>(1);
this.originalZipFiles.add(originalZipFile);
this.originalDeployProps = new DeploymentProperties(1, "simple", "1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles, null, deployDir, null, null,
- null, null, true);
+ DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles, null, tmpDir, deployDir, null,
+ null, null, null, true, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = new File(deployDir, originalFileName);
@@ -226,8 +226,8 @@ public class SimpleDeployerTest {
this.originalZipFiles = new HashSet<File>(1);
this.originalZipFiles.add(originalZipFile);
this.originalDeployProps = new DeploymentProperties(1, "simple", "1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles, null, deployDir, null, null,
- null, null, true);
+ DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles, null, tmpDir, deployDir, null,
+ null, null, null, true, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
assert new File(this.deployDir, origFileName1).exists();
@@ -246,7 +246,8 @@ public class SimpleDeployerTest {
new String[] { newFileName1, newFileName2 });
HashSet<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null, true);
+ dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null, null, true,
+ null);
deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap = deployer.deploy(this.diff);
assert new File(this.deployDir, newFileName1).exists();
@@ -261,8 +262,8 @@ public class SimpleDeployerTest {
}
private void baseX_X_X(boolean dryRun) throws Exception {
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -304,8 +305,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -351,8 +352,8 @@ public class SimpleDeployerTest {
String newHashcode = MessageDigestGenerator.getDigestString(newContent);
writeFile(newContent, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -400,8 +401,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -449,8 +450,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -512,8 +513,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -574,8 +575,8 @@ public class SimpleDeployerTest {
String inTheWayHashcode = MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -634,8 +635,8 @@ public class SimpleDeployerTest {
private void baseNoCurrent(boolean dryRun) throws Exception {
assert this.currentFile.delete() : "Failed to delete the current file, cannot prepare the test";
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -685,8 +686,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -749,8 +750,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -823,8 +824,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff); // no dry run - we need to do this to force backup file creation
@@ -863,7 +864,8 @@ public class SimpleDeployerTest {
DeploymentProperties v1Duplicate = new DeploymentProperties();
v1Duplicate.putAll(this.originalDeployProps);
v1Duplicate.setDeploymentId(3); // this is the same as v1, but it needs a unique deployment ID
- dd = new DeploymentData(v1Duplicate, originalZipFiles, null, deployDir, null, null, null, null, true);
+ dd = new DeploymentData(v1Duplicate, originalZipFiles, null, tmpDir, deployDir, null, null, null, null, true,
+ null);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
@@ -912,8 +914,8 @@ public class SimpleDeployerTest {
Pattern iRegex = Pattern.compile(".*ignoreSubdir.*"); // this matches the subdirectory name, thus everything under it is ignored
assert ignoredFile.exists() : "for some reason we couldn't create our test file; cannot know if clean worked";
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, iRegex,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir, null, null, null,
+ iRegex, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff, true, dryRun); // note: clean is true
13 years, 4 months
[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 6 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java | 6 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 6 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java | 6 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 6 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 6 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java | 6 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java | 9 ++-------
8 files changed, 37 insertions(+), 14 deletions(-)
New commits:
commit 35b1680ff655706712cf4feecc016b05a5f0c4bf
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Dec 23 01:04:38 2010 -0500
i)fix build compilation problem
ii)update portlets to return same instance
iii)fix refresh issue with default page refresh value.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index 14e4d4f..e31ea1d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -180,9 +180,13 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ private static Portlet reference = null;
public final Portlet getInstance(String locatorId) {
- return new AutodiscoveryPortlet(locatorId);
+ if (reference == null) {
+ reference = new AutodiscoveryPortlet(locatorId);
+ }
+ return reference;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
index 40311ff..1681d58 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
@@ -107,10 +107,14 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ private static Portlet reference;
public final Portlet getInstance(String locatorId) {
//return GWT.create(FavoriteResourcesPortlet.class);
- return new FavoriteResourcesPortlet(locatorId);
+ if (reference == null) {
+ reference = new FavoriteResourcesPortlet(locatorId);
+ }
+ return reference;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index 1ebf65e..a9a801d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -531,9 +531,13 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ private static Portlet reference;
public final Portlet getInstance(String locatorId) {
- return new RecentAlertsPortlet(locatorId);
+ if (reference == null) {
+ reference = new RecentAlertsPortlet(locatorId);
+ }
+ return reference;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
index 46d376a..b80f0d3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
@@ -208,9 +208,13 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ private Portlet reference;
public final Portlet getInstance(String locatorId) {
- return new RecentlyAddedResourcesPortlet(locatorId);
+ if (reference == null) {
+ reference = new RecentlyAddedResourcesPortlet(locatorId);
+ }
+ return reference;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 4c46860..8ae6ee3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -366,9 +366,13 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ private Portlet reference;
public final Portlet getInstance(String locatorId) {
- return new OperationsPortlet(locatorId);
+ if (reference == null) {
+ reference = new OperationsPortlet(locatorId);
+ }
+ return reference;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 658257f..8c6f106 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -239,9 +239,13 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ private Portlet reference;
public final Portlet getInstance(String locatorId) {
- return new ProblemResourcesPortlet(locatorId);
+ if (reference == null) {
+ reference = new ProblemResourcesPortlet(locatorId);
+ }
+ return reference;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
index 62bcf15..adb7911 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
@@ -163,10 +163,14 @@ public class InventorySummaryPortlet extends LocatableVLayout implements AutoRef
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ private Portlet reference;
public final Portlet getInstance(String locatorId) {
// return GWT.create(InventorySummaryView.class);
- return new InventorySummaryPortlet(locatorId);
+ if (reference == null) {
+ reference = new InventorySummaryPortlet(locatorId);
+ }
+ return reference;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
index 7fde8e7..f5c936d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
@@ -75,19 +75,14 @@ public class UserPreferences {
public int getPageRefreshInterval() {
if ((getPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD) == null)
- || (Long.valueOf(getPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD)) < MeasurementUtility.MINUTES)) {
- //default to 60 seconds
+ || (Integer.valueOf(getPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD)) == 60)) {//default to 60 seconds
setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(MeasurementUtility.MINUTES));
}
return getPreferenceAsInteger(UserPreferenceNames.PAGE_REFRESH_PERIOD);
}
public void setPageRefreshInterval(int refreshInterval, AsyncCallback<Subject> callback) {
- if (refreshInterval >= MeasurementUtility.MINUTES) {
- setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(refreshInterval));
- } else {
- setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(MeasurementUtility.MINUTES));
- }
+ setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(refreshInterval));
store(callback);
}
13 years, 4 months
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 864d54670483b27c4f5d7d6996117c26c877efbf
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Dec 23 00:29:41 2010 -0500
fix compile error
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
index 8080f30..0adfdc3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
@@ -64,11 +64,11 @@ public class ResourceOperationScheduleDataSource extends OperationScheduleDataSo
throw new RuntimeException("Failed to find scheduled operations for "
+ resourceComposite.getResource() + ".", caught);
}
- });
+ });
}
@Override
protected void executeAdd(Record recordToAdd, DSRequest request, DSResponse response) {
- operationService.scheduleResourceOperation();
+ //operationService.scheduleResourceOperation();
}
}
13 years, 4 months
[rhq] 2 commits - modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SearchBarItem.java | 8 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 38 +++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java | 53 +++-------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 22 +++-
6 files changed, 73 insertions(+), 53 deletions(-)
New commits:
commit dca49573ece14274b2184a1046420e217784fa9a
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Dec 22 23:04:01 2010 -0500
initial integration of search bar contained within a smartgwt form
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SearchBarItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SearchBarItem.java
index abc0958..83793e4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SearchBarItem.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SearchBarItem.java
@@ -32,8 +32,8 @@ public class SearchBarItem extends CanvasItem {
private Canvas canvas = new Canvas();
private FlexSearchBar searchBar;
- public SearchBarItem(SearchSubsystem subsystem) {
- super("Search");
+ public SearchBarItem(String name, String title, SearchSubsystem subsystem) {
+ super(name, title);
searchBar = new FlexSearchBar();
searchBar.setSearchSubsystem(subsystem);
@@ -50,4 +50,8 @@ public class SearchBarItem extends CanvasItem {
return canvas;
}
+ public FlexSearchBar getSearchBar() {
+ return searchBar;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index a99ff5a..c569234 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.google.gwt.event.dom.client.KeyCodes;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
@@ -51,6 +52,7 @@ import com.smartgwt.client.widgets.events.DoubleClickEvent;
import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
@@ -715,9 +717,12 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
*
* @author Joseph Marques
*/
- private static class TableFilter extends DynamicForm implements KeyPressHandler, ChangedHandler {
+ private static class TableFilter extends DynamicForm implements KeyPressHandler, ChangedHandler,
+ com.google.gwt.event.dom.client.KeyPressHandler {
private Table table;
+ private SearchBarItem searchBarItem;
+ private HiddenItem hiddenItem;
public TableFilter(Table table) {
super();
@@ -728,12 +733,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
@Override
public void setItems(FormItem... items) {
- super.setItems(items);
- setupFormItems(items);
- }
-
- private void setupFormItems(FormItem... formItems) {
- for (FormItem nextFormItem : formItems) {
+ for (FormItem nextFormItem : items) {
nextFormItem.setWrapTitle(false);
nextFormItem.setWidth(300); // wider than default
if (nextFormItem instanceof TextItem) {
@@ -741,9 +741,22 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
} else if (nextFormItem instanceof SelectItem) {
nextFormItem.addChangedHandler(this);
} else if (nextFormItem instanceof SearchBarItem) {
- nextFormItem.addKeyPressHandler(this);
+ searchBarItem = (SearchBarItem) nextFormItem;
+ searchBarItem.getSearchBar().addKeyPressHandler(this);
+ String name = searchBarItem.getName();
+ searchBarItem.setName(name + "_hidden");
+ hiddenItem = new HiddenItem(name);
}
}
+
+ if (hiddenItem != null) {
+ FormItem[] tmpItems = new FormItem[items.length + 1];
+ System.arraycopy(items, 0, tmpItems, 0, items.length);
+ tmpItems[items.length] = hiddenItem;
+ items = tmpItems;
+ }
+
+ super.setItems(items);
}
private void fetchFilteredTableData() {
@@ -765,6 +778,15 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
return super.getFields().length != 0;
}
+ @Override
+ public void onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event) {
+ if (event.getCharCode() != KeyCodes.KEY_ENTER) {
+ return;
+ }
+ // TODO: figure out why this event is being sent twice
+ hiddenItem.setValue(searchBarItem.getSearchBar().getValue());
+ fetchFilteredTableData();
+ }
}
public static class TableActionInfo {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 8d0ac24..2590ea3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -164,7 +164,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
protected ResourceCriteria getFetchCriteria(final DSRequest request) {
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(getPageControl(request));
-
+ //printRequestCriteria(request);
criteria.addFilterId(getFilter(request, "id", Integer.class));
criteria.addFilterParentResourceId(getFilter(request, "parentId", Integer.class));
criteria.addFilterCurrentAvailability(getFilter(request, AVAILABILITY.propertyName(), AvailabilityType.class));
@@ -177,6 +177,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
criteria.addFilterTagNamespace(getFilter(request, "tagNamespace", String.class));
criteria.addFilterTagSemantic(getFilter(request, "tagSemantic", String.class));
criteria.addFilterTagName(getFilter(request, "tagName", String.class));
+ criteria.setSearchExpression(getFilter(request, "search", String.class));
return criteria;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
index 9e3e6eb..2284b78 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
@@ -34,11 +34,6 @@ import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.Event.NativePreviewHandler;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
@@ -94,23 +89,6 @@ public class FlexSearchBar extends AbstractSearchBar {
private String defaultSearchText;
private String defaultSavedSearchPatternId;
- private Element searchButton;
-
- public void setupButton() {
- searchButton = DOM.createButton();
- Event.addNativePreviewHandler(new NativePreviewHandler() {
- public void onPreviewNativeEvent(NativePreviewEvent event) {
- if (event.getNativeEvent() != null && event.getNativeEvent().getEventTarget() != null) {
-
- if (event.getNativeEvent().getEventTarget().equals(searchButton)
- && event.getTypeInt() == Event.ONMOUSEDOWN) {
- //prepareSearchExecution();
- }
- }
- }
- });
- }
-
HorizontalPanel sbc;
HorizontalPanel sbc_sbbgc;
HorizontalPanel sbc_sbbgc_sbcc;
@@ -143,6 +121,14 @@ public class FlexSearchBar extends AbstractSearchBar {
sbc_sbbc = createHPanel(sbc, "searchBarButtonContainer", "searchButtonContainer");
sbc_pfsc = createHPanel(sbc, null, "patternFieldSuggestionsContainer");
sbc_ssc = createHPanel(sbc, null, "savedSearchesContainer");
+
+ sbc_sbbgc_sbcc_sbclhs_pfc.add(autoCompletePatternField);
+ sbc_sbbgc_sbcc_sbcrhs_pnfc.add(patternNameField);
+ sbc_sbbgc_sbcc_sbcrhs_pnlc.add(patternNameLabel);
+ sbc_sbbgc_sbcc_sbcrhs_sic.add(starImage);
+ sbc_sbbgc_sbcc_sbcrhs_aic.add(arrowImage);
+ sbc_ssc.add(savedSearchesPanel);
+
initWidget(sbc);
savedSearchManager = new SavedSearchManager(this);
@@ -163,13 +149,6 @@ public class FlexSearchBar extends AbstractSearchBar {
}
public void onSavedSearchManagerLoaded() {
- sbc_sbbgc_sbcc_sbclhs_pfc.add(autoCompletePatternField);
- sbc_sbbgc_sbcc_sbcrhs_pnfc.add(patternNameField);
- sbc_sbbgc_sbcc_sbcrhs_pnlc.add(patternNameLabel);
- sbc_sbbgc_sbcc_sbcrhs_sic.add(starImage);
- sbc_sbbgc_sbcc_sbcrhs_aic.add(arrowImage);
- sbc_ssc.add(savedSearchesPanel);
-
setupAutoCompletingPatternField();
setupPatternNameField();
setupPatternNameLabel();
@@ -179,14 +158,12 @@ public class FlexSearchBar extends AbstractSearchBar {
if (defaultSearchText != null) {
this.autoCompletePatternField.setText(defaultSearchText);
- click(searchButton); // execute the search with this default search expression
} else if (defaultSavedSearchPatternId != null) {
try {
Integer savedSearchId = Integer.valueOf(defaultSavedSearchPatternId);
activateSavedSearch(savedSearchId);
} catch (Exception e) {
this.autoCompletePatternField.setText(MSG.view_searchBar_error_selectSavedSearch());
- click(searchButton); // execute the search, which will help to further highlight the error
}
}
@@ -475,11 +452,6 @@ public class FlexSearchBar extends AbstractSearchBar {
}
}
- private static native void click(Element button)
- /*-{
- button.click();
- }-*/;
-
public void activateSavedSearch(Integer savedSearchId) {
SavedSearch savedSearch = savedSearchManager.getSavedSearchById(savedSearchId);
if (savedSearch == null) {
@@ -505,11 +477,18 @@ public class FlexSearchBar extends AbstractSearchBar {
Log.debug("search results change: [" + savedSearch.getName() + "," + savedSearch.getPattern() + "]");
turnNameFieldIntoLabel();
savedSearchesPanel.hide();
- click(searchButton);
}
public String getSelectedTab() {
return null;
}
+ public void addKeyPressHandler(KeyPressHandler handler) {
+ autoCompletePatternField.addKeyPressHandler(handler);
+ }
+
+ public String getValue() {
+ return autoCompletePatternField.getValue();
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java
index d58197d..234d775 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java
@@ -21,7 +21,7 @@ public class TestSearchBarView extends ResourceSearchView {
final TextItem nameFilter = new TextItem(NAME.propertyName(), NAME.title());
final EnumSelectItem categoryFilter = new EnumSelectItem(CATEGORY.propertyName(), CATEGORY.title(),
ResourceCategory.class);
- final SearchBarItem searchFilter = new SearchBarItem(SearchSubsystem.RESOURCE);
+ final SearchBarItem searchFilter = new SearchBarItem("search", "Search", SearchSubsystem.RESOURCE);
setFilterFormItems(nameFilter, categoryFilter, searchFilter);
}
commit d897f1dbb0d5744c64b22c828f8f449e385b6597
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Dec 22 22:55:24 2010 -0500
more robust handling around filter parameters with multiple values
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index a7bd459..f43417f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -29,6 +29,7 @@ import java.util.Set;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.user.client.Window;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -425,7 +426,7 @@ public abstract class RPCDataSource<T> extends DataSource {
// nothing to do, result is already null
} else if (type == Integer.class) {
int[] intermediates;
- if (type.getClass().isArray()) {
+ if (isArray(value)) {
intermediates = criteria.getAttributeAsIntArray(paramName);
} else { // want array return, but only single instance of the type in the request
intermediates = new int[] { criteria.getAttributeAsInt(paramName) };
@@ -437,7 +438,7 @@ public abstract class RPCDataSource<T> extends DataSource {
}
} else if (type == String.class) {
String[] intermediates;
- if (type.getClass().isArray()) {
+ if (isArray(value)) {
intermediates = criteria.getAttributeAsStringArray(paramName);
} else { // want array return, but only single instance of the type in the request
intermediates = new String[] { criteria.getAttributeAsString(paramName) };
@@ -449,7 +450,7 @@ public abstract class RPCDataSource<T> extends DataSource {
}
} else if (type.isEnum()) {
String[] intermediates;
- if (type.getClass().isArray()) {
+ if (isArray(value)) {
intermediates = criteria.getAttributeAsStringArray(paramName);
} else { // want array return, but only single instance of the type in the request
intermediates = new String[] { criteria.getAttributeAsString(paramName) };
@@ -468,6 +469,10 @@ public abstract class RPCDataSource<T> extends DataSource {
return resultArray;
}
+ private static boolean isArray(Object value) {
+ return value.getClass().isArray() || value.getClass().equals(ArrayList.class);
+ }
+
@SuppressWarnings("unchecked")
private static <S> S[] getEnumArray(Class<S> genericEnumType, int size) {
// workaround until GWT implements reflection APIs, so we can do:
@@ -484,8 +489,17 @@ public abstract class RPCDataSource<T> extends DataSource {
}
@SuppressWarnings("unchecked")
+ public static void printRequestCriteria(DSRequest request) {
+ Criteria criteria = request.getCriteria();
+ Map<String, Object> criteriaMap = criteria.getValues();
+
+ for (Map.Entry<String, Object> nextEntry : criteriaMap.entrySet()) {
+ Window.alert(nextEntry.getKey() + ":" + nextEntry.getValue());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
public static <S> S getFilter(DSRequest request, String paramName, Class<S> type) {
- Log.debug("Fetching " + paramName + " (" + type + ")");
Criteria criteria = request.getCriteria();
Map<String, Object> criteriaMap = criteria.getValues();
13 years, 4 months
[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 19 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java | 19 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 18 +++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java | 19 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 19 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 18 +++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java | 19 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java | 10 ++++-
8 files changed, 83 insertions(+), 58 deletions(-)
New commits:
commit 682db9a8bd03ebedab669fc02147c2bc46e7ff23
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Dec 22 17:06:00 2010 -0500
fix refresh issue.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index 74ce25c..14e4d4f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -197,13 +198,15 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
if (defaultReloader != null) {
defaultReloader.cancel();
}
- defaultReloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- defaultReloader.schedule(retrievedRefreshInterval);
- }
- };
- defaultReloader.schedule(retrievedRefreshInterval);
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
index f7cbcdc..40311ff 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
/**
* @author Greg Hinkle
@@ -121,13 +122,15 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto
if (defaultReloader != null) {
defaultReloader.cancel();
}
- defaultReloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- defaultReloader.schedule(retrievedRefreshInterval);
- }
- };
- defaultReloader.schedule(retrievedRefreshInterval);
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index 024adb3..1ebf65e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -545,14 +545,16 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti
if (defaultReloader != null) {
defaultReloader.cancel();
}
- defaultReloader = new Timer() {
- public void run() {
- refresh();
- //launch again until portlet reference and child references GC.
- defaultReloader.schedule(retrievedRefreshInterval);
- }
- };
- defaultReloader.schedule(retrievedRefreshInterval);
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ defaultReloader = new Timer() {
+ public void run() {
+ refresh();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
index 30c9b4e..46d376a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
@@ -44,6 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements CustomSettingsPortlet,
@@ -236,13 +237,15 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C
if (defaultReloader != null) {
defaultReloader.cancel();
}
- defaultReloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- defaultReloader.schedule(retrievedRefreshInterval);
- }
- };
- defaultReloader.schedule(retrievedRefreshInterval);
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 507c8ed..4c46860 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
@@ -424,13 +425,15 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
if (defaultReloader != null) {
defaultReloader.cancel();
}
- defaultReloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- defaultReloader.schedule(retrievedRefreshInterval);
- }
- };
- defaultReloader.schedule(retrievedRefreshInterval);
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index fddbfa1..658257f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -298,14 +298,16 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
if (defaultReloader != null) {
defaultReloader.cancel();
}
- defaultReloader = new Timer() {
- public void run() {
- refresh();
- //launch again until portlet reference and child references GC.
- defaultReloader.schedule(retrievedRefreshInterval);
- }
- };
- defaultReloader.schedule(retrievedRefreshInterval);
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ defaultReloader = new Timer() {
+ public void run() {
+ refresh();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
index 6b70298..62bcf15 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -177,13 +178,15 @@ public class InventorySummaryPortlet extends LocatableVLayout implements AutoRef
if (defaultReloader != null) {
defaultReloader.cancel();
}
- defaultReloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- defaultReloader.schedule(retrievedRefreshInterval);
- }
- };
- defaultReloader.schedule(retrievedRefreshInterval);
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
index 1c311b0..7fde8e7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
@@ -74,14 +74,20 @@ public class UserPreferences {
}
public int getPageRefreshInterval() {
- if (getPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD) == null) {//default to 60 seconds
+ if ((getPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD) == null)
+ || (Long.valueOf(getPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD)) < MeasurementUtility.MINUTES)) {
+ //default to 60 seconds
setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(MeasurementUtility.MINUTES));
}
return getPreferenceAsInteger(UserPreferenceNames.PAGE_REFRESH_PERIOD);
}
public void setPageRefreshInterval(int refreshInterval, AsyncCallback<Subject> callback) {
- setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(refreshInterval));
+ if (refreshInterval >= MeasurementUtility.MINUTES) {
+ setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(refreshInterval));
+ } else {
+ setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(MeasurementUtility.MINUTES));
+ }
store(callback);
}
13 years, 4 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 96 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java | 316 ++++++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/CanvasUtility.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 45 +
6 files changed, 378 insertions(+), 110 deletions(-)
New commits:
commit 51864e3db11b09ee8fb6bed6d16dd1322e3f6c25
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Dec 22 16:27:01 2010 -0500
finish up calendar mode of schedule editor widget functionality-wise; start on new SLSB method for scheduling an operation that takes a ResourceOperationSchedule as a param
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index c2e2626..45bf782 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -24,7 +24,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -87,7 +86,6 @@ import com.smartgwt.client.widgets.grid.events.CellSavedHandler;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import com.smartgwt.client.widgets.layout.VLayout;
@@ -123,7 +121,6 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.CanvasUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -166,7 +163,6 @@ public class ConfigurationEditor extends LocatableVLayout {
private int resourceId;
private int resourceTypeId;
private ConfigType configType;
- private IButton saveButton;
private boolean readOnly = false;
private Set<String> invalidPropertyNames = new HashSet<String>();
@@ -361,61 +357,50 @@ public class ConfigurationEditor extends LocatableVLayout {
sectionStack.addSection(buildGroupSection(layout.extendLocatorId(definition.getName()), definition));
}
- toolStrip = new LocatableToolStrip(layout.extendLocatorId("Tools"));
- toolStrip.setBackgroundImage(null);
- toolStrip.setWidth100();
+ this.toolStrip = buildToolStrip(layout, sectionStack);
+ layout.addMember(toolStrip);
+ layout.addMember(sectionStack);
+ }
- toolStrip.addMember(new LayoutSpacer());
- saveButton = new LocatableIButton(toolStrip.extendLocatorId("Save"), MSG.common_button_save());
- saveButton.setAlign(Alignment.CENTER);
- saveButton.setDisabled(true);
- //toolStrip.addMember(saveButton);
+ return layout;
+ }
- IButton resetButton = new LocatableIButton(toolStrip.extendLocatorId("Reset"), MSG.common_button_reset());
- resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- reload();
- }
- });
- //toolStrip.addMember(resetButton);
-
- toolStrip.addMember(new LayoutSpacer());
-
- Menu menu = new LocatableMenu(toolStrip.extendLocatorId("JumpMenu"));
- for (SectionStackSection section : sectionStack.getSections()) {
- MenuItem item = new MenuItem(section.getTitle());
- item.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- int x = event.getMenu().getItemNum(event.getItem());
- sectionStack.expandSection(x);
- sectionStack.showSection(x);
- }
- });
- menu.addItem(item);
- }
- menu.addItem(new MenuItemSeparator());
+ private LocatableToolStrip buildToolStrip(LocatableVLayout layout, final SectionStack sectionStack) {
+ LocatableToolStrip toolStrip = new LocatableToolStrip(layout.extendLocatorId("Tools"));
+ toolStrip.setBackgroundImage(null);
+ toolStrip.setWidth100();
- MenuItem hideAllItem = new MenuItem(MSG.view_configEdit_hideAll());
- hideAllItem.addClickHandler(new ClickHandler() {
+ Menu menu = new LocatableMenu(toolStrip.extendLocatorId("JumpMenu"));
+ for (SectionStackSection section : sectionStack.getSections()) {
+ MenuItem item = new MenuItem(section.getTitle());
+ item.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- for (int i = 0; i < sectionStack.getSections().length; i++) {
- sectionStack.collapseSection(i);
- }
+ int x = event.getMenu().getItemNum(event.getItem());
+ sectionStack.expandSection(x);
+ sectionStack.showSection(x);
}
});
- menu.addItem(hideAllItem);
+ menu.addItem(item);
+ }
+ menu.addItem(new MenuItemSeparator());
- // TODO GH: Save button as saveListener() or remove the buttons from this form and have
- // the container provide them?
+ MenuItem hideAllItem = new MenuItem(MSG.view_configEdit_hideAll());
+ hideAllItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ for (int i = 0; i < sectionStack.getSections().length; i++) {
+ sectionStack.collapseSection(i);
+ }
+ }
+ });
+ menu.addItem(hideAllItem);
- toolStrip.addMember(new LocatableIMenuButton(toolStrip.extendLocatorId("Jump"), MSG
- .view_configEdit_jumpToSection(), menu));
+ // TODO GH: Save button as saveListener() or remove the buttons from this form and have
+ // the container provide them?
- layout.addMember(toolStrip);
- layout.addMember(sectionStack);
- }
+ toolStrip.addMember(new LocatableIMenuButton(toolStrip.extendLocatorId("Jump"), MSG
+ .view_configEdit_jumpToSection(), menu));
- return layout;
+ return toolStrip;
}
public SectionStackSection buildGroupSection(String locatorId, PropertyGroupDefinition group) {
@@ -451,17 +436,6 @@ public class ConfigurationEditor extends LocatableVLayout {
form.setValuesManager(valuesManager);
form.setValidateOnExit(true);
form.setHiliteRequiredFields(true);
-
- form.addItemChangedHandler(new ItemChangedHandler() {
- public void onItemChanged(ItemChangedEvent itemChangedEvent) {
- if (!changed) {
- changed = true;
- CanvasUtility.blink(saveButton);
- saveButton.setDisabled(false);
- }
- }
- });
-
form.setNumCols(4);
form.setCellPadding(5);
form.setColWidths(190, 28, 210);
@@ -1123,7 +1097,6 @@ public class ConfigurationEditor extends LocatableVLayout {
final IButton okButton = new LocatableIButton(extendLocatorId("OK"), MSG.common_button_ok());
okButton.disable();
- // saveButton.setID("config_structured_button_save");
okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
propertyList.add(newMemberPropertySimple);
@@ -1469,7 +1442,6 @@ public class ConfigurationEditor extends LocatableVLayout {
final IButton okButton = new LocatableIButton(extendLocatorId("OK"), MSG.common_button_ok());
okButton.disable();
- // saveButton.setID("config_structured_button_save");
okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
if (newRow) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
index 5684067..fc9aef4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
@@ -20,8 +20,11 @@
package org.rhq.enterprise.gui.coregui.client.components.trigger;
import java.util.Date;
+import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.Map;
+import com.smartgwt.client.types.Visibility;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.DateTimeItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
@@ -47,8 +50,47 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class JobTriggerEditor extends LocatableVLayout {
+ private static final String FIELD_REPEAT_INTERVAL = "repeatInterval";
+ private static final String FIELD_REPEAT_DURATION = "repeatDuration";
+ private static final String FIELD_END_TIME = "endTime";
+
+ private static final Map<String, Long> UNITS_TO_MILLIS_MULTIPLIER_MAP = new HashMap();
+ static {
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("seconds", 1000L);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("s", 1000L);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("minutes", 1000L * 60);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("m", 1000L * 60);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("hours", 1000L * 60 * 60);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("h", 1000L * 60 * 60);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("days", 1000L * 60 * 60 * 24);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("d", 1000L * 60 * 60 * 24);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("weeks", 1000L * 60 * 60 * 24 * 7);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("w", 1000L * 60 * 60 * 24 * 7);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("months", 1000L * 60 * 60 * 24 * 7 * 30);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("M", 1000L * 60 * 60 * 24 * 7 * 30);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("quarters", 1000L * 60 * 60 * 24 * 7 * 90);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("q", 1000L * 60 * 60 * 24 * 7 * 90);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("years", 1000L * 60 * 60 * 24 * 7 * 30 * 365);
+ UNITS_TO_MILLIS_MULTIPLIER_MAP.put("y", 1000L * 60 * 60 * 24 * 7 * 30 * 365);
+ }
+
private boolean isReadOnly;
- private boolean isValid;
+
+ private DynamicForm laterForm;
+ private DynamicForm repeatForm;
+
+ // These flags allow us to determine the trigger type.
+ private boolean isCronMode;
+ private boolean isStartLater;
+ private boolean isRecurring;
+ private boolean isRepeatDuration;
+ private boolean isEndTime;
+ private boolean isStartDelay;
+ private boolean isStartTime;
+ private static final String FIELD_START_TYPE = "startType";
+ private static final String FIELD_START_TIME = "startTime";
+ private static final String FIELD_START_DELAY = "startDelay";
+ private static final String FIELD_RECURRENCE_TYPE = "recurrenceType";
/**
* Create a new job trigger.
@@ -111,70 +153,81 @@ public class JobTriggerEditor extends LocatableVLayout {
modeItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
if (event.getValue().equals("calendar")) {
- calendarTypeForm.show();
+ JobTriggerEditor.this.isCronMode = false;
+ calendarTypeForm.show();
}
}
});
- final DynamicForm laterForm = createLaterForm();
- addMember(laterForm);
+ this.laterForm = createLaterForm();
+ addMember(this.laterForm);
- final DynamicForm repeatForm = createRepeatForm();
- addMember(repeatForm);
+ this.repeatForm = createRepeatForm();
+ addMember(this.repeatForm);
calendarTypeItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
String value = (String)event.getValue();
if (value.equals("now")) {
- isValid = true;
+ JobTriggerEditor.this.isStartLater = false;
+ JobTriggerEditor.this.isRecurring = false;
} else if (value.equals("nowAndRepeat")) {
- laterForm.hide();
- FormItem repeatIntervalItem = repeatForm.getItem("repeatInterval");
+ JobTriggerEditor.this.isStartLater = false;
+ JobTriggerEditor.this.isRecurring = true;
+
+ FormItem repeatIntervalItem = repeatForm.getItem(FIELD_REPEAT_INTERVAL);
repeatIntervalItem.setTitle("Run now and every");
repeatIntervalItem.redraw();
- repeatForm.show();
} else if (value.equals("later")) {
- repeatForm.hide();
- laterForm.show();
+ JobTriggerEditor.this.isStartLater = true;
+ JobTriggerEditor.this.isRecurring = false;
} else {
- // later and repeat
- laterForm.show();
- FormItem repeatIntervalItem = repeatForm.getItem("repeatInterval");
+ // value.equals("laterAndRepeat")
+ JobTriggerEditor.this.isStartLater = true;
+ JobTriggerEditor.this.isRecurring = true;
+
+ FormItem repeatIntervalItem = repeatForm.getItem(FIELD_REPEAT_INTERVAL);
repeatIntervalItem.setTitle("Repeat every");
repeatIntervalItem.redraw();
- repeatForm.show();
}
+ laterForm.setVisibility(JobTriggerEditor.this.isStartLater ? Visibility.VISIBLE : Visibility.HIDDEN);
+ repeatForm.setVisibility(JobTriggerEditor.this.isRecurring ? Visibility.VISIBLE : Visibility.HIDDEN);
}
});
}
private DynamicForm createRepeatForm() {
- final DynamicForm nowAndRepeatForm = new DynamicForm();
- nowAndRepeatForm.setNumCols(6);
- nowAndRepeatForm.setColWidths(130, 130, 130, 130, 130);
+ final DynamicForm repeatForm = new DynamicForm();
+ repeatForm.setNumCols(6);
+ repeatForm.setColWidths(130, 130, 130, 130, 130);
- TextItem repeatIntervalItem = new TextItem("repeatInterval", "Run now and every");
+ TextItem repeatIntervalItem = new TextItem(FIELD_REPEAT_INTERVAL, "Run now and every");
+ repeatIntervalItem.setRequired(true);
// Configure hint.
- repeatIntervalItem.setHint("[1-9][0-9]* (seconds|minutes|hours|days|weeks|months|quarters|years)");
+ repeatIntervalItem.setHint("N UNITS (where N is a positive integer and UNITS is \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"6 weeks\")");
repeatIntervalItem.setShowHint(false);
repeatIntervalItem.addFocusHandler(new FocusHandler() {
public void onFocus(FocusEvent event) {
+ repeatForm.setColWidths(130, 400, 130, 130, 130);
event.getItem().setShowHint(true);
+ repeatForm.markForRedraw();
}
});
repeatIntervalItem.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
- event.getItem().setShowHint(false);
+ repeatForm.setColWidths(130, 130, 130, 130, 130);
+ event.getItem().setShowHint(false);
+ repeatForm.markForRedraw();
}
});
// Configure validation.
- RegExpValidator repeatIntervalValidator = new RegExpValidator("[1-9][0-9]*[ ]+(seconds|minutes|hours|days|weeks|months|quarters|years)");
+ RegExpValidator repeatIntervalValidator = new RegExpValidator("[1-9][0-9]*[ ]*(seconds|s|minutes|m|hours|h|days|d|weeks|w|months|M|quarters|q|years|y)");
repeatIntervalItem.setValidators(repeatIntervalValidator);
repeatIntervalItem.setValidateOnExit(true);
- RadioGroupItem recurrenceTypeItem = new RadioGroupItem("recurrenceType");
+ RadioGroupItem recurrenceTypeItem = new RadioGroupItem(FIELD_RECURRENCE_TYPE);
recurrenceTypeItem.setShowTitle(false);
LinkedHashMap<String, String> recurrenceTypeValueMap = new LinkedHashMap<String, String>();
recurrenceTypeValueMap.put("for", "For");
@@ -182,31 +235,34 @@ public class JobTriggerEditor extends LocatableVLayout {
recurrenceTypeValueMap.put("indefinitely", "Indefinitely");
recurrenceTypeItem.setValueMap(recurrenceTypeValueMap);
- final TextItem repeatDurationItem = new TextItem("repeatDuration");
+ final TextItem repeatDurationItem = new TextItem(FIELD_REPEAT_DURATION);
repeatDurationItem.setShowTitle(false);
repeatDurationItem.setVisible(false);
// Configure hint.
- repeatDurationItem.setHint("[1-9][0-9]* (repetitions|seconds|minutes|hours|days|weeks|months|quarters|years)");
+ repeatDurationItem.setHint("N UNITS (where N is a positive integer and UNITS is \"times\", \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"5 repetitions\")");
repeatDurationItem.setShowHint(false);
repeatDurationItem.addFocusHandler(new FocusHandler() {
public void onFocus(FocusEvent event) {
+ repeatForm.setColWidths(130, 130, 400, 130, 130);
event.getItem().setShowHint(true);
+ repeatForm.markForRedraw();
}
});
repeatDurationItem.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
+ repeatForm.setColWidths(130, 130, 130, 130, 130);
event.getItem().setShowHint(false);
+ repeatForm.markForRedraw();
}
});
// Configure validation.
- RegExpValidator repeatDurationValidator = new RegExpValidator("[1-9][0-9]*[ ]+(repetitions|seconds|minutes|hours|days|weeks|months|quarters|years)");
+ RegExpValidator repeatDurationValidator = new RegExpValidator("[1-9][0-9]*[ ]*(times|repetitions|seconds|s|minutes|m|hours|h|days|d|weeks|w|months|M|quarters|q|years|y)");
repeatDurationItem.setValidators(repeatDurationValidator);
repeatDurationItem.setValidateOnExit(true);
-
- final DateTimeItem endTimeItem = createDateTimeItem("endTime");
+ final DateTimeItem endTimeItem = createDateTimeItem(FIELD_END_TIME);
endTimeItem.setShowTitle(false);
endTimeItem.setVisible(false);
@@ -216,22 +272,36 @@ public class JobTriggerEditor extends LocatableVLayout {
public void onChanged(ChangedEvent event) {
String value = (String)event.getValue();
if (value.equals("for")) {
- endTimeItem.hide();
- repeatDurationItem.show();
+ JobTriggerEditor.this.isEndTime = false;
+ JobTriggerEditor.this.isRepeatDuration = true;
} else if (value.equals("until")) {
- repeatDurationItem.hide();
+ JobTriggerEditor.this.isEndTime = true;
+ JobTriggerEditor.this.isRepeatDuration = false;
+ } else {
+ // indefinite
+ JobTriggerEditor.this.isEndTime = false;
+ JobTriggerEditor.this.isRepeatDuration = false;
+ }
+
+ endTimeItem.setRequired(JobTriggerEditor.this.isEndTime);
+ if (JobTriggerEditor.this.isEndTime) {
endTimeItem.show();
} else {
- repeatDurationItem.hide();
endTimeItem.hide();
}
+ repeatDurationItem.setRequired(JobTriggerEditor.this.isRepeatDuration);
+ if (JobTriggerEditor.this.isRepeatDuration) {
+ repeatDurationItem.show();
+ } else {
+ repeatDurationItem.hide();
+ }
}
});
- nowAndRepeatForm.setFields(repeatIntervalItem, recurrenceTypeItem, repeatDurationItem, endTimeItem, spacerItem);
- nowAndRepeatForm.setVisible(false);
+ repeatForm.setFields(repeatIntervalItem, recurrenceTypeItem, repeatDurationItem, endTimeItem, spacerItem);
+ repeatForm.setVisible(false);
- return nowAndRepeatForm;
+ return repeatForm;
}
private DynamicForm createLaterForm() {
@@ -239,34 +309,38 @@ public class JobTriggerEditor extends LocatableVLayout {
laterForm.setNumCols(4);
laterForm.setColWidths(130, 130, 130);
- RadioGroupItem startTypeItem = new RadioGroupItem("startType", "Run");
+ RadioGroupItem startTypeItem = new RadioGroupItem(FIELD_START_TYPE, "Run");
LinkedHashMap<String, String> startTypeValueMap = new LinkedHashMap<String, String>();
startTypeValueMap.put("on", "on");
startTypeValueMap.put("in", "in");
startTypeItem.setValueMap(startTypeValueMap);
- final DateTimeItem startTimeItem = createDateTimeItem("startTime");
+ final DateTimeItem startTimeItem = createDateTimeItem(FIELD_START_TIME);
- final TextItem startDelayItem = new TextItem("startDelay");
+ final TextItem startDelayItem = new TextItem(FIELD_START_DELAY);
startDelayItem.setShowTitle(false);
startDelayItem.setVisible(false);
// Configure hint.
- startDelayItem.setHint("[1-9][0-9]* (seconds|minutes|hours|days|weeks|months|quarters|years)");
+ startDelayItem.setHint("N UNITS (where N is a positive integer and UNITS is \"seconds\", \"minutes\", \"hours\", \"days\", \"weeks\", \"months\", \"quarters\", or \"years\", e.g. \"30 seconds\" or \"6 weeks\")");
startDelayItem.setShowHint(false);
startDelayItem.addFocusHandler(new FocusHandler() {
public void onFocus(FocusEvent event) {
+ laterForm.setColWidths(130, 130, 400);
event.getItem().setShowHint(true);
+ laterForm.markForRedraw();
}
});
startDelayItem.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
+ laterForm.setColWidths(130, 130, 130);
event.getItem().setShowHint(false);
+ laterForm.markForRedraw();
}
});
// Configure validation.
- RegExpValidator startDelayValidator = new RegExpValidator("[1-9][0-9]*[ ]+(seconds|minutes|hours|days|weeks|months|quarters|years)");
+ RegExpValidator startDelayValidator = new RegExpValidator("[1-9][0-9]*([ ]+(seconds|minutes|hours|days|weeks|months|quarters|years)|(s|m|h|d|w|M|q|y))");
startDelayItem.setValidators(startDelayValidator);
startDelayItem.setValidateOnExit(true);
@@ -276,11 +350,24 @@ public class JobTriggerEditor extends LocatableVLayout {
public void onChanged(ChangedEvent event) {
String value = (String)event.getValue();
if (value.equals("on")) {
+ JobTriggerEditor.this.isStartDelay = false;
+ JobTriggerEditor.this.isStartTime = true;
+ } else {
+ // value.equals("in")
+ JobTriggerEditor.this.isStartDelay = true;
+ JobTriggerEditor.this.isStartTime = false;
+ }
+ startDelayItem.setRequired(JobTriggerEditor.this.isStartDelay);
+ if (JobTriggerEditor.this.isStartDelay) {
+ startDelayItem.show();
+ } else {
startDelayItem.hide();
+ }
+ startTimeItem.setRequired(JobTriggerEditor.this.isStartTime);
+ if (JobTriggerEditor.this.isStartTime) {
startTimeItem.show();
} else {
startTimeItem.hide();
- startDelayItem.show();
}
}
});
@@ -291,6 +378,139 @@ public class JobTriggerEditor extends LocatableVLayout {
return laterForm;
}
+ public JobTrigger getJobTrigger() throws Exception {
+ JobTrigger jobTrigger = null;
+
+ if (this.isCronMode) {
+ // TODO
+ } else {
+ // calendar mode
+
+ // Validate first.
+ boolean isValid = true;
+ if (this.isStartLater) {
+ isValid = isValid && this.laterForm.validate();
+ }
+ if (this.isRecurring) {
+ isValid = isValid && this.repeatForm.validate();
+ }
+ if (!isValid) {
+ throw new Exception("The specified schedule is not valid.");
+ }
+
+ if (this.isStartLater) {
+ Date startDate;
+ if (this.isStartDelay) {
+ // start delay - computer start time
+ String startDelay = this.laterForm.getValueAsString(FIELD_START_DELAY);
+ Duration startDelayDuration = parseDurationString(startDelay);
+ long delay = startDelayDuration.count * startDelayDuration.multiplier;
+ long startTime = System.currentTimeMillis() + delay;
+ startDate = new Date(startTime);
+ } else {
+ // start time
+ DateTimeItem startTimeItem = (DateTimeItem)this.laterForm.getField(FIELD_START_TIME);
+ startDate = startTimeItem.getValueAsDate();
+ }
+
+ if (this.isRecurring) {
+ // LATER AND REPEAT
+
+ String repeatInterval = this.repeatForm.getValueAsString(FIELD_REPEAT_INTERVAL);
+ Duration intervalDuration = parseDurationString(repeatInterval);
+ long intervalMillis = intervalDuration.count * intervalDuration.multiplier;
+
+ if (this.isRepeatDuration) {
+ String repeatDurationString = this.repeatForm.getValueAsString(FIELD_REPEAT_DURATION);
+ Duration repeatDuration = parseDurationString(repeatDurationString);
+ if (repeatDuration.multiplier == null) {
+ // n repetitions
+ int repetitions = repeatDuration.count;
+ jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startDate, intervalMillis, repetitions);
+ } else {
+ // n units of time - compute end time
+ long delay = repeatDuration.count * repeatDuration.multiplier;
+ long endTime = System.currentTimeMillis() + delay;
+ Date endDate = new Date(endTime);
+ jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startDate, intervalMillis, endDate);
+ }
+ } else if (this.isEndTime) {
+ DateTimeItem endTimeItem = (DateTimeItem)this.repeatForm.getField(FIELD_END_TIME);
+ Date endDate = endTimeItem.getValueAsDate();
+ jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startDate, intervalMillis, endDate);
+ }
+ } else {
+ // LATER
+
+ jobTrigger = JobTrigger.createLaterTrigger(startDate);
+ }
+ } else {
+ if (this.isRecurring) {
+ // NOW AND REPEAT
+
+ String repeatInterval = this.repeatForm.getValueAsString(FIELD_REPEAT_INTERVAL);
+ Duration intervalDuration = parseDurationString(repeatInterval);
+ long intervalMillis = intervalDuration.count * intervalDuration.multiplier;
+
+ if (this.isRepeatDuration) {
+ String repeatDurationString = this.repeatForm.getValueAsString(FIELD_REPEAT_DURATION);
+ Duration repeatDuration = parseDurationString(repeatDurationString);
+ if (repeatDuration.multiplier == null) {
+ // n repetitions
+ int repetitions = repeatDuration.count;
+ jobTrigger = JobTrigger.createNowAndRepeatTrigger(intervalMillis, repetitions);
+ } else {
+ // n units of time - compute end time
+ long delay = repeatDuration.count * repeatDuration.multiplier;
+ long endTime = System.currentTimeMillis() + delay;
+ Date endDate = new Date(endTime);
+ jobTrigger = JobTrigger.createNowAndRepeatTrigger(intervalMillis, endDate);
+ }
+ } else if (this.isEndTime) {
+ DateTimeItem endTimeItem = (DateTimeItem)this.repeatForm.getField(FIELD_END_TIME);
+ Date endDate = endTimeItem.getValueAsDate();
+ jobTrigger = JobTrigger.createNowAndRepeatTrigger(intervalMillis, endDate);
+ }
+ } else {
+ // NOW
+
+ jobTrigger = JobTrigger.createNowTrigger();
+ }
+ }
+ }
+
+ return jobTrigger;
+ }
+
+ private static Duration parseDurationString(String durationString) {
+ String countString = "";
+ int index;
+ for (index = 0; index < durationString.length(); index++) {
+ char c = durationString.charAt(index);
+ if (Character.isDigit(c)) {
+ countString += c;
+ } else {
+ break;
+ }
+ }
+ int count = Integer.valueOf(countString);
+
+ // Skip optional whitespace.
+ while (index < durationString.length()) {
+ char c = durationString.charAt(index);
+ if (c != ' ') {
+ break;
+ }
+ index++;
+ }
+
+ String units = durationString.substring(index);
+ Long multiplier = UNITS_TO_MILLIS_MULTIPLIER_MAP.get(units.toLowerCase());
+
+ return new Duration(count, multiplier);
+ }
+
+
private static DateTimeItem createDateTimeItem(String name) {
final DateTimeItem dateTimeItem = new DateTimeItem(name);
dateTimeItem.setEnforceDate(true);
@@ -307,8 +527,14 @@ public class JobTriggerEditor extends LocatableVLayout {
return isReadOnly;
}
- public boolean isValid() {
- return isValid;
+ private static class Duration {
+ public int count;
+ // a null multiplier means the count refers repetitions, rather than units of time
+ public Long multiplier;
+
+ private Duration(int count, Long multiplier) {
+ this.count = count;
+ this.multiplier = multiplier;
+ }
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
index 6da2ec5..1a87bd3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
@@ -33,17 +33,20 @@ import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.form.AbstractRecordEditor;
import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
import org.rhq.enterprise.gui.coregui.client.components.trigger.JobTriggerEditor;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -63,6 +66,7 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
private StaticTextItem operationDescriptionItem;
private StaticTextItem operationParametersItem;
private LocatableHLayout operationParametersConfigurationHolder;
+ private JobTriggerEditor triggerEditor;
public ResourceOperationScheduleDetailsView(String locatorId, ResourceComposite resourceComposite, int scheduleId) {
super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite), scheduleId, "Scheduled Operation", null);
@@ -117,8 +121,8 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
contentPane.addMember(this.operationParametersConfigurationHolder);
if (isNewRecord()) {
- JobTriggerEditor triggerEditor = new JobTriggerEditor(extendLocatorId("TriggerEditor"));
- contentPane.addMember(triggerEditor);
+ this.triggerEditor = new JobTriggerEditor(extendLocatorId("TriggerEditor"));
+ contentPane.addMember(this.triggerEditor);
}
EnhancedDynamicForm notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"), isReadOnly(),
@@ -144,6 +148,21 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
return ResourceOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
}
+ @Override
+ protected void save() {
+ try {
+ JobTrigger trigger = this.triggerEditor.getJobTrigger();
+ System.out.println(trigger);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ CoreGUI.getMessageCenter().notify(new Message(e.getMessage(), Message.Severity.Warning));
+ return;
+ }
+
+ super.save();
+ }
+
private void refreshOperationDescriptionItem() {
String operationName = this.operationNameItem.getValueAsString();
String value;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
index 6e9c744..8080f30 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
@@ -67,4 +67,8 @@ public class ResourceOperationScheduleDataSource extends OperationScheduleDataSo
});
}
+ @Override
+ protected void executeAdd(Record recordToAdd, DSRequest request, DSResponse response) {
+ operationService.scheduleResourceOperation();
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/CanvasUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/CanvasUtility.java
index ef37367..5e1e6c0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/CanvasUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/CanvasUtility.java
@@ -27,7 +27,9 @@ import com.smartgwt.client.widgets.Canvas;
public class CanvasUtility {
public static void blink(Canvas canvas) {
- canvas.animateFade(10, new FadeAnimationCallback(3,canvas,false));
+ if (canvas != null) {
+ canvas.animateFade(10, new FadeAnimationCallback(3, canvas, false));
+ }
}
private static class FadeAnimationCallback implements AnimationCallback {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
index b54dc27..3c71dd4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.operation;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -165,6 +166,18 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
+ public ResourceOperationSchedule scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule)
+ throws ScheduleException {
+ JobTrigger jobTrigger = schedule.getJobTrigger();
+ Trigger trigger = convertToTrigger(jobTrigger);
+ try {
+ return scheduleResourceOperation(subject, schedule.getResource().getId(), schedule.getOperationName(), schedule.getParameters(), trigger, schedule.getDescription());
+ }
+ catch (SchedulerException e) {
+ throw new ScheduleException(e);
+ }
+ }
+
public ResourceOperationSchedule scheduleResourceOperation(Subject subject, int resourceId, String operationName,
Configuration parameters, Trigger trigger, String notes) throws SchedulerException {
Resource resource = getResourceIfAuthorized(subject, resourceId);
@@ -1943,4 +1956,36 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
return schedule;
}
+ private static Trigger convertToTrigger(JobTrigger jobTrigger) {
+ Trigger trigger;
+ if (jobTrigger.getRecurrenceType() == JobTrigger.RecurrenceType.CRON_EXPRESSION) {
+ CronTrigger cronTrigger = new CronTrigger();
+ try {
+ cronTrigger.setCronExpression(jobTrigger.getCronExpression());
+ }
+ catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ trigger = cronTrigger;
+ } else {
+ SimpleTrigger simpleTrigger = new SimpleTrigger();
+ Date startTime = null;
+ switch (jobTrigger.getStartType()) {
+ case NOW:
+ startTime = new Date();
+ break;
+ case DATETIME:
+ startTime = jobTrigger.getStartDate();
+ break;
+ }
+ simpleTrigger.setStartTime(startTime);
+
+ // TODO (ips): Finish implementing this.
+
+ trigger= simpleTrigger;
+ }
+
+ return trigger;
+ }
+
}
\ No newline at end of file
13 years, 4 months
[rhq] 5 commits - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 174 +++++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/TableOrCanvasAutoRefresh.java | 69 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 46 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java | 24 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 9
14 files changed, 377 insertions(+), 57 deletions(-)
New commits:
commit 7c3612eeeb3f43c84544811b61e9b89c3cfc37c2
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Dec 22 15:36:47 2010 -0500
revert use of shared component as introduced a regression in portlet refresh.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index e7c2265..74ce25c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue;
+import com.google.gwt.user.client.Timer;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -31,12 +32,12 @@ import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -56,8 +57,7 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
//portlet settings and datasource elements
private DashboardPortlet storedPortlet;
private AutodiscoveryQueueDataSource dataSource;
- private static TableOrCanvasAutoRefresh defaultReloader;
- private static Canvas componentToReload;
+ private Timer defaultReloader;
public AutodiscoveryPortlet(String locatorId) {
super(locatorId, true);
@@ -191,14 +191,19 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
@Override
public void startRefreshCycle() {
- //lazy load
- if (componentToReload == null) {
- componentToReload = this;
- }
- //cancel the previous timer run
+ //current setting
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ //cancel previous operation
if (defaultReloader != null) {
- defaultReloader.stopTimer();
+ defaultReloader.cancel();
}
- defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
index 3b860b8..f7cbcdc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
@@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resou
import java.util.Set;
+import com.google.gwt.user.client.Timer;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
@@ -38,7 +39,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
/**
@@ -52,9 +52,7 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto
private DashboardPortlet storedPortlet;
private PortletWindow portletWindow;
-
- private static Canvas componentToReload;
- private static TableOrCanvasAutoRefresh defaultReloader;
+ private Timer defaultReloader;
public FavoriteResourcesPortlet(String locatorId) {
super(locatorId);
@@ -117,14 +115,19 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto
@Override
public void startRefreshCycle() {
- //lazy load
- if (componentToReload == null) {
- componentToReload = this;
- }
- //cancel the previous timer run
+ //current setting
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ //cancel previous operation
if (defaultReloader != null) {
- defaultReloader.stopTimer();
+ defaultReloader.cancel();
}
- defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index 7cfcdb8..024adb3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
+import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -36,6 +37,7 @@ import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView;
import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletDataSource;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
@@ -43,7 +45,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -93,8 +94,7 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti
private AlertPortletDataSource dataSource;
//instance ui widgets
private Canvas containerCanvas;
- private static Canvas componentToReload;
- private static TableOrCanvasAutoRefresh defaultReloader;
+ private Timer defaultReloader;
public RecentAlertsPortlet(String locatorId) {
super(locatorId);
@@ -539,15 +539,20 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti
@Override
public void startRefreshCycle() {
- //lazy load
- if (componentToReload == null) {
- componentToReload = this;
- }
- //cancel the previous timer run
+ //current setting
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ //cancel previous operation
if (defaultReloader != null) {
- defaultReloader.stopTimer();
+ defaultReloader.cancel();
}
- defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
+ defaultReloader = new Timer() {
+ public void run() {
+ refresh();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
index 5a3a0b2..30c9b4e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
@@ -23,6 +23,7 @@
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported;
+import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -36,13 +37,13 @@ import com.smartgwt.client.widgets.tree.TreeGrid;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements CustomSettingsPortlet,
@@ -59,8 +60,7 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C
private static final String RECENTLY_ADDED_SHOW_MAX = "recently-added-show-amount";
private static final String RECENTLY_ADDED_SHOW_HRS = "recently-added-time-range";
- private static Canvas componentToReload;
- private static TableOrCanvasAutoRefresh defaultReloader;
+ private Timer defaultReloader;
public RecentlyAddedResourcesPortlet(String locatorId) {
super(locatorId);
@@ -230,14 +230,19 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C
@Override
public void startRefreshCycle() {
- //lazy load
- if (componentToReload == null) {
- componentToReload = this;
- }
- //cancel the previous timer run
+ //current setting
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ //cancel previous operation
if (defaultReloader != null) {
- defaultReloader.stopTimer();
+ defaultReloader.cancel();
}
- defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 76f61be..507c8ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -19,6 +19,7 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operatio
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -36,12 +37,12 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -79,8 +80,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
public static String unlimited = MSG.common_label_unlimited();
public static String defaultValue = unlimited;
public static boolean defaultEnabled = true;
- private static Canvas componentToReload;
- private static TableOrCanvasAutoRefresh defaultReloader;
+ private Timer defaultReloader;
//default no-args constructor for serialization.
private OperationsPortlet() {
@@ -418,14 +418,19 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
@Override
public void startRefreshCycle() {
- //lazy load
- if (componentToReload == null) {
- componentToReload = this;
- }
- //cancel the previous timer run
+ //current setting
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ //cancel previous operation
if (defaultReloader != null) {
- defaultReloader.stopTimer();
+ defaultReloader.cancel();
}
- defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 296d92d..fddbfa1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -38,6 +38,7 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
@@ -45,7 +46,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -72,8 +72,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
//constants
public static final String unlimited = MSG.common_label_unlimited();
public static final String defaultValue = unlimited;
- private static Canvas componentToReload;
- private static TableOrCanvasAutoRefresh defaultReloader;
+ private Timer defaultReloader;
public ProblemResourcesPortlet(String locatorId) {
super(locatorId, TITLE, true);
@@ -293,15 +292,20 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
@Override
public void startRefreshCycle() {
- //lazy load
- if (componentToReload == null) {
- componentToReload = this;
- }
- //cancel the previous timer run
+ //current setting
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ //cancel previous operation
if (defaultReloader != null) {
- defaultReloader.stopTimer();
+ defaultReloader.cancel();
}
- defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
+ defaultReloader = new Timer() {
+ public void run() {
+ refresh();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
index 9a569aa..6b70298 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary;
import java.util.ArrayList;
import java.util.List;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -37,11 +38,11 @@ import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.InventorySummary;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -52,8 +53,7 @@ public class InventorySummaryPortlet extends LocatableVLayout implements AutoRef
private LocatableDynamicForm form;
public static final String KEY = MSG.common_title_summary_counts();
- private static Canvas componentToReload;
- private static TableOrCanvasAutoRefresh defaultReloader;
+ private Timer defaultReloader;
public InventorySummaryPortlet(String locatorId) {
super(locatorId);
@@ -171,14 +171,19 @@ public class InventorySummaryPortlet extends LocatableVLayout implements AutoRef
@Override
public void startRefreshCycle() {
- //lazy load
- if (componentToReload == null) {
- componentToReload = this;
- }
- //cancel the previous timer run
+ //current setting
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ //cancel previous operation
if (defaultReloader != null) {
- defaultReloader.stopTimer();
+ defaultReloader.cancel();
}
- defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
+ defaultReloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ defaultReloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ defaultReloader.schedule(retrievedRefreshInterval);
}
}
commit d05803785b4fc6f381aca71b8a41b43013a8faa1
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Dec 17 08:41:57 2010 -0500
attempt to fix initial menu load missing icons.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 02f942b..9feaffd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -269,10 +269,14 @@ public class DashboardView extends LocatableVLayout {
Integer[] refreshValues = { STOP_VALUE, REFRESH1_VALUE, REFRESH5_VALUE, REFRESH10_VALUE };
refreshMenuMappings = new HashMap<Integer, String>();
refreshMenuItems = new MenuItem[refreshIntervals.length];
+ int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
for (int i = 0; i < refreshIntervals.length; i++) {
MenuItem item = new MenuItem(refreshIntervals[i], "");
item.addClickHandler(menuClick);
refreshMenuMappings.put(refreshValues[i], refreshIntervals[i]);
+ if (retrievedRefreshInterval == refreshValues[i]) {
+ item.setIcon(ImageManager.getAvailabilityIcon(true));
+ }
refreshMenuItems[i] = item;
}
@@ -280,6 +284,7 @@ public class DashboardView extends LocatableVLayout {
refreshMenuButton = new LocatableIMenuButton(extendLocatorId("AutoRefreshButton"), MSG
.common_title_change_refresh_time(), refreshMenu);
refreshMenu.setAutoHeight();
+ refreshMenuButton.getMenu().setItems(refreshMenuItems);
refreshMenuButton.setWidth(170);
refreshMenuButton.setShowTitle(true);
refreshMenuButton.setTop(0);
@@ -294,6 +299,8 @@ public class DashboardView extends LocatableVLayout {
editForm.setItems(nameItem, numColItem, addCanvas, picker, addColumn, removeColumn, refreshCanvas);
updateRefreshMenu();
+ this.refreshMenuButton.markForRedraw();
+ markForRedraw();
return editForm;
}
commit 5cccd335fac28b498cabf4269d655bbd4eb0ff12
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Dec 16 19:01:42 2010 -0500
set default value for refresh interval.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index bbb05bd..02f942b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -62,6 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
+ * @author Simeon Pinder
*/
public class DashboardView extends LocatableVLayout {
private DashboardsView dashboardsView;
@@ -78,6 +79,11 @@ public class DashboardView extends LocatableVLayout {
private static String REFRESH1 = MSG.view_dashboards_portlets_refresh_one_min();
private static String REFRESH5 = MSG.view_dashboards_portlets_refresh_multiple_min(String.valueOf(5));
private static String REFRESH10 = MSG.view_dashboards_portlets_refresh_multiple_min(String.valueOf(10));
+ private static Integer STOP_VALUE = 0;
+ private static Integer REFRESH1_VALUE = 1 * Long.valueOf(MeasurementUtility.MINUTES).intValue();
+ private static Integer REFRESH5_VALUE = 5 * Long.valueOf(MeasurementUtility.MINUTES).intValue();
+ private static Integer REFRESH10_VALUE = 10 * Long.valueOf(MeasurementUtility.MINUTES).intValue();
+
private HashMap<Integer, String> refreshMenuMappings;
private MenuItem[] refreshMenuItems;
private int refreshInterval = 0;
@@ -243,15 +249,15 @@ public class DashboardView extends LocatableVLayout {
refreshInterval = 0;
if (selection != null) {
if (selection.equals(STOP)) {
- refreshInterval = 0;
+ refreshInterval = STOP_VALUE;
} else if (selection.equals(REFRESH1)) {
- refreshInterval = Long.valueOf(MeasurementUtility.MINUTES).intValue();
+ refreshInterval = REFRESH1_VALUE;
} else if (selection.equals(REFRESH5)) {
- refreshInterval = 5 * Long.valueOf(MeasurementUtility.MINUTES).intValue();
+ refreshInterval = REFRESH5_VALUE;
} else if (selection.equals(REFRESH10)) {
- refreshInterval = 10 * Long.valueOf(MeasurementUtility.MINUTES).intValue();
+ refreshInterval = REFRESH10_VALUE;
} else {//unable to locate value disable refresh
- refreshInterval = 0;//
+ refreshInterval = STOP_VALUE;//
}
UserSessionManager.getUserPreferences().setPageRefreshInterval(refreshInterval,
new UpdatePortletRefreshCallback());
@@ -260,9 +266,7 @@ public class DashboardView extends LocatableVLayout {
};
String[] refreshIntervals = { STOP, REFRESH1, REFRESH5, REFRESH10 };
- Integer[] refreshValues = { 0, 1 * Long.valueOf(MeasurementUtility.MINUTES).intValue(),
- 5 * Long.valueOf(MeasurementUtility.MINUTES).intValue(),
- 10 * Long.valueOf(MeasurementUtility.MINUTES).intValue() };
+ Integer[] refreshValues = { STOP_VALUE, REFRESH1_VALUE, REFRESH5_VALUE, REFRESH10_VALUE };
refreshMenuMappings = new HashMap<Integer, String>();
refreshMenuItems = new MenuItem[refreshIntervals.length];
for (int i = 0; i < refreshIntervals.length; i++) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
index 97e6314..1c311b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
/**
* @author Greg Hinkle
@@ -73,6 +74,9 @@ public class UserPreferences {
}
public int getPageRefreshInterval() {
+ if (getPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD) == null) {//default to 60 seconds
+ setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(MeasurementUtility.MINUTES));
+ }
return getPreferenceAsInteger(UserPreferenceNames.PAGE_REFRESH_PERIOD);
}
commit dedf4e96b1ce355cc2d3df01f397e3be006ad62d
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Dec 16 18:38:31 2010 -0500
i)modify dashboard to allow portlet refresh interval configuration with other dashboard settings
ii)refactored portlet refresh logic into shared utility
iii)refactor portlets to use shared utilty for refresh
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java
index 2453272..2dca467 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java
@@ -29,6 +29,8 @@ public interface AutoRefreshPortlet extends Portlet {
int refreshCycle = 60000;//ms
+ /** Each portlet implements to define the refresh cycle. See
+ * TableOrCanvasAutoRefresh for sample implementation.
+ */
void startRefreshCycle();
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index c276e09..bbb05bd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -74,10 +74,10 @@ public class DashboardView extends LocatableVLayout {
IMenuButton addPortlet;
Set<PortletWindow> portlets = new HashSet<PortletWindow>();
- private static String STOP = "Stop";
- private static String REFRESH1 = "Refresh every 1 minute";
- private static String REFRESH5 = "Refresh every 5 minutes";
- private static String REFRESH10 = "Refresh every 10 minutes";
+ private static String STOP = MSG.common_title_stop();
+ private static String REFRESH1 = MSG.view_dashboards_portlets_refresh_one_min();
+ private static String REFRESH5 = MSG.view_dashboards_portlets_refresh_multiple_min(String.valueOf(5));
+ private static String REFRESH10 = MSG.view_dashboards_portlets_refresh_multiple_min(String.valueOf(10));
private HashMap<Integer, String> refreshMenuMappings;
private MenuItem[] refreshMenuItems;
private int refreshInterval = 0;
@@ -273,8 +273,8 @@ public class DashboardView extends LocatableVLayout {
}
refreshMenu.setItems(refreshMenuItems);
- refreshMenuButton = new LocatableIMenuButton(extendLocatorId("AutoRefreshButton"), "Change Refresh Time",
- refreshMenu);
+ refreshMenuButton = new LocatableIMenuButton(extendLocatorId("AutoRefreshButton"), MSG
+ .common_title_change_refresh_time(), refreshMenu);
refreshMenu.setAutoHeight();
refreshMenuButton.setWidth(170);
refreshMenuButton.setShowTitle(true);
@@ -282,7 +282,7 @@ public class DashboardView extends LocatableVLayout {
refreshMenuButton.setIconOrientation("left");
CanvasItem refreshCanvas = new CanvasItem();
- refreshCanvas.setTitle("Portlets auto-refresh interval");
+ refreshCanvas.setTitle(MSG.common_title_portlet_auto_refresh());
refreshCanvas.setWrapTitle(false);
refreshCanvas.setCanvas(refreshMenuButton);
refreshCanvas.setStartRow(false);
@@ -415,6 +415,7 @@ public class DashboardView extends LocatableVLayout {
if (portletWindow.getDashboardPortlet().getId() == portlet.getId()) {
portletWindow.getDashboardPortlet().setConfiguration(portlet.getConfiguration());
+ //restarting port auto-refresh with newest settings
PortletViewFactory viewFactory = portletMap.get(portlet.getPortletKey());
// TODO: Note, we're using a sequence generated ID here as a locatorId. This is not optimal for repeatable
@@ -424,7 +425,7 @@ public class DashboardView extends LocatableVLayout {
+ "-" + Integer.toString(portlet.getId()));
//add code to re-initialize refresh cycle for portlets
- if (portlet instanceof AutoRefreshPortlet) {
+ if (view instanceof AutoRefreshPortlet) {
((AutoRefreshPortlet) view).startRefreshCycle();
}
}
@@ -472,9 +473,9 @@ public class DashboardView extends LocatableVLayout {
public void onSuccess(Subject subject) {
String m;
if (refreshInterval > 0) {
- m = "Updated interval for portlets that auto-refresh";
+ m = MSG.view_dashboards_portlets_refresh_success1();
} else {
- m = "Stopping reload for portlets that auto-refresh";
+ m = MSG.view_dashboards_portlets_refresh_success2();
}
CoreGUI.getMessageCenter().notify(new Message(m, Message.Severity.Info));
updateRefreshMenu();
@@ -484,9 +485,9 @@ public class DashboardView extends LocatableVLayout {
public void onFailure(Throwable throwable) {
String m;
if (refreshInterval > 0) {
- m = "Failed to updated interval for portlets that auto-refresh";
+ m = MSG.view_dashboards_portlets_refresh_fail1();
} else {
- m = "Failed to disable reload for portlets that auto-refresh";
+ m = MSG.view_dashboards_portlets_refresh_fail2();
}
CoreGUI.getMessageCenter().notify(new Message(m, Message.Severity.Error));
// Revert back to our original favorite status, since the server update failed.
@@ -498,7 +499,7 @@ public class DashboardView extends LocatableVLayout {
if (refreshMenuItems != null) {
int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
String currentSelection = refreshMenuMappings.get(retrievedRefreshInterval);
- if (currentSelection != null) {
+ if (currentSelection != null) {//iterate over menu items and update icon details
for (int i = 0; i < refreshMenuItems.length; i++) {
MenuItem menu = refreshMenuItems[i];
if (currentSelection.equals(menu.getTitle())) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/TableOrCanvasAutoRefresh.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/TableOrCanvasAutoRefresh.java
index 2c9c217..75f15c0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/TableOrCanvasAutoRefresh.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/TableOrCanvasAutoRefresh.java
@@ -25,18 +25,25 @@ import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
-/**
+/**An implementation of a shared portet refresh utility.
* @author Simeon Pinder
*/
public class TableOrCanvasAutoRefresh {
private Timer reloader;
+ /** reloads the Table or Canvas page based on the pageRefreshInterval saved to the
+ * current user's settings.
+ */
public TableOrCanvasAutoRefresh(final Canvas toBeReloaded) {
if (toBeReloaded != null) {
+ //current setting
final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ if (this.reloader != null) {
+ this.reloader.cancel();
+ }
if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
- reloader = new Timer() {
+ this.reloader = new Timer() {
public void run() {
if (toBeReloaded instanceof Table) {
((Table) toBeReloaded).refresh();
@@ -44,14 +51,19 @@ public class TableOrCanvasAutoRefresh {
((Canvas) toBeReloaded).redraw();
}
- //launch again until portlet reference and child references GC.
+ //launch again until shedule stopped or GC.
reloader.schedule(retrievedRefreshInterval);
}
};
- reloader.schedule(retrievedRefreshInterval);
- } else {//disable timer
- reloader = null;
+ this.reloader.schedule(retrievedRefreshInterval);
}
}
}
+
+ //stops the timer from previous run.
+ public void stopTimer() {
+ if (this.reloader != null) {
+ this.reloader.cancel();
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index c837294..e7c2265 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue;
-import com.google.gwt.user.client.Timer;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -32,19 +31,19 @@ import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
+ * @author Simeon Pinder
* @author Greg Hinkle
*/
public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements CustomSettingsPortlet,
@@ -57,7 +56,8 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
//portlet settings and datasource elements
private DashboardPortlet storedPortlet;
private AutodiscoveryQueueDataSource dataSource;
- private Timer reloader;
+ private static TableOrCanvasAutoRefresh defaultReloader;
+ private static Canvas componentToReload;
public AutodiscoveryPortlet(String locatorId) {
super(locatorId, true);
@@ -71,21 +71,23 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
if (getTreeGrid() != null) {
getTreeGrid().setDataSource(getDataSource());
}
- //loads/retrieves initial portlet settings for datasource
- String retrieved = null;
- //if settings already exist for this portlet
- if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) != null) {
- //retrieve and translate to int
- retrieved = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
- } else {//create setting
- storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
- retrieved = defaultValue;
- }
+ if ((storedPortlet != null) && (storedPortlet.getConfiguration() != null)) {
+ //loads/retrieves initial portlet settings for datasource
+ String retrieved = null;
+ //if settings already exist for this portlet
+ if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) != null) {
+ //retrieve and translate to int
+ retrieved = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
+ retrieved = defaultValue;
+ }
- if (retrieved.equals(unlimited)) {
- getDataSource().setMaximumPlatformsToDisplay(-1);
- } else {
- getDataSource().setMaximumPlatformsToDisplay(Integer.parseInt(retrieved));
+ if (retrieved.equals(unlimited)) {
+ getDataSource().setMaximumPlatformsToDisplay(-1);
+ } else {
+ getDataSource().setMaximumPlatformsToDisplay(Integer.parseInt(retrieved));
+ }
}
}
@@ -189,19 +191,14 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
@Override
public void startRefreshCycle() {
- final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
- if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
- reloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- reloader.schedule(retrievedRefreshInterval);
- }
- };
- reloader.schedule(retrievedRefreshInterval);
- } else {//disable timer
- reloader = null;
+ //lazy load
+ if (componentToReload == null) {
+ componentToReload = this;
+ }
+ //cancel the previous timer run
+ if (defaultReloader != null) {
+ defaultReloader.stopTimer();
}
- // new TableOrCanvasAutoRefresh(this);
+ defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
index f1a3876..3b860b8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
@@ -24,7 +24,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resou
import java.util.Set;
-import com.google.gwt.user.client.Timer;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
@@ -39,6 +38,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
/**
@@ -53,7 +53,8 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto
private DashboardPortlet storedPortlet;
private PortletWindow portletWindow;
- private Timer reloader;
+ private static Canvas componentToReload;
+ private static TableOrCanvasAutoRefresh defaultReloader;
public FavoriteResourcesPortlet(String locatorId) {
super(locatorId);
@@ -116,14 +117,14 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto
@Override
public void startRefreshCycle() {
- reloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- reloader.schedule(refreshCycle);
- }
- };
- reloader.schedule(refreshCycle);
+ //lazy load
+ if (componentToReload == null) {
+ componentToReload = this;
+ }
+ //cancel the previous timer run
+ if (defaultReloader != null) {
+ defaultReloader.stopTimer();
+ }
+ defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index ad26a09..7cfcdb8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
-import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -44,6 +43,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -93,7 +93,8 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti
private AlertPortletDataSource dataSource;
//instance ui widgets
private Canvas containerCanvas;
- private Timer reloader;
+ private static Canvas componentToReload;
+ private static TableOrCanvasAutoRefresh defaultReloader;
public RecentAlertsPortlet(String locatorId) {
super(locatorId);
@@ -538,14 +539,15 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti
@Override
public void startRefreshCycle() {
- reloader = new Timer() {
- public void run() {
- refresh();
- //launch again until portlet reference and child references GC.
- reloader.schedule(refreshCycle);
- }
- };
- reloader.schedule(refreshCycle);
+ //lazy load
+ if (componentToReload == null) {
+ componentToReload = this;
+ }
+ //cancel the previous timer run
+ if (defaultReloader != null) {
+ defaultReloader.stopTimer();
+ }
+ defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
index abc9e6b..5a3a0b2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
@@ -23,7 +23,6 @@
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported;
-import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -43,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements CustomSettingsPortlet,
@@ -59,7 +59,8 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C
private static final String RECENTLY_ADDED_SHOW_MAX = "recently-added-show-amount";
private static final String RECENTLY_ADDED_SHOW_HRS = "recently-added-time-range";
- private Timer reloader;
+ private static Canvas componentToReload;
+ private static TableOrCanvasAutoRefresh defaultReloader;
public RecentlyAddedResourcesPortlet(String locatorId) {
super(locatorId);
@@ -229,13 +230,14 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C
@Override
public void startRefreshCycle() {
- reloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- reloader.schedule(refreshCycle);
- }
- };
- reloader.schedule(refreshCycle);
+ //lazy load
+ if (componentToReload == null) {
+ componentToReload = this;
+ }
+ //cancel the previous timer run
+ if (defaultReloader != null) {
+ defaultReloader.stopTimer();
+ }
+ defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index adc9706..76f61be 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -19,7 +19,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operatio
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -42,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -76,10 +76,11 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
private DashboardPortlet storedPortlet = null;
private RecentOperationsDataSource dataSourceCompleted;
private ScheduledOperationsDataSource dataSourceScheduled;
- private Timer reloader;
public static String unlimited = MSG.common_label_unlimited();
public static String defaultValue = unlimited;
public static boolean defaultEnabled = true;
+ private static Canvas componentToReload;
+ private static TableOrCanvasAutoRefresh defaultReloader;
//default no-args constructor for serialization.
private OperationsPortlet() {
@@ -417,13 +418,14 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
@Override
public void startRefreshCycle() {
- reloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- reloader.schedule(refreshCycle);
- }
- };
- reloader.schedule(refreshCycle);
+ //lazy load
+ if (componentToReload == null) {
+ componentToReload = this;
+ }
+ //cancel the previous timer run
+ if (defaultReloader != null) {
+ defaultReloader.stopTimer();
+ }
+ defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 81fc756..296d92d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -71,6 +72,8 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
//constants
public static final String unlimited = MSG.common_label_unlimited();
public static final String defaultValue = unlimited;
+ private static Canvas componentToReload;
+ private static TableOrCanvasAutoRefresh defaultReloader;
public ProblemResourcesPortlet(String locatorId) {
super(locatorId, TITLE, true);
@@ -290,14 +293,15 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
@Override
public void startRefreshCycle() {
- reloader = new Timer() {
- public void run() {
- refresh();
- //launch again until portlet reference and child references GC.
- reloader.schedule(refreshCycle);
- }
- };
- reloader.schedule(refreshCycle);
+ //lazy load
+ if (componentToReload == null) {
+ componentToReload = this;
+ }
+ //cancel the previous timer run
+ if (defaultReloader != null) {
+ defaultReloader.stopTimer();
+ }
+ defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
index 2bc852c..9a569aa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
@@ -25,7 +25,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary;
import java.util.ArrayList;
import java.util.List;
-import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -42,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.TableOrCanvasAutoRefresh;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -52,7 +52,8 @@ public class InventorySummaryPortlet extends LocatableVLayout implements AutoRef
private LocatableDynamicForm form;
public static final String KEY = MSG.common_title_summary_counts();
- private Timer reloader;
+ private static Canvas componentToReload;
+ private static TableOrCanvasAutoRefresh defaultReloader;
public InventorySummaryPortlet(String locatorId) {
super(locatorId);
@@ -170,13 +171,14 @@ public class InventorySummaryPortlet extends LocatableVLayout implements AutoRef
@Override
public void startRefreshCycle() {
- reloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- reloader.schedule(refreshCycle);
- }
- };
- reloader.schedule(refreshCycle);
+ //lazy load
+ if (componentToReload == null) {
+ componentToReload = this;
+ }
+ //cancel the previous timer run
+ if (defaultReloader != null) {
+ defaultReloader.stopTimer();
+ }
+ defaultReloader = new TableOrCanvasAutoRefresh(componentToReload);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 8f06b15..0263cc9 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -79,6 +79,7 @@ common_title_background = Background
common_title_bundle = Bundle
common_title_bundles = Bundles
common_title_category = Category
+common_title_change_refresh_time=Change Refresh Time
common_title_columns = Columns
common_title_configuration = Configuration
common_title_compatibleGroups = Compatible Groups
@@ -130,6 +131,7 @@ common_title_platform = Platform
common_title_platform_total = Platform Total
common_title_plugin = Plugin
common_title_port = Port
+common_title_portlet_auto_refresh=Portlet Auto-refresh Interval
common_title_providers = Providers
common_title_recently_added = Recently Added Resources
common_title_recent_alerts = Recent Alerts
@@ -162,6 +164,7 @@ common_title_show = Show
common_title_show_more = Show more...
common_title_start = Start
common_title_status = Status
+common_title_stop= Stop
common_title_summary = Summary
common_title_tag_cloud = Tag Cloud
common_title_the = The
@@ -1168,6 +1171,12 @@ view_dashboardManager_deleteFail = Failed to delete dashboard.
view_dashboardManager_deleted = Successfully deleted dashboard {0}
view_dashboards_title = Dashboard
view_dashboards_confirm1 = Are you sure you want to delete
+view_dashboards_portlets_refresh_fail1=Failed to update interval for portlets that auto-refresh
+view_dashboards_portlets_refresh_fail2=Failed to disable reload for portlets that auto-refresh
+view_dashboards_portlets_refresh_multiple_min = Refresh every {0} minutes
+view_dashboards_portlets_refresh_one_min = Refresh every 1 minute
+view_dashboards_portlets_refresh_success1=Updated interval for portlets that auto-refresh
+view_dashboards_portlets_refresh_success2=Stopping reload for portlets that auto-refresh
view_dashboardsManager_error1 = Failed to add new dashboard
# // dup in common
view_dashboardsManager_inventory_title = Inventory Summary
commit 6fc936a2a16732c2a6e1699ba48c18d0ad21f810
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Dec 15 19:37:15 2010 -0500
dashboard portlet refresh configuration logic.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java
index 2aedc24..2453272 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/AutoRefreshPortlet.java
@@ -27,7 +27,7 @@ package org.rhq.enterprise.gui.coregui.client.dashboard;
*/
public interface AutoRefreshPortlet extends Portlet {
- int refreshCycle = 40000;//ms
+ int refreshCycle = 60000;//ms
void startRefreshCycle();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 81d3bb2..c276e09 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@@ -39,17 +40,24 @@ import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.menu.IMenuButton;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
import com.smartgwt.client.widgets.menu.events.ItemClickEvent;
import com.smartgwt.client.widgets.menu.events.ItemClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.Dashboard;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -66,6 +74,15 @@ public class DashboardView extends LocatableVLayout {
IMenuButton addPortlet;
Set<PortletWindow> portlets = new HashSet<PortletWindow>();
+ private static String STOP = "Stop";
+ private static String REFRESH1 = "Refresh every 1 minute";
+ private static String REFRESH5 = "Refresh every 5 minutes";
+ private static String REFRESH10 = "Refresh every 10 minutes";
+ private HashMap<Integer, String> refreshMenuMappings;
+ private MenuItem[] refreshMenuItems;
+ private int refreshInterval = 0;
+ private LocatableIMenuButton refreshMenuButton;
+ private HashMap<String, PortletViewFactory> portletMap = null;
public DashboardView(String locatorId, DashboardsView dashboardsView, Dashboard storedDashboard) {
super(locatorId);
@@ -117,10 +134,11 @@ public class DashboardView extends LocatableVLayout {
private DynamicForm buildEditForm() {
editForm = new LocatableDynamicForm(extendLocatorId("Editor"));
editForm.setAutoWidth();
- editForm.setNumCols(9);
+ editForm.setNumCols(12);
TextItem nameItem = new TextItem("name", MSG.common_title_dashboard_name());
nameItem.setValue(storedDashboard.getName());
+ nameItem.setWrapTitle(false);
nameItem.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent blurEvent) {
String val = (String) blurEvent.getItem().getValue();
@@ -153,7 +171,6 @@ public class DashboardView extends LocatableVLayout {
});
ButtonItem removeColumn = new ButtonItem("removeColumn", MSG.common_title_remove_column());
- // removeColumn.setIcon("silk/application_side_contract.png");
removeColumn.setAutoFit(true);
removeColumn.setStartRow(false);
removeColumn.setEndRow(false);
@@ -175,7 +192,7 @@ public class DashboardView extends LocatableVLayout {
});
Menu addPorletMenu = new Menu();
- for (String portletName : PortletFactory.getRegisteredPortlets()) {
+ for (String portletName : PortletFactory.getRegisteredPortletKeys()) {
addPorletMenu.addItem(new MenuItem(portletName));
}
@@ -213,7 +230,66 @@ public class DashboardView extends LocatableVLayout {
});
picker.setValue(storedDashboard.getConfiguration().getSimpleValue(Dashboard.CFG_BACKGROUND, "white"));
- editForm.setItems(nameItem, numColItem, addCanvas, picker, addColumn, removeColumn);
+ //refresh interval
+ LocatableMenu refreshMenu = new LocatableMenu(extendLocatorId("AutoRefreshMenu"));
+ refreshMenu.setShowShadow(true);
+ refreshMenu.setShadowDepth(10);
+ refreshMenu.setAutoWidth();
+ refreshMenu.setHeight(15);
+ ClickHandler menuClick = new ClickHandler() {
+ @Override
+ public void onClick(MenuItemClickEvent event) {
+ String selection = event.getItem().getTitle();
+ refreshInterval = 0;
+ if (selection != null) {
+ if (selection.equals(STOP)) {
+ refreshInterval = 0;
+ } else if (selection.equals(REFRESH1)) {
+ refreshInterval = Long.valueOf(MeasurementUtility.MINUTES).intValue();
+ } else if (selection.equals(REFRESH5)) {
+ refreshInterval = 5 * Long.valueOf(MeasurementUtility.MINUTES).intValue();
+ } else if (selection.equals(REFRESH10)) {
+ refreshInterval = 10 * Long.valueOf(MeasurementUtility.MINUTES).intValue();
+ } else {//unable to locate value disable refresh
+ refreshInterval = 0;//
+ }
+ UserSessionManager.getUserPreferences().setPageRefreshInterval(refreshInterval,
+ new UpdatePortletRefreshCallback());
+ }
+ }
+ };
+
+ String[] refreshIntervals = { STOP, REFRESH1, REFRESH5, REFRESH10 };
+ Integer[] refreshValues = { 0, 1 * Long.valueOf(MeasurementUtility.MINUTES).intValue(),
+ 5 * Long.valueOf(MeasurementUtility.MINUTES).intValue(),
+ 10 * Long.valueOf(MeasurementUtility.MINUTES).intValue() };
+ refreshMenuMappings = new HashMap<Integer, String>();
+ refreshMenuItems = new MenuItem[refreshIntervals.length];
+ for (int i = 0; i < refreshIntervals.length; i++) {
+ MenuItem item = new MenuItem(refreshIntervals[i], "");
+ item.addClickHandler(menuClick);
+ refreshMenuMappings.put(refreshValues[i], refreshIntervals[i]);
+ refreshMenuItems[i] = item;
+ }
+
+ refreshMenu.setItems(refreshMenuItems);
+ refreshMenuButton = new LocatableIMenuButton(extendLocatorId("AutoRefreshButton"), "Change Refresh Time",
+ refreshMenu);
+ refreshMenu.setAutoHeight();
+ refreshMenuButton.setWidth(170);
+ refreshMenuButton.setShowTitle(true);
+ refreshMenuButton.setTop(0);
+ refreshMenuButton.setIconOrientation("left");
+
+ CanvasItem refreshCanvas = new CanvasItem();
+ refreshCanvas.setTitle("Portlets auto-refresh interval");
+ refreshCanvas.setWrapTitle(false);
+ refreshCanvas.setCanvas(refreshMenuButton);
+ refreshCanvas.setStartRow(false);
+ refreshCanvas.setEndRow(false);
+
+ editForm.setItems(nameItem, numColItem, addCanvas, picker, addColumn, removeColumn, refreshCanvas);
+ updateRefreshMenu();
return editForm;
}
@@ -327,10 +403,31 @@ public class DashboardView extends LocatableVLayout {
}
private void updateConfigs(Dashboard result) {
- for (PortletWindow portletWindow : portlets) {
- for (DashboardPortlet portlet : result.getPortlets()) {
- if (portletWindow.getDashboardPortlet().getId() == portlet.getId()) {
- portletWindow.getDashboardPortlet().setConfiguration(portlet.getConfiguration());
+ if (result != null) {
+ if (portletMap == null) {
+ portletMap = new HashMap<String, PortletViewFactory>();
+ for (String key : PortletFactory.getRegisteredPortletKeys()) {
+ portletMap.put(key, PortletFactory.getRegisteredPortlet(key));
+ }
+ }
+ for (PortletWindow portletWindow : portlets) {
+ for (DashboardPortlet portlet : result.getPortlets()) {
+ if (portletWindow.getDashboardPortlet().getId() == portlet.getId()) {
+ portletWindow.getDashboardPortlet().setConfiguration(portlet.getConfiguration());
+
+ PortletViewFactory viewFactory = portletMap.get(portlet.getPortletKey());
+
+ // TODO: Note, we're using a sequence generated ID here as a locatorId. This is not optimal for repeatable
+ // tests as a change in the number of default portlets, or a change in test order could make a test
+ // non-repeatable. But, at the moment we lack the infrastructure to generate a unique, predictable id.
+ Portlet view = viewFactory.getInstance(PortletFactory.replaceSpaces(portlet.getPortletKey())
+ + "-" + Integer.toString(portlet.getId()));
+
+ //add code to re-initialize refresh cycle for portlets
+ if (portlet instanceof AutoRefreshPortlet) {
+ ((AutoRefreshPortlet) view).startRefreshCycle();
+ }
+ }
}
}
}
@@ -370,4 +467,53 @@ public class DashboardView extends LocatableVLayout {
}
markForRedraw();
}
+
+ public class UpdatePortletRefreshCallback implements AsyncCallback<Subject> {
+ public void onSuccess(Subject subject) {
+ String m;
+ if (refreshInterval > 0) {
+ m = "Updated interval for portlets that auto-refresh";
+ } else {
+ m = "Stopping reload for portlets that auto-refresh";
+ }
+ CoreGUI.getMessageCenter().notify(new Message(m, Message.Severity.Info));
+ updateRefreshMenu();
+ save();
+ }
+
+ public void onFailure(Throwable throwable) {
+ String m;
+ if (refreshInterval > 0) {
+ m = "Failed to updated interval for portlets that auto-refresh";
+ } else {
+ m = "Failed to disable reload for portlets that auto-refresh";
+ }
+ CoreGUI.getMessageCenter().notify(new Message(m, Message.Severity.Error));
+ // Revert back to our original favorite status, since the server update failed.
+ updateRefreshMenu();
+ }
+ }
+
+ public void updateRefreshMenu() {
+ if (refreshMenuItems != null) {
+ int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ String currentSelection = refreshMenuMappings.get(retrievedRefreshInterval);
+ if (currentSelection != null) {
+ for (int i = 0; i < refreshMenuItems.length; i++) {
+ MenuItem menu = refreshMenuItems[i];
+ if (currentSelection.equals(menu.getTitle())) {
+ menu.setIcon(ImageManager.getAvailabilityIcon(true));
+ } else {
+ menu.setIcon("");
+ }
+ refreshMenuItems[i] = menu;
+ }
+ //update the menu
+ refreshMenuButton.getMenu().setItems(refreshMenuItems);
+ }
+ }
+ if (this.refreshMenuButton != null) {
+ this.refreshMenuButton.markForRedraw();
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index f3c3246..61bd111 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -253,8 +253,8 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
DashboardPortlet recentAlerts = new DashboardPortlet(RecentAlertsPortlet.KEY, RecentAlertsPortlet.KEY, 250);
dashboard.addPortlet(recentAlerts, 1, 3);
- DashboardPortlet recentlyAdded = new DashboardPortlet(MSG.common_title_recently_added(), RecentlyAddedResourcesPortlet.KEY,
- 250);
+ DashboardPortlet recentlyAdded = new DashboardPortlet(MSG.common_title_recently_added(),
+ RecentlyAddedResourcesPortlet.KEY, 250);
dashboard.addPortlet(recentlyAdded, 1, 4);
DashboardPortlet operations = new DashboardPortlet(MSG.common_title_operations(), OperationsPortlet.KEY, 500);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 07dd73f..857f893 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -92,7 +92,7 @@ public class PortletFactory {
* @param portletKey
* @return
*/
- private static String replaceSpaces(String portletKey) {
+ public static String replaceSpaces(String portletKey) {
String translated = portletKey;
if (portletKey != null) {
translated = portletKey.replaceAll(" ", "_");
@@ -101,11 +101,19 @@ public class PortletFactory {
}
@SuppressWarnings("unchecked")
- public static List<String> getRegisteredPortlets() {
+ public static List<String> getRegisteredPortletKeys() {
ArrayList portlets = new ArrayList(registeredPortlets.keySet());
Collections.sort(portlets);
return portlets;
}
+ public static PortletViewFactory getRegisteredPortlet(String key) {
+ PortletViewFactory portletFactory = null;
+ if ((key != null) & (!key.trim().isEmpty())) {
+ portletFactory = registeredPortlets.get(key);
+ }
+ return portletFactory;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/TableOrCanvasAutoRefresh.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/TableOrCanvasAutoRefresh.java
new file mode 100644
index 0000000..2c9c217
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/TableOrCanvasAutoRefresh.java
@@ -0,0 +1,57 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.dashboard;
+
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+
+/**
+ * @author Simeon Pinder
+ */
+public class TableOrCanvasAutoRefresh {
+
+ private Timer reloader;
+
+ public TableOrCanvasAutoRefresh(final Canvas toBeReloaded) {
+ if (toBeReloaded != null) {
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ reloader = new Timer() {
+ public void run() {
+ if (toBeReloaded instanceof Table) {
+ ((Table) toBeReloaded).refresh();
+ } else {
+ ((Canvas) toBeReloaded).redraw();
+ }
+
+ //launch again until portlet reference and child references GC.
+ reloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ reloader.schedule(retrievedRefreshInterval);
+ } else {//disable timer
+ reloader = null;
+ }
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index 87d2911..c837294 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
@@ -39,6 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -187,13 +189,19 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
@Override
public void startRefreshCycle() {
- reloader = new Timer() {
- public void run() {
- redraw();
- //launch again until portlet reference and child references GC.
- reloader.schedule(refreshCycle);
- }
- };
- reloader.schedule(refreshCycle);
+ final int retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+ if (retrievedRefreshInterval >= MeasurementUtility.MINUTES) {
+ reloader = new Timer() {
+ public void run() {
+ redraw();
+ //launch again until portlet reference and child references GC.
+ reloader.schedule(retrievedRefreshInterval);
+ }
+ };
+ reloader.schedule(retrievedRefreshInterval);
+ } else {//disable timer
+ reloader = null;
+ }
+ // new TableOrCanvasAutoRefresh(this);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
index d0913fc..97e6314 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
@@ -72,6 +72,15 @@ public class UserPreferences {
store(callback);
}
+ public int getPageRefreshInterval() {
+ return getPreferenceAsInteger(UserPreferenceNames.PAGE_REFRESH_PERIOD);
+ }
+
+ public void setPageRefreshInterval(int refreshInterval, AsyncCallback<Subject> callback) {
+ setPreference(UserPreferenceNames.PAGE_REFRESH_PERIOD, String.valueOf(refreshInterval));
+ store(callback);
+ }
+
protected String getPreference(String name) {
return userConfiguration.getSimpleValue(name, null);
}
@@ -144,6 +153,17 @@ public class UserPreferences {
}
}
+ public Integer getPreferenceAsInteger(String key) {
+ String pref = null;
+ try {
+ pref = getPreference(key);
+ } catch (IllegalArgumentException e) {
+
+ // log.debug("A user preference named '" + key + "' does not exist.");
+ }
+ return (pref != null) ? Integer.valueOf(pref) : Integer.valueOf(0);
+ }
+
public void addChangeListener(UserPreferenceChangeListener listener) {
changeListeners.add(listener);
}
13 years, 4 months
[rhq] 2 commits - modules/common
by mazz
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java | 23 -
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java | 172 ++++++++--
modules/common/ant-bundle/src/test/resources/file.zip |binary
modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml | 4
modules/common/ant-bundle/src/test/resources/test-bundle-v2-noManageRootDir.xml | 46 ++
modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml | 14
6 files changed, 221 insertions(+), 38 deletions(-)
New commits:
commit d2a766a39f4e3cf9b6e823d53dd356f8d42c5b1c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Dec 22 11:39:22 2010 -0500
BZ 659142 - ant unit test shows the manageRootDir=false working
diff --git a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
index 8a12139..a9edfc1 100644
--- a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
@@ -23,6 +23,7 @@
package org.rhq.bundle.ant;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -33,6 +34,7 @@ import java.util.Set;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration;
@@ -49,7 +51,15 @@ import org.rhq.core.util.file.FileUtil;
public class AntLauncherTest {
private static final File DEPLOY_DIR = new File("target/test-ant-bundle").getAbsoluteFile();
+ @AfterClass
+ public void afterClass() {
+ FileUtil.purge(DEPLOY_DIR, true);
+ }
+
public void testParse() throws Exception {
+ // We want to test with an empty deploy dir to ensure nothing gets installed there after a parse
+ FileUtil.purge(DEPLOY_DIR, true);
+
AntLauncher ant = new AntLauncher();
BundleAntProject project = ant.parseBundleDeployFile(getBuildXml("test-bundle-v1.xml"));
@@ -74,12 +84,18 @@ public class AntLauncherTest {
assert propDef.getDefaultValue().equals("8080");
assert propDef.getDescription().equals("This is where the product will listen for incoming messages");
assert propDef.isRequired();
+
+ // all we did was parse, nothing should really have been extracted or installed
+ assert !DEPLOY_DIR.exists() : "Nothing should have been installed to the deploy dir";
}
public void testInstall() throws Exception {
// We want to test a fresh install, so make sure the deploy dir doesn't pre-exist.
FileUtil.purge(DEPLOY_DIR, true);
+ // but we do want to add an unrelated file to see that it remains untouched - the install just "goes around" it
+ File unrelatedFile = writeFile("unrelated content", DEPLOY_DIR, "unrelated-file.txt");
+
AntLauncher ant = new AntLauncher();
Properties inputProps = createInputProperties("/test-bundle-v1-input.properties");
List<BuildListener> buildListeners = createBuildListeners();
@@ -116,6 +132,10 @@ public class AntLauncherTest {
assert preinstallTargetExecuted.equals("1a");
String postinstallTargetExecuted = (String) project.getProperties().get("postinstallTargetExecuted");
assert postinstallTargetExecuted.equals("1b");
+
+ assert new File(DEPLOY_DIR, "subdir/test.properties").exists() : "missing file";
+ assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() : "missing archived bundle file";
+ assert unrelatedFile.exists() : "unrelated file was removed during the install";
}
private List<BuildListener> createBuildListeners() {
@@ -130,7 +150,9 @@ public class AntLauncherTest {
@Test(dependsOnMethods = "testInstall")
public void testUpgrade() throws Exception {
- // We want to test an upgrade, so do *not* wipe out the deploy dir.
+ // We want to test an upgrade, so do *not* wipe out the deploy dir - our test method @dependsOnMethods testInstall
+ // but we do want to add an unrelated file to see that it gets deleted as part of the upgrade
+ File unrelatedFile = writeFile("unrelated content", DEPLOY_DIR, "unrelated-file.txt");
AntLauncher ant = new AntLauncher();
Properties inputProps = createInputProperties("/test-bundle-v2-input.properties");
@@ -168,6 +190,61 @@ public class AntLauncherTest {
assert preinstallTargetExecuted.equals("2a");
String postinstallTargetExecuted = (String) project.getProperties().get("postinstallTargetExecuted");
assert postinstallTargetExecuted.equals("2b");
+
+ assert new File(DEPLOY_DIR, "subdir/test.properties").exists() : "missing file";
+ assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() : "missing archived bundle file";
+ assert !unrelatedFile.exists() : "we are managing root dir so unrelated file should be removed during upgrade";
+ }
+
+ public void testUpgradeNoManageRootDir() throws Exception {
+ // We want to test an upgrade, so do *not* wipe out the deploy dir - let's re-invoke testInstall
+ // to get us to an initial state of the v1 bundle installed
+ testInstall();
+
+ // we still want the unrelated file - we want to see that manageRootDir=false works (unrelated files should not be deleted)
+ File unrelatedFile = new File(DEPLOY_DIR, "unrelated-file.txt");
+ assert unrelatedFile.exists() : "our initial install test method should have prepared an unmanaged file";
+
+ AntLauncher ant = new AntLauncher();
+ Properties inputProps = createInputProperties("/test-bundle-v2-input.properties");
+ List<BuildListener> buildListeners = createBuildListeners();
+
+ BundleAntProject project = ant.executeBundleDeployFile(getBuildXml("test-bundle-v2-noManageRootDir.xml"),
+ inputProps, buildListeners);
+ assert project != null;
+ Set<String> bundleFiles = project.getBundleFileNames();
+ assert bundleFiles != null;
+ assert bundleFiles.size() == 4 : bundleFiles;
+ assert bundleFiles.contains("test-v2.properties") : bundleFiles;
+ assert bundleFiles.contains("file.zip") : bundleFiles;
+ assert bundleFiles.contains("foo-script") : bundleFiles; // from install-system-service
+ assert bundleFiles.contains("foo-config") : bundleFiles; // from install-system-service
+
+ assert project.getBundleName().equals("example.com (JBoss EAP 4.3)");
+ assert project.getBundleVersion().equals("2.5");
+ assert project.getBundleDescription().equals("updated bundle");
+
+ ConfigurationDefinition configDef = project.getConfigurationDefinition();
+ assert configDef.getPropertyDefinitions().size() == 1 : configDef.getPropertyDefinitions();
+ PropertyDefinitionSimple propDef = configDef.getPropertyDefinitionSimple("listener.port");
+ assert propDef != null;
+ assert propDef.getType() == PropertySimpleType.INTEGER;
+ assert propDef.getDefaultValue().equals("9090");
+ assert propDef.getDescription().equals("This is where the product will listen for incoming messages");
+ assert propDef.isRequired();
+
+ Configuration config = project.getConfiguration();
+ assert config.getProperties().size() == 1;
+ assert "20000".equals(config.getSimpleValue("listener.port", null)) : config.getProperties();
+
+ String preinstallTargetExecuted = (String) project.getProperties().get("preinstallTargetExecuted");
+ assert preinstallTargetExecuted.equals("2a");
+ String postinstallTargetExecuted = (String) project.getProperties().get("postinstallTargetExecuted");
+ assert postinstallTargetExecuted.equals("2b");
+
+ assert new File(DEPLOY_DIR, "subdir/test.properties").exists() : "missing file";
+ assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() : "missing archived bundle file";
+ assert unrelatedFile.exists() : "we are NOT managing root dir so unrelated file should NOT be removed during upgrade";
}
private Properties createInputProperties(String resourcePath) throws IOException {
@@ -189,4 +266,24 @@ public class AntLauncherTest {
assert file.exists() : "The test Ant build script doesn't exist: " + file.getAbsolutePath();
return file;
}
+
+ private File writeFile(String content, File fileToOverwrite) throws Exception {
+ FileOutputStream out = null;
+
+ try {
+ fileToOverwrite.getParentFile().mkdirs();
+ out = new FileOutputStream(fileToOverwrite);
+ out.write(content.getBytes());
+ return fileToOverwrite;
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ private File writeFile(String content, File destDir, String fileName) throws Exception {
+ File destFile = new File(destDir, fileName);
+ return writeFile(content, destFile);
+ }
}
diff --git a/modules/common/ant-bundle/src/test/resources/file.zip b/modules/common/ant-bundle/src/test/resources/file.zip
index ea45ad7..922658a 100644
Binary files a/modules/common/ant-bundle/src/test/resources/file.zip and b/modules/common/ant-bundle/src/test/resources/file.zip differ
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-v2-noManageRootDir.xml b/modules/common/ant-bundle/src/test/resources/test-bundle-v2-noManageRootDir.xml
new file mode 100644
index 0000000..0b07e9e
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-v2-noManageRootDir.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+
+<project name="test-bundle" default="main" xmlns:rhq="antlib:org.rhq.bundle">
+
+ <rhq:bundle name="example.com (JBoss EAP 4.3)" version="2.5"
+ description="updated bundle">
+
+ <rhq:input-property
+ name="listener.port"
+ description="This is where the product will listen for incoming messages"
+ required="true"
+ defaultValue="9090"
+ type="integer"/>
+
+ <rhq:deployment-unit name="appserver" preinstallTarget="preinstall" postinstallTarget="postinstall"
+ manageRootDir="false"> <!-- this is the only difference with test-bundle-v2.xml -->
+ <rhq:system-service name="foo" scriptFile="foo-script"
+ configFile="foo-config" overwriteScript="true"
+ startLevels="3,4,5" startPriority="80" stopPriority="20" root="root"/>
+ <rhq:file name="test-v2.properties" destinationFile="subdir/test.properties" replace="true"/>
+ <rhq:archive name="file.zip">
+ <rhq:replace>
+ <rhq:fileset includes="**/*.properties"/>
+ </rhq:replace>
+ </rhq:archive>
+ <!-- the files that should be ignored during upgrades -->
+ <rhq:ignore>
+ <rhq:fileset includes="*.log"/>
+ </rhq:ignore>
+ </rhq:deployment-unit>
+
+ </rhq:bundle>
+
+ <target name="main"/>
+
+ <target name="preinstall">
+ <echo>Deploying Test Bundle v2.5 to ${rhq.deploy.dir}...</echo>
+ <property name="preinstallTargetExecuted" value="2a"/>
+ </target>
+
+ <target name="postinstall">
+ <echo>Done deploying Test Bundle v2.5 to ${rhq.deploy.dir}.</echo>
+ <property name="postinstallTargetExecuted" value="2b"/>
+ </target>
+
+</project>
\ No newline at end of file
commit 64407320dc3715ce09caf4c6f1f8c067602bddbd
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Dec 22 10:38:24 2010 -0500
put test more things in the ant launcher unit test
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
index bfc8d2e..86fd666 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
@@ -83,13 +83,18 @@ public class AntLauncher {
* @throws InvalidBuildFileException if the build file is invalid
*/
public BundleAntProject executeBundleDeployFile(File buildFile, Properties buildProperties,
- List<BuildListener> buildListeners)
- throws InvalidBuildFileException {
+ List<BuildListener> buildListeners) throws InvalidBuildFileException {
// Parse and validate the build file before even attempting to execute it.
- parseBundleDeployFile(buildFile);
+ BundleAntProject parsedProject = parseBundleDeployFile(buildFile);
BundleAntProject project = createProject(buildFile, false);
+ // The parse above got us all the bundle files names. The rest of this method
+ // will be able to re-determine everything else for 'project' but these filenames.
+ // Therefore, we need to copy those filenames from the parsedProject to project.
+ // The rest of project will be filled in later.
+ project.getBundleFileNames().addAll(parsedProject.getBundleFileNames());
+
try {
if (buildProperties != null) {
for (Map.Entry<Object, Object> property : buildProperties.entrySet()) {
@@ -133,10 +138,9 @@ public class AntLauncher {
try {
// Use the 3-param version of parse(), rather than the 2-param version, or ProjectHelper.configureProject(),
// to avoid actually executing the implicit target (which would cause the rhq:bundle task to be executed).
- AntXMLContext context = (AntXMLContext) project.getReference(REFID_CONTEXT);
- projectHelper.parse(project, buildFile,
- new ProjectHelper2.RootHandler(context,
- new ProjectHelper2.MainHandler()));
+ AntXMLContext context = (AntXMLContext) project.getReference(REFID_CONTEXT);
+ projectHelper.parse(project, buildFile, new ProjectHelper2.RootHandler(context,
+ new ProjectHelper2.MainHandler()));
} catch (BuildException e) {
throw new InvalidBuildFileException("Failed to parse bundle Ant build file.", e);
}
@@ -210,7 +214,7 @@ public class AntLauncher {
for (Object targetObj : targets) {
Target target = (Target) targetObj;
Task[] tasks = target.getTasks();
- for (Task task : tasks) {
+ for (Task task : tasks) {
if (task.getTaskName().equals(BUNDLE_TASK_NAME)) {
abortIfTaskWithinTarget(target, task);
bundleTaskCount++;
@@ -230,7 +234,8 @@ public class AntLauncher {
BundleTask bundleTask = (BundleTask) preconfigureTask(unconfiguredBundleTask);
Collection<DeploymentUnitType> deployments = bundleTask.getDeploymentUnits().values();
if (deployments.isEmpty()) {
- throw new InvalidBuildFileException("The bundle task must contain exactly one rhq:deploymentUnit child element.");
+ throw new InvalidBuildFileException(
+ "The bundle task must contain exactly one rhq:deploymentUnit child element.");
}
DeploymentUnitType deployment = deployments.iterator().next();
Map<File, File> files = deployment.getFiles();
diff --git a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
index 831bdf9..8a12139 100644
--- a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
@@ -28,6 +28,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.DefaultLogger;
@@ -53,17 +54,26 @@ public class AntLauncherTest {
BundleAntProject project = ant.parseBundleDeployFile(getBuildXml("test-bundle-v1.xml"));
assert project != null;
- /*Map<String, String> bundleFiles = project.getBundleFiles();
+ Set<String> bundleFiles = project.getBundleFileNames();
assert bundleFiles != null;
- assert bundleFiles.size() == 2 : bundleFiles;
- assert bundleFiles.get("f").equals("test-v2.properties") : bundleFiles;
- assert bundleFiles.get("pkg").equals("package.zip") : bundleFiles;*/
+ assert bundleFiles.size() == 4 : bundleFiles;
+ assert bundleFiles.contains("test-v1.properties") : bundleFiles;
+ assert bundleFiles.contains("file.zip") : bundleFiles;
+ assert bundleFiles.contains("foo-script") : bundleFiles; // from install-system-service
+ assert bundleFiles.contains("foo-config") : bundleFiles; // from install-system-service
+
+ assert project.getBundleName().equals("example.com (JBoss EAP 4.3)");
+ assert project.getBundleVersion().equals("1.0");
+ assert project.getBundleDescription().equals("example.com corporate website hosted on JBoss EAP 4.3");
ConfigurationDefinition configDef = project.getConfigurationDefinition();
assert configDef.getPropertyDefinitions().size() == 1 : configDef.getPropertyDefinitions();
PropertyDefinitionSimple propDef = configDef.getPropertyDefinitionSimple("listener.port");
assert propDef != null;
assert propDef.getType() == PropertySimpleType.INTEGER;
+ assert propDef.getDefaultValue().equals("8080");
+ assert propDef.getDescription().equals("This is where the product will listen for incoming messages");
+ assert propDef.isRequired();
}
public void testInstall() throws Exception {
@@ -75,27 +85,37 @@ public class AntLauncherTest {
List<BuildListener> buildListeners = createBuildListeners();
BundleAntProject project = ant.executeBundleDeployFile(getBuildXml("test-bundle-v1.xml"), inputProps,
- buildListeners);
- /*Map<String, String> bundleFiles = project.getBundleFiles();
+ buildListeners);
+ assert project != null;
+ Set<String> bundleFiles = project.getBundleFileNames();
assert bundleFiles != null;
- assert bundleFiles.size() == 2 : bundleFiles;
- assert bundleFiles.get("f").equals("test-v2.properties") : bundleFiles;
- assert bundleFiles.get("pkg").equals("package.zip") : bundleFiles;*/
+ assert bundleFiles.size() == 4 : bundleFiles;
+ assert bundleFiles.contains("test-v1.properties") : bundleFiles;
+ assert bundleFiles.contains("file.zip") : bundleFiles;
+ assert bundleFiles.contains("foo-script") : bundleFiles; // from install-system-service
+ assert bundleFiles.contains("foo-config") : bundleFiles; // from install-system-service
+
+ assert project.getBundleName().equals("example.com (JBoss EAP 4.3)");
+ assert project.getBundleVersion().equals("1.0");
+ assert project.getBundleDescription().equals("example.com corporate website hosted on JBoss EAP 4.3");
ConfigurationDefinition configDef = project.getConfigurationDefinition();
assert configDef.getPropertyDefinitions().size() == 1 : configDef.getPropertyDefinitions();
PropertyDefinitionSimple propDef = configDef.getPropertyDefinitionSimple("listener.port");
assert propDef != null;
assert propDef.getType() == PropertySimpleType.INTEGER;
+ assert propDef.getDefaultValue().equals("8080");
+ assert propDef.getDescription().equals("This is where the product will listen for incoming messages");
+ assert propDef.isRequired();
Configuration config = project.getConfiguration();
assert config.getProperties().size() == 1 : config.getProperties();
assert "10000".equals(config.getSimpleValue("listener.port", null)) : config.getProperties();
-
+
String preinstallTargetExecuted = (String) project.getProperties().get("preinstallTargetExecuted");
- assert preinstallTargetExecuted.equals("true");
+ assert preinstallTargetExecuted.equals("1a");
String postinstallTargetExecuted = (String) project.getProperties().get("postinstallTargetExecuted");
- assert postinstallTargetExecuted.equals("true");
+ assert postinstallTargetExecuted.equals("1b");
}
private List<BuildListener> createBuildListeners() {
@@ -117,28 +137,43 @@ public class AntLauncherTest {
List<BuildListener> buildListeners = createBuildListeners();
BundleAntProject project = ant.executeBundleDeployFile(getBuildXml("test-bundle-v2.xml"), inputProps,
- buildListeners);
- /*Map<String, String> bundleFiles = project.getBundleFiles();
+ buildListeners);
+ assert project != null;
+ Set<String> bundleFiles = project.getBundleFileNames();
assert bundleFiles != null;
- assert bundleFiles.size() == 2 : bundleFiles;
- assert bundleFiles.get("f").equals("test-v2.properties") : bundleFiles;
- assert bundleFiles.get("pkg").equals("package.zip") : bundleFiles;*/
+ assert bundleFiles.size() == 4 : bundleFiles;
+ assert bundleFiles.contains("test-v2.properties") : bundleFiles;
+ assert bundleFiles.contains("file.zip") : bundleFiles;
+ assert bundleFiles.contains("foo-script") : bundleFiles; // from install-system-service
+ assert bundleFiles.contains("foo-config") : bundleFiles; // from install-system-service
+
+ assert project.getBundleName().equals("example.com (JBoss EAP 4.3)");
+ assert project.getBundleVersion().equals("2.5");
+ assert project.getBundleDescription().equals("updated bundle");
ConfigurationDefinition configDef = project.getConfigurationDefinition();
- assert configDef.getPropertyDefinitions().size() == 1;
+ assert configDef.getPropertyDefinitions().size() == 1 : configDef.getPropertyDefinitions();
PropertyDefinitionSimple propDef = configDef.getPropertyDefinitionSimple("listener.port");
assert propDef != null;
assert propDef.getType() == PropertySimpleType.INTEGER;
+ assert propDef.getDefaultValue().equals("9090");
+ assert propDef.getDescription().equals("This is where the product will listen for incoming messages");
+ assert propDef.isRequired();
Configuration config = project.getConfiguration();
assert config.getProperties().size() == 1;
assert "20000".equals(config.getSimpleValue("listener.port", null)) : config.getProperties();
+
+ String preinstallTargetExecuted = (String) project.getProperties().get("preinstallTargetExecuted");
+ assert preinstallTargetExecuted.equals("2a");
+ String postinstallTargetExecuted = (String) project.getProperties().get("postinstallTargetExecuted");
+ assert postinstallTargetExecuted.equals("2b");
}
private Properties createInputProperties(String resourcePath) throws IOException {
Properties inputProps = new Properties();
inputProps.setProperty(DeployPropertyNames.DEPLOY_DIR, DEPLOY_DIR.getPath());
- inputProps.setProperty(DeployPropertyNames.DEPLOY_ID, "100");
+ inputProps.setProperty(DeployPropertyNames.DEPLOY_ID, "100");
inputProps.setProperty(DeployPropertyNames.DEPLOY_PHASE, DeploymentPhase.INSTALL.name());
InputStream inputStream = this.getClass().getResourceAsStream(resourcePath);
try {
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml b/modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml
index 76820bf..a6dcfec 100644
--- a/modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-v1.xml
@@ -34,12 +34,12 @@
<target name="preinstall">
<echo>Deploying Test Bundle v1.0 to ${rhq.deploy.dir}...</echo>
- <property name="preinstallTargetExecuted" value="true"/>
+ <property name="preinstallTargetExecuted" value="1a"/>
</target>
<target name="postinstall">
<echo>Done deploying Test Bundle v1.0 to ${rhq.deploy.dir}.</echo>
- <property name="postinstallTargetExecuted" value="true"/>
+ <property name="postinstallTargetExecuted" value="1b"/>
</target>
</project>
\ No newline at end of file
diff --git a/modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml b/modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml
index 6764c13..1bbe0d1 100644
--- a/modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-v2.xml
@@ -2,14 +2,14 @@
<project name="test-bundle" default="main" xmlns:rhq="antlib:org.rhq.bundle">
- <rhq:bundle name="example.com (JBoss EAP 4.3)" version="1.0"
- description="example.com corporate website hosted on JBoss EAP 4.3">
+ <rhq:bundle name="example.com (JBoss EAP 4.3)" version="2.5"
+ description="updated bundle">
<rhq:input-property
name="listener.port"
description="This is where the product will listen for incoming messages"
required="true"
- defaultValue="8080"
+ defaultValue="9090"
type="integer"/>
<rhq:deployment-unit name="appserver" preinstallTarget="preinstall" postinstallTarget="postinstall">
@@ -33,13 +33,13 @@
<target name="main"/>
<target name="preinstall">
- <echo>Deploying Test Bundle v1.0 to ${rhq.deploy.dir}...</echo>
- <property name="preinstallTargetExecuted" value="true"/>
+ <echo>Deploying Test Bundle v2.5 to ${rhq.deploy.dir}...</echo>
+ <property name="preinstallTargetExecuted" value="2a"/>
</target>
<target name="postinstall">
- <echo>Done deploying Test Bundle v1.0 to ${rhq.deploy.dir}.</echo>
- <property name="postinstallTargetExecuted" value="true"/>
+ <echo>Done deploying Test Bundle v2.5 to ${rhq.deploy.dir}.</echo>
+ <property name="postinstallTargetExecuted" value="2b"/>
</target>
</project>
\ No newline at end of file
13 years, 4 months