[rhq] 2 commits - modules/common modules/core modules/enterprise
by mazz
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java | 67
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java | 8
modules/core/util/src/main/java/org/rhq/core/util/updater/ChangesFileHashcodeMap.java | 9
modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java | 26
modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java | 14
modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java | 66
modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java | 14
modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java | 109
modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java | 1101 ++++++++++
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java | 37
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java | 37
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java | 94
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 9
17 files changed, 1490 insertions(+), 109 deletions(-)
New commits:
commit 067f66c0c2e4f1e9f544158f9d356f0ca70f2479
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Dec 22 03:25:03 2010 -0500
BZ 659142 - Add support for deploying bundles into a folder in which
the bundle doesn't have exclusive usage. this is to support being able to deploy
a bundle in a JBossAS deploy/ directory. All unit tests pass with this
commit, with a new set of unit tests being added to test this
feature. however, more testing needs to be done on the ant recipe side
to make sure the ant recipe is passing this flag correctly to the
Deployer utility.
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 dda489c..3727adb 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
@@ -17,9 +17,19 @@
*/
package org.rhq.bundle.ant.type;
+import java.io.File;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
+
import org.rhq.bundle.ant.DeployPropertyNames;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -30,15 +40,6 @@ import org.rhq.core.util.updater.Deployer;
import org.rhq.core.util.updater.DeploymentData;
import org.rhq.core.util.updater.DeploymentProperties;
-import java.io.File;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-
/**
* An Ant task for deploying a bundle or previewing the deployment.
*
@@ -46,13 +47,13 @@ import java.util.regex.Pattern;
*/
public class DeploymentUnitType extends AbstractBundleType {
private String name;
+ private String manageRootDir = Boolean.TRUE.toString();
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, Pattern> archiveReplacePatterns = new HashMap<File, Pattern>();
private SystemServiceType systemService;
private Pattern ignorePattern;
- private boolean preview;
private String preinstallTarget;
private String postinstallTarget;
@@ -78,7 +79,8 @@ public class DeploymentUnitType extends AbstractBundleType {
TemplateEngine templateEngine = createTemplateEngine();
if (this.files.isEmpty() && this.archives.isEmpty()) {
- throw new BuildException("You must specify at least one file to deploy via nested rhq:file, rhq:archive, and/or rhq:system-service elements.");
+ throw new BuildException(
+ "You must specify at least one file to deploy via nested rhq:file, rhq:archive, and/or rhq:system-service elements.");
}
if (!this.files.isEmpty()) {
log("Deploying files " + this.files + "...", Project.MSG_VERBOSE);
@@ -87,8 +89,17 @@ public class DeploymentUnitType extends AbstractBundleType {
log("Deploying archives " + this.archives + "...", Project.MSG_VERBOSE);
}
+ boolean willManageRootDir = Boolean.parseBoolean(this.manageRootDir);
+ if (willManageRootDir) {
+ log("Managing the root directory of this deployment unit - unrelated files found will be removed",
+ Project.MSG_VERBOSE);
+ } else {
+ log("Not managing the root directory of this deployment unit - unrelated files will remain intact",
+ Project.MSG_VERBOSE);
+ }
+
DeploymentData deploymentData = new DeploymentData(deploymentProps, this.archives, this.files, deployDir,
- this.archiveReplacePatterns, this.rawFilesToReplace, templateEngine, this.ignorePattern);
+ this.archiveReplacePatterns, this.rawFilesToReplace, templateEngine, this.ignorePattern, willManageRootDir);
Deployer deployer = new Deployer(deploymentData);
try {
DeployDifferences diffs = getProject().getDeployDifferences();
@@ -98,7 +109,7 @@ public class DeploymentUnitType extends AbstractBundleType {
} else {
deployer.deploy(diffs, clean, dryRun);
}
- getProject().log("Results:\n" + diffs + "\n");
+ getProject().log("Results:\n" + diffs + "\n");
} catch (Exception e) {
throw new BuildException("Failed to deploy bundle '" + getProject().getBundleName() + "' version "
+ getProject().getBundleVersion() + ": " + e, e);
@@ -111,7 +122,8 @@ public class DeploymentUnitType extends AbstractBundleType {
if (this.postinstallTarget != null) {
Target target = (Target) getProject().getTargets().get(this.postinstallTarget);
if (target == null) {
- throw new BuildException("Specified postinstall target (" + this.postinstallTarget + ") does not exist.");
+ throw new BuildException("Specified postinstall target (" + this.postinstallTarget
+ + ") does not exist.");
}
target.performTasks();
}
@@ -140,7 +152,7 @@ public class DeploymentUnitType extends AbstractBundleType {
this.systemService.uninstall();
}
}
-
+
public String getName() {
return name;
}
@@ -149,20 +161,24 @@ public class DeploymentUnitType extends AbstractBundleType {
this.name = name;
}
- public Map<File, File> getFiles() {
- return files;
+ public String getManageRootDir() {
+ return manageRootDir;
}
- public Set<File> getArchives() {
- return archives;
+ public void setManageRootDir(String booleanString) {
+ if (!Boolean.TRUE.toString().equalsIgnoreCase(booleanString)
+ && !Boolean.FALSE.toString().equalsIgnoreCase(booleanString)) {
+ throw new BuildException("manageRootDir attribute must be 'true' or 'false': " + booleanString);
+ }
+ this.manageRootDir = booleanString;
}
- public boolean isPreview() {
- return this.preview;
+ public Map<File, File> getFiles() {
+ return files;
}
- public void setPreview(boolean preview) {
- this.preview = preview;
+ public Set<File> getArchives() {
+ return archives;
}
public String getPreinstallTarget() {
@@ -183,7 +199,8 @@ public class DeploymentUnitType extends AbstractBundleType {
public void addConfigured(SystemServiceType systemService) {
if (this.systemService != null) {
- throw new IllegalStateException("A rhq:deploymentUnit element can only have one rhq:system-service child element.");
+ throw new IllegalStateException(
+ "A rhq:deployment-unit element can only have one rhq:system-service child element.");
}
this.systemService = systemService;
this.systemService.validate();
@@ -230,7 +247,7 @@ public class DeploymentUnitType extends AbstractBundleType {
}
// And add the special rhq.deploy.dir prop.
templateEngine.getTokens().put(DeployPropertyNames.DEPLOY_DIR,
- getProject().getProperty(DeployPropertyNames.DEPLOY_DIR));
+ getProject().getProperty(DeployPropertyNames.DEPLOY_DIR));
return templateEngine;
}
}
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/ChangesFileHashcodeMap.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/ChangesFileHashcodeMap.java
index 9fc824e..3f0c364 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/ChangesFileHashcodeMap.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/ChangesFileHashcodeMap.java
@@ -41,6 +41,7 @@ public class ChangesFileHashcodeMap extends FileHashcodeMap {
private final Map<String, String> additions = new HashMap<String, String>();
private final Map<String, String> changes = new HashMap<String, String>();
private final Set<String> ignored = new HashSet<String>();
+ private final Set<String> skipped = new HashSet<String>();
/**
* Creates an file/hashcode map populated with a map of original file data.
@@ -87,4 +88,12 @@ public class ChangesFileHashcodeMap extends FileHashcodeMap {
public Set<String> getIgnored() {
return ignored;
}
+
+ /**
+ * @return the files and directories located directly under the root deploy dir that were skipped.
+ * These are files/directories that are considered unrelated to the deployment and should be left alone.
+ */
+ public Set<String> getSkipped() {
+ return skipped;
+ }
}
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 2a4e99d..5116631 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
@@ -340,7 +340,7 @@ public class Deployer {
FileHashcodeMap original = this.deploymentsMetadata.getCurrentDeploymentFileHashcodes();
ChangesFileHashcodeMap current = original.rescan(this.deploymentData.getDestinationDir(), this.deploymentData
- .getIgnoreRegex());
+ .getIgnoreRegex(), this.deploymentData.isManageRootDir());
FileHashcodeMap newFiles = getNewDeploymentFileHashcodeMap();
if (current.getUnknownContent() != null) {
@@ -439,6 +439,9 @@ public class Deployer {
currentFilesToDelete.removeAll(newFiles.keySet());
currentFilesToDelete.removeAll(current.getDeletions().keySet()); // these are already deleted, no sense trying to delete them again
+ // remember what files were skipped so we don't delete them during our purge below (only care about this if we are going to 'clean')
+ Set<String> skippedFiles = (clean) ? current.getSkipped() : null;
+
// don't use this anymore - its underlying key set has been altered and this no longer is the full current files
current = null;
@@ -487,7 +490,7 @@ public class Deployer {
if (clean) {
debug("Cleaning the existing deployment's files found in the destination directory. dryRun=", dryRun);
if (!dryRun) {
- purgeFileOrDirectory(this.deploymentData.getDestinationDir(), false);
+ purgeFileOrDirectory(this.deploymentData.getDestinationDir(), skippedFiles, 0, false);
}
}
diff.setCleaned(clean);
@@ -816,8 +819,9 @@ public class Deployer {
restoreBackupFilesRecursive(child, base, destDir, map, diff, dryRun);
} else {
String childRelativePath = child.getAbsolutePath().substring(base.length());
+ //if (this.deploymentData.isManageRootDir() || new File(childRelativePath).getParent() != null) {
File restoredFile = new File(destDir, childRelativePath);
- debug("Restoring backup file [" + child + "] to [" + restoredFile + "]. dryRun=" + dryRun);
+ debug("Restoring backup file [", child, "] to [", restoredFile, "]. dryRun=", dryRun);
if (!dryRun) {
restoredFile.getParentFile().mkdirs();
String hashcode = copyFileAndCalcHashcode(child, restoredFile);
@@ -826,6 +830,10 @@ public class Deployer {
map.put(childRelativePath, MessageDigestGenerator.getDigestString(child));
}
diff.addRestoredFile(childRelativePath, child.getAbsolutePath());
+ //} else {
+ // debug("Skipping the restoration of the backed up file [", childRelativePath,
+ // "] since this deployment was told to not manage the root directory");
+ //}
}
}
}
@@ -843,7 +851,7 @@ public class Deployer {
} else {
String childRelativePath = child.getAbsolutePath().substring(base.length());
File restoredFile = new File(rootDir, childRelativePath);
- debug("Restoring backup file [" + child + "] to external location [" + restoredFile + "]. dryRun="
+ debug("Restoring backup file [", child, "] to external location [", restoredFile, "]. dryRun="
+ dryRun);
if (!dryRun) {
restoredFile.getParentFile().mkdirs();
@@ -882,14 +890,20 @@ public class Deployer {
}
}
- private void purgeFileOrDirectory(File fileOrDir, boolean deleteIt) {
+ private void purgeFileOrDirectory(File fileOrDir, Set<String> skippedFiles, int level, boolean deleteIt) {
// make sure we only purge deployment files, never the metadata directory or its files
+ // we also want to leave all skipped files alone - don't delete those since they are unrelated to our deployment
if (fileOrDir != null && !fileOrDir.getName().equals(DeploymentsMetadata.METADATA_DIR)) {
if (fileOrDir.isDirectory()) {
File[] doomedFiles = fileOrDir.listFiles();
if (doomedFiles != null) {
for (File doomedFile : doomedFiles) {
- purgeFileOrDirectory(doomedFile, true); // call this method recursively
+ // Do not purge any skipped files - we want to skip them.
+ // All our skipped files are always at the top root dir (level 0),
+ // so we can ignore the skipped set if we are at levels 1 or below since there are no skipped files down there
+ if (level != 0 || !skippedFiles.contains(doomedFile.getName())) {
+ purgeFileOrDirectory(doomedFile, skippedFiles, level + 1, true); // call this method recursively
+ }
}
}
}
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 32c1a26..b1fac47 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
@@ -47,6 +47,7 @@ public class DeploymentData {
private final Set<File> rawFilesToRealize;
private final TemplateEngine templateEngine;
private final Pattern ignoreRegex;
+ private final boolean manageRootDir;
/**
* Constructors that prepares this object with the data that is necessary in order to deploy archive/file content
@@ -69,10 +70,17 @@ public class DeploymentData {
* @param templateEngine if one or more filesToRealize are specified, this template engine is used to determine
* the values that should replace all replacement variables found in those files
* @param ignoreRegex the files/directories to ignore when updating an existing deployment
+ * @param manageRootDir if false, the top directory where the files will be deployed (i.e. the destinationDir)
+ * will be left alone. That is, if files already exist there, they will not be removed or
+ * otherwise merged with this deployment's root files. If true, this top root directory
+ * will be managed just as any subdirectory within the deployment will be managed.
+ * 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.
*/
public DeploymentData(DeploymentProperties deploymentProps, Set<File> zipFiles, Map<File, File> rawFiles,
File destinationDir, Map<File, Pattern> zipEntriesToRealizeRegex, Set<File> rawFilesToRealize,
- TemplateEngine templateEngine, Pattern ignoreRegex) {
+ TemplateEngine templateEngine, Pattern ignoreRegex, boolean manageRootDir) {
if (deploymentProps == null) {
throw new IllegalArgumentException("deploymentProps == null");
@@ -96,6 +104,7 @@ public class DeploymentData {
this.rawFiles = rawFiles;
this.destinationDir = destinationDir;
this.ignoreRegex = ignoreRegex;
+ this.manageRootDir = manageRootDir;
// 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)) {
@@ -143,4 +152,7 @@ public class DeploymentData {
return ignoreRegex;
}
+ public boolean isManageRootDir() {
+ return manageRootDir;
+ }
}
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java
index 5945abe..2a68f5d 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/FileHashcodeMap.java
@@ -204,18 +204,22 @@ public class FileHashcodeMap extends TreeMap<String, String> {
*
* The root directory is also scanned for new files that are not in this original
* map - if new files are found (and they do not match the ignoreRegex), they are added to the
- * returned map.
+ * returned map. Note that if <code>reportNewRootFilesAsNew</code> is false, and if new files
+ * are found in the top root directory and they are not related to the deployment fileset,
+ * they will not be added to the returned map.
*
* @param rootDir directory where the relative paths are expected to be
* @param ignoreRegex if relative paths of files under rootDir match this, they will be ignored.
* This will eliminate files/directories from being considered "new" because
* they aren't in original.
+ * @param reportNewRootFilesAsNew do not report as new any unrelated files found in the root dir
* @return a map with current files/hashcodes, including files that were not found in original.
* the returned object also has additional info such as those files that were added,
* deleted, changed from this original. It also indicates what was ignored during the rescan.
* @throws Exception
*/
- public ChangesFileHashcodeMap rescan(File rootDir, Pattern ignoreRegex) throws Exception {
+ public ChangesFileHashcodeMap rescan(File rootDir, Pattern ignoreRegex, boolean reportNewRootFilesAsNew)
+ throws Exception {
ChangesFileHashcodeMap current = new ChangesFileHashcodeMap(this);
// go through our original files and recalculate their hashcodes
@@ -253,9 +257,12 @@ public class FileHashcodeMap extends TreeMap<String, String> {
// now recursively traverse the root directory and look for new files that aren't in our original map
// files that have been added need to be put into our returned map and also marked as added
FileHashcodeMap newFiles = new FileHashcodeMap();
- lookForNewFilesRecursive(newFiles, rootDir.getAbsolutePath(), 0, rootDir, ignoreRegex, current.getIgnored());
+ Set<String> skippedFiles = new HashSet<String>();
+ lookForNewFilesRecursive(newFiles, skippedFiles, rootDir.getAbsolutePath(), 0, rootDir, ignoreRegex, current
+ .getIgnored(), reportNewRootFilesAsNew);
current.putAll(newFiles);
current.getAdditions().putAll(newFiles);
+ current.getSkipped().addAll(skippedFiles);
return current;
}
@@ -264,16 +271,24 @@ public class FileHashcodeMap extends TreeMap<String, String> {
* This looks for new files under the given fileOrDir and adds them to <code>newFiles</code>.
*
* @param newFiles the map where the new, current file/hashcode data will be stored
- * @param rootPath the top root directory that is being scanned
- * @param level the level deep in the file hierarchy currently being processed (0==at top root dir)
- * @param fileOrDir existing directory/file to rescan
+ * @param skippedFiles a set where names of unrelated files/directories are stored. The names
+ * found here after this method returns are those files/dirs that were found
+ * in the top level root dir, but were skipped over and not processed. This will not
+ * contain paths with subdirectories - they will only be a filename with no paths
+ * because they are located directly under the root dir.
+ * @param rootPath the top root directory that is being scanned
+ * @param level the level deep in the file hierarchy currently being processed (0==at top root dir)
+ * @param fileOrDir existing directory/file to rescan
* @param ignoreRegex a regular expression that indicates which files/directories should be ignored.
* If a relative file/directory path matches this regex, it will be skipped.
- * @param ignored a set that will contain those files/directories that were ignored while scanning the root dir
+ * @param ignored a set that will contain those files/directories that were ignored while scanning the root dir
+ * @param reportNewRootFilesAsNew if false, ignore unrelated files at the root dir location (level=0)
+ *
* @throws Exception
*/
- private void lookForNewFilesRecursive(FileHashcodeMap newFiles, String rootPath, int level, File fileOrDir,
- Pattern ignoreRegex, Set<String> ignored) throws Exception {
+ private void lookForNewFilesRecursive(FileHashcodeMap newFiles, Set<String> skippedFiles, String rootPath,
+ int level, File fileOrDir, Pattern ignoreRegex, Set<String> ignored, boolean reportNewRootFilesAsNew)
+ throws Exception {
if (fileOrDir == null || !fileOrDir.exists()) {
throw new Exception("Non-existent file/directory provided: " + fileOrDir);
@@ -301,10 +316,41 @@ public class FileHashcodeMap extends TreeMap<String, String> {
return;
}
+ // If we are currently at the top level and we are not to report unrelated files as new
+ // then we need to find out which files ARE related first. Related files are those files
+ // already in our Map at the root level (i.e. they are just a filename, no parent paths)
+ // plus those in our Map with a top parent dir name that match a child directory of
+ // fileOrDir (which is the root dir if we are at level=0).
+ // Note that we use File API to manipulate filenames/parents to ensure we do this right
+ // on Windows (taking care of relative paths with drive letters, e.g. C:subdir/file.txt).
+ HashSet<String> relatedTopLevelFiles = null;
+ if (level == 0 && !reportNewRootFilesAsNew) {
+ relatedTopLevelFiles = new HashSet<String>();
+ for (String relatedFilePath : keySet()) { // loop through our Map key entries, these are the "related" files
+ File relatedFile = new File(relatedFilePath);
+ if (!relatedFile.isAbsolute()) {
+ String topLevelName = relatedFile.getName(); // prime the pump; if we have no parent, this is our file already at the top root dir
+ File parent = relatedFile.getParentFile();
+ // walk up the file hierarchy until we hit the top parent - this is the related dir found in our top root
+ while (parent != null) {
+ topLevelName = parent.getName();
+ parent = parent.getParentFile();
+ }
+ relatedTopLevelFiles.add(topLevelName); // this is a file or dir at the top root dir
+ }
+ }
+ }
+
File[] children = fileOrDir.listFiles();
if (children != null) {
for (File child : children) {
- lookForNewFilesRecursive(newFiles, rootPath, level + 1, child, ignoreRegex, ignored);
+ // skip this child if we are at the top root dir and it is not related to our fileset
+ if (relatedTopLevelFiles == null || relatedTopLevelFiles.contains(child.getName())) {
+ lookForNewFilesRecursive(newFiles, skippedFiles, rootPath, level + 1, child, ignoreRegex,
+ ignored, reportNewRootFilesAsNew);
+ } else {
+ skippedFiles.add(child.getName());
+ }
}
}
} else {
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 50709cc..5f0fca6 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
@@ -256,7 +256,7 @@ public class DeployerTest {
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);
+ null, templateEngine, ignoreRegex, true);
Deployer deployer = new Deployer(dd);
diff = new DeployDifferences();
@@ -292,7 +292,7 @@ public class DeployerTest {
Map<File, Pattern> filesToRealizeRegex2 = new HashMap<File, Pattern>(1);
filesToRealizeRegex2.put(testZipFile2, realizeRegex);
dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, filesToRealizeRegex2, null,
- templateEngine, ignoreRegex);
+ templateEngine, ignoreRegex, true);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -420,7 +420,7 @@ public class DeployerTest {
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);
+ templateEngine, ignoreRegex, true);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -460,7 +460,7 @@ public class DeployerTest {
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);
+ templateEngine, ignoreRegex, true);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -526,7 +526,7 @@ public class DeployerTest {
Set<File> realizeRawFiles1 = new HashSet<File>(1);
realizeRawFiles1.add(testRawFileB);
DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, null,
- realizeRawFiles1, templateEngine, ignoreRegex);
+ realizeRawFiles1, templateEngine, ignoreRegex, true);
Deployer deployer = new Deployer(dd);
DeployDifferences diff = new DeployDifferences();
FileHashcodeMap map = deployer.deploy(diff);
@@ -580,7 +580,7 @@ public class DeployerTest {
realizeRawFiles1.add(testZipFile2);
realizeRawFiles1.add(testRawFileB);
DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, null,
- realizeRawFiles1, templateEngine, ignoreRegex);
+ realizeRawFiles1, templateEngine, ignoreRegex, true);
Deployer deployer = new Deployer(dd);
DeployDifferences listener = new DeployDifferences();
deployer.deploy(listener);
@@ -678,7 +678,7 @@ public class DeployerTest {
realizeRegex1.put(testZipFile1, filesToRealizeRegex);
DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir, realizeRegex1, null,
- templateEngine, ignoreRegex);
+ templateEngine, ignoreRegex, true);
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/FileHashcodeMapTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
index 2fce1e4..034f1e8 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/FileHashcodeMapTest.java
@@ -77,17 +77,18 @@ public class FileHashcodeMapTest {
assert ignored.contains("ignoreme1.txt") : ignored;
// first test - see that no changes can be detected
- ChangesFileHashcodeMap currentMap = originalMap.rescan(tmpDir, ignoreRegex);
+ ChangesFileHashcodeMap currentMap = originalMap.rescan(tmpDir, ignoreRegex, true);
assertSameMap(originalMap, currentMap);
assert currentMap.getAdditions().isEmpty();
assert currentMap.getDeletions().isEmpty();
assert currentMap.getChanges().isEmpty();
assert currentMap.getIgnored().size() == 1 : currentMap;
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap;
+ assert currentMap.getSkipped().size() == 0;
// second test - change an original file
StreamUtil.copy(new ByteArrayInputStream("test1-change".getBytes()), new FileOutputStream(testFile1));
- currentMap = originalMap.rescan(tmpDir, ignoreRegex);
+ currentMap = originalMap.rescan(tmpDir, ignoreRegex, true);
assert currentMap.size() == 2 : currentMap;
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
@@ -99,10 +100,11 @@ public class FileHashcodeMapTest {
assert currentMap.getChanges().get("test1.txt").equals(currentMap.get("test1.txt"));
assert currentMap.getIgnored().size() == 1 : currentMap;
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap;
+ assert currentMap.getSkipped().size() == 0;
// third test - delete an original file
assert testFile1.delete() : "could not delete file in order to test delete-detection";
- currentMap = originalMap.rescan(tmpDir, ignoreRegex);
+ currentMap = originalMap.rescan(tmpDir, ignoreRegex, true);
assert currentMap.size() == 2 : currentMap;
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
@@ -114,12 +116,13 @@ public class FileHashcodeMapTest {
assert currentMap.getChanges().isEmpty();
assert currentMap.getIgnored().size() == 1 : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap.getIgnored();
+ assert currentMap.getSkipped().size() == 0;
// fourth test - add a new file
StreamUtil.copy(new ByteArrayInputStream("test1".getBytes()), new FileOutputStream(testFile1));
File testFile3 = new File(tmpDir, "test3.txt");
StreamUtil.copy(new ByteArrayInputStream("test3".getBytes()), new FileOutputStream(testFile3));
- currentMap = originalMap.rescan(tmpDir, ignoreRegex);
+ currentMap = originalMap.rescan(tmpDir, ignoreRegex, true);
assert currentMap.size() == 3 : currentMap;
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
@@ -133,6 +136,7 @@ public class FileHashcodeMapTest {
assert currentMap.getChanges().isEmpty();
assert currentMap.getIgnored().size() == 1 : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap.getIgnored();
+ assert currentMap.getSkipped().size() == 0;
// fifth test - concurrently change a file, delete a file add new file and add new file in new directory
// changed file: testFile1
@@ -149,7 +153,7 @@ public class FileHashcodeMapTest {
assert ignoreFile2.getParentFile().mkdirs() : "could not create new subdirectory for test";
StreamUtil.copy(new ByteArrayInputStream("ignore2".getBytes()), new FileOutputStream(ignoreFile2));
- currentMap = originalMap.rescan(tmpDir, ignoreRegex);
+ currentMap = originalMap.rescan(tmpDir, ignoreRegex, true);
assert currentMap.size() == 4 : currentMap;
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
@@ -171,6 +175,7 @@ public class FileHashcodeMapTest {
assert currentMap.getIgnored().size() == 2 : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme") : currentMap.getIgnored();
+ assert currentMap.getSkipped().size() == 0;
// sixth test - starting from 5th test above, add an absolute path file
absPathFile = File.createTempFile("fileHashcodeMapTestFile", ".test");
@@ -178,7 +183,7 @@ public class FileHashcodeMapTest {
StreamUtil.copy(new ByteArrayInputStream("abs".getBytes()), new FileOutputStream(absPathFile));
originalMap.put(absPathFile.getAbsolutePath(), MessageDigestGenerator.getDigestString(absPathFile));
- currentMap = originalMap.rescan(tmpDir, ignoreRegex);
+ currentMap = originalMap.rescan(tmpDir, ignoreRegex, true);
assert currentMap.size() == 5 : currentMap;
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
@@ -203,10 +208,11 @@ public class FileHashcodeMapTest {
assert currentMap.getIgnored().size() == 2 : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme") : currentMap.getIgnored();
+ assert currentMap.getSkipped().size() == 0;
// seventh test - detect that the absolute path file has changed
StreamUtil.copy(new ByteArrayInputStream("abs-changed".getBytes()), new FileOutputStream(absPathFile));
- currentMap = originalMap.rescan(tmpDir, ignoreRegex);
+ currentMap = originalMap.rescan(tmpDir, ignoreRegex, true);
assert currentMap.size() == 5 : currentMap;
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
@@ -233,10 +239,11 @@ public class FileHashcodeMapTest {
assert currentMap.getIgnored().size() == 2 : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme") : currentMap.getIgnored();
+ assert currentMap.getSkipped().size() == 0;
// eighth test - detect absolute path file has been deleted
assert absPathFile.delete() : "could not delete the absolute path file for testing";
- currentMap = originalMap.rescan(tmpDir, ignoreRegex);
+ currentMap = originalMap.rescan(tmpDir, ignoreRegex, true);
assert currentMap.size() == 5 : currentMap;
assert currentMap.containsKey("test1.txt") : currentMap;
assert currentMap.containsKey("test2.txt") : currentMap;
@@ -262,6 +269,92 @@ public class FileHashcodeMapTest {
assert currentMap.getIgnored().size() == 2 : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme1.txt") : currentMap.getIgnored();
assert currentMap.getIgnored().contains("ignoreme") : currentMap.getIgnored();
+ assert currentMap.getSkipped().size() == 0;
+
+ } finally {
+ FileUtil.purge(tmpDir, true);
+ if (absPathFile != null) {
+ absPathFile.delete();
+ }
+ }
+ }
+
+ public void testRescanSkipNewRootDirFiles() throws Exception {
+ File absPathFile = null;
+ File tmpDir = FileUtil.createTempDirectory("fileHashcodeMapTest", ".dir", null);
+ try {
+ File testFile1 = new File(tmpDir, "test1.txt");
+ File testFile2 = new File(tmpDir, "testsubdir/test2.txt");
+ File ignoreFile1 = new File(tmpDir, "ignoreme1.txt");
+ Pattern ignoreRegex = Pattern.compile("ignoreme.*");
+
+ assert testFile2.getParentFile().mkdirs() : "could not create testsubdir";
+
+ StreamUtil.copy(new ByteArrayInputStream("test1".getBytes()), new FileOutputStream(testFile1));
+ StreamUtil.copy(new ByteArrayInputStream("test2".getBytes()), new FileOutputStream(testFile2));
+ StreamUtil.copy(new ByteArrayInputStream("ignore1".getBytes()), new FileOutputStream(ignoreFile1));
+
+ Set<String> ignored = new HashSet<String>();
+ FileHashcodeMap originalMap = FileHashcodeMap.generateFileHashcodeMap(tmpDir, ignoreRegex, ignored);
+ assert originalMap.size() == 2 : originalMap;
+ assert originalMap.containsKey("test1.txt") : originalMap;
+ assert originalMap.containsKey("testsubdir/test2.txt") : originalMap;
+ assert ignored.size() == 1 : ignored;
+ assert ignored.contains("ignoreme1.txt") : ignored;
+
+ // concurrently change a file, delete a file add new file and add new file in new directory
+ // changed file: testFile1
+ // deleted file: testFile2
+ // added file: testFile3 (should not be reported as new, its unrelated)
+ // added file in original directory: testsubdir/testFile4 (should be reported, its in related dir "testsubdir")
+ // I'll add an "ignoreme" directory just to see that it still gets ignored (technically it will get skipped)
+ StreamUtil.copy(new ByteArrayInputStream("test1-change".getBytes()), new FileOutputStream(testFile1));
+ assert testFile2.delete() : "could not delete file in order to test delete-detection";
+ File testFile3 = new File(tmpDir, "test3.txt");
+ StreamUtil.copy(new ByteArrayInputStream("test3".getBytes()), new FileOutputStream(testFile3));
+ File testFile4 = new File(tmpDir, "testsubdir/test4.txt");
+ StreamUtil.copy(new ByteArrayInputStream("test4".getBytes()), new FileOutputStream(testFile4));
+ File ignoreFile2 = new File(tmpDir, "ignoreme/ignore2.txt");
+ assert ignoreFile2.getParentFile().mkdirs() : "could not create new subdirectory for test";
+ StreamUtil.copy(new ByteArrayInputStream("ignore2".getBytes()), new FileOutputStream(ignoreFile2));
+
+ // now add some more unrelated files/dirs - these should not be reported as new
+ File unrelatedFile1 = new File(tmpDir, "unrelated1.txt");
+ File unrelatedFile2 = new File(tmpDir, "unrelatedsubdir/unrelated2.txt");
+ assert unrelatedFile2.getParentFile().mkdirs() : "could not create unrelated subdir";
+ StreamUtil.copy(new ByteArrayInputStream("unrelated1".getBytes()), new FileOutputStream(unrelatedFile1));
+ StreamUtil.copy(new ByteArrayInputStream("unrelated2".getBytes()), new FileOutputStream(unrelatedFile2));
+ assert unrelatedFile1.exists(); // sanity check
+ assert unrelatedFile2.exists(); // sanity check
+
+ ChangesFileHashcodeMap currentMap = originalMap.rescan(tmpDir, ignoreRegex, false);
+ assert currentMap.size() == 3 : currentMap;
+ assert currentMap.containsKey("test1.txt") : currentMap;
+ assert currentMap.containsKey("testsubdir/test2.txt") : currentMap;
+ assert !currentMap.containsKey("test3.txt") : currentMap;
+ assert currentMap.containsKey("testsubdir" + fileSeparator + "test4.txt") : currentMap;
+ assert !currentMap.get("test1.txt").equals(originalMap.get("test1.txt")) : currentMap + ":" + originalMap;
+ assert currentMap.get("testsubdir/test2.txt").equals(FileHashcodeMap.DELETED_FILE_HASHCODE) : currentMap;
+ assert currentMap.get("testsubdir" + fileSeparator + "test4.txt").equals(
+ MessageDigestGenerator.getDigestString(testFile4)) : currentMap;
+ assert currentMap.getAdditions().size() == 1;
+ assert currentMap.getAdditions().get("testsubdir" + fileSeparator + "test4.txt").equals(
+ currentMap.get("testsubdir" + fileSeparator + "test4.txt"));
+ assert currentMap.getDeletions().size() == 1;
+ assert currentMap.getDeletions().get("testsubdir/test2.txt").equals(currentMap.get("testsubdir/test2.txt"));
+ assert currentMap.getChanges().size() == 1;
+ assert currentMap.getChanges().get("test1.txt").equals(currentMap.get("test1.txt"));
+ // because we are not managing the root dir, those ignore dirs are totally skipped since they are in the root dir
+ // therefore, they aren't ignored due to the regex, they are skipped due to reportNewRootFilesAsNew=false
+ assert currentMap.getIgnored().size() == 0 : currentMap.getIgnored();
+ // now we can look at what was really skipped which were:
+ // test3.txt, unrelatedsubdir, ignoreme, unrelated1.txt, ignoreme1.txt
+ assert currentMap.getSkipped().size() == 5 : currentMap.getSkipped();
+ assert currentMap.getSkipped().contains("test3.txt") : currentMap.getSkipped();
+ assert currentMap.getSkipped().contains("ignoreme1.txt") : currentMap.getSkipped();
+ assert currentMap.getSkipped().contains("ignoreme") : currentMap.getSkipped();
+ assert currentMap.getSkipped().contains("unrelatedsubdir") : currentMap.getSkipped();
+ assert currentMap.getSkipped().contains("unrelated1.txt") : currentMap.getSkipped();
} finally {
FileUtil.purge(tmpDir, true);
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
new file mode 100644
index 0000000..88d2731
--- /dev/null
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
@@ -0,0 +1,1101 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.util.updater;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.util.MessageDigestGenerator;
+import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.stream.StreamUtil;
+
+/**
+ * Individually tests these situations but with the "manageRootDir" flag off so we should not
+ * remove files not involved in the deployment that are found in the root destination dir:
+ *
+ * (X, Y, Z, ? represent hashcodes; none means file doesn't exist):
+ *
+ * ORIGINAL CURRENT NEW What To Do...
+ * a. X X X New file is installed over current*
+ * b. X X Y New file is installed over current
+ * c. X Y X Current file is left as-is
+ * d. X Y Y New file is installed over current*
+ * e. X Y Z New file is installed over current, current is backed up
+ * f. none ? ? New file is installed over current, current is backed up
+ * g. X none ? New file is installed
+ * h. ? ? none Current file deleted, backed up if different than original
+ *
+ * (*) means the new and current files will actually be the same content
+ *
+ * @author John Mazzitelli
+ */
+@Test
+public class ManageRootDirTest {
+
+ private final String originalContent = "original content";
+ private final String originalFileName = "original_file_name.txt";
+ private final String unrelatedContent = "unrelated file content";
+ private final String unrelatedFileName = "unrelated_file_name.txt";
+ private final String unrelatedDirName = "unrelated_dir";
+ private File tmpDir;
+ private File deployDir;
+ private File originalZipFile;
+ private Set<File> originalZipFiles;
+ private DeploymentProperties originalDeployProps;
+ private FileHashcodeMap originalFileHashcodeMap;
+ private String originalHashcode;
+ private File currentFile;
+ private DeploymentProperties newDeployProps;
+ private DeployDifferences diff;
+ private DeploymentsMetadata metadata;
+ private File unrelatedFile;
+ private String unrelatedFileHashcode;
+ private File unrelatedDir;
+ private File unrelatedDirFile;
+ private String unrelatedDirFileHashcode;
+
+ @BeforeMethod
+ public void beforeMethod() throws Exception {
+ this.tmpDir = FileUtil.createTempDirectory("simpleDeployer_TMP", ".test", null);
+ this.deployDir = FileUtil.createTempDirectory("simpleDeployer", ".test", null);
+ this.unrelatedFile = writeFile(unrelatedContent, deployDir, unrelatedFileName);
+ this.unrelatedFileHashcode = MessageDigestGenerator.getDigestString(unrelatedContent);
+ this.unrelatedDir = new File(this.deployDir, this.unrelatedDirName);
+ assert this.unrelatedDir.mkdirs() : "Failed to create a test dir";
+ this.unrelatedDirFile = writeFile(unrelatedContent, this.unrelatedDir, unrelatedFileName);
+ this.unrelatedDirFileHashcode = MessageDigestGenerator.getDigestString(unrelatedContent);
+ this.originalHashcode = MessageDigestGenerator.getDigestString(originalContent);
+ this.originalZipFile = createZip(originalContent, tmpDir, "original.zip", originalFileName);
+ 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);
+ Deployer deployer = new Deployer(dd);
+ this.originalFileHashcodeMap = deployer.deploy(null);
+ this.currentFile = new File(deployDir, originalFileName);
+
+ this.newDeployProps = new DeploymentProperties(2, "simple", "2.0", "new test deployment");
+ this.diff = new DeployDifferences();
+ this.metadata = new DeploymentsMetadata(this.deployDir);
+
+ // sanity check due to my paranoia
+ assert this.currentFile.exists();
+ assert this.originalHashcode.equals(MessageDigestGenerator.getDigestString(currentFile));
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ assert this.unrelatedFile.exists();
+ assert this.unrelatedDirFile.exists();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void afterMethod() throws Exception {
+ FileUtil.purge(this.tmpDir, true);
+ FileUtil.purge(this.deployDir, true);
+ }
+
+ public void testX_X_X() throws Exception {
+ baseX_X_X(false);
+ }
+
+ public void testX_X_Y() throws Exception {
+ baseX_X_Y(false);
+ }
+
+ public void testX_Y_X() throws Exception {
+ baseX_Y_X(false);
+ }
+
+ public void testX_Y_Y() throws Exception {
+ baseX_Y_Y(false);
+ }
+
+ public void testX_Y_Z() throws Exception {
+ baseX_Y_Z(false);
+ }
+
+ public void testX_Y_Z_Restore() throws Exception {
+ baseX_Y_Z_Restore(false);
+ }
+
+ public void testX_Y_Z_Clean() throws Exception {
+ baseX_Y_Z_Clean(false);
+ }
+
+ public void testNoOriginalNoCurrentWithNew() throws Exception {
+ baseNoOriginalNoCurrentWithNew(false);
+ }
+
+ public void testNoOriginalWithCurrentWithNew() throws Exception {
+ baseNoOriginalWithCurrentWithNew(false);
+ }
+
+ public void testNoCurrent() throws Exception {
+ baseNoCurrent(false);
+ }
+
+ public void testNoNew() throws Exception {
+ baseNoNew(false);
+ }
+
+ public void testNoNewWithCurrentDifferentThanOriginal() throws Exception {
+ baseNoNewWithCurrentDifferentThanOriginal(false);
+ }
+
+ public void testX_X_X_DryRun() throws Exception {
+ baseX_X_X(true);
+ }
+
+ public void testX_X_Y_DryRun() throws Exception {
+ baseX_X_Y(true);
+ }
+
+ public void testX_Y_X_DryRun() throws Exception {
+ baseX_Y_X(true);
+ }
+
+ public void testX_Y_Y_DryRun() throws Exception {
+ baseX_Y_Y(true);
+ }
+
+ public void testX_Y_Z_DryRun() throws Exception {
+ baseX_Y_Z(true);
+ }
+
+ public void testX_Y_Z_Restore_DryRun() throws Exception {
+ baseX_Y_Z_Restore(true);
+ }
+
+ public void testX_Y_Z_Clean_DryRun() throws Exception {
+ baseX_Y_Z_Clean(true);
+ }
+
+ public void testNoOriginalNoCurrentWithNew_DryRun() throws Exception {
+ baseNoOriginalNoCurrentWithNew(true);
+ }
+
+ public void testNoOriginalWithCurrentWithNew_DryRun() throws Exception {
+ baseNoOriginalWithCurrentWithNew(true);
+ }
+
+ public void testNoCurrent_DryRun() throws Exception {
+ baseNoCurrent(true);
+ }
+
+ public void testNoNew_DryRun() throws Exception {
+ baseNoNew(true);
+ }
+
+ public void testNoNewWithCurrentDifferentThanOriginal_DryRun() throws Exception {
+ baseNoNewWithCurrentDifferentThanOriginal(true);
+ }
+
+ public void testWithSubdirectories() throws Exception {
+ // this test is different than all the rest, start with clean tmp/dest dirs with no beforeMethod buildup
+ FileUtil.purge(this.tmpDir, false);
+ FileUtil.purge(this.deployDir, false);
+
+ // fill the deployDir with some unrelated content
+ File unrelated1 = writeFile("unrelated1", this.deployDir, "unrelated.txt");
+ File unrelated2 = writeFile("unrelated2", this.deployDir, "unrelateddir/unrelated.txt");
+ assert unrelated1.exists();
+ assert unrelated2.exists();
+
+ // deploy initial content
+ String origFileName1 = "original-file1.txt";
+ String origFileName2 = "subdir/original-file2.txt";
+ this.originalZipFile = createZip(new String[] { "content1", "content2" }, this.tmpDir, "original.zip",
+ new String[] { origFileName1, origFileName2 });
+ 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);
+ Deployer deployer = new Deployer(dd);
+ this.originalFileHashcodeMap = deployer.deploy(null);
+ assert new File(this.deployDir, origFileName1).exists();
+ assert new File(this.deployDir, origFileName2).exists();
+ assert unrelated1.exists() : "the deployment removed unrelated file1";
+ assert unrelated2.getParentFile().isDirectory() : "the deployment removed an unrelated dir";
+ assert unrelated2.exists() : "the deployment removed unrelated file2";
+
+ // deploy new content
+ this.newDeployProps = new DeploymentProperties(2, "simple", "2.0", "new test deployment");
+ this.diff = new DeployDifferences();
+ this.metadata = new DeploymentsMetadata(this.deployDir);
+ String newFileName1 = "new-file1.txt";
+ String newFileName2 = "newsubdir/new-file2.txt";
+ File newZipFile = createZip(new String[] { "newcontent1", "newcontent2" }, this.tmpDir, "new.zip",
+ 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);
+ deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap = deployer.deploy(this.diff);
+ assert new File(this.deployDir, newFileName1).exists();
+ assert new File(this.deployDir, newFileName2).exists();
+ assert !new File(this.deployDir, origFileName1).exists();
+ assert !new File(this.deployDir, origFileName2).exists();
+ assert unrelated1.exists() : "the deployment removed unrelated file1";
+ assert unrelated2.getParentFile().isDirectory() : "the deployment removed an unrelated dir";
+ assert unrelated2.exists() : "the deployment removed unrelated file2";
+ assert this.diff.getBackedUpFiles().size() == 0 : this.diff;
+ }
+
+ private void baseX_X_X(boolean dryRun) throws Exception {
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
+ null, false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // nothing changed!
+
+ assert newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ assert contentHash[0].equals(this.originalContent);
+ assert contentHash[1].equals(this.originalHashcode);
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().isEmpty() : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().isEmpty() : this.diff;
+ assert this.diff.getBackedUpFiles().isEmpty() : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getRestoredFiles().isEmpty() : this.diff;
+ assert !this.diff.wasCleaned() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+ }
+
+ private void baseX_X_Y(boolean dryRun) throws Exception {
+ String newContent = "testX_X_Y";
+ String newHashcode = MessageDigestGenerator.getDigestString(newContent);
+ File newZipFile = createZip(newContent, tmpDir, "new-content.zip", originalFileName);
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // The new file changed the original file. The current file was never touched, so this is a simple upgrade
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 1;
+ assert newFileHashcodeMap.get(originalFileName).equals(newHashcode);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ if (dryRun) {
+ assert contentHash[0].equals(originalContent);
+ assert contentHash[1].equals(originalHashcode);
+ } else {
+ assert contentHash[0].equals(newContent);
+ assert contentHash[1].equals(newHashcode);
+ }
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().isEmpty() : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().size() == 1 : this.diff;
+ assert this.diff.getChangedFiles().contains(originalFileName) : this.diff;
+ assert this.diff.getBackedUpFiles().isEmpty() : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+ }
+
+ private void baseX_Y_X(boolean dryRun) throws Exception {
+ String newContent = "testX_Y_X";
+ String newHashcode = MessageDigestGenerator.getDigestString(newContent);
+ writeFile(newContent, this.currentFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
+ null, false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // very important to understand this - even though the current file is changed, the hashcode
+ // stored in the map and the metadata directory is the ORIGINAL hashcode. This is to make it
+ // known that the new deployment itself is the same as the original deployment. It is just
+ // that we allow the user's manual changes to continue to live on in the filesystem. However,
+ // if a newer deployment comes along in the future and changes the new file, this current file
+ // must be updated/backed up as appropriate and the only way to know when that happens is if
+ // the metadata retains the original/new hashcode and not the current one.
+
+ assert newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ assert contentHash[0].equals(newContent);
+ assert contentHash[1].equals(newHashcode);
+
+ assertUnrelatedFiles();
+ // note nothing changed - our current file remains as is
+ assert this.diff.getAddedFiles().isEmpty() : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().isEmpty() : this.diff;
+ assert this.diff.getBackedUpFiles().isEmpty() : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+ }
+
+ private void baseX_Y_Y(boolean dryRun) throws Exception {
+ String newContent = "testX_Y_Y";
+ String newHashcode = MessageDigestGenerator.getDigestString(newContent);
+ writeFile(newContent, this.currentFile);
+ File newZipFile = createZip(newContent, tmpDir, "new-content.zip", originalFileName);
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // The new file changed the original, but our current file has already been manually updated
+ // to match the new file. Therefore, the current file doesn't have to change its content.
+ // Technically, the file could be overwritten, but the content will still be the same.
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 1;
+ assert newFileHashcodeMap.get(originalFileName).equals(newHashcode);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ assert contentHash[0].equals(newContent);
+ assert contentHash[1].equals(newHashcode);
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().isEmpty() : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().isEmpty() : this.diff;
+ assert this.diff.getBackedUpFiles().isEmpty() : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+ }
+
+ private void baseX_Y_Z(boolean dryRun) throws Exception {
+ String newContentY = "testX_Y_Z_YYY";
+ writeFile(newContentY, this.currentFile);
+ String newHashcodeY = MessageDigestGenerator.getDigestString(newContentY);
+
+ String newContentZ = "testX_Y_Z_ZZZ";
+ String newHashcodeZ = MessageDigestGenerator.getDigestString(newContentZ);
+ File newZipFile = createZip(newContentZ, tmpDir, "new-content.zip", originalFileName);
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // The new file changed the original, and our current file has been manually updated
+ // but that current file's change does not match the new file. Therefore, the current file
+ // is out of date. The safest thing to do is backup the current and copy the new file
+ // to become the current file.
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 1;
+ assert newFileHashcodeMap.get(originalFileName).equals(newHashcodeZ);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ if (dryRun) {
+ assert contentHash[0].equals(newContentY);
+ assert contentHash[1].equals(newHashcodeY);
+ } else {
+ assert contentHash[0].equals(newContentZ);
+ assert contentHash[1].equals(newHashcodeZ);
+ }
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().isEmpty() : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().size() == 1 : this.diff;
+ assert this.diff.getChangedFiles().contains(originalFileName) : this.diff;
+ assert this.diff.getBackedUpFiles().size() == 1 : this.diff;
+ assert this.diff.getBackedUpFiles().containsKey(originalFileName) : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+
+ // verify the backup copy
+ File backupFile = new File(this.diff.getBackedUpFiles().get(originalFileName));
+ if (dryRun) {
+ assert !backupFile.exists() : "dry run should not create backup";
+ } else {
+ assert readFile(backupFile).equals(newContentY) : "did not backup the correct file?";
+ }
+ }
+
+ private void baseNoOriginalNoCurrentWithNew(boolean dryRun) throws Exception {
+ String newContent = "new content";
+ String newHashcode = MessageDigestGenerator.getDigestString(newContent);
+ String newFileName = "new_filename.new";
+ File newZipFile = createZip(new String[] { originalContent, newContent }, tmpDir, "new.zip", new String[] {
+ originalFileName, newFileName });
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // the new deployment introduces a new file. This is simple - its just added to the filesystem
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 2;
+ assert newFileHashcodeMap.get(originalFileName).equals(originalHashcode);
+ assert newFileHashcodeMap.get(newFileName).equals(newHashcode);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ assert contentHash[0].equals(originalContent);
+ assert contentHash[1].equals(originalHashcode);
+ try {
+ contentHash = getFilenameContentHashcode(newFileName);
+ assert contentHash[0].equals(newContent);
+ assert contentHash[1].equals(newHashcode);
+ } catch (FileNotFoundException e) {
+ // this is expected if we are in a dry run
+ if (!dryRun) {
+ throw e;
+ }
+ }
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().size() == 1 : this.diff;
+ assert this.diff.getAddedFiles().contains(newFileName) : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().isEmpty() : this.diff;
+ assert this.diff.getBackedUpFiles().isEmpty() : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+ }
+
+ private void baseNoOriginalWithCurrentWithNew(boolean dryRun) throws Exception {
+ String newContent = "new content";
+ String newHashcode = MessageDigestGenerator.getDigestString(newContent);
+ String newFileName = "new_filename.new";
+ File newZipFile = createZip(new String[] { originalContent, newContent }, tmpDir, "new.zip", new String[] {
+ originalFileName, newFileName });
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ File inTheWayFile = new File(this.deployDir, newFileName);
+ String inTheWayContent = "this is in the way";
+ String inTheWayHashcode = MessageDigestGenerator.getDigestString(inTheWayContent);
+ writeFile(inTheWayContent, inTheWayFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // The new deployment introduces a new file. However, there is already a current file at the new file location.
+ // That current file is unknown and in the way.
+ // This normally is considered a "change" not an "addition" since the file system already had the file, it just got changed.
+ // Also, normally, it would be backed up.
+ // However, because we are not managing the root dir, that file "in the way" is simply skipped and not backed up.
+ // But because our new zip has the same file in it, it is considered "new" thus it will be "added" to the
+ // set of managed files.
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 2;
+ assert newFileHashcodeMap.get(originalFileName).equals(originalHashcode);
+ assert newFileHashcodeMap.get(newFileName).equals(newHashcode);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ assert contentHash[0].equals(originalContent);
+ assert contentHash[1].equals(originalHashcode);
+ contentHash = getFilenameContentHashcode(newFileName);
+ if (dryRun) {
+ assert contentHash[0].equals(inTheWayContent);
+ assert contentHash[1].equals(inTheWayHashcode);
+ } else {
+ assert contentHash[0].equals(newContent);
+ assert contentHash[1].equals(newHashcode);
+ }
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().size() == 1 : this.diff;
+ assert this.diff.getAddedFiles().contains(newFileName) : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().size() == 0 : this.diff;
+ assert this.diff.getBackedUpFiles().size() == 0 : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+ }
+
+ 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);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // its the same deployment as before, except someone deleted our current file.
+ // This adds the new file back (which is the same as the original).
+
+ assert newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ try {
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ assert contentHash[0].equals(this.originalContent);
+ assert contentHash[1].equals(this.originalHashcode);
+ } catch (FileNotFoundException e) {
+ // this is expected if we are in a dry run
+ if (!dryRun) {
+ throw e;
+ }
+ }
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().size() == 1 : this.diff;
+ assert this.diff.getAddedFiles().contains(this.originalFileName) : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().isEmpty() : this.diff;
+ assert this.diff.getBackedUpFiles().isEmpty() : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+ }
+
+ private void baseNoNew(boolean dryRun) throws Exception {
+ String newContent = "new content";
+ String newHashcode = MessageDigestGenerator.getDigestString(newContent);
+ String newFileName = "new_filename.new";
+ File newZipFile = createZip(newContent, tmpDir, "new.zip", newFileName);
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // The new deployment removes a file that was in the original (it also introduces a new file).
+ // There is already a current file at the original file location that is the same as the original, as you would expect.
+ // That current file is to be deleted (since its not in the new deployment) and is not backed up since it is
+ // the same as the original.
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 1;
+ assert newFileHashcodeMap.get(newFileName).equals(newHashcode);
+ if (dryRun) {
+ assert this.currentFile.exists() : "this should have been left as-is";
+ } else {
+ assert !this.currentFile.exists() : "this should have been deleted";
+ }
+ try {
+ String[] contentHash = getFilenameContentHashcode(newFileName);
+ assert contentHash[0].equals(newContent);
+ assert contentHash[1].equals(newHashcode);
+ } catch (FileNotFoundException e) {
+ // this is expected if we are in a dry run
+ if (!dryRun) {
+ throw e;
+ }
+ }
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().size() == 1 : this.diff;
+ assert this.diff.getAddedFiles().contains(newFileName) : this.diff;
+ assert this.diff.getDeletedFiles().size() == 1 : this.diff;
+ assert this.diff.getDeletedFiles().contains(originalFileName) : this.diff;
+ assert this.diff.getChangedFiles().isEmpty() : this.diff;
+ assert this.diff.getBackedUpFiles().isEmpty() : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+ }
+
+ private void baseNoNewWithCurrentDifferentThanOriginal(boolean dryRun) throws Exception {
+ String currentContent = "modified content";
+ writeFile(currentContent, this.currentFile);
+
+ String newContent = "new content";
+ String newHashcode = MessageDigestGenerator.getDigestString(newContent);
+ String newFileName = "new_filename.new";
+ File newZipFile = createZip(newContent, tmpDir, "new.zip", newFileName);
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ false);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ if (dryRun) {
+ newFileHashcodeMap = deployer.dryRun(this.diff);
+ } else {
+ newFileHashcodeMap = deployer.deploy(this.diff);
+ }
+
+ // The new deployment removes a file that was in the original (it also introduces a new file).
+ // However, there is already a current file at the original file location as you would expect but
+ // its different than the original.
+ // That current file is to be deleted (since its not in the new deployment) and it must be backed up
+ // since it looks modified from the original.
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 1;
+ assert newFileHashcodeMap.get(newFileName).equals(newHashcode);
+ if (dryRun) {
+ assert this.currentFile.exists() : "this should have been left as-is";
+ } else {
+ assert !this.currentFile.exists() : "this should have been deleted";
+ }
+ try {
+ String[] contentHash = getFilenameContentHashcode(newFileName);
+ assert contentHash[0].equals(newContent);
+ assert contentHash[1].equals(newHashcode);
+ } catch (FileNotFoundException e) {
+ // this is expected if we are in a dry run
+ if (!dryRun) {
+ throw e;
+ }
+ }
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().size() == 1 : this.diff;
+ assert this.diff.getAddedFiles().contains(newFileName) : this.diff;
+ assert this.diff.getDeletedFiles().size() == 1 : this.diff;
+ assert this.diff.getDeletedFiles().contains(originalFileName) : this.diff;
+ assert this.diff.getChangedFiles().isEmpty() : this.diff;
+ assert this.diff.getBackedUpFiles().size() == 1 : this.diff;
+ assert this.diff.getBackedUpFiles().containsKey(originalFileName) : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+
+ // verify the backup copy
+ File backupFile = new File(this.diff.getBackedUpFiles().get(originalFileName));
+ if (dryRun) {
+ assert !backupFile.exists() : "dry run should not create backup";
+ } else {
+ assert readFile(backupFile).equals(currentContent) : "did not backup the correct file?";
+ }
+ }
+
+ private void baseX_Y_Z_Restore(boolean dryRun) throws Exception {
+ String newContentY = "testX_Y_Z_YYY";
+ writeFile(newContentY, this.currentFile);
+ String newHashcodeY = MessageDigestGenerator.getDigestString(newContentY);
+
+ String newContentZ = "testX_Y_Z_ZZZ";
+ String newHashcodeZ = MessageDigestGenerator.getDigestString(newContentZ);
+ File newZipFile = createZip(newContentZ, tmpDir, "new-content.zip", originalFileName);
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ false);
+ 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
+
+ // The new file changed the original, and our current file has been manually updated
+ // but that current file's change does not match the new file. Therefore, the current file
+ // is out of date. The safest thing to do is backup the current and copy the new file
+ // to become the current file.
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 1;
+ assert newFileHashcodeMap.get(originalFileName).equals(newHashcodeZ);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ assert contentHash[0].equals(newContentZ);
+ assert contentHash[1].equals(newHashcodeZ);
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().isEmpty() : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().size() == 1 : this.diff;
+ assert this.diff.getChangedFiles().contains(originalFileName) : this.diff;
+ assert this.diff.getBackedUpFiles().size() == 1 : this.diff;
+ assert this.diff.getBackedUpFiles().containsKey(originalFileName) : this.diff;
+ assert this.diff.getRestoredFiles().isEmpty() : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+
+ // verify the backup copy
+ File backupFile = new File(this.diff.getBackedUpFiles().get(originalFileName));
+ assert readFile(backupFile).equals(newContentY) : "did not backup the correct file?";
+
+ // all we did so far was upgrade to v2 and created a backup file, now we need to redeploy v1 and see the backup restored
+ 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);
+ deployer = new Deployer(dd);
+ this.diff = new DeployDifferences();
+ FileHashcodeMap restoreFileHashcodeMap;
+ restoreFileHashcodeMap = deployer.redeployAndRestoreBackupFiles(this.diff, false, dryRun);
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().isEmpty() : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().size() == 1 : this.diff;
+ assert this.diff.getChangedFiles().contains(originalFileName) : this.diff;
+ assert this.diff.getBackedUpFiles().isEmpty() : this.diff;
+ assert this.diff.getRestoredFiles().size() == 1 : this.diff;
+ assert this.diff.getRestoredFiles().containsKey(originalFileName) : this.diff;
+ assert this.diff.getIgnoredFiles().isEmpty() : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ assert restoreFileHashcodeMap.get(originalFileName).equals(newHashcodeY) : "hashcode doesn't reflect restored backup";
+
+ if (dryRun) {
+ // still our v2
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ } else {
+ // we reverted back to v1 with the manual changes
+ assert this.metadata.getCurrentDeploymentProperties().equals(v1Duplicate);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(restoreFileHashcodeMap);
+ assert MessageDigestGenerator.getDigestString(this.currentFile).equals(newHashcodeY) : "file wasn't restored";
+ }
+ }
+
+ private void baseX_Y_Z_Clean(boolean dryRun) throws Exception {
+ String newContentY = "testX_Y_Z_YYY";
+ writeFile(newContentY, this.currentFile);
+ String newHashcodeY = MessageDigestGenerator.getDigestString(newContentY);
+
+ String newContentZ = "testX_Y_Z_ZZZ";
+ String newHashcodeZ = MessageDigestGenerator.getDigestString(newContentZ);
+ File newZipFile = createZip(newContentZ, tmpDir, "new-content.zip", originalFileName);
+ Set<File> newZipFiles = new HashSet<File>(1);
+ newZipFiles.add(newZipFile);
+
+ File ignoredSubdir = new File(this.deployDir, "ignoreSubdir");
+ File ignoredFile = new File(ignoredSubdir, "ignore-me.txt");
+ ignoredSubdir.mkdirs();
+ writeFile("ignored content", ignoredFile);
+ 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);
+ Deployer deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap;
+ newFileHashcodeMap = deployer.deploy(this.diff, true, dryRun); // note: clean is true
+
+ // The new file changed the original, and our current file has been manually updated
+ // but that current file's change does not match the new file. Therefore, the current file
+ // is out of date. The safest thing to do is backup the current and copy the new file
+ // to become the current file.
+
+ assert !newFileHashcodeMap.equals(this.originalFileHashcodeMap);
+ assert newFileHashcodeMap.size() == 1;
+ assert newFileHashcodeMap.get(originalFileName).equals(newHashcodeZ);
+ String[] contentHash = getOriginalFilenameContentHashcode();
+ if (dryRun) {
+ assert contentHash[0].equals(newContentY);
+ assert contentHash[1].equals(newHashcodeY);
+ } else {
+ assert contentHash[0].equals(newContentZ);
+ assert contentHash[1].equals(newHashcodeZ);
+ }
+
+ assertUnrelatedFiles();
+ assert this.diff.getAddedFiles().isEmpty() : this.diff;
+ assert this.diff.getDeletedFiles().isEmpty() : this.diff;
+ assert this.diff.getChangedFiles().size() == 1 : this.diff;
+ assert this.diff.getChangedFiles().contains(originalFileName) : this.diff;
+ assert this.diff.getBackedUpFiles().size() == 1 : this.diff;
+ assert this.diff.getBackedUpFiles().containsKey(originalFileName) : this.diff;
+ // because we are not managing the root dir, that ignore dir found at the root level is skipped
+ // so it never gets to the point where it matches the ignore regex therefore it doesn't count as ignored.
+ assert this.diff.getIgnoredFiles().size() == 0 : this.diff;
+ assert this.diff.getRealizedFiles().isEmpty() : this.diff;
+ assert this.diff.wasCleaned() : this.diff;
+ assert this.diff.getErrors().isEmpty() : this.diff;
+
+ if (dryRun) {
+ assert this.metadata.getCurrentDeploymentProperties().equals(originalDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(originalFileHashcodeMap);
+ } else {
+ assert this.metadata.getCurrentDeploymentProperties().equals(newDeployProps);
+ assert this.metadata.getCurrentDeploymentFileHashcodes().equals(newFileHashcodeMap);
+ }
+
+ // verify the backup copy
+ File backupFile = new File(this.diff.getBackedUpFiles().get(originalFileName));
+ if (dryRun) {
+ assert !backupFile.exists() : "dry run should not create backup";
+ } else {
+ assert readFile(backupFile).equals(newContentY) : "did not backup the correct file?";
+ }
+
+ // even though we cleaned, the ignored subdir and its file should have been skipped due to
+ // the fact were told the deployer not to manage the top root dir. Therefore, they should still exist.
+ if (dryRun) {
+ assert ignoredSubdir.isDirectory() : "dry run should not have really cleaned";
+ assert ignoredFile.exists() : "dry run should not have really cleaned";
+ } else {
+ assert ignoredSubdir.isDirectory() : "should not have really cleaned";
+ assert ignoredFile.exists() : "should not have really cleaned";
+ }
+ }
+
+ private String[] getOriginalFilenameContentHashcode() throws Exception {
+ return getFilenameContentHashcode(this.originalFileName);
+ }
+
+ private String[] getFilenameContentHashcode(String filename) throws Exception {
+ String content = readFile(new File(this.deployDir, filename));
+ String hashcode = MessageDigestGenerator.getDigestString(content);
+ String[] contentHash = new String[] { content, hashcode };
+ return contentHash;
+ }
+
+ private String readFile(File file) throws Exception {
+ return new String(StreamUtil.slurp(new FileInputStream(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);
+ }
+
+ 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);
+
+ ZipEntry zipAdd = new ZipEntry(entryName);
+ zipAdd.setTime(System.currentTimeMillis());
+ out.putNextEntry(zipAdd);
+ out.write(content.getBytes());
+ return zipFile;
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ if (stream != null) {
+ stream.close();
+ }
+ }
+ }
+
+ 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();
+ }
+ }
+ }
+
+ private void assertUnrelatedFiles() throws Exception {
+ // make sure we didn't delete or alter the file or dir that are unrelated to the deployed content
+ // the dir and its file...
+ assert this.unrelatedDir.isDirectory() : "unrelated directory was deleted: " + this.unrelatedDir;
+ assert this.unrelatedDirFile.exists() : "unrelated dir file was deleted: " + this.unrelatedDirFile;
+ String hash = MessageDigestGenerator.getDigestString(this.unrelatedDirFile);
+ assert this.unrelatedDirFileHashcode.equals(hash) : "unrelated dir file was changed: " + this.unrelatedDirFile;
+
+ // the file located directly in the deployDir...
+ assert this.unrelatedFile.exists() : "unrelated file was deleted: " + this.unrelatedFile;
+ hash = MessageDigestGenerator.getDigestString(this.unrelatedFile);
+ assert this.unrelatedFileHashcode.equals(hash) : "unrelated file was changed: " + this.unrelatedFile;
+ }
+}
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 e1eafcb..16275ef 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
@@ -93,7 +93,7 @@ public class SimpleDeployerRawFileTest {
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);
+ null, true);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = sourceRawFiles.get(sourceRawFile);
@@ -206,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -248,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -294,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -342,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -390,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -453,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -515,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -575,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -626,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -690,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -763,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
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
@@ -802,7 +813,7 @@ 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);
+ dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, deployDir, null, null, null, null, true);
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 cf366cb..5a0f842 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
@@ -91,7 +91,7 @@ public class SimpleDeployerRawRelativeFileTest {
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);
+ null, true);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = sourceRawFiles.get(sourceRawFile);
@@ -205,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -247,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -293,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -341,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -389,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -452,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -514,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -573,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -624,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -688,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -761,7 +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);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, deployDir, null, null, null, null,
+ true);
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
@@ -800,7 +811,7 @@ 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);
+ dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, deployDir, null, null, null, null, true);
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 24884ed..712a984 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
@@ -87,7 +87,7 @@ public class SimpleDeployerTest {
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);
+ null, null, true);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = new File(deployDir, originalFileName);
@@ -205,9 +205,64 @@ public class SimpleDeployerTest {
baseNoNewWithCurrentDifferentThanOriginal(true);
}
+ public void testWithSubdirectories() throws Exception {
+ // this test is different than all the rest, start with clean tmp/dest dirs with no beforeMethod buildup
+ FileUtil.purge(this.tmpDir, false);
+ FileUtil.purge(this.deployDir, false);
+
+ // fill the deployDir with some unrelated content
+ String unrelatedFileName1 = "unrelated.txt";
+ String unrelatedFileName2 = "unrelateddir/unrelated.txt";
+ File unrelated1 = writeFile("unrelated1", this.deployDir, unrelatedFileName1);
+ File unrelated2 = writeFile("unrelated2", this.deployDir, unrelatedFileName2);
+ assert unrelated1.exists();
+ assert unrelated2.exists();
+
+ // deploy initial content
+ String origFileName1 = "original-file1.txt";
+ String origFileName2 = "subdir/original-file2.txt";
+ this.originalZipFile = createZip(new String[] { "content1", "content2" }, this.tmpDir, "original.zip",
+ new String[] { origFileName1, origFileName2 });
+ 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);
+ Deployer deployer = new Deployer(dd);
+ this.originalFileHashcodeMap = deployer.deploy(null);
+ assert new File(this.deployDir, origFileName1).exists();
+ assert new File(this.deployDir, origFileName2).exists();
+ assert unrelated1.exists() : "the deployment removed unrelated file1";
+ assert unrelated2.getParentFile().isDirectory() : "the deployment removed an unrelated dir";
+ assert unrelated2.exists() : "the deployment removed unrelated file2";
+
+ // deploy new content
+ this.newDeployProps = new DeploymentProperties(2, "simple", "2.0", "new test deployment");
+ this.diff = new DeployDifferences();
+ this.metadata = new DeploymentsMetadata(this.deployDir);
+ String newFileName1 = "new-file1.txt";
+ String newFileName2 = "newsubdir/new-file2.txt";
+ File newZipFile = createZip(new String[] { "newcontent1", "newcontent2" }, this.tmpDir, "new.zip",
+ 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);
+ deployer = new Deployer(dd);
+ FileHashcodeMap newFileHashcodeMap = deployer.deploy(this.diff);
+ assert new File(this.deployDir, newFileName1).exists();
+ assert new File(this.deployDir, newFileName2).exists();
+ assert !new File(this.deployDir, origFileName1).exists();
+ assert !new File(this.deployDir, origFileName2).exists();
+ assert !unrelated1.exists() : "the deployment did not remove unrelated file1";
+ assert !unrelated2.exists() : "the deployment did not remove unrelated file1";
+ assert this.diff.getBackedUpFiles().size() == 2 : this.diff;
+ assert new File(this.diff.getBackedUpFiles().get(unrelatedFileName1)).exists() : this.diff;
+ assert new File(this.diff.getBackedUpFiles().get(unrelatedFileName2)).exists() : this.diff;
+ }
+
private void baseX_X_X(boolean dryRun) throws Exception {
DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
- null);
+ null, true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -249,7 +304,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);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -296,7 +352,7 @@ public class SimpleDeployerTest {
writeFile(newContent, this.currentFile);
DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null, deployDir, null, null, null,
- null);
+ null, true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -344,7 +400,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);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -392,7 +449,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);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -454,7 +512,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);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -515,7 +574,8 @@ public class SimpleDeployerTest {
String inTheWayHashcode = MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -575,7 +635,7 @@ public class SimpleDeployerTest {
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);
+ null, true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -625,7 +685,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);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -688,7 +749,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);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -761,7 +823,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);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, null,
+ true);
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
@@ -800,7 +863,7 @@ 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);
+ dd = new DeploymentData(v1Duplicate, originalZipFiles, null, deployDir, null, null, null, null, true);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
@@ -849,7 +912,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);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null, null, iRegex,
+ true);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff, true, dryRun); // note: clean is true
@@ -928,8 +992,8 @@ public class SimpleDeployerTest {
FileOutputStream out = null;
try {
- out = new FileOutputStream(fileToOverwrite);
fileToOverwrite.getParentFile().mkdirs();
+ out = new FileOutputStream(fileToOverwrite);
out.write(content.getBytes());
return fileToOverwrite;
} finally {
commit f2f5fba1821350531a5eb90b7d71c6295ce37ab7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Dec 21 12:24:11 2010 -0500
be able to delete deployments if they are finished
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java
index 5c9787b..8eca429 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentStatus.java
@@ -31,12 +31,12 @@ package org.rhq.core.domain.bundle;
* @author Jay Shaughnessy
*/
public enum BundleDeploymentStatus {
- PENDING("Pending"), //
- IN_PROGRESS("In Progress"), //
+ PENDING("Pending"), // for future, when we support true scheduling of bundle deployments
+ IN_PROGRESS("In Progress"), //
MIXED("Mixed"), //
SUCCESS("Success"), //
- FAILURE("Failure"), //
- WARN("Warning");
+ FAILURE("Failure") //
+ ; // need this for GWT
private String displayName;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
index 9cb3f58..cea040d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
@@ -100,10 +100,10 @@ public class BundleDeploymentListView extends Table<RPCDataSource<BundleDeployme
});
HashMap<String, String> statusIcons = new HashMap<String, String>();
+ statusIcons.put(BundleDeploymentStatus.PENDING.name(), "subsystems/bundle/install-loader.gif");
statusIcons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Error_11.png");
statusIcons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
- statusIcons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
statusIcons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
statusField.setValueIcons(statusIcons);
statusField.setValueIconWidth(11);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
index 94b216a..870988e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
@@ -105,10 +105,10 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
//setMargin(10); // do not set margin, we already have our margin set outside of us
statusIcons = new HashMap<String, String>();
+ statusIcons.put(BundleDeploymentStatus.PENDING.name(), "subsystems/bundle/install-loader.gif");
statusIcons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Error_11.png");
statusIcons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
- statusIcons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
statusIcons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
index 972e618..89eec9d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
@@ -69,10 +69,10 @@ public class BundleResourceDeploymentHistoryListView extends LocatableVLayout {
this.resourceDeployment = resourceDeployment;
statusIcons = new HashMap<String, String>();
+ statusIcons.put(BundleDeploymentStatus.PENDING.name(), "subsystems/bundle/install-loader.gif");
statusIcons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Error_11.png");
statusIcons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
- statusIcons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
statusIcons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
index 5bfc174..00d25df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
@@ -101,10 +101,10 @@ public class BundleDestinationListView extends Table<RPCDataSource<BundleDestina
});
HashMap<String, String> statusIcons = new HashMap<String, String>();
+ statusIcons.put(BundleDeploymentStatus.PENDING.name(), "subsystems/bundle/install-loader.gif");
statusIcons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Error_11.png");
statusIcons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
- statusIcons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
statusIcons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
latestDeploymentStatusField.setValueIcons(statusIcons);
latestDeploymentStatusField.setValueIconHeight(11);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index a57b618..25ff496 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -1263,11 +1263,14 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
if (null == doomed) {
return;
}
- if (!BundleDeploymentStatus.PENDING.equals(doomed.getStatus())) {
+ // only allow deployments to be deleted if they are finished
+ if (BundleDeploymentStatus.SUCCESS == doomed.getStatus()
+ || BundleDeploymentStatus.FAILURE == doomed.getStatus()
+ || BundleDeploymentStatus.MIXED == doomed.getStatus()) {
+ entityManager.remove(doomed);
+ } else {
throw new IllegalArgumentException("Can not delete deployment with status [" + doomed.getStatus() + "]");
}
-
- entityManager.remove(doomed);
}
@RequiredPermission(Permission.MANAGE_BUNDLE)
13 years, 4 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java | 314 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java | 6
2 files changed, 320 insertions(+)
New commits:
commit f2e70918b70c767edc3dca70442c0df09bfd556c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Dec 21 18:32:12 2010 -0500
an initial revision of the job trigger editor widget; usage of the trigger editor on the create new resource operation schedule view
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
new file mode 100644
index 0000000..5684067
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
@@ -0,0 +1,314 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.components.trigger;
+
+import java.util.Date;
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.DateTimeItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
+import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.FocusEvent;
+import com.smartgwt.client.widgets.form.fields.events.FocusHandler;
+import com.smartgwt.client.widgets.form.validator.RegExpValidator;
+
+import org.rhq.core.domain.common.JobTrigger;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A SmartGWT widget that provides the ability to create a new {@link JobTrigger job trigger}, or view or edit an
+ * existing job trigger.
+ *
+ * @author Ian Springer
+ */
+public class JobTriggerEditor extends LocatableVLayout {
+
+ private boolean isReadOnly;
+ private boolean isValid;
+
+ /**
+ * Create a new job trigger.
+ *
+ * @param locatorId
+ */
+ public JobTriggerEditor(String locatorId) {
+ super(locatorId);
+ }
+
+ /**
+ * View or edit an existing job trigger.
+ *
+ * @param locatorId
+ * @param jobTrigger
+ * @param isReadOnly
+ */
+ public JobTriggerEditor(String locatorId, JobTrigger jobTrigger, boolean isReadOnly) {
+ super(locatorId);
+
+ this.isReadOnly = isReadOnly;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ DynamicForm modeForm = new DynamicForm();
+
+ RadioGroupItem modeItem = new RadioGroupItem("mode", "Schedule using");
+ modeItem.setWidth(220);
+ LinkedHashMap<String, String> modeValueMap = new LinkedHashMap<String, String>();
+ modeValueMap.put("calendar", "Calendar");
+ modeValueMap.put("cron", "Cron Mode");
+ modeItem.setValueMap(modeValueMap);
+ modeItem.setVertical(false);
+
+ modeForm.setFields(modeItem);
+ addMember(modeForm);
+
+
+ final DynamicForm calendarTypeForm = new DynamicForm();
+
+ RadioGroupItem calendarTypeItem = new RadioGroupItem("calendarType");
+ calendarTypeItem.setWidth(440);
+ calendarTypeItem.setShowTitle(false);
+ LinkedHashMap<String, String> calendarTypeValueMap = new LinkedHashMap<String, String>();
+ calendarTypeValueMap.put("now", "Now");
+ calendarTypeValueMap.put("nowAndRepeat", "Now & Repeat");
+ calendarTypeValueMap.put("later", "Later");
+ calendarTypeValueMap.put("laterAndRepeat", "Later & Repeat");
+ calendarTypeItem.setValueMap(calendarTypeValueMap);
+ calendarTypeItem.setVertical(false);
+
+ calendarTypeForm.setFields(calendarTypeItem);
+ calendarTypeForm.setVisible(false);
+
+ addMember(calendarTypeForm);
+
+ modeItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ if (event.getValue().equals("calendar")) {
+ calendarTypeForm.show();
+ }
+ }
+ });
+
+ final DynamicForm laterForm = createLaterForm();
+ addMember(laterForm);
+
+ final DynamicForm repeatForm = createRepeatForm();
+ addMember(repeatForm);
+
+ calendarTypeItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ String value = (String)event.getValue();
+ if (value.equals("now")) {
+ isValid = true;
+ } else if (value.equals("nowAndRepeat")) {
+ laterForm.hide();
+ FormItem repeatIntervalItem = repeatForm.getItem("repeatInterval");
+ repeatIntervalItem.setTitle("Run now and every");
+ repeatIntervalItem.redraw();
+ repeatForm.show();
+ } else if (value.equals("later")) {
+ repeatForm.hide();
+ laterForm.show();
+ } else {
+ // later and repeat
+ laterForm.show();
+ FormItem repeatIntervalItem = repeatForm.getItem("repeatInterval");
+ repeatIntervalItem.setTitle("Repeat every");
+ repeatIntervalItem.redraw();
+ repeatForm.show();
+ }
+ }
+ });
+ }
+
+ private DynamicForm createRepeatForm() {
+ final DynamicForm nowAndRepeatForm = new DynamicForm();
+ nowAndRepeatForm.setNumCols(6);
+ nowAndRepeatForm.setColWidths(130, 130, 130, 130, 130);
+
+ TextItem repeatIntervalItem = new TextItem("repeatInterval", "Run now and every");
+
+ // Configure hint.
+ repeatIntervalItem.setHint("[1-9][0-9]* (seconds|minutes|hours|days|weeks|months|quarters|years)");
+ repeatIntervalItem.setShowHint(false);
+ repeatIntervalItem.addFocusHandler(new FocusHandler() {
+ public void onFocus(FocusEvent event) {
+ event.getItem().setShowHint(true);
+ }
+ });
+ repeatIntervalItem.addBlurHandler(new BlurHandler() {
+ public void onBlur(BlurEvent event) {
+ event.getItem().setShowHint(false);
+ }
+ });
+
+ // Configure validation.
+ RegExpValidator repeatIntervalValidator = new RegExpValidator("[1-9][0-9]*[ ]+(seconds|minutes|hours|days|weeks|months|quarters|years)");
+ repeatIntervalItem.setValidators(repeatIntervalValidator);
+ repeatIntervalItem.setValidateOnExit(true);
+
+ RadioGroupItem recurrenceTypeItem = new RadioGroupItem("recurrenceType");
+ recurrenceTypeItem.setShowTitle(false);
+ LinkedHashMap<String, String> recurrenceTypeValueMap = new LinkedHashMap<String, String>();
+ recurrenceTypeValueMap.put("for", "For");
+ recurrenceTypeValueMap.put("until", "Until");
+ recurrenceTypeValueMap.put("indefinitely", "Indefinitely");
+ recurrenceTypeItem.setValueMap(recurrenceTypeValueMap);
+
+ final TextItem repeatDurationItem = new TextItem("repeatDuration");
+ repeatDurationItem.setShowTitle(false);
+ repeatDurationItem.setVisible(false);
+
+ // Configure hint.
+ repeatDurationItem.setHint("[1-9][0-9]* (repetitions|seconds|minutes|hours|days|weeks|months|quarters|years)");
+ repeatDurationItem.setShowHint(false);
+ repeatDurationItem.addFocusHandler(new FocusHandler() {
+ public void onFocus(FocusEvent event) {
+ event.getItem().setShowHint(true);
+ }
+ });
+ repeatDurationItem.addBlurHandler(new BlurHandler() {
+ public void onBlur(BlurEvent event) {
+ event.getItem().setShowHint(false);
+ }
+ });
+
+ // Configure validation.
+ RegExpValidator repeatDurationValidator = new RegExpValidator("[1-9][0-9]*[ ]+(repetitions|seconds|minutes|hours|days|weeks|months|quarters|years)");
+ repeatDurationItem.setValidators(repeatDurationValidator);
+ repeatDurationItem.setValidateOnExit(true);
+
+
+ final DateTimeItem endTimeItem = createDateTimeItem("endTime");
+ endTimeItem.setShowTitle(false);
+ endTimeItem.setVisible(false);
+
+ SpacerItem spacerItem = new SpacerItem();
+
+ recurrenceTypeItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ String value = (String)event.getValue();
+ if (value.equals("for")) {
+ endTimeItem.hide();
+ repeatDurationItem.show();
+ } else if (value.equals("until")) {
+ repeatDurationItem.hide();
+ endTimeItem.show();
+ } else {
+ repeatDurationItem.hide();
+ endTimeItem.hide();
+ }
+ }
+ });
+
+ nowAndRepeatForm.setFields(repeatIntervalItem, recurrenceTypeItem, repeatDurationItem, endTimeItem, spacerItem);
+ nowAndRepeatForm.setVisible(false);
+
+ return nowAndRepeatForm;
+ }
+
+ private DynamicForm createLaterForm() {
+ final DynamicForm laterForm = new DynamicForm();
+ laterForm.setNumCols(4);
+ laterForm.setColWidths(130, 130, 130);
+
+ RadioGroupItem startTypeItem = new RadioGroupItem("startType", "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 TextItem startDelayItem = new TextItem("startDelay");
+ startDelayItem.setShowTitle(false);
+ startDelayItem.setVisible(false);
+
+ // Configure hint.
+ startDelayItem.setHint("[1-9][0-9]* (seconds|minutes|hours|days|weeks|months|quarters|years)");
+ startDelayItem.setShowHint(false);
+ startDelayItem.addFocusHandler(new FocusHandler() {
+ public void onFocus(FocusEvent event) {
+ event.getItem().setShowHint(true);
+ }
+ });
+ startDelayItem.addBlurHandler(new BlurHandler() {
+ public void onBlur(BlurEvent event) {
+ event.getItem().setShowHint(false);
+ }
+ });
+
+ // Configure validation.
+ RegExpValidator startDelayValidator = new RegExpValidator("[1-9][0-9]*[ ]+(seconds|minutes|hours|days|weeks|months|quarters|years)");
+ startDelayItem.setValidators(startDelayValidator);
+ startDelayItem.setValidateOnExit(true);
+
+ SpacerItem spacerItem = new SpacerItem();
+
+ startTypeItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ String value = (String)event.getValue();
+ if (value.equals("on")) {
+ startDelayItem.hide();
+ startTimeItem.show();
+ } else {
+ startTimeItem.hide();
+ startDelayItem.show();
+ }
+ }
+ });
+
+ laterForm.setFields(startTypeItem, startTimeItem, startDelayItem, spacerItem);
+ laterForm.setVisible(false);
+
+ return laterForm;
+ }
+
+ private static DateTimeItem createDateTimeItem(String name) {
+ final DateTimeItem dateTimeItem = new DateTimeItem(name);
+ dateTimeItem.setEnforceDate(true);
+ dateTimeItem.setCenturyThreshold(99);
+ dateTimeItem.setShowTitle(false);
+ dateTimeItem.setVisible(false);
+ dateTimeItem.setStartDate(new Date());
+ dateTimeItem.setUseMask(true);
+ dateTimeItem.setShowHint(true);
+ return dateTimeItem;
+ }
+
+ public boolean isReadOnly() {
+ return isReadOnly;
+ }
+
+ public boolean isValid() {
+ return isValid;
+ }
+
+}
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 3afb1e2..6da2ec5 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
@@ -42,6 +42,7 @@ 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.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -115,6 +116,11 @@ public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
this.operationParametersConfigurationHolder.setVisible(false);
contentPane.addMember(this.operationParametersConfigurationHolder);
+ if (isNewRecord()) {
+ JobTriggerEditor triggerEditor = new JobTriggerEditor(extendLocatorId("TriggerEditor"));
+ contentPane.addMember(triggerEditor);
+ }
+
EnhancedDynamicForm notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"), isReadOnly(),
isNewRecord());
TextAreaItem notesItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, "Notes");
13 years, 4 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 37 ++++++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java | 3
2 files changed, 34 insertions(+), 6 deletions(-)
New commits:
commit a2619e9946f686fdb50f161df01766d88964980f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Dec 21 17:14:28 2010 -0500
[BZ 661808 - Removing portlets from the dashboard is not working]
Actually it turns out it was "rapid" portlet removal was not working. There
is a basic issue with the implementation in that the user can perform
several callback-initiating actions (like portlet removal) faster than
DashboardView's async save() method can complete. The save() method's
async success() method updates the stored dashboard with the results
of the save (merge operation). This in effect can "overwrite" any work
that had been done on the "old" Dashboard while the update was taking
place.
I've protected add/remove portlet using some synchronization but it we need
to go further we may need to put a locking mechanism in place.
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 02e6b00..81d3bb2 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
@@ -238,7 +238,11 @@ public class DashboardView extends LocatableVLayout {
}
}
- private void addPortlet(String portletKey, String portletName) {
+ /**
+ * A synchronized call to ensure add/remove/save are exclusive.
+ *
+ */
+ synchronized private void addPortlet(String portletKey, String portletName) {
DashboardPortlet storedPortlet = new DashboardPortlet(portletName, portletKey, 250);
final PortletWindow newPortlet = new PortletWindow(extendLocatorId(portletKey), this, storedPortlet);
@@ -278,11 +282,32 @@ public class DashboardView extends LocatableVLayout {
newPortlet.show();
}
}, 750);
- save();
+ save(storedDashboard);
+ }
+
+ /**
+ * A synchronized call to ensure the remove and save are atomic.
+ *
+ * @param portlet
+ */
+ synchronized public void removePortlet(DashboardPortlet portlet) {
+ storedDashboard.removePortlet(portlet);
+ save(storedDashboard);
+ }
+
+ /**
+ * A synchronized call to ensure add/remove/save are exclusive.
+ */
+ synchronized private void setDashboard(Dashboard dashboard) {
+ storedDashboard = dashboard;
}
public void save() {
- GWTServiceLookup.getDashboardService().storeDashboard(storedDashboard, new AsyncCallback<Dashboard>() {
+ save(storedDashboard);
+ }
+
+ private void save(Dashboard dashboard) {
+ GWTServiceLookup.getDashboardService().storeDashboard(dashboard, new AsyncCallback<Dashboard>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_dashboardManager_error(), caught);
}
@@ -290,7 +315,11 @@ public class DashboardView extends LocatableVLayout {
public void onSuccess(Dashboard result) {
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_dashboardManager_saved(result.getName()), Message.Severity.Info));
- storedDashboard = result;
+ // use the synchronized call to ensure add/delete portlet doesn't get interrupted. This is really
+ // just limited protection for add/remove portlet. Since this now sets storedDashboard,
+ // anything using the old version could lose edits. If we want to make this more robust we'll probably
+ // need a locking mechanism for editing the dashboard.
+ setDashboard(storedDashboard);
updateConfigs(result);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
index caffe54..3277aeb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
@@ -148,8 +148,7 @@ public class PortletWindow extends LocatableWindow {
addCloseClickHandler(new CloseClickHandler() {
public void onCloseClick(CloseClientEvent closeClientEvent) {
- PortletWindow.this.dashboardPortlet.getDashboard().removePortlet(PortletWindow.this.dashboardPortlet);
- save();
+ PortletWindow.this.dashboardView.removePortlet(PortletWindow.this.dashboardPortlet);
destroy();
}
});
13 years, 4 months
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java | 55 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java | 30 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java | 30 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java | 30 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java | 136 ++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java | 42 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java | 161 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java | 35 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java | 24 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java | 44 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java | 30 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java | 52 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java | 124 ++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 53 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java | 43 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 125 ++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java | 33 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java | 31 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java | 42 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java | 37 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java | 89 ++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java | 61 +--
27 files changed, 693 insertions(+), 654 deletions(-)
New commits:
commit 4bda12a4c8de28aa2f7f8bf30d2536b1a4b7d9e5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Dec 21 15:07:34 2010 -0500
fix serialization issues across the board for all gwt service implementations
use the following coding style:
public ReturnType someMethod(Args...) throws RuntimeException {
try {
// method body
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java
index 80bc779..448debd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java
@@ -35,24 +35,24 @@ public class AgentGWTServiceImpl extends AbstractGWTServiceImpl implements Agent
private AgentManagerLocal agentManager = LookupUtil.getAgentManager();
@Override
- public Agent getAgentForResource(int resourceId) {
+ public Agent getAgentForResource(int resourceId) throws RuntimeException {
try {
//security handled in AgentManagerBean. requires View_Resource.
return SerialUtility.prepare(agentManager.getAgentByResourceId(getSessionSubject(), resourceId),
"AgentService.getAgentForResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public Boolean pingAgentForResource(int resourceId) {
+ public Boolean pingAgentForResource(int resourceId) throws RuntimeException {
try {
//security handled in AgentManagerBean. requires View_Resource.
return SerialUtility.prepare(agentManager.pingAgentByResourceId(getSessionSubject(), resourceId),
"AgentService.pingAgentForResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@@ -60,8 +60,8 @@ public class AgentGWTServiceImpl extends AbstractGWTServiceImpl implements Agent
// try {
// return SerialUtility.prepare(availabilityManager.findAvailabilityForResource(getSessionSubject(),
// resourceId, pc), "AvailabilityService.findAvailabilityForResource");
- // } catch (Exception e) {
- // throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ // } catch (Throwable t) {
+ // throw new RuntimeException(ThrowableUtil.getAllMessages(t));
// }
// }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
index c704b49..3ed01c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
@@ -39,98 +39,99 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
private AlertNotificationManagerLocal alertNotifManager = LookupUtil.getAlertNotificationManager();
@Override
- public PageList<AlertDefinition> findAlertDefinitionsByCriteria(AlertDefinitionCriteria criteria) {
+ public PageList<AlertDefinition> findAlertDefinitionsByCriteria(AlertDefinitionCriteria criteria)
+ throws RuntimeException {
try {
PageList<AlertDefinition> results = this.alertDefManager.findAlertDefinitionsByCriteria(
getSessionSubject(), criteria);
return SerialUtility.prepare(results, "findAlertDefinitionsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws Exception {
+ public int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException {
try {
int results = alertDefManager.createAlertDefinition(getSessionSubject(), alertDefinition, resourceId);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
public AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition,
- boolean updateInternals) throws Exception {
+ boolean updateInternals) throws RuntimeException {
try {
AlertDefinition results = alertDefManager.updateAlertDefinition(getSessionSubject(), alertDefinitionId,
alertDefinition, updateInternals);
return SerialUtility.prepare(results, "updateAlertDefinition");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public int enableAlertDefinitions(int[] alertDefinitionIds) throws Exception {
+ public int enableAlertDefinitions(int[] alertDefinitionIds) throws RuntimeException {
try {
int results = alertDefManager.enableAlertDefinitions(getSessionSubject(), alertDefinitionIds);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public int disableAlertDefinitions(int[] alertDefinitionIds) throws Exception {
+ public int disableAlertDefinitions(int[] alertDefinitionIds) throws RuntimeException {
try {
int results = alertDefManager.disableAlertDefinitions(getSessionSubject(), alertDefinitionIds);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public int removeAlertDefinitions(int[] alertDefinitionIds) throws Exception {
+ public int removeAlertDefinitions(int[] alertDefinitionIds) throws RuntimeException {
try {
int results = alertDefManager.removeAlertDefinitions(getSessionSubject(), alertDefinitionIds);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public String[] getAlertNotificationConfigurationPreview(AlertNotification[] notifs) throws Exception {
+ public String[] getAlertNotificationConfigurationPreview(AlertNotification[] notifs) throws RuntimeException {
try {
String[] results = alertDefManager.getAlertNotificationConfigurationPreview(getSessionSubject(), notifs);
return SerialUtility.prepare(results, "getAlertNotificationConfigurationPreview");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public String[] getAllAlertSenders() throws Exception {
+ public String[] getAllAlertSenders() throws RuntimeException {
try {
List<String> results = alertNotifManager.listAllAlertSenders();
if (results == null) {
return null;
}
return SerialUtility.prepare(results.toArray(new String[results.size()]), "getAllAlertSenders");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public ConfigurationDefinition getConfigurationDefinitionForSender(String sender) throws Exception {
+ public ConfigurationDefinition getConfigurationDefinitionForSender(String sender) throws RuntimeException {
try {
ConfigurationDefinition results = alertNotifManager.getConfigurationDefinitionForSender(sender);
return SerialUtility.prepare(results, "getConfigurationDefinitionForSender");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
index 9f66d19..3072708 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
@@ -37,44 +37,44 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
private AlertManagerLocal alertManager = LookupUtil.getAlertManager();
- public PageList<Alert> findAlertsByCriteria(AlertCriteria criteria) {
+ public PageList<Alert> findAlertsByCriteria(AlertCriteria criteria) throws RuntimeException {
try {
return SerialUtility.prepare(this.alertManager.findAlertsByCriteria(getSessionSubject(), criteria),
"AlertService.findAlertsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public int deleteAlerts(int[] alertIds) {
+ public int deleteAlerts(int[] alertIds) throws RuntimeException {
try {
return this.alertManager.deleteAlerts(getSessionSubject(), alertIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public int deleteAlertsByContext(EntityContext context) {
+ public int deleteAlertsByContext(EntityContext context) throws RuntimeException {
try {
return this.alertManager.deleteAlertsByContext(getSessionSubject(), context);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public int acknowledgeAlerts(int[] alertIds) {
+ public int acknowledgeAlerts(int[] alertIds) throws RuntimeException {
try {
return this.alertManager.acknowledgeAlerts(getSessionSubject(), alertIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public int acknowledgeAlertsByContext(EntityContext context) {
+ public int acknowledgeAlertsByContext(EntityContext context) throws RuntimeException {
try {
return this.alertManager.acknowledgeAlertsByContext(getSessionSubject(), context);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
index 55a24e3..7179ffc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
@@ -31,55 +31,55 @@ public class AlertTemplateGWTServiceImpl extends AbstractGWTServiceImpl implemen
private AlertTemplateManagerLocal alertTemplateManager = LookupUtil.getAlertTemplateManager();
@Override
- public int createAlertTemplate(AlertDefinition alertDefinition, Integer resourceTypeId) throws Exception {
+ public int createAlertTemplate(AlertDefinition alertDefinition, Integer resourceTypeId) throws RuntimeException {
try {
int results = alertTemplateManager
.createAlertTemplate(getSessionSubject(), alertDefinition, resourceTypeId);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
public AlertDefinition updateAlertTemplate(AlertDefinition alertDefinition, boolean purgeInternals)
- throws Exception {
+ throws RuntimeException {
try {
AlertDefinition results = alertTemplateManager.updateAlertTemplate(getSessionSubject(), alertDefinition,
purgeInternals);
return SerialUtility.prepare(results, "AlertTemplateService.updateAlertTemplate");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public void enableAlertTemplates(Integer[] alertDefinitionIds) throws Exception {
+ public void enableAlertTemplates(Integer[] alertDefinitionIds) throws RuntimeException {
try {
alertTemplateManager.enableAlertTemplates(getSessionSubject(), alertDefinitionIds);
return;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public void disableAlertTemplates(Integer[] alertDefinitionIds) throws Exception {
+ public void disableAlertTemplates(Integer[] alertDefinitionIds) throws RuntimeException {
try {
alertTemplateManager.disableAlertTemplates(getSessionSubject(), alertDefinitionIds);
return;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public void removeAlertTemplates(Integer[] alertDefinitionIds) throws Exception {
+ public void removeAlertTemplates(Integer[] alertDefinitionIds) throws RuntimeException {
try {
alertTemplateManager.removeAlertTemplates(getSessionSubject(), alertDefinitionIds);
return;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
index 56a4857..a23bf27 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
@@ -37,49 +37,49 @@ public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implemen
private AuthorizationManagerLocal authorizationManager = LookupUtil.getAuthorizationManager();
- public Set<Permission> getExplicitResourcePermissions(int resourceId) {
+ public Set<Permission> getExplicitResourcePermissions(int resourceId) throws RuntimeException {
try {
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getExplicitResourcePermissions(
getSessionSubject(), resourceId)), "AuthorizationManager.getExplicitResourcePermissions");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Set<Permission> getImplicitResourcePermissions(int resourceId) {
+ public Set<Permission> getImplicitResourcePermissions(int resourceId) throws RuntimeException {
try {
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getImplicitResourcePermissions(
getSessionSubject(), resourceId)), "AuthorizationManager.getImplicitResourcePermissions");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Set<Permission> getExplicitGroupPermissions(int groupId) {
+ public Set<Permission> getExplicitGroupPermissions(int groupId) throws RuntimeException {
try {
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getExplicitGroupPermissions(
getSessionSubject(), groupId)), "AuthorizationManager.getExplicitGroupPermissions");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Set<Permission> getImplicitGroupPermissions(int groupId) {
+ public Set<Permission> getImplicitGroupPermissions(int groupId) throws RuntimeException {
try {
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getImplicitGroupPermissions(
getSessionSubject(), groupId)), "AuthorizationManager.getImplicitGroupPermissions");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Set<Permission> getExplicitGlobalPermissions() {
+ public Set<Permission> getExplicitGlobalPermissions() throws RuntimeException {
try {
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager
.getExplicitGlobalPermissions(getSessionSubject())),
"AuthorizationManager.getExplicitGlobalPermissions");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
index 4b636f0..93e16c9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
@@ -36,12 +36,12 @@ public class AvailabilityGWTServiceImpl extends AbstractGWTServiceImpl implement
private AvailabilityManagerLocal availabilityManager = LookupUtil.getAvailabilityManager();
- public PageList<Availability> findAvailabilityForResource(int resourceId, PageControl pc) {
+ public PageList<Availability> findAvailabilityForResource(int resourceId, PageControl pc) throws RuntimeException {
try {
return SerialUtility.prepare(availabilityManager.findAvailabilityForResource(getSessionSubject(),
resourceId, pc), "AvailabilityService.findAvailabilityForResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
index 103fcac..4049454 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
@@ -48,218 +48,222 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
private BundleManagerLocal bundleManager = LookupUtil.getBundleManager();
- public BundleVersion createBundleVersionViaURL(String url) throws Exception {
+ public BundleVersion createBundleVersionViaURL(String url) throws RuntimeException {
try {
BundleVersion results = bundleManager.createBundleVersionViaURL(getSessionSubject(), url);
return SerialUtility.prepare(results, "createBundleVersionViaURL");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public BundleVersion createBundleVersionViaRecipe(String recipe) throws Exception {
+ public BundleVersion createBundleVersionViaRecipe(String recipe) throws RuntimeException {
try {
BundleVersion results = bundleManager.createBundleVersionViaRecipe(getSessionSubject(), recipe);
return SerialUtility.prepare(results, "createBundleVersionViaRecipe");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public BundleDeployment createBundleDeployment(int bundleVersionId, int bundleDestinationId, String description,
Configuration configuration, boolean enforcePolicy, int enforcementInterval, boolean pinToBundle)
- throws Exception {
+ throws RuntimeException {
try {
BundleDeployment result = bundleManager.createBundleDeployment(getSessionSubject(), bundleVersionId,
bundleDestinationId, description, configuration);
return SerialUtility.prepare(result, "createBundleDeployment");
- } catch (Exception e) {
- throw new Exception(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public BundleDestination createBundleDestination(int bundleId, String name, String description, String deployDir,
- int groupId) throws Exception {
+ int groupId) throws RuntimeException {
try {
BundleDestination result = bundleManager.createBundleDestination(getSessionSubject(), bundleId, name,
description, deployDir, groupId);
return SerialUtility.prepare(result, "createBundleDestination");
- } catch (Exception e) {
- throw new Exception(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public BundleVersion createBundleVersion(int bundleId, String name, String version, String recipe) throws Exception {
+ public BundleVersion createBundleVersion(int bundleId, String name, String version, String recipe)
+ throws RuntimeException {
try {
BundleVersion results = bundleManager.createBundleVersion(getSessionSubject(), bundleId, name, null,
version, recipe);
return SerialUtility.prepare(results, "createBundleVersion");
- } catch (Exception e) {
- throw new Exception(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteBundles(int[] bundleIds) throws Exception {
+ public void deleteBundles(int[] bundleIds) throws RuntimeException {
try {
bundleManager.deleteBundles(getSessionSubject(), bundleIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteBundle(int bundleId) throws Exception {
+ public void deleteBundle(int bundleId) throws RuntimeException {
try {
bundleManager.deleteBundle(getSessionSubject(), bundleId);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteBundleDeployment(int bundleDeploymentId) throws Exception {
+ public void deleteBundleDeployment(int bundleDeploymentId) throws RuntimeException {
try {
bundleManager.deleteBundleDeployment(getSessionSubject(), bundleDeploymentId);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteBundleDestination(int bundleDestinationId) throws Exception {
+ public void deleteBundleDestination(int bundleDestinationId) throws RuntimeException {
try {
bundleManager.deleteBundleDestination(getSessionSubject(), bundleDestinationId);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteBundleVersion(int bundleVersionId, boolean deleteBundleIfEmpty) throws Exception {
+ public void deleteBundleVersion(int bundleVersionId, boolean deleteBundleIfEmpty) throws RuntimeException {
try {
bundleManager.deleteBundleVersion(getSessionSubject(), bundleVersionId, deleteBundleIfEmpty);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public ArrayList<BundleType> getAllBundleTypes() throws Exception {
+ public ArrayList<BundleType> getAllBundleTypes() throws RuntimeException {
try {
ArrayList<BundleType> bundleTypes = new ArrayList<BundleType>();
bundleTypes.addAll(bundleManager.getAllBundleTypes(getSessionSubject()));
return SerialUtility.prepare(bundleTypes, "getAllBundleTypes");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public HashMap<String, Boolean> getAllBundleVersionFilenames(int bundleVersionId) throws Exception {
+ public HashMap<String, Boolean> getAllBundleVersionFilenames(int bundleVersionId) throws RuntimeException {
HashMap<String, Boolean> results = new HashMap<String, Boolean>();
try {
results.putAll(bundleManager.getAllBundleVersionFilenames(getSessionSubject(), bundleVersionId));
return SerialUtility.prepare(results, "getAllBundleVersionFilenames");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public String getBundleDeploymentName(int bundleDestinationId, int bundleVersionId, int prevDeploymentId) {
+ public String getBundleDeploymentName(int bundleDestinationId, int bundleVersionId, int prevDeploymentId)
+ throws RuntimeException {
String result;
try {
result = bundleManager.getBundleDeploymentName(getSessionSubject(), bundleDestinationId, bundleVersionId,
prevDeploymentId);
return SerialUtility.prepare(result, "getBundleDeploymentName");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public BundleDeployment scheduleBundleDeployment(int bundleDeploymentId, boolean isCleanDeployment)
- throws Exception {
+ throws RuntimeException {
try {
BundleDeployment result = bundleManager.scheduleBundleDeployment(getSessionSubject(), bundleDeploymentId,
isCleanDeployment);
return SerialUtility.prepare(result, "scheduleBundleDeployment");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public BundleDeployment scheduleRevertBundleDeployment(int bundleDeploymentId, String deploymentDescription,
- boolean isCleanDeployment) throws Exception {
+ boolean isCleanDeployment) throws RuntimeException {
try {
BundleDeployment result = bundleManager.scheduleRevertBundleDeployment(getSessionSubject(),
bundleDeploymentId, deploymentDescription, isCleanDeployment);
return SerialUtility.prepare(result, "scheduleRevertBundleDeployment");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<Bundle> findBundlesByCriteria(BundleCriteria criteria) throws Exception {
+ public PageList<Bundle> findBundlesByCriteria(BundleCriteria criteria) throws RuntimeException {
try {
PageList<Bundle> results = bundleManager.findBundlesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(results, "findBundlesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<BundleDeployment> findBundleDeploymentsByCriteria(BundleDeploymentCriteria criteria) {
+ public PageList<BundleDeployment> findBundleDeploymentsByCriteria(BundleDeploymentCriteria criteria)
+ throws RuntimeException {
try {
PageList<BundleDeployment> result = bundleManager.findBundleDeploymentsByCriteria(getSessionSubject(),
criteria);
return SerialUtility.prepare(result, "BundleService.findBundleDeploymentsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<BundleDestination> findBundleDestinationsByCriteria(BundleDestinationCriteria criteria) {
+ public PageList<BundleDestination> findBundleDestinationsByCriteria(BundleDestinationCriteria criteria)
+ throws RuntimeException {
try {
PageList<BundleDestination> result = bundleManager.findBundleDestinationsByCriteria(getSessionSubject(),
criteria);
return SerialUtility.prepare(result, "BundleService.findBundleDestinationsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<BundleFile> findBundleFilesByCriteria(BundleFileCriteria criteria) {
+ public PageList<BundleFile> findBundleFilesByCriteria(BundleFileCriteria criteria) throws RuntimeException {
try {
PageList<BundleFile> result = bundleManager.findBundleFilesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(result, "BundleService.findBundleFilesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<BundleResourceDeployment> findBundleResourceDeploymentsByCriteria(
- BundleResourceDeploymentCriteria criteria) {
+ BundleResourceDeploymentCriteria criteria) throws RuntimeException {
try {
PageList<BundleResourceDeployment> result = bundleManager.findBundleResourceDeploymentsByCriteria(
getSessionSubject(), criteria);
return SerialUtility.prepare(result, "BundleService.findBundleResourceDeploymentsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<BundleVersion> findBundleVersionsByCriteria(BundleVersionCriteria criteria) throws Exception {
+ public PageList<BundleVersion> findBundleVersionsByCriteria(BundleVersionCriteria criteria) throws RuntimeException {
try {
PageList<BundleVersion> results = bundleManager.findBundleVersionsByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(results, "findBundleVersionsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<BundleWithLatestVersionComposite> findBundlesWithLatestVersionCompositesByCriteria(
- BundleCriteria criteria) throws Exception {
+ BundleCriteria criteria) throws RuntimeException {
try {
PageList<BundleWithLatestVersionComposite> results;
results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(results, "findBundlesWithLatestVersionCompositesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
index 211735d..ad81c84 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
@@ -28,6 +28,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.ClusterKey;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ClusterFlyweight;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ClusterGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.resource.cluster.ClusterManagerLocal;
@@ -42,24 +43,41 @@ public class ClusterGWTServiceImpl extends AbstractGWTServiceImpl implements Clu
private ClusterManagerLocal clusterManager = LookupUtil.getClusterManager();
- public ResourceGroup createAutoClusterBackingGroup(ClusterKey clusterKey, boolean addResources) {
- return SerialUtility.prepare(clusterManager.createAutoClusterBackingGroup(getSessionSubject(), clusterKey,
- addResources), "ClusterGWTServiceImpl.createAutoClusterBackingGroup");
+ public ResourceGroup createAutoClusterBackingGroup(ClusterKey clusterKey, boolean addResources)
+ throws RuntimeException {
+ try {
+ return SerialUtility.prepare(clusterManager.createAutoClusterBackingGroup(getSessionSubject(), clusterKey,
+ addResources), "ClusterGWTServiceImpl.createAutoClusterBackingGroup");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
- public ResourceGroup getAutoClusterBackingGroup(ClusterKey clusterKey) {
- return SerialUtility.prepare(clusterManager.getAutoClusterBackingGroup(getSessionSubject(), clusterKey),
- "ClusterGWTServiceImpl.getAutoClusterBackingGroup");
+ public ResourceGroup getAutoClusterBackingGroup(ClusterKey clusterKey) throws RuntimeException {
+ try {
+ return SerialUtility.prepare(clusterManager.getAutoClusterBackingGroup(getSessionSubject(), clusterKey),
+ "ClusterGWTServiceImpl.getAutoClusterBackingGroup");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
- public List<Resource> getAutoClusterResources(ClusterKey clusterKey) {
- return SerialUtility.prepare(clusterManager.getAutoClusterResources(getSessionSubject(), clusterKey),
- "ClusterGWTServiceImpl.getAutoClusterResources");
+ public List<Resource> getAutoClusterResources(ClusterKey clusterKey) throws RuntimeException {
+ try {
+ return SerialUtility.prepare(clusterManager.getAutoClusterResources(getSessionSubject(), clusterKey),
+ "ClusterGWTServiceImpl.getAutoClusterResources");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
- public ClusterFlyweight getClusterTree(int groupId) {
- return SerialUtility.prepare(clusterManager.getClusterTree(getSessionSubject(), groupId),
- "ClusterGWTServiceImpl.getClusterTree");
+ public ClusterFlyweight getClusterTree(int groupId) throws RuntimeException {
+ try {
+ return SerialUtility.prepare(clusterManager.getClusterTree(getSessionSubject(), groupId),
+ "ClusterGWTServiceImpl.getClusterTree");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index 72515a4..935a3dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -47,122 +47,125 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
private ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
- public Configuration getPluginConfiguration(int resourceId) {
+ public Configuration getPluginConfiguration(int resourceId) throws RuntimeException {
try {
Configuration configuration = configurationManager.getPluginConfiguration(getSessionSubject(), resourceId);
return SerialUtility.prepare(configuration, "PluginConfiguration");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public ConfigurationDefinition getPluginConfigurationDefinition(int resourceTypeId) {
+ public ConfigurationDefinition getPluginConfigurationDefinition(int resourceTypeId) throws RuntimeException {
try {
ConfigurationDefinition definition = configurationManager.getPluginConfigurationDefinitionForResourceType(
getSessionSubject(), resourceTypeId);
return SerialUtility.prepare(definition, "PluginDefinition");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Configuration getResourceConfiguration(int resourceId) {
+ public Configuration getResourceConfiguration(int resourceId) throws RuntimeException {
try {
Configuration configuration = configurationManager
.getResourceConfiguration(getSessionSubject(), resourceId);
return SerialUtility.prepare(configuration, "ResourceConfiguration");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public ConfigurationDefinition getResourceConfigurationDefinition(int resourceTypeId) {
+ public ConfigurationDefinition getResourceConfigurationDefinition(int resourceTypeId) throws RuntimeException {
try {
ConfigurationDefinition definition = configurationManager
.getResourceConfigurationDefinitionWithTemplatesForResourceType(getSessionSubject(), resourceTypeId);
return SerialUtility.prepare(definition, "ResourceDefinition");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<ResourceConfigurationUpdate> findResourceConfigurationUpdates(Integer resourceId, Long beginDate,
- Long endDate, boolean suppressOldest, PageControl pc) {
+ Long endDate, boolean suppressOldest, PageControl pc) throws RuntimeException {
try {
PageList<ResourceConfigurationUpdate> result = configurationManager.findResourceConfigurationUpdates(
getSessionSubject(), resourceId, beginDate, endDate, suppressOldest, pc);
return SerialUtility.prepare(result, "ConfigurationService.findResourceConfigurationUpdates");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public ResourceConfigurationUpdate updateResourceConfiguration(int resourceId, Configuration configuration) {
+ public ResourceConfigurationUpdate updateResourceConfiguration(int resourceId, Configuration configuration)
+ throws RuntimeException {
try {
ResourceConfigurationUpdate update = configurationManager.updateResourceConfiguration(getSessionSubject(),
resourceId, configuration);
return SerialUtility.prepare(update, "ConfigurationService.updateResourceConfiguration");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PluginConfigurationUpdate updatePluginConfiguration(int resourceId, Configuration configuration) {
+ public PluginConfigurationUpdate updatePluginConfiguration(int resourceId, Configuration configuration)
+ throws RuntimeException {
try {
PluginConfigurationUpdate update = configurationManager.updatePluginConfiguration(getSessionSubject(),
resourceId, configuration);
return SerialUtility.prepare(update, "ConfigurationService.updatePluginConfiguration");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<ResourceConfigurationUpdate> findResourceConfigurationUpdatesByCriteria(
- ResourceConfigurationUpdateCriteria criteria) {
+ ResourceConfigurationUpdateCriteria criteria) throws RuntimeException {
try {
PageList<ResourceConfigurationUpdate> updates = configurationManager
.findResourceConfigurationUpdatesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(updates, "ConfigurationService.findResourceConfigurationUpdatesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<PluginConfigurationUpdate> findPluginConfigurationUpdatesByCriteria(
- PluginConfigurationUpdateCriteria criteria) {
+ PluginConfigurationUpdateCriteria criteria) throws RuntimeException {
try {
PageList<PluginConfigurationUpdate> updates = configurationManager
.findPluginConfigurationUpdatesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(updates, "ConfigurationService.findPluginConfigurationUpdatesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<GroupResourceConfigurationUpdate> findGroupResourceConfigurationUpdatesByCriteria(
- GroupResourceConfigurationUpdateCriteria criteria) {
+ GroupResourceConfigurationUpdateCriteria criteria) throws RuntimeException {
try {
PageList<GroupResourceConfigurationUpdate> updates = configurationManager
.findGroupResourceConfigurationUpdatesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(updates,
"ConfigurationService.findGroupResourceConfigurationUpdatesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<GroupPluginConfigurationUpdate> findGroupPluginConfigurationUpdatesByCriteria(
- GroupPluginConfigurationUpdateCriteria criteria) {
+ GroupPluginConfigurationUpdateCriteria criteria) throws RuntimeException {
try {
PageList<GroupPluginConfigurationUpdate> updates = configurationManager
.findGroupPluginConfigurationUpdatesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(updates, "ConfigurationService.findGroupPluginConfigurationUpdatesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<DisambiguationReport<ResourceConfigurationComposite>> findResourceConfigurationsForGroup(int groupId) {
+ public List<DisambiguationReport<ResourceConfigurationComposite>> findResourceConfigurationsForGroup(int groupId)
+ throws RuntimeException {
try {
ResourceGroup group = this.groupManager.getResourceGroup(getSessionSubject(), groupId);
Map<Integer, Configuration> configurations = this.configurationManager
@@ -176,12 +179,13 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(disambiguatedConfigurationComposites,
"ConfigurationService.findResourceConfigurationsForGroup");
- } catch (RuntimeException e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<DisambiguationReport<ResourceConfigurationComposite>> findPluginConfigurationsForGroup(int groupId) {
+ public List<DisambiguationReport<ResourceConfigurationComposite>> findPluginConfigurationsForGroup(int groupId)
+ throws RuntimeException {
try {
Map<Integer, Configuration> configurations = this.configurationManager
.getPluginConfigurationsForCompatibleGroup(getSessionSubject(), groupId);
@@ -194,13 +198,13 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(disambiguatedConfigurationComposites,
"ConfigurationService.findPluginConfigurationsForGroup");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public List<DisambiguationReport<ResourceConfigurationComposite>> findPluginConfigurationsForGroupUpdate(
- int groupUpdateId) {
+ int groupUpdateId) throws RuntimeException {
try {
Map<Integer, Configuration> configurations = this.configurationManager
.getPluginConfigurationMapForGroupUpdate(groupUpdateId);
@@ -213,76 +217,81 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(disambiguatedConfigurationComposites,
"ConfigurationService.findPluginConfigurationsForGroupUpdate");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public void updateResourceConfigurationsForGroup(int groupId,
- List<ResourceConfigurationComposite> resourceConfigurations) {
+ List<ResourceConfigurationComposite> resourceConfigurations) throws RuntimeException {
try {
Map<Integer, Configuration> configurations = convertToMap(resourceConfigurations);
this.configurationManager.scheduleGroupResourceConfigurationUpdate(getSessionSubject(), groupId,
configurations);
- } catch (RuntimeException e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public void updatePluginConfigurationsForGroup(int groupId,
- List<ResourceConfigurationComposite> pluginConfigurations) {
+ List<ResourceConfigurationComposite> pluginConfigurations) throws RuntimeException {
try {
Map<Integer, Configuration> configurations = convertToMap(pluginConfigurations);
this.configurationManager.scheduleGroupPluginConfigurationUpdate(getSessionSubject(), groupId,
configurations);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteGroupPluginConfigurationUpdate(Integer groupId, Integer[] groupPluginConfigUpdateIds) {
+ public void deleteGroupPluginConfigurationUpdate(Integer groupId, Integer[] groupPluginConfigUpdateIds)
+ throws RuntimeException {
try {
this.configurationManager.deleteGroupPluginConfigurationUpdates(getSessionSubject(), groupId,
groupPluginConfigUpdateIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteGroupResourceConfigurationUpdate(Integer groupId, Integer[] groupResourceConfigUpdateIds) {
+ public void deleteGroupResourceConfigurationUpdate(Integer groupId, Integer[] groupResourceConfigUpdateIds)
+ throws RuntimeException {
try {
this.configurationManager.deleteGroupResourceConfigurationUpdates(getSessionSubject(), groupId,
groupResourceConfigUpdateIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- /*
- // Dummy method for gwt compiler
- public RawConfiguration dummy(RawConfiguration config) {
- Log.info(config.getPath());
- return new RawConfiguration();
- }
- */
-
- private List<ResourceConfigurationComposite> convertToCompositesList(Map<Integer, Configuration> configurations) {
- List<ResourceConfigurationComposite> configurationComposites = new ArrayList<ResourceConfigurationComposite>(
- configurations.size());
- for (Integer resourceId : configurations.keySet()) {
- Configuration configuration = configurations.get(resourceId);
- ResourceConfigurationComposite configurationComposite = new ResourceConfigurationComposite(resourceId,
- configuration);
- configurationComposites.add(configurationComposite);
+ private List<ResourceConfigurationComposite> convertToCompositesList(Map<Integer, Configuration> configurations)
+ throws RuntimeException {
+ try {
+ List<ResourceConfigurationComposite> configurationComposites = new ArrayList<ResourceConfigurationComposite>(
+ configurations.size());
+ for (Integer resourceId : configurations.keySet()) {
+ Configuration configuration = configurations.get(resourceId);
+ ResourceConfigurationComposite configurationComposite = new ResourceConfigurationComposite(resourceId,
+ configuration);
+ configurationComposites.add(configurationComposite);
+ }
+ return configurationComposites;
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
- return configurationComposites;
}
- private Map<Integer, Configuration> convertToMap(List<ResourceConfigurationComposite> resourceConfigurations) {
- Map<Integer, Configuration> configurations = new HashMap<Integer, Configuration>(resourceConfigurations.size());
- for (ResourceConfigurationComposite resourceConfiguration : resourceConfigurations) {
- configurations.put(resourceConfiguration.getResourceId(), resourceConfiguration.getConfiguration());
+ private Map<Integer, Configuration> convertToMap(List<ResourceConfigurationComposite> resourceConfigurations)
+ throws RuntimeException {
+ try {
+ Map<Integer, Configuration> configurations = new HashMap<Integer, Configuration>(resourceConfigurations
+ .size());
+ for (ResourceConfigurationComposite resourceConfiguration : resourceConfigurations) {
+ configurations.put(resourceConfiguration.getResourceId(), resourceConfiguration.getConfiguration());
+ }
+ return configurations;
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
- return configurations;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
index cc9c288..3df2f0b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
@@ -33,7 +33,6 @@ import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ContentGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.content.ContentManagerLocal;
-import org.rhq.enterprise.server.content.ContentUIManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -44,50 +43,52 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
private static final long serialVersionUID = 1L;
private ContentManagerLocal contentManager = LookupUtil.getContentManager();
- private ContentUIManagerLocal contentUiManager = LookupUtil.getContentUIManager();
- public void deletePackageVersion(int packageVersionId) {
+ //private ContentUIManagerLocal contentUiManager = LookupUtil.getContentUIManager();
+
+ public void deletePackageVersion(int packageVersionId) throws RuntimeException {
try {
contentManager.deletePackageVersion(getSessionSubject(), packageVersionId);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<PackageVersion> findPackageVersionsByCriteria(PackageVersionCriteria criteria) {
+ public PageList<PackageVersion> findPackageVersionsByCriteria(PackageVersionCriteria criteria)
+ throws RuntimeException {
try {
return SerialUtility.prepare(contentManager.findPackageVersionsByCriteria(getSessionSubject(), criteria),
"ContentService.findPackageVersionsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- // public PageList<InstalledPackageHistory> getInstalledPackageHistoryForResource(int resourceId, int count) {
+ // public PageList<InstalledPackageHistory> getInstalledPackageHistoryForResource(int resourceId, int count) throws RuntimeException {
// try {
// PageControl pc = new PageControl(0, count);
// return SerialUtility.prepare(contentUiManager.getInstalledPackageHistoryForResource(resourceId, pc),
// "ContentService.getInstalledPackageHistoryForResource");
- // } catch (Exception e) {
- // throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ // } catch (Throwable t) {
+ // throw new RuntimeException(ThrowableUtil.getAllMessages(t));
// }
// }
- public List<Architecture> getArchitectures() {
+ public List<Architecture> getArchitectures() throws RuntimeException {
try {
return SerialUtility.prepare(contentManager.findArchitectures(getSessionSubject()),
"ContentService.getArchitectures");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PackageType getResourceCreationPackageType(int resourceTypeId) {
+ public PackageType getResourceCreationPackageType(int resourceTypeId) throws RuntimeException {
try {
return SerialUtility.prepare(contentManager.getResourceCreationPackageType(resourceTypeId),
"ContentService.getResourceCreationPackageType");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
index 742c68e..c45ca10 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
@@ -40,38 +40,38 @@ public class DashboardGWTServiceImpl extends AbstractGWTServiceImpl implements D
private DashboardManagerLocal dashboardManager = LookupUtil.getDashboardManagerLocal();
- public List<Dashboard> findDashboardsForSubject() {
+ public List<Dashboard> findDashboardsForSubject() throws RuntimeException {
try {
return SerialUtility.prepare(dashboardManager.findDashboardsForSubject(getSessionSubject()),
"DashboardManager.findDashboardsForSubject");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<Dashboard> findSharedDashboards() {
+ public List<Dashboard> findSharedDashboards() throws RuntimeException {
try {
return SerialUtility.prepare(dashboardManager.findSharedDashboards(getSessionSubject()),
"DashboardManager.findSharedDashboards");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Dashboard storeDashboard(Dashboard dashboard) {
+ public Dashboard storeDashboard(Dashboard dashboard) throws RuntimeException {
try {
return SerialUtility.prepare(dashboardManager.storeDashboard(getSessionSubject(), dashboard),
"DashboardManager.storeDashboard");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void removeDashboard(int dashboardId) {
+ public void removeDashboard(int dashboardId) throws RuntimeException {
try {
dashboardManager.removeDashboard(getSessionSubject(), dashboardId);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
index 6369c90..9654a9d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
@@ -46,32 +46,34 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
private EventManagerLocal eventManager = LookupUtil.getEventManager();
- public EventSeverity[] getSeverityBuckets(int resourceId, long begin, long end, int numBuckets) {
+ public EventSeverity[] getSeverityBuckets(int resourceId, long begin, long end, int numBuckets)
+ throws RuntimeException {
try {
return SerialUtility.prepare(eventManager.getSeverityBuckets(getSessionSubject(), resourceId, begin, end,
numBuckets), "EventService.getSeverityBuckets");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public EventSeverity[] getSeverityBucketsForAutoGroup(int parentResourceId, int resourceTypeId, long begin,
- long end, int numBuckets) {
+ long end, int numBuckets) throws RuntimeException {
try {
return SerialUtility.prepare(eventManager.getSeverityBucketsForAutoGroup(getSessionSubject(),
parentResourceId, resourceTypeId, begin, end, numBuckets),
"EventService.getSeverityBucketsForAutoGroup");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public EventSeverity[] getSeverityBucketsForCompGroup(int resourceGroupId, long begin, long end, int numBuckets) {
+ public EventSeverity[] getSeverityBucketsForCompGroup(int resourceGroupId, long begin, long end, int numBuckets)
+ throws RuntimeException {
try {
return SerialUtility.prepare(eventManager.getSeverityBucketsForCompGroup(getSessionSubject(),
resourceGroupId, begin, end, numBuckets), "EventService.getSeverityBucketsForCompGroup");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@@ -84,37 +86,37 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
// }
// }
- public PageList<Event> findEventsByCriteria(EventCriteria criteria) {
+ public PageList<Event> findEventsByCriteria(EventCriteria criteria) throws RuntimeException {
try {
return SerialUtility.prepare(eventManager.findEventsByCriteria(getSessionSubject(), criteria),
"EventService.findEventsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria) {
+ public PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria) throws RuntimeException {
try {
return SerialUtility.prepare(eventManager.findEventCompositesByCriteria(getSessionSubject(), criteria),
"EventService.findEventsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public int deleteEventsForContext(EntityContext context, List<Integer> eventIds) {
+ public int deleteEventsForContext(EntityContext context, List<Integer> eventIds) throws RuntimeException {
try {
return eventManager.deleteEventsForContext(getSessionSubject(), context, eventIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public int purgeEventsForContext(EntityContext context) {
+ public int purgeEventsForContext(EntityContext context) throws RuntimeException {
try {
return eventManager.purgeEventsForContext(getSessionSubject(), context);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
index 7b65ee2..38a076b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
@@ -33,58 +33,58 @@ public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl i
@Override
public int createGroupAlertDefinitions(AlertDefinition groupAlertDefinition, Integer resourceGroupId)
- throws Exception {
+ throws RuntimeException {
try {
int results = groupAlertDefManager.createGroupAlertDefinitions(getSessionSubject(), groupAlertDefinition,
resourceGroupId);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
public AlertDefinition updateGroupAlertDefinitions(AlertDefinition groupAlertDefinition, boolean purgeInternals)
- throws Exception {
+ throws RuntimeException {
try {
AlertDefinition results = groupAlertDefManager.updateGroupAlertDefinitions(getSessionSubject(),
groupAlertDefinition, purgeInternals);
return SerialUtility.prepare(results, "updateGroupAlertDefinitions");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public int enableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ public int enableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws RuntimeException {
try {
int results = groupAlertDefManager
.enableGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public int disableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ public int disableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws RuntimeException {
try {
int results = groupAlertDefManager.disableGroupAlertDefinitions(getSessionSubject(),
groupAlertDefinitionIds);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public int removeGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ public int removeGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws RuntimeException {
try {
int results = groupAlertDefManager
.removeGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
index 5969954..6e3363e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
@@ -19,7 +19,6 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -57,11 +56,12 @@ public class LdapGWTServiceImpl extends AbstractGWTServiceImpl implements LdapGW
private final Log log = LogFactory.getLog(LdapGWTServiceImpl.class);
@Override
- public Set<Map<String, String>> findAvailableGroups() {
- //add permissions check
- Set<Permission> globalPermissions = authorizationManager.getExplicitGlobalPermissions(getSessionSubject());
- Boolean accessGranted = globalPermissions.contains(Permission.MANAGE_SECURITY);
+ public Set<Map<String, String>> findAvailableGroups() throws RuntimeException {
try {
+ //add permissions check
+ Set<Permission> globalPermissions = authorizationManager.getExplicitGlobalPermissions(getSessionSubject());
+ Boolean accessGranted = globalPermissions.contains(Permission.MANAGE_SECURITY);
+
Set<Map<String, String>> results = null;
if (accessGranted) {
results = ldapManager.findAvailableGroups();
@@ -77,11 +77,12 @@ public class LdapGWTServiceImpl extends AbstractGWTServiceImpl implements LdapGW
}
}
- public void setLdapGroupsForRole(int roleId, List<String> groupIds) {
- //add permissions check
- Set<Permission> globalPermissions = authorizationManager.getExplicitGlobalPermissions(getSessionSubject());
- Boolean accessGranted = globalPermissions.contains(Permission.MANAGE_SECURITY);
+ public void setLdapGroupsForRole(int roleId, List<String> groupIds) throws RuntimeException {
try {
+ //add permissions check
+ Set<Permission> globalPermissions = authorizationManager.getExplicitGlobalPermissions(getSessionSubject());
+ Boolean accessGranted = globalPermissions.contains(Permission.MANAGE_SECURITY);
+
if (accessGranted) {
//clean out existing roles as this defines the new list of roles
PageList<LdapGroup> existing = ldapManager.findLdapGroupsByRole(roleId, PageControl
@@ -122,13 +123,12 @@ public class LdapGWTServiceImpl extends AbstractGWTServiceImpl implements LdapGW
}
}
- @Override
- public PageList<LdapGroup> findLdapGroupsAssignedToRole(int roleId) {
- //add permissions check
- Set<Permission> globalPermissions = authorizationManager.getExplicitGlobalPermissions(getSessionSubject());
- Boolean accessGranted = globalPermissions.contains(Permission.MANAGE_SECURITY);
-
+ public PageList<LdapGroup> findLdapGroupsAssignedToRole(int roleId) throws RuntimeException {
try {
+ //add permissions check
+ Set<Permission> globalPermissions = authorizationManager.getExplicitGlobalPermissions(getSessionSubject());
+ Boolean accessGranted = globalPermissions.contains(Permission.MANAGE_SECURITY);
+
PageList<LdapGroup> allAssignedLdapGroups = null;
if (accessGranted) {
allAssignedLdapGroups = ldapManager.findLdapGroupsByRole(roleId, PageControl.getUnlimitedInstance());
@@ -144,32 +144,26 @@ public class LdapGWTServiceImpl extends AbstractGWTServiceImpl implements LdapGW
}
}
- /**Light call to determine ldap configuration status.
- *
+ /**
+ * Light call to determine ldap configuration status.
*/
- @Override
- public Boolean checkLdapConfiguredStatus() {
- Boolean ldapEnabled = false;
+ public Boolean checkLdapConfiguredStatus() throws RuntimeException {
try {
String provider = systemManager.getSystemConfiguration().getProperty(RHQConstants.JAASProvider);
- ldapEnabled = ((provider != null) && provider.equals(RHQConstants.LDAPJAASProvider));
+ return ((provider != null) && provider.equals(RHQConstants.LDAPJAASProvider));
} catch (Exception e) {
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
- return ldapEnabled;
}
- /**Returns all LDAP details for a given user, using the configured ldap details of server.
- *
+ /**
+ * Returns all LDAP details for a given user, using the configured ldap details of server.
*/
- @Override
- public Map<String, String> getLdapDetailsFor(String user) {
- Map<String, String> ldapDetails = new HashMap<String, String>();
+ public Map<String, String> getLdapDetailsFor(String user) throws RuntimeException {
try {
- ldapDetails = ldapManager.findLdapUserDetails(user);
+ return ldapManager.findLdapUserDetails(user);
} catch (Exception e) {
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
- return ldapDetails;
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
index 0a83095..5ac43c3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
@@ -60,179 +60,189 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
private MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
private MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
- public List<MeasurementDataTrait> findCurrentTraitsForResource(int resourceId, DisplayType displayType) {
+ public List<MeasurementDataTrait> findCurrentTraitsForResource(int resourceId, DisplayType displayType)
+ throws RuntimeException {
try {
return SerialUtility.prepare(dataManager.findCurrentTraitsForResource(getSessionSubject(), resourceId,
displayType), "MeasurementDataService.findCurrentTraitsForResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Set<MeasurementData> findLiveData(int resourceId, int[] definitionIds) {
+ public Set<MeasurementData> findLiveData(int resourceId, int[] definitionIds) throws RuntimeException {
try {
return SerialUtility.prepare(dataManager.findLiveData(getSessionSubject(), resourceId, definitionIds),
"MeasurementDataService.findLiveData");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public List<List<MeasurementDataNumericHighLowComposite>> findDataForResource(int resourceId, int[] definitionIds,
- long beginTime, long endTime, int numPoints) {
+ long beginTime, long endTime, int numPoints) throws RuntimeException {
try {
return SerialUtility.prepare(dataManager.findDataForResource(getSessionSubject(), resourceId,
definitionIds, beginTime, endTime, numPoints), "MeasurementDataService.findDataForResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<CallTimeDataComposite> findCallTimeDataForResource(int scheduleId, long start, long end,
- PageControl pageControl) {
+ PageControl pageControl) throws RuntimeException {
try {
return SerialUtility.prepare(callTimeDataManager.findCallTimeDataForResource(getSessionSubject(),
scheduleId, start, end, pageControl), "MeasurementDataService.findCallTimeDataForResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<MeasurementDefinition> findMeasurementDefinitionsByCriteria(MeasurementDefinitionCriteria criteria) {
+ public PageList<MeasurementDefinition> findMeasurementDefinitionsByCriteria(MeasurementDefinitionCriteria criteria)
+ throws RuntimeException {
try {
return SerialUtility.prepare(definitionManager.findMeasurementDefinitionsByCriteria(getSessionSubject(),
criteria), "MeasurementDataService.findMeasurementDefinintionsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<MeasurementSchedule> findMeasurementSchedulesByCriteria(MeasurementScheduleCriteria criteria) {
+ public PageList<MeasurementSchedule> findMeasurementSchedulesByCriteria(MeasurementScheduleCriteria criteria)
+ throws RuntimeException {
try {
return SerialUtility.prepare(scheduleManager.findSchedulesByCriteria(getSessionSubject(), criteria),
"MeasurementDataService.findMeasurementSchedulesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<MeasurementScheduleComposite> getMeasurementScheduleCompositesByContext(EntityContext context) {
+ public PageList<MeasurementScheduleComposite> getMeasurementScheduleCompositesByContext(EntityContext context)
+ throws RuntimeException {
try {
return SerialUtility.prepare(scheduleManager.getMeasurementScheduleCompositesByContext(getSessionSubject(),
context, PageControl.getUnlimitedInstance()),
"MeasurementDataService.getMeasurementScheduleCompositesByContext");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public PageList<MeasurementOOBComposite> getSchedulesWithOOBs(String metricNameFilter, String resourceNameFilter,
- String parentNameFilter, PageControl pc) {
+ String parentNameFilter, PageControl pc) throws RuntimeException {
try {
return SerialUtility.prepare(measurementOOBManager.getSchedulesWithOOBs(getSessionSubject(),
metricNameFilter, resourceNameFilter, parentNameFilter, pc),
"MeasurementDataService.getSchedulesWithOOBs");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<MeasurementOOBComposite> getHighestNOOBsForResource(int resourceId, int n) {
+ public PageList<MeasurementOOBComposite> getHighestNOOBsForResource(int resourceId, int n) throws RuntimeException {
try {
return SerialUtility.prepare(measurementOOBManager.getHighestNOOBsForResource(getSessionSubject(),
resourceId, n), "MeasurementDataService.getHighestNOOBsForResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void enableSchedulesForResource(int resourceId, int[] measurementDefinitionIds) {
+ public void enableSchedulesForResource(int resourceId, int[] measurementDefinitionIds) throws RuntimeException {
try {
scheduleManager.enableSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void disableSchedulesForResource(int resourceId, int[] measurementDefinitionIds) {
+ public void disableSchedulesForResource(int resourceId, int[] measurementDefinitionIds) throws RuntimeException {
try {
scheduleManager.disableSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateSchedulesForResource(int resourceId, int[] measurementDefinitionIds, long collectionInterval) {
+ public void updateSchedulesForResource(int resourceId, int[] measurementDefinitionIds, long collectionInterval)
+ throws RuntimeException {
try {
scheduleManager.updateSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds,
collectionInterval);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void enableSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds) {
+ public void enableSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds)
+ throws RuntimeException {
try {
scheduleManager.enableSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
measurementDefinitionIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void disableSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds) {
+ public void disableSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds)
+ throws RuntimeException {
try {
scheduleManager.disableSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
measurementDefinitionIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public void updateSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds,
- long collectionInterval) {
+ long collectionInterval) throws RuntimeException {
try {
scheduleManager.updateSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
measurementDefinitionIds, collectionInterval);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void enableSchedulesForResourceType(int[] measurementDefinitionIds, boolean updateExistingSchedules) {
+ public void enableSchedulesForResourceType(int[] measurementDefinitionIds, boolean updateExistingSchedules)
+ throws RuntimeException {
try {
scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
measurementDefinitionIds, 0, updateExistingSchedules);
- } catch (RuntimeException e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void disableSchedulesForResourceType(int[] measurementDefinitionIds, boolean updateExistingSchedules) {
+ public void disableSchedulesForResourceType(int[] measurementDefinitionIds, boolean updateExistingSchedules)
+ throws RuntimeException {
try {
scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
measurementDefinitionIds, -1, updateExistingSchedules);
- } catch (RuntimeException e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public void updateSchedulesForResourceType(int[] measurementDefinitionIds, long collectionInterval,
- boolean updateExistingSchedules) {
+ boolean updateExistingSchedules) throws RuntimeException {
try {
scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
measurementDefinitionIds, collectionInterval, updateExistingSchedules);
- } catch (RuntimeException e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<MeasurementDataTrait> findTraitsByCriteria(MeasurementDataTraitCriteria criteria) {
+ public PageList<MeasurementDataTrait> findTraitsByCriteria(MeasurementDataTraitCriteria criteria)
+ throws RuntimeException {
try {
return SerialUtility.prepare(dataManager.findTraitsByCriteria(getSessionSubject(), criteria),
"MeasurementDataService.findTraitsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index a51ed3f..8d15f3c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -52,21 +52,22 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
public PageList<ResourceOperationHistory> findResourceOperationHistoriesByCriteria(
- ResourceOperationHistoryCriteria criteria) {
+ ResourceOperationHistoryCriteria criteria) throws RuntimeException {
try {
return SerialUtility.prepare(operationManager.findResourceOperationHistoriesByCriteria(getSessionSubject(),
criteria), "OperationService.findResourceOperationHistoriesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<GroupOperationHistory> findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria) {
+ public PageList<GroupOperationHistory> findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria)
+ throws RuntimeException {
try {
return SerialUtility.prepare(operationManager.findGroupOperationHistoriesByCriteria(getSessionSubject(),
criteria), "OperationService.findGroupOperationHistoriesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@@ -75,8 +76,8 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
try {
ResourceOperationSchedule opSchedule = operationManager.scheduleResourceOperation(getSessionSubject(),
resourceId, operationName, 0, 0, 0, 0, parameters, description);
- } catch (Exception e) {
- throw new RuntimeException("Unable to invoke operation: " + e.getMessage());
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@@ -86,9 +87,8 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
CronTrigger ct = new CronTrigger("resource " + resourceId + "_" + operationName, "group", cronString);
ResourceOperationSchedule opSchedule = operationManager.scheduleResourceOperation(getSessionSubject(),
resourceId, operationName, parameters, ct, description);
-
- } catch (Exception e) {
- throw new RuntimeException("Unable to schedule operation execution: " + e.getMessage());
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@@ -96,7 +96,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
*
*/
public List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(
- int pageSize) {
+ int pageSize) throws RuntimeException {
try {
PageControl pageControl = new PageControl(0, pageSize);
PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = operationManager
@@ -108,15 +108,16 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
DefaultDisambiguationUpdateStrategies.getDefault());
return disambiguatedLastCompletedResourceOps;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
/** Find scheduled operations, disambiguate them and return that list.
*
*/
- public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize) {
+ public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize)
+ throws RuntimeException {
try {
PageControl pageControl = new PageControl(0, pageSize);
PageList<ResourceOperationScheduleComposite> scheduledResourceOps = operationManager
@@ -128,30 +129,28 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
DefaultDisambiguationUpdateStrategies.getDefault());
return disambiguatedNextScheduledResourceOps;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public List<ResourceOperationSchedule> findScheduledResourceOperations(int resourceId) throws RuntimeException {
try {
- List<ResourceOperationSchedule> resourceOperationSchedules =
- operationManager.findScheduledResourceOperations(getSessionSubject(), resourceId);
+ List<ResourceOperationSchedule> resourceOperationSchedules = operationManager
+ .findScheduledResourceOperations(getSessionSubject(), resourceId);
return SerialUtility.prepare(resourceOperationSchedules, "findScheduledResourceOperations");
- }
- catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public List<GroupOperationSchedule> findScheduledGroupOperations(int groupId) throws RuntimeException {
try {
- List<GroupOperationSchedule> groupOperationSchedules =
- operationManager.findScheduledGroupOperations(getSessionSubject(), groupId);
+ List<GroupOperationSchedule> groupOperationSchedules = operationManager.findScheduledGroupOperations(
+ getSessionSubject(), groupId);
return SerialUtility.prepare(groupOperationSchedules, "findScheduledGroupOperations");
- }
- catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java
index f29598f..b397c15 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java
@@ -38,66 +38,67 @@ public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implemen
private RemoteInstallManagerLocal remoteInstallManager = LookupUtil.getRemoteInstallManager();
- public boolean agentInstallCheck(RemoteAccessInfo remoteAccessInfo, String agentInstallPath) {
+ public boolean agentInstallCheck(RemoteAccessInfo remoteAccessInfo, String agentInstallPath)
+ throws RuntimeException {
try {
return SerialUtility.prepare(remoteInstallManager.agentInstallCheck(getSessionSubject(), remoteAccessInfo,
agentInstallPath), "RemoteInstallService.agentInstallCheck");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public AgentInstallInfo installAgent(RemoteAccessInfo remoteAccessInfo, String parentPath) {
+ public AgentInstallInfo installAgent(RemoteAccessInfo remoteAccessInfo, String parentPath) throws RuntimeException {
try {
return SerialUtility.prepare(remoteInstallManager.installAgent(getSessionSubject(), remoteAccessInfo,
parentPath), "RemoteInstallService.installAgent");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public String startAgent(RemoteAccessInfo remoteAccessInfo, String agentInstallPath) {
+ public String startAgent(RemoteAccessInfo remoteAccessInfo, String agentInstallPath) throws RuntimeException {
try {
return SerialUtility.prepare(remoteInstallManager.startAgent(getSessionSubject(), remoteAccessInfo,
agentInstallPath), "RemoteInstallService.startAgent");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public String stopAgent(RemoteAccessInfo remoteAccessInfo, String agentInstallPath) {
+ public String stopAgent(RemoteAccessInfo remoteAccessInfo, String agentInstallPath) throws RuntimeException {
try {
return SerialUtility.prepare(remoteInstallManager.stopAgent(getSessionSubject(), remoteAccessInfo,
agentInstallPath), "RemoteInstallService.stopAgent");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public String agentStatus(RemoteAccessInfo remoteAccessInfo, String agentInstallPath) {
+ public String agentStatus(RemoteAccessInfo remoteAccessInfo, String agentInstallPath) throws RuntimeException {
try {
return SerialUtility.prepare(remoteInstallManager.agentStatus(getSessionSubject(), remoteAccessInfo,
agentInstallPath), "RemoteInstallService.agentStatus");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public String findAgentInstallPath(RemoteAccessInfo remoteAccessInfo, String parentPath) {
+ public String findAgentInstallPath(RemoteAccessInfo remoteAccessInfo, String parentPath) throws RuntimeException {
try {
return SerialUtility.prepare((remoteInstallManager.findAgentInstallPath(getSessionSubject(),
remoteAccessInfo, parentPath)), "RemoteInstallService.findAgentInstallPath");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public String[] remotePathDiscover(RemoteAccessInfo remoteAccessInfo, String parentPath) {
+ public String[] remotePathDiscover(RemoteAccessInfo remoteAccessInfo, String parentPath) throws RuntimeException {
try {
return SerialUtility.prepare((remoteInstallManager.remotePathDiscover(getSessionSubject(),
remoteAccessInfo, parentPath)), "RemoteInstallService.remotePathDiscover");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
index 98c26cc..100289c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
@@ -40,12 +40,12 @@ public class RepoGWTServiceImpl extends AbstractGWTServiceImpl implements RepoGW
private RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
- public PageList<Repo> findReposByCriteria(RepoCriteria criteria) throws Exception {
+ public PageList<Repo> findReposByCriteria(RepoCriteria criteria) throws RuntimeException {
try {
return SerialUtility.prepare(repoManager.findReposByCriteria(getSessionSubject(), criteria),
"RepoService.findReposByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
index fb00c3a..046443d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
@@ -44,11 +44,11 @@ public class ResourceBossGWTServiceImpl extends AbstractGWTServiceImpl implement
return getInventorySummary(subject);
}
- public InventorySummary getInventorySummary(Subject user) {
+ public InventorySummary getInventorySummary(Subject user) throws RuntimeException {
try {
return resourceBoss.getInventorySummary(user);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 105963c..c2b7ab4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -110,6 +110,12 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
private static Set<String> importantFieldsSet = new HashSet<String>(Arrays.asList(importantFields));
+ private static final IntExtractor<ProblemResourceComposite> RESOURCE_ID_EXTRACTOR = new IntExtractor<ProblemResourceComposite>() {
+ public int extract(ProblemResourceComposite object) {
+ return object.getResourceId();
+ }
+ };
+
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
@@ -119,19 +125,20 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
public ResourceGWTServiceImpl() {
}
- public PageList<Resource> findResourcesByCriteria(ResourceCriteria criteria) {
+ public PageList<Resource> findResourcesByCriteria(ResourceCriteria criteria) throws RuntimeException {
try {
PageList<Resource> result = resourceManager.findResourcesByCriteria(getSessionSubject(), criteria);
ObjectFilter.filterFieldsInCollection(result, importantFieldsSet);
return SerialUtility.prepare(result, "ResourceService.findResourcesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<ResourceComposite> findResourceCompositesByCriteria(ResourceCriteria criteria) {
+ public PageList<ResourceComposite> findResourceCompositesByCriteria(ResourceCriteria criteria)
+ throws RuntimeException {
try {
PageList<ResourceComposite> result = resourceManager.findResourceCompositesByCriteria(getSessionSubject(),
criteria);
@@ -142,15 +149,16 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
}
return SerialUtility.prepare(result, "ResourceService.findResourceCompositesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
/** Locate ProblemResourcesComposites and generate the disambiguation reports for them.
* Criteria passed in not currently used.
*/
- public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems) {
+ public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems)
+ throws RuntimeException {
try {
List<ProblemResourceComposite> located = new ArrayList<ProblemResourceComposite>();
MeasurementProblemManagerLocal problemManager = LookupUtil.getMeasurementProblemManager();
@@ -163,38 +171,33 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
List<DisambiguationReport<ProblemResourceComposite>> translated = resourceManager.disambiguate(located,
RESOURCE_ID_EXTRACTOR, DefaultDisambiguationUpdateStrategies.getDefault());
return translated;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- private static final IntExtractor<ProblemResourceComposite> RESOURCE_ID_EXTRACTOR = new IntExtractor<ProblemResourceComposite>() {
- public int extract(ProblemResourceComposite object) {
- return object.getResourceId();
- }
- };
-
- public List<ResourceLineageComposite> getResourceLineageAndSiblings(int resourceId) {
+ public List<ResourceLineageComposite> getResourceLineageAndSiblings(int resourceId) throws RuntimeException {
try {
return SerialUtility.prepare(
resourceManager.getResourceLineageAndSiblings(getSessionSubject(), resourceId),
"ResourceService.getResourceLineageAndSiblings");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Resource getPlatformForResource(int resourceId) {
+ public Resource getPlatformForResource(int resourceId) throws RuntimeException {
try {
return SerialUtility.prepare(resourceManager.getRootResourceForResource(resourceId),
"ResourceService.getPlatformForResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems) {
+ public List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems)
+ throws RuntimeException {
try {
List<RecentlyAddedResourceComposite> platforms = resourceManager.findRecentlyAddedPlatforms(
getSessionSubject(), ctime, maxItems);
@@ -206,32 +209,31 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
}
return SerialUtility.prepare(platforms, "ResourceService.findRecentlyAddedResources");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<Integer> uninventoryResources(int[] resourceIds) {
+ public List<Integer> uninventoryResources(int[] resourceIds) throws RuntimeException {
try {
return SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(), resourceIds),
"ResourceService.uninventoryResources");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateResource(Resource resource) {
+ public void updateResource(Resource resource) throws RuntimeException {
try {
resourceManager.updateResource(getSessionSubject(), resource);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public void createResource(int parentResourceId, int newResourceTypeId, String newResourceName,
- Configuration newResourceConfiguration) {
+ Configuration newResourceConfiguration) throws RuntimeException {
try {
-
ConfigurationDefinition pluginConfigDefinition = LookupUtil.getConfigurationManager()
.getPluginConfigurationDefinitionForResourceType(getSessionSubject(), newResourceTypeId);
Configuration pluginConfig = null;
@@ -246,15 +248,14 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
resourceFactoryManager.createResource(getSessionSubject(), parentResourceId, newResourceTypeId,
newResourceName, pluginConfig, newResourceConfiguration);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
public void createResource(int parentResourceId, int newResourceTypeId, String newResourceName,
- Configuration deploymentTimeConfiguration, int packageVersionId) {
+ Configuration deploymentTimeConfiguration, int packageVersionId) throws RuntimeException {
try {
-
ConfigurationDefinition pluginConfigDefinition = LookupUtil.getConfigurationManager()
.getPluginConfigurationDefinitionForResourceType(getSessionSubject(), newResourceTypeId);
Configuration pluginConfig = null;
@@ -269,65 +270,71 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
resourceFactoryManager.createPackageBackedResourceViaPackageVersion(getSessionSubject(), parentResourceId,
newResourceTypeId, newResourceName, pluginConfig, deploymentTimeConfiguration, packageVersionId);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<DeleteResourceHistory> deleteResources(int[] resourceIds) {
+ public List<DeleteResourceHistory> deleteResources(int[] resourceIds) throws RuntimeException {
try {
return SerialUtility.prepare(resourceFactoryManager.deleteResources(getSessionSubject(), resourceIds),
"ResourceService.deleteResources");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Map<Resource, List<Resource>> getQueuedPlatformsAndServers(HashSet<InventoryStatus> statuses, PageControl pc) {
+ public Map<Resource, List<Resource>> getQueuedPlatformsAndServers(HashSet<InventoryStatus> statuses, PageControl pc)
+ throws RuntimeException {
try {
return SerialUtility.prepare(discoveryBoss.getQueuedPlatformsAndServers(getSessionSubject(), EnumSet
.copyOf(statuses), pc), "ResourceService.getQueuedPlatformsAndServers");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void importResources(int[] resourceIds) {
+ public void importResources(int[] resourceIds) throws RuntimeException {
try {
discoveryBoss.importResources(getSessionSubject(), resourceIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void ignoreResources(int[] resourceIds) {
+ public void ignoreResources(int[] resourceIds) throws RuntimeException {
try {
discoveryBoss.ignoreResources(getSessionSubject(), resourceIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void unignoreResources(int[] resourceIds) {
+ public void unignoreResources(int[] resourceIds) throws RuntimeException {
try {
discoveryBoss.unignoreResources(getSessionSubject(), resourceIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<ResourceError> findResourceErrors(int resourceId) {
- return SerialUtility.prepare(resourceManager.findResourceErrors(getSessionSubject(), resourceId),
- "ResourceService.getResourceErrors");
+ public List<ResourceError> findResourceErrors(int resourceId) throws RuntimeException {
+ try {
+ return SerialUtility.prepare(resourceManager.findResourceErrors(getSessionSubject(), resourceId),
+ "ResourceService.getResourceErrors");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
- public Resource manuallyAddResource(int resourceTypeId, int parentResourceId, Configuration pluginConfiguration) {
+ public Resource manuallyAddResource(int resourceTypeId, int parentResourceId, Configuration pluginConfiguration)
+ throws RuntimeException {
try {
Resource result = discoveryBoss.manuallyAddResource(getSessionSubject(), resourceTypeId, parentResourceId,
pluginConfiguration);
return SerialUtility.prepare(result, "ResourceService.manuallyAddResource");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
index 2ef7eec..6963b8c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
@@ -42,7 +42,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
private ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
private GroupDefinitionManagerLocal definitionManager = LookupUtil.getGroupDefinitionManager();
- public PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria) {
+ public PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria) throws RuntimeException {
try {
PageList<ResourceGroup> groups = groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(groups, "ResourceGroupService.findResourceGroupsByCriteria");
@@ -51,7 +51,8 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria) {
+ public PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria)
+ throws RuntimeException {
try {
PageList<ResourceGroupComposite> composites = groupManager.findResourceGroupCompositesByCriteria(
getSessionSubject(), criteria);
@@ -61,7 +62,8 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria) {
+ public PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria)
+ throws RuntimeException {
try {
PageList<GroupDefinition> definitions = definitionManager.findGroupDefinitionsByCriteria(
getSessionSubject(), criteria);
@@ -71,7 +73,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void setAssignedResources(int groupId, int[] resourceIds, boolean setType) {
+ public void setAssignedResources(int groupId, int[] resourceIds, boolean setType) throws RuntimeException {
try {
groupManager.setAssignedResources(getSessionSubject(), groupId, resourceIds, setType);
} catch (Throwable t) {
@@ -79,7 +81,8 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void setAssignedResourceGroupsForResource(int resourceId, int[] resourceGroupIds, boolean setType) {
+ public void setAssignedResourceGroupsForResource(int resourceId, int[] resourceGroupIds, boolean setType)
+ throws RuntimeException {
try {
groupManager.setAssignedResourceGroupsForResource(getSessionSubject(), resourceId, resourceGroupIds,
setType);
@@ -88,7 +91,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public ResourceGroup createPrivateResourceGroup(ResourceGroup group, int[] resourceIds) {
+ public ResourceGroup createPrivateResourceGroup(ResourceGroup group, int[] resourceIds) throws RuntimeException {
try {
Subject user = getSessionSubject();
group = groupManager.createPrivateResourceGroup(user, group);
@@ -99,7 +102,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds) {
+ public ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds) throws RuntimeException {
try {
Subject user = getSessionSubject();
group = groupManager.createResourceGroup(user, group);
@@ -110,7 +113,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void deleteResourceGroups(int[] groupIds) {
+ public void deleteResourceGroups(int[] groupIds) throws RuntimeException {
try {
groupManager.deleteResourceGroups(getSessionSubject(), groupIds);
} catch (Throwable t) {
@@ -118,7 +121,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void updateResourceGroup(ResourceGroup group) {
+ public void updateResourceGroup(ResourceGroup group) throws RuntimeException {
try {
groupManager.updateResourceGroup(getSessionSubject(), group);
} catch (Throwable t) {
@@ -126,7 +129,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void updateResourceGroup(ResourceGroup group, boolean updateMembership) {
+ public void updateResourceGroup(ResourceGroup group, boolean updateMembership) throws RuntimeException {
try {
groupManager.updateResourceGroup(getSessionSubject(), group, null, updateMembership);
} catch (Throwable t) {
@@ -134,7 +137,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public GroupDefinition createGroupDefinition(GroupDefinition groupDefinition) {
+ public GroupDefinition createGroupDefinition(GroupDefinition groupDefinition) throws RuntimeException {
try {
GroupDefinition results = definitionManager.createGroupDefinition(getSessionSubject(), groupDefinition);
@@ -144,7 +147,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void updateGroupDefinition(GroupDefinition groupDefinition) {
+ public void updateGroupDefinition(GroupDefinition groupDefinition) throws RuntimeException {
try {
definitionManager.updateGroupDefinition(getSessionSubject(), groupDefinition);
} catch (Throwable t) {
@@ -152,7 +155,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void recalculateGroupDefinitions(int[] groupDefinitionIds) {
+ public void recalculateGroupDefinitions(int[] groupDefinitionIds) throws RuntimeException {
try {
for (int nextGroupDefinitionId : groupDefinitionIds) {
definitionManager.calculateGroupMembership(getSessionSubject(), nextGroupDefinitionId);
@@ -162,7 +165,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void deleteGroupDefinitions(int[] groupDefinitionIds) {
+ public void deleteGroupDefinitions(int[] groupDefinitionIds) throws RuntimeException {
try {
for (int nextGroupDefinitionId : groupDefinitionIds) {
definitionManager.removeGroupDefinition(getSessionSubject(), nextGroupDefinitionId);
@@ -173,7 +176,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
@Override
- public void setRecursive(int groupId, boolean isRecursive) throws Exception {
+ public void setRecursive(int groupId, boolean isRecursive) throws RuntimeException {
try {
groupManager.setRecursive(getSessionSubject(), groupId, isRecursive);
} catch (Throwable t) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
index 5cffd24..223a23e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
@@ -22,14 +22,14 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
private static final long serialVersionUID = 1L;
@Override
- public PageList<ResourceType> findResourceTypesByCriteria(ResourceTypeCriteria criteria) {
+ public PageList<ResourceType> findResourceTypesByCriteria(ResourceTypeCriteria criteria) throws RuntimeException {
try {
ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
return SerialUtility.prepare(typeManager.findResourceTypesByCriteria(getSessionSubject(), criteria),
"ResourceTypes.findResourceTypesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@@ -37,7 +37,7 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
* Given a resource ID, this gets all resource types for all ancestors in that resource's lineage.
*/
@Override
- public ArrayList<ResourceType> getResourceTypesForResourceAncestors(int resourceId) {
+ public ArrayList<ResourceType> getResourceTypesForResourceAncestors(int resourceId) throws RuntimeException {
try {
ResourceManagerLocal manager = LookupUtil.getResourceManager();
List<ResourceLineageComposite> lineage = manager.getResourceLineage(getSessionSubject(), resourceId);
@@ -46,43 +46,44 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
types.add(composite.getResource().getResourceType());
}
return SerialUtility.prepare(types, "ResourceTypes.getResourceTypesForResourceAncestors");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public ArrayList<ResourceType> getAllResourceTypeAncestors(int resourceTypeId) {
+ public ArrayList<ResourceType> getAllResourceTypeAncestors(int resourceTypeId) throws RuntimeException {
try {
ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
List<ResourceType> list = typeManager.getAllResourceTypeAncestors(getSessionSubject(), resourceTypeId);
return SerialUtility
.prepare(new ArrayList<ResourceType>(list), "ResourceTypes.getAllResourceTypeAncestors");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public HashMap<Integer, String> getResourceTypeDescendantsWithOperations(int resourceTypeId) {
+ public HashMap<Integer, String> getResourceTypeDescendantsWithOperations(int resourceTypeId)
+ throws RuntimeException {
try {
ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
HashMap<Integer, String> map = typeManager.getResourceTypeDescendantsWithOperations(getSessionSubject(),
resourceTypeId);
return SerialUtility.prepare(map, "ResourceTypes.getResourceTypeDescendantsWithOperations");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
@Override
- public Map<Integer, ResourceTypeTemplateCountComposite> getTemplateCountCompositeMap() {
+ public Map<Integer, ResourceTypeTemplateCountComposite> getTemplateCountCompositeMap() throws RuntimeException {
try {
ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
Map<Integer, ResourceTypeTemplateCountComposite> map = typeManager.getTemplateCountCompositeMap();
return SerialUtility.prepare(map, "ResourceTypes.getTemplateCountCompositeMap");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
index 2f1dcbc..73659e0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
@@ -36,60 +36,60 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
private RoleManagerLocal roleManager = LookupUtil.getRoleManager();
- public PageList<Role> findRolesByCriteria(RoleCriteria criteria) {
+ public PageList<Role> findRolesByCriteria(RoleCriteria criteria) throws RuntimeException {
try {
return SerialUtility.prepare(roleManager.findRolesByCriteria(getSessionSubject(), criteria),
"RoleService.findRolesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Role createRole(Role role) {
+ public Role createRole(Role role) throws RuntimeException {
try {
return SerialUtility.prepare(roleManager.createRole(getSessionSubject(), role), "RoleService.createRole");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Role updateRole(Role role) {
+ public Role updateRole(Role role) throws RuntimeException {
try {
return SerialUtility.prepare(roleManager.updateRole(getSessionSubject(), role), "RoleService.updateRole");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void removeRoles(int[] roleIds) {
+ public void removeRoles(int[] roleIds) throws RuntimeException {
try {
roleManager.deleteRoles(getSessionSubject(), roleIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void setAssignedResourceGroups(int roleId, int[] resourceGroupIds) {
+ public void setAssignedResourceGroups(int roleId, int[] resourceGroupIds) throws RuntimeException {
try {
roleManager.setAssignedResourceGroups(getSessionSubject(), roleId, resourceGroupIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void setAssignedSubjects(int roleId, int[] subjectIds) {
+ public void setAssignedSubjects(int roleId, int[] subjectIds) throws RuntimeException {
try {
roleManager.setAssignedSubjects(getSessionSubject(), roleId, subjectIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void setAssignedRolesForSubject(int subjectId, int[] roleIds) {
+ public void setAssignedRolesForSubject(int subjectId, int[] roleIds) throws RuntimeException {
try {
roleManager.setAssignedSubjectRoles(getSessionSubject(), subjectId, roleIds);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
index ae72b4c..c80728e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
@@ -41,56 +41,57 @@ public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements Sear
private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
public List<SearchSuggestion> getTabAwareSuggestions(SearchSubsystem searchSubsystem, String expression,
- int caretPosition, String tab) {
+ int caretPosition, String tab) throws RuntimeException {
try {
SearchAssistManager searchAssistManager = new SearchAssistManager(getSessionSubject(), searchSubsystem);
List<SearchSuggestion> results = searchAssistManager.getTabAwareSuggestions(expression, caretPosition, tab);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<SearchSuggestion> getSuggestions(SearchSubsystem searchSubsystem, String expression, int caretPosition) {
+ public List<SearchSuggestion> getSuggestions(SearchSubsystem searchSubsystem, String expression, int caretPosition)
+ throws RuntimeException {
try {
SearchAssistManager searchAssistManager = new SearchAssistManager(getSessionSubject(), searchSubsystem);
List<SearchSuggestion> results = searchAssistManager.getSuggestions(expression, caretPosition);
return results;
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public int createSavedSearch(SavedSearch savedSearch) {
+ public int createSavedSearch(SavedSearch savedSearch) throws RuntimeException {
try {
return savedSearchManager.createSavedSearch(getSessionSubject(), savedSearch);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateSavedSearch(SavedSearch savedSearch) {
+ public void updateSavedSearch(SavedSearch savedSearch) throws RuntimeException {
try {
savedSearchManager.updateSavedSearch(getSessionSubject(), savedSearch);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteSavedSearch(int savedSearchId) {
+ public void deleteSavedSearch(int savedSearchId) throws RuntimeException {
try {
savedSearchManager.deleteSavedSearch(getSessionSubject(), savedSearchId);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public List<SavedSearch> findSavedSearchesByCriteria(SavedSearchCriteria criteria) {
+ public List<SavedSearch> findSavedSearchesByCriteria(SavedSearchCriteria criteria) throws RuntimeException {
try {
return SerialUtility.prepare(savedSearchManager.findSavedSearchesByCriteria(getSessionSubject(), criteria),
"SearchService.findRolesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
index d9b50fd..df34cab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
@@ -18,8 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.util.PageList;
@@ -37,85 +35,77 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
private static final long serialVersionUID = 1L;
- private final Log log = LogFactory.getLog(this.getClass());
-
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
- public void createPrincipal(String username, String password) {
+ public void createPrincipal(String username, String password) throws RuntimeException {
try {
subjectManager.createPrincipal(getSessionSubject(), username, password);
- } catch (RuntimeException e) {
- handleException(e);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Subject createSubject(Subject subjectToCreate) {
+ public Subject createSubject(Subject subjectToCreate) throws RuntimeException {
try {
return SerialUtility.prepare(subjectManager.createSubject(getSessionSubject(), subjectToCreate),
"SubjectManager.createSubject");
- } catch (RuntimeException e) {
- handleException(e);
- return null;
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Subject createSubject(Subject subjectToCreate, String password) throws Exception {
+ public Subject createSubject(Subject subjectToCreate, String password) throws RuntimeException {
try {
return SerialUtility.prepare(subjectManager.createSubject(getSessionSubject(), subjectToCreate, password),
"SubjectManager.createSubject");
- } catch (RuntimeException e) {
- throw new Exception(e);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void deleteSubjects(int[] subjectIds) {
+ public void deleteSubjects(int[] subjectIds) throws RuntimeException {
try {
subjectManager.deleteSubjects(getSessionSubject(), subjectIds);
- } catch (RuntimeException e) {
- handleException(e);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Subject login(String username, String password) {
+ public Subject login(String username, String password) throws RuntimeException {
try {
return SerialUtility.prepare(subjectManager.login(username, password), "SubjectManager.login");
- } catch (LoginException e) {
- throw new RuntimeException("LoginException: " + e.getMessage());
- } catch (RuntimeException e) {
- handleException(e);
- return null;
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void logout(Subject subject) {
+ public void logout(Subject subject) throws RuntimeException {
try {
subjectManager.logout(subject.getSessionId());
- } catch (RuntimeException e) {
- handleException(e);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Subject updateSubject(Subject subjectToModify) {
+ public Subject updateSubject(Subject subjectToModify) throws RuntimeException {
try {
return SerialUtility.prepare(subjectManager.updateSubject(getSessionSubject(), subjectToModify),
"SubjectManager.updateSubject");
- } catch (RuntimeException e) {
- handleException(e);
- return null;
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Subject updateSubject(Subject subjectToModify, String newPassword) {
+ public Subject updateSubject(Subject subjectToModify, String newPassword) throws RuntimeException {
try {
- return SerialUtility.prepare(subjectManager.updateSubject(getSessionSubject(), subjectToModify, newPassword),
- "SubjectManager.updateSubject");
- } catch (RuntimeException e) {
- handleException(e);
- return null;
+ return SerialUtility.prepare(subjectManager
+ .updateSubject(getSessionSubject(), subjectToModify, newPassword), "SubjectManager.updateSubject");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Subject processSubjectForLdap(Subject subjectToModify, String password) {
+ public Subject processSubjectForLdap(Subject subjectToModify, String password) throws RuntimeException {
//no permissions check as embedded in the SLSB call.
try {
Subject processedSubject = subjectManager.processSubjectForLdap(subjectToModify, password);
@@ -146,28 +136,25 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
} catch (LoginException e) {
throw new RuntimeException("LoginException: " + e.getMessage());
} catch (RuntimeException e) {
- handleException(e);
- return null;
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
- public PageList<Subject> findSubjectsByCriteria(SubjectCriteria criteria) {
+ public PageList<Subject> findSubjectsByCriteria(SubjectCriteria criteria) throws RuntimeException {
try {
return SerialUtility.prepare(subjectManager.findSubjectsByCriteria(getSessionSubject(), criteria),
"SubjectManager.findSubjectsByCriteria");
- } catch (RuntimeException e) {
- handleException(e);
- return null;
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
-
- public boolean isUserWithPrincipal(String username) {
- return subjectManager.isUserWithPrincipal(username);
- }
- private void handleException(Exception e) {
- log.error("Unexpected error.", e);
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ public boolean isUserWithPrincipal(String username) throws RuntimeException {
+ try {
+ return subjectManager.isUserWithPrincipal(username);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
-
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
index 43431c7..eb1f3c9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
@@ -33,11 +33,11 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
- public ProductInfo getProductInfo() {
+ public ProductInfo getProductInfo() throws RuntimeException {
try {
return this.systemManager.getProductInfo(getSessionSubject());
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
index 7ab6941..2f28bbf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
@@ -43,86 +43,87 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
private TagManagerLocal tagManager = LookupUtil.getTagManager();
- public PageList<Tag> findTagsByCriteria(TagCriteria tagCriteria) {
+ public PageList<Tag> findTagsByCriteria(TagCriteria tagCriteria) throws RuntimeException {
try {
return SerialUtility.prepare(tagManager.findTagsByCriteria(getSessionSubject(), tagCriteria),
"TagService.findTagsByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public Set<Tag> addTags(Set<Tag> tags) {
+ public Set<Tag> addTags(Set<Tag> tags) throws RuntimeException {
try {
return SerialUtility.prepare(tagManager.addTags(getSessionSubject(), tags), "TagService.addTags");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void removeTags(Set<Tag> tags) {
+ public void removeTags(Set<Tag> tags) throws RuntimeException {
try {
tagManager.removeTags(getSessionSubject(), tags);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateResourceTags(int resourceId, Set<Tag> tags) {
+ public void updateResourceTags(int resourceId, Set<Tag> tags) throws RuntimeException {
try {
tagManager.updateResourceTags(getSessionSubject(), resourceId, tags);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateResourceGroupTags(int resourceGroupId, Set<Tag> tags) {
+ public void updateResourceGroupTags(int resourceGroupId, Set<Tag> tags) throws RuntimeException {
try {
tagManager.updateResourceGroupTags(getSessionSubject(), resourceGroupId, tags);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateBundleTags(int bundleId, Set<Tag> tags) {
+ public void updateBundleTags(int bundleId, Set<Tag> tags) throws RuntimeException {
try {
tagManager.updateBundleTags(getSessionSubject(), bundleId, tags);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateBundleVersionTags(int bundleVersionId, Set<Tag> tags) {
+ public void updateBundleVersionTags(int bundleVersionId, Set<Tag> tags) throws RuntimeException {
try {
tagManager.updateBundleVersionTags(getSessionSubject(), bundleVersionId, tags);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateBundleDeploymentTags(int bundleDeploymentId, Set<Tag> tags) {
+ public void updateBundleDeploymentTags(int bundleDeploymentId, Set<Tag> tags) throws RuntimeException {
try {
tagManager.updateBundleDeploymentTags(getSessionSubject(), bundleDeploymentId, tags);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public void updateBundleDestinationTags(int bundleDestinationId, Set<Tag> tags) {
+ public void updateBundleDestinationTags(int bundleDestinationId, Set<Tag> tags) throws RuntimeException {
try {
tagManager.updateBundleDestinationTags(getSessionSubject(), bundleDestinationId, tags);
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
- public PageList<TagReportComposite> findTagReportCompositesByCriteria(TagCriteria tagCriteria) {
+ public PageList<TagReportComposite> findTagReportCompositesByCriteria(TagCriteria tagCriteria)
+ throws RuntimeException {
try {
return SerialUtility.prepare(
tagManager.findTagReportCompositesByCriteria(getSessionSubject(), tagCriteria),
"TagService.findTagReportCompositesByCriteria");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
}
}
13 years, 4 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 29 +++++-----
1 file changed, 16 insertions(+), 13 deletions(-)
New commits:
commit 8c639f21851747d2b128e80682419101c5e640e7
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Dec 21 14:47:50 2010 -0500
remove assumptions about fetch return order, which is not guaranteed by a
db impl. hopefully got them all...
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index 932e617..d4963a2 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -535,6 +535,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assertNotNull(b1);
BundleCriteria criteria = new BundleCriteria();
+ criteria.addSortName(PageOrdering.ASC);
PageList<BundleWithLatestVersionComposite> results;
// verify there are no bundle versions yet
@@ -922,33 +923,35 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
BundleVersion bv3 = createBundleVersion(b1.getName(), "2.1", b1);
BundleVersionCriteria c = new BundleVersionCriteria();
PageList<BundleVersion> bvs = null;
- BundleVersion bv = null;
+ BundleVersion bvOut = null;
// return all with no optional data
c.addFilterName(TEST_PREFIX);
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
- bv = bvs.get(1);
- EntityManager em = getEntityManager();
- bv = em.merge(bv);
assertNotNull(bvs);
assertEquals(3, bvs.size());
- assertEquals(bv2, bv);
+ assertFalse(bvs.get(0).equals(bvs.get(1)));
+ assertFalse(bvs.get(0).equals(bvs.get(2)));
+ assertFalse(bvs.get(1).equals(bvs.get(2)));
+ assertTrue(bvs.get(0).equals(bvs.get(0)));
+ assertTrue(bvs.get(0).equals(bv2) || bvs.get(1).equals(bv2) || bvs.get(2).equals(bv2));
// return bundle version using all criteria and with all optional data
- c.addFilterId(bv.getId());
- c.addFilterName(bv.getName());
+ BundleVersion bvIn = bvs.get(1);
+ c.addFilterId(bvIn.getId());
+ c.addFilterName(bvIn.getName());
c.addFilterBundleName("one");
- c.addFilterVersion(bv.getVersion());
+ c.addFilterVersion(bvIn.getVersion());
c.fetchBundle(true);
c.fetchBundleDeployments(true);
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
assertNotNull(bvs);
assertEquals(1, bvs.size());
- bv = bvs.get(0);
- assertEquals(bv2, bv);
- assertEquals(bv.getBundle(), b1);
- assertNotNull(bv.getBundleDeployments());
- assertTrue(bv.getBundleDeployments().isEmpty());
+ bvOut = bvs.get(0);
+ assertEquals(bvIn, bvOut);
+ assertEquals(bvOut.getBundle(), b1);
+ assertNotNull(bvOut.getBundleDeployments());
+ assertTrue(bvOut.getBundleDeployments().isEmpty());
}
@Test(enabled = DISABLED)
13 years, 4 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit d861e2386d02b68b19b640ff535c6b7268f9ad31
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Dec 21 13:43:18 2010 -0500
Not sure what changed to make "Logout" start hanging off the right side,
but instead of trying to force min size, now provide ample space.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index 77d24fd..a4a1e40 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -161,7 +161,7 @@ public class MenuBarView extends LocatableVLayout {
lineLabel.setAlign(Alignment.CENTER);
Hyperlink logoutLink = SeleniumUtility.setHtmlId(new Hyperlink(MSG.view_menuBar_logout(), "LogOut"));
- logoutLink.setWidth("1px");
+ logoutLink.setWidth("50px");
layout.addMember(userLabel);
layout.addMember(lineLabel);
13 years, 4 months
[rhq] modules/core
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java | 5 +-
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java | 21 +++++-----
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java | 18 +++++++-
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java | 12 +++++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java | 3 -
5 files changed, 46 insertions(+), 13 deletions(-)
New commits:
commit a1d95800d25edf92c3a9f96e3f27a133f93ad1b4
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Dec 21 11:43:48 2010 -0500
Some tweaks to Bundle Domain objects.
- add some missing null protection in toString()
- remove ctime from BundleDeployment hashCode as it's not part of the
natural key and could cause issues due to the way its initialized at
construction-time.
- for relevant entities add some jdoc for hashcode/equals impls noting
the use of lazy loaded fields in the natural key. This should not be a
problem for real-work scenarios but is a subtlety that may need to be
made clear, especially for test code.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
index 6dd4a02..9bf477f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
@@ -217,7 +217,10 @@ public class Bundle implements Serializable {
@Override
public String toString() {
- return "Bundle[id=" + id + ",name=" + name + ",bundleType=" + bundleType + ",packageType=" + packageType + "]";
+ return "Bundle[id=" + id //
+ + ",name=" + name //
+ + ",bundleType=" + bundleType //
+ + ",packageType=" + packageType + "]";
}
@Override
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
index c2a062b..fc0c72c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -360,6 +360,12 @@ public class BundleDeployment implements Serializable {
return "BundleDeployment[id=" + id + ", name=" + name + "]";
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
final int prime = 31;
@@ -367,10 +373,15 @@ public class BundleDeployment implements Serializable {
result = prime * result + ((this.bundleVersion == null) ? 0 : this.bundleVersion.hashCode());
result = prime * result + ((this.destination == null) ? 0 : this.destination.hashCode());
result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
- result = prime * result + ((this.ctime == null) ? 0 : this.ctime.hashCode());
return result;
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -406,14 +417,6 @@ public class BundleDeployment implements Serializable {
return false;
}
- if (this.ctime == null) {
- if (other.ctime != null) {
- return false;
- }
- } else if (!this.ctime.equals(other.ctime)) {
- return false;
- }
-
return true;
}
}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java
index 5c37ebf..dc730c7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java
@@ -224,10 +224,18 @@ public class BundleDestination implements Serializable {
@Override
public String toString() {
- return "BundleDestination[id=" + id + ", bundle=" + bundle.getName() + ", group=" + group.getName() + ", name="
- + name + "]";
+ return "BundleDestination[id=" + id //
+ + ((null != bundle) ? (", bundle=" + bundle.getName()) : "") //
+ + ((null != group) ? (", group=" + group.getName()) : "") //
+ + ", name=" + name + "]";
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
final int prime = 31;
@@ -238,6 +246,12 @@ public class BundleDestination implements Serializable {
return result;
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
index 1bc3c25..7cd7b50 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
@@ -172,6 +172,12 @@ public class BundleResourceDeployment implements Serializable {
return str.toString();
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
int result = 1;
@@ -180,6 +186,12 @@ public class BundleResourceDeployment implements Serializable {
return result;
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index 0afdb13..cfbb9d7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -261,7 +261,8 @@ public class BundleVersion implements Serializable {
@Override
public String toString() {
- return "BundleVersion[id=" + id + ",name=" + name + ",version=" + version + ",bundle=" + bundle.getName() + "]";
+ return "BundleVersion[id=" + id + ",name=" + name + ",version=" + version
+ + ((null != bundle) ? (",bundle=" + bundle.getName()) : "") + "]";
}
@Override
13 years, 4 months
[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 30 +---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java | 2
2 files changed, 4 insertions(+), 28 deletions(-)
New commits:
commit 2c3e0d126fd58d775bdce779e86ffcd2387014d0
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Dec 21 09:00:13 2010 -0500
i)fix copy paste error in ImgManager ii)removed redundant method for configIcon status
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index 7b79f88..437cb54 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -352,44 +352,20 @@ public class ImageManager {
return "subsystems/configure/Configure_failed_16.png";
}
case INPROGRESS: {
- return "subsystems/inventory/Configure_inprogress_16.png";
+ return "subsystems/configure/Configure_inprogress_16.png";
}
case NOCHANGE:
- return "subsystems/inventory/Configure_16.png";
+ return "subsystems/configure/Configure_16.png";
}
}
- return "subsystems/inventory/Configure_16.png";
+ return "subsystems/configure/Configure_16.png";
}
public static String getLockedIcon() {
return "global/Locked_16.png";
}
- /**
- * Returns the configuration update status icon. If status is null, returns
- * the plain, unbadged, configuration icon.
- */
- public static String getConfigurationUpdateResultsIcon(ConfigurationUpdateStatus status) {
- String icon = "";
- if (status != null) {
- switch (status) {
- case INPROGRESS:
- icon = "_inprogress";
- break;
- case SUCCESS:
- icon = "_ok";
- break;
- case FAILURE:
- icon = "_failed";
- break;
- }
- }
-
- return "subsystems/configure/Configure" + icon + "_16.png";
-
- }
-
public static String getEventSeverityIcon(EventSeverity severity) {
String icon = "";
if (severity != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 8907f16..15969bb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -364,7 +364,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
StaticTextItem iconItem = new StaticTextItem();
FormItemIcon img = new FormItemIcon();
- img.setSrc(ImageManager.getConfigurationUpdateResultsIcon(update.getStatus()));
+ img.setSrc(ImageManager.getResourceConfigurationIcon(update.getStatus()));
img.setWidth(16);
img.setHeight(16);
iconItem.setIcons(img);
13 years, 4 months
[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 50
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java | 618 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java | 99 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java | 9
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 13
7 files changed, 810 insertions(+), 2 deletions(-)
New commits:
commit c68e0e42d9b2bdb075372e87e1b62f5e1fbcc000
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Dec 20 21:04:46 2010 -0500
initial commit of resource/activity. There are several jsf pieces that are non-trivial to replace.
Will keep both iframe and gwt versions until more functionality can be moved.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index 576af53..7b79f88 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -2,6 +2,7 @@ package org.rhq.enterprise.gui.coregui.client;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.ResourceAvailability;
import org.rhq.core.domain.operation.OperationRequestStatus;
@@ -364,4 +365,53 @@ public class ImageManager {
public static String getLockedIcon() {
return "global/Locked_16.png";
}
+
+ /**
+ * Returns the configuration update status icon. If status is null, returns
+ * the plain, unbadged, configuration icon.
+ */
+ public static String getConfigurationUpdateResultsIcon(ConfigurationUpdateStatus status) {
+ String icon = "";
+ if (status != null) {
+ switch (status) {
+ case INPROGRESS:
+ icon = "_inprogress";
+ break;
+ case SUCCESS:
+ icon = "_ok";
+ break;
+ case FAILURE:
+ icon = "_failed";
+ break;
+ }
+ }
+
+ return "subsystems/configure/Configure" + icon + "_16.png";
+
+ }
+
+ public static String getEventSeverityIcon(EventSeverity severity) {
+ String icon = "";
+ if (severity != null) {
+ switch (severity) {
+ case DEBUG:
+ icon = "_debug";
+ break;
+ case INFO:
+ icon = "_info";
+ break;
+ case WARN:
+ icon = "_warning";
+ break;
+ case ERROR:
+ icon = "_info";
+ break;
+ case FATAL:
+ icon = "_fatal";
+ break;
+ }
+ }
+
+ return "subsystems/event/Events" + icon + "_16.png";
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index ffc4ca5..0c61ed0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -63,6 +63,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitorin
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView2;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -92,6 +93,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private TwoLevelTab contentTab;
private SubTab summaryActivity;
+ private SubTab summaryActivity2;
private SubTab summaryTimeline;
private SubTab monitorGraphs;
private SubTab monitorTables;
@@ -129,9 +131,12 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
.view_tabs_common_summary()), ImageManager.getResourceIcon(ResourceCategory.SERVICE, Boolean.TRUE));
summaryActivity = new SubTab(summaryTab.extendLocatorId("Activity"), new ViewName("Activity", MSG
.view_tabs_common_activity()), null);
+ summaryActivity2 = new SubTab(summaryTab.extendLocatorId("Activity2"), new ViewName("Activity2", MSG
+ .view_tabs_common_activity() + 2), null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), new ViewName("Timeline", MSG
.view_tabs_common_timeline()), null);
- summaryTab.registerSubTabs(summaryActivity, summaryTimeline);
+ // summaryTab.registerSubTabs(summaryActivity, summaryTimeline);
+ summaryTab.registerSubTabs(summaryActivity, summaryActivity2, summaryTimeline);
tabs.add(summaryTab);
inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), new ViewName("Inventory", MSG
@@ -255,6 +260,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private void updateSummaryTabContent(Resource resource) {
updateSubTab(this.summaryTab, this.summaryActivity, new ActivityView(this.summaryActivity
.extendLocatorId("View"), this.resourceComposite), true, true);
+ updateSubTab(this.summaryTab, this.summaryActivity2, new ActivityView2(this.summaryActivity2
+ .extendLocatorId("View"), this.resourceComposite), true, true);
updateSubTab(this.summaryTab, this.summaryTimeline, new FullHTMLPane(this.summaryTimeline
.extendLocatorId("View"), "/rhq/resource/summary/timeline-plain.xhtml?id=" + resource.getId()), true, true);
@@ -347,7 +354,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.operationsTab, this.operationsHistory, new ResourceOperationHistoryListView(operationsTab
.extendLocatorId("HistoryView"), this.resourceComposite), true, true);
- updateSubTab(this.operationsTab, this.operationsSchedule,new ResourceOperationScheduleListView(
+ updateSubTab(this.operationsTab, this.operationsSchedule, new ResourceOperationScheduleListView(
operationsTab.extendLocatorId("SchedulesView"), this.resourceComposite), true, true);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
new file mode 100644
index 0000000..8907f16
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -0,0 +1,618 @@
+/*
+ * 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.inventory.resource.detail.summary;
+
+import java.util.Date;
+import java.util.List;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.form.fields.FormItemIcon;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+
+import org.rhq.core.domain.alert.Alert;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.criteria.EventCriteria;
+import org.rhq.core.domain.criteria.InstalledPackageCriteria;
+import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
+import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.RefreshableView;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
+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.LocatableVLayout;
+
+/**
+ * The content pane of the Resource Summary>Activity tab.
+ *
+ * @author Simeon Pinder
+ */
+public class ActivityView2 extends LocatableHLayout implements RefreshableView {
+ private LocatableVLayout leftPane;
+ private LocatableVLayout rightPane;
+ private LocatableCanvas recentMeasurementsContent = new LocatableCanvas(extendLocatorId("RecentMetricsContent"));
+ private LocatableCanvas recentAlertsContent = new LocatableCanvas(extendLocatorId("RecentAlertsContent"));
+ private LocatableCanvas recentOobContent = new LocatableCanvas(extendLocatorId("RecentOobsContent"));
+ private LocatableCanvas recentConfigurationContent = new LocatableCanvas(extendLocatorId("RecentConfigContent"));
+ private LocatableCanvas recentOperationsContent = new LocatableCanvas(extendLocatorId("RecentOperationsContent"));
+ private LocatableCanvas recentEventsContent = new LocatableCanvas(extendLocatorId("RecentEventsContent"));
+ private LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(extendLocatorId("RecentPkgHistoryContent"));
+ private String RECENT_MEASUREMENTS = MSG.common_title_recent_measurements();
+ private String RECENT_MEASUREMENTS_NONE = MSG.view_resource_inventory_activity_no_recent_metrics();
+ private String RECENT_ALERTS = MSG.common_title_recent_alerts();
+ private String RECENT_ALERTS_NONE = MSG.view_resource_inventory_activity_no_recent_alerts();
+ private String RECENT_OOB = MSG.common_title_recent_oob_metrics();
+ private String RECENT_OOB_NONE = MSG.view_resource_inventory_activity_no_recent_oob();
+ private String RECENT_CONFIGURATIONS = MSG.common_title_recent_configuration_updates();
+ private String RECENT_CONFIGURATIONS_NONE = MSG.view_resource_inventory_activity_no_recent_config_history();
+ private String RECENT_OPERATIONS = MSG.common_title_recent_operations();
+ private String RECENT_OPERATIONS_NONE = MSG.view_resource_inventory_activity_no_recent_operations();
+ private String RECENT_EVENTS = MSG.common_title_recent_event_counts();
+ private String RECENT_EVENTS_NONE = MSG.view_resource_inventory_activity_no_recent_events();
+ private String RECENT_PKG_HISTORY = MSG.common_title_recent_pkg_history();
+ private String RECENT_PKG_HISTORY_NONE = MSG.view_resource_inventory_activity_no_recent_pkg_history();
+
+ private ResourceComposite resourceComposite;
+
+ public ActivityView2(String locatorId, ResourceComposite resourceComposite) {
+ super(locatorId);
+ this.resourceComposite = resourceComposite;
+ initializeUi();
+ }
+
+ private void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ //dividers definition
+ HTMLFlow divider1 = new HTMLFlow("<hr/>");
+ HTMLFlow divider2 = new HTMLFlow("<hr/>");
+ HTMLFlow divider3 = new HTMLFlow("<hr/>");
+ HTMLFlow divider4 = new HTMLFlow("<hr/>");
+ HTMLFlow divider5 = new HTMLFlow("<hr/>");
+ divider1.setWidth("50%");
+ divider2.setWidth("50%");
+ divider3.setWidth("50%");
+ divider4.setWidth("50%");
+ divider5.setWidth("50%");
+
+ //leftPane
+ leftPane = new LocatableVLayout(extendLocatorId("Left"));
+ leftPane.setWidth("50%");
+ leftPane.setPadding(5);
+ leftPane.setMembersMargin(5);
+ leftPane.setAutoHeight();
+ //recentMetrics.xhtml
+ LocatableHLayout recentMetricsTitle = new TitleWithIcon(leftPane, "RecentMetrics",
+ "subsystems/monitor/Monitor_24.png", RECENT_MEASUREMENTS);
+ leftPane.addMember(recentMetricsTitle);
+ leftPane.addMember(recentMeasurementsContent);
+ recentMeasurementsContent.setHeight(20);
+ recentMeasurementsContent.setContents(RECENT_MEASUREMENTS_NONE);
+ leftPane.addMember(divider1);
+ //recentAlerts.xhtml
+ LocatableHLayout recentAlertsTitle = new TitleWithIcon(leftPane, "RecentAlerts",
+ "subsystems/alert/Flag_blue_24.png", RECENT_ALERTS);
+ leftPane.addMember(recentAlertsTitle);
+ leftPane.addMember(recentAlertsContent);
+ recentAlertsContent.setHeight(20);
+ // recentAlertsContent.setContents(RECENT_ALERTS_NONE);
+ leftPane.addMember(divider2);
+ //recentOOBs.xhtml
+ LocatableHLayout recentOobsTitle = new TitleWithIcon(leftPane, "RecentOobs",
+ "subsystems/monitor/Monitor_failed_24.png", RECENT_OOB);
+ leftPane.addMember(recentOobsTitle);
+ leftPane.addMember(recentOobContent);
+ recentOobContent.setHeight(20);
+ recentOobContent.setContents(RECENT_OOB_NONE);
+
+ //rightPane
+ rightPane = new LocatableVLayout(extendLocatorId("Right"));
+ rightPane.setWidth("50%");
+ rightPane.setPadding(5);
+ rightPane.setMembersMargin(5);
+ rightPane.setAutoHeight();
+ //recentConfigUpdates.xhtml
+ LocatableHLayout recentConfigUpdatesTitle = new TitleWithIcon(leftPane, "RecentConfigUpdates",
+ "subsystems/configure/Configure_24.png", RECENT_CONFIGURATIONS);
+ rightPane.addMember(recentConfigUpdatesTitle);
+ rightPane.addMember(recentConfigurationContent);
+ recentConfigurationContent.setHeight(20);
+ // recentConfigurationContent.setContents(RECENT_CONFIGURATIONS_NONE);
+ rightPane.addMember(divider3);
+ //recentOperations.xhtml
+ LocatableHLayout recentOperationsTitle = new TitleWithIcon(leftPane, "RecentOperations",
+ "subsystems/control/Operation_24.png", RECENT_OPERATIONS);
+ rightPane.addMember(recentOperationsTitle);
+ rightPane.addMember(recentOperationsContent);
+ recentOperationsContent.setHeight(20);
+ // recentOperationsContent.setContents(RECENT_OPERATIONS_NONE);
+ rightPane.addMember(divider4);
+ //recentEventCounts.xhtml
+ LocatableHLayout recentEventsTitle = new TitleWithIcon(leftPane, "RecentEvent",
+ "subsystems/event/Events_24.png", RECENT_EVENTS);
+ rightPane.addMember(recentEventsTitle);
+ rightPane.addMember(recentEventsContent);
+ recentEventsContent.setHeight(20);
+ recentEventsContent.setContents(RECENT_EVENTS_NONE);
+ rightPane.addMember(divider5);
+ //recentPackageHistory.xhtml
+ LocatableHLayout recentPkgHistoryTitle = new TitleWithIcon(leftPane, "RecentPkgHistory",
+ "subsystems/content/Content_24.png", RECENT_PKG_HISTORY);
+ rightPane.addMember(recentPkgHistoryTitle);
+ rightPane.addMember(recentPkgHistoryContent);
+ recentPkgHistoryContent.setHeight(20);
+ recentPkgHistoryContent.setContents(RECENT_PKG_HISTORY_NONE);
+ loadData();
+ }
+
+ private void loadData() {
+ getRecentAlerts();
+ getRecentOperations();
+ getRecentConfigurationUpdates();
+ getRecentEventUpdates();
+ getRecentOobs();
+ getRecentPkgHistory();
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ addMember(leftPane);
+ addMember(rightPane);
+ refresh();
+ }
+
+ @Override
+ public void refresh() {
+ // int resourceId = this.resourceComposite.getResource().getId();
+ // this.iFrame.setContentsURL("/rhq/resource/summary/overview-plain.xhtml?id=" + resourceId);
+ loadData();
+ markForRedraw();
+ }
+
+ class TitleWithIcon extends LocatableHLayout {
+ public TitleWithIcon(String locatorId) {
+ super(locatorId);
+ }
+
+ public TitleWithIcon(Locatable parentContainer, String locatorIdentifier, String imageUrl, String title) {
+ super(parentContainer.extendLocatorId(locatorIdentifier));
+ Img titleImage = new Img(imageUrl, 24, 24);
+ HTMLFlow titleElement = new HTMLFlow();
+ titleElement.setWidth("*");
+ titleElement.setContents(title);
+ titleElement.setStyleName("HeaderLabel");
+ addMember(titleImage);
+ addMember(titleElement);
+ setMembersMargin(10);
+ }
+ }
+
+ private void getRecentAlerts() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ AlertCriteria criteria = new AlertCriteria();
+ criteria.addFilterResourceIds(resourceId);
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+ GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
+ @Override
+ public void onSuccess(PageList<Alert> result) {
+ LocatableVLayout column = new LocatableVLayout(recentAlertsContent.extendLocatorId("Content"));
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (Alert alert : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent
+ .extendLocatorId("ContentForm"));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = new StaticTextItem();
+ FormItemIcon img = new FormItemIcon();
+ img.setSrc(ImageManager.getAlertIcon(alert.getAlertDefinition().getPriority()));
+ img.setWidth(16);
+ img.setHeight(16);
+ iconItem.setIcons(img);
+ iconItem.setShowTitle(false);
+
+ LinkItem link = new LinkItem();
+ link.setLinkTitle(alert.getAlertDefinition().getName());
+ link.setTitle(alert.getAlertDefinition().getName());
+ link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/Definitions/"
+ + alert.getAlertDefinition().getId());
+ link.setTarget("_self");
+ link.setShowTitle(false);
+
+ StaticTextItem time = new StaticTextItem();
+ time.setDefaultValue(new Date(alert.getAlertDefinition().getCtime()).toString());
+ time.setShowTitle(false);
+ time.setShowPickerIcon(false);
+ time.setWrap(false);
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ } else {
+ column.setContents(RECENT_ALERTS_NONE);
+ }
+ recentAlertsContent.setContents("");
+ for (Canvas child : recentAlertsContent.getChildren()) {
+ child.destroy();
+ }
+ recentAlertsContent.addChild(column);
+ recentAlertsContent.markForRedraw();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent alerts for resource [" + resourceId + "]:" + caught.getMessage());
+ }
+ });
+ }
+
+ private void getRecentOperations() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ GWTServiceLookup.getOperationService().findRecentCompletedOperations(5,
+ new AsyncCallback<List<DisambiguationReport<ResourceOperationLastCompletedComposite>>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent operations for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(List<DisambiguationReport<ResourceOperationLastCompletedComposite>> result) {
+ LocatableVLayout column = new LocatableVLayout(recentOperationsContent.extendLocatorId("Content"));
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (DisambiguationReport<ResourceOperationLastCompletedComposite> report : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId("ContentForm"));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = new StaticTextItem();
+ FormItemIcon img = new FormItemIcon();
+ img.setSrc(ImageManager.getOperationResultsIcon(report.getOriginal().getOperationStatus()));
+ img.setWidth(16);
+ img.setHeight(16);
+ iconItem.setIcons(img);
+ iconItem.setShowTitle(false);
+
+ LinkItem link = new LinkItem();
+ link.setLinkTitle(report.getOriginal().getOperationName());
+ link.setTitle(report.getOriginal().getOperationName());
+ link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Operations/History/"
+ + report.getOriginal().getOperationHistoryId());
+ link.setTarget("_self");
+ link.setShowTitle(false);
+
+ StaticTextItem time = new StaticTextItem();
+ time.setDefaultValue(new Date(report.getOriginal().getOperationStartTime()).toString());
+ time.setShowTitle(false);
+ time.setShowPickerIcon(false);
+ time.setWrap(false);
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ } else {
+ column.setContents(RECENT_OPERATIONS_NONE);
+ }
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
+ }
+ recentOperationsContent.addChild(column);
+ recentOperationsContent.markForRedraw();
+ }
+ });
+ }
+
+ private void getRecentConfigurationUpdates() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
+ criteria.addFilterResourceIds(resourceId);
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+ GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent configuration updates for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
+ LocatableVLayout column = new LocatableVLayout(recentOperationsContent.extendLocatorId("Content"));
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (ResourceConfigurationUpdate update : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId("ContentForm"));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = new StaticTextItem();
+ FormItemIcon img = new FormItemIcon();
+ img.setSrc(ImageManager.getConfigurationUpdateResultsIcon(update.getStatus()));
+ img.setWidth(16);
+ img.setHeight(16);
+ iconItem.setIcons(img);
+ iconItem.setShowTitle(false);
+
+ LinkItem link = new LinkItem();
+ link.setLinkTitle(MSG.view_resource_inventory_activity_changed_by()
+ + update.getSubjectName());
+ link.setTitle(MSG.view_resource_inventory_activity_changed_by() + update.getSubjectName());
+ link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Configuration/History/"
+ + update.getId());
+ link.setTarget("_self");
+ link.setShowTitle(false);
+
+ StaticTextItem time = new StaticTextItem();
+ time.setDefaultValue(new Date(update.getCreatedTime()).toString());
+ time.setShowTitle(false);
+ time.setShowPickerIcon(false);
+ time.setWrap(false);
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ } else {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId("ContentForm"));
+ row.setNumCols(3);
+ StaticTextItem none = new StaticTextItem();
+ none.setShowTitle(false);
+ none.setDefaultValue(RECENT_CONFIGURATIONS_NONE);
+ none.setWrap(false);
+ row.setItems(none);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentConfigurationContent.getChildren()) {
+ child.destroy();
+ }
+ recentConfigurationContent.addChild(column);
+ recentConfigurationContent.markForRedraw();
+ }
+ });
+ }
+
+ private void getRecentEventUpdates() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ EventCriteria criteria = new EventCriteria();
+ // criteria.addFilterResourceIds(resourceId);
+ long now = System.currentTimeMillis();
+ long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
+
+ criteria.addFilterResourceId(resourceId);
+ PageControl pageControl = PageControl.getUnlimitedInstance();
+ criteria.setPageControl(pageControl);
+ //Error retrieving recent event counts for resource [" + resourceId + "]:"
+ // GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId, nowMinus24Hours, now,
+ // new AsyncCallback<Map<EventSeverity, Integer>>() {
+ // @Override
+ // public void onFailure(Throwable caught) {
+ // Log.debug("Error retrieving recent event counts for resource [" + resourceId + "]:"
+ // + caught.getMessage());
+ // }
+ //
+ // @Override
+ // public void onSuccess(Map<EventSeverity, Integer> result) {
+ // LocatableVLayout column = new LocatableVLayout(recentOperationsContent.extendLocatorId("Content"));
+ // column.setHeight(10);
+ // if (!result.isEmpty()) {
+ // for (Entry<EventSeverity, Integer> entry : result.entrySet()) {
+ // EventSeverity severity = entry.getKey();
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
+ // .extendLocatorId("ContentForm"));
+ // row.setNumCols(2);
+ //
+ // StaticTextItem iconItem = new StaticTextItem();
+ // FormItemIcon img = new FormItemIcon();
+ // img.setSrc(ImageManager.getEventSeverityIcon(severity));
+ // // img.set
+ // img.setWidth(16);
+ // img.setHeight(16);
+ // iconItem.setIcons(img);
+ // iconItem.setShowTitle(false);
+ //
+ // StaticTextItem time = new StaticTextItem();
+ // time.setDefaultValue(entry.getValue());
+ // time.setShowTitle(false);
+ // time.setShowPickerIcon(false);
+ // time.setWrap(false);
+ // row.setItems(iconItem, time);
+ //
+ // column.addMember(row);
+ // }
+ // } else {
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
+ // .extendLocatorId("ContentForm"));
+ // row.setNumCols(3);
+ // StaticTextItem none = new StaticTextItem();
+ // none.setShowTitle(false);
+ // none.setDefaultValue(RECENT_EVENTS_NONE);
+ // none.setWrap(false);
+ // row.setItems(none);
+ // column.addMember(row);
+ // }
+ // //cleanup
+ // for (Canvas child : recentEventsContent.getChildren()) {
+ // child.destroy();
+ // }
+ // recentEventsContent.addChild(column);
+ // recentEventsContent.markForRedraw();
+ // }
+ // });
+ }
+
+ private void getRecentOobs() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ AlertCriteria criteria = new AlertCriteria();
+ criteria.addFilterResourceIds(resourceId);
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+ GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resourceId, 5,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent out of bound metrics for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<MeasurementOOBComposite> result) {
+ LocatableVLayout column = new LocatableVLayout(recentAlertsContent.extendLocatorId("Content"));
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (MeasurementOOBComposite oob : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent
+ .extendLocatorId("ContentForm"));
+ row.setNumCols(3);
+
+ // StaticTextItem iconItem = new StaticTextItem();
+ // FormItemIcon img = new FormItemIcon();
+ // img.setSrc(ImageManager.getAlertIcon(alert.getAlertDefinition().getPriority()));
+ // img.setWidth(16);
+ // img.setHeight(16);
+ // iconItem.setIcons(img);
+ // iconItem.setShowTitle(false);
+ //
+ // LinkItem link = new LinkItem();
+ // link.setLinkTitle(alert.getAlertDefinition().getName());
+ // link.setTitle(alert.getAlertDefinition().getName());
+ // link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/Definitions/"
+ // + alert.getAlertDefinition().getId());
+ // link.setTarget("_self");
+ // link.setShowTitle(false);
+ //
+ // StaticTextItem time = new StaticTextItem();
+ // time.setDefaultValue(new Date(alert.getAlertDefinition().getCtime()).toString());
+ // time.setShowTitle(false);
+ // time.setShowPickerIcon(false);
+ // time.setWrap(false);
+ // row.setItems(iconItem, link, time);
+ //
+ // column.addMember(row);
+ }
+ } else {
+ column.setContents(RECENT_OOB_NONE);
+ }
+ recentOobContent.setContents("");
+ for (Canvas child : recentOobContent.getChildren()) {
+ child.destroy();
+ }
+ recentOobContent.addChild(column);
+ recentOobContent.markForRedraw();
+
+ }
+ });
+ }
+
+ private void getRecentPkgHistory() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ InstalledPackageCriteria criteria = new InstalledPackageCriteria();
+ criteria.addFilterResourceId(resourceId);
+ // criteria.
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+
+ // GWTServiceLookup.getContentService().getInstalledPackageHistoryForResource(resourceId, 5,
+ // new AsyncCallback<PageList<InstalledPackageHistory>>() {
+ // @Override
+ // public void onFailure(Throwable caught) {
+ // Log.debug("Error retrieving installed package history for resource [" + resourceId + "]:"
+ // + caught.getMessage());
+ // }
+ //
+ // @Override
+ // public void onSuccess(PageList<InstalledPackageHistory> result) {
+ // LocatableVLayout column = new LocatableVLayout(recentPkgHistoryContent.extendLocatorId("Content"));
+ // column.setHeight(10);
+ // if (!result.isEmpty()) {
+ // for (InstalledPackageHistory history : result) {
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ // .extendLocatorId("ContentForm"));
+ // row.setNumCols(3);
+ //
+ // StaticTextItem iconItem = new StaticTextItem();
+ // FormItemIcon img = new FormItemIcon();
+ // img.setSrc("subsystems/content/Content_16.png");
+ // img.setWidth(16);
+ // img.setHeight(16);
+ // iconItem.setIcons(img);
+ // iconItem.setShowTitle(false);
+ //
+ // LinkItem link = new LinkItem();
+ // link.setLinkTitle(history.getPackageVersion().getDisplayName());
+ // link.setTitle(history.getPackageVersion().getDisplayName());
+ // // link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Configuration/History/"
+ // // + update.getId());
+ // //link.setValue(rhq/resource/content/audit-trail-item.xhtml?id=10005&selectedHistoryId=10002
+ // link.setValue("rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId
+ // + "&selectedHistoryId=" + history.getId());
+ // link.setTarget("_self");
+ // link.setShowTitle(false);
+ //
+ // StaticTextItem time = new StaticTextItem();
+ // time.setDefaultValue(new Date(history.getTimestamp()).toString());
+ // time.setShowTitle(false);
+ // time.setShowPickerIcon(false);
+ // time.setWrap(false);
+ // row.setItems(iconItem, link, time);
+ //
+ // column.addMember(row);
+ // }
+ // } else {
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ // .extendLocatorId("ContentForm"));
+ // row.setNumCols(3);
+ // StaticTextItem none = new StaticTextItem();
+ // none.setShowTitle(false);
+ // none.setDefaultValue(RECENT_PKG_HISTORY_NONE);
+ // none.setWrap(false);
+ // row.setItems(none);
+ // column.addMember(row);
+ // }
+ // //cleanup
+ // for (Canvas child : recentPkgHistoryContent.getChildren()) {
+ // child.destroy();
+ // }
+ // recentPkgHistoryContent.addChild(column);
+ // recentPkgHistoryContent.markForRedraw();
+ // }
+ // });
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java
new file mode 100644
index 0000000..36dee5e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtRelativeDurationConverter.java
@@ -0,0 +1,99 @@
+package org.rhq.enterprise.gui.coregui.client.util;
+
+//import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.i18n.client.TimeZone;
+import com.google.gwt.i18n.client.TimeZoneInfo;
+
+/** An RPC gwt serializable implemenation of the jsf RelativeDurationConverter
+ * utility.
+ *
+ * Convert the passed value in to a relative date compared to now.
+ * If the passed value is -1, the output will be empty (as a value of 0
+ * returns the number of days since the epoch)
+ * @author Joseph Marques
+ * @author Simeon Pinder
+ */
+public class GwtRelativeDurationConverter {
+ private static final long MILLIS_IN_SECOND = 1000L;
+ private static final long MILLIS_IN_MINUTE = 60 * MILLIS_IN_SECOND;
+ private static final long MILLIS_IN_HOUR = 60 * MILLIS_IN_MINUTE;
+ private static final long NEVER = -1;
+
+ private static final long MILLIS_IN_DAY = 24 * MILLIS_IN_HOUR;
+ // private static final SimpleDateFormat dayFormatter = new SimpleDateFormat("D");
+ // private static final SimpleDateFormat formatter = new SimpleDateFormat("hh:mm aaa z");
+ private static final DateTimeFormat dayFormatter = DateTimeFormat.getFormat("D");
+ private static final DateTimeFormat formatter = DateTimeFormat.getFormat("hh:mm aaa z");
+
+ public static TimeZone tz = null;
+
+ public static String format(long eventMillis) {
+ int dayOfYearToday = Integer.parseInt(dayFormatter.format(new Date(System.currentTimeMillis())));
+ int dayOfYearEvent = Integer.parseInt(dayFormatter.format(new Date(eventMillis)));
+ String result = null;
+ if (dayOfYearEvent == dayOfYearToday) {
+ // <time>
+ result = formatter.format(new Date(eventMillis));
+ } else if (dayOfYearEvent == dayOfYearToday - 1) {
+ // "yesterday" <time>
+ result = "Yesterday, " + formatter.format(new Date(eventMillis));
+ } else {
+ // <time> "ago"
+ result = getRelativeTimeAgo(eventMillis) + " ago";
+ }
+ return result;
+ }
+
+ private static TimeZone getTimeZone() {
+ if (tz == null) {
+ // return TimeZone.getDefault();
+ return TimeZone.createTimeZone(TimeZoneInfo.buildTimeZoneData(String.valueOf(System.currentTimeMillis())));
+ } else {
+ return tz;
+ }
+ }
+
+ private static String getRelativeTimeAgo(long millis) {
+ StringBuilder buf = new StringBuilder();
+ long timeAgo = System.currentTimeMillis() - millis;
+
+ int count = 0;
+ int days = (int) (timeAgo / MILLIS_IN_DAY);
+ timeAgo %= MILLIS_IN_DAY;
+ if (days > 0) {
+ count++;
+ buf.append(days).append(" day");
+ if (days != 1)
+ buf.append("s");
+ }
+
+ int hours = (int) (timeAgo / MILLIS_IN_HOUR);
+ timeAgo %= MILLIS_IN_HOUR;
+ if (hours > 0) {
+ count++;
+ if (buf.length() > 0)
+ buf.append(", ");
+ buf.append(hours).append(" hour");
+ if (hours != 1)
+ buf.append("s");
+ }
+
+ if (count < 2) {
+ int mins = (int) (timeAgo / MILLIS_IN_MINUTE);
+ timeAgo %= MILLIS_IN_MINUTE;
+ if (mins > 0) {
+ if (buf.length() > 0)
+ buf.append(", ");
+ buf.append(mins).append(" minute");
+ if (mins != 1)
+ buf.append("s");
+ }
+ }
+
+ return buf.toString();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
index bd6da37..cc9c288 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
@@ -33,6 +33,7 @@ import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ContentGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.content.ContentManagerLocal;
+import org.rhq.enterprise.server.content.ContentUIManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -43,6 +44,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
private static final long serialVersionUID = 1L;
private ContentManagerLocal contentManager = LookupUtil.getContentManager();
+ private ContentUIManagerLocal contentUiManager = LookupUtil.getContentUIManager();
public void deletePackageVersion(int packageVersionId) {
try {
@@ -61,6 +63,16 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
}
}
+ // public PageList<InstalledPackageHistory> getInstalledPackageHistoryForResource(int resourceId, int count) {
+ // try {
+ // PageControl pc = new PageControl(0, count);
+ // return SerialUtility.prepare(contentUiManager.getInstalledPackageHistoryForResource(resourceId, pc),
+ // "ContentService.getInstalledPackageHistoryForResource");
+ // } catch (Exception e) {
+ // throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ // }
+ // }
+
public List<Architecture> getArchitectures() {
try {
return SerialUtility.prepare(contentManager.findArchitectures(getSessionSubject()),
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
index 3dbae8e..6369c90 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
@@ -75,6 +75,15 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
}
}
+ // public Map<EventSeverity, Integer> getEventCountsBySeverity(int resourceId, long startDate, long endDate) {
+ // try {
+ // return SerialUtility.prepare(eventManager.getEventCountsBySeverity(getSessionSubject(), resourceId,
+ // startDate, endDate), "EventService.getEventCountsBySeverity");
+ // } catch (Exception e) {
+ // throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ // }
+ // }
+
public PageList<Event> findEventsByCriteria(EventCriteria criteria) {
try {
return SerialUtility.prepare(eventManager.findEventsByCriteria(getSessionSubject(), criteria),
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 2c45fbb..8f06b15 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
@@ -133,7 +133,12 @@ common_title_port = Port
common_title_providers = Providers
common_title_recently_added = Recently Added Resources
common_title_recent_alerts = Recent Alerts
+common_title_recent_configuration_updates=Recent Configuration Updates
+common_title_recent_event_counts=Recent Event Counts
+common_title_recent_measurements=Recent Measurements
+common_title_recent_oob_metrics=Recent Out of Bound metrics
common_title_recent_operations = Recent Operations
+common_title_recent_pkg_history=Recent Package History
common_title_remove_column = Remove Column
common_title_repositories = Repositories
common_title_resource = Resource
@@ -1286,6 +1291,14 @@ view_inventory_resources_loadFailed = Failed to load resource composite data
view_inventory_resources_title = Member Resources
view_inventory_resources_title_children = Child Resources
view_inventory_resources_title_members = Member Resources
+view_resource_inventory_activity_changed_by=Changed by
+view_resource_inventory_activity_no_recent_alerts=No recent alerts
+view_resource_inventory_activity_no_recent_config_history=No configuration change history
+view_resource_inventory_activity_no_recent_events =No events in the last 24 hours
+view_resource_inventory_activity_no_recent_metrics=This resource has no recent metrics
+view_resource_inventory_activity_no_recent_oob=No OOB conditions found
+view_resource_inventory_activity_no_recent_operations=No recent operation history
+view_resource_inventory_activity_no_recent_pkg_history=No recent package history
view_resource_monitor_availability_loadFailed = Failed to load availability history
view_resource_monitor_graphs_noneAvailable = No graphs available
view_resource_monitor_graphs_loadFailed = Failed to load graph data
13 years, 4 months
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 18 +++++-----
1 file changed, 10 insertions(+), 8 deletions(-)
New commits:
commit 79bcb67697b578e110e62bed262ec9a363fbb1bd
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Dec 21 11:46:35 2010 +0100
See if attaching the BundleVersion to the EM allows to pick up the Bundle for the implicit toString() call to work.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index 968d5cd..932e617 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -158,7 +158,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
// remove bundleversions which cascade remove bundlefiles and bundledeployments
// bundlefiles cascaderemove packageversions
// bundledeployments cascade remove bundleresourcedeployments
- // bundleresourcedeployments cascade remove bundleresourcedeploymenthistory
+ // bundleresourcedeployments cascade remove bundleresourcedeploymenthistory
q = em.createQuery("SELECT bv FROM BundleVersion bv WHERE bv.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
for (Object removeMe : doomed) {
@@ -172,7 +172,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
for (Object removeMe : doomed) {
em.remove(em.getReference(BundleFile.class, ((BundleFile) removeMe).getId()));
}
- // remove any orphaned deployment history
+ // remove any orphaned deployment history
q = em
.createQuery("SELECT brdh FROM BundleResourceDeploymentHistory brdh WHERE brdh.resourceDeployment.bundleDeployment.name LIKE '"
+ TEST_PREFIX + "%'");
@@ -198,7 +198,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
// remove bundles which cascade remove packageTypes and destinations
// packagetypes cascade remove packages
- // package cascade remove packageversions
+ // package cascade remove packageversions
q = em.createQuery("SELECT b FROM Bundle b WHERE b.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
for (Object removeMe : doomed) {
@@ -218,27 +218,27 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
for (Object removeMe : doomed) {
em.remove(em.getReference(Package.class, ((Package) removeMe).getId()));
}
- // remove any orphaned packagetypes
+ // remove any orphaned packagetypes
q = em.createQuery("SELECT pt FROM PackageType pt WHERE pt.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
for (Object removeMe : doomed) {
em.remove(em.getReference(PackageType.class, ((PackageType) removeMe).getId()));
}
- // remove any orphaned destinations
+ // remove any orphaned destinations
q = em.createQuery("SELECT bd FROM BundleDestination bd WHERE bd.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
for (Object removeMe : doomed) {
em.remove(em.getReference(BundleDestination.class, ((BundleDestination) removeMe).getId()));
}
- // remove repos no longer referenced by bundles
+ // remove repos no longer referenced by bundles
q = em.createQuery("SELECT r FROM Repo r WHERE r.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
for (Object removeMe : doomed) {
em.remove(em.getReference(Repo.class, ((Repo) removeMe).getId()));
}
- // remove Resource Groups left over from test deployments freeing up test resources
+ // remove Resource Groups left over from test deployments freeing up test resources
q = em.createQuery("SELECT rg FROM ResourceGroup rg WHERE rg.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
for (Object removeMe : doomed) {
@@ -259,7 +259,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
em.remove(em.getReference(BundleType.class, ((BundleType) removeMe).getId()));
}
- // remove Agents left over from test resources
+ // remove Agents left over from test resources
q = em.createQuery("SELECT a FROM Agent a WHERE a.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
for (Object removeMe : doomed) {
@@ -928,6 +928,8 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
c.addFilterName(TEST_PREFIX);
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
bv = bvs.get(1);
+ EntityManager em = getEntityManager();
+ bv = em.merge(bv);
assertNotNull(bvs);
assertEquals(3, bvs.size());
assertEquals(bv2, bv);
13 years, 4 months