[rhq] Branch 'bundle' - 2 commits - .classpath etc/eclipse-tools modules/common modules/enterprise modules/plugins
by mazz
.classpath | 2
etc/eclipse-tools/maven/RHQ | 11
modules/common/filetemplate-bundle/pom.xml | 37 ++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigdefRecipeCommand.java | 69 +++++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/DeployRecipeCommand.java | 76 +++++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeCommand.java | 42 +++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java | 45 +++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java | 127 ++++++++++
modules/common/pom.xml | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java | 4
modules/enterprise/server/plugins/filetemplate-bundle/pom.xml | 37 ++
modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java | 32 ++
modules/plugins/filetemplate-bundle/pom.xml | 13 -
14 files changed, 488 insertions(+), 13 deletions(-)
New commits:
commit 7f70926f340987e7808652cce688769dca1eac0e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 1 14:27:00 2010 -0500
stub the useage of parse results
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
index c810a97..ba53759 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
@@ -40,13 +40,15 @@ public class RecipeParseResults {
/** The set of bundle files that make up the bundle (version) as specified in the recipe commands */
private Set<String> bundleFileNames;
- private RecipeParseResults(ConfigurationDefinition configDef, Set<String> bundleFileNames) {
+ public RecipeParseResults(ConfigurationDefinition configDef, Set<String> bundleFileNames) {
this.configDef = configDef;
this.bundleFileNames = bundleFileNames;
}
public ConfigurationDefinition getConfigDef() {
+
// stub out a test ConfigDef here until we actual parse the recipe
+ System.out.println("!!!!!! REMOVE THIS TEST CODE !!!!!!!!");
configDef = new ConfigurationDefinition("SampleBundle", "Stubbed ConfigDef for Sample Bundle");
configDef.put(new PropertyDefinitionSimple("sample.bundle.deploy.directory",
"Stubbed Property for deploy directory (must already exist on target platform)", true,
@@ -62,6 +64,7 @@ public class RecipeParseResults {
public Set<String> getBundleFileNames() {
// stub out a test set of BundleFiles here until we actual parse the recipe. For now lets just deploy
// a war file into an existing app server dir.
+ System.out.println("!!!!!! REMOVE THIS TEST CODE !!!!!!!!");
bundleFileNames = new HashSet<String>();
bundleFileNames.add("sample-bundle.war");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
index 2bf4719..a2d6b96 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
@@ -19,12 +19,13 @@
package org.rhq.enterprise.server.plugin.pc.bundle;
+import org.rhq.enterprise.server.bundle.RecipeParseResults;
+
/**
* All bundle server plugins must implement this facet.
*
* @author John Mazzitelli
*/
public interface BundleServerPluginFacet {
- // TODO return something the server/jar SLSB likes
- void parseRecipe(String recipe) throws Exception;
+ RecipeParseResults parseRecipe(String recipe) throws Exception;
}
diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
index a1f770e..96f7070 100644
--- a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
@@ -19,9 +19,17 @@
package org.rhq.enterprise.server.plugins.filetemplate;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.bundle.filetemplate.recipe.RecipeContext;
import org.rhq.bundle.filetemplate.recipe.RecipeParser;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.enterprise.server.bundle.RecipeParseResults;
import org.rhq.enterprise.server.plugin.pc.ControlFacet;
import org.rhq.enterprise.server.plugin.pc.ControlResults;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
@@ -35,28 +43,38 @@ import org.rhq.enterprise.server.plugin.pc.bundle.BundleServerPluginFacet;
*/
public class BundleServerPluginComponent implements ServerPluginComponent, BundleServerPluginFacet, ControlFacet {
+ private final Log log = LogFactory.getLog(BundleServerPluginComponent.class);
+
private ServerPluginContext context;
public void initialize(ServerPluginContext context) throws Exception {
this.context = context;
- System.out.println("The filetemplate bundle plugin has been initialized!!! : " + this);
+ log.debug("The filetemplate bundle plugin has been initialized!!! : " + this);
}
public void start() {
- System.out.println("The filetemplate bundle plugin has started!!! : " + this);
+ log.debug("The filetemplate bundle plugin has started!!! : " + this);
}
public void stop() {
- System.out.println("The filetemplate bundle plugin has stopped!!! : " + this);
+ log.debug("The filetemplate bundle plugin has stopped!!! : " + this);
}
public void shutdown() {
- System.out.println("The filetemplate bundle plugin has been shut down!!! : " + this);
+ log.debug("The filetemplate bundle plugin has been shut down!!! : " + this);
}
- public void parseRecipe(String recipe) throws Exception {
+ public RecipeParseResults parseRecipe(String recipe) throws Exception {
RecipeParser parser = new RecipeParser();
- parser.parseRecipe(recipe);
+ RecipeContext parserContext = parser.parseRecipe(recipe);
+
+ // TODO convert the context to the results object
+ ConfigurationDefinition configDef = null;
+ Set<String> bundleFileNames = null;
+
+ RecipeParseResults results = new RecipeParseResults(configDef, bundleFileNames);
+ return results;
+
}
public ControlResults invoke(String name, Configuration parameters) {
commit 7210b1f604f74ac9e384715a84f7ef0fc785fcfa
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 1 13:57:49 2010 -0500
first stubbed version of the commons filetemplate bundle commons lib
diff --git a/.classpath b/.classpath
index bb17f97..c6a1ed2 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="modules/common/jboss-as/src/main/java"/>
+ <classpathentry kind="src" path="modules/common/filetemplate-bundle/src/main/java"/>
+ <classpathentry kind="src" path="modules/common/filetemplate-bundle/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/gui/base-perspective-jar/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/server/plugins/jboss-software/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/server/plugins/jboss-software/src/main/java"/>
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build and Test - Plugin Common Libraries.launch b/etc/eclipse-tools/maven/RHQ Maven Build and Test - Plugin Common Libraries.launch
new file mode 100644
index 0000000..34c8c3d
--- /dev/null
+++ b/etc/eclipse-tools/maven/RHQ Maven Build and Test - Plugin Common Libraries.launch
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=false install"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/common}"/>
+</launchConfiguration>
diff --git a/modules/common/filetemplate-bundle/pom.xml b/modules/common/filetemplate-bundle/pom.xml
new file mode 100644
index 0000000..e6a3107
--- /dev/null
+++ b/modules/common/filetemplate-bundle/pom.xml
@@ -0,0 +1,37 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-common-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <packaging>jar</packaging>
+
+ <name>RHQ File Template Bundle Plugins Common Library</name>
+ <description>A library with the code common to the agent and server plugins for File Template Bundles</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/common/filetemplat...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/common/filetemplat...</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/common/filetemplate-bundle/</scm.module.path>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>gnu-getopt</groupId>
+ <artifactId>getopt</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigdefRecipeCommand.java b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigdefRecipeCommand.java
new file mode 100644
index 0000000..057d474
--- /dev/null
+++ b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigdefRecipeCommand.java
@@ -0,0 +1,69 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.filetemplate.recipe;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+public class ConfigdefRecipeCommand implements RecipeCommand {
+
+ public String getName() {
+ return "configdef";
+ }
+
+ public void parse(RecipeContext context, String[] args) {
+ String sopts = ":f:";
+ LongOpt[] lopts = { new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null, 'f') };
+
+ String filename = null;
+
+ Getopt getopt = new Getopt(context.toString(), args, sopts, lopts);
+ int code;
+
+ while ((code = getopt.getopt()) != -1) {
+ switch (code) {
+ case ':':
+ case '?': {
+ throw new IllegalArgumentException("Bad recipe command [" + getName() + "]: " + args);
+ }
+
+ case 1: {
+ throw new IllegalArgumentException("Bad recipe command [" + getName() + "]: " + args);
+ }
+
+ case 'f': {
+ filename = getopt.getOptarg();
+ break;
+ }
+
+ default: {
+ throw new IllegalArgumentException("Unexpected error in recipe command [" + getName() + "]: " + args);
+ }
+
+ }
+ }
+
+ // TODO : do something with filename
+ }
+}
diff --git a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/DeployRecipeCommand.java b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/DeployRecipeCommand.java
new file mode 100644
index 0000000..145398c
--- /dev/null
+++ b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/DeployRecipeCommand.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.filetemplate.recipe;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+public class DeployRecipeCommand implements RecipeCommand {
+
+ public String getName() {
+ return "deploy";
+ }
+
+ public void parse(RecipeContext context, String[] args) {
+ String sopts = ":f:d:";
+ LongOpt[] lopts = { new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null, 'f'),
+ new LongOpt("directory", LongOpt.REQUIRED_ARGUMENT, null, 'd') };
+
+ String filename = null;
+ String directory = null;
+
+ Getopt getopt = new Getopt(context.toString(), args, sopts, lopts);
+ int code;
+
+ while ((code = getopt.getopt()) != -1) {
+ switch (code) {
+ case ':':
+ case '?': {
+ throw new IllegalArgumentException("Bad recipe command [" + getName() + "]: " + args);
+ }
+
+ case 1: {
+ throw new IllegalArgumentException("Bad recipe command [" + getName() + "]: " + args);
+ }
+
+ case 'f': {
+ filename = getopt.getOptarg();
+ break;
+ }
+
+ case 'd': {
+ directory = getopt.getOptarg();
+ break;
+ }
+
+ default: {
+ throw new IllegalArgumentException("Unexpected error in recipe command [" + getName() + "]: " + args);
+ }
+
+ }
+ }
+
+ // TODO : do something with filename and directory
+ }
+}
diff --git a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeCommand.java b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeCommand.java
new file mode 100644
index 0000000..7cfa964
--- /dev/null
+++ b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeCommand.java
@@ -0,0 +1,42 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.filetemplate.recipe;
+
+public interface RecipeCommand {
+
+ /**
+ * The name of the recipe command. This must be the first word in the recipe line in order for this command to be triggered.
+ *
+ * @return name of the recipe command
+ */
+ String getName();
+
+ /**
+ * Parses this recipe command and optionally puts information in the context.
+ *
+ * @param context information where the parser can store information regarding the command that was processed
+ * @param args arguments passed to the command.
+ */
+ void parse(RecipeContext context, String[] args);
+}
diff --git a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
new file mode 100644
index 0000000..da96ceb
--- /dev/null
+++ b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.filetemplate.recipe;
+
+/**
+ * @author John Mazzitelli
+ */
+public class RecipeContext {
+
+ private final String recipe;
+
+ public RecipeContext(String recipe) {
+ this.recipe = recipe;
+ }
+
+ /**
+ * The full recipe that this context represents.
+ *
+ * @return the actual recipe text
+ */
+ public String getRecipe() {
+ return recipe;
+ }
+}
diff --git a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
new file mode 100644
index 0000000..ff9b91f
--- /dev/null
+++ b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
@@ -0,0 +1,127 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.bundle.filetemplate.recipe;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StreamTokenizer;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Parses the file template recipe.
+ *
+ * @author John Mazzitelli
+ *
+ */
+public class RecipeParser {
+ private Map<String, RecipeCommand> recipeCommands;
+
+ public RecipeParser() {
+ setupRecipeCommands();
+ }
+
+ public RecipeContext parseRecipe(String recipe) throws Exception {
+ RecipeContext context = new RecipeContext(recipe);
+
+ BufferedReader recipeReader = new BufferedReader(new StringReader(recipe));
+ String line = recipeReader.readLine();
+ while (line != null) {
+ String[] commandLineArray = splitCommandLine(line);
+ String commandName = commandLineArray[0];
+ String[] arguments = extractArguments(commandLineArray);
+
+ RecipeCommand recipeCommand = recipeCommands.get(commandName);
+ if (recipeCommand == null) {
+ throw new Exception("Unknown command in recipe: " + commandName);
+ }
+
+ recipeCommand.parse(context, arguments);
+
+ line = recipeReader.readLine();
+ }
+
+ return context;
+ }
+
+ private void setupRecipeCommands() {
+ recipeCommands = new HashMap<String, RecipeCommand>();
+
+ RecipeCommand[] knownCommands = new RecipeCommand[] { new ConfigdefRecipeCommand(), //
+ new DeployRecipeCommand() //
+ };
+
+ for (RecipeCommand recipeCommand : knownCommands) {
+ recipeCommands.put(recipeCommand.getName(), recipeCommand);
+ }
+ }
+
+ private String[] splitCommandLine(String cmdLine) {
+ ByteArrayInputStream in = new ByteArrayInputStream(cmdLine.getBytes());
+ StreamTokenizer strtok = new StreamTokenizer(new InputStreamReader(in));
+ List<String> args = new ArrayList<String>();
+ boolean keep_going = true;
+
+ // we don't want to parse numbers and we want ' to be a normal word character
+ strtok.ordinaryChars('0', '9');
+ strtok.ordinaryChar('.');
+ strtok.ordinaryChar('-');
+ strtok.ordinaryChar('\'');
+ strtok.wordChars(33, 127);
+ strtok.quoteChar('\"');
+
+ // parse the command line
+ while (keep_going) {
+ int nextToken;
+
+ try {
+ nextToken = strtok.nextToken();
+ } catch (IOException e) {
+ nextToken = StreamTokenizer.TT_EOF;
+ }
+
+ if (nextToken == java.io.StreamTokenizer.TT_WORD) {
+ args.add(strtok.sval);
+ } else if (nextToken == '\"') {
+ args.add(strtok.sval);
+ } else if ((nextToken == java.io.StreamTokenizer.TT_EOF) || (nextToken == java.io.StreamTokenizer.TT_EOL)) {
+ keep_going = false;
+ }
+ }
+
+ return args.toArray(new String[args.size()]);
+ }
+
+ private String[] extractArguments(String[] commandLine) {
+ // strip the first element (the command name) from the array, leaving only the arguments
+ int newLength = commandLine.length - 1;
+ String[] argsOnly = new String[newLength];
+ System.arraycopy(commandLine, 1, argsOnly, 0, newLength);
+ return argsOnly;
+ }
+}
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index e9f0385..8abfe11 100644
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -66,5 +66,6 @@
<modules>
<module>jboss-as</module>
+ <module>filetemplate-bundle</module>
</modules>
</project>
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
index 0585a4b..2bf4719 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
@@ -25,5 +25,6 @@ package org.rhq.enterprise.server.plugin.pc.bundle;
* @author John Mazzitelli
*/
public interface BundleServerPluginFacet {
-
+ // TODO return something the server/jar SLSB likes
+ void parseRecipe(String recipe) throws Exception;
}
diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml b/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
index 7a19819..4a3536e 100644
--- a/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
+++ b/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
@@ -42,6 +42,12 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- 3rd Party Deps -->
<!-- TODO: This is a fix for the Javac bug requiring annotations to be
@@ -71,11 +77,37 @@
<configuration>
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
<!--
- <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
+ <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
-->
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy-rhq-plugins</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+
+ <artifactItem>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <version>${project.version}</version>
+ </artifactItem>
+
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
@@ -141,7 +173,8 @@
<include name="META-INF/**" />
</patternset>
</unjar>
- <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+ update="true">
</jar>
</tasks>
</configuration>
diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
index 58dd5b1..a1f770e 100644
--- a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.plugins.filetemplate;
+import org.rhq.bundle.filetemplate.recipe.RecipeParser;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.enterprise.server.plugin.pc.ControlFacet;
@@ -53,6 +54,11 @@ public class BundleServerPluginComponent implements ServerPluginComponent, Bundl
System.out.println("The filetemplate bundle plugin has been shut down!!! : " + this);
}
+ public void parseRecipe(String recipe) throws Exception {
+ RecipeParser parser = new RecipeParser();
+ parser.parseRecipe(recipe);
+ }
+
public ControlResults invoke(String name, Configuration parameters) {
ControlResults controlResults = new ControlResults();
if (name.equals("testControl")) {
diff --git a/modules/plugins/filetemplate-bundle/pom.xml b/modules/plugins/filetemplate-bundle/pom.xml
index b1f18b5..93f1c4c 100644
--- a/modules/plugins/filetemplate-bundle/pom.xml
+++ b/modules/plugins/filetemplate-bundle/pom.xml
@@ -26,13 +26,17 @@
<dependencies>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<plugins>
- <!--
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
@@ -47,9 +51,9 @@
<artifactItems>
<artifactItem>
- <groupId>org.jboss</groupId>
- <artifactId>byteman</artifactId>
- <version>1.2.0</version>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <version>${project.version}</version>
</artifactItem>
</artifactItems>
@@ -58,7 +62,6 @@
</execution>
</executions>
</plugin>
- -->
</plugins>
</build>
14 years, 2 months
[rhq] Branch 'bundle' - modules/enterprise
by Jay Shaughnessy
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java | 75 ++++++++++
1 file changed, 75 insertions(+)
New commits:
commit 47723277426d7e582828b2bc45316edbdd005195
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 1 13:55:48 2010 -0500
initial version with some stubbed return values for testing
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
new file mode 100644
index 0000000..c810a97
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
@@ -0,0 +1,75 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License 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.server.bundle;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+
+/**
+ * This class is general to all Bundle handling server side plugins. It is returned by the SSP when parsing
+ * a bundle's recipe and contains all of the information neded to create a bundle version.
+ *
+ * @author jay shaughnessy
+ */
+public class RecipeParseResults {
+
+ /** The configuration definition parsed out of, or expcitly provided by, the recipe */
+ private ConfigurationDefinition configDef;
+
+ /** The set of bundle files that make up the bundle (version) as specified in the recipe commands */
+ private Set<String> bundleFileNames;
+
+ private RecipeParseResults(ConfigurationDefinition configDef, Set<String> bundleFileNames) {
+ this.configDef = configDef;
+ this.bundleFileNames = bundleFileNames;
+ }
+
+ public ConfigurationDefinition getConfigDef() {
+ // stub out a test ConfigDef here until we actual parse the recipe
+ configDef = new ConfigurationDefinition("SampleBundle", "Stubbed ConfigDef for Sample Bundle");
+ configDef.put(new PropertyDefinitionSimple("sample.bundle.deploy.directory",
+ "Stubbed Property for deploy directory (must already exist on target platform)", true,
+ PropertySimpleType.STRING));
+
+ return configDef;
+ }
+
+ public void setConfigDef(ConfigurationDefinition configDef) {
+ this.configDef = configDef;
+ }
+
+ public Set<String> getBundleFileNames() {
+ // stub out a test set of BundleFiles here until we actual parse the recipe. For now lets just deploy
+ // a war file into an existing app server dir.
+ bundleFileNames = new HashSet<String>();
+ bundleFileNames.add("sample-bundle.war");
+
+ return bundleFileNames;
+ }
+
+ public void setBundleFiles(Set<String> bundleFileNames) {
+ this.bundleFileNames = bundleFileNames;
+ }
+
+}
14 years, 2 months
[rhq] Branch 'gwt' - modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java | 116 +---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java | 110 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 128 +++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Presenter.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UnknownViewException.java | 47 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java | 81 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java | 119 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewRenderer.java | 36 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 288 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/report/InventorySummaryReportView.java | 35 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourcesView.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java | 86 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/places/Place.java | 4
modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml | 93 +++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main-layout.xhtml | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main.xhtml | 4
25 files changed, 965 insertions(+), 269 deletions(-)
New commits:
commit b8e74ea0b436305d25b13cbe5df6d81d93c5b824
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Mar 1 13:33:35 2010 -0500
implement Administration>Reports>Inventory Summary page (loads JSF page via IFRAME); revamp history/breadcrumb API
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java
index 2f5a744..c57c352 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/BreadCrumb.java
@@ -18,105 +18,89 @@
*/
package org.rhq.enterprise.gui.coregui.client;
-import org.rhq.enterprise.gui.coregui.client.places.Place;
-
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.Hyperlink;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.HTMLPane;
-import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.HStack;
import java.util.ArrayList;
+import java.util.List;
/**
+ * GWT widget for the breadcrumb trail, which is displayed at the top of each page.
+ *
* @author Greg Hinkle
+ * @author Ian Springer
*/
public class BreadCrumb extends HTMLPane {
- private ArrayList<Place> trail = new ArrayList<Place>();
+ private List<Breadcrumb> breadcrumbs = new ArrayList<Breadcrumb>();
public BreadCrumb() {
-
setHeight(28);
setBackgroundColor("#E6E3E3");
setPadding(5);
setOverflow(Overflow.CLIP_V);
}
-
- public void initialize(String historyPath) {
- String[] ids =historyPath.split("\\/");
-
- for (String id : ids) {
- trail.add(new Place(id,"?"));
- }
-
+ public List<Breadcrumb> getBreadcrumbs() {
+ return this.breadcrumbs;
}
- public void verify(String historyPath) {
- String[] ids = historyPath.split("\\/");
+ public void setBreadcrumbs(List<Breadcrumb> breadcrumbs) {
+ this.breadcrumbs = breadcrumbs;
+ }
- for (int i = 0; i < ids.length; i++) {
- if (trail.size() > i && !trail.get(i).getId().equals(ids[i])) {
- trail = new ArrayList(trail.subList(0,i));
- trail.add(new Place(ids[i], "?"));
- } else {
- if (trail.size() > i) {
- trail.set(i,new Place(ids[i],"?"));
+ public void refresh() {
+ try {
+ boolean first = true;
+ StringBuilder path = new StringBuilder();
+ StringBuilder content = new StringBuilder();
+ content.append("<div class=\"BreadCrumb\">");
+ for (int i = 0, trailSize = this.breadcrumbs.size(); i < trailSize; i++) {
+ if (!first) {
+ path.append("/");
+ content.append(" > ");
} else {
- trail.add(new Place(ids[i],"?"));
+ first = false;
}
- }
- }
- }
+ Breadcrumb breadcrumb = breadcrumbs.get(i);
+ path.append(breadcrumb.getName());
-
- public void setPlace(Place place) {
- trail.clear();
- addPlace(place);
- }
-
- public void addPlace(Place place) {
- trail.add(place);
-
- refresh();
- }
-
- public void refresh() {
- String content = "";
- boolean first = true;
-
- String path = "";
- for (Place place : trail) {
- if (!first) {
- content += " > ";
- }
- first = false;
- if (path.length() > 0) {
- path += "/";
+ if ((i == (trailSize - 1) || !breadcrumb.isHyperlink())) {
+ // last item in trail is the current page and so should not be a link
+ content.append(breadcrumb.getDisplayName());
+ } else {
+ content.append("<a href=\"#");
+ // NOTE: We have to call toString() below, because GWT chokes if you try to append a StringBuilder.
+ content.append(path.toString());
+ content.append("\">");
+ content.append(breadcrumb.getDisplayName());
+ content.append("</a>");
+ }
+ content.append("\n");
}
- path += place.getId();
-
+ content.append("</div>");
- content += "<a class=\"BreadCrumb\" href=\"#" + path + "\">" + place.getName() + "</a>";
+ setContents(content.toString());
+ } catch (Throwable t) {
+ System.err.println("Failed to refresh bread crumb HTML - cause: " + t);
}
- setContents(content);
-
- History.newItem(path);
- if (!trail.isEmpty())
- Window.setTitle("RHQ: " + trail.get(trail.size()-1));
+ String title = "RHQ";
+ if (!breadcrumbs.isEmpty()) {
+ title += ": " + this.breadcrumbs.get(this.breadcrumbs.size() - 1);
+ }
+ Window.setTitle(title);
redraw();
}
-
- public ArrayList<Place> getTrail() {
- return trail;
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder("BreadCrumb[");
+ result.append(this.breadcrumbs);
+ result.append("]");
+ return result.toString();
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java
new file mode 100644
index 0000000..4d61b96
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Breadcrumb.java
@@ -0,0 +1,110 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client;
+
+/**
+ * Information about a breadcrumb (i.e. history token component) that is used to render that breadcrumb in the
+ * breadcrumb trail at the top of the page.
+ *
+ * @author Ian Springer
+ */
+public class Breadcrumb {
+ private String name;
+ private String displayName;
+ private boolean hyperlink;
+
+ public Breadcrumb(String name) {
+ this(name, null);
+ }
+
+ public Breadcrumb(String name, String displayName) {
+ this(name, displayName, true);
+ }
+
+ public Breadcrumb(String name, boolean hyperlink) {
+ this(name, null, hyperlink);
+ }
+
+ public Breadcrumb(String name, String displayName, boolean hyperlink) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name is null.");
+ }
+ this.name = name;
+ setDisplayName(displayName);
+ this.hyperlink = hyperlink;
+ }
+
+ /**
+ * Returns this breadcrumb's name (e.g. "10001").
+ *
+ * @return this breadcrumb's name (e.g. "10001")
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns the display name to use for this breadcrumb in the breadcrumb trail, or null if the display name should
+ * be derived from the name.
+ *
+ * @return the display name to use for this breadcrumb in the breadcrumb trail, or null if the display name should
+ * be derived from the name
+ */
+ public String getDisplayName() {
+ return this.displayName;
+ }
+
+ /**
+ * Sets the display name to use for this breadcrumb in the breadcrumb trail, or null if the display name should
+ * be derived from the name.
+ */
+ public void setDisplayName(String displayName) {
+ this.displayName = (displayName != null) ? displayName : getDefaultDisplayName();
+ }
+
+ /**
+ * Return true if this breadcrumb should be a hyperlink in the breadcrumb trail, or false otherwise. NOTE:
+ * Regardless of what this method returns, if this breadcrumb is the last item in the breadcrumb trail, it
+ * will not be made a hyperlink, since it already corresponds to the current view.
+ *
+ * @return true if this breadcrumb should be a hyperlink in the breadcrumb trail, or false otherwise
+ */
+ public boolean isHyperlink() {
+ return this.hyperlink;
+ }
+
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ private String getDefaultDisplayName() {
+ StringBuilder displayName = new StringBuilder();
+ boolean first = true;
+ for (int i = 0; i < this.name.length(); i++) {
+ char c = this.name.charAt(i);
+ if (Character.isUpperCase(c) && !first) {
+ displayName.append(" ");
+ }
+ first = false;
+ displayName.append(c);
+ }
+ return displayName.toString();
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 9b081c0..3ab6790 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -8,7 +8,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourcesView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceView;
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
-import org.rhq.enterprise.gui.coregui.client.places.Place;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import com.google.gwt.core.client.EntryPoint;
@@ -33,6 +32,9 @@ import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.layout.VLayout;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
/**
@@ -43,7 +45,7 @@ public class CoreGUI implements EntryPoint {
public static final String CONTENT_CANVAS_ID = "BaseContent";
private static Subject sessionSubject;
- private static Subject fullSubject;
+ //private static Subject fullSubject;
private static ErrorHandler errorHandler = new ErrorHandler();
@@ -51,6 +53,8 @@ public class CoreGUI implements EntryPoint {
private static Canvas content;
+ private View rootView;
+
public void onModuleLoad() {
if (!GWT.isScript()) {
@@ -118,9 +122,9 @@ public class CoreGUI implements EntryPoint {
private void buildCoreUI() {
- VLayout layout = new VLayout();
- layout.setWidth100();//(1200);
- layout.setHeight100(); //(900);
+ RootCanvas rootCanvas = new RootCanvas();
+ this.rootView = new View(new ViewId("", null), rootCanvas);
+
// HTMLPane menuPane = new HTMLPane();
// menuPane.setWidth100();
@@ -139,12 +143,12 @@ public class CoreGUI implements EntryPoint {
// menuCanvas.setWidth100();
// menuCanvas.draw();
- layout.addMember(menuBarView);
+ rootCanvas.addMember(menuBarView);
breadCrumb = new BreadCrumb();
- layout.addMember(breadCrumb);
+ rootCanvas.addMember(breadCrumb);
DOM.setInnerHTML(RootPanel.get("Loading-Panel").getElement(), "");
@@ -154,34 +158,53 @@ public class CoreGUI implements EntryPoint {
canvas.setWidth100();
canvas.setHeight100();
- layout.addMember(canvas);
+ rootCanvas.addMember(canvas);
// canvas.addChild(new AdministrationView()) ; //DemoCanvas());
- layout.draw();
-
-
- breadCrumb.initialize(History.getToken());
-
+ rootCanvas.draw();
History.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> historyChangeEvent) {
- System.out.println("History request: " + historyChangeEvent.getValue());
-
+ String path = historyChangeEvent.getValue();
+ System.out.println("History request: " + path);
+
+ List<String> viewIdNames = path.equals("") ? Collections.<String>emptyList() : Arrays.asList(path.split("\\/"));
+
+ View parentView = CoreGUI.this.rootView;
+ ViewRenderer viewRenderer = (ViewRenderer)parentView.getCanvas();
+ List<Breadcrumb> breadcrumbs = new ArrayList<Breadcrumb>(viewIdNames.size());
+ try {
+ for (String viewIdName : viewIdNames) {
+ Canvas parentCanvas = parentView.getCanvas();
+ if (parentCanvas != null && parentCanvas instanceof ViewRenderer) {
+ viewRenderer = (ViewRenderer)parentCanvas;
+ }
+ ViewId viewId = new ViewId(viewIdName, parentView.getId());
+ parentView = viewRenderer.renderView(parentView, viewId);
+ breadcrumbs.add(parentView.getBreadcrumb());
+ }
+ } catch (UnknownViewException e) {
+ // Abort the for-loop, since once we hit an unknown name, we don't care about any remaining names
+ // in the list. The breadcrumbs list will contain breadcrumbs for only the names that were
+ // recognized.
+ System.err.println(e.getMessage());
+ }
- breadCrumb.verify(historyChangeEvent.getValue());
+ System.out.println("Breadcrumbs: " + breadcrumbs);
+ breadCrumb.setBreadcrumbs(breadcrumbs);
+ /*breadCrumb.initialize(path);
ArrayList<Place> trail = breadCrumb.getTrail();
Place base = trail.get(0);
-
if (content != null && content instanceof Presenter) {
Presenter p = ((Presenter) content);
if (!p.fireDisplay(base, trail.subList(1, trail.size()))) {
- Canvas c = displayContent(base.getId());
+ Canvas c = createContent(base.getId());
setContent(c);
if (trail.size() >= 2 && c instanceof Presenter) {
@@ -189,32 +212,36 @@ public class CoreGUI implements EntryPoint {
}
}
} else {
- Canvas c = displayContent(base.getId());
+ Canvas c = createContent(base.getId());
setContent(c);
if (trail.size() >= 2 && c instanceof Presenter) {
((Presenter) c).fireDisplay(trail.get(0), trail.subList(1, trail.size()));
}
- }
+ }*/
+
+ breadCrumb.refresh();
}
});
History.fireCurrentHistoryState();
}
- public Canvas displayContent(String key) {
- Canvas c = null;
- if (key.equals("Administration")) {
- c = new AdministrationView();
- } else if (key.equals("Demo")) {
- c = new DemoCanvas();
- } else if (key.equals("Resources")) {
- c = new ResourcesView();
- } else if (key.equals("Resource")) {
- c = new ResourceView();
- } else if (key.equals("Dashboard")) {
- c = new DashboardView();
+ public Canvas createContent(String breadcrumbName) {
+ Canvas canvas;
+ if (breadcrumbName.equals("Administration")) {
+ canvas = new AdministrationView();
+ } else if (breadcrumbName.equals("Demo")) {
+ canvas = new DemoCanvas();
+ } else if (breadcrumbName.equals("Resources")) {
+ canvas = new ResourcesView();
+ } else if (breadcrumbName.equals("Resource")) {
+ canvas = new ResourceView();
+ } else if (breadcrumbName.equals("Dashboard")) {
+ canvas = new DashboardView();
+ } else {
+ canvas = null;
}
- return c;
+ return canvas;
}
@@ -250,16 +277,41 @@ public class CoreGUI implements EntryPoint {
contentCanvas.draw();
}
- public static void addBreadCrumb(Place place) {
- breadCrumb.addPlace(place);
+ public static void goTo(String path) {
+ History.newItem(path, true);
+ }
+ public static void updateBreadCrumbDisplayName(ViewId viewId, String displayName) {
+ int index = -1;
+ for (ViewId current = viewId.getParent(); current != null; current = current.getParent()) {
+ index++;
+ }
+ List<Breadcrumb> breadcrumbs = breadCrumb.getBreadcrumbs();
+ if (index < breadcrumbs.size()) {
+ Breadcrumb breadcrumb = breadcrumbs.get(index);
+ if (breadcrumb.getName().equals(viewId.getName())) {
+ breadcrumbs.set(index, new Breadcrumb(breadcrumb.getName(), displayName));
+ breadCrumb.refresh();
+ }
+ }
}
- public static void setBreadCrumb(Place place) {
- breadCrumb.setPlace(place);
+ private class RootCanvas extends VLayout implements ViewRenderer {
+ private RootCanvas() {
+ setWidth100(); // (1200);
+ setHeight100(); // (900);
+ }
+ public View renderView(View parentView, ViewId viewId) throws UnknownViewException {
+ String path = viewId.getPath();
+ Canvas canvas = createContent(path);
+ if (canvas != null) {
+ setContent(canvas);
+ return new View(viewId, canvas);
+ }
+ throw new UnknownViewException(viewId);
+ }
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
index 0c000b2..4468edf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
@@ -18,11 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client;
-import org.rhq.core.domain.resource.Resource;
import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeView;
import com.smartgwt.client.types.Side;
import com.smartgwt.client.types.TabBarControls;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Presenter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Presenter.java
index 2f772db..84fa7e5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Presenter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Presenter.java
@@ -20,19 +20,17 @@ package org.rhq.enterprise.gui.coregui.client;
import org.rhq.enterprise.gui.coregui.client.places.Place;
-import com.smartgwt.client.widgets.Canvas;
-
-import java.util.ArrayList;
import java.util.List;
/**
+ * @deprecated replaced by {@link ViewRenderer}
+ *
* @author Greg Hinkle
*/
+@Deprecated
public interface Presenter {
-
- boolean fireDisplay(Place place, List<Place> children);
-
+ boolean fireDisplay(Place baseLocation, List<Place> subLocations);
Place getPlace();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UnknownViewException.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UnknownViewException.java
new file mode 100644
index 0000000..8179b86
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UnknownViewException.java
@@ -0,0 +1,47 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client;
+
+/**
+ * TODO
+ *
+ * @author Ian Springer
+ */
+public class UnknownViewException extends Exception {
+ private ViewId viewId;
+ private String message;
+
+ public UnknownViewException(ViewId viewId) {
+ this(viewId, null);
+ }
+
+ public UnknownViewException(ViewId viewId, String message) {
+ this.viewId = viewId;
+ this.message = message;
+ }
+
+ @Override
+ public String getMessage() {
+ String message = "Unknown view id [" + this.viewId + "]";
+ if (this.message != null) {
+ message += ": " + this.message;
+ }
+ return message;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java
new file mode 100644
index 0000000..6c37f97
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/View.java
@@ -0,0 +1,81 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client;
+
+import com.smartgwt.client.widgets.Canvas;
+
+/**
+ * TODO
+ *
+ * @author Ian Springer
+ */
+public class View {
+ private ViewId id;
+ private Canvas canvas;
+ private Breadcrumb breadcrumb;
+
+ public View(ViewId id) {
+ this(id, null, null);
+ }
+
+ public View(ViewId id, Canvas canvas) {
+ this(id, canvas, null);
+ }
+
+ public View(ViewId id, Breadcrumb breadcrumb) {
+ this(id, null, breadcrumb);
+ }
+
+ public View(ViewId id, Canvas canvas, Breadcrumb breadcrumb) {
+ if (id == null) {
+ throw new IllegalArgumentException("Id is null.");
+ }
+ this.id = id;
+ if (breadcrumb != null) {
+ if (!breadcrumb.getName().equals(id.getName())) {
+ throw new IllegalArgumentException("Breadcrumb name is not equal to id name.");
+ }
+ this.breadcrumb = breadcrumb;
+ } else {
+ this.breadcrumb = new Breadcrumb(id.getName());
+ }
+ this.canvas = canvas;
+ }
+
+ public ViewId getId() {
+ return id;
+ }
+
+ public Canvas getCanvas() {
+ return canvas;
+ }
+
+ public Breadcrumb getBreadcrumb() {
+ return breadcrumb;
+ }
+
+ @Override
+ public String toString() {
+ return "View[" +
+ "id=" + id +
+ ", canvas=" + canvas +
+ ", breadcrumb=" + breadcrumb +
+ ']';
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
new file mode 100644
index 0000000..77c7dd6
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
@@ -0,0 +1,119 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author Ian Springer
+ */
+public class ViewId {
+ public static final char PATH_SEPARATOR = '/';
+ public static final ViewId ROOT_VIEW_ID = new ViewId("", null);
+
+ private String name;
+ private ViewId parent;
+ private String path;
+
+ public ViewId(String name, ViewId parent) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name is null.");
+ }
+ if (name.indexOf(PATH_SEPARATOR) >= 0) {
+ throw new IllegalArgumentException("Name contains illegal character '" + PATH_SEPARATOR + "'. ");
+ }
+ this.name = name;
+ this.parent = parent;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public ViewId getParent() {
+ return this.parent;
+ }
+
+ public String getPath() {
+ if (this.path == null) {
+ StringBuilder buffer = new StringBuilder();
+ List<String> names = new ArrayList<String>(5);
+ ViewId current = this;
+ do {
+ names.add(0, current.getName());
+ current = current.getParent();
+ } while (current != null && !current.getName().equals(ROOT_VIEW_ID.getName()));
+ boolean first = true;
+ for (String name : names) {
+ if (first) {
+ first = false;
+ } else {
+ buffer.append(PATH_SEPARATOR);
+ }
+ buffer.append(name);
+ }
+ this.path = buffer.toString();
+ }
+ return this.path;
+ }
+
+ /**
+ *
+ * @param viewId the id of some View that is an ancestor of the View represented by this id
+ * (i.e. the following must be true: this.getPath().startsWith(viewId.getPath())
+ * @return the path relative to the specified ancestral view id
+ */
+ public String getPathRelativeTo(ViewId viewId) {
+ if (viewId == null) {
+ throw new IllegalArgumentException("ViewId is null.");
+ }
+ if (!getPath().startsWith(viewId.getPath())) {
+ throw new IllegalArgumentException("ViewId [" + viewId + "] is not an ancestor of this ViewId [" + this + "]");
+ }
+ if (viewId.getName().equals(ViewId.ROOT_VIEW_ID.getName())) {
+ return getPath();
+ }
+ return getPath().substring(viewId.getPath().length() + 1);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ViewId viewId = (ViewId) o;
+
+ if (!getPath().equals(viewId.getPath())) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return getPath().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return getPath();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewRenderer.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewRenderer.java
new file mode 100644
index 0000000..f2eb39b
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewRenderer.java
@@ -0,0 +1,36 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client;
+
+/**
+ * TODO
+ *
+ * @author Ian Springer
+ */
+public interface ViewRenderer {
+ /**
+ * TODO
+ *
+ * @param parentView
+ * @param viewId
+ * @return
+ * @throws UnknownViewException
+ */
+ View renderView(View parentView, ViewId viewId) throws UnknownViewException;
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index 4a3ee93..455b00e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -18,10 +18,15 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin;
+import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
+import org.rhq.enterprise.gui.coregui.client.UnknownViewException;
+import org.rhq.enterprise.gui.coregui.client.View;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewRenderer;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Presenter;
+import org.rhq.enterprise.gui.coregui.client.admin.report.InventorySummaryReportView;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
-import org.rhq.enterprise.gui.coregui.client.admin.users.UserEditView;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
import org.rhq.enterprise.gui.coregui.client.places.Place;
@@ -30,7 +35,6 @@ import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.HTMLPane;
-import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionEvent;
import com.smartgwt.client.widgets.layout.HLayout;
@@ -41,17 +45,19 @@ import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeNode;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
*
* @author Greg Hinkle
*/
-public class AdministrationView extends HLayout implements Presenter {
+public class AdministrationView extends HLayout implements Presenter, ViewRenderer {
private SectionStack sectionStack;
private Canvas contentCanvas;
+ private List<TreeGrid> treeGrids;
@Override
protected void onInit() {
@@ -60,35 +66,33 @@ public class AdministrationView extends HLayout implements Presenter {
setWidth100();
setHeight100();
-
contentCanvas = new Canvas();
contentCanvas.setWidth("*");
contentCanvas.setHeight100();
-
sectionStack = new SectionStack();
sectionStack.setShowResizeBar(true);
sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
sectionStack.setWidth(250);
sectionStack.setHeight100();
+ this.treeGrids = new ArrayList<TreeGrid>(5);
sectionStack.addSection(buildSecuritySection());
sectionStack.addSection(buildPluginsSection());
sectionStack.addSection(buildManagementClusterSection());
sectionStack.addSection(buildSystemConfigurationSection());
+ sectionStack.addSection(buildReportsSection());
addMember(sectionStack);
addMember(contentCanvas);
-
- setContent(buildLanding());
- CoreGUI.setBreadCrumb(getPlace());
+ setContent(buildLanding());
}
private HTMLFlow buildLanding() {
String contents = "<h1>Administration</h1>\n" +
- "From this section, the RHQ global settings can be administered. This includeds configuring \n" +
+ "From this section, the RHQ global settings can be administered. This includes configuring \n" +
"<a href=\"\">Security</a>, setting up <a href=\"\">Plugins</a> and other stuff.";
HTMLFlow flow = new HTMLFlow(contents);
flow.setPadding(20);
@@ -100,8 +104,9 @@ public class AdministrationView extends HLayout implements Presenter {
final SectionStackSection section = new SectionStackSection("Security");
section.setExpanded(true);
- TreeGrid treeGrid = new TreeGrid();
- treeGrid.setShowHeader(false);
+ final TreeGrid securityTreeGrid = new TreeGrid();
+ securityTreeGrid.setShowHeader(false);
+ this.treeGrids.add(securityTreeGrid);
Tree tree = new Tree();
final TreeNode manageUsersNode = new TreeNode("Manage Users");
@@ -112,24 +117,28 @@ public class AdministrationView extends HLayout implements Presenter {
manageRolesNode,
manageGroups));
- treeGrid.setData(tree);
-
+ securityTreeGrid.setData(tree);
- treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ securityTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getRecord() == manageUsersNode) {
- setContent(new UsersView());
- } else if (selectionEvent.getRecord() == manageRolesNode) {
- setContent(new RolesView());
- } else if (selectionEvent.getRecord() == manageGroups) {
- setContent(new RolesView());
+ if (selectionEvent.getState()) {
+ if (selectionEvent.getRecord() == manageUsersNode) {
+ setContent(new UsersView());
+ } else if (selectionEvent.getRecord() == manageRolesNode) {
+ setContent(new RolesView());
+ } else if (selectionEvent.getRecord() == manageGroups) {
+ setContent(new RolesView());
+ }
+ for (TreeGrid treeGrid : treeGrids) {
+ if (treeGrid != securityTreeGrid) {
+ treeGrid.deselectAllRecords();
+ }
+ }
}
}
});
-
- section.addItem(treeGrid);
-
+ section.addItem(securityTreeGrid);
return section;
}
@@ -139,8 +148,9 @@ public class AdministrationView extends HLayout implements Presenter {
final SectionStackSection section = new SectionStackSection("Management Cluster");
section.setExpanded(true);
- TreeGrid treeGrid = new TreeGrid();
- treeGrid.setShowHeader(false);
+ final TreeGrid mgmtClusterTreeGrid = new TreeGrid();
+ mgmtClusterTreeGrid.setShowHeader(false);
+ this.treeGrids.add(mgmtClusterTreeGrid);
Tree tree = new Tree();
final TreeNode manageServersNode = new TreeNode("Servers");
@@ -154,34 +164,38 @@ public class AdministrationView extends HLayout implements Presenter {
manageAffinityGroupsNode,
managePartitionEventsNode));
- treeGrid.setData(tree);
+ mgmtClusterTreeGrid.setData(tree);
-
- treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ mgmtClusterTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
- HTMLPane pane = new HTMLPane();
- pane.setContentsType(ContentsType.PAGE);
- pane.setWidth100();
- pane.setHeight100();
-
- String url = null;
- if (selectionEvent.getRecord() == manageServersNode) {
- url = "/rhq/ha/listServers.xhtml";
- } else if (selectionEvent.getRecord() == manageAgentsNode) {
- url = "/rhq/ha/listAgents.xhtml";
- } else if (selectionEvent.getRecord() == manageAffinityGroupsNode) {
- url = "/rhq/ha/listAffinityGroups.xhtml";
- } else if (selectionEvent.getRecord() == managePartitionEventsNode) {
- url = "/rhq/ha/listPartitionEvents.xhtml";
+ if (selectionEvent.getState()) {
+ HTMLPane pane = new HTMLPane();
+ pane.setContentsType(ContentsType.PAGE);
+ pane.setWidth100();
+ pane.setHeight100();
+
+ String url = null;
+ if (selectionEvent.getRecord() == manageServersNode) {
+ url = "/rhq/ha/listServers.xhtml";
+ } else if (selectionEvent.getRecord() == manageAgentsNode) {
+ url = "/rhq/ha/listAgents.xhtml";
+ } else if (selectionEvent.getRecord() == manageAffinityGroupsNode) {
+ url = "/rhq/ha/listAffinityGroups.xhtml";
+ } else if (selectionEvent.getRecord() == managePartitionEventsNode) {
+ url = "/rhq/ha/listPartitionEvents.xhtml";
+ }
+ pane.setContentsURL(url + "?nomenu=true");
+ setContent(pane);
+ for (TreeGrid treeGrid : treeGrids) {
+ if (treeGrid != mgmtClusterTreeGrid) {
+ treeGrid.deselectAllRecords();
+ }
+ }
}
- pane.setContentsURL(url + "?nomenu=true");
- setContent(pane);
-
}
});
-
- section.addItem(treeGrid);
+ section.addItem(mgmtClusterTreeGrid);
return section;
}
@@ -190,8 +204,9 @@ public class AdministrationView extends HLayout implements Presenter {
final SectionStackSection section = new SectionStackSection("Plugins");
section.setExpanded(true);
- TreeGrid treeGrid = new TreeGrid();
- treeGrid.setShowHeader(false);
+ final TreeGrid pluginsTreeGrid = new TreeGrid();
+ pluginsTreeGrid.setShowHeader(false);
+ this.treeGrids.add(pluginsTreeGrid);
Tree tree = new Tree();
final TreeNode managePlugins = new TreeNode("Plugins");
@@ -199,27 +214,32 @@ public class AdministrationView extends HLayout implements Presenter {
tree.setRoot(new TreeNode("clustering",
managePlugins));
- treeGrid.setData(tree);
-
+ pluginsTreeGrid.setData(tree);
- treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ pluginsTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
- HTMLPane pane = new HTMLPane();
- pane.setContentsType(ContentsType.PAGE);
- pane.setWidth100();
- pane.setHeight100();
-
- String url = null;
- if (selectionEvent.getRecord() == managePlugins) {
- url = "/rhq/admin/plugin/plugin-list.xhtml";
+ if (selectionEvent.getState()) {
+ HTMLPane pane = new HTMLPane();
+ pane.setContentsType(ContentsType.PAGE);
+ pane.setWidth100();
+ pane.setHeight100();
+
+ String url = null;
+ if (selectionEvent.getRecord() == managePlugins) {
+ url = "/rhq/admin/plugin/plugin-list.xhtml";
+ }
+ pane.setContentsURL(url + "?nomenu=true");
+ setContent(pane);
+ for (TreeGrid treeGrid : treeGrids) {
+ if (treeGrid != pluginsTreeGrid) {
+ treeGrid.deselectAllRecords();
+ }
+ }
}
- pane.setContentsURL(url + "?nomenu=true");
- setContent(pane);
}
});
- section.addItem(treeGrid);
-
+ section.addItem(pluginsTreeGrid);
return section;
}
@@ -229,40 +249,85 @@ public class AdministrationView extends HLayout implements Presenter {
final SectionStackSection section = new SectionStackSection("System Configuration");
section.setExpanded(true);
- TreeGrid treeGrid = new TreeGrid();
- treeGrid.setShowHeader(false);
+ final TreeGrid systemConfigTreeGrid = new TreeGrid();
+ systemConfigTreeGrid.setShowHeader(false);
+ this.treeGrids.add(systemConfigTreeGrid);
Tree tree = new Tree();
final TreeNode manageSettings = new TreeNode("System Settings");
final TreeNode manageTemplates = new TreeNode("Templates");
final TreeNode manageLicense = new TreeNode("License");
- tree.setRoot(new TreeNode("clustering",
+ tree.setRoot(new TreeNode("System Configuration",
manageSettings, manageTemplates, manageLicense));
- treeGrid.setData(tree);
+ systemConfigTreeGrid.setData(tree);
- treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ systemConfigTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
- HTMLPane pane = new HTMLPane();
- pane.setContentsType(ContentsType.PAGE);
- pane.setWidth100();
- pane.setHeight100();
-
- String url = null;
- if (selectionEvent.getRecord() == manageSettings) {
- url = "/admin/config/Config.do?mode=edit";
- } else if (selectionEvent.getRecord() == manageTemplates) {
- url = "/admin/config/EditDefaults.do?mode=monitor&viewMode=all";
+ if (selectionEvent.getState()) {
+ HTMLPane pane = new HTMLPane();
+ pane.setContentsType(ContentsType.PAGE);
+ pane.setWidth100();
+ pane.setHeight100();
+
+ String url = null;
+ if (selectionEvent.getRecord() == manageSettings) {
+ url = "/admin/config/Config.do?mode=edit";
+ } else if (selectionEvent.getRecord() == manageTemplates) {
+ url = "/admin/config/EditDefaults.do?mode=monitor&viewMode=all";
+ }
+
+ pane.setContentsURL(url + "&nomenu=true");
+ setContent(pane);
+ for (TreeGrid treeGrid : treeGrids) {
+ if (treeGrid != systemConfigTreeGrid) {
+ treeGrid.deselectAllRecords();
+ }
+ }
}
+ }
+ });
- pane.setContentsURL(url + "&nomenu=true");
- setContent(pane);
+ section.addItem(systemConfigTreeGrid);
+
+ return section;
+ }
+
+ private SectionStackSection buildReportsSection() {
+ final SectionStackSection section = new SectionStackSection("Reports");
+ section.setID("Reports");
+ section.setExpanded(true);
+
+ final TreeGrid reportsTreeGrid = new TreeGrid();
+ reportsTreeGrid.setShowHeader(false);
+ this.treeGrids.add(reportsTreeGrid);
+
+ Tree tree = new Tree();
+ final TreeNode inventorySummaryNode = new TreeNode("Inventory Summary");
+
+ TreeNode reportsNode = new TreeNode("Reports", inventorySummaryNode);
+ tree.setRoot(reportsNode);
+
+ reportsTreeGrid.setData(tree);
+
+ reportsTreeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ if (selectionEvent.getState()) {
+ HTMLPane pane = new InventorySummaryReportView();
+ setContent(pane);
+ CoreGUI.goTo(InventorySummaryReportView.PATH);
+ for (TreeGrid treeGrid : treeGrids) {
+ if (treeGrid != reportsTreeGrid) {
+ treeGrid.deselectAllRecords();
+ }
+ }
+ }
}
});
- section.addItem(treeGrid);
+ section.addItem(reportsTreeGrid);
return section;
}
@@ -279,11 +344,66 @@ public class AdministrationView extends HLayout implements Presenter {
}
- public boolean fireDisplay(Place place, List<Place> children) {
- return place.equals(getPlace());
+ public boolean fireDisplay(Place base, List<Place> subLocations) {
+ try {
+ if (base.equals(getPlace())) {
+ if (!subLocations.isEmpty()) {
+ Place child = subLocations.get(0);
+ String childId = child.getId();
+ if (childId.equals("Reports")) {
+ if (subLocations.size() >= 2) {
+ Place grandchild = subLocations.get(1);
+ String grandchildId = grandchild.getId();
+ if (grandchildId.equals("InventorySummary")) {
+ HTMLPane pane = new InventorySummaryReportView();
+ setContent(pane);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.err.println(e);
+ }
+ return false;
}
public Place getPlace() {
return new Place("Administration", "Administration");
}
+
+ public List<Breadcrumb> render(List<String> breadcrumbNames) {
+ if (breadcrumbNames == null || breadcrumbNames.size() < 2) {
+ return Collections.emptyList();
+ }
+ List<Breadcrumb> renderedBreadcrumbs = new ArrayList<Breadcrumb>(breadcrumbNames.size());
+ String firstBreadcrumbName = breadcrumbNames.get(0);
+ if (firstBreadcrumbName.equals("Reports")) {
+ String secondBreadcrumbName = breadcrumbNames.get(1);
+ if (secondBreadcrumbName.equals("InventorySummary")) {
+ HTMLPane pane = new InventorySummaryReportView();
+ setContent(pane);
+ renderedBreadcrumbs.add(new Breadcrumb("Reports"));
+ renderedBreadcrumbs.add(new Breadcrumb("InventorySummary"));
+ }
+ }
+ return renderedBreadcrumbs;
+ }
+
+ public View renderView(View parentView, ViewId viewId) throws UnknownViewException {
+ String parentPath = viewId.getParent().getPath();
+ if (parentPath.equals("Administration")) {
+ SectionStackSection stackSection = this.sectionStack.getSection(viewId.getName());
+ if (stackSection != null) {
+ stackSection.setExpanded(true);
+ return new View(viewId, new Breadcrumb(viewId.getName(), false));
+ }
+ } else if (parentPath.equals("Administration/Reports")) {
+ InventorySummaryReportView canvas = new InventorySummaryReportView();
+ setContent(canvas);
+ return new View(viewId, canvas);
+ }
+ throw new UnknownViewException(viewId);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/report/InventorySummaryReportView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/report/InventorySummaryReportView.java
new file mode 100644
index 0000000..1faeba5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/report/InventorySummaryReportView.java
@@ -0,0 +1,35 @@
+package org.rhq.enterprise.gui.coregui.client.admin.report;
+
+import com.smartgwt.client.types.ContentsType;
+import com.smartgwt.client.widgets.HTMLPane;
+import org.rhq.enterprise.gui.coregui.client.BreadCrumb;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.Presenter;
+import org.rhq.enterprise.gui.coregui.client.places.Place;
+
+import java.util.List;
+
+/**
+ * @author Ian Springer
+ */
+public class InventorySummaryReportView extends HTMLPane implements Presenter {
+ public static final String PATH = "Administration/Reports/InventorySummary";
+ public static final Place PLACE = new Place(PATH.substring(PATH.lastIndexOf('/') + 1), null);
+ private static final String URL = "/rhq/admin/report/resourceInstallReport-body.xhtml";
+
+ public InventorySummaryReportView() {
+ super();
+ setContentsType(ContentsType.PAGE);
+ setWidth100();
+ setHeight100();
+ setContentsURL(URL);
+ }
+
+ public boolean fireDisplay(Place base, List<Place> subLocations) {
+ return false;
+ }
+
+ public Place getPlace() {
+ return PLACE;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
index ab78f58..bc88bad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
@@ -152,8 +152,8 @@ public class RolesView extends VLayout implements Presenter {
}
- public boolean fireDisplay(Place place, List<Place> children) {
- if (!getPlace().equals(place)) {
+ public boolean fireDisplay(Place base, List<Place> subLocations) {
+ if (!getPlace().equals(base)) {
return false;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index 1c2b183..b6757ea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -159,12 +159,12 @@ public class UsersView extends SectionStack implements Presenter {
}
- public boolean fireDisplay(Place place, List<Place> children) {
- if (!place.equals(getPlace())) {
+ public boolean fireDisplay(Place base, List<Place> subLocations) {
+ if (!base.equals(getPlace())) {
return false;
}
- if (children.size() > 0) {
- int userId = Integer.parseInt(children.get(0).getId());
+ if (subLocations.size() > 0) {
+ int userId = Integer.parseInt(subLocations.get(0).getId());
}
return true;
}
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 4f78085..ba07d21 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
@@ -25,18 +25,14 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitorin
import org.rhq.enterprise.gui.coregui.client.places.Place;
import com.google.gwt.user.client.Random;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.AnimationCallback;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.layout.VLayout;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -44,7 +40,6 @@ import java.util.List;
*/
public class DashboardView extends VLayout implements Presenter {
-
private static String[] colors = new String[]{
"FF6600", "808000", "008000", "008080", "0000FF", "666699",
"FF0000", "FF9900", "99CC00", "339966", "33CCCC", "3366FF",
@@ -193,8 +188,8 @@ public class DashboardView extends VLayout implements Presenter {
}
- public boolean fireDisplay(Place place, List<Place> children) {
- return place.equals(getPlace());
+ public boolean fireDisplay(Place base, List<Place> subLocations) {
+ return base.equals(getPlace());
}
public Place getPlace() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourcesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourcesView.java
index ec5bea4..b3bf91f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourcesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourcesView.java
@@ -21,9 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource;
import org.rhq.core.domain.resource.Resource;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Presenter;
-import org.rhq.enterprise.gui.coregui.client.admin.users.UserEditView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceDetailView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceView;
import org.rhq.enterprise.gui.coregui.client.places.Place;
import com.smartgwt.client.types.ContentsType;
@@ -39,7 +36,6 @@ import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeNode;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -47,10 +43,11 @@ import java.util.List;
*/
public class ResourcesView extends HLayout implements Presenter {
+ public static final String VIEW_PATH = "Resources";
+
private SectionStack sectionStack;
private Canvas contentCanvas;
-
@Override
protected void onInit() {
super.onInit();
@@ -58,12 +55,10 @@ public class ResourcesView extends HLayout implements Presenter {
setWidth100();
setHeight100();
-
contentCanvas = new Canvas();
contentCanvas.setWidth("*");
contentCanvas.setHeight100();
-
sectionStack = new SectionStack();
sectionStack.setShowResizeBar(true);
sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
@@ -77,8 +72,6 @@ public class ResourcesView extends HLayout implements Presenter {
addMember(contentCanvas);
setContent(buildResourceSearchView());
-
- CoreGUI.setBreadCrumb(getPlace());
}
@@ -86,7 +79,8 @@ public class ResourcesView extends HLayout implements Presenter {
ResourceSearchView searchView = new ResourceSearchView();
searchView.addResourceSelectedListener(new ResourceSelectListener() {
public void onResourceSelected(Resource resource) {
- CoreGUI.setContent(new ResourceView(resource));
+ //CoreGUI.setContent(new ResourceView(resource));
+ CoreGUI.goTo("Resource/" + resource.getId());
}
});
return searchView;
@@ -190,13 +184,13 @@ public class ResourcesView extends HLayout implements Presenter {
}
- public boolean fireDisplay(Place place, List<Place> children) {
- if (place.equals(getPlace())) {
- if (!children.isEmpty()) {
+ public boolean fireDisplay(Place base, List<Place> subLocations) {
+ if (base.equals(getPlace())) {
+ if (!subLocations.isEmpty()) {
if (contentCanvas.getChildren().length > 0) {
Canvas element = contentCanvas.getChildren()[0];
if (element instanceof Presenter) {
- ((Presenter) element).fireDisplay(children.get(0), children.subList(1, children.size() - 1));
+ ((Presenter) element).fireDisplay(subLocations.get(0), subLocations.subList(1, subLocations.size() - 1));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
index 5fe42be..178043d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/CustomResourceTreeGrid.java
@@ -20,7 +20,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.widgets.tree.TreeGrid;
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 0e2a101..f97a858 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
@@ -30,16 +30,13 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitorin
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.places.Place;
-import com.smartgwt.client.types.ContentsType;
import com.smartgwt.client.types.Side;
import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.HTMLPane;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.List;
/**
@@ -78,13 +75,10 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe
setWidth100();
setHeight100();
-
-
// The header section
summaryView = new ResourceSummaryView();
summaryPanel = new SimpleCollapsiblePanel("Summary", summaryView);
-
// The Tabs section
topTabSet = new TabSet();
@@ -94,7 +88,6 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe
topTabSet.setEdgeMarginSize(0);
topTabSet.setEdgeSize(0);
-
summaryTab = new Tab("Summary", "/images/icons/Service_up_16.png");
monitoringTab = new Tab("Monitoring", "/images/icons/Monitor_grey_16.png");
inventoryTab = new Tab("Inventory", "/images/icons/Inventory_grey_16.png");
@@ -104,7 +97,6 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe
eventsTab = new Tab("Events", "/images/icons/Events_grey_16.png");
contentTab = new Tab("Content", "/images/icons/Content_grey_16.png");
-
topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab, alertsTab, configurationTab, eventsTab, contentTab);
title.setContents("Loading...");
@@ -118,9 +110,8 @@ public class ResourceDetailView extends VLayout implements Presenter, ResourceSe
}
- public boolean fireDisplay(Place place, List<Place> children) {
- if (place.equals(getPlace())) {
-
+ public boolean fireDisplay(Place base, List<Place> subLocations) {
+ if (base.equals(getPlace())) {
}
return true;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 37ad015..dce0409 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -279,11 +279,18 @@ public class ResourceTreeView extends VLayout {
importChildMenu.setEnabled(importChildSubMenu.getItems().length > 0);
contextMenu.addItem(importChildMenu);
-
-
-
}
+ Resource getResource(int resourceId) {
+ if (this.treeGrid != null && this.treeGrid.getTree() != null) {
+ ResourceTreeDatasource.ResourceTreeNode treeNode =
+ (ResourceTreeDatasource.ResourceTreeNode) this.treeGrid.getTree().findById(String.valueOf(resourceId));
+ if (treeNode != null) {
+ return treeNode.getResource();
+ }
+ }
+ return null;
+ }
public void setSelectedResource(final Resource selectedResource) {
this.selectedResource = selectedResource;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
index 0299905..aa1f7a9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceView.java
@@ -21,11 +21,16 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.Breadcrumb;
+import org.rhq.enterprise.gui.coregui.client.UnknownViewException;
+import org.rhq.enterprise.gui.coregui.client.View;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewRenderer;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Presenter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourcesView;
import org.rhq.enterprise.gui.coregui.client.places.Place;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -38,14 +43,12 @@ import java.util.List;
/**
* @author Greg Hinkle
*/
-public class ResourceView extends HLayout implements Presenter {
+public class ResourceView extends HLayout implements Presenter, ViewRenderer {
private Canvas contentCanvas;
-
private Resource selectedResource;
- private Resource resourcePlatform;
-
+ //private Resource resourcePlatform;
private ResourceTreeView treeView;
private ResourceDetailView detailView;
@@ -60,7 +63,7 @@ public class ResourceView extends HLayout implements Presenter {
public ResourceView(Resource selectedResource) {
this.selectedResource = selectedResource;
- System.out.println("displaying resource: " + selectedResource);
+ System.out.println("Displaying Resource: " + selectedResource);
}
@Override
@@ -87,15 +90,15 @@ public class ResourceView extends HLayout implements Presenter {
}
- public boolean fireDisplay(Place place, List<Place> children) {
+ public boolean fireDisplay(Place base, List<Place> subLocations) {
try {
- if (place.equals(getPlace())) {
- if (children.size() > 0) {
- Place resourcePlace = children.get(0);
+ if (base.equals(getPlace())) {
+ if (subLocations.size() > 0) {
+ Place resourcePlace = subLocations.get(0);
int resourceId = Integer.parseInt(resourcePlace.getId());
if (selectedResource == null || selectedResource.getId() != resourceId) {
- setSelectedResource(resourceId);
+ setSelectedResource(resourceId, null);
}
}
return true;
@@ -108,27 +111,40 @@ public class ResourceView extends HLayout implements Presenter {
}
+ public void setSelectedResource(final int resourceId, final ViewId viewId) {
+ Resource resource = this.treeView.getResource(resourceId);
+ if (resource != null) {
+ setSelectedResource(resource);
+ CoreGUI.updateBreadCrumbDisplayName(viewId, resource.getName());
+ } else {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterId(resourceId);
+ resourceService.findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() {
+ public void onFailure(Throwable caught) {
+ SC.say("Failed to load Resource with id " + resourceId + ": " + caught);
+ // TODO: Display this error in a red box at top of page instead?
+ CoreGUI.goTo(ResourcesView.VIEW_PATH);
+ }
- public void setSelectedResource(int resourceId) {
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.addFilterId(resourceId);
- resourceService.findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() {
- public void onFailure(Throwable caught) {
- SC.say("failed to load");
- }
-
- public void onSuccess(PageList<Resource> result) {
- Resource res = result.get(0);
- setSelectedResource(res);
- }
- });
+ public void onSuccess(PageList<Resource> result) {
+ if (result.isEmpty()) {
+ //noinspection ThrowableInstanceNeverThrown
+ onFailure(new Exception("Resource with id [" + resourceId + "] does not exist."));
+ } else {
+ Resource resource = result.get(0);
+ setSelectedResource(resource);
+ CoreGUI.updateBreadCrumbDisplayName(viewId, resource.getName());
+ }
+ }
+ });
+ }
}
public void setSelectedResource(Resource resource) {
this.selectedResource = resource;
- treeView.setSelectedResource(resource);
- detailView.onResourceSelected(resource);
+ this.treeView.setSelectedResource(resource);
+ this.detailView.onResourceSelected(resource);
}
@@ -143,4 +159,22 @@ public class ResourceView extends HLayout implements Presenter {
contentCanvas.addChild(newContent);
contentCanvas.draw();
}
+
+ public View renderView(View parentView, ViewId viewId) throws UnknownViewException {
+ String path = viewId.getPathRelativeTo(parentView.getId());
+ int resourceId;
+ try {
+ resourceId = Integer.parseInt(path);
+ } catch (NumberFormatException e) {
+ // not a valid Resource id - nothing for us to do
+ throw new UnknownViewException(viewId, "Invalid Resource id [" + path + "]");
+ }
+ if (this.selectedResource == null || this.selectedResource.getId() != resourceId) {
+ setSelectedResource(resourceId, viewId);
+ }
+ // Use "..." as temporary display name for breadcrumb. If the Resource is fetched successfully, the display name
+ // will be updated to be the Resource's name.
+ Breadcrumb breadcrumb = new Breadcrumb(viewId.getName(), "...");
+ return new View(viewId, this.detailView, breadcrumb);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
index df284fa..2c3a254 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
@@ -29,7 +29,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectLi
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.rpc.core.java.util.Arrays;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.VLayout;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/places/Place.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/places/Place.java
index 4e6a086..cb63156 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/places/Place.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/places/Place.java
@@ -19,8 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.places;
/**
+ * @deprecated replaced by {@link org.rhq.enterprise.gui.coregui.client.View} and
+ * {@link org.rhq.enterprise.gui.coregui.client.Breadcrumb}
+ *
* @author Greg Hinkle
*/
+@Deprecated
public class Place {
private String id;
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
index 7211bc6..2011c8c 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
@@ -106,7 +106,7 @@ a:hover {
.BreadCrumb {
font-size: 12pt;
- font-weidght: bold;
+ font-weight: bold;
text-decoration: none;
color: darkgray;
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml
new file mode 100644
index 0000000..65ce5ee
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/report/resourceInstallReport-body.xhtml
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+
+<ui:composition
+ template="/rhq/layout/main.xhtml"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:fn="http://java.sun.com/jsp/jstl/functions"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:rhq="http://rhq-project.org/rhq"
+ xmlns:onc="http://jboss.org/on/component">
+
+ <ui:param name="pageTitle" value="Resource Version Inventory Report"/>
+ <ui:param name="disableMenu" value="true"/>
+ <ui:param name="disableBreadcrumbs" value="true"/>
+
+ <ui:define name="body">
+
+ <rich:panel>
+ <f:facet name="header">
+ <h:outputText value="Resource Version Inventory Report"/>
+ </f:facet>
+
+ <h:panelGrid columns="1" width="100%">
+
+ <h:form>
+ <h:selectBooleanCheckbox id="groupByVersion" value="#{ResourceInstallReportUIBean.groupByVersion}"
+ label="gbvLabel">
+ <a4j:support reRender="reportTable" event="onclick" status="commonStatus"/>
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Group By Version" id="gbvLabel"/>
+
+ <rich:dataTable
+ id="reportTable"
+ value="#{ResourceInstallReportUIBean.resourceInstallCounts}"
+ var="installReport"
+ width="100%"
+ columnsWidth="15%, 15%, 10%, 10%, 10%"
+ headerClass="tableRowHeader"
+ footerClass="on-pager-footer"
+ onRowMouseOver="this.style.backgroundColor='#E7E7E7'"
+ onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
+
+ <rich:column title="Type">
+ <f:facet name="header">
+ Type
+ </f:facet>
+ <h:outputLink value="#Resources" target="_top">
+ <h:outputText value="#{installReport.typeName}"/>
+ </h:outputLink>
+ </rich:column>
+
+ <rich:column title="Plugin">
+ <f:facet name="header">
+ Plugin
+ </f:facet>
+ <h:outputText value="#{installReport.typePlugin}"/>
+ </rich:column>
+
+ <rich:column title="Category">
+ <f:facet name="header">
+ Category
+ </f:facet>
+ <h:outputText value="#{installReport.category}"/>
+ </rich:column>
+
+ <rich:column title="Version" rendered="#{ResourceInstallReportUIBean.groupByVersion}">
+ <f:facet name="header">
+ Version
+ </f:facet>
+ <h:outputText value="#{installReport.version}"/>
+ </rich:column>
+
+ <rich:column title="Imported Count">
+ <f:facet name="header">
+ Imported Count
+ </f:facet>
+ <h:outputText value="#{installReport.count}"/>
+ </rich:column>
+
+ </rich:dataTable>
+ </h:form>
+
+ </h:panelGrid>
+
+ </rich:panel>
+
+ </ui:define>
+
+</ui:composition>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main-layout.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main-layout.xhtml
index dc5c95b..a210bb2 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main-layout.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main-layout.xhtml
@@ -98,7 +98,7 @@ Firefox and other Gecko-based browsers to render the page in "Almost Standards"
<div id="PageHeader" style="border-bottom: 2px solid #999; position: absolute; top: 0; bottom: 0; left: 0; right: 0;">
<!--<![endif]-->
- <c:if test="${empty param.nomenu}">
+ <c:if test="${empty param.nomenu and empty disableMenu}">
<ui:include src="/rhq/common/menu/menu.xhtml"/>
</c:if>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main.xhtml
index 78ea9d7..3d034e6 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/layout/main.xhtml
@@ -16,9 +16,9 @@
<ui:define name="body-area">
<div id="content-full" style="width: 100%; height: 100%; overflow: auto;">
- <div id="Breadcrumb">
+ <h:panelGroup id="Breadcrumb" layout="block" rendered="#{empty disableBreadcrumbs}">
<ui:insert name="breadcrumbs">Default Full Screen Content</ui:insert>
- </div>
+ </h:panelGroup>
<p />
<ui:insert name="body">Default Full Screen Body</ui:insert>
</div>
14 years, 2 months
[rhq] Branch 'alertPlugin' - modules/enterprise
by jharris
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 15ff7e397d9a01af13937c7d806679918e2dda7d
Author: Justin Harris <jharris(a)redhat.com>
Date: Mon Mar 1 11:26:37 2010 -0500
BZ 568796 - Changing input length on metric baseline % field.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml
index 2000efd..668d175 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml
@@ -372,7 +372,8 @@
converter="#{metricPercentConverter}"
required="true"
requiredMessage="#{alertMessages.percentRange}"
- validatorMessage="#{alertMessages.percentRange}">
+ validatorMessage="#{alertMessages.percentRange}"
+ size="6">
<f:validateDoubleRange minimum="0.0" maximum="1000.0" />
</h:inputText>
<h:outputLabel for="metricBaselinePercent" value=" #{messages['alert.config.props.CB.Content.Percent']} " />
14 years, 2 months
[rhq] Branch 'bundle' - modules/core modules/plugins
by mazz
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java | 11 --
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java | 52 ++++++++++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 22 ----
modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java | 5
4 files changed, 62 insertions(+), 28 deletions(-)
New commits:
commit 007fe3b4708ebeb2953b0dd8482b02d1f558993a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 1 10:12:52 2010 -0500
remove circular dep - plugin api should never dep on pc module
introduct new bundle manager provider interface that plugins will use to callback into the PC bundle manager
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java
index 40e663b..2dd6e6d 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleDeployRequest.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,6 @@ package org.rhq.core.pluginapi.bundle;
import java.io.Serializable;
import org.rhq.core.domain.bundle.BundleDeployDefinition;
-import org.rhq.core.pc.bundle.BundleManager;
/**
* A request to deploy a bundle.
@@ -33,7 +32,7 @@ public class BundleDeployRequest implements Serializable {
private static final long serialVersionUID = 1L;
private BundleDeployDefinition bundleDeployDefinition;
- private BundleManager bundleManager;
+ private BundleManagerProvider bundleManager;
public BundleDeployDefinition getBundleDeployDefinition() {
return bundleDeployDefinition;
@@ -43,12 +42,12 @@ public class BundleDeployRequest implements Serializable {
this.bundleDeployDefinition = bundleDeployDefinition;
}
- public BundleManager getBundleManager() {
+ public BundleManagerProvider getBundleManagerProvider() {
return bundleManager;
}
- public void setBundleManager(BundleManager bundleManager) {
- this.bundleManager = bundleManager;
+ public void setBundleManagerProvider(BundleManagerProvider provider) {
+ this.bundleManager = provider;
}
}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
new file mode 100644
index 0000000..d06561f
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleManagerProvider.java
@@ -0,0 +1,52 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.pluginapi.bundle;
+
+import java.io.OutputStream;
+import java.util.List;
+
+import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.content.PackageVersion;
+
+/**
+ * Provides bundle functionality that plugin components will need in order to process bundles.
+ *
+ * @author John Mazzitelli
+ */
+public interface BundleManagerProvider {
+ /**
+ * Bndle plugins call back into this manager to obtain the bundle files that belong to a given bundle version.
+ *
+ * @param bundleVersion
+ * @return the bundle files that are associated with the given bundle
+ * @throws Exception
+ */
+ List<PackageVersion> getAllBundleVersionPackageVersions(BundleVersion bundleVersion) throws Exception;
+
+ /**
+ * Bundle plugins call back into this manager to obtain the bundle file content for the given package.
+ *
+ * @param packageVersion the package whose bits are to be downloaded
+ * @param outputStream where the package bits will get written to
+ * @return the size of the package version content that was downloaded and output
+ * @throws Exception
+ */
+ long getFileContent(PackageVersion packageVersion, OutputStream outputStream) throws Exception;
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index 6f6eed5..5db906f 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -50,6 +50,7 @@ import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
+import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
/**
* Manages the bundle subsystem, which allows bundles of content to be installed.
@@ -58,7 +59,7 @@ import org.rhq.core.pluginapi.bundle.BundleFacet;
*
* @author John Mazzitelli
*/
-public class BundleManager extends AgentService implements BundleAgentService, ContainerService {
+public class BundleManager extends AgentService implements BundleAgentService, BundleManagerProvider, ContainerService {
private final Log log = LogFactory.getLog(BundleManager.class);
private PluginContainerConfiguration configuration;
@@ -99,7 +100,7 @@ public class BundleManager extends AgentService implements BundleAgentService, C
// deploy the bundle utilizing the bundle facet object
BundleDeployRequest deployRequest = new BundleDeployRequest();
- deployRequest.setBundleManager(this);
+ deployRequest.setBundleManagerProvider(this);
deployRequest.setBundleDeployDefinition(request.getBundleDeployDefinition());
BundleDeployResult result = bundlePluginComponent.deployBundle(deployRequest);
if (!result.isSuccess()) {
@@ -113,29 +114,12 @@ public class BundleManager extends AgentService implements BundleAgentService, C
return response;
}
- /**
- * This is used by bundle plugins - bundle plugins call back into this manager to obtain the
- * bundle files that belong to a given bundle version.
- *
- * @param bundleVersion
- * @return the bundle files that are associated with the given bundle
- * @throws Exception
- */
public List<PackageVersion> getAllBundleVersionPackageVersions(BundleVersion bundleVersion) throws Exception {
int bvId = bundleVersion.getId();
List<PackageVersion> pvs = getBundleServerService().getAllBundleVersionPackageVersions(bvId);
return pvs;
}
- /**
- * This is used by bundle plugins - bundle plugins call back into this manager to obtain the
- * bundle file content for the given package.
- *
- * @param packageVersion the package whose bits are to be downloaded
- * @param outputStream where the package bits will get written to
- * @return the size of the package version content that was downloaded and output
- * @throws Exception
- */
public long getFileContent(PackageVersion packageVersion, OutputStream outputStream) throws Exception {
long size = getBundleServerService().downloadPackageBits(packageVersion, outputStream);
return size;
diff --git a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
index d8ac092..a1320ad 100644
--- a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
+++ b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/FileTemplateBundlePluginServerComponent.java
@@ -30,10 +30,10 @@ import org.rhq.core.domain.bundle.BundleDeployDefinition;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pc.bundle.BundleManager;
import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
+import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.util.MessageDigestGenerator;
@@ -59,7 +59,6 @@ public class FileTemplateBundlePluginServerComponent implements ResourceComponen
return AvailabilityType.UP;
}
- @Override
public BundleDeployResult deployBundle(BundleDeployRequest request) {
BundleDeployResult result = new BundleDeployResult();
try {
@@ -68,7 +67,7 @@ public class FileTemplateBundlePluginServerComponent implements ResourceComponen
// download all the bundle files to our tmp directory
File tmpDir = new File(this.resourceContext.getTemporaryDirectory(), "" + bundleVersion.getId());
- BundleManager bundleManager = request.getBundleManager();
+ BundleManagerProvider bundleManager = request.getBundleManagerProvider();
List<PackageVersion> packageVersions = bundleManager.getAllBundleVersionPackageVersions(bundleVersion);
for (PackageVersion packageVersion : packageVersions) {
File packageFile = new File(tmpDir, packageVersion.getFileName());
14 years, 2 months
[rhq] Branch 'ldap' - 46 commits - .classpath modules/core modules/enterprise modules/plugins
by Partha Aji
.classpath | 1
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup-build.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml | 25
modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml | 23
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 51 ++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java | 142 +++++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java | 253 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java | 38 +
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java | 2
modules/enterprise/server/jar/pom.xml | 47 +
modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g | 181 +++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 66 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java | 120 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java | 31 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java | 119 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 6
modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt | 126 ++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java | 171 ++++++
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 12
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 8
modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java | 5
modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml | 3
modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java | 2
modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java | 2
modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java | 2
modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java | 2
modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml | 2
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java | 5
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java | 2
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java | 76 ++-
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java | 2
modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java | 3
modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml | 3
modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml | 12
modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java | 2
modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java | 10
modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java | 2
modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java | 2
42 files changed, 1501 insertions(+), 82 deletions(-)
New commits:
commit 71e2d920463a909506ffee19dfa73c26f074578a
Merge: 308b9d3... 6445fb2...
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Mar 1 09:49:24 2010 -0500
Merge branch 'linux-config' into ldap
commit 6445fb2b8895d354c5621ff8a5c9fa26f1189672
Merge: 589df77... 6278e70...
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Mar 1 09:49:07 2010 -0500
Merge branch 'master' into linux-config
commit 308b9d3b2caa2f344368d713551c12f879448171
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Mar 1 09:48:27 2010 -0500
whateve
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
index 029a2b9..ad8ae65 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
@@ -47,6 +47,7 @@ public class AuthorizationManagerBean implements AuthorizationManagerLocal {
@SuppressWarnings("unchecked")
public Set<Permission> getExplicitGlobalPermissions(Subject subject) {
+ entityManager.flush();
Query query = entityManager.createNamedQuery(Subject.QUERY_GET_GLOBAL_PERMISSIONS);
query.setParameter("subject", subject);
List<Permission> results = query.getResultList();
commit 589df77934ed96b0361db10481a2dc61d4424c16
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 26 18:14:49 2010 +0100
Postgres plugin resources renamed.
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java
index 060ee03..5236fd3 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java
@@ -45,7 +45,7 @@ public class PostgresDatabaseDiscoveryComponent implements ResourceDiscoveryComp
while (resultSet.next()) {
String databaseName = resultSet.getString("datname");
DiscoveredResourceDetails database = new DiscoveredResourceDetails(context.getResourceType(),
- databaseName, databaseName + " Database", null, "The " + databaseName
+ databaseName, databaseName, null, "The " + databaseName
+ " Postgres Database Instance", null, null);
database.getPluginConfiguration().put(new PropertySimple("databaseName", databaseName));
databases.add(database);
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
index 5e0a83d..825a4a3 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
@@ -26,14 +26,19 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.*;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.plugins.postgres.util.PostgresqlConfFile;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -56,6 +61,8 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
private static final String PGDATA_ENV_VAR = "PGDATA";
private static final String DEFAULT_RESOURCE_DESCRIPTION = "Postgres relational database server";
+ private static final String POSTGRES_DEFAULT_DATABASE_NAME = "postgres";
+
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
Set<DiscoveredResourceDetails> servers = new LinkedHashSet<DiscoveredResourceDetails>();
@@ -140,9 +147,10 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
Configuration pluginConfiguration, @Nullable
ProcessInfo processInfo) {
String key = buildUrl(pluginConfiguration);
- String db = pluginConfiguration.getSimple(DB_CONFIGURATION_PROPERTY).getStringValue();
- String name = "Postgres [" + db + "]";
- String version = getVersion(pluginConfiguration);
+ Connection conn = getConnection(pluginConfiguration);
+ String name = getServerResourceName(pluginConfiguration, conn);
+ String version = getVersion(pluginConfiguration, conn);
+ JDBCUtil.safeClose(conn);
return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, version,
DEFAULT_RESOURCE_DESCRIPTION, pluginConfiguration, processInfo);
}
@@ -155,11 +163,12 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
return url;
}
- protected static String getVersion(Configuration config) {
+ protected static String getVersion(Configuration config, Connection conn) {
String version = null;
try {
- Connection conn = buildConnection(config);
- version = conn.getMetaData().getDatabaseProductVersion();
+ if (conn != null) {
+ version = conn.getMetaData().getDatabaseProductVersion();
+ }
} catch (SQLException e) {
// TODO GH: How to put this back to the server while inventorying this resource in an unconfigured state
log.info("Exception detecting postgres instance", e);
@@ -182,7 +191,12 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
String principal = configuration.getSimple(PRINCIPAL_CONFIGURATION_PROPERTY).getStringValue();
String credentials = configuration.getSimple(CREDENTIALS_CONFIGURATION_PROPERTY).getStringValue();
- return DriverManager.getConnection(url, principal, credentials);
+ try {
+ return DriverManager.getConnection(url, principal, credentials);
+ } catch (SQLException e) {
+ log.info("Failed to connect to the database", e);
+ return null;
+ }
}
@Nullable
@@ -239,4 +253,52 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
return configFilePath;
}
+
+ private static Connection getConnection(Configuration config) {
+ try {
+ return buildConnection(config);
+ } catch (SQLException e) {
+ log.info("Failed to connect to postgres database.", e);
+
+ return null;
+ }
+ }
+
+ public static List<String> getDatabases(Configuration pluginConfiguration) {
+ return getDatabaseNames(pluginConfiguration, getConnection(pluginConfiguration));
+ }
+
+ private static List<String> getDatabaseNames(Configuration config, Connection conn) {
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ List<String> ret = new ArrayList<String>();
+
+ statement = conn.createStatement();
+ resultSet = statement
+ .executeQuery("SELECT *, pg_database_size(datname) FROM pg_database where datistemplate = false");
+ while (resultSet.next()) {
+ String databaseName = resultSet.getString("datname");
+ ret.add(databaseName);
+ }
+
+ return ret;
+ } catch (SQLException e) {
+ log.info("Failed to obtain the list of databases in a postgres instance", e);
+ return Collections.emptyList();
+ } finally {
+ JDBCUtil.safeClose(statement, resultSet);
+ }
+ }
+
+ private static String getServerResourceName(Configuration config, Connection conn) {
+ List<String> schemas = getDatabaseNames(config, conn);
+ if (schemas.size() > 0 && schemas.size() < 3) {
+ String firstDatabase = schemas.get(0);
+ String secondDatabase = schemas.get(1);
+ return POSTGRES_DEFAULT_DATABASE_NAME.equals(firstDatabase) ? secondDatabase : firstDatabase;
+ } else {
+ return config.getSimpleValue(DB_CONFIGURATION_PROPERTY, POSTGRES_DEFAULT_DATABASE_NAME);
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java
index a48deb1..c0d0273 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java
@@ -61,7 +61,7 @@ public class PostgresUserDiscoveryComponent implements ResourceDiscoveryComponen
while (resultSet.next()) {
String userName = resultSet.getString("rolname");
DiscoveredResourceDetails service = new DiscoveredResourceDetails(context.getResourceType(), userName,
- userName + " User", null, "A Postgres user", null, null);
+ userName, null, "A Postgres user", null, null);
service.getPluginConfiguration().put(new PropertySimple("userName", userName));
discoveredUsers.add(service);
}
commit 6602a4542a782cec37f434b97cfe6089277e0eae
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Feb 25 09:39:07 2010 +0100
IIS plugin resources renamed.
diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
index 50b9448..f4cbceb 100644
--- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
+++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
@@ -78,7 +78,7 @@ public class IISServerDiscoveryComponent implements ResourceDiscoveryComponent {
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- imagePath, discoveryContext.getSystemInformation().getHostname() + " IIS Server", version, "IIS Server on "
+ imagePath, "IIS", version, "IIS Server on "
+ discoveryContext.getSystemInformation().getHostname(), pluginConfig, null);
return Collections.singleton(details);
diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
index 9ea5aa9..a6fc8a1 100644
--- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
+++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
@@ -86,7 +86,7 @@ public class IISVHostDiscoveryComponent implements ResourceDiscoveryComponent<II
config.put(new PropertySimple("logDirectory", "C:\\Windows\\System32\\LogFiles\\W3SVC" + info.getId()));
DiscoveredResourceDetails details = new DiscoveredResourceDetails(resourceDiscoveryContext
- .getResourceType(), siteName, siteName + " VHost", "1.0", siteName + " Virtual Host", config, null);
+ .getResourceType(), siteName, siteName, "1.0", siteName + " Virtual Host", config, null);
hostDetails.add(details);
}
commit bc19e61c3b7fc42f1aec1dc603ed6c637f3d7b79
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Feb 24 18:34:18 2010 +0100
Virt plugin resources renamed.
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java
index fe7b2ce..98f1979 100644
--- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java
+++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java
@@ -49,7 +49,7 @@ public class VirtualizationBlockDeviceDiscoveryComponent implements ResourceDisc
String device = intf.getSimple("targetDevice").getStringValue();
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- device, device + " virtual device", null, "Virtual block device", null, null);
+ device, device, null, "Virtual block device", null, null);
details.add(detail);
}
}
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java
index 7829c9f..7d769d6 100644
--- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java
+++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java
@@ -49,7 +49,7 @@ public class VirtualizationInterfaceDiscoveryComponent implements ResourceDiscov
String path = intf.getSimple("target").getStringValue();
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- path, path + " virtual interface", null, "Virtual network interface", null, null);
+ path, path, null, "Virtual network interface", null, null);
details.add(detail);
}
}
commit 51cd46a911b27118e02ccc589dda2952c17af66a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Feb 24 11:19:36 2010 +0100
Snmptrapd plugin resources renamed.
diff --git a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
index ec741a4..aab6d6e 100644
--- a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
+++ b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
@@ -37,6 +37,8 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
*/
public class SnmpTrapdDiscovery implements ResourceDiscoveryComponent<SnmpTrapdComponent>, ManualAddFacet<SnmpTrapdComponent> {
+ private static final String PORT_PROPERTY = "port";
+
/*
* Autodiscovery is not supported.
*/
@@ -52,11 +54,11 @@ public class SnmpTrapdDiscovery implements ResourceDiscoveryComponent<SnmpTrapdC
*/
public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
ResourceDiscoveryContext<SnmpTrapdComponent> ctx) throws InvalidPluginConfigurationException {
-
- String pcName = ctx.getPluginContainerName();
- String key = "Trapd (" + pcName + ")";
+
+ String port = pluginConfiguration.getSimpleValue(PORT_PROPERTY, null);
+ String key = "Trapd " + port;
String name = key;
- String description = "SNMP Trap receiver on " + pcName;
+ String description = "SNMP Trap receiver on port " + port;
ResourceType resourceType = ctx.getResourceType();
DiscoveredResourceDetails details = new DiscoveredResourceDetails(resourceType, key, name, null, description,
pluginConfiguration, null);
commit 7e2477a7d75fe8ff2de499f3b1143022b3d8e385
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 17:50:48 2010 +0100
Script2 plugin resources renamed.
diff --git a/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java b/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java
index 25411ee..4847261 100644
--- a/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java
+++ b/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java
@@ -47,7 +47,7 @@ public class ScriptDiscovery implements ResourceDiscoveryComponent,ManualAddFace
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
context.getResourceType(), // ResourceType
key, // resource key
- "Script " + lang + "::" + script, // resource name TODO get via configuration
+ script, // resource name TODO get via configuration
null, // version
lang + "Script " + script, // Description
pluginConfiguration, // Configuration
commit e167b466c5a2b32c64bc2b8afe83e1213eb12460
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 17:48:06 2010 +0100
RHQ Server plugin resources renamed.
diff --git a/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
index 3b0b5da..1cc0925 100644
--- a/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
@@ -19,7 +19,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq:service=AlertConditionCacheMonitor"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Alerts Engine Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Alert Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Statistics for the RHQ Server Alerts Engine Subsystem."/>
</plugin-configuration>
@@ -88,7 +88,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq:service=MeasurementMonitor"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Measurement Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Measurement Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Statistics for the RHQ Server Measurement Subsystem."/>
</plugin-configuration>
@@ -144,7 +144,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq:service=GroupDefinitionRecalculationThreadMonitor"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Group Definition / DynaGroups Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Group Definition Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Statistics for the RHQ Server Group Definition / DynaGroups Subsystem."/>
</plugin-configuration>
@@ -189,7 +189,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq:service=ServerCommunications"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Communications Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Communications Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Details on communications with agents"/>
</plugin-configuration>
@@ -265,7 +265,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq.remoting:type=RemoteApiMetrics"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Remote API Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Remote API Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Details on remote API communications with external clients, including the CLI"/>
</plugin-configuration>
@@ -309,7 +309,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq.serverplugin:service=ServerPluginService"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Plugin Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Plugin Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Details on the server-side plugin container subsystem"/>
</plugin-configuration>
commit bdf73e8c82c4568ea9a52b678d0b67b82926ffde
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 17:44:00 2010 +0100
RHQ agent plugin resources renamed.
diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
index 9580b69..52d9ac2 100644
--- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
+++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
@@ -65,8 +65,7 @@ public class AgentDiscoveryComponent implements ResourceDiscoveryComponent {
try {
AgentManagementMBean mbean = getAgentManagementMBean();
- String agentName = mbean.getAgentConfiguration().getProperty(AgentConfigurationConstants.NAME);
- String name = agentName + " RHQ Agent";
+ String name = "RHQ Agent";
String key = name; // our key IS our name - its unique since there is only one per platform
String version = mbean.getVersion();
String description = "RHQ Management Agent";
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index ab76cb6..45af5ba 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -13,7 +13,8 @@
<server name="RHQ Agent"
discovery="AgentDiscoveryComponent"
class="AgentServerComponent"
- description="Management Agent">
+ description="Management Agent"
+ singleton="true">
<plugin-configuration>
<c:group name="event" displayName="Log Tracking">
commit f0ba96ddb125030a5ce73106e47b33fc03a11c9d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 15:06:09 2010 +0100
Platforms plugin resources renamed.
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java
index dbd207f..b7960c2 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java
@@ -63,10 +63,9 @@ public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent<
}
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
try {
- String name = ((hostname == null) ? "" : (hostname + " ")) + " File System ("
- + fs.getFileSystem().getTypeName() + ") " + fs.getMountPoint();
+ String key = fs.getMountPoint();
DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- fs.getMountPoint(), name, null, fs.getFileSystem().getDevName() + ": "
+ key, key, null, fs.getFileSystem().getDevName() + ": "
+ fs.getFileSystem().getDirName(), pluginConfig, null);
results.add(details);
} catch (Exception e) {
commit 0790ffbfc48e7e7dd9eb43a43510282861f1bbd0
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 15:03:22 2010 +0100
Oracle plugin resources renamed.
diff --git a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
index 985058a..2340f0b 100644
--- a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
+++ b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
@@ -92,7 +92,7 @@ public class OracleDiscoveryComponent implements ResourceDiscoveryComponent, Man
Configuration pluginConfig, String version, @Nullable
ProcessInfo processInfo) {
String key = pluginConfig.getSimpleValue("sid", "XE");
- String name = "Oracle (" + key + ")";
+ String name = key;
String description = "Oracle " + version + " (" + key + ")";
return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, version, description,
pluginConfig, processInfo);
diff --git a/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
index 9478f12..11eb232 100644
--- a/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
@@ -580,7 +580,7 @@
<c:simple-property name="table" default="DBA_USERS"/>
<c:simple-property name="metricQuery" default="SELECT * FROM DBA_USERS"/>
<c:simple-property name="keyColumn" default="username"/>
- <c:simple-property name="name" default="Oracle User - {key}"/>
+ <c:simple-property name="name" default="{key}"/>
<c:simple-property name="description" default="Oracle User"/>
</plugin-configuration>
commit 112fadec0620f71058ca4f422753b6d3fe67a28c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 14:54:13 2010 +0100
Jira plugin resources renamed.
diff --git a/modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java b/modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java
index 1585ba0..7349dfc 100644
--- a/modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java
+++ b/modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java
@@ -50,7 +50,7 @@ public class JiraServerDiscoveryComponent implements ResourceDiscoveryComponent,
new DiscoveredResourceDetails(
resourceDiscoveryContext.getResourceType(),
url,
- "Jira " + url,
+ url,
info.getVersion(),
info.getEdition(),
config,
commit 58b5f646641ffa0b2acb5ee117873f564b503deb
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 14:47:26 2010 +0100
Grub plugin resources renamed.
diff --git a/modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java b/modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java
index 53022f1..4233bab 100644
--- a/modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java
+++ b/modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java
@@ -21,6 +21,8 @@ package org.rhq.plugins.grub;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
+
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
@@ -38,8 +40,9 @@ public class GrubDiscoveryComponent implements ResourceDiscoveryComponent {
File grubFile = new File("/etc/grub.conf");
if (grubFile.exists()) {
+ ResourceType resourceType = resourceDiscoveryContext.getResourceType();
DiscoveredResourceDetails resource =
- new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(), "grub", "GRUB Boot Loader",
+ new DiscoveredResourceDetails(resourceType, "grub", resourceType.getName(),
"1.0", "GRUB configuration on the machine.", null, null);
details.add(resource);
diff --git a/modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml
index bf4d069..b5f9ab8 100644
--- a/modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml
@@ -11,7 +11,8 @@
<server name="GRUB"
description="The GRUB boot loader"
discovery="GrubDiscoveryComponent"
- class="GrubComponent">
+ class="GrubComponent"
+ singleton="true">
<plugin-configuration>
<c:group name="augeas" displayName="Augeas Settings">
commit 881e397532a18850d9c9d01e6bea00816dd2b277
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 16 13:40:10 2010 +0100
Slight updates to the apache resource names.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index f19f2e3..b87b3d6 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -21,6 +21,7 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
+import java.net.URI;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -216,7 +217,15 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
Configuration pluginConfig, ProcessInfo processInfo, ApacheBinaryInfo binaryInfo) throws Exception {
String httpdConf = pluginConfig.getSimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF).getStringValue();
String version = binaryInfo.getVersion();
- String name = httpdConf;
+ String serverUrl = pluginConfig.getSimpleValue(ApacheServerComponent.PLUGIN_CONFIG_PROP_URL, null);
+ //use the server url if we could detect it, otherwise use something unique
+ String name;
+ if (serverUrl == null) {
+ name = httpdConf;
+ } else {
+ URI uri = new URI(serverUrl);
+ name = uri.getHost() + ":" + uri.getPort();
+ }
DiscoveredResourceDetails resourceDetails = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
httpdConf, name, version, PRODUCT_DESCRIPTION, pluginConfig, processInfo);
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 024517f..ad8ab5e 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -251,7 +251,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
DiscoveredResourceDetails mainServer = new DiscoveredResourceDetails(resourceType,
- ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY, "Main Server", null, null,
+ ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY, "Main", null, null,
mainServerPluginConfig, null);
discoveredResources.add(mainServer);
}
commit 29e014aca53d7d1ab417005f81a204069f1d9ae7
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Feb 15 13:12:13 2010 +0100
apache renaming
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index dae7df0..f19f2e3 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -216,8 +216,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
Configuration pluginConfig, ProcessInfo processInfo, ApacheBinaryInfo binaryInfo) throws Exception {
String httpdConf = pluginConfig.getSimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF).getStringValue();
String version = binaryInfo.getVersion();
- String hostname = discoveryContext.getSystemInformation().getHostname();
- String name = hostname + " Apache " + version + " (" + httpdConf + ")";
+ String name = httpdConf;
DiscoveredResourceDetails resourceDetails = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
httpdConf, name, version, PRODUCT_DESCRIPTION, pluginConfig, processInfo);
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 7e41eb4..024517f 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -135,11 +135,11 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
pluginConfiguration.put(rtLogProp);
- String resourceName = "Virtual Host ";
+ String resourceName;
if (serverName != null) {
- resourceName += address.host + ":" + address.port;
+ resourceName = address.host + ":" + address.port;
} else {
- resourceName += resourceKey;
+ resourceName = resourceKey;
}
discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
commit 6278e7056403b2dcd0ffde84a7109e60790022eb
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:55:32 2010 -0500
simplify dbupgrade by merge saved search-related entries into a single schemaSpec
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 6fe555e..b2b3b11 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3231,9 +3231,7 @@
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
- </schemaSpec>
-
- <schemaSpec version="2.82.1">
+
<schema-directSQL>
<statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Platforms'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
commit a6efa283222790b6e22f82861b1c145e34af9391
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:54:58 2010 -0500
insert some default global searches into the system during dbsetup
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
index 1a11114..da98622 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -10,7 +10,7 @@
DESCRIPTION="All downed machines across the entire enterprise"
PATTERN="down platform"
LAST_COMPUTE_TIME="0"
- SUBJECT="1"
+ SUBJECT_ID="1"
GLOBAL="TRUE" />
<data ID="2"
CONTEXT="Resource"
@@ -18,7 +18,7 @@
DESCRIPTION="All downed servers across the entire enterprise"
PATTERN="down server"
LAST_COMPUTE_TIME="0"
- SUBJECT="1"
+ SUBJECT_ID="1"
GLOBAL="TRUE" />
</table>
commit 1d02547312924f4904730bb0aebe7d0d8d9b70d2
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:21:37 2010 -0500
fix typo for column name in saved search table
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
index 7c0de23..14634b6 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
@@ -17,7 +17,7 @@
<column name="RESULT_COUNT" type="LONG" required="false"/>
<column name="SUBJECT_ID" type="INTEGER" references="RHQ_SUBJECT" required="true"/>
- <column name="ENABLED" type="BOOLEAN" required="true"/>
+ <column name="GLOBAL" type="BOOLEAN" required="true"/>
</table>
</dbsetup>
\ No newline at end of file
commit 92adfd37e105c60efc0f1981d7fc2258ee423ad5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:05:08 2010 -0500
change order of dbsetup so that saved search table gets created after the rhq_subject table
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
index f5e4eae..d5be746 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
@@ -39,7 +39,7 @@ To run the default target, you must set one of the following properties to true:
<property name="dbsetup.scripts.dir" value="${basedir}/src/main/scripts/dbsetup" />
<property name="dbsetup.output.dir" value="${basedir}/target/dbsetup" /> <!-- away from classes so it doesn't go into the jar -->
<!-- define the setup creation processing order. note, removals are done in the reverse order -->
- <property name="dbsetup.subsystems" value="search,config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
+ <property name="dbsetup.subsystems" value="config,cluster,inventory,auth,authz,search,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
<property name="dbsetup.combined.schema" value="${dbsetup.output.dir}/all-schema.xml" />
<property name="dbsetup.combined.data" value="${dbsetup.output.dir}/all-data.xml" />
<property name="dbsetup.tstamp.file" value="${dbsetup.output.dir}/dbsetup-combine.tstamp" />
commit d0ef49e101ef7887e834b0a9021c0c0654a7f5d5
Merge: 613b993... 8a0951a...
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:34:50 2010 -0500
Merge branch 'master' into search
commit 613b993b85ac47117fda5d7f7810318e891cdf0e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:32:41 2010 -0500
construct AST from parse tree for RHQL grammar
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
index 00a0dab..ded91a1 100644
--- a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -27,11 +27,43 @@
* @author Joseph Marques
*/
grammar RHQL;
-
options {
language=Java;
backtrack=true;
memoize=true;
+ output=AST;
+ ASTLabelType=CommonTree;
+}
+
+/*
+ * Imaginary nodes serve to fully abstract the parse tree from the AST. This
+ * allows us, for example, to support the conjunctive ('and') operator between
+ * conditional expressions, but gives us the flexibility to modify the lexical
+ * element that represents that operation. In the future, we might want to
+ * support '&&' instead of 'and', or even support them both. The inclusion of
+ * imaginary tokens creates a more stable AST that downstream grammars can use
+ * without fear that every change to the syntax will break their tree parser.
+ */
+tokens {
+ OR;
+ AND;
+
+ CONTEXT;
+ LINEAGE;
+ PATH;
+ PARAM;
+ IDENT;
+ VALUE;
+
+ OP_EQUALS;
+ OP_EQUALS_STRICT;
+ OP_NULL;
+ OP_IN;
+
+ OP_NOT_EQUALS;
+ OP_NOT_EQUALS_STRICT;
+ OP_NOT_NULL;
+ OP_NOT_IN;
}
@header {
@@ -41,26 +73,29 @@ options {
package org.rhq.enterprise.server.search;
}
+
/*
* parser rules
*/
searchExpression
- : conditionalExpression
+ : conditionalExpression { System.out.println($conditionalExpression.tree.toStringTree()); }
;
conditionalExpression
- : conditionalFactor ( 'or' conditionalFactor )*
- ;
+ : conds+=conditionalFactor ( WS* ( 'or' ) WS* conds+=conditionalFactor )* -> { $conds.size() == 1 }? ^($conds)
+ -> ^(OR conditionalFactor+)
+ ; // use rewrite predicates to eliminate superfluous 'or' node if only one child
conditionalFactor
- : conditionalPrimary ( ( 'and' )? conditionalPrimary )*
- ;
+ : conds+=conditionalPrimary ( WS* ( 'and' WS* )? conds+=conditionalPrimary )* -> { $conds.size() == 1 }? ^($conds)
+ -> ^(AND conditionalPrimary+)
+ ; // use rewrite predicates to eliminate superfluous 'and' node if only one child
conditionalPrimary
- : simpleConditionalExpression
- | '(' conditionalExpression ')'
- ;
+ : WS* simpleConditionalExpression WS* -> simpleConditionalExpression
+ | '(' WS* conditionalExpression WS* ')' -> conditionalExpression
+ ; // avoid building nodes for parens, tree structure implies existence appropriately -- ignore captured WS
simpleConditionalExpression
: comparisonConditionalExpression
@@ -69,69 +104,78 @@ simpleConditionalExpression
;
comparisonConditionalExpression
- : context comparisonOperator identifier
- ;
+ : c=context WS* op=comparisonOperator WS* ident=identifier -> ^($op $c ^(VALUE $ident))
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
nullComparisonConditionalExpression
- : context nullOperator
- ;
+ : c=context WS* op=nullOperator -> ^($op $c)
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
inExpression
- : context inOperator '[' '='? identifier ( ',' '='? identifier )* ']'
- ;
+ : c=context WS* op=inOperator WS* '[' WS* ids+=identifier WS* ( ',' WS* ids+=identifier WS* )* ']'
+ -> ^($op $c ^(VALUE $ids+))
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
context
- : ( lineage '.' )? path ( '[' identifier ']' )?
+ : ( l=lineage '.' )? p=path ( '[' ident=identifier ']' )? -> ^(CONTEXT ^(LINEAGE $l)? ^(PATH $p) ^(PARAM $ident)?)
;
lineage
- : path ( '(' INT ')' )?
- ;
+ : path ( '('! LEVEL ')'! )?
+ ; // avoid building nodes for brackets, tree structure implies existence appropriately
path
: ID+
;
identifier
- : quotedValue
- | value
+ : doubleQuotedValue -> ^(IDENT doubleQuotedValue)
+ | quotedValue -> ^(IDENT quotedValue)
+ | openEndedvalue -> ^(IDENT openEndedvalue)
;
+doubleQuotedValue
+ : '"'! ~('"')* '"'!
+ ; // avoid building nodes for the double-quote characters
+
+
quotedValue
- : '\'' ~('\'')* '\''
- ;
+ : '\''! ~('\'')* '\''!
+ ; // avoid building nodes for the sinngle-quote characters
-value
- : ~('\'') ~(']'|','|')')*
- ;
+openEndedvalue
+ : ~(']' | ',' | ')' | '(' | 'or' | 'and' | WS )*
+ ; // consume until we find a char to terminate the current phrase ']' ',' ')' or begin the next '(' 'or' 'and'
comparisonOperator
- : '='
- | '=='
- | '!='
- | '!=='
- ;
+ : '=' -> ^(OP_EQUALS)
+ | '==' -> ^(OP_EQUALS_STRICT)
+ | '!=' -> ^(OP_NOT_EQUALS)
+ | '!==' -> ^(OP_NOT_EQUALS_STRICT)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
nullOperator
- : 'is' 'not'? 'null'
- ;
+ : 'is' WS+ (negation='not' WS+)? 'null' -> { $negation == null }? ^(OP_NULL)
+ -> ^(OP_NOT_NULL)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
inOperator
- : 'not'? 'in'
- ;
+ : (negation+='not' WS+)? 'in' -> { $negation == null }? ^(OP_IN)
+ -> ^(OP_NOT_IN)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
/*
* lexical elements
- */
+ */
ID
: 'a'..'z'
;
-INT
- : '0'..'9'
+LEVEL
+ : '0'..'5'
;
WS
- : ( ' ' | '\n' | '\r' )+ { $channel = HIDDEN; }
+ : ( ' ' | '\n' | '\r' )+
;
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
index 637e339..ceab3e3 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
@@ -62,6 +62,7 @@ public class RHQLTest extends AssertJUnit {
@Override
public TestResult call() throws Exception {
try {
+ System.out.println(line);
ANTLRStringStream input = new ANTLRStringStream(line); // Create an input character stream from standard in
RHQLLexer lexer = new RHQLLexer(input); // Create an echoLexer that feeds from that stream
CommonTokenStream tokens = new CommonTokenStream(lexer); // Create a stream of tokens fed by the lexer
commit eac78662084095c22fb80326643fbf59f0e1a863
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:31:54 2010 -0500
modify RHQL test case file to adhere to simpler syntax for IN-clause:
* remove multi-word non-quoted identifers for the IN-clause
* remove ability to change case-sensitivity comparison for IN-clause
diff --git a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
index 2a5a195..f8c241a 100644
--- a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
+++ b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
@@ -7,11 +7,11 @@ context !== value
context is null
context is not null
context in [value]
-context in [value1, =value2]
-context in [=value1, value2, value3]
+context in [value1, value2]
+context in [value1, value2, value3]
context not in [value]
-context not in [value1, =value2]
-context not in [=value1, value2, value3]
+context not in [value1, value2]
+context not in [value1, value2, value3]
# simple term, all operators, quoted value
context = 'quoted value'
@@ -21,19 +21,11 @@ context !== 'quoted value'
context is null
context is not null
context in ['quoted value1']
-context in ['quoted value1', ='quoted value2']
-context in [='quoted value1', 'quoted value2', 'quoted value3']
+context in ['quoted value1', 'quoted value2']
+context in ['quoted value1', 'quoted value2', 'quoted value3']
context not in ['quoted value1']
-context not in ['quoted value1', ='quoted value2']
-context not in [='quoted value1', 'quoted value2', 'quoted value3']
-
-# simple term, 'in' operator, non-quoted but multi-word values
-context in [quoted value1]
-context in [quoted value1, =quoted value2]
-context in [=quoted value1, quoted value2, quoted value3]
-context not in [quoted value1]
-context not in [quoted value1, =quoted value2]
-context not in [=quoted value1, quoted value2, quoted value3]
+context not in ['quoted value1', 'quoted value2']
+context not in ['quoted value1', 'quoted value2', 'quoted value3']
# parameterized term, all operators
context[param] = value
@@ -43,11 +35,11 @@ context[param] !== value
context[param] is null
context[param] is not null
context[param] in [value]
-context[param] in [value1, =value2]
-context[param] in [=value1, value2, value3]
+context[param] in [value1, value2]
+context[param] in [value1, value2, value3]
context[param] not in [value]
-context[param] not in [value1, =value2]
-context[param] not in [=value1, value2, value3]
+context[param] not in [value1, value2]
+context[param] not in [value1, value2, value3]
# deeply nested parenthetical simple terms
((context = value))
@@ -63,11 +55,11 @@ context[param] not in [=value1, value2, value3]
(context is null)
(context is not null)
(context in [value])
-(context in [value1, =value2])
-(context in [=value1, value2, value3])
+(context in [value1, value2])
+(context in [value1, value2, value3])
(context not in [value])
-(context not in [value1, =value2])
-(context not in [=value1, value2, value3])
+(context not in [value1, value2])
+(context not in [value1, value2, value3])
# parameterized parenthetical term, all operators
(context[param] = value)
@@ -77,11 +69,11 @@ context[param] not in [=value1, value2, value3]
(context[param] is null)
(context[param] is not null)
(context[param] in [value])
-(context[param] in [value1, =value2])
-(context[param] in [=value1, value2, value3])
+(context[param] in [value1, value2])
+(context[param] in [value1, value2, value3])
(context[param] not in [value])
-(context[param] not in [value1, =value2])
-(context[param] not in [=value1, value2, value3])
+(context[param] not in [value1, value2])
+(context[param] not in [value1, value2, value3])
# single-pair parenthetical combinations
@@ -131,4 +123,4 @@ context = value1 and ((context = value2))
((context = value1)) context = value2
(context = value1) (context = value2)
(context = value1 (context = value2))
-context = value1 ((context1 = value2))
\ No newline at end of file
+context = value1 ((context = value2))
\ No newline at end of file
commit 8a0951a835997a2cdc75d2cf9840a7a7fdf59c15
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 26 17:57:56 2010 +0100
BZ 568544 - disambiguation doesn't get confused if more than one item in the provided results corresponds to a signle resource.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
index 67f3276..dd359da 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
@@ -64,6 +64,6 @@ public class DisambiguationReport<T> implements Serializable {
}
public String toString() {
- return "DisambiguationReport(type=" + resourceTypeName + ", plugin=" + resourceTypePluginName + ", parents=" + parents + ")";
+ return "DisambiguationReport(type=" + resourceTypeName + ", plugin=" + resourceTypePluginName + ", parents=" + parents + ", original=" + original + ")";
}
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 3af7a35..e5684d2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -31,6 +31,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -2170,34 +2171,36 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
false);
}
- //this will contain the disambiguated results
- List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size());
boolean typeResolutionNeeded = false;
boolean pluginResolutionNeeded = false;
boolean parentResolutionNeeded = false;
//we can't assume the ordering of the provided results and the disambiguation query results
- //will be the same, hence this map.
- Map<Integer, MutableDisambiguationReport<T>> reportByResourceId = new HashMap<Integer, MutableDisambiguationReport<T>>();
+ //will be the same.
+
+ //this list contains the resulting reports in the same order as the original results
+ List<MutableDisambiguationReport<T>> reports = new ArrayList<MutableDisambiguationReport<T>>(results.size());
+
+ //this maps the reports to resourceIds. More than one report can correspond to a single
+ //resource id. The reports in this map are the same instances as in the reports list.
+ Map<Integer, List<MutableDisambiguationReport<T>>> reportsByResourceId = new HashMap<Integer, List<MutableDisambiguationReport<T>>>();
for (T r : results) {
MutableDisambiguationReport<T> value = new MutableDisambiguationReport<T>();
value.original = r;
int resourceId = extractor.extract(r);
if (resourceId > 0) {
- reportByResourceId.put(resourceId, value);
+ List<MutableDisambiguationReport<T>> correspondingResults = reportsByResourceId.get(resourceId);
+ if (correspondingResults == null) {
+ correspondingResults = new ArrayList<MutableDisambiguationReport<T>>();
+ reportsByResourceId.put(resourceId, correspondingResults);
+ }
+ correspondingResults.add(value);
}
+ reports.add(value);
}
//check that we still have something to disambiguate
- if (reportByResourceId.isEmpty()) {
- //no, we don't. construct the resolution only using the results.
-
- for (T result : results) {
- DisambiguationReport<T> report = new DisambiguationReport<T>(result, Collections
- .<ResourceParentFlyweight> emptyList(), null, null);
- resolution.add(report);
- }
- } else {
+ if (reportsByResourceId.size() > 0) {
//first find out how many ancestors we are going to require to disambiguate the resuls
String query = Resource.NATIVE_QUERY_FIND_DISAMBIGUATION_LEVEL;
@@ -2247,7 +2250,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
Query parentsQuery = entityManager.createQuery(selectBuilder.append(" ").append(fromBuilder).toString());
- parentsQuery.setParameter("resourceIds", reportByResourceId.keySet());
+ parentsQuery.setParameter("resourceIds", reportsByResourceId.keySet());
@SuppressWarnings("unchecked")
List<Object[]> parentsResults = (List<Object[]>) parentsQuery.getResultList();
@@ -2264,28 +2267,22 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
String parentName = (String) parentsResult[2 * i + 2];
parents.add(new ResourceParentFlyweight(parentId, parentName));
}
- MutableDisambiguationReport<T> report = reportByResourceId.get(resourceId);
- report.typeName = typeName;
- report.pluginName = pluginName;
- report.parents = parents;
- }
-
- //now we have all the information to create the result.
- for (T result : results) {
- int resourceId = extractor.extract(result);
- if (resourceId > 0) {
- //this results was disambiguated by the query above...
- MutableDisambiguationReport<T> report = reportByResourceId.get(resourceId);
- resolution.add(report.getReport());
- } else {
- //this result doesn't correspond to any resource, need to handle it specially
- DisambiguationReport<T> report = new DisambiguationReport<T>(result, Collections
- .<ResourceParentFlyweight> emptyList(), null, null);
- resolution.add(report);
+
+ //update all the reports that correspond to this resourceId
+ for(MutableDisambiguationReport<T> report : reportsByResourceId.get(resourceId)) {
+ report.typeName = typeName;
+ report.pluginName = pluginName;
+ report.parents = parents;
}
}
}
+ List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size());
+
+ for (MutableDisambiguationReport<T> report : reports) {
+ resolution.add(report.getReport());
+ }
+
return new ResourceNamesDisambiguationResult<T>(resolution, typeResolutionNeeded, parentResolutionNeeded,
pluginResolutionNeeded);
}
@@ -2297,7 +2294,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public List<ResourceParentFlyweight> parents;
public DisambiguationReport<T> getReport() {
- return new DisambiguationReport<T>(original, parents, typeName, pluginName);
+ return new DisambiguationReport<T>(original, parents == null ? Collections
+ .<ResourceParentFlyweight> emptyList() : parents, typeName, pluginName);
}
}
}
commit 602b8780654df9298dc36f6e8523e2ebb3e0c906
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Feb 25 12:34:39 2010 -0500
add missing @WebMethod annotation to saved search manager remote interface
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
index ffd4255..231167e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -112,6 +112,7 @@ public interface SavedSearchManagerRemote {
* @return the {@link PageList} of {@link SavedSearch} entities that match the criteria filters, an empty list
* will be returned if no results were found or none matches the given filters
*/
+ @WebMethod
public PageList<SavedSearch> findSavedSearchesByCriteria( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "criteria") SavedSearchCriteria criteria);
commit 07a482e999b87952b9cdbd2573fe6b04c4b8ff8e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Feb 24 22:04:30 2010 -0500
abstract RHQL grammar support:
* initial combined lexer/parser grammar file
* test harness to verify grammar correctness
* 100 acceptance test cases exercising all major parts of generic syntax
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
new file mode 100644
index 0000000..00a0dab
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -0,0 +1,137 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * Antlr v3 grammar file to parse RHQL search expressions.
+ *
+ * @author Joseph Marques
+ */
+grammar RHQL;
+
+options {
+ language=Java;
+ backtrack=true;
+ memoize=true;
+}
+
+@header {
+ package org.rhq.enterprise.server.search;
+}
+@lexer::header {
+ package org.rhq.enterprise.server.search;
+}
+
+/*
+ * parser rules
+ */
+
+searchExpression
+ : conditionalExpression
+ ;
+
+conditionalExpression
+ : conditionalFactor ( 'or' conditionalFactor )*
+ ;
+
+conditionalFactor
+ : conditionalPrimary ( ( 'and' )? conditionalPrimary )*
+ ;
+
+conditionalPrimary
+ : simpleConditionalExpression
+ | '(' conditionalExpression ')'
+ ;
+
+simpleConditionalExpression
+ : comparisonConditionalExpression
+ | nullComparisonConditionalExpression
+ | inExpression
+ ;
+
+comparisonConditionalExpression
+ : context comparisonOperator identifier
+ ;
+
+nullComparisonConditionalExpression
+ : context nullOperator
+ ;
+
+inExpression
+ : context inOperator '[' '='? identifier ( ',' '='? identifier )* ']'
+ ;
+
+context
+ : ( lineage '.' )? path ( '[' identifier ']' )?
+ ;
+
+lineage
+ : path ( '(' INT ')' )?
+ ;
+
+path
+ : ID+
+ ;
+
+identifier
+ : quotedValue
+ | value
+ ;
+
+quotedValue
+ : '\'' ~('\'')* '\''
+ ;
+
+value
+ : ~('\'') ~(']'|','|')')*
+ ;
+
+comparisonOperator
+ : '='
+ | '=='
+ | '!='
+ | '!=='
+ ;
+
+nullOperator
+ : 'is' 'not'? 'null'
+ ;
+
+inOperator
+ : 'not'? 'in'
+ ;
+
+/*
+ * lexical elements
+ */
+
+ID
+ : 'a'..'z'
+ ;
+
+INT
+ : '0'..'9'
+ ;
+
+WS
+ : ( ' ' | '\n' | '\r' )+ { $channel = HIDDEN; }
+ ;
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
new file mode 100644
index 0000000..2a5a195
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
@@ -0,0 +1,134 @@
+
+# simple term, all operators
+context = value
+context == value
+context != value
+context !== value
+context is null
+context is not null
+context in [value]
+context in [value1, =value2]
+context in [=value1, value2, value3]
+context not in [value]
+context not in [value1, =value2]
+context not in [=value1, value2, value3]
+
+# simple term, all operators, quoted value
+context = 'quoted value'
+context == 'quoted value'
+context != 'quoted value'
+context !== 'quoted value'
+context is null
+context is not null
+context in ['quoted value1']
+context in ['quoted value1', ='quoted value2']
+context in [='quoted value1', 'quoted value2', 'quoted value3']
+context not in ['quoted value1']
+context not in ['quoted value1', ='quoted value2']
+context not in [='quoted value1', 'quoted value2', 'quoted value3']
+
+# simple term, 'in' operator, non-quoted but multi-word values
+context in [quoted value1]
+context in [quoted value1, =quoted value2]
+context in [=quoted value1, quoted value2, quoted value3]
+context not in [quoted value1]
+context not in [quoted value1, =quoted value2]
+context not in [=quoted value1, quoted value2, quoted value3]
+
+# parameterized term, all operators
+context[param] = value
+context[param] == value
+context[param] != value
+context[param] !== value
+context[param] is null
+context[param] is not null
+context[param] in [value]
+context[param] in [value1, =value2]
+context[param] in [=value1, value2, value3]
+context[param] not in [value]
+context[param] not in [value1, =value2]
+context[param] not in [=value1, value2, value3]
+
+# deeply nested parenthetical simple terms
+((context = value))
+(((context = value)))
+((((context = value))))
+(((((context = value)))))
+
+# simple parenthetical term, all operators
+(context = value)
+(context == value)
+(context != value)
+(context !== value)
+(context is null)
+(context is not null)
+(context in [value])
+(context in [value1, =value2])
+(context in [=value1, value2, value3])
+(context not in [value])
+(context not in [value1, =value2])
+(context not in [=value1, value2, value3])
+
+# parameterized parenthetical term, all operators
+(context[param] = value)
+(context[param] == value)
+(context[param] != value)
+(context[param] !== value)
+(context[param] is null)
+(context[param] is not null)
+(context[param] in [value])
+(context[param] in [value1, =value2])
+(context[param] in [=value1, value2, value3])
+(context[param] not in [value])
+(context[param] not in [value1, =value2])
+(context[param] not in [=value1, value2, value3])
+
+
+# single-pair parenthetical combinations
+# simple expression, 'or' boolean operator
+context = value1 or context = value2
+(context = value1) or context = value2
+context = value1 or (context = value2)
+(context = value1) or (context = value2)
+
+# single-pair parenthetical combinations
+# simple expression, 'and' boolean operator
+context = value and context = value
+(context = value) and context = value
+context = value and (context = value)
+(context = value) and (context = value)
+
+# single-pair parenthetical combinations
+# simple expression, no boolean operator (implies 'and' semantics)
+context = value context = value
+(context = value) context = value
+context = value (context = value)
+(context = value) (context = value)
+
+
+# double-pair parenthetical combinations
+# simple expression, 'or' boolean operator
+((context = value1 or context = value2))
+((context = value1) or context = value2)
+((context = value1)) or context = value2
+(context = value1) or (context = value2)
+(context = value1 or (context = value2))
+context = value1 or ((context = value2))
+
+# double-pair parenthetical combinations
+# simple expression, 'and' boolean operator
+((context = value1 and context = value2))
+((context = value1) and context = value2)
+((context = value1)) and context = value2
+(context = value1) and (context = value2)
+(context = value1 and (context = value2))
+context = value1 and ((context = value2))
+
+# double-pair parenthetical combinations
+# simple expression, no boolean operator (implies 'and' semantics)
+((context = value1 context = value2))
+((context = value1) context = value2)
+((context = value1)) context = value2
+(context = value1) (context = value2)
+(context = value1 (context = value2))
+context = value1 ((context1 = value2))
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
new file mode 100644
index 0000000..637e339
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
@@ -0,0 +1,170 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.testng.AssertJUnit;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+/**
+ * Test harness to verify correctness of RHQL grammar
+ *
+ * @author Joseph Marques
+ */
+public class RHQLTest extends AssertJUnit {
+
+ private enum TestResult {
+ SUCCESS, FAILURE, TIMEOUT, SKIPPED;
+ }
+
+ private class AntlrTask implements Callable<TestResult> {
+ private String line;
+
+ public AntlrTask(String line) {
+ this.line = line;
+ }
+
+ @Override
+ public TestResult call() throws Exception {
+ try {
+ ANTLRStringStream input = new ANTLRStringStream(line); // Create an input character stream from standard in
+ RHQLLexer lexer = new RHQLLexer(input); // Create an echoLexer that feeds from that stream
+ CommonTokenStream tokens = new CommonTokenStream(lexer); // Create a stream of tokens fed by the lexer
+ RHQLParser parser = new RHQLParser(tokens); // Create a parser that feeds off the token stream
+ parser.searchExpression(); // Begin parsing at 'searchExpression' rule
+ return TestResult.SUCCESS;
+ } catch (Throwable t) {
+ return TestResult.FAILURE;
+ }
+ }
+ };
+
+ private ExecutorService executor;
+
+ @BeforeSuite
+ public void init() {
+ executor = Executors.newSingleThreadExecutor();
+ }
+
+ @AfterSuite
+ public void teardown() {
+ executor.shutdownNow();
+ }
+
+ @Test
+ public void testSingleLineRHQL() throws Exception {
+ BufferedReader reader = null;
+ List<String> successes = new java.util.ArrayList<String>();
+ List<String> failures = new java.util.ArrayList<String>();
+ int count = 0;
+ try {
+ InputStream stream = getClass().getClassLoader().getResourceAsStream("single-line-rhql.txt");
+ reader = new BufferedReader(new InputStreamReader(stream));
+ String line = null;
+ long timeout = 2000;
+ while ((line = reader.readLine()) != null) {
+ TestResult result = testSuccess(line, timeout);
+ if (result == TestResult.SKIPPED) {
+ continue;
+ }
+ count++;
+ if (result == TestResult.SUCCESS) {
+ successes.add(line);
+ } else if (result == TestResult.FAILURE) {
+ failures.add(line);
+ } else if (result == TestResult.TIMEOUT) {
+ System.out.println("Parsing took more than " + timeout
+ + "ms, does your grammar have an infinite loop?");
+ }
+ }
+ } catch (Exception e) {
+ System.out.println("Error testing single line RHQL: " + e);
+ throw e;
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+
+ System.out.println();
+ for (String success : successes) {
+ System.out.println("Parse success: " + success);
+ }
+ for (String failure : failures) {
+ System.out.println("Parse failure: " + failure);
+ }
+
+ System.out.println();
+ System.out.printf("RHQL expressions parsed: %1$s, Failures: %2$s", count, failures.size());
+ System.out.println();
+
+ assert failures.size() == 0;
+ }
+
+ private TestResult testSuccess(final String line, long timeout) {
+ if (shouldSkip(line)) {
+ return TestResult.SKIPPED; // skip empty lines used for visual separation in test file
+ }
+
+ AntlrTask task = new AntlrTask(line);
+ Future<TestResult> futureTask = executor.submit(task);
+ TestResult result = null;
+ try {
+ result = futureTask.get(timeout, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException ee) {
+ } catch (TimeoutException te) {
+ futureTask.cancel(true);
+ result = TestResult.TIMEOUT;
+ } catch (InterruptedException ie) {
+ futureTask.cancel(true);
+ }
+
+ return result;
+ }
+
+ private boolean shouldSkip(String line) {
+ line = line.trim();
+ if (line.equals("")) {
+ return true; // ignore empty lines
+ }
+ if (line.startsWith("#")) {
+ return true; // ignore comments
+ }
+ return false;
+ }
+}
commit 7369db803076bc12f02bcc6131b9fe1e5303ae47
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Feb 24 01:57:08 2010 -0500
antlr should compile the grammar files before the standard maven compile phase
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index b322503..533c0e9 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -467,10 +467,10 @@
<version>3.2</version>
<executions>
<execution>
- <phase>compile</phase>
- <goals>
- <goal>antlr</goal>
- </goals>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
<configuration>
<conversionTimeout>30000</conversionTimeout>
<debug>false</debug>
commit d17f4616c524e65decd6af3db65df8a83d18c12e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 16:54:20 2010 -0500
add anltr support to server/jar maven module, update eclipse classpath accordingly;
diff --git a/.classpath b/.classpath
index 660d74d..1a35400 100644
--- a/.classpath
+++ b/.classpath
@@ -19,6 +19,7 @@
<classpathentry kind="src" path="modules/plugins/jboss-cache/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-cache-v3/src/main/java"/>
<classpathentry kind="src" path="etc/samples/perspectives/sample-perspective/app/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/server/jar/target/generated-sources/antlr3"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index e109c41..b322503 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -366,6 +366,13 @@
<artifactId>test-utils</artifactId>
<version>${version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.2</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
@@ -454,6 +461,41 @@
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr3-maven-plugin</artifactId>
+ <version>3.2</version>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ <configuration>
+ <conversionTimeout>30000</conversionTimeout>
+ <debug>false</debug>
+ <dfa>false</dfa>
+ <nfa>false</nfa>
+ <excludes>
+
+ </excludes>
+ <includes>
+
+ </includes>
+ <libDirectory>src/main/antlr3/imports</libDirectory>
+ <messageFormat>antlr</messageFormat>
+ <outputDirectory>target/generated-sources/antlr3</outputDirectory>
+ <printGrammar>false</printGrammar>
+ <profile>false</profile>
+ <report>false</report>
+ <sourceDirectory>src/main/antlr3</sourceDirectory>
+ <trace>false</trace>
+ <verbose>true</verbose>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
commit fc1118af81ff953f2c05fb696629d799169b22f1
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 13:21:29 2010 -0500
fix some whitespace issues
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index f14e145..e109c41 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -414,7 +414,7 @@
Build-Jdk=${java.version}
Build-OS-Name=${os.name}
Build-OS-Version=${os.version}
-</echo>
+ </echo>
</tasks>
</configuration>
<goals>
@@ -593,8 +593,7 @@
<link href="../domain" />
<link href="../plugin-api" />
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
- <bottom><![CDATA[Copyright © 2008-2009 <a href="http://rhq-project.org/">Red Hat, Inc.</a>. All Rights Reserved.
-]]></bottom>
+ <bottom><![CDATA[Copyright © 2008-2009 <a href="http://rhq-project.org/">Red Hat, Inc.</a>. All Rights Reserved.]]></bottom>
</javadoc>
</tasks>
</configuration>
commit 1c79730a4d3ce260e2f3d6ce9b8e971da158e1d7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 13:10:18 2010 -0500
add some default, global saved searches for the resource context
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
new file mode 100644
index 0000000..1a11114
--- /dev/null
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<dbsetup name="search-data.xml">
+
+ <!-- overlord-created, global, default saved searches -->
+ <table name="RHQ_SAVED_SEARCH">
+ <data ID="1"
+ CONTEXT="Resource"
+ NAME="Downed Platforms"
+ DESCRIPTION="All downed machines across the entire enterprise"
+ PATTERN="down platform"
+ LAST_COMPUTE_TIME="0"
+ SUBJECT="1"
+ GLOBAL="TRUE" />
+ <data ID="2"
+ CONTEXT="Resource"
+ NAME="Downed Servers"
+ DESCRIPTION="All downed servers across the entire enterprise"
+ PATTERN="down server"
+ LAST_COMPUTE_TIME="0"
+ SUBJECT="1"
+ GLOBAL="TRUE" />
+ </table>
+
+</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 834e9ce..6fe555e 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3202,13 +3202,18 @@
</statement>
</schema-directSQL>
</schemaSpec>
-
+
<schemaSpec version="2.82">
<schema-directSQL>
<statement desc="Creating table RHQ_SAVED_SEARCH">
CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER )
</statement>
</schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_AFFINITY_GROUP">
+ ALTER TABLE RHQ_SAVED_SEARCH ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
<schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
@@ -3227,6 +3232,29 @@
<schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
</schemaSpec>
+
+ <schemaSpec version="2.82.1">
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Platforms'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, true)
+ </statement>
+ <statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Platforms'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, 1)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Servers'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, true)
+ </statement>
+ <statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Servers'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, 1)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
commit 68f3634b787768dd5ee138a04a5398fdd4cb6404
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 12:07:56 2010 -0500
fix copy/paste error for saved search entity annotation
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
index 9142772..d6b50e7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
@@ -87,7 +87,7 @@ public class SavedSearch {
@Column(name = "SUBJECT_ID", nullable = false)
private Subject subject;
- @Column(name = "RESOURCE_ID", insertable = false, updatable = false)
+ @Column(name = "SUBJECT_ID", insertable = false, updatable = false)
private int subjectId;
@Column(name = "GLOBAL", nullable = false)
commit 2325fa6314a7ebcbf1d932fb42e9f9559e1d079b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 03:02:28 2010 -0500
add auto-completion capability for saved search manager to the CLI
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index acafe6f..a1a5b38 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -54,6 +54,7 @@ import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerRemote;
+import org.rhq.enterprise.server.search.SavedSearchManagerRemote;
import org.rhq.enterprise.server.support.SupportManagerRemote;
import org.rhq.enterprise.server.system.ServerVersion;
import org.rhq.enterprise.server.system.SystemManagerRemote;
@@ -94,6 +95,7 @@ public class RemoteClient {
ResourceGroupManager(ResourceGroupManagerRemote.class), //
ResourceTypeManager(ResourceTypeManagerRemote.class), //
RoleManager(RoleManagerRemote.class), //
+ SavedSearchManager(SavedSearchManagerRemote.class), //
SubjectManager(SubjectManagerRemote.class), //
SupportManager(SupportManagerRemote.class), //
SystemManager(SystemManagerRemote.class) //
commit 9bfad0211e66635e09d02d8959a81db33f6175b7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:51:14 2010 -0500
add LookupUtil method to retrieve the saved search manager from the UI layer
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index dc9ae11..c21526a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -165,6 +165,8 @@ import org.rhq.enterprise.server.resource.metadata.ResourceMetadataManagerBean;
import org.rhq.enterprise.server.resource.metadata.ResourceMetadataManagerLocal;
import org.rhq.enterprise.server.scheduler.SchedulerBean;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerBean;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
import org.rhq.enterprise.server.subsystem.AlertSubsystemManagerBean;
import org.rhq.enterprise.server.subsystem.AlertSubsystemManagerLocal;
import org.rhq.enterprise.server.subsystem.ConfigurationSubsystemManagerBean;
@@ -516,6 +518,10 @@ public final class LookupUtil {
return lookupLocal(SchedulerBean.class);
}
+ public static SavedSearchManagerLocal getSavedSearchManager() {
+ return lookupLocal(SavedSearchManagerBean.class);
+ }
+
public static SubjectManagerLocal getSubjectManager() {
return lookupLocal(SubjectManagerBean.class);
}
commit 7b68ec1372bd5af42793b5d15020e7b2f66bb931
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:49:08 2010 -0500
add criteria-based retrieval for the saved search manager
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
new file mode 100644
index 0000000..bd70b6f
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
@@ -0,0 +1,142 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.criteria;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.search.SearchContext;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Joseph Marques
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class SavedSearchCriteria extends Criteria {
+ public static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private SearchContext filterContext;
+ private String filterName;
+ private String filterDescription;
+ private String filterPattern;
+ private Long filterLastComputeTimeMin;
+ private Long filterLastComputeTimeMax;
+ private Long filterResultCountMin;
+ private Long filterResultCountMax;
+ private Integer filterSubjectId;
+ private Boolean filterGlobal;
+
+ private boolean fetchSubject;
+
+ private PageOrdering sortContext;
+ private PageOrdering sortName;
+ private PageOrdering sortLastComputeTime;
+ private PageOrdering sortResultCount;
+ private PageOrdering sortGlobal;
+
+ public SavedSearchCriteria() {
+ super(SavedSearch.class);
+
+ filterOverrides.put("lastComputeTimeMin", "lastComputeTime >= ?");
+ filterOverrides.put("lastComputeTimeMax", "lastComputeTime <= ?");
+ filterOverrides.put("resultCountMin", "resultCount >= ?");
+ filterOverrides.put("resultCountMax", "resultCount <= ?");
+ }
+
+ public void addFilterId(Integer filterId) {
+ this.filterId = filterId;
+ }
+
+ public void addFilterSearchContext(SearchContext filterContext) {
+ this.filterContext = filterContext;
+ }
+
+ public void addFilterName(String filterName) {
+ this.filterName = filterName;
+ }
+
+ public void addFilterDescription(String filterDescription) {
+ this.filterDescription = filterDescription;
+ }
+
+ public void addFilterPattern(String filterPattern) {
+ this.filterPattern = filterPattern;
+ }
+
+ public void addFilterResultCountMin(Long filterResultCountMin) {
+ this.filterResultCountMin = filterResultCountMin;
+ }
+
+ public void addFilterResultCountMax(Long filterResultCountMax) {
+ this.filterResultCountMax = filterResultCountMax;
+ }
+
+ public void addFilterLastComputeTimeMin(Long filterLastComputeTimeMin) {
+ this.filterLastComputeTimeMin = filterLastComputeTimeMin;
+ }
+
+ public void addFilterLastComputeTimeMax(Long filterLastComputeTimeMax) {
+ this.filterLastComputeTimeMax = filterLastComputeTimeMax;
+ }
+
+ public void addFilterSubjectId(Integer filterSubjectId) {
+ this.filterSubjectId = filterSubjectId;
+ }
+
+ public void addFilterGlobal(Boolean filterGlobal) {
+ this.filterGlobal = filterGlobal;
+ }
+
+ public void setFetchSubject(boolean fetchSubject) {
+ this.fetchSubject = fetchSubject;
+ }
+
+ public void addSortContext(PageOrdering sortContext) {
+ addSortField("context");
+ this.sortContext = sortContext;
+ }
+
+ public void addSortName(PageOrdering sortName) {
+ addSortField("name");
+ this.sortName = sortName;
+ }
+
+ public void addSortLastComputeTime(PageOrdering sortLastComputeTime) {
+ addSortField("lastComputeTime");
+ this.sortLastComputeTime = sortLastComputeTime;
+ }
+
+ public void addSortResultCount(PageOrdering sortResultCount) {
+ addSortField("resultCount");
+ this.sortResultCount = sortResultCount;
+ }
+
+ public void addSortGlobal(PageOrdering sortGlobal) {
+ addSortField("global");
+ this.sortGlobal = sortGlobal;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
index f672ac7..1485197 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
@@ -24,10 +24,14 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
+import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
+import org.rhq.enterprise.server.util.CriteriaQueryRunner;
/**
* This bean provides functionality to CRUD saved search patterns.
@@ -79,6 +83,18 @@ public class SavedSearchManagerBean implements SavedSearchManagerLocal /* local
return savedSearch;
}
+ public PageList<SavedSearch> findSavedSearchesByCriteria(Subject subject, SavedSearchCriteria criteria) {
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
+
+ if (!authorizationManager.isInventoryManager(subject)) {
+ generator.setAuthorizationCustomConditionFragment("(subject.id=" + subject.getId() + " OR global=true)");
+ }
+
+ CriteriaQueryRunner<SavedSearch> queryRunner = new CriteriaQueryRunner<SavedSearch>(criteria, generator,
+ entityManager);
+ return queryRunner.execute();
+ }
+
private void validateManipulatePermission(Subject subject, SavedSearch savedSearch) {
if (savedSearch.isGlobal()) {
if (!authorizationManager.isInventoryManager(subject)) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
index a1615ec..ffd4255 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -25,7 +25,9 @@ import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.system.ServerVersion;
@@ -99,4 +101,18 @@ public interface SavedSearchManagerRemote {
public SavedSearch getSavedSearchById( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "savedSearchId") int savedSearchId);
+
+ /**
+ * Returns the {@link PageList} of {@link SavedSearch} entities that match the criteria filters that are visible
+ * to the user
+ *
+ * @param subject the logged in user requesting the {@link PageList} of {@link SavedSearch} to be returned
+ * @param criteria the {@link SavedSearchCriteria} object that will filter the returned results
+ *
+ * @return the {@link PageList} of {@link SavedSearch} entities that match the criteria filters, an empty list
+ * will be returned if no results were found or none matches the given filters
+ */
+ public PageList<SavedSearch> findSavedSearchesByCriteria( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "criteria") SavedSearchCriteria criteria);
}
commit 8bee964f9c9fb494fc08a3baaa307361d826b445
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:48:32 2010 -0500
enhance the CriteriaQueryGenerator to allow more flexible authorization:
support users to set a completely arbitrary authorization fragment, which
will be inserted into the list of conditions for the generated query
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 9c62eed..bb0c072 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -58,13 +58,14 @@ public final class CriteriaQueryGenerator {
public enum AuthorizationTokenType {
RESOURCE, // specifies the resource alias to join on for standard res-group-role-subject authorization checking
- GROUP; // specifies the group alias to join on for standard group-role-subject authorization checking
+ GROUP; // specifies the group alias to join on for standard group-role-subject authorization checking
}
private Criteria criteria;
private String authorizationJoinFragment;
private String authorizationPermsFragment;
+ private String authorizationCustomConditionFragment;
private int authorizationSubjectId;
private String alias;
@@ -89,6 +90,10 @@ public final class CriteriaQueryGenerator {
this.alias = aliasBuilder.toString();
}
+ public void setAuthorizationCustomConditionFragment(String fragment) {
+ this.authorizationCustomConditionFragment = fragment;
+ }
+
public void setAuthorizationResourceFragment(AuthorizationTokenType type, int subjectId) {
String defaultFragment = null;
if (type == AuthorizationTokenType.RESOURCE) {
@@ -260,6 +265,16 @@ public final class CriteriaQueryGenerator {
}
}
+ if (authorizationCustomConditionFragment != null) {
+ if (firstCrit) {
+ firstCrit = false;
+ } else {
+ // always want AND for security, regardless of conjunctiveFragment
+ results.append(NL).append(" AND ");
+ }
+ results.append(this.authorizationCustomConditionFragment);
+ }
+
if (countQuery == false) {
boolean overridden = true;
PageControl pc = criteria.getPageControlOverrides();
commit d065f478b829887eda067308a10f98edef113b66
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 00:50:35 2010 -0500
initial SLSB support basic CRUD, with security restrictions, for saved search patterns
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
new file mode 100644
index 0000000..f672ac7
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
@@ -0,0 +1,104 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
+import org.rhq.enterprise.server.authz.PermissionException;
+
+/**
+ * This bean provides functionality to CRUD saved search patterns.
+ *
+ * @author Joseoh Marques
+ */
+@Stateless
+public class SavedSearchManagerBean implements SavedSearchManagerLocal /* local already implements remote interface */{
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ @EJB
+ private AuthorizationManagerLocal authorizationManager;
+
+ /**
+ * @see SavedSearchManagerRemote#createSavedSearch(Subject, SavedSearch)
+ */
+ public void createSavedSearch(Subject subject, SavedSearch savedSearch) {
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.persist(savedSearch);
+ return;
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#updateSavedSearch(Subject, SavedSearch)
+ */
+ public void updateSavedSearch(Subject subject, SavedSearch savedSearch) {
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.merge(savedSearch);
+ return;
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#deleteSavedSearch(Subject, int)
+ */
+ public void deleteSavedSearch(Subject subject, int savedSearchId) {
+ SavedSearch savedSearch = entityManager.find(SavedSearch.class, savedSearchId);
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.remove(savedSearch);
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#getSavedSearchById(Subject, int)
+ */
+ public SavedSearch getSavedSearchById(Subject subject, int savedSearchId) {
+ SavedSearch savedSearch = entityManager.find(SavedSearch.class, savedSearchId);
+ validateReadPermission(subject, savedSearch);
+ return savedSearch;
+ }
+
+ private void validateManipulatePermission(Subject subject, SavedSearch savedSearch) {
+ if (savedSearch.isGlobal()) {
+ if (!authorizationManager.isInventoryManager(subject)) {
+ throw new PermissionException("Only inventory managers can manipulate global saved searches");
+ }
+ // note: inventory managers can modify any saved search pattern, not just their own
+ } else {
+ if (subject.equals(savedSearch.getSubject())) {
+ throw new PermissionException("Users without inventory manager permission "
+ + "can only manipulate their own saved searches");
+ }
+ }
+ }
+
+ private void validateReadPermission(Subject subject, SavedSearch savedSearch) {
+ if (!savedSearch.isGlobal()) {
+ if (subject.equals(savedSearch.getSubject())) {
+ throw new PermissionException("Users without inventory manager permission "
+ + "can only view their own or global saved saved searches");
+ }
+ }
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java
new file mode 100644
index 0000000..7ced552
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java
@@ -0,0 +1,31 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.Local;
+
+/**
+ * The local interface to the SavedSearchManager.
+ *
+ * @author Joseph Marques
+ */
+@Local
+public interface SavedSearchManagerLocal extends SavedSearchManagerRemote {
+ // there are currently no methods in the local interface that do not exist in the remote interface
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
new file mode 100644
index 0000000..a1615ec
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -0,0 +1,102 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.Remote;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.enterprise.server.authz.PermissionException;
+import org.rhq.enterprise.server.system.ServerVersion;
+
+/**
+ * The remote interface to the SavedSearchManager.
+ *
+ * @author Joseph Marques
+ */
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(targetNamespace = ServerVersion.namespace)
+@Remote
+public interface SavedSearchManagerRemote {
+
+ /**
+ * Persisted a new {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} deletion
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be deleted
+ *
+ * @throws PermissionException if the user is not authorized to create the {@link SavedSearch}. Only inventory
+ * managers can create global saved searches. Regular users can only create {@link SavedSearch}es against
+ * their own accounts.
+ */
+ @WebMethod
+ public void createSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearch") SavedSearch savedSearch);
+
+ /**
+ * Saves all changes to the passed {@link SavedSearch} database, correlating it to the record already
+ * persisted with the same primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} persisted modification
+ * @param savedSearchId the {@link SavedSearch} which will have its modifications persisted
+ *.
+ * @throws PermissionException if the user is not authorized to modify the {@link SavedSearch}. Only inventory
+ * managers can update global saved searches. Regular users can only update {@link SavedSearch}es from
+ * their own accounts.
+ */
+ @WebMethod
+ public void updateSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearch") SavedSearch savedSearch);
+
+ /**
+ * Deletes the {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} deletion
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be deleted
+ *
+ * @throws PermissionException if the user is not authorized to delete the {@link SavedSearch}. Only inventory
+ * managers can delete global saved searches. Regular users can only delete {@link SavedSearch}es from
+ * their own accounts.
+ */
+ @WebMethod
+ public void deleteSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearchId") int savedSearchId);
+
+ /**
+ * Returns the {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} to be loaded
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be loaded
+ *
+ * @return the {@link SavedSearch} or <code>null</code> if it wasn't found
+ * @throws PermissionException if the user is not authorized to view the {@link SavedSearch}. Regular users can
+ * only view {@link SavedSearch}es from their own accounts.
+ */
+ @WebMethod
+ public SavedSearch getSavedSearchById( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearchId") int savedSearchId);
+}
commit c95388946134a47b002f5821c3a168db6f549355
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:31 2010 -0500
saved search hibernate entities
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
new file mode 100644
index 0000000..9142772
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
@@ -0,0 +1,253 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.search;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.auth.Subject;
+
+/**
+ * The data model for saved searches. Each users has his or her own set of
+ * saved searches, but inventory managers are allowed to "promote" their
+ * saved searches to GLOBAL status, which makes them available to all users
+ * under that installation of RHQ.
+ *
+ * There are two levels of pre-computed data within this structured. After
+ * the {@link SavedSearch} is created, the pattern will be translated into its
+ * JPQL equivalent and stored. If the {@link SavedSearch} is ever modified
+ * and saved, the JPQL will be re-computed.
+ *
+ * Periodically, the count-query version of the {@link SavedSearch} will be
+ * executed (using the stored JPQL), and the number of matching records will
+ * be stored. If this {@link SavedSearch} ever needs to be displayed on the
+ * user interface, it will by default retrieve this cached result count.
+ *
+ * @author Joseph Marques
+ */
+@Entity
+@SequenceGenerator(name = "id", sequenceName = "RHQ_SAVED_SEARCH_ID_SEQ")
+@Table(name = "RHQ_SAVED_SEARCH")
+public class SavedSearch {
+
+ @Id
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
+ private Integer id;
+
+ @Column(name = "CONTEXT", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private SearchContext context;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+ @Column(name = "PATTERN", nullable = false)
+ private String pattern;
+
+ @Column(name = "JPQL_TRANSLATION")
+ private String jpqlTranslation;
+
+ @Column(name = "LAST_COMPUTE_TIME", nullable = false)
+ private long lastComputeTime;
+
+ @Column(name = "RESULT_COUNT")
+ private Long resultCount;
+
+ @Column(name = "SUBJECT_ID", nullable = false)
+ private Subject subject;
+
+ @Column(name = "RESOURCE_ID", insertable = false, updatable = false)
+ private int subjectId;
+
+ @Column(name = "GLOBAL", nullable = false)
+ private boolean global;
+
+ protected SavedSearch() {
+ // no-arg ctor for Hibernate
+ }
+
+ public SavedSearch(SearchContext context, String name, String pattern, Subject subject) {
+ // call setters to go through parameter validation
+ setContext(context);
+ setPattern(pattern);
+ setSubject(subject);
+ setName(name); // name can be null, to allow for saving searches quickly
+
+ this.description = null;
+ this.jpqlTranslation = null; // null value for pre-computed JPQL implies computation is needed
+ this.lastComputeTime = 0; // further imply that computation needs to occur
+ this.resultCount = null; // NULL resultCount implies either computation failed or hasn't begun yet
+ this.global = false; // user must promote saved search to be a global after creation
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public SearchContext getContext() {
+ return context;
+ }
+
+ private void setContext(SearchContext context) {
+ if (context == null) {
+ throw new IllegalArgumentException("All saved searches must be bound to a SearchContext");
+ }
+ this.context = context;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ private void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public void setPattern(String pattern) {
+ if (pattern == null || pattern.trim().equals("")) {
+ throw new IllegalArgumentException("All saved searches must have a non-empty pattern");
+ }
+ this.pattern = pattern;
+ }
+
+ public String getJpqlTranslation() {
+ return jpqlTranslation;
+ }
+
+ public void setJpqlTransation(String jpqlTranslation) {
+ this.jpqlTranslation = jpqlTranslation;
+ }
+
+ public long getLastComputeTime() {
+ return lastComputeTime;
+ }
+
+ public void setLastComputeTime(long lastComputeTime) {
+ this.lastComputeTime = lastComputeTime;
+ }
+
+ public Long getResultCount() {
+ return resultCount;
+ }
+
+ public void setResultCount(Long resultCount) {
+ this.resultCount = resultCount;
+ }
+
+ public Subject getSubject() {
+ return subject;
+ }
+
+ private void setSubject(Subject subject) {
+ if (subject == null) {
+ throw new IllegalArgumentException("All saved searches must be owned by a specific user");
+ }
+ this.subject = subject;
+ this.subjectId = subject.getId();
+ }
+
+ public int getSubjectId() {
+ return subjectId;
+ }
+
+ public boolean isGlobal() {
+ return global;
+ }
+
+ public void setGlobal(boolean global) {
+ this.global = global;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + subjectId;
+ result = (prime * result) + context.hashCode();
+ result = (prime * result) + ((name == null) ? 0 : name.hashCode());
+ result = (prime * result) + pattern.hashCode();
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof SavedSearch))) {
+ return false;
+ }
+
+ final SavedSearch other = (SavedSearch) obj;
+
+ if (subjectId != other.subjectId) {
+ return false;
+ }
+
+ if (context != other.context) {
+ return false;
+ }
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ if (!pattern.equals(other.pattern)) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java
new file mode 100644
index 0000000..bb045d5
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java
@@ -0,0 +1,38 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.search;
+
+/**
+ * The search mechanism is generic and, thus, suited to finding data in any
+ * RHQ subsystem, including its own. Each individual page in the UI can have
+ * different advanced syntax. This enum will serve as a unique identifier
+ * for which context is currently active. You can think of it as a piece of
+ * meta-data that annotates each saved search, representing which context it
+ * belongs to. This will also affect which grammar is used to auto-complete
+ * search expressions.
+ *
+ * @author Joseph Marques
+ */
+public enum SearchContext {
+ Resource, Group;
+}
commit c9d080cc510d6e4bf5c26c34f7b9050544736da3
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:19 2010 -0500
saved search dbupgrade scripts
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 1d4d3dd..2fb6a90 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.79</db.schema.version>
+ <db.schema.version>2.82</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 9af6aa5..834e9ce 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3202,6 +3202,31 @@
</statement>
</schema-directSQL>
</schemaSpec>
+
+ <schemaSpec version="2.82">
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_SAVED_SEARCH">
+ CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="PATTERN" columnType="VARCHAR2" precision="1000" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="PATTERN" nullable="FALSE" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="JPQL_TRANSLATION" columnType="VARCHAR2" precision="4000" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="RESULT_COUNT" columnType="LONG" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
+ </schemaSpec>
</dbupgrade>
</target>
</project>
commit afc78a9b2bfcb14b5b079ffb29aa82c4e6b0e81f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:07 2010 -0500
saved searches dbsetup scripts
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
index 047d615..f5e4eae 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
@@ -39,7 +39,7 @@ To run the default target, you must set one of the following properties to true:
<property name="dbsetup.scripts.dir" value="${basedir}/src/main/scripts/dbsetup" />
<property name="dbsetup.output.dir" value="${basedir}/target/dbsetup" /> <!-- away from classes so it doesn't go into the jar -->
<!-- define the setup creation processing order. note, removals are done in the reverse order -->
- <property name="dbsetup.subsystems" value="config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
+ <property name="dbsetup.subsystems" value="search,config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
<property name="dbsetup.combined.schema" value="${dbsetup.output.dir}/all-schema.xml" />
<property name="dbsetup.combined.data" value="${dbsetup.output.dir}/all-data.xml" />
<property name="dbsetup.tstamp.file" value="${dbsetup.output.dir}/dbsetup-combine.tstamp" />
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
new file mode 100644
index 0000000..7c0de23
--- /dev/null
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<dbsetup name="amps-schema.xml"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-dbsetup-schema">
+
+ <table name="RHQ_SAVED_SEARCH">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="CONTEXT" type="VARCHAR2" size="25" required="true"/>
+
+ <column name="NAME" type="VARCHAR2" size="200" required="true"/>
+ <column name="DESCRIPTION" type="VARCHAR2" size="500" required="false"/>
+ <column name="PATTERN" type="VARCHAR2" size="1000" required="true"/>
+
+ <column name="JPQL_TRANSLATION" type="VARCHAR2" size="4000" required="false"/>
+ <column name="LAST_COMPUTE_TIME" type="LONG" required="true"/>
+ <column name="RESULT_COUNT" type="LONG" required="false"/>
+
+ <column name="SUBJECT_ID" type="INTEGER" references="RHQ_SUBJECT" required="true"/>
+ <column name="ENABLED" type="BOOLEAN" required="true"/>
+ </table>
+
+</dbsetup>
\ No newline at end of file
commit 6d87241b69c095bd2928f4e3b03bc9dcfbeeefd1
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Sat Feb 20 10:49:01 2010 +0100
Fix potential NPE
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
index 5ed6d4f..b90def3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
@@ -113,8 +113,8 @@ public class AlertNotificationLog implements Serializable {
@PrePersist
@PreUpdate
public void trimMessage() {
- if (message.length()>255)
- message = message.substring(0,254);
+ if (message!=null && message.length()>255)
+ message = message.substring(0,255);
}
protected AlertNotificationLog() {
commit 2d38d85bb4500c1a873aba7b193fb9984d00539d
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Sat Feb 20 09:47:10 2010 +0100
Truncate the message at 140 chars, as identi.ca bails out on longer messages; seems to improve stability with Twitter too.
Introduce abbreviated versions of the messages as space on Microblog etc is scarce. BZ 555091
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
index ba75940..5ed6d4f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
@@ -38,6 +38,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -108,6 +110,13 @@ public class AlertNotificationLog implements Serializable {
@Transient
transient List<String> transientEmails = new ArrayList<String>();
+ @PrePersist
+ @PreUpdate
+ public void trimMessage() {
+ if (message.length()>255)
+ message = message.substring(0,254);
+ }
+
protected AlertNotificationLog() {
} // JPA
@@ -130,7 +139,6 @@ public class AlertNotificationLog implements Serializable {
public AlertNotificationLog(Alert alert, String senderName, ResultState state, String message) {
this.alert = alert;
- this.sender = sender;
this.resultState = state;
this.message = message;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
index 454b9a9..ff4025f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
@@ -780,7 +780,7 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
Map<String, String> alertMessage = emailManager.getAlertEmailMessage(
prettyPrintResourceHierarchy(alertDefinition.getResource()), alertDefinition.getResource().getName(),
alertDefinition.getName(), alertDefinition.getPriority().toString(), new Date(alert.getCtime()).toString(),
- prettyPrintAlertConditions(alert.getConditionLogs()), prettyPrintAlertURL(alert));
+ prettyPrintAlertConditions(alert.getConditionLogs(), false), prettyPrintAlertURL(alert));
String messageSubject = alertMessage.keySet().iterator().next();
String messageBody = alertMessage.values().iterator().next();
@@ -834,13 +834,14 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
/**
* Create a human readable description of the conditions that led to this alert.
* @param alert Alert to create human readable condition description
+ * @param shortVersion if true the messages printed are abbreviated to save space
* @return human readable condition log
*/
- public String prettyPrintAlertConditions(Alert alert) {
- return prettyPrintAlertConditions(alert.getConditionLogs());
+ public String prettyPrintAlertConditions(Alert alert, boolean shortVersion) {
+ return prettyPrintAlertConditions(alert.getConditionLogs(), shortVersion);
}
- private String prettyPrintAlertConditions(Set<AlertConditionLog> conditionLogs) {
+ private String prettyPrintAlertConditions(Set<AlertConditionLog> conditionLogs, boolean shortVersion) {
StringBuilder builder = new StringBuilder();
int conditionCounter = 1;
@@ -858,16 +859,27 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
builder.append(NEW_LINE);
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT,
- conditionCounter, prettyPrintAlertCondition(aLog.getCondition()), new SimpleDateFormat(
- "yyyy/MM/dd HH:mm:ss z").format(new Date(aLog.getCtime())), formattedValue));
+ String format;
+ if (shortVersion)
+ format = AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT_SHORT;
+ else
+ format = AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT;
+ SimpleDateFormat dateFormat;
+ if (shortVersion)
+ dateFormat= new SimpleDateFormat(
+ "yy/MM/dd HH:mm:ss z");
+ else
+ dateFormat= new SimpleDateFormat(
+ "yyyy/MM/dd HH:mm:ss z");
+ builder.append(AlertI18NFactory.getMessage(format,
+ conditionCounter, prettyPrintAlertCondition(aLog.getCondition(), shortVersion), dateFormat.format(new Date(aLog.getCtime())), formattedValue));
conditionCounter++;
}
return builder.toString();
}
- private String prettyPrintAlertCondition(AlertCondition condition) {
+ private String prettyPrintAlertCondition(AlertCondition condition, boolean shortVersion) {
StringBuilder builder = new StringBuilder();
AlertConditionCategory category = condition.getCategory();
@@ -915,19 +927,38 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
} else if ((category == AlertConditionCategory.RESOURCE_CONFIG) || (category == AlertConditionCategory.CHANGE)
|| (category == AlertConditionCategory.TRAIT)) {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED));
+
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED));
+
} else if (category == AlertConditionCategory.EVENT) {
if ((condition.getOption() != null) && (condition.getOption().length() > 0)) {
+ String propsCbEventSeverityRegexMatch;
+ if (shortVersion)
+ propsCbEventSeverityRegexMatch = AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH_SHORT;
+ else
+ propsCbEventSeverityRegexMatch = AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH;
+
builder.append(AlertI18NFactory.getMessage(
- AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH, condition.getName(),
+ propsCbEventSeverityRegexMatch, condition.getName(),
condition.getOption()));
} else {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY,
- condition.getName()));
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT,
+ condition.getName()));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY,
+ condition.getName()));
}
} else if (category == AlertConditionCategory.AVAILABILITY) {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
- condition.getOption()));
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT,
+ condition.getOption()));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
+ condition.getOption()));
} else {
// do nothing
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
index 996f245..e482ffa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
@@ -96,9 +96,10 @@ public interface AlertManagerLocal {
/**
* Create a human readable description of the conditions that led to this alert.
* @param alert Alert to create human readable condition description
+ * @param shortVersion if true the messages printed are abbreviated to save space
* @return human readable condition log
*/
- String prettyPrintAlertConditions(Alert alert);
+ String prettyPrintAlertConditions(Alert alert, boolean shortVersion);
/**
* Tells us if the definition of the passed alert will be disabled after this alert was fired
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
index 8734771..1de3d85 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
@@ -32,20 +32,41 @@ public interface AlertI18NResourceKeys {
@I18NMessage(locale = "de", value = "Verfgbarkeit wird {0}") })
String ALERT_CONFIG_PROPS_CB_AVAILABILITY = "alert.config.props.CB.Availability";
+ @I18NMessages( { @I18NMessage("Avail goes {0}"),
+ @I18NMessage(locale = "de", value = "Verf. wird {0}") })
+ String ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT = "alert.config.props.CB.Availability.short";
+
@I18NMessages( { @I18NMessage("Event Severity: {0}"),
@I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0}") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY = "alert.config.props.CB.EventSeverity";
+ @I18NMessages( { @I18NMessage("Sev: {0}"),
+ @I18NMessage(locale = "de", value = "Schwere: {0}") })
+ String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT = "alert.config.props.CB.EventSeverity.short";
+
@I18NMessages( { @I18NMessage("Event Severity: {0} and matching expression \"{1}\""),
@I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0} und zugehriger Ausdruck \"{1}\"") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH = "alert.config.props.CB.EventSeverity.RegexMatch";
+ @I18NMessages( { @I18NMessage("Sev: {0} & exp \"{1}\""),
+ @I18NMessage(locale = "de", value = "Schwere: {0} & Ausdruck \"{1}\"") })
+ String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH_SHORT = "alert.config.props.CB.EventSeverity.RegexMatch.short";
+
@I18NMessages( { @I18NMessage("value changed"), @I18NMessage(locale = "de", value = "Der Wert hat sich gendert") })
String ALERT_CURRENT_LIST_VALUE_CHANGED = "alert.current.list.ValueChanged";
+ @I18NMessages( { @I18NMessage("val chg"), @I18NMessage(locale = "de", value = "Wertnd.") })
+ String ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT = "alert.current.list.ValueChanged.short";
+
@I18NMessages( {
@I18NMessage("\\ - Condition {0}: {1}\\n\\\n" + "\\ - Date/Time: {2}\\n\\\n" + "\\ - Details: {3}\\n\\\n"),
@I18NMessage(locale = "de", value = " - Bedingung {0}: {1}\\n\\\n - Datum/Uhrzeit: {2}\\n\\\n"
+ "\\ - Details: {3}\\n\\\n") })
String ALERT_EMAIL_CONDITION_LOG_FORMAT = "alert.email.condition.log.format";
+
+ @I18NMessages( {
+ @I18NMessage("\\ - Cond {0}: {1}\\n\\\n" + "\\ - Time: {2}\\n\\\n" + "\\ - Det: {3}\\n\\\n"),
+ @I18NMessage(locale = "de", value = " - Bed {0}: {1}\\n\\\n - Zeit: {2}\\n\\\n"
+ + "\\ - Det: {3}\\n\\\n") })
+ String ALERT_EMAIL_CONDITION_LOG_FORMAT_SHORT = "alert.email.condition.log.format.short";
}
\ No newline at end of file
diff --git a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
index 93eecc6..95abdb9 100644
--- a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
+++ b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
@@ -65,7 +65,7 @@ public class IrcSender extends AlertSender<IrcAlertComponent> {
b.append("): ");
b.append(alertManager.prettyPrintAlertURL(alert));
b.append("\n");
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, false));
return b.toString();
}
diff --git a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
index 257b315..b13763e 100644
--- a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
+++ b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
@@ -57,14 +57,19 @@ public class MicroblogSender extends AlertSender {
b.append("' (");
b.append(alert.getAlertDefinition().getResource().getId());
b.append("): ");
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, true));
b.append("-by @JBossJopr"); // TODO not for production :-)
// TODO use some alert url shortening service
SenderResult result ;
String txt = "user@baseUrl [" + user + "@" + baseUrl + "]:";
try {
- Status status = twitter.updateStatus(b.toString());
+ String msg = b.toString();
+ if (msg.length()>140)
+ msg = msg.substring(0,140);
+
+ Status status = twitter.updateStatus(msg);
+
result = new SenderResult(ResultState.SUCCESS,"Send notification to " + txt + ", msg-id: " + status.getId());
} catch (TwitterException e) {
diff --git a/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java b/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
index 649d6ed..b14c85d 100644
--- a/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
+++ b/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
@@ -74,7 +74,7 @@ public class MobicentsSender extends AlertSender {
// Switch locale to english, as the voice synthesizer expects this for now
Locale currentLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, false));
Locale.setDefault(currentLocale);
boolean willBeDisabled = alertManager.willDefinitionBeDisabled(alert);
diff --git a/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java b/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
index 985d890..bac51fb 100644
--- a/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
+++ b/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
@@ -93,7 +93,7 @@ public class ScriptLangSender extends AlertSender<ScriptLangComponent> {
Object[] args = new Object[3];
args[0] = alert;
args[1] = alertManager.prettyPrintAlertURL(alert);
- args[2] = alertManager.prettyPrintAlertConditions(alert);
+ args[2] = alertManager.prettyPrintAlertConditions(alert, false);
result = ((Invocable) engine).invokeFunction("sendAlert", args);
if (result == null) {
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
index 3fd5d79..045c3bb 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
@@ -68,7 +68,7 @@ public class SnmpSender extends AlertSender {
String result;
List<Resource> lineage = resourceManager.getResourceLineage(alert.getAlertDefinition().getResource().getId());
String platformName = lineage.get(0).getName();
- String conditions = alertManager.prettyPrintAlertConditions(alert);
+ String conditions = alertManager.prettyPrintAlertConditions(alert, false);
String alertUrl = alertManager.prettyPrintAlertURL(alert);
SenderResult res ;
commit 798ac30ead634c43a72beed52446a38d9bfc1f09
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:51:53 2010 -0500
i think this should report an error always on lock acq failure. we'll leave the flag alone - don't set it to true - let the next call take care of whether or not the init callback should be invoked or not
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 8c37b50..cd3b479 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -588,11 +588,9 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
writeLock.unlock();
}
} else {
- if (m_needToCallInitializeCallback) {
- Throwable t = new Throwable("Initialize callback lock could not be acquired");
- LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
- return new GenericCommandResponse(command, false, null, t);
- }
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
}
}
return null;
commit 9746ea32492b638eacb741d608d9ce17349c925d
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:44:11 2010 -0500
should not worry about the lock failure if the init callback doesn't need to be invoked anyway
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 762b9b4..8c37b50 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -588,10 +588,11 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
writeLock.unlock();
}
} else {
- m_needToCallInitializeCallback = true; // can't invoke callback, we'll want to still call it later
- Throwable t = new Throwable("Initialize callback lock could not be acquired");
- LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
- return new GenericCommandResponse(command, false, null, t);
+ if (m_needToCallInitializeCallback) {
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
+ }
}
}
return null;
commit c2cca917c88986ca48c84bbbdaf3408753299bf1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:38:16 2010 -0500
BZ 537396 - to not block indefinitely if a lock cannot be acquired before attempting to invoke the initialize callback
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 3775212..762b9b4 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -21,6 +21,9 @@ package org.rhq.enterprise.communications.command.client;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import mazz.i18n.Logger;
@@ -95,10 +98,22 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
private InitializeCallback m_initializeCallback;
/**
- * When the first element is <code>true</code>, the initialize callback will need to be called prior
- * to sending any commands. This is an array because the array itself is used for its lock.
+ * When <code>true</code>, the initialize callback will need to be called prior
+ * to sending any commands. Used in conjunection with its associated RW lock.
*/
- private final boolean[] m_needToCallInitializeCallback;
+ private boolean m_needToCallInitializeCallback;
+
+ /**
+ * RW lock when needing to access its associated atomic boolean flag.
+ */
+ private final ReentrantReadWriteLock m_needToCallInitializeCallbackLock;
+
+ /**
+ * Number of minutes to wait while attempting to aquire a lock before attempting
+ * to invoke the initialize callback. If this amount of minutes expires before the lock
+ * is acquired, an error will occur and the initialize callback will have to be attempted later.
+ */
+ private final long m_initializeCallbackLockAcquisitionTimeoutMins;
/**
* Constructor for {@link JBossRemotingRemoteCommunicator} that initializes the client with no invoker locator
@@ -200,7 +215,17 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
m_clientConfiguration.putAll(client_config);
}
- m_needToCallInitializeCallback = new boolean[] { false };
+ m_needToCallInitializeCallback = false;
+ m_needToCallInitializeCallbackLock = new ReentrantReadWriteLock();
+
+ long mins;
+ try {
+ String minsStr = System.getProperty("rhq.communications.initial-callback-lock-wait-mins", "60");
+ mins = Long.parseLong(minsStr);
+ } catch (Throwable t) {
+ mins = 60L;
+ }
+ m_initializeCallbackLockAcquisitionTimeoutMins = mins;
return;
}
@@ -319,7 +344,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
if (m_remotingClient != null) {
m_remotingClient.disconnect();
m_remotingClient = null;
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
LOG.info(CommI18NResourceKeys.COMMUNICATOR_CHANGING_ENDPOINT, m_invokerLocator, locator);
@@ -377,7 +402,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void setInitializeCallback(InitializeCallback callback) {
m_initializeCallback = callback;
- m_needToCallInitializeCallback[0] = (callback != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (callback != null); // specifically do not synchrononize by using lock, just set it
}
public String getRemoteEndpoint() {
@@ -403,7 +428,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void connect() throws Exception {
if ((m_remotingClient != null) && !m_remotingClient.isConnected()) {
m_remotingClient.connect();
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
return;
@@ -412,7 +437,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void disconnect() {
if (m_remotingClient != null) {
m_remotingClient.disconnect();
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
return;
@@ -535,18 +560,38 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
private CommandResponse invokeInitializeCallbackIfNeeded(Command command) {
InitializeCallback callback = getInitializeCallback();
if (callback != null) {
- // block here - in effect, this will stop all commands from going out until the callback is done
- synchronized (m_needToCallInitializeCallback) {
- if (m_needToCallInitializeCallback[0]) {
- try {
- m_needToCallInitializeCallback[0] = !callback.sendingInitialCommand(this, command);
- LOG.debug(CommI18NResourceKeys.INITIALIZE_CALLBACK_DONE, m_needToCallInitializeCallback[0]);
- } catch (Throwable t) {
- m_needToCallInitializeCallback[0] = true; // callback failed, we'll want to call it again
- LOG.error(t, CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, ThrowableUtil.getAllMessages(t));
- return new GenericCommandResponse(command, false, null, t);
+ // block here - in effect, this will stop all commands from going out until the callback is done
+ // to avoid infinite blocking, we'll only wait for a set time (though long).
+
+ WriteLock writeLock = m_needToCallInitializeCallbackLock.writeLock();
+ boolean locked;
+ try {
+ locked = writeLock.tryLock(m_initializeCallbackLockAcquisitionTimeoutMins, TimeUnit.MINUTES);
+ } catch (InterruptedException ie) {
+ locked = false;
+ }
+
+ if (locked) {
+ try {
+ if (m_needToCallInitializeCallback) {
+ try {
+ m_needToCallInitializeCallback = (!callback.sendingInitialCommand(this, command));
+ LOG.debug(CommI18NResourceKeys.INITIALIZE_CALLBACK_DONE, m_needToCallInitializeCallback);
+ } catch (Throwable t) {
+ m_needToCallInitializeCallback = true; // callback failed, we'll want to call it again
+ LOG.error(t, CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, ThrowableUtil
+ .getAllMessages(t));
+ return new GenericCommandResponse(command, false, null, t);
+ }
}
+ } finally {
+ writeLock.unlock();
}
+ } else {
+ m_needToCallInitializeCallback = true; // can't invoke callback, we'll want to still call it later
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
}
}
return null;
commit 55ba6f8778820bdd417e99909220136a2e1e091f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 11:10:53 2010 -0500
BZ 566724 - if classloader fails to be created, master PC will skip the plugin
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
index f46eaf5..bd4feac 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
@@ -136,16 +136,23 @@ public class MasterServerPluginContainer {
String pluginName = descriptor.getName();
ServerPluginType pluginType = new ServerPluginType(descriptor);
PluginKey pluginKey = PluginKey.createServerPluginKey(pluginType.stringify(), pluginName);
- ClassLoader classLoader = this.classLoaderManager.obtainServerPluginClassLoader(pluginKey);
- log.debug("Pre-loading server plugin [" + pluginKey + "] from [" + pluginUrl
- + "] into its plugin container");
try {
- ServerPluginEnvironment env = new ServerPluginEnvironment(pluginUrl, classLoader, descriptor);
- boolean enabled = !allDisabledPlugins.contains(pluginKey);
- pc.loadPlugin(env, enabled);
- log.info("Preloaded server plugin [" + pluginKey.getPluginName() + "]");
+ ClassLoader classLoader = this.classLoaderManager.obtainServerPluginClassLoader(pluginKey);
+ log.debug("Pre-loading server plugin [" + pluginKey + "] from [" + pluginUrl
+ + "] into its plugin container");
+ try {
+ ServerPluginEnvironment env = new ServerPluginEnvironment(pluginUrl, classLoader,
+ descriptor);
+ boolean enabled = !allDisabledPlugins.contains(pluginKey);
+ pc.loadPlugin(env, enabled);
+ log.info("Preloaded server plugin [" + pluginName + "]");
+ } catch (Exception e) {
+ log.warn("Failed to preload server plugin [" + pluginName + "] from URL [" + pluginUrl
+ + "]", e);
+ }
} catch (Exception e) {
- log.warn("Failed to preload server plugin [" + pluginUrl + "]", e);
+ log.warn("Failed to preload server plugin [" + pluginName
+ + "]; cannot get its classloader from URL [ " + pluginUrl + "]", e);
}
} else {
log.warn("There is no server plugin container to support plugin: " + pluginUrl);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
index 9f27ce9..fa26970 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
@@ -64,7 +64,7 @@ public class ServerPluginClassLoader extends URLClassLoader {
try {
unpackedDirectory = unpackEmbeddedJars(pluginJarName, pluginUrl, classpathUrlList, tmpDirectory);
} catch (Exception e) {
- throw new Exception("Failed to unpack embedded JARs within: " + pluginUrl);
+ throw new Exception("Failed to unpack embedded JARs within: " + pluginUrl, e);
}
}
}
commit 2ffc564d7ff69a427755fa374419bc5980e47f94
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Fri Feb 19 13:37:36 2010 +0100
Fix link to definitions BZ 566004
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
index b6e386c..fd09f82 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
@@ -148,8 +148,7 @@
</onc:sortableColumnHeader>
</f:facet>
- <h:outputLink value="/alerts/Config.do">
- <f:param name="mode" value="viewRoles"/>
+ <h:outputLink value="/rhq/resource/alert/viewAlert.xhtml">
<f:param name="id" value="#{Resource.id}"/>
<f:param name="ad" value="#{item.alert.alertDefinition.id}"/>
<h:outputText value="#{item.alert.alertDefinition.name}" />
14 years, 2 months
[rhq] Branch 'linux-config' - 31 commits - .classpath modules/core modules/enterprise
by Partha Aji
.classpath | 1
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup-build.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml | 25
modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml | 23
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 51 ++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java | 142 +++++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java | 253 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java | 38 +
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java | 2
modules/enterprise/server/jar/pom.xml | 47 +
modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g | 181 +++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 66 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java | 120 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java | 31 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java | 119 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 6
modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt | 126 ++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java | 171 ++++++
21 files changed, 1384 insertions(+), 41 deletions(-)
New commits:
commit 6445fb2b8895d354c5621ff8a5c9fa26f1189672
Merge: 589df77... 6278e70...
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Mar 1 09:49:07 2010 -0500
Merge branch 'master' into linux-config
commit 6278e7056403b2dcd0ffde84a7109e60790022eb
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:55:32 2010 -0500
simplify dbupgrade by merge saved search-related entries into a single schemaSpec
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 6fe555e..b2b3b11 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3231,9 +3231,7 @@
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
- </schemaSpec>
-
- <schemaSpec version="2.82.1">
+
<schema-directSQL>
<statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Platforms'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
commit a6efa283222790b6e22f82861b1c145e34af9391
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:54:58 2010 -0500
insert some default global searches into the system during dbsetup
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
index 1a11114..da98622 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -10,7 +10,7 @@
DESCRIPTION="All downed machines across the entire enterprise"
PATTERN="down platform"
LAST_COMPUTE_TIME="0"
- SUBJECT="1"
+ SUBJECT_ID="1"
GLOBAL="TRUE" />
<data ID="2"
CONTEXT="Resource"
@@ -18,7 +18,7 @@
DESCRIPTION="All downed servers across the entire enterprise"
PATTERN="down server"
LAST_COMPUTE_TIME="0"
- SUBJECT="1"
+ SUBJECT_ID="1"
GLOBAL="TRUE" />
</table>
commit 1d02547312924f4904730bb0aebe7d0d8d9b70d2
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:21:37 2010 -0500
fix typo for column name in saved search table
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
index 7c0de23..14634b6 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
@@ -17,7 +17,7 @@
<column name="RESULT_COUNT" type="LONG" required="false"/>
<column name="SUBJECT_ID" type="INTEGER" references="RHQ_SUBJECT" required="true"/>
- <column name="ENABLED" type="BOOLEAN" required="true"/>
+ <column name="GLOBAL" type="BOOLEAN" required="true"/>
</table>
</dbsetup>
\ No newline at end of file
commit 92adfd37e105c60efc0f1981d7fc2258ee423ad5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:05:08 2010 -0500
change order of dbsetup so that saved search table gets created after the rhq_subject table
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
index f5e4eae..d5be746 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
@@ -39,7 +39,7 @@ To run the default target, you must set one of the following properties to true:
<property name="dbsetup.scripts.dir" value="${basedir}/src/main/scripts/dbsetup" />
<property name="dbsetup.output.dir" value="${basedir}/target/dbsetup" /> <!-- away from classes so it doesn't go into the jar -->
<!-- define the setup creation processing order. note, removals are done in the reverse order -->
- <property name="dbsetup.subsystems" value="search,config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
+ <property name="dbsetup.subsystems" value="config,cluster,inventory,auth,authz,search,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
<property name="dbsetup.combined.schema" value="${dbsetup.output.dir}/all-schema.xml" />
<property name="dbsetup.combined.data" value="${dbsetup.output.dir}/all-data.xml" />
<property name="dbsetup.tstamp.file" value="${dbsetup.output.dir}/dbsetup-combine.tstamp" />
commit d0ef49e101ef7887e834b0a9021c0c0654a7f5d5
Merge: 613b993... 8a0951a...
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:34:50 2010 -0500
Merge branch 'master' into search
commit 613b993b85ac47117fda5d7f7810318e891cdf0e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:32:41 2010 -0500
construct AST from parse tree for RHQL grammar
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
index 00a0dab..ded91a1 100644
--- a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -27,11 +27,43 @@
* @author Joseph Marques
*/
grammar RHQL;
-
options {
language=Java;
backtrack=true;
memoize=true;
+ output=AST;
+ ASTLabelType=CommonTree;
+}
+
+/*
+ * Imaginary nodes serve to fully abstract the parse tree from the AST. This
+ * allows us, for example, to support the conjunctive ('and') operator between
+ * conditional expressions, but gives us the flexibility to modify the lexical
+ * element that represents that operation. In the future, we might want to
+ * support '&&' instead of 'and', or even support them both. The inclusion of
+ * imaginary tokens creates a more stable AST that downstream grammars can use
+ * without fear that every change to the syntax will break their tree parser.
+ */
+tokens {
+ OR;
+ AND;
+
+ CONTEXT;
+ LINEAGE;
+ PATH;
+ PARAM;
+ IDENT;
+ VALUE;
+
+ OP_EQUALS;
+ OP_EQUALS_STRICT;
+ OP_NULL;
+ OP_IN;
+
+ OP_NOT_EQUALS;
+ OP_NOT_EQUALS_STRICT;
+ OP_NOT_NULL;
+ OP_NOT_IN;
}
@header {
@@ -41,26 +73,29 @@ options {
package org.rhq.enterprise.server.search;
}
+
/*
* parser rules
*/
searchExpression
- : conditionalExpression
+ : conditionalExpression { System.out.println($conditionalExpression.tree.toStringTree()); }
;
conditionalExpression
- : conditionalFactor ( 'or' conditionalFactor )*
- ;
+ : conds+=conditionalFactor ( WS* ( 'or' ) WS* conds+=conditionalFactor )* -> { $conds.size() == 1 }? ^($conds)
+ -> ^(OR conditionalFactor+)
+ ; // use rewrite predicates to eliminate superfluous 'or' node if only one child
conditionalFactor
- : conditionalPrimary ( ( 'and' )? conditionalPrimary )*
- ;
+ : conds+=conditionalPrimary ( WS* ( 'and' WS* )? conds+=conditionalPrimary )* -> { $conds.size() == 1 }? ^($conds)
+ -> ^(AND conditionalPrimary+)
+ ; // use rewrite predicates to eliminate superfluous 'and' node if only one child
conditionalPrimary
- : simpleConditionalExpression
- | '(' conditionalExpression ')'
- ;
+ : WS* simpleConditionalExpression WS* -> simpleConditionalExpression
+ | '(' WS* conditionalExpression WS* ')' -> conditionalExpression
+ ; // avoid building nodes for parens, tree structure implies existence appropriately -- ignore captured WS
simpleConditionalExpression
: comparisonConditionalExpression
@@ -69,69 +104,78 @@ simpleConditionalExpression
;
comparisonConditionalExpression
- : context comparisonOperator identifier
- ;
+ : c=context WS* op=comparisonOperator WS* ident=identifier -> ^($op $c ^(VALUE $ident))
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
nullComparisonConditionalExpression
- : context nullOperator
- ;
+ : c=context WS* op=nullOperator -> ^($op $c)
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
inExpression
- : context inOperator '[' '='? identifier ( ',' '='? identifier )* ']'
- ;
+ : c=context WS* op=inOperator WS* '[' WS* ids+=identifier WS* ( ',' WS* ids+=identifier WS* )* ']'
+ -> ^($op $c ^(VALUE $ids+))
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
context
- : ( lineage '.' )? path ( '[' identifier ']' )?
+ : ( l=lineage '.' )? p=path ( '[' ident=identifier ']' )? -> ^(CONTEXT ^(LINEAGE $l)? ^(PATH $p) ^(PARAM $ident)?)
;
lineage
- : path ( '(' INT ')' )?
- ;
+ : path ( '('! LEVEL ')'! )?
+ ; // avoid building nodes for brackets, tree structure implies existence appropriately
path
: ID+
;
identifier
- : quotedValue
- | value
+ : doubleQuotedValue -> ^(IDENT doubleQuotedValue)
+ | quotedValue -> ^(IDENT quotedValue)
+ | openEndedvalue -> ^(IDENT openEndedvalue)
;
+doubleQuotedValue
+ : '"'! ~('"')* '"'!
+ ; // avoid building nodes for the double-quote characters
+
+
quotedValue
- : '\'' ~('\'')* '\''
- ;
+ : '\''! ~('\'')* '\''!
+ ; // avoid building nodes for the sinngle-quote characters
-value
- : ~('\'') ~(']'|','|')')*
- ;
+openEndedvalue
+ : ~(']' | ',' | ')' | '(' | 'or' | 'and' | WS )*
+ ; // consume until we find a char to terminate the current phrase ']' ',' ')' or begin the next '(' 'or' 'and'
comparisonOperator
- : '='
- | '=='
- | '!='
- | '!=='
- ;
+ : '=' -> ^(OP_EQUALS)
+ | '==' -> ^(OP_EQUALS_STRICT)
+ | '!=' -> ^(OP_NOT_EQUALS)
+ | '!==' -> ^(OP_NOT_EQUALS_STRICT)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
nullOperator
- : 'is' 'not'? 'null'
- ;
+ : 'is' WS+ (negation='not' WS+)? 'null' -> { $negation == null }? ^(OP_NULL)
+ -> ^(OP_NOT_NULL)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
inOperator
- : 'not'? 'in'
- ;
+ : (negation+='not' WS+)? 'in' -> { $negation == null }? ^(OP_IN)
+ -> ^(OP_NOT_IN)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
/*
* lexical elements
- */
+ */
ID
: 'a'..'z'
;
-INT
- : '0'..'9'
+LEVEL
+ : '0'..'5'
;
WS
- : ( ' ' | '\n' | '\r' )+ { $channel = HIDDEN; }
+ : ( ' ' | '\n' | '\r' )+
;
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
index 637e339..ceab3e3 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
@@ -62,6 +62,7 @@ public class RHQLTest extends AssertJUnit {
@Override
public TestResult call() throws Exception {
try {
+ System.out.println(line);
ANTLRStringStream input = new ANTLRStringStream(line); // Create an input character stream from standard in
RHQLLexer lexer = new RHQLLexer(input); // Create an echoLexer that feeds from that stream
CommonTokenStream tokens = new CommonTokenStream(lexer); // Create a stream of tokens fed by the lexer
commit eac78662084095c22fb80326643fbf59f0e1a863
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:31:54 2010 -0500
modify RHQL test case file to adhere to simpler syntax for IN-clause:
* remove multi-word non-quoted identifers for the IN-clause
* remove ability to change case-sensitivity comparison for IN-clause
diff --git a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
index 2a5a195..f8c241a 100644
--- a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
+++ b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
@@ -7,11 +7,11 @@ context !== value
context is null
context is not null
context in [value]
-context in [value1, =value2]
-context in [=value1, value2, value3]
+context in [value1, value2]
+context in [value1, value2, value3]
context not in [value]
-context not in [value1, =value2]
-context not in [=value1, value2, value3]
+context not in [value1, value2]
+context not in [value1, value2, value3]
# simple term, all operators, quoted value
context = 'quoted value'
@@ -21,19 +21,11 @@ context !== 'quoted value'
context is null
context is not null
context in ['quoted value1']
-context in ['quoted value1', ='quoted value2']
-context in [='quoted value1', 'quoted value2', 'quoted value3']
+context in ['quoted value1', 'quoted value2']
+context in ['quoted value1', 'quoted value2', 'quoted value3']
context not in ['quoted value1']
-context not in ['quoted value1', ='quoted value2']
-context not in [='quoted value1', 'quoted value2', 'quoted value3']
-
-# simple term, 'in' operator, non-quoted but multi-word values
-context in [quoted value1]
-context in [quoted value1, =quoted value2]
-context in [=quoted value1, quoted value2, quoted value3]
-context not in [quoted value1]
-context not in [quoted value1, =quoted value2]
-context not in [=quoted value1, quoted value2, quoted value3]
+context not in ['quoted value1', 'quoted value2']
+context not in ['quoted value1', 'quoted value2', 'quoted value3']
# parameterized term, all operators
context[param] = value
@@ -43,11 +35,11 @@ context[param] !== value
context[param] is null
context[param] is not null
context[param] in [value]
-context[param] in [value1, =value2]
-context[param] in [=value1, value2, value3]
+context[param] in [value1, value2]
+context[param] in [value1, value2, value3]
context[param] not in [value]
-context[param] not in [value1, =value2]
-context[param] not in [=value1, value2, value3]
+context[param] not in [value1, value2]
+context[param] not in [value1, value2, value3]
# deeply nested parenthetical simple terms
((context = value))
@@ -63,11 +55,11 @@ context[param] not in [=value1, value2, value3]
(context is null)
(context is not null)
(context in [value])
-(context in [value1, =value2])
-(context in [=value1, value2, value3])
+(context in [value1, value2])
+(context in [value1, value2, value3])
(context not in [value])
-(context not in [value1, =value2])
-(context not in [=value1, value2, value3])
+(context not in [value1, value2])
+(context not in [value1, value2, value3])
# parameterized parenthetical term, all operators
(context[param] = value)
@@ -77,11 +69,11 @@ context[param] not in [=value1, value2, value3]
(context[param] is null)
(context[param] is not null)
(context[param] in [value])
-(context[param] in [value1, =value2])
-(context[param] in [=value1, value2, value3])
+(context[param] in [value1, value2])
+(context[param] in [value1, value2, value3])
(context[param] not in [value])
-(context[param] not in [value1, =value2])
-(context[param] not in [=value1, value2, value3])
+(context[param] not in [value1, value2])
+(context[param] not in [value1, value2, value3])
# single-pair parenthetical combinations
@@ -131,4 +123,4 @@ context = value1 and ((context = value2))
((context = value1)) context = value2
(context = value1) (context = value2)
(context = value1 (context = value2))
-context = value1 ((context1 = value2))
\ No newline at end of file
+context = value1 ((context = value2))
\ No newline at end of file
commit 8a0951a835997a2cdc75d2cf9840a7a7fdf59c15
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 26 17:57:56 2010 +0100
BZ 568544 - disambiguation doesn't get confused if more than one item in the provided results corresponds to a signle resource.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
index 67f3276..dd359da 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
@@ -64,6 +64,6 @@ public class DisambiguationReport<T> implements Serializable {
}
public String toString() {
- return "DisambiguationReport(type=" + resourceTypeName + ", plugin=" + resourceTypePluginName + ", parents=" + parents + ")";
+ return "DisambiguationReport(type=" + resourceTypeName + ", plugin=" + resourceTypePluginName + ", parents=" + parents + ", original=" + original + ")";
}
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 3af7a35..e5684d2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -31,6 +31,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -2170,34 +2171,36 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
false);
}
- //this will contain the disambiguated results
- List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size());
boolean typeResolutionNeeded = false;
boolean pluginResolutionNeeded = false;
boolean parentResolutionNeeded = false;
//we can't assume the ordering of the provided results and the disambiguation query results
- //will be the same, hence this map.
- Map<Integer, MutableDisambiguationReport<T>> reportByResourceId = new HashMap<Integer, MutableDisambiguationReport<T>>();
+ //will be the same.
+
+ //this list contains the resulting reports in the same order as the original results
+ List<MutableDisambiguationReport<T>> reports = new ArrayList<MutableDisambiguationReport<T>>(results.size());
+
+ //this maps the reports to resourceIds. More than one report can correspond to a single
+ //resource id. The reports in this map are the same instances as in the reports list.
+ Map<Integer, List<MutableDisambiguationReport<T>>> reportsByResourceId = new HashMap<Integer, List<MutableDisambiguationReport<T>>>();
for (T r : results) {
MutableDisambiguationReport<T> value = new MutableDisambiguationReport<T>();
value.original = r;
int resourceId = extractor.extract(r);
if (resourceId > 0) {
- reportByResourceId.put(resourceId, value);
+ List<MutableDisambiguationReport<T>> correspondingResults = reportsByResourceId.get(resourceId);
+ if (correspondingResults == null) {
+ correspondingResults = new ArrayList<MutableDisambiguationReport<T>>();
+ reportsByResourceId.put(resourceId, correspondingResults);
+ }
+ correspondingResults.add(value);
}
+ reports.add(value);
}
//check that we still have something to disambiguate
- if (reportByResourceId.isEmpty()) {
- //no, we don't. construct the resolution only using the results.
-
- for (T result : results) {
- DisambiguationReport<T> report = new DisambiguationReport<T>(result, Collections
- .<ResourceParentFlyweight> emptyList(), null, null);
- resolution.add(report);
- }
- } else {
+ if (reportsByResourceId.size() > 0) {
//first find out how many ancestors we are going to require to disambiguate the resuls
String query = Resource.NATIVE_QUERY_FIND_DISAMBIGUATION_LEVEL;
@@ -2247,7 +2250,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
Query parentsQuery = entityManager.createQuery(selectBuilder.append(" ").append(fromBuilder).toString());
- parentsQuery.setParameter("resourceIds", reportByResourceId.keySet());
+ parentsQuery.setParameter("resourceIds", reportsByResourceId.keySet());
@SuppressWarnings("unchecked")
List<Object[]> parentsResults = (List<Object[]>) parentsQuery.getResultList();
@@ -2264,28 +2267,22 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
String parentName = (String) parentsResult[2 * i + 2];
parents.add(new ResourceParentFlyweight(parentId, parentName));
}
- MutableDisambiguationReport<T> report = reportByResourceId.get(resourceId);
- report.typeName = typeName;
- report.pluginName = pluginName;
- report.parents = parents;
- }
-
- //now we have all the information to create the result.
- for (T result : results) {
- int resourceId = extractor.extract(result);
- if (resourceId > 0) {
- //this results was disambiguated by the query above...
- MutableDisambiguationReport<T> report = reportByResourceId.get(resourceId);
- resolution.add(report.getReport());
- } else {
- //this result doesn't correspond to any resource, need to handle it specially
- DisambiguationReport<T> report = new DisambiguationReport<T>(result, Collections
- .<ResourceParentFlyweight> emptyList(), null, null);
- resolution.add(report);
+
+ //update all the reports that correspond to this resourceId
+ for(MutableDisambiguationReport<T> report : reportsByResourceId.get(resourceId)) {
+ report.typeName = typeName;
+ report.pluginName = pluginName;
+ report.parents = parents;
}
}
}
+ List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size());
+
+ for (MutableDisambiguationReport<T> report : reports) {
+ resolution.add(report.getReport());
+ }
+
return new ResourceNamesDisambiguationResult<T>(resolution, typeResolutionNeeded, parentResolutionNeeded,
pluginResolutionNeeded);
}
@@ -2297,7 +2294,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public List<ResourceParentFlyweight> parents;
public DisambiguationReport<T> getReport() {
- return new DisambiguationReport<T>(original, parents, typeName, pluginName);
+ return new DisambiguationReport<T>(original, parents == null ? Collections
+ .<ResourceParentFlyweight> emptyList() : parents, typeName, pluginName);
}
}
}
commit 602b8780654df9298dc36f6e8523e2ebb3e0c906
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Feb 25 12:34:39 2010 -0500
add missing @WebMethod annotation to saved search manager remote interface
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
index ffd4255..231167e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -112,6 +112,7 @@ public interface SavedSearchManagerRemote {
* @return the {@link PageList} of {@link SavedSearch} entities that match the criteria filters, an empty list
* will be returned if no results were found or none matches the given filters
*/
+ @WebMethod
public PageList<SavedSearch> findSavedSearchesByCriteria( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "criteria") SavedSearchCriteria criteria);
commit 07a482e999b87952b9cdbd2573fe6b04c4b8ff8e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Feb 24 22:04:30 2010 -0500
abstract RHQL grammar support:
* initial combined lexer/parser grammar file
* test harness to verify grammar correctness
* 100 acceptance test cases exercising all major parts of generic syntax
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
new file mode 100644
index 0000000..00a0dab
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -0,0 +1,137 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * Antlr v3 grammar file to parse RHQL search expressions.
+ *
+ * @author Joseph Marques
+ */
+grammar RHQL;
+
+options {
+ language=Java;
+ backtrack=true;
+ memoize=true;
+}
+
+@header {
+ package org.rhq.enterprise.server.search;
+}
+@lexer::header {
+ package org.rhq.enterprise.server.search;
+}
+
+/*
+ * parser rules
+ */
+
+searchExpression
+ : conditionalExpression
+ ;
+
+conditionalExpression
+ : conditionalFactor ( 'or' conditionalFactor )*
+ ;
+
+conditionalFactor
+ : conditionalPrimary ( ( 'and' )? conditionalPrimary )*
+ ;
+
+conditionalPrimary
+ : simpleConditionalExpression
+ | '(' conditionalExpression ')'
+ ;
+
+simpleConditionalExpression
+ : comparisonConditionalExpression
+ | nullComparisonConditionalExpression
+ | inExpression
+ ;
+
+comparisonConditionalExpression
+ : context comparisonOperator identifier
+ ;
+
+nullComparisonConditionalExpression
+ : context nullOperator
+ ;
+
+inExpression
+ : context inOperator '[' '='? identifier ( ',' '='? identifier )* ']'
+ ;
+
+context
+ : ( lineage '.' )? path ( '[' identifier ']' )?
+ ;
+
+lineage
+ : path ( '(' INT ')' )?
+ ;
+
+path
+ : ID+
+ ;
+
+identifier
+ : quotedValue
+ | value
+ ;
+
+quotedValue
+ : '\'' ~('\'')* '\''
+ ;
+
+value
+ : ~('\'') ~(']'|','|')')*
+ ;
+
+comparisonOperator
+ : '='
+ | '=='
+ | '!='
+ | '!=='
+ ;
+
+nullOperator
+ : 'is' 'not'? 'null'
+ ;
+
+inOperator
+ : 'not'? 'in'
+ ;
+
+/*
+ * lexical elements
+ */
+
+ID
+ : 'a'..'z'
+ ;
+
+INT
+ : '0'..'9'
+ ;
+
+WS
+ : ( ' ' | '\n' | '\r' )+ { $channel = HIDDEN; }
+ ;
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
new file mode 100644
index 0000000..2a5a195
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
@@ -0,0 +1,134 @@
+
+# simple term, all operators
+context = value
+context == value
+context != value
+context !== value
+context is null
+context is not null
+context in [value]
+context in [value1, =value2]
+context in [=value1, value2, value3]
+context not in [value]
+context not in [value1, =value2]
+context not in [=value1, value2, value3]
+
+# simple term, all operators, quoted value
+context = 'quoted value'
+context == 'quoted value'
+context != 'quoted value'
+context !== 'quoted value'
+context is null
+context is not null
+context in ['quoted value1']
+context in ['quoted value1', ='quoted value2']
+context in [='quoted value1', 'quoted value2', 'quoted value3']
+context not in ['quoted value1']
+context not in ['quoted value1', ='quoted value2']
+context not in [='quoted value1', 'quoted value2', 'quoted value3']
+
+# simple term, 'in' operator, non-quoted but multi-word values
+context in [quoted value1]
+context in [quoted value1, =quoted value2]
+context in [=quoted value1, quoted value2, quoted value3]
+context not in [quoted value1]
+context not in [quoted value1, =quoted value2]
+context not in [=quoted value1, quoted value2, quoted value3]
+
+# parameterized term, all operators
+context[param] = value
+context[param] == value
+context[param] != value
+context[param] !== value
+context[param] is null
+context[param] is not null
+context[param] in [value]
+context[param] in [value1, =value2]
+context[param] in [=value1, value2, value3]
+context[param] not in [value]
+context[param] not in [value1, =value2]
+context[param] not in [=value1, value2, value3]
+
+# deeply nested parenthetical simple terms
+((context = value))
+(((context = value)))
+((((context = value))))
+(((((context = value)))))
+
+# simple parenthetical term, all operators
+(context = value)
+(context == value)
+(context != value)
+(context !== value)
+(context is null)
+(context is not null)
+(context in [value])
+(context in [value1, =value2])
+(context in [=value1, value2, value3])
+(context not in [value])
+(context not in [value1, =value2])
+(context not in [=value1, value2, value3])
+
+# parameterized parenthetical term, all operators
+(context[param] = value)
+(context[param] == value)
+(context[param] != value)
+(context[param] !== value)
+(context[param] is null)
+(context[param] is not null)
+(context[param] in [value])
+(context[param] in [value1, =value2])
+(context[param] in [=value1, value2, value3])
+(context[param] not in [value])
+(context[param] not in [value1, =value2])
+(context[param] not in [=value1, value2, value3])
+
+
+# single-pair parenthetical combinations
+# simple expression, 'or' boolean operator
+context = value1 or context = value2
+(context = value1) or context = value2
+context = value1 or (context = value2)
+(context = value1) or (context = value2)
+
+# single-pair parenthetical combinations
+# simple expression, 'and' boolean operator
+context = value and context = value
+(context = value) and context = value
+context = value and (context = value)
+(context = value) and (context = value)
+
+# single-pair parenthetical combinations
+# simple expression, no boolean operator (implies 'and' semantics)
+context = value context = value
+(context = value) context = value
+context = value (context = value)
+(context = value) (context = value)
+
+
+# double-pair parenthetical combinations
+# simple expression, 'or' boolean operator
+((context = value1 or context = value2))
+((context = value1) or context = value2)
+((context = value1)) or context = value2
+(context = value1) or (context = value2)
+(context = value1 or (context = value2))
+context = value1 or ((context = value2))
+
+# double-pair parenthetical combinations
+# simple expression, 'and' boolean operator
+((context = value1 and context = value2))
+((context = value1) and context = value2)
+((context = value1)) and context = value2
+(context = value1) and (context = value2)
+(context = value1 and (context = value2))
+context = value1 and ((context = value2))
+
+# double-pair parenthetical combinations
+# simple expression, no boolean operator (implies 'and' semantics)
+((context = value1 context = value2))
+((context = value1) context = value2)
+((context = value1)) context = value2
+(context = value1) (context = value2)
+(context = value1 (context = value2))
+context = value1 ((context1 = value2))
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
new file mode 100644
index 0000000..637e339
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
@@ -0,0 +1,170 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.testng.AssertJUnit;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+/**
+ * Test harness to verify correctness of RHQL grammar
+ *
+ * @author Joseph Marques
+ */
+public class RHQLTest extends AssertJUnit {
+
+ private enum TestResult {
+ SUCCESS, FAILURE, TIMEOUT, SKIPPED;
+ }
+
+ private class AntlrTask implements Callable<TestResult> {
+ private String line;
+
+ public AntlrTask(String line) {
+ this.line = line;
+ }
+
+ @Override
+ public TestResult call() throws Exception {
+ try {
+ ANTLRStringStream input = new ANTLRStringStream(line); // Create an input character stream from standard in
+ RHQLLexer lexer = new RHQLLexer(input); // Create an echoLexer that feeds from that stream
+ CommonTokenStream tokens = new CommonTokenStream(lexer); // Create a stream of tokens fed by the lexer
+ RHQLParser parser = new RHQLParser(tokens); // Create a parser that feeds off the token stream
+ parser.searchExpression(); // Begin parsing at 'searchExpression' rule
+ return TestResult.SUCCESS;
+ } catch (Throwable t) {
+ return TestResult.FAILURE;
+ }
+ }
+ };
+
+ private ExecutorService executor;
+
+ @BeforeSuite
+ public void init() {
+ executor = Executors.newSingleThreadExecutor();
+ }
+
+ @AfterSuite
+ public void teardown() {
+ executor.shutdownNow();
+ }
+
+ @Test
+ public void testSingleLineRHQL() throws Exception {
+ BufferedReader reader = null;
+ List<String> successes = new java.util.ArrayList<String>();
+ List<String> failures = new java.util.ArrayList<String>();
+ int count = 0;
+ try {
+ InputStream stream = getClass().getClassLoader().getResourceAsStream("single-line-rhql.txt");
+ reader = new BufferedReader(new InputStreamReader(stream));
+ String line = null;
+ long timeout = 2000;
+ while ((line = reader.readLine()) != null) {
+ TestResult result = testSuccess(line, timeout);
+ if (result == TestResult.SKIPPED) {
+ continue;
+ }
+ count++;
+ if (result == TestResult.SUCCESS) {
+ successes.add(line);
+ } else if (result == TestResult.FAILURE) {
+ failures.add(line);
+ } else if (result == TestResult.TIMEOUT) {
+ System.out.println("Parsing took more than " + timeout
+ + "ms, does your grammar have an infinite loop?");
+ }
+ }
+ } catch (Exception e) {
+ System.out.println("Error testing single line RHQL: " + e);
+ throw e;
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+
+ System.out.println();
+ for (String success : successes) {
+ System.out.println("Parse success: " + success);
+ }
+ for (String failure : failures) {
+ System.out.println("Parse failure: " + failure);
+ }
+
+ System.out.println();
+ System.out.printf("RHQL expressions parsed: %1$s, Failures: %2$s", count, failures.size());
+ System.out.println();
+
+ assert failures.size() == 0;
+ }
+
+ private TestResult testSuccess(final String line, long timeout) {
+ if (shouldSkip(line)) {
+ return TestResult.SKIPPED; // skip empty lines used for visual separation in test file
+ }
+
+ AntlrTask task = new AntlrTask(line);
+ Future<TestResult> futureTask = executor.submit(task);
+ TestResult result = null;
+ try {
+ result = futureTask.get(timeout, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException ee) {
+ } catch (TimeoutException te) {
+ futureTask.cancel(true);
+ result = TestResult.TIMEOUT;
+ } catch (InterruptedException ie) {
+ futureTask.cancel(true);
+ }
+
+ return result;
+ }
+
+ private boolean shouldSkip(String line) {
+ line = line.trim();
+ if (line.equals("")) {
+ return true; // ignore empty lines
+ }
+ if (line.startsWith("#")) {
+ return true; // ignore comments
+ }
+ return false;
+ }
+}
commit 7369db803076bc12f02bcc6131b9fe1e5303ae47
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Feb 24 01:57:08 2010 -0500
antlr should compile the grammar files before the standard maven compile phase
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index b322503..533c0e9 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -467,10 +467,10 @@
<version>3.2</version>
<executions>
<execution>
- <phase>compile</phase>
- <goals>
- <goal>antlr</goal>
- </goals>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
<configuration>
<conversionTimeout>30000</conversionTimeout>
<debug>false</debug>
commit d17f4616c524e65decd6af3db65df8a83d18c12e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 16:54:20 2010 -0500
add anltr support to server/jar maven module, update eclipse classpath accordingly;
diff --git a/.classpath b/.classpath
index 660d74d..1a35400 100644
--- a/.classpath
+++ b/.classpath
@@ -19,6 +19,7 @@
<classpathentry kind="src" path="modules/plugins/jboss-cache/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-cache-v3/src/main/java"/>
<classpathentry kind="src" path="etc/samples/perspectives/sample-perspective/app/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/server/jar/target/generated-sources/antlr3"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index e109c41..b322503 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -366,6 +366,13 @@
<artifactId>test-utils</artifactId>
<version>${version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.2</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
@@ -454,6 +461,41 @@
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr3-maven-plugin</artifactId>
+ <version>3.2</version>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ <configuration>
+ <conversionTimeout>30000</conversionTimeout>
+ <debug>false</debug>
+ <dfa>false</dfa>
+ <nfa>false</nfa>
+ <excludes>
+
+ </excludes>
+ <includes>
+
+ </includes>
+ <libDirectory>src/main/antlr3/imports</libDirectory>
+ <messageFormat>antlr</messageFormat>
+ <outputDirectory>target/generated-sources/antlr3</outputDirectory>
+ <printGrammar>false</printGrammar>
+ <profile>false</profile>
+ <report>false</report>
+ <sourceDirectory>src/main/antlr3</sourceDirectory>
+ <trace>false</trace>
+ <verbose>true</verbose>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
commit fc1118af81ff953f2c05fb696629d799169b22f1
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 13:21:29 2010 -0500
fix some whitespace issues
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index f14e145..e109c41 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -414,7 +414,7 @@
Build-Jdk=${java.version}
Build-OS-Name=${os.name}
Build-OS-Version=${os.version}
-</echo>
+ </echo>
</tasks>
</configuration>
<goals>
@@ -593,8 +593,7 @@
<link href="../domain" />
<link href="../plugin-api" />
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
- <bottom><![CDATA[Copyright © 2008-2009 <a href="http://rhq-project.org/">Red Hat, Inc.</a>. All Rights Reserved.
-]]></bottom>
+ <bottom><![CDATA[Copyright © 2008-2009 <a href="http://rhq-project.org/">Red Hat, Inc.</a>. All Rights Reserved.]]></bottom>
</javadoc>
</tasks>
</configuration>
commit 1c79730a4d3ce260e2f3d6ce9b8e971da158e1d7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 13:10:18 2010 -0500
add some default, global saved searches for the resource context
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
new file mode 100644
index 0000000..1a11114
--- /dev/null
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<dbsetup name="search-data.xml">
+
+ <!-- overlord-created, global, default saved searches -->
+ <table name="RHQ_SAVED_SEARCH">
+ <data ID="1"
+ CONTEXT="Resource"
+ NAME="Downed Platforms"
+ DESCRIPTION="All downed machines across the entire enterprise"
+ PATTERN="down platform"
+ LAST_COMPUTE_TIME="0"
+ SUBJECT="1"
+ GLOBAL="TRUE" />
+ <data ID="2"
+ CONTEXT="Resource"
+ NAME="Downed Servers"
+ DESCRIPTION="All downed servers across the entire enterprise"
+ PATTERN="down server"
+ LAST_COMPUTE_TIME="0"
+ SUBJECT="1"
+ GLOBAL="TRUE" />
+ </table>
+
+</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 834e9ce..6fe555e 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3202,13 +3202,18 @@
</statement>
</schema-directSQL>
</schemaSpec>
-
+
<schemaSpec version="2.82">
<schema-directSQL>
<statement desc="Creating table RHQ_SAVED_SEARCH">
CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER )
</statement>
</schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_AFFINITY_GROUP">
+ ALTER TABLE RHQ_SAVED_SEARCH ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
<schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
@@ -3227,6 +3232,29 @@
<schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
</schemaSpec>
+
+ <schemaSpec version="2.82.1">
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Platforms'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, true)
+ </statement>
+ <statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Platforms'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, 1)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Servers'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, true)
+ </statement>
+ <statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Servers'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, 1)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
commit 68f3634b787768dd5ee138a04a5398fdd4cb6404
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 12:07:56 2010 -0500
fix copy/paste error for saved search entity annotation
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
index 9142772..d6b50e7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
@@ -87,7 +87,7 @@ public class SavedSearch {
@Column(name = "SUBJECT_ID", nullable = false)
private Subject subject;
- @Column(name = "RESOURCE_ID", insertable = false, updatable = false)
+ @Column(name = "SUBJECT_ID", insertable = false, updatable = false)
private int subjectId;
@Column(name = "GLOBAL", nullable = false)
commit 2325fa6314a7ebcbf1d932fb42e9f9559e1d079b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 03:02:28 2010 -0500
add auto-completion capability for saved search manager to the CLI
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index acafe6f..a1a5b38 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -54,6 +54,7 @@ import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerRemote;
+import org.rhq.enterprise.server.search.SavedSearchManagerRemote;
import org.rhq.enterprise.server.support.SupportManagerRemote;
import org.rhq.enterprise.server.system.ServerVersion;
import org.rhq.enterprise.server.system.SystemManagerRemote;
@@ -94,6 +95,7 @@ public class RemoteClient {
ResourceGroupManager(ResourceGroupManagerRemote.class), //
ResourceTypeManager(ResourceTypeManagerRemote.class), //
RoleManager(RoleManagerRemote.class), //
+ SavedSearchManager(SavedSearchManagerRemote.class), //
SubjectManager(SubjectManagerRemote.class), //
SupportManager(SupportManagerRemote.class), //
SystemManager(SystemManagerRemote.class) //
commit 9bfad0211e66635e09d02d8959a81db33f6175b7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:51:14 2010 -0500
add LookupUtil method to retrieve the saved search manager from the UI layer
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index dc9ae11..c21526a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -165,6 +165,8 @@ import org.rhq.enterprise.server.resource.metadata.ResourceMetadataManagerBean;
import org.rhq.enterprise.server.resource.metadata.ResourceMetadataManagerLocal;
import org.rhq.enterprise.server.scheduler.SchedulerBean;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerBean;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
import org.rhq.enterprise.server.subsystem.AlertSubsystemManagerBean;
import org.rhq.enterprise.server.subsystem.AlertSubsystemManagerLocal;
import org.rhq.enterprise.server.subsystem.ConfigurationSubsystemManagerBean;
@@ -516,6 +518,10 @@ public final class LookupUtil {
return lookupLocal(SchedulerBean.class);
}
+ public static SavedSearchManagerLocal getSavedSearchManager() {
+ return lookupLocal(SavedSearchManagerBean.class);
+ }
+
public static SubjectManagerLocal getSubjectManager() {
return lookupLocal(SubjectManagerBean.class);
}
commit 7b68ec1372bd5af42793b5d15020e7b2f66bb931
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:49:08 2010 -0500
add criteria-based retrieval for the saved search manager
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
new file mode 100644
index 0000000..bd70b6f
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
@@ -0,0 +1,142 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.criteria;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.search.SearchContext;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Joseph Marques
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class SavedSearchCriteria extends Criteria {
+ public static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private SearchContext filterContext;
+ private String filterName;
+ private String filterDescription;
+ private String filterPattern;
+ private Long filterLastComputeTimeMin;
+ private Long filterLastComputeTimeMax;
+ private Long filterResultCountMin;
+ private Long filterResultCountMax;
+ private Integer filterSubjectId;
+ private Boolean filterGlobal;
+
+ private boolean fetchSubject;
+
+ private PageOrdering sortContext;
+ private PageOrdering sortName;
+ private PageOrdering sortLastComputeTime;
+ private PageOrdering sortResultCount;
+ private PageOrdering sortGlobal;
+
+ public SavedSearchCriteria() {
+ super(SavedSearch.class);
+
+ filterOverrides.put("lastComputeTimeMin", "lastComputeTime >= ?");
+ filterOverrides.put("lastComputeTimeMax", "lastComputeTime <= ?");
+ filterOverrides.put("resultCountMin", "resultCount >= ?");
+ filterOverrides.put("resultCountMax", "resultCount <= ?");
+ }
+
+ public void addFilterId(Integer filterId) {
+ this.filterId = filterId;
+ }
+
+ public void addFilterSearchContext(SearchContext filterContext) {
+ this.filterContext = filterContext;
+ }
+
+ public void addFilterName(String filterName) {
+ this.filterName = filterName;
+ }
+
+ public void addFilterDescription(String filterDescription) {
+ this.filterDescription = filterDescription;
+ }
+
+ public void addFilterPattern(String filterPattern) {
+ this.filterPattern = filterPattern;
+ }
+
+ public void addFilterResultCountMin(Long filterResultCountMin) {
+ this.filterResultCountMin = filterResultCountMin;
+ }
+
+ public void addFilterResultCountMax(Long filterResultCountMax) {
+ this.filterResultCountMax = filterResultCountMax;
+ }
+
+ public void addFilterLastComputeTimeMin(Long filterLastComputeTimeMin) {
+ this.filterLastComputeTimeMin = filterLastComputeTimeMin;
+ }
+
+ public void addFilterLastComputeTimeMax(Long filterLastComputeTimeMax) {
+ this.filterLastComputeTimeMax = filterLastComputeTimeMax;
+ }
+
+ public void addFilterSubjectId(Integer filterSubjectId) {
+ this.filterSubjectId = filterSubjectId;
+ }
+
+ public void addFilterGlobal(Boolean filterGlobal) {
+ this.filterGlobal = filterGlobal;
+ }
+
+ public void setFetchSubject(boolean fetchSubject) {
+ this.fetchSubject = fetchSubject;
+ }
+
+ public void addSortContext(PageOrdering sortContext) {
+ addSortField("context");
+ this.sortContext = sortContext;
+ }
+
+ public void addSortName(PageOrdering sortName) {
+ addSortField("name");
+ this.sortName = sortName;
+ }
+
+ public void addSortLastComputeTime(PageOrdering sortLastComputeTime) {
+ addSortField("lastComputeTime");
+ this.sortLastComputeTime = sortLastComputeTime;
+ }
+
+ public void addSortResultCount(PageOrdering sortResultCount) {
+ addSortField("resultCount");
+ this.sortResultCount = sortResultCount;
+ }
+
+ public void addSortGlobal(PageOrdering sortGlobal) {
+ addSortField("global");
+ this.sortGlobal = sortGlobal;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
index f672ac7..1485197 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
@@ -24,10 +24,14 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
+import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
+import org.rhq.enterprise.server.util.CriteriaQueryRunner;
/**
* This bean provides functionality to CRUD saved search patterns.
@@ -79,6 +83,18 @@ public class SavedSearchManagerBean implements SavedSearchManagerLocal /* local
return savedSearch;
}
+ public PageList<SavedSearch> findSavedSearchesByCriteria(Subject subject, SavedSearchCriteria criteria) {
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
+
+ if (!authorizationManager.isInventoryManager(subject)) {
+ generator.setAuthorizationCustomConditionFragment("(subject.id=" + subject.getId() + " OR global=true)");
+ }
+
+ CriteriaQueryRunner<SavedSearch> queryRunner = new CriteriaQueryRunner<SavedSearch>(criteria, generator,
+ entityManager);
+ return queryRunner.execute();
+ }
+
private void validateManipulatePermission(Subject subject, SavedSearch savedSearch) {
if (savedSearch.isGlobal()) {
if (!authorizationManager.isInventoryManager(subject)) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
index a1615ec..ffd4255 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -25,7 +25,9 @@ import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.system.ServerVersion;
@@ -99,4 +101,18 @@ public interface SavedSearchManagerRemote {
public SavedSearch getSavedSearchById( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "savedSearchId") int savedSearchId);
+
+ /**
+ * Returns the {@link PageList} of {@link SavedSearch} entities that match the criteria filters that are visible
+ * to the user
+ *
+ * @param subject the logged in user requesting the {@link PageList} of {@link SavedSearch} to be returned
+ * @param criteria the {@link SavedSearchCriteria} object that will filter the returned results
+ *
+ * @return the {@link PageList} of {@link SavedSearch} entities that match the criteria filters, an empty list
+ * will be returned if no results were found or none matches the given filters
+ */
+ public PageList<SavedSearch> findSavedSearchesByCriteria( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "criteria") SavedSearchCriteria criteria);
}
commit 8bee964f9c9fb494fc08a3baaa307361d826b445
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:48:32 2010 -0500
enhance the CriteriaQueryGenerator to allow more flexible authorization:
support users to set a completely arbitrary authorization fragment, which
will be inserted into the list of conditions for the generated query
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 9c62eed..bb0c072 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -58,13 +58,14 @@ public final class CriteriaQueryGenerator {
public enum AuthorizationTokenType {
RESOURCE, // specifies the resource alias to join on for standard res-group-role-subject authorization checking
- GROUP; // specifies the group alias to join on for standard group-role-subject authorization checking
+ GROUP; // specifies the group alias to join on for standard group-role-subject authorization checking
}
private Criteria criteria;
private String authorizationJoinFragment;
private String authorizationPermsFragment;
+ private String authorizationCustomConditionFragment;
private int authorizationSubjectId;
private String alias;
@@ -89,6 +90,10 @@ public final class CriteriaQueryGenerator {
this.alias = aliasBuilder.toString();
}
+ public void setAuthorizationCustomConditionFragment(String fragment) {
+ this.authorizationCustomConditionFragment = fragment;
+ }
+
public void setAuthorizationResourceFragment(AuthorizationTokenType type, int subjectId) {
String defaultFragment = null;
if (type == AuthorizationTokenType.RESOURCE) {
@@ -260,6 +265,16 @@ public final class CriteriaQueryGenerator {
}
}
+ if (authorizationCustomConditionFragment != null) {
+ if (firstCrit) {
+ firstCrit = false;
+ } else {
+ // always want AND for security, regardless of conjunctiveFragment
+ results.append(NL).append(" AND ");
+ }
+ results.append(this.authorizationCustomConditionFragment);
+ }
+
if (countQuery == false) {
boolean overridden = true;
PageControl pc = criteria.getPageControlOverrides();
commit d065f478b829887eda067308a10f98edef113b66
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 00:50:35 2010 -0500
initial SLSB support basic CRUD, with security restrictions, for saved search patterns
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
new file mode 100644
index 0000000..f672ac7
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
@@ -0,0 +1,104 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
+import org.rhq.enterprise.server.authz.PermissionException;
+
+/**
+ * This bean provides functionality to CRUD saved search patterns.
+ *
+ * @author Joseoh Marques
+ */
+@Stateless
+public class SavedSearchManagerBean implements SavedSearchManagerLocal /* local already implements remote interface */{
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ @EJB
+ private AuthorizationManagerLocal authorizationManager;
+
+ /**
+ * @see SavedSearchManagerRemote#createSavedSearch(Subject, SavedSearch)
+ */
+ public void createSavedSearch(Subject subject, SavedSearch savedSearch) {
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.persist(savedSearch);
+ return;
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#updateSavedSearch(Subject, SavedSearch)
+ */
+ public void updateSavedSearch(Subject subject, SavedSearch savedSearch) {
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.merge(savedSearch);
+ return;
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#deleteSavedSearch(Subject, int)
+ */
+ public void deleteSavedSearch(Subject subject, int savedSearchId) {
+ SavedSearch savedSearch = entityManager.find(SavedSearch.class, savedSearchId);
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.remove(savedSearch);
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#getSavedSearchById(Subject, int)
+ */
+ public SavedSearch getSavedSearchById(Subject subject, int savedSearchId) {
+ SavedSearch savedSearch = entityManager.find(SavedSearch.class, savedSearchId);
+ validateReadPermission(subject, savedSearch);
+ return savedSearch;
+ }
+
+ private void validateManipulatePermission(Subject subject, SavedSearch savedSearch) {
+ if (savedSearch.isGlobal()) {
+ if (!authorizationManager.isInventoryManager(subject)) {
+ throw new PermissionException("Only inventory managers can manipulate global saved searches");
+ }
+ // note: inventory managers can modify any saved search pattern, not just their own
+ } else {
+ if (subject.equals(savedSearch.getSubject())) {
+ throw new PermissionException("Users without inventory manager permission "
+ + "can only manipulate their own saved searches");
+ }
+ }
+ }
+
+ private void validateReadPermission(Subject subject, SavedSearch savedSearch) {
+ if (!savedSearch.isGlobal()) {
+ if (subject.equals(savedSearch.getSubject())) {
+ throw new PermissionException("Users without inventory manager permission "
+ + "can only view their own or global saved saved searches");
+ }
+ }
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java
new file mode 100644
index 0000000..7ced552
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java
@@ -0,0 +1,31 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.Local;
+
+/**
+ * The local interface to the SavedSearchManager.
+ *
+ * @author Joseph Marques
+ */
+@Local
+public interface SavedSearchManagerLocal extends SavedSearchManagerRemote {
+ // there are currently no methods in the local interface that do not exist in the remote interface
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
new file mode 100644
index 0000000..a1615ec
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -0,0 +1,102 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.Remote;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.enterprise.server.authz.PermissionException;
+import org.rhq.enterprise.server.system.ServerVersion;
+
+/**
+ * The remote interface to the SavedSearchManager.
+ *
+ * @author Joseph Marques
+ */
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(targetNamespace = ServerVersion.namespace)
+@Remote
+public interface SavedSearchManagerRemote {
+
+ /**
+ * Persisted a new {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} deletion
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be deleted
+ *
+ * @throws PermissionException if the user is not authorized to create the {@link SavedSearch}. Only inventory
+ * managers can create global saved searches. Regular users can only create {@link SavedSearch}es against
+ * their own accounts.
+ */
+ @WebMethod
+ public void createSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearch") SavedSearch savedSearch);
+
+ /**
+ * Saves all changes to the passed {@link SavedSearch} database, correlating it to the record already
+ * persisted with the same primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} persisted modification
+ * @param savedSearchId the {@link SavedSearch} which will have its modifications persisted
+ *.
+ * @throws PermissionException if the user is not authorized to modify the {@link SavedSearch}. Only inventory
+ * managers can update global saved searches. Regular users can only update {@link SavedSearch}es from
+ * their own accounts.
+ */
+ @WebMethod
+ public void updateSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearch") SavedSearch savedSearch);
+
+ /**
+ * Deletes the {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} deletion
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be deleted
+ *
+ * @throws PermissionException if the user is not authorized to delete the {@link SavedSearch}. Only inventory
+ * managers can delete global saved searches. Regular users can only delete {@link SavedSearch}es from
+ * their own accounts.
+ */
+ @WebMethod
+ public void deleteSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearchId") int savedSearchId);
+
+ /**
+ * Returns the {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} to be loaded
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be loaded
+ *
+ * @return the {@link SavedSearch} or <code>null</code> if it wasn't found
+ * @throws PermissionException if the user is not authorized to view the {@link SavedSearch}. Regular users can
+ * only view {@link SavedSearch}es from their own accounts.
+ */
+ @WebMethod
+ public SavedSearch getSavedSearchById( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearchId") int savedSearchId);
+}
commit c95388946134a47b002f5821c3a168db6f549355
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:31 2010 -0500
saved search hibernate entities
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
new file mode 100644
index 0000000..9142772
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
@@ -0,0 +1,253 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.search;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.auth.Subject;
+
+/**
+ * The data model for saved searches. Each users has his or her own set of
+ * saved searches, but inventory managers are allowed to "promote" their
+ * saved searches to GLOBAL status, which makes them available to all users
+ * under that installation of RHQ.
+ *
+ * There are two levels of pre-computed data within this structured. After
+ * the {@link SavedSearch} is created, the pattern will be translated into its
+ * JPQL equivalent and stored. If the {@link SavedSearch} is ever modified
+ * and saved, the JPQL will be re-computed.
+ *
+ * Periodically, the count-query version of the {@link SavedSearch} will be
+ * executed (using the stored JPQL), and the number of matching records will
+ * be stored. If this {@link SavedSearch} ever needs to be displayed on the
+ * user interface, it will by default retrieve this cached result count.
+ *
+ * @author Joseph Marques
+ */
+@Entity
+@SequenceGenerator(name = "id", sequenceName = "RHQ_SAVED_SEARCH_ID_SEQ")
+@Table(name = "RHQ_SAVED_SEARCH")
+public class SavedSearch {
+
+ @Id
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
+ private Integer id;
+
+ @Column(name = "CONTEXT", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private SearchContext context;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+ @Column(name = "PATTERN", nullable = false)
+ private String pattern;
+
+ @Column(name = "JPQL_TRANSLATION")
+ private String jpqlTranslation;
+
+ @Column(name = "LAST_COMPUTE_TIME", nullable = false)
+ private long lastComputeTime;
+
+ @Column(name = "RESULT_COUNT")
+ private Long resultCount;
+
+ @Column(name = "SUBJECT_ID", nullable = false)
+ private Subject subject;
+
+ @Column(name = "RESOURCE_ID", insertable = false, updatable = false)
+ private int subjectId;
+
+ @Column(name = "GLOBAL", nullable = false)
+ private boolean global;
+
+ protected SavedSearch() {
+ // no-arg ctor for Hibernate
+ }
+
+ public SavedSearch(SearchContext context, String name, String pattern, Subject subject) {
+ // call setters to go through parameter validation
+ setContext(context);
+ setPattern(pattern);
+ setSubject(subject);
+ setName(name); // name can be null, to allow for saving searches quickly
+
+ this.description = null;
+ this.jpqlTranslation = null; // null value for pre-computed JPQL implies computation is needed
+ this.lastComputeTime = 0; // further imply that computation needs to occur
+ this.resultCount = null; // NULL resultCount implies either computation failed or hasn't begun yet
+ this.global = false; // user must promote saved search to be a global after creation
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public SearchContext getContext() {
+ return context;
+ }
+
+ private void setContext(SearchContext context) {
+ if (context == null) {
+ throw new IllegalArgumentException("All saved searches must be bound to a SearchContext");
+ }
+ this.context = context;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ private void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public void setPattern(String pattern) {
+ if (pattern == null || pattern.trim().equals("")) {
+ throw new IllegalArgumentException("All saved searches must have a non-empty pattern");
+ }
+ this.pattern = pattern;
+ }
+
+ public String getJpqlTranslation() {
+ return jpqlTranslation;
+ }
+
+ public void setJpqlTransation(String jpqlTranslation) {
+ this.jpqlTranslation = jpqlTranslation;
+ }
+
+ public long getLastComputeTime() {
+ return lastComputeTime;
+ }
+
+ public void setLastComputeTime(long lastComputeTime) {
+ this.lastComputeTime = lastComputeTime;
+ }
+
+ public Long getResultCount() {
+ return resultCount;
+ }
+
+ public void setResultCount(Long resultCount) {
+ this.resultCount = resultCount;
+ }
+
+ public Subject getSubject() {
+ return subject;
+ }
+
+ private void setSubject(Subject subject) {
+ if (subject == null) {
+ throw new IllegalArgumentException("All saved searches must be owned by a specific user");
+ }
+ this.subject = subject;
+ this.subjectId = subject.getId();
+ }
+
+ public int getSubjectId() {
+ return subjectId;
+ }
+
+ public boolean isGlobal() {
+ return global;
+ }
+
+ public void setGlobal(boolean global) {
+ this.global = global;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + subjectId;
+ result = (prime * result) + context.hashCode();
+ result = (prime * result) + ((name == null) ? 0 : name.hashCode());
+ result = (prime * result) + pattern.hashCode();
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof SavedSearch))) {
+ return false;
+ }
+
+ final SavedSearch other = (SavedSearch) obj;
+
+ if (subjectId != other.subjectId) {
+ return false;
+ }
+
+ if (context != other.context) {
+ return false;
+ }
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ if (!pattern.equals(other.pattern)) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java
new file mode 100644
index 0000000..bb045d5
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java
@@ -0,0 +1,38 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.search;
+
+/**
+ * The search mechanism is generic and, thus, suited to finding data in any
+ * RHQ subsystem, including its own. Each individual page in the UI can have
+ * different advanced syntax. This enum will serve as a unique identifier
+ * for which context is currently active. You can think of it as a piece of
+ * meta-data that annotates each saved search, representing which context it
+ * belongs to. This will also affect which grammar is used to auto-complete
+ * search expressions.
+ *
+ * @author Joseph Marques
+ */
+public enum SearchContext {
+ Resource, Group;
+}
commit c9d080cc510d6e4bf5c26c34f7b9050544736da3
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:19 2010 -0500
saved search dbupgrade scripts
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 1d4d3dd..2fb6a90 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.79</db.schema.version>
+ <db.schema.version>2.82</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 9af6aa5..834e9ce 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3202,6 +3202,31 @@
</statement>
</schema-directSQL>
</schemaSpec>
+
+ <schemaSpec version="2.82">
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_SAVED_SEARCH">
+ CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="PATTERN" columnType="VARCHAR2" precision="1000" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="PATTERN" nullable="FALSE" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="JPQL_TRANSLATION" columnType="VARCHAR2" precision="4000" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="RESULT_COUNT" columnType="LONG" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
+ </schemaSpec>
</dbupgrade>
</target>
</project>
commit afc78a9b2bfcb14b5b079ffb29aa82c4e6b0e81f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:07 2010 -0500
saved searches dbsetup scripts
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
index 047d615..f5e4eae 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
@@ -39,7 +39,7 @@ To run the default target, you must set one of the following properties to true:
<property name="dbsetup.scripts.dir" value="${basedir}/src/main/scripts/dbsetup" />
<property name="dbsetup.output.dir" value="${basedir}/target/dbsetup" /> <!-- away from classes so it doesn't go into the jar -->
<!-- define the setup creation processing order. note, removals are done in the reverse order -->
- <property name="dbsetup.subsystems" value="config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
+ <property name="dbsetup.subsystems" value="search,config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
<property name="dbsetup.combined.schema" value="${dbsetup.output.dir}/all-schema.xml" />
<property name="dbsetup.combined.data" value="${dbsetup.output.dir}/all-data.xml" />
<property name="dbsetup.tstamp.file" value="${dbsetup.output.dir}/dbsetup-combine.tstamp" />
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
new file mode 100644
index 0000000..7c0de23
--- /dev/null
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<dbsetup name="amps-schema.xml"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-dbsetup-schema">
+
+ <table name="RHQ_SAVED_SEARCH">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="CONTEXT" type="VARCHAR2" size="25" required="true"/>
+
+ <column name="NAME" type="VARCHAR2" size="200" required="true"/>
+ <column name="DESCRIPTION" type="VARCHAR2" size="500" required="false"/>
+ <column name="PATTERN" type="VARCHAR2" size="1000" required="true"/>
+
+ <column name="JPQL_TRANSLATION" type="VARCHAR2" size="4000" required="false"/>
+ <column name="LAST_COMPUTE_TIME" type="LONG" required="true"/>
+ <column name="RESULT_COUNT" type="LONG" required="false"/>
+
+ <column name="SUBJECT_ID" type="INTEGER" references="RHQ_SUBJECT" required="true"/>
+ <column name="ENABLED" type="BOOLEAN" required="true"/>
+ </table>
+
+</dbsetup>
\ No newline at end of file
commit 6d87241b69c095bd2928f4e3b03bc9dcfbeeefd1
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Sat Feb 20 10:49:01 2010 +0100
Fix potential NPE
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
index 5ed6d4f..b90def3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
@@ -113,8 +113,8 @@ public class AlertNotificationLog implements Serializable {
@PrePersist
@PreUpdate
public void trimMessage() {
- if (message.length()>255)
- message = message.substring(0,254);
+ if (message!=null && message.length()>255)
+ message = message.substring(0,255);
}
protected AlertNotificationLog() {
commit 2d38d85bb4500c1a873aba7b193fb9984d00539d
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Sat Feb 20 09:47:10 2010 +0100
Truncate the message at 140 chars, as identi.ca bails out on longer messages; seems to improve stability with Twitter too.
Introduce abbreviated versions of the messages as space on Microblog etc is scarce. BZ 555091
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
index ba75940..5ed6d4f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
@@ -38,6 +38,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -108,6 +110,13 @@ public class AlertNotificationLog implements Serializable {
@Transient
transient List<String> transientEmails = new ArrayList<String>();
+ @PrePersist
+ @PreUpdate
+ public void trimMessage() {
+ if (message.length()>255)
+ message = message.substring(0,254);
+ }
+
protected AlertNotificationLog() {
} // JPA
@@ -130,7 +139,6 @@ public class AlertNotificationLog implements Serializable {
public AlertNotificationLog(Alert alert, String senderName, ResultState state, String message) {
this.alert = alert;
- this.sender = sender;
this.resultState = state;
this.message = message;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
index 454b9a9..ff4025f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
@@ -780,7 +780,7 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
Map<String, String> alertMessage = emailManager.getAlertEmailMessage(
prettyPrintResourceHierarchy(alertDefinition.getResource()), alertDefinition.getResource().getName(),
alertDefinition.getName(), alertDefinition.getPriority().toString(), new Date(alert.getCtime()).toString(),
- prettyPrintAlertConditions(alert.getConditionLogs()), prettyPrintAlertURL(alert));
+ prettyPrintAlertConditions(alert.getConditionLogs(), false), prettyPrintAlertURL(alert));
String messageSubject = alertMessage.keySet().iterator().next();
String messageBody = alertMessage.values().iterator().next();
@@ -834,13 +834,14 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
/**
* Create a human readable description of the conditions that led to this alert.
* @param alert Alert to create human readable condition description
+ * @param shortVersion if true the messages printed are abbreviated to save space
* @return human readable condition log
*/
- public String prettyPrintAlertConditions(Alert alert) {
- return prettyPrintAlertConditions(alert.getConditionLogs());
+ public String prettyPrintAlertConditions(Alert alert, boolean shortVersion) {
+ return prettyPrintAlertConditions(alert.getConditionLogs(), shortVersion);
}
- private String prettyPrintAlertConditions(Set<AlertConditionLog> conditionLogs) {
+ private String prettyPrintAlertConditions(Set<AlertConditionLog> conditionLogs, boolean shortVersion) {
StringBuilder builder = new StringBuilder();
int conditionCounter = 1;
@@ -858,16 +859,27 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
builder.append(NEW_LINE);
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT,
- conditionCounter, prettyPrintAlertCondition(aLog.getCondition()), new SimpleDateFormat(
- "yyyy/MM/dd HH:mm:ss z").format(new Date(aLog.getCtime())), formattedValue));
+ String format;
+ if (shortVersion)
+ format = AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT_SHORT;
+ else
+ format = AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT;
+ SimpleDateFormat dateFormat;
+ if (shortVersion)
+ dateFormat= new SimpleDateFormat(
+ "yy/MM/dd HH:mm:ss z");
+ else
+ dateFormat= new SimpleDateFormat(
+ "yyyy/MM/dd HH:mm:ss z");
+ builder.append(AlertI18NFactory.getMessage(format,
+ conditionCounter, prettyPrintAlertCondition(aLog.getCondition(), shortVersion), dateFormat.format(new Date(aLog.getCtime())), formattedValue));
conditionCounter++;
}
return builder.toString();
}
- private String prettyPrintAlertCondition(AlertCondition condition) {
+ private String prettyPrintAlertCondition(AlertCondition condition, boolean shortVersion) {
StringBuilder builder = new StringBuilder();
AlertConditionCategory category = condition.getCategory();
@@ -915,19 +927,38 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
} else if ((category == AlertConditionCategory.RESOURCE_CONFIG) || (category == AlertConditionCategory.CHANGE)
|| (category == AlertConditionCategory.TRAIT)) {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED));
+
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED));
+
} else if (category == AlertConditionCategory.EVENT) {
if ((condition.getOption() != null) && (condition.getOption().length() > 0)) {
+ String propsCbEventSeverityRegexMatch;
+ if (shortVersion)
+ propsCbEventSeverityRegexMatch = AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH_SHORT;
+ else
+ propsCbEventSeverityRegexMatch = AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH;
+
builder.append(AlertI18NFactory.getMessage(
- AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH, condition.getName(),
+ propsCbEventSeverityRegexMatch, condition.getName(),
condition.getOption()));
} else {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY,
- condition.getName()));
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT,
+ condition.getName()));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY,
+ condition.getName()));
}
} else if (category == AlertConditionCategory.AVAILABILITY) {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
- condition.getOption()));
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT,
+ condition.getOption()));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
+ condition.getOption()));
} else {
// do nothing
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
index 996f245..e482ffa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
@@ -96,9 +96,10 @@ public interface AlertManagerLocal {
/**
* Create a human readable description of the conditions that led to this alert.
* @param alert Alert to create human readable condition description
+ * @param shortVersion if true the messages printed are abbreviated to save space
* @return human readable condition log
*/
- String prettyPrintAlertConditions(Alert alert);
+ String prettyPrintAlertConditions(Alert alert, boolean shortVersion);
/**
* Tells us if the definition of the passed alert will be disabled after this alert was fired
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
index 8734771..1de3d85 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
@@ -32,20 +32,41 @@ public interface AlertI18NResourceKeys {
@I18NMessage(locale = "de", value = "Verfgbarkeit wird {0}") })
String ALERT_CONFIG_PROPS_CB_AVAILABILITY = "alert.config.props.CB.Availability";
+ @I18NMessages( { @I18NMessage("Avail goes {0}"),
+ @I18NMessage(locale = "de", value = "Verf. wird {0}") })
+ String ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT = "alert.config.props.CB.Availability.short";
+
@I18NMessages( { @I18NMessage("Event Severity: {0}"),
@I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0}") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY = "alert.config.props.CB.EventSeverity";
+ @I18NMessages( { @I18NMessage("Sev: {0}"),
+ @I18NMessage(locale = "de", value = "Schwere: {0}") })
+ String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT = "alert.config.props.CB.EventSeverity.short";
+
@I18NMessages( { @I18NMessage("Event Severity: {0} and matching expression \"{1}\""),
@I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0} und zugehriger Ausdruck \"{1}\"") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH = "alert.config.props.CB.EventSeverity.RegexMatch";
+ @I18NMessages( { @I18NMessage("Sev: {0} & exp \"{1}\""),
+ @I18NMessage(locale = "de", value = "Schwere: {0} & Ausdruck \"{1}\"") })
+ String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH_SHORT = "alert.config.props.CB.EventSeverity.RegexMatch.short";
+
@I18NMessages( { @I18NMessage("value changed"), @I18NMessage(locale = "de", value = "Der Wert hat sich gendert") })
String ALERT_CURRENT_LIST_VALUE_CHANGED = "alert.current.list.ValueChanged";
+ @I18NMessages( { @I18NMessage("val chg"), @I18NMessage(locale = "de", value = "Wertnd.") })
+ String ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT = "alert.current.list.ValueChanged.short";
+
@I18NMessages( {
@I18NMessage("\\ - Condition {0}: {1}\\n\\\n" + "\\ - Date/Time: {2}\\n\\\n" + "\\ - Details: {3}\\n\\\n"),
@I18NMessage(locale = "de", value = " - Bedingung {0}: {1}\\n\\\n - Datum/Uhrzeit: {2}\\n\\\n"
+ "\\ - Details: {3}\\n\\\n") })
String ALERT_EMAIL_CONDITION_LOG_FORMAT = "alert.email.condition.log.format";
+
+ @I18NMessages( {
+ @I18NMessage("\\ - Cond {0}: {1}\\n\\\n" + "\\ - Time: {2}\\n\\\n" + "\\ - Det: {3}\\n\\\n"),
+ @I18NMessage(locale = "de", value = " - Bed {0}: {1}\\n\\\n - Zeit: {2}\\n\\\n"
+ + "\\ - Det: {3}\\n\\\n") })
+ String ALERT_EMAIL_CONDITION_LOG_FORMAT_SHORT = "alert.email.condition.log.format.short";
}
\ No newline at end of file
diff --git a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
index 93eecc6..95abdb9 100644
--- a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
+++ b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
@@ -65,7 +65,7 @@ public class IrcSender extends AlertSender<IrcAlertComponent> {
b.append("): ");
b.append(alertManager.prettyPrintAlertURL(alert));
b.append("\n");
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, false));
return b.toString();
}
diff --git a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
index 257b315..b13763e 100644
--- a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
+++ b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
@@ -57,14 +57,19 @@ public class MicroblogSender extends AlertSender {
b.append("' (");
b.append(alert.getAlertDefinition().getResource().getId());
b.append("): ");
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, true));
b.append("-by @JBossJopr"); // TODO not for production :-)
// TODO use some alert url shortening service
SenderResult result ;
String txt = "user@baseUrl [" + user + "@" + baseUrl + "]:";
try {
- Status status = twitter.updateStatus(b.toString());
+ String msg = b.toString();
+ if (msg.length()>140)
+ msg = msg.substring(0,140);
+
+ Status status = twitter.updateStatus(msg);
+
result = new SenderResult(ResultState.SUCCESS,"Send notification to " + txt + ", msg-id: " + status.getId());
} catch (TwitterException e) {
diff --git a/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java b/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
index 649d6ed..b14c85d 100644
--- a/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
+++ b/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
@@ -74,7 +74,7 @@ public class MobicentsSender extends AlertSender {
// Switch locale to english, as the voice synthesizer expects this for now
Locale currentLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, false));
Locale.setDefault(currentLocale);
boolean willBeDisabled = alertManager.willDefinitionBeDisabled(alert);
diff --git a/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java b/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
index 985d890..bac51fb 100644
--- a/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
+++ b/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
@@ -93,7 +93,7 @@ public class ScriptLangSender extends AlertSender<ScriptLangComponent> {
Object[] args = new Object[3];
args[0] = alert;
args[1] = alertManager.prettyPrintAlertURL(alert);
- args[2] = alertManager.prettyPrintAlertConditions(alert);
+ args[2] = alertManager.prettyPrintAlertConditions(alert, false);
result = ((Invocable) engine).invokeFunction("sendAlert", args);
if (result == null) {
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
index 3fd5d79..045c3bb 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
@@ -68,7 +68,7 @@ public class SnmpSender extends AlertSender {
String result;
List<Resource> lineage = resourceManager.getResourceLineage(alert.getAlertDefinition().getResource().getId());
String platformName = lineage.get(0).getName();
- String conditions = alertManager.prettyPrintAlertConditions(alert);
+ String conditions = alertManager.prettyPrintAlertConditions(alert, false);
String alertUrl = alertManager.prettyPrintAlertURL(alert);
SenderResult res ;
commit 798ac30ead634c43a72beed52446a38d9bfc1f09
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:51:53 2010 -0500
i think this should report an error always on lock acq failure. we'll leave the flag alone - don't set it to true - let the next call take care of whether or not the init callback should be invoked or not
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 8c37b50..cd3b479 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -588,11 +588,9 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
writeLock.unlock();
}
} else {
- if (m_needToCallInitializeCallback) {
- Throwable t = new Throwable("Initialize callback lock could not be acquired");
- LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
- return new GenericCommandResponse(command, false, null, t);
- }
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
}
}
return null;
commit 9746ea32492b638eacb741d608d9ce17349c925d
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:44:11 2010 -0500
should not worry about the lock failure if the init callback doesn't need to be invoked anyway
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 762b9b4..8c37b50 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -588,10 +588,11 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
writeLock.unlock();
}
} else {
- m_needToCallInitializeCallback = true; // can't invoke callback, we'll want to still call it later
- Throwable t = new Throwable("Initialize callback lock could not be acquired");
- LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
- return new GenericCommandResponse(command, false, null, t);
+ if (m_needToCallInitializeCallback) {
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
+ }
}
}
return null;
commit c2cca917c88986ca48c84bbbdaf3408753299bf1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:38:16 2010 -0500
BZ 537396 - to not block indefinitely if a lock cannot be acquired before attempting to invoke the initialize callback
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 3775212..762b9b4 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -21,6 +21,9 @@ package org.rhq.enterprise.communications.command.client;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import mazz.i18n.Logger;
@@ -95,10 +98,22 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
private InitializeCallback m_initializeCallback;
/**
- * When the first element is <code>true</code>, the initialize callback will need to be called prior
- * to sending any commands. This is an array because the array itself is used for its lock.
+ * When <code>true</code>, the initialize callback will need to be called prior
+ * to sending any commands. Used in conjunection with its associated RW lock.
*/
- private final boolean[] m_needToCallInitializeCallback;
+ private boolean m_needToCallInitializeCallback;
+
+ /**
+ * RW lock when needing to access its associated atomic boolean flag.
+ */
+ private final ReentrantReadWriteLock m_needToCallInitializeCallbackLock;
+
+ /**
+ * Number of minutes to wait while attempting to aquire a lock before attempting
+ * to invoke the initialize callback. If this amount of minutes expires before the lock
+ * is acquired, an error will occur and the initialize callback will have to be attempted later.
+ */
+ private final long m_initializeCallbackLockAcquisitionTimeoutMins;
/**
* Constructor for {@link JBossRemotingRemoteCommunicator} that initializes the client with no invoker locator
@@ -200,7 +215,17 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
m_clientConfiguration.putAll(client_config);
}
- m_needToCallInitializeCallback = new boolean[] { false };
+ m_needToCallInitializeCallback = false;
+ m_needToCallInitializeCallbackLock = new ReentrantReadWriteLock();
+
+ long mins;
+ try {
+ String minsStr = System.getProperty("rhq.communications.initial-callback-lock-wait-mins", "60");
+ mins = Long.parseLong(minsStr);
+ } catch (Throwable t) {
+ mins = 60L;
+ }
+ m_initializeCallbackLockAcquisitionTimeoutMins = mins;
return;
}
@@ -319,7 +344,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
if (m_remotingClient != null) {
m_remotingClient.disconnect();
m_remotingClient = null;
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
LOG.info(CommI18NResourceKeys.COMMUNICATOR_CHANGING_ENDPOINT, m_invokerLocator, locator);
@@ -377,7 +402,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void setInitializeCallback(InitializeCallback callback) {
m_initializeCallback = callback;
- m_needToCallInitializeCallback[0] = (callback != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (callback != null); // specifically do not synchrononize by using lock, just set it
}
public String getRemoteEndpoint() {
@@ -403,7 +428,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void connect() throws Exception {
if ((m_remotingClient != null) && !m_remotingClient.isConnected()) {
m_remotingClient.connect();
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
return;
@@ -412,7 +437,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void disconnect() {
if (m_remotingClient != null) {
m_remotingClient.disconnect();
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
return;
@@ -535,18 +560,38 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
private CommandResponse invokeInitializeCallbackIfNeeded(Command command) {
InitializeCallback callback = getInitializeCallback();
if (callback != null) {
- // block here - in effect, this will stop all commands from going out until the callback is done
- synchronized (m_needToCallInitializeCallback) {
- if (m_needToCallInitializeCallback[0]) {
- try {
- m_needToCallInitializeCallback[0] = !callback.sendingInitialCommand(this, command);
- LOG.debug(CommI18NResourceKeys.INITIALIZE_CALLBACK_DONE, m_needToCallInitializeCallback[0]);
- } catch (Throwable t) {
- m_needToCallInitializeCallback[0] = true; // callback failed, we'll want to call it again
- LOG.error(t, CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, ThrowableUtil.getAllMessages(t));
- return new GenericCommandResponse(command, false, null, t);
+ // block here - in effect, this will stop all commands from going out until the callback is done
+ // to avoid infinite blocking, we'll only wait for a set time (though long).
+
+ WriteLock writeLock = m_needToCallInitializeCallbackLock.writeLock();
+ boolean locked;
+ try {
+ locked = writeLock.tryLock(m_initializeCallbackLockAcquisitionTimeoutMins, TimeUnit.MINUTES);
+ } catch (InterruptedException ie) {
+ locked = false;
+ }
+
+ if (locked) {
+ try {
+ if (m_needToCallInitializeCallback) {
+ try {
+ m_needToCallInitializeCallback = (!callback.sendingInitialCommand(this, command));
+ LOG.debug(CommI18NResourceKeys.INITIALIZE_CALLBACK_DONE, m_needToCallInitializeCallback);
+ } catch (Throwable t) {
+ m_needToCallInitializeCallback = true; // callback failed, we'll want to call it again
+ LOG.error(t, CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, ThrowableUtil
+ .getAllMessages(t));
+ return new GenericCommandResponse(command, false, null, t);
+ }
}
+ } finally {
+ writeLock.unlock();
}
+ } else {
+ m_needToCallInitializeCallback = true; // can't invoke callback, we'll want to still call it later
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
}
}
return null;
commit 55ba6f8778820bdd417e99909220136a2e1e091f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 11:10:53 2010 -0500
BZ 566724 - if classloader fails to be created, master PC will skip the plugin
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
index f46eaf5..bd4feac 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
@@ -136,16 +136,23 @@ public class MasterServerPluginContainer {
String pluginName = descriptor.getName();
ServerPluginType pluginType = new ServerPluginType(descriptor);
PluginKey pluginKey = PluginKey.createServerPluginKey(pluginType.stringify(), pluginName);
- ClassLoader classLoader = this.classLoaderManager.obtainServerPluginClassLoader(pluginKey);
- log.debug("Pre-loading server plugin [" + pluginKey + "] from [" + pluginUrl
- + "] into its plugin container");
try {
- ServerPluginEnvironment env = new ServerPluginEnvironment(pluginUrl, classLoader, descriptor);
- boolean enabled = !allDisabledPlugins.contains(pluginKey);
- pc.loadPlugin(env, enabled);
- log.info("Preloaded server plugin [" + pluginKey.getPluginName() + "]");
+ ClassLoader classLoader = this.classLoaderManager.obtainServerPluginClassLoader(pluginKey);
+ log.debug("Pre-loading server plugin [" + pluginKey + "] from [" + pluginUrl
+ + "] into its plugin container");
+ try {
+ ServerPluginEnvironment env = new ServerPluginEnvironment(pluginUrl, classLoader,
+ descriptor);
+ boolean enabled = !allDisabledPlugins.contains(pluginKey);
+ pc.loadPlugin(env, enabled);
+ log.info("Preloaded server plugin [" + pluginName + "]");
+ } catch (Exception e) {
+ log.warn("Failed to preload server plugin [" + pluginName + "] from URL [" + pluginUrl
+ + "]", e);
+ }
} catch (Exception e) {
- log.warn("Failed to preload server plugin [" + pluginUrl + "]", e);
+ log.warn("Failed to preload server plugin [" + pluginName
+ + "]; cannot get its classloader from URL [ " + pluginUrl + "]", e);
}
} else {
log.warn("There is no server plugin container to support plugin: " + pluginUrl);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
index 9f27ce9..fa26970 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
@@ -64,7 +64,7 @@ public class ServerPluginClassLoader extends URLClassLoader {
try {
unpackedDirectory = unpackEmbeddedJars(pluginJarName, pluginUrl, classpathUrlList, tmpDirectory);
} catch (Exception e) {
- throw new Exception("Failed to unpack embedded JARs within: " + pluginUrl);
+ throw new Exception("Failed to unpack embedded JARs within: " + pluginUrl, e);
}
}
}
commit 2ffc564d7ff69a427755fa374419bc5980e47f94
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Fri Feb 19 13:37:36 2010 +0100
Fix link to definitions BZ 566004
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
index b6e386c..fd09f82 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
@@ -148,8 +148,7 @@
</onc:sortableColumnHeader>
</f:facet>
- <h:outputLink value="/alerts/Config.do">
- <f:param name="mode" value="viewRoles"/>
+ <h:outputLink value="/rhq/resource/alert/viewAlert.xhtml">
<f:param name="id" value="#{Resource.id}"/>
<f:param name="ad" value="#{item.alert.alertDefinition.id}"/>
<h:outputText value="#{item.alert.alertDefinition.name}" />
14 years, 2 months
[rhq] Branch 'alertPlugin' - 34 commits - .classpath modules/core modules/enterprise
by Heiko W. Rupp
.classpath | 1
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup-build.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml | 25
modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml | 23
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 51 ++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java | 142 +++++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java | 253 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java | 38 +
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java | 2
modules/enterprise/server/jar/pom.xml | 47 +
modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g | 181 +++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 66 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java | 120 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java | 31 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java | 119 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 6
modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt | 126 ++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java | 171 ++++++
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java | 39 +
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java | 64 ++
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java | 67 ++
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java | 20
28 files changed, 1559 insertions(+), 71 deletions(-)
New commits:
commit dd92239d4a43a1ae899353f3268857de832ead3e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 1 14:04:55 2010 +0100
Provide token descriptions and a way to get a full list of tokens defined.
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
new file mode 100644
index 0000000..78ac850
--- /dev/null
+++ b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
@@ -0,0 +1,64 @@
+/*
+ * 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.server.plugins.alertOperations;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Print the available tokens to stdout, for documentation generation purposes
+ * @author Heiko W. Rupp
+ */
+public class PrintTokens {
+
+ private final Log log = LogFactory.getLog(PrintTokens.class);
+ private static final String CLOSE = "\">\n";
+
+ public static void main(String[] args) throws Exception {
+
+ EnumSet<TokenClass> tokenClasses = EnumSet.allOf(TokenClass.class);
+
+ StringBuilder builder = new StringBuilder("<tokenClasses>\n");
+
+ for (TokenClass tc : tokenClasses ) {
+ builder.append(" <tokenClass name=\"").append(tc.getText()).
+ append("\"").append(" description=\"").append(tc.getDescription()).
+ append(CLOSE);
+
+ Set<Token> tokens = Token.getByTokenClass(tc);
+ for (Token token : tokens) {
+ builder.append(" <token name=\"").append(token.getName()).append(CLOSE);
+ builder.append(" <fullName>").append(token.getText()).append(CLOSE);
+ builder.append(" <descr>").append(token.getDescription()).append("</descr>\n");
+ builder.append(" </token>\n");
+
+ }
+
+ builder.append(" </tokenClass>\n");
+
+ }
+
+ builder.append("</tokenClasses>\n");
+
+ System.out.println(builder.toString());
+ }
+}
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
index bcd7570..e665bd4 100644
--- a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
+++ b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
@@ -19,39 +19,59 @@
package org.rhq.enterprise.server.plugins.alertOperations;
import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
/**
- * Tokens that can be replaced in
+ * Tokens that can be replaced in operation parameters
* @author Heiko W. Rupp
*/
public enum Token {
// Alert related tokens
- ALERT_ID(TokenClass.ALERT, "id"),
- ALERT_URL(TokenClass.ALERT, "url"),
+ ALERT_ID(TokenClass.ALERT, "id","The id of this particular alert"),
+ ALERT_URL(TokenClass.ALERT, "url","Url to the alert details page"),
+ ALERT_FIRE_TIME(TokenClass.ALERT, "firedAt","Time the alert fired"),
+ ALERT_WILL_RECOVER(TokenClass.ALERT,"willRecover","?? TODO"),
+ ALERT_CONDITIONS(TokenClass.ALERT,"conditions","A text representation of the conditions that led to this alert"),
+ ALERT_DEF_NAME(TokenClass.ALERT,"name","Name from the defining alert definition"),
+ ALERT_DEF_DESC(TokenClass.ALERT,"description","Description of this alert"),
+ ALERT_DEF_PRIO(TokenClass.ALERT,"priority", "Priority of this alert"),
+ ALERT_WILL_DISABLE(TokenClass.ALERT,"willBeDisabled","Will the alert definition be disabled after firing?"),
+
// resource that triggered the alert related tokens
- RESOURCE_ID(TokenClass.RESOURCE, "id"),
- RESOURCE_NAME(TokenClass.RESOURCE, "name"),
+ RESOURCE_ID(TokenClass.RESOURCE, "id", "Id of the resource"),
+ RESOURCE_NAME(TokenClass.RESOURCE, "name", "Name of the resource"),
// resource the operation is run on related tokens
- TRESOURCE_ID(TokenClass.TARGET_RESOURCE, "id"),
- TRESOURCE_NAME(TokenClass.TARGET_RESOURCE, "name"),
+ TRESOURCE_ID(TokenClass.TARGET_RESOURCE, "id","Id of the target resource"),
+ TRESOURCE_NAME(TokenClass.TARGET_RESOURCE, "name", "Name of the target resource"),
+
+ // Information about the fired operation
+ OPERATION_ID(TokenClass.OPERATION,"id","Id of the operation fired"),
+ OPERATION_NAME(TokenClass.OPERATION,"name","Name of the operation fired"),
// only for testing
- TEST_ECHO(TokenClass.TEST,"echo"),
- TEST_FIX(TokenClass.TEST,"fix")
+ TEST_ECHO(TokenClass.TEST,"echo", "Echo the input"),
+ TEST_FIX(TokenClass.TEST,"fix", "Return a fixed string")
;
+ private TokenClass tc;
+ private String name;
private String text;
+ private String description;
- private Token(TokenClass tc, String text) {
+ private Token(TokenClass tc, String name, String description) {
- this.text = tc.getText() + "." + text;
+ this.tc = tc;
+ this.name = name;
+ this.text = tc.getText() + "." + name;
+ this.description = description;
}
/**
@@ -69,4 +89,29 @@ public enum Token {
}
return null;
}
+
+ public static Set<Token> getByTokenClass(TokenClass tokenClass) {
+
+ Set<Token> tokens = new HashSet<Token>();
+
+ EnumSet<Token> es = EnumSet.allOf(Token.class);
+ for (Token t : es) {
+ if (t.tc == tokenClass)
+ tokens.add(t);
+ }
+
+ return tokens;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public String getDescription() {
+ return description;
+ }
}
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java
index 5125a72..16cb240 100644
--- a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java
+++ b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java
@@ -26,22 +26,30 @@ import java.util.EnumSet;
*/
public enum TokenClass {
- ALERT("alert"),
- RESOURCE("resource"),
- TARGET_RESOURCE("targetResource"),
- TEST("test");
+ ALERT("alert","Information about the alert itself"),
+ RESOURCE("resource","Information about the resource that triggered the alert"),
+ TARGET_RESOURCE("targetResource","Information about the resource the alert is fired on "),
+ OPERATION("operation","Information about the triggered operation"),
+ //
+ TEST("test","Just some dummies for internal testing purposes");
private String text;
+ private String description;
- private TokenClass(String text) {
+ private TokenClass(String text,String description) {
this.text = text;
+ this.description = description;
}
public String getText() {
return text;
}
- /**
+ public String getDescription() {
+ return description;
+ }
+
+ /**
* Return the tokenclass that matches the input text or null if not found.
* The token delimiters need to be already stripped from the input
* @param input a token text like <i>alert</i>, which would return the
commit ac9103aaf2c5c999bd6f1d940ff0159072b2cbad
Merge: 79afeae... 6278e70...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 1 10:47:39 2010 +0100
Merge branch 'master' into alertPlugin
commit 79afeae9fab3bcf14508792f0007c1c773934e36
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 1 10:46:53 2010 +0100
Provide a way to initialize the backing bean after it got created and the alertParameters got injected.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 0896c6e..ccb5d7d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -288,6 +288,12 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
Configuration config2 = config.deepCopy(true);
bean.setAlertParameters(config2);
+ try {
+ bean.internalInit();
+ }
+ catch (Throwable t ) {
+ LOG.error("getBackinBean, calling backingBean.internalInit() resulted in " + t.getMessage());
+ }
}
}
return bean;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
index e4b2d20..12312f2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
@@ -40,6 +40,13 @@ public class CustomAlertSenderBackingBean {
public void setAlertParameters(Configuration alertParameters) {
this.alertParameters = alertParameters;
}
+
+ /**
+ * This method is called after constructing the bean and injecting the
+ * #alertParameters
+ */
+ public void internalInit() {}
+
/**
* This method is called when the alert notification that uses this backing bean
* is removed, so that the backing bean can do some cleanup work
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
index 98fa0e9..dc41f01 100644
--- a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
+++ b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
@@ -67,19 +67,32 @@ public class OperationsBackingBean extends CustomAlertSenderBackingBean {
log.info("new " + hashCode());
}
- @Create
- public void init() {
- log.info("init");
+ @Override
+ public void internalInit() {
+/* log.info("internalInit");
+ try {
+ getResId();
+ getResourceName();
+ obtainOperationIds();
+ getOperationId();
+ lookupConfiguration();
+ }
+ catch (Throwable t) {
+ t.printStackTrace();
+ }*/
}
+
@Override
public void internalCleanup() {
+ log.info("internalCleanup");
PropertySimple parameterConfigProp = alertParameters.getSimple(OperationsSender.PARAMETERS_CONFIG);
if (parameterConfigProp!=null) {
Integer paramId = parameterConfigProp.getIntegerValue();
if (paramId!=null) {
ConfigurationManagerLocal cmgr = LookupUtil.getConfigurationManager();
cmgr.deleteConfigurations(Arrays.asList(paramId));
+ cleanProperty(alertParameters,OperationsSender.PARAMETERS_CONFIG);
}
}
}
@@ -92,6 +105,8 @@ public class OperationsBackingBean extends CustomAlertSenderBackingBean {
persistProperty(alertParameters, OperationsSender.RESOURCE_ID,resId);
cleanProperty(alertParameters,OperationsSender.OPERATION_ID);
cleanProperty(alertParameters,OperationsSender.USABLE);
+ operationIds = new HashMap<String,Integer>(); // Clean out operations dropdown
+ operationId = null;
}
@@ -116,25 +131,25 @@ public class OperationsBackingBean extends CustomAlertSenderBackingBean {
private void lookupConfiguration() {
-// log.info("getCD: " + configurationDefinition);
try {
// Subject subject = EnterpriseFacesContextUtility.getSubject();
Subject subject = LookupUtil.getSubjectManager().getOverlord(); // TODO replace with real subject
-// int operationId = Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("opId"));
OperationManagerLocal opMan = LookupUtil.getOperationManager();
obtainOperationIds();
- OperationDefinition operationDefinition = opMan.getOperationDefinition(subject, operationId);
- configurationDefinition = operationDefinition.getParametersConfigurationDefinition();
+ if (operationId!=null) {
+ OperationDefinition operationDefinition = opMan.getOperationDefinition(subject, operationId);
+ configurationDefinition = operationDefinition.getParametersConfigurationDefinition();
- // call a SLSB method to get around lazy initialization of configDefs and configTemplates
- ConfigurationManagerLocal configurationManager = LookupUtil.getConfigurationManager();
- configuration = configurationManager.getConfigurationFromDefaultTemplate(configurationDefinition);
-// Configuration newConfiguration = configuration.deepCopy(false);
-log.info("gConfig: " + configuration + ", " + configuration.hashCode() + ", " + configuration.getSimpleValue("detailedDiscovery","-unset-"));
+ // call a SLSB method to get around lazy initialization of configDefs and configTemplates
+ ConfigurationManagerLocal configurationManager = LookupUtil.getConfigurationManager();
+ configuration = configurationManager.getConfigurationFromDefaultTemplate(configurationDefinition);
+ // Configuration newConfiguration = configuration.deepCopy(false);
+ log.info("lookupConfiguration: " + configuration + ", " + configuration.hashCode() );
+ }
} catch (Exception e) {
e.printStackTrace();
}
commit 6278e7056403b2dcd0ffde84a7109e60790022eb
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:55:32 2010 -0500
simplify dbupgrade by merge saved search-related entries into a single schemaSpec
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 6fe555e..b2b3b11 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3231,9 +3231,7 @@
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
<schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
- </schemaSpec>
-
- <schemaSpec version="2.82.1">
+
<schema-directSQL>
<statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Platforms'">
INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
commit a6efa283222790b6e22f82861b1c145e34af9391
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:54:58 2010 -0500
insert some default global searches into the system during dbsetup
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
index 1a11114..da98622 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -10,7 +10,7 @@
DESCRIPTION="All downed machines across the entire enterprise"
PATTERN="down platform"
LAST_COMPUTE_TIME="0"
- SUBJECT="1"
+ SUBJECT_ID="1"
GLOBAL="TRUE" />
<data ID="2"
CONTEXT="Resource"
@@ -18,7 +18,7 @@
DESCRIPTION="All downed servers across the entire enterprise"
PATTERN="down server"
LAST_COMPUTE_TIME="0"
- SUBJECT="1"
+ SUBJECT_ID="1"
GLOBAL="TRUE" />
</table>
commit 1d02547312924f4904730bb0aebe7d0d8d9b70d2
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:21:37 2010 -0500
fix typo for column name in saved search table
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
index 7c0de23..14634b6 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
@@ -17,7 +17,7 @@
<column name="RESULT_COUNT" type="LONG" required="false"/>
<column name="SUBJECT_ID" type="INTEGER" references="RHQ_SUBJECT" required="true"/>
- <column name="ENABLED" type="BOOLEAN" required="true"/>
+ <column name="GLOBAL" type="BOOLEAN" required="true"/>
</table>
</dbsetup>
\ No newline at end of file
commit 92adfd37e105c60efc0f1981d7fc2258ee423ad5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 16:05:08 2010 -0500
change order of dbsetup so that saved search table gets created after the rhq_subject table
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
index f5e4eae..d5be746 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
@@ -39,7 +39,7 @@ To run the default target, you must set one of the following properties to true:
<property name="dbsetup.scripts.dir" value="${basedir}/src/main/scripts/dbsetup" />
<property name="dbsetup.output.dir" value="${basedir}/target/dbsetup" /> <!-- away from classes so it doesn't go into the jar -->
<!-- define the setup creation processing order. note, removals are done in the reverse order -->
- <property name="dbsetup.subsystems" value="search,config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
+ <property name="dbsetup.subsystems" value="config,cluster,inventory,auth,authz,search,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
<property name="dbsetup.combined.schema" value="${dbsetup.output.dir}/all-schema.xml" />
<property name="dbsetup.combined.data" value="${dbsetup.output.dir}/all-data.xml" />
<property name="dbsetup.tstamp.file" value="${dbsetup.output.dir}/dbsetup-combine.tstamp" />
commit d0ef49e101ef7887e834b0a9021c0c0654a7f5d5
Merge: 613b993... 8a0951a...
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:34:50 2010 -0500
Merge branch 'master' into search
commit 613b993b85ac47117fda5d7f7810318e891cdf0e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:32:41 2010 -0500
construct AST from parse tree for RHQL grammar
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
index 00a0dab..ded91a1 100644
--- a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -27,11 +27,43 @@
* @author Joseph Marques
*/
grammar RHQL;
-
options {
language=Java;
backtrack=true;
memoize=true;
+ output=AST;
+ ASTLabelType=CommonTree;
+}
+
+/*
+ * Imaginary nodes serve to fully abstract the parse tree from the AST. This
+ * allows us, for example, to support the conjunctive ('and') operator between
+ * conditional expressions, but gives us the flexibility to modify the lexical
+ * element that represents that operation. In the future, we might want to
+ * support '&&' instead of 'and', or even support them both. The inclusion of
+ * imaginary tokens creates a more stable AST that downstream grammars can use
+ * without fear that every change to the syntax will break their tree parser.
+ */
+tokens {
+ OR;
+ AND;
+
+ CONTEXT;
+ LINEAGE;
+ PATH;
+ PARAM;
+ IDENT;
+ VALUE;
+
+ OP_EQUALS;
+ OP_EQUALS_STRICT;
+ OP_NULL;
+ OP_IN;
+
+ OP_NOT_EQUALS;
+ OP_NOT_EQUALS_STRICT;
+ OP_NOT_NULL;
+ OP_NOT_IN;
}
@header {
@@ -41,26 +73,29 @@ options {
package org.rhq.enterprise.server.search;
}
+
/*
* parser rules
*/
searchExpression
- : conditionalExpression
+ : conditionalExpression { System.out.println($conditionalExpression.tree.toStringTree()); }
;
conditionalExpression
- : conditionalFactor ( 'or' conditionalFactor )*
- ;
+ : conds+=conditionalFactor ( WS* ( 'or' ) WS* conds+=conditionalFactor )* -> { $conds.size() == 1 }? ^($conds)
+ -> ^(OR conditionalFactor+)
+ ; // use rewrite predicates to eliminate superfluous 'or' node if only one child
conditionalFactor
- : conditionalPrimary ( ( 'and' )? conditionalPrimary )*
- ;
+ : conds+=conditionalPrimary ( WS* ( 'and' WS* )? conds+=conditionalPrimary )* -> { $conds.size() == 1 }? ^($conds)
+ -> ^(AND conditionalPrimary+)
+ ; // use rewrite predicates to eliminate superfluous 'and' node if only one child
conditionalPrimary
- : simpleConditionalExpression
- | '(' conditionalExpression ')'
- ;
+ : WS* simpleConditionalExpression WS* -> simpleConditionalExpression
+ | '(' WS* conditionalExpression WS* ')' -> conditionalExpression
+ ; // avoid building nodes for parens, tree structure implies existence appropriately -- ignore captured WS
simpleConditionalExpression
: comparisonConditionalExpression
@@ -69,69 +104,78 @@ simpleConditionalExpression
;
comparisonConditionalExpression
- : context comparisonOperator identifier
- ;
+ : c=context WS* op=comparisonOperator WS* ident=identifier -> ^($op $c ^(VALUE $ident))
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
nullComparisonConditionalExpression
- : context nullOperator
- ;
+ : c=context WS* op=nullOperator -> ^($op $c)
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
inExpression
- : context inOperator '[' '='? identifier ( ',' '='? identifier )* ']'
- ;
+ : c=context WS* op=inOperator WS* '[' WS* ids+=identifier WS* ( ',' WS* ids+=identifier WS* )* ']'
+ -> ^($op $c ^(VALUE $ids+))
+ ; // rewrite tree output so operator is always the root -- ignore captured WS
context
- : ( lineage '.' )? path ( '[' identifier ']' )?
+ : ( l=lineage '.' )? p=path ( '[' ident=identifier ']' )? -> ^(CONTEXT ^(LINEAGE $l)? ^(PATH $p) ^(PARAM $ident)?)
;
lineage
- : path ( '(' INT ')' )?
- ;
+ : path ( '('! LEVEL ')'! )?
+ ; // avoid building nodes for brackets, tree structure implies existence appropriately
path
: ID+
;
identifier
- : quotedValue
- | value
+ : doubleQuotedValue -> ^(IDENT doubleQuotedValue)
+ | quotedValue -> ^(IDENT quotedValue)
+ | openEndedvalue -> ^(IDENT openEndedvalue)
;
+doubleQuotedValue
+ : '"'! ~('"')* '"'!
+ ; // avoid building nodes for the double-quote characters
+
+
quotedValue
- : '\'' ~('\'')* '\''
- ;
+ : '\''! ~('\'')* '\''!
+ ; // avoid building nodes for the sinngle-quote characters
-value
- : ~('\'') ~(']'|','|')')*
- ;
+openEndedvalue
+ : ~(']' | ',' | ')' | '(' | 'or' | 'and' | WS )*
+ ; // consume until we find a char to terminate the current phrase ']' ',' ')' or begin the next '(' 'or' 'and'
comparisonOperator
- : '='
- | '=='
- | '!='
- | '!=='
- ;
+ : '=' -> ^(OP_EQUALS)
+ | '==' -> ^(OP_EQUALS_STRICT)
+ | '!=' -> ^(OP_NOT_EQUALS)
+ | '!==' -> ^(OP_NOT_EQUALS_STRICT)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
nullOperator
- : 'is' 'not'? 'null'
- ;
+ : 'is' WS+ (negation='not' WS+)? 'null' -> { $negation == null }? ^(OP_NULL)
+ -> ^(OP_NOT_NULL)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
inOperator
- : 'not'? 'in'
- ;
+ : (negation+='not' WS+)? 'in' -> { $negation == null }? ^(OP_IN)
+ -> ^(OP_NOT_IN)
+ ; // use imaginary nodes for all operators, which further removes the AST from the real lexical elements
/*
* lexical elements
- */
+ */
ID
: 'a'..'z'
;
-INT
- : '0'..'9'
+LEVEL
+ : '0'..'5'
;
WS
- : ( ' ' | '\n' | '\r' )+ { $channel = HIDDEN; }
+ : ( ' ' | '\n' | '\r' )+
;
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
index 637e339..ceab3e3 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
@@ -62,6 +62,7 @@ public class RHQLTest extends AssertJUnit {
@Override
public TestResult call() throws Exception {
try {
+ System.out.println(line);
ANTLRStringStream input = new ANTLRStringStream(line); // Create an input character stream from standard in
RHQLLexer lexer = new RHQLLexer(input); // Create an echoLexer that feeds from that stream
CommonTokenStream tokens = new CommonTokenStream(lexer); // Create a stream of tokens fed by the lexer
commit eac78662084095c22fb80326643fbf59f0e1a863
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Feb 26 15:31:54 2010 -0500
modify RHQL test case file to adhere to simpler syntax for IN-clause:
* remove multi-word non-quoted identifers for the IN-clause
* remove ability to change case-sensitivity comparison for IN-clause
diff --git a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
index 2a5a195..f8c241a 100644
--- a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
+++ b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
@@ -7,11 +7,11 @@ context !== value
context is null
context is not null
context in [value]
-context in [value1, =value2]
-context in [=value1, value2, value3]
+context in [value1, value2]
+context in [value1, value2, value3]
context not in [value]
-context not in [value1, =value2]
-context not in [=value1, value2, value3]
+context not in [value1, value2]
+context not in [value1, value2, value3]
# simple term, all operators, quoted value
context = 'quoted value'
@@ -21,19 +21,11 @@ context !== 'quoted value'
context is null
context is not null
context in ['quoted value1']
-context in ['quoted value1', ='quoted value2']
-context in [='quoted value1', 'quoted value2', 'quoted value3']
+context in ['quoted value1', 'quoted value2']
+context in ['quoted value1', 'quoted value2', 'quoted value3']
context not in ['quoted value1']
-context not in ['quoted value1', ='quoted value2']
-context not in [='quoted value1', 'quoted value2', 'quoted value3']
-
-# simple term, 'in' operator, non-quoted but multi-word values
-context in [quoted value1]
-context in [quoted value1, =quoted value2]
-context in [=quoted value1, quoted value2, quoted value3]
-context not in [quoted value1]
-context not in [quoted value1, =quoted value2]
-context not in [=quoted value1, quoted value2, quoted value3]
+context not in ['quoted value1', 'quoted value2']
+context not in ['quoted value1', 'quoted value2', 'quoted value3']
# parameterized term, all operators
context[param] = value
@@ -43,11 +35,11 @@ context[param] !== value
context[param] is null
context[param] is not null
context[param] in [value]
-context[param] in [value1, =value2]
-context[param] in [=value1, value2, value3]
+context[param] in [value1, value2]
+context[param] in [value1, value2, value3]
context[param] not in [value]
-context[param] not in [value1, =value2]
-context[param] not in [=value1, value2, value3]
+context[param] not in [value1, value2]
+context[param] not in [value1, value2, value3]
# deeply nested parenthetical simple terms
((context = value))
@@ -63,11 +55,11 @@ context[param] not in [=value1, value2, value3]
(context is null)
(context is not null)
(context in [value])
-(context in [value1, =value2])
-(context in [=value1, value2, value3])
+(context in [value1, value2])
+(context in [value1, value2, value3])
(context not in [value])
-(context not in [value1, =value2])
-(context not in [=value1, value2, value3])
+(context not in [value1, value2])
+(context not in [value1, value2, value3])
# parameterized parenthetical term, all operators
(context[param] = value)
@@ -77,11 +69,11 @@ context[param] not in [=value1, value2, value3]
(context[param] is null)
(context[param] is not null)
(context[param] in [value])
-(context[param] in [value1, =value2])
-(context[param] in [=value1, value2, value3])
+(context[param] in [value1, value2])
+(context[param] in [value1, value2, value3])
(context[param] not in [value])
-(context[param] not in [value1, =value2])
-(context[param] not in [=value1, value2, value3])
+(context[param] not in [value1, value2])
+(context[param] not in [value1, value2, value3])
# single-pair parenthetical combinations
@@ -131,4 +123,4 @@ context = value1 and ((context = value2))
((context = value1)) context = value2
(context = value1) (context = value2)
(context = value1 (context = value2))
-context = value1 ((context1 = value2))
\ No newline at end of file
+context = value1 ((context = value2))
\ No newline at end of file
commit 8a0951a835997a2cdc75d2cf9840a7a7fdf59c15
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 26 17:57:56 2010 +0100
BZ 568544 - disambiguation doesn't get confused if more than one item in the provided results corresponds to a signle resource.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
index 67f3276..dd359da 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
@@ -64,6 +64,6 @@ public class DisambiguationReport<T> implements Serializable {
}
public String toString() {
- return "DisambiguationReport(type=" + resourceTypeName + ", plugin=" + resourceTypePluginName + ", parents=" + parents + ")";
+ return "DisambiguationReport(type=" + resourceTypeName + ", plugin=" + resourceTypePluginName + ", parents=" + parents + ", original=" + original + ")";
}
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 3af7a35..e5684d2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -31,6 +31,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -2170,34 +2171,36 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
false);
}
- //this will contain the disambiguated results
- List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size());
boolean typeResolutionNeeded = false;
boolean pluginResolutionNeeded = false;
boolean parentResolutionNeeded = false;
//we can't assume the ordering of the provided results and the disambiguation query results
- //will be the same, hence this map.
- Map<Integer, MutableDisambiguationReport<T>> reportByResourceId = new HashMap<Integer, MutableDisambiguationReport<T>>();
+ //will be the same.
+
+ //this list contains the resulting reports in the same order as the original results
+ List<MutableDisambiguationReport<T>> reports = new ArrayList<MutableDisambiguationReport<T>>(results.size());
+
+ //this maps the reports to resourceIds. More than one report can correspond to a single
+ //resource id. The reports in this map are the same instances as in the reports list.
+ Map<Integer, List<MutableDisambiguationReport<T>>> reportsByResourceId = new HashMap<Integer, List<MutableDisambiguationReport<T>>>();
for (T r : results) {
MutableDisambiguationReport<T> value = new MutableDisambiguationReport<T>();
value.original = r;
int resourceId = extractor.extract(r);
if (resourceId > 0) {
- reportByResourceId.put(resourceId, value);
+ List<MutableDisambiguationReport<T>> correspondingResults = reportsByResourceId.get(resourceId);
+ if (correspondingResults == null) {
+ correspondingResults = new ArrayList<MutableDisambiguationReport<T>>();
+ reportsByResourceId.put(resourceId, correspondingResults);
+ }
+ correspondingResults.add(value);
}
+ reports.add(value);
}
//check that we still have something to disambiguate
- if (reportByResourceId.isEmpty()) {
- //no, we don't. construct the resolution only using the results.
-
- for (T result : results) {
- DisambiguationReport<T> report = new DisambiguationReport<T>(result, Collections
- .<ResourceParentFlyweight> emptyList(), null, null);
- resolution.add(report);
- }
- } else {
+ if (reportsByResourceId.size() > 0) {
//first find out how many ancestors we are going to require to disambiguate the resuls
String query = Resource.NATIVE_QUERY_FIND_DISAMBIGUATION_LEVEL;
@@ -2247,7 +2250,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
Query parentsQuery = entityManager.createQuery(selectBuilder.append(" ").append(fromBuilder).toString());
- parentsQuery.setParameter("resourceIds", reportByResourceId.keySet());
+ parentsQuery.setParameter("resourceIds", reportsByResourceId.keySet());
@SuppressWarnings("unchecked")
List<Object[]> parentsResults = (List<Object[]>) parentsQuery.getResultList();
@@ -2264,28 +2267,22 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
String parentName = (String) parentsResult[2 * i + 2];
parents.add(new ResourceParentFlyweight(parentId, parentName));
}
- MutableDisambiguationReport<T> report = reportByResourceId.get(resourceId);
- report.typeName = typeName;
- report.pluginName = pluginName;
- report.parents = parents;
- }
-
- //now we have all the information to create the result.
- for (T result : results) {
- int resourceId = extractor.extract(result);
- if (resourceId > 0) {
- //this results was disambiguated by the query above...
- MutableDisambiguationReport<T> report = reportByResourceId.get(resourceId);
- resolution.add(report.getReport());
- } else {
- //this result doesn't correspond to any resource, need to handle it specially
- DisambiguationReport<T> report = new DisambiguationReport<T>(result, Collections
- .<ResourceParentFlyweight> emptyList(), null, null);
- resolution.add(report);
+
+ //update all the reports that correspond to this resourceId
+ for(MutableDisambiguationReport<T> report : reportsByResourceId.get(resourceId)) {
+ report.typeName = typeName;
+ report.pluginName = pluginName;
+ report.parents = parents;
}
}
}
+ List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size());
+
+ for (MutableDisambiguationReport<T> report : reports) {
+ resolution.add(report.getReport());
+ }
+
return new ResourceNamesDisambiguationResult<T>(resolution, typeResolutionNeeded, parentResolutionNeeded,
pluginResolutionNeeded);
}
@@ -2297,7 +2294,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public List<ResourceParentFlyweight> parents;
public DisambiguationReport<T> getReport() {
- return new DisambiguationReport<T>(original, parents, typeName, pluginName);
+ return new DisambiguationReport<T>(original, parents == null ? Collections
+ .<ResourceParentFlyweight> emptyList() : parents, typeName, pluginName);
}
}
}
commit b2f7c0e76fc8bd366bb58bda3250b75cf6f7ecca
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 26 12:51:53 2010 +0100
BZ 565626 - fixing the URL query string for groups used in menu search.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
index a5bd861..6a837c9 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
@@ -164,7 +164,7 @@ public class ResourceGroupComposite implements Serializable {
* @return query string snippet that can appear after the "?" in group URLs.
*/
public String getGroupQueryString() {
- return "category=" + getCategory().getName() + "&groupId=" + getResourceGroup().getId();
+ return "groupId=" + getResourceGroup().getId();
}
private String getAlignedAvailabilityResults(long up, long down) {
commit 602b8780654df9298dc36f6e8523e2ebb3e0c906
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Feb 25 12:34:39 2010 -0500
add missing @WebMethod annotation to saved search manager remote interface
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
index ffd4255..231167e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -112,6 +112,7 @@ public interface SavedSearchManagerRemote {
* @return the {@link PageList} of {@link SavedSearch} entities that match the criteria filters, an empty list
* will be returned if no results were found or none matches the given filters
*/
+ @WebMethod
public PageList<SavedSearch> findSavedSearchesByCriteria( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "criteria") SavedSearchCriteria criteria);
commit 07a482e999b87952b9cdbd2573fe6b04c4b8ff8e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Feb 24 22:04:30 2010 -0500
abstract RHQL grammar support:
* initial combined lexer/parser grammar file
* test harness to verify grammar correctness
* 100 acceptance test cases exercising all major parts of generic syntax
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
new file mode 100644
index 0000000..00a0dab
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -0,0 +1,137 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * Antlr v3 grammar file to parse RHQL search expressions.
+ *
+ * @author Joseph Marques
+ */
+grammar RHQL;
+
+options {
+ language=Java;
+ backtrack=true;
+ memoize=true;
+}
+
+@header {
+ package org.rhq.enterprise.server.search;
+}
+@lexer::header {
+ package org.rhq.enterprise.server.search;
+}
+
+/*
+ * parser rules
+ */
+
+searchExpression
+ : conditionalExpression
+ ;
+
+conditionalExpression
+ : conditionalFactor ( 'or' conditionalFactor )*
+ ;
+
+conditionalFactor
+ : conditionalPrimary ( ( 'and' )? conditionalPrimary )*
+ ;
+
+conditionalPrimary
+ : simpleConditionalExpression
+ | '(' conditionalExpression ')'
+ ;
+
+simpleConditionalExpression
+ : comparisonConditionalExpression
+ | nullComparisonConditionalExpression
+ | inExpression
+ ;
+
+comparisonConditionalExpression
+ : context comparisonOperator identifier
+ ;
+
+nullComparisonConditionalExpression
+ : context nullOperator
+ ;
+
+inExpression
+ : context inOperator '[' '='? identifier ( ',' '='? identifier )* ']'
+ ;
+
+context
+ : ( lineage '.' )? path ( '[' identifier ']' )?
+ ;
+
+lineage
+ : path ( '(' INT ')' )?
+ ;
+
+path
+ : ID+
+ ;
+
+identifier
+ : quotedValue
+ | value
+ ;
+
+quotedValue
+ : '\'' ~('\'')* '\''
+ ;
+
+value
+ : ~('\'') ~(']'|','|')')*
+ ;
+
+comparisonOperator
+ : '='
+ | '=='
+ | '!='
+ | '!=='
+ ;
+
+nullOperator
+ : 'is' 'not'? 'null'
+ ;
+
+inOperator
+ : 'not'? 'in'
+ ;
+
+/*
+ * lexical elements
+ */
+
+ID
+ : 'a'..'z'
+ ;
+
+INT
+ : '0'..'9'
+ ;
+
+WS
+ : ( ' ' | '\n' | '\r' )+ { $channel = HIDDEN; }
+ ;
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
new file mode 100644
index 0000000..2a5a195
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
@@ -0,0 +1,134 @@
+
+# simple term, all operators
+context = value
+context == value
+context != value
+context !== value
+context is null
+context is not null
+context in [value]
+context in [value1, =value2]
+context in [=value1, value2, value3]
+context not in [value]
+context not in [value1, =value2]
+context not in [=value1, value2, value3]
+
+# simple term, all operators, quoted value
+context = 'quoted value'
+context == 'quoted value'
+context != 'quoted value'
+context !== 'quoted value'
+context is null
+context is not null
+context in ['quoted value1']
+context in ['quoted value1', ='quoted value2']
+context in [='quoted value1', 'quoted value2', 'quoted value3']
+context not in ['quoted value1']
+context not in ['quoted value1', ='quoted value2']
+context not in [='quoted value1', 'quoted value2', 'quoted value3']
+
+# simple term, 'in' operator, non-quoted but multi-word values
+context in [quoted value1]
+context in [quoted value1, =quoted value2]
+context in [=quoted value1, quoted value2, quoted value3]
+context not in [quoted value1]
+context not in [quoted value1, =quoted value2]
+context not in [=quoted value1, quoted value2, quoted value3]
+
+# parameterized term, all operators
+context[param] = value
+context[param] == value
+context[param] != value
+context[param] !== value
+context[param] is null
+context[param] is not null
+context[param] in [value]
+context[param] in [value1, =value2]
+context[param] in [=value1, value2, value3]
+context[param] not in [value]
+context[param] not in [value1, =value2]
+context[param] not in [=value1, value2, value3]
+
+# deeply nested parenthetical simple terms
+((context = value))
+(((context = value)))
+((((context = value))))
+(((((context = value)))))
+
+# simple parenthetical term, all operators
+(context = value)
+(context == value)
+(context != value)
+(context !== value)
+(context is null)
+(context is not null)
+(context in [value])
+(context in [value1, =value2])
+(context in [=value1, value2, value3])
+(context not in [value])
+(context not in [value1, =value2])
+(context not in [=value1, value2, value3])
+
+# parameterized parenthetical term, all operators
+(context[param] = value)
+(context[param] == value)
+(context[param] != value)
+(context[param] !== value)
+(context[param] is null)
+(context[param] is not null)
+(context[param] in [value])
+(context[param] in [value1, =value2])
+(context[param] in [=value1, value2, value3])
+(context[param] not in [value])
+(context[param] not in [value1, =value2])
+(context[param] not in [=value1, value2, value3])
+
+
+# single-pair parenthetical combinations
+# simple expression, 'or' boolean operator
+context = value1 or context = value2
+(context = value1) or context = value2
+context = value1 or (context = value2)
+(context = value1) or (context = value2)
+
+# single-pair parenthetical combinations
+# simple expression, 'and' boolean operator
+context = value and context = value
+(context = value) and context = value
+context = value and (context = value)
+(context = value) and (context = value)
+
+# single-pair parenthetical combinations
+# simple expression, no boolean operator (implies 'and' semantics)
+context = value context = value
+(context = value) context = value
+context = value (context = value)
+(context = value) (context = value)
+
+
+# double-pair parenthetical combinations
+# simple expression, 'or' boolean operator
+((context = value1 or context = value2))
+((context = value1) or context = value2)
+((context = value1)) or context = value2
+(context = value1) or (context = value2)
+(context = value1 or (context = value2))
+context = value1 or ((context = value2))
+
+# double-pair parenthetical combinations
+# simple expression, 'and' boolean operator
+((context = value1 and context = value2))
+((context = value1) and context = value2)
+((context = value1)) and context = value2
+(context = value1) and (context = value2)
+(context = value1 and (context = value2))
+context = value1 and ((context = value2))
+
+# double-pair parenthetical combinations
+# simple expression, no boolean operator (implies 'and' semantics)
+((context = value1 context = value2))
+((context = value1) context = value2)
+((context = value1)) context = value2
+(context = value1) (context = value2)
+(context = value1 (context = value2))
+context = value1 ((context1 = value2))
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
new file mode 100644
index 0000000..637e339
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/RHQLTest.java
@@ -0,0 +1,170 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.testng.AssertJUnit;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+/**
+ * Test harness to verify correctness of RHQL grammar
+ *
+ * @author Joseph Marques
+ */
+public class RHQLTest extends AssertJUnit {
+
+ private enum TestResult {
+ SUCCESS, FAILURE, TIMEOUT, SKIPPED;
+ }
+
+ private class AntlrTask implements Callable<TestResult> {
+ private String line;
+
+ public AntlrTask(String line) {
+ this.line = line;
+ }
+
+ @Override
+ public TestResult call() throws Exception {
+ try {
+ ANTLRStringStream input = new ANTLRStringStream(line); // Create an input character stream from standard in
+ RHQLLexer lexer = new RHQLLexer(input); // Create an echoLexer that feeds from that stream
+ CommonTokenStream tokens = new CommonTokenStream(lexer); // Create a stream of tokens fed by the lexer
+ RHQLParser parser = new RHQLParser(tokens); // Create a parser that feeds off the token stream
+ parser.searchExpression(); // Begin parsing at 'searchExpression' rule
+ return TestResult.SUCCESS;
+ } catch (Throwable t) {
+ return TestResult.FAILURE;
+ }
+ }
+ };
+
+ private ExecutorService executor;
+
+ @BeforeSuite
+ public void init() {
+ executor = Executors.newSingleThreadExecutor();
+ }
+
+ @AfterSuite
+ public void teardown() {
+ executor.shutdownNow();
+ }
+
+ @Test
+ public void testSingleLineRHQL() throws Exception {
+ BufferedReader reader = null;
+ List<String> successes = new java.util.ArrayList<String>();
+ List<String> failures = new java.util.ArrayList<String>();
+ int count = 0;
+ try {
+ InputStream stream = getClass().getClassLoader().getResourceAsStream("single-line-rhql.txt");
+ reader = new BufferedReader(new InputStreamReader(stream));
+ String line = null;
+ long timeout = 2000;
+ while ((line = reader.readLine()) != null) {
+ TestResult result = testSuccess(line, timeout);
+ if (result == TestResult.SKIPPED) {
+ continue;
+ }
+ count++;
+ if (result == TestResult.SUCCESS) {
+ successes.add(line);
+ } else if (result == TestResult.FAILURE) {
+ failures.add(line);
+ } else if (result == TestResult.TIMEOUT) {
+ System.out.println("Parsing took more than " + timeout
+ + "ms, does your grammar have an infinite loop?");
+ }
+ }
+ } catch (Exception e) {
+ System.out.println("Error testing single line RHQL: " + e);
+ throw e;
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+
+ System.out.println();
+ for (String success : successes) {
+ System.out.println("Parse success: " + success);
+ }
+ for (String failure : failures) {
+ System.out.println("Parse failure: " + failure);
+ }
+
+ System.out.println();
+ System.out.printf("RHQL expressions parsed: %1$s, Failures: %2$s", count, failures.size());
+ System.out.println();
+
+ assert failures.size() == 0;
+ }
+
+ private TestResult testSuccess(final String line, long timeout) {
+ if (shouldSkip(line)) {
+ return TestResult.SKIPPED; // skip empty lines used for visual separation in test file
+ }
+
+ AntlrTask task = new AntlrTask(line);
+ Future<TestResult> futureTask = executor.submit(task);
+ TestResult result = null;
+ try {
+ result = futureTask.get(timeout, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException ee) {
+ } catch (TimeoutException te) {
+ futureTask.cancel(true);
+ result = TestResult.TIMEOUT;
+ } catch (InterruptedException ie) {
+ futureTask.cancel(true);
+ }
+
+ return result;
+ }
+
+ private boolean shouldSkip(String line) {
+ line = line.trim();
+ if (line.equals("")) {
+ return true; // ignore empty lines
+ }
+ if (line.startsWith("#")) {
+ return true; // ignore comments
+ }
+ return false;
+ }
+}
commit 7369db803076bc12f02bcc6131b9fe1e5303ae47
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Feb 24 01:57:08 2010 -0500
antlr should compile the grammar files before the standard maven compile phase
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index b322503..533c0e9 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -467,10 +467,10 @@
<version>3.2</version>
<executions>
<execution>
- <phase>compile</phase>
- <goals>
- <goal>antlr</goal>
- </goals>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
<configuration>
<conversionTimeout>30000</conversionTimeout>
<debug>false</debug>
commit d17f4616c524e65decd6af3db65df8a83d18c12e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 16:54:20 2010 -0500
add anltr support to server/jar maven module, update eclipse classpath accordingly;
diff --git a/.classpath b/.classpath
index 660d74d..1a35400 100644
--- a/.classpath
+++ b/.classpath
@@ -19,6 +19,7 @@
<classpathentry kind="src" path="modules/plugins/jboss-cache/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-cache-v3/src/main/java"/>
<classpathentry kind="src" path="etc/samples/perspectives/sample-perspective/app/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/server/jar/target/generated-sources/antlr3"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index e109c41..b322503 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -366,6 +366,13 @@
<artifactId>test-utils</artifactId>
<version>${version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.2</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
@@ -454,6 +461,41 @@
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr3-maven-plugin</artifactId>
+ <version>3.2</version>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ <configuration>
+ <conversionTimeout>30000</conversionTimeout>
+ <debug>false</debug>
+ <dfa>false</dfa>
+ <nfa>false</nfa>
+ <excludes>
+
+ </excludes>
+ <includes>
+
+ </includes>
+ <libDirectory>src/main/antlr3/imports</libDirectory>
+ <messageFormat>antlr</messageFormat>
+ <outputDirectory>target/generated-sources/antlr3</outputDirectory>
+ <printGrammar>false</printGrammar>
+ <profile>false</profile>
+ <report>false</report>
+ <sourceDirectory>src/main/antlr3</sourceDirectory>
+ <trace>false</trace>
+ <verbose>true</verbose>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
commit fc1118af81ff953f2c05fb696629d799169b22f1
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 13:21:29 2010 -0500
fix some whitespace issues
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index f14e145..e109c41 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -414,7 +414,7 @@
Build-Jdk=${java.version}
Build-OS-Name=${os.name}
Build-OS-Version=${os.version}
-</echo>
+ </echo>
</tasks>
</configuration>
<goals>
@@ -593,8 +593,7 @@
<link href="../domain" />
<link href="../plugin-api" />
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
- <bottom><![CDATA[Copyright © 2008-2009 <a href="http://rhq-project.org/">Red Hat, Inc.</a>. All Rights Reserved.
-]]></bottom>
+ <bottom><![CDATA[Copyright © 2008-2009 <a href="http://rhq-project.org/">Red Hat, Inc.</a>. All Rights Reserved.]]></bottom>
</javadoc>
</tasks>
</configuration>
commit 1c79730a4d3ce260e2f3d6ce9b8e971da158e1d7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 13:10:18 2010 -0500
add some default, global saved searches for the resource context
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
new file mode 100644
index 0000000..1a11114
--- /dev/null
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<dbsetup name="search-data.xml">
+
+ <!-- overlord-created, global, default saved searches -->
+ <table name="RHQ_SAVED_SEARCH">
+ <data ID="1"
+ CONTEXT="Resource"
+ NAME="Downed Platforms"
+ DESCRIPTION="All downed machines across the entire enterprise"
+ PATTERN="down platform"
+ LAST_COMPUTE_TIME="0"
+ SUBJECT="1"
+ GLOBAL="TRUE" />
+ <data ID="2"
+ CONTEXT="Resource"
+ NAME="Downed Servers"
+ DESCRIPTION="All downed servers across the entire enterprise"
+ PATTERN="down server"
+ LAST_COMPUTE_TIME="0"
+ SUBJECT="1"
+ GLOBAL="TRUE" />
+ </table>
+
+</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 834e9ce..6fe555e 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3202,13 +3202,18 @@
</statement>
</schema-directSQL>
</schemaSpec>
-
+
<schemaSpec version="2.82">
<schema-directSQL>
<statement desc="Creating table RHQ_SAVED_SEARCH">
CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER )
</statement>
</schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_AFFINITY_GROUP">
+ ALTER TABLE RHQ_SAVED_SEARCH ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
<schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
@@ -3227,6 +3232,29 @@
<schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
<schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
</schemaSpec>
+
+ <schemaSpec version="2.82.1">
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Platforms'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, true)
+ </statement>
+ <statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Platforms'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (1, 'Resource', 'Downed Platforms', 'All downed machines across the entire enterprise', 'down platform', 0, 1, 1)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql" desc="Inserting global default saved search 'Downed Servers'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, true)
+ </statement>
+ <statement targetDBVendor="oracle" desc="Inserting global default saved search 'Downed Servers'">
+ INSERT INTO rhq_saved_search (id, context, name, description, pattern, last_compute_time, subject_id, global)
+ VALUES (2, 'Resource', 'Downed Servers', 'All downed servers across the entire enterprise', 'down server', 0, 1, 1)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
commit 68f3634b787768dd5ee138a04a5398fdd4cb6404
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 12:07:56 2010 -0500
fix copy/paste error for saved search entity annotation
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
index 9142772..d6b50e7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
@@ -87,7 +87,7 @@ public class SavedSearch {
@Column(name = "SUBJECT_ID", nullable = false)
private Subject subject;
- @Column(name = "RESOURCE_ID", insertable = false, updatable = false)
+ @Column(name = "SUBJECT_ID", insertable = false, updatable = false)
private int subjectId;
@Column(name = "GLOBAL", nullable = false)
commit 2325fa6314a7ebcbf1d932fb42e9f9559e1d079b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 03:02:28 2010 -0500
add auto-completion capability for saved search manager to the CLI
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index acafe6f..a1a5b38 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -54,6 +54,7 @@ import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerRemote;
+import org.rhq.enterprise.server.search.SavedSearchManagerRemote;
import org.rhq.enterprise.server.support.SupportManagerRemote;
import org.rhq.enterprise.server.system.ServerVersion;
import org.rhq.enterprise.server.system.SystemManagerRemote;
@@ -94,6 +95,7 @@ public class RemoteClient {
ResourceGroupManager(ResourceGroupManagerRemote.class), //
ResourceTypeManager(ResourceTypeManagerRemote.class), //
RoleManager(RoleManagerRemote.class), //
+ SavedSearchManager(SavedSearchManagerRemote.class), //
SubjectManager(SubjectManagerRemote.class), //
SupportManager(SupportManagerRemote.class), //
SystemManager(SystemManagerRemote.class) //
commit 9bfad0211e66635e09d02d8959a81db33f6175b7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:51:14 2010 -0500
add LookupUtil method to retrieve the saved search manager from the UI layer
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index dc9ae11..c21526a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -165,6 +165,8 @@ import org.rhq.enterprise.server.resource.metadata.ResourceMetadataManagerBean;
import org.rhq.enterprise.server.resource.metadata.ResourceMetadataManagerLocal;
import org.rhq.enterprise.server.scheduler.SchedulerBean;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerBean;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
import org.rhq.enterprise.server.subsystem.AlertSubsystemManagerBean;
import org.rhq.enterprise.server.subsystem.AlertSubsystemManagerLocal;
import org.rhq.enterprise.server.subsystem.ConfigurationSubsystemManagerBean;
@@ -516,6 +518,10 @@ public final class LookupUtil {
return lookupLocal(SchedulerBean.class);
}
+ public static SavedSearchManagerLocal getSavedSearchManager() {
+ return lookupLocal(SavedSearchManagerBean.class);
+ }
+
public static SubjectManagerLocal getSubjectManager() {
return lookupLocal(SubjectManagerBean.class);
}
commit 7b68ec1372bd5af42793b5d15020e7b2f66bb931
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:49:08 2010 -0500
add criteria-based retrieval for the saved search manager
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
new file mode 100644
index 0000000..bd70b6f
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
@@ -0,0 +1,142 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.criteria;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.search.SearchContext;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Joseph Marques
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class SavedSearchCriteria extends Criteria {
+ public static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private SearchContext filterContext;
+ private String filterName;
+ private String filterDescription;
+ private String filterPattern;
+ private Long filterLastComputeTimeMin;
+ private Long filterLastComputeTimeMax;
+ private Long filterResultCountMin;
+ private Long filterResultCountMax;
+ private Integer filterSubjectId;
+ private Boolean filterGlobal;
+
+ private boolean fetchSubject;
+
+ private PageOrdering sortContext;
+ private PageOrdering sortName;
+ private PageOrdering sortLastComputeTime;
+ private PageOrdering sortResultCount;
+ private PageOrdering sortGlobal;
+
+ public SavedSearchCriteria() {
+ super(SavedSearch.class);
+
+ filterOverrides.put("lastComputeTimeMin", "lastComputeTime >= ?");
+ filterOverrides.put("lastComputeTimeMax", "lastComputeTime <= ?");
+ filterOverrides.put("resultCountMin", "resultCount >= ?");
+ filterOverrides.put("resultCountMax", "resultCount <= ?");
+ }
+
+ public void addFilterId(Integer filterId) {
+ this.filterId = filterId;
+ }
+
+ public void addFilterSearchContext(SearchContext filterContext) {
+ this.filterContext = filterContext;
+ }
+
+ public void addFilterName(String filterName) {
+ this.filterName = filterName;
+ }
+
+ public void addFilterDescription(String filterDescription) {
+ this.filterDescription = filterDescription;
+ }
+
+ public void addFilterPattern(String filterPattern) {
+ this.filterPattern = filterPattern;
+ }
+
+ public void addFilterResultCountMin(Long filterResultCountMin) {
+ this.filterResultCountMin = filterResultCountMin;
+ }
+
+ public void addFilterResultCountMax(Long filterResultCountMax) {
+ this.filterResultCountMax = filterResultCountMax;
+ }
+
+ public void addFilterLastComputeTimeMin(Long filterLastComputeTimeMin) {
+ this.filterLastComputeTimeMin = filterLastComputeTimeMin;
+ }
+
+ public void addFilterLastComputeTimeMax(Long filterLastComputeTimeMax) {
+ this.filterLastComputeTimeMax = filterLastComputeTimeMax;
+ }
+
+ public void addFilterSubjectId(Integer filterSubjectId) {
+ this.filterSubjectId = filterSubjectId;
+ }
+
+ public void addFilterGlobal(Boolean filterGlobal) {
+ this.filterGlobal = filterGlobal;
+ }
+
+ public void setFetchSubject(boolean fetchSubject) {
+ this.fetchSubject = fetchSubject;
+ }
+
+ public void addSortContext(PageOrdering sortContext) {
+ addSortField("context");
+ this.sortContext = sortContext;
+ }
+
+ public void addSortName(PageOrdering sortName) {
+ addSortField("name");
+ this.sortName = sortName;
+ }
+
+ public void addSortLastComputeTime(PageOrdering sortLastComputeTime) {
+ addSortField("lastComputeTime");
+ this.sortLastComputeTime = sortLastComputeTime;
+ }
+
+ public void addSortResultCount(PageOrdering sortResultCount) {
+ addSortField("resultCount");
+ this.sortResultCount = sortResultCount;
+ }
+
+ public void addSortGlobal(PageOrdering sortGlobal) {
+ addSortField("global");
+ this.sortGlobal = sortGlobal;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
index f672ac7..1485197 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
@@ -24,10 +24,14 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
+import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
+import org.rhq.enterprise.server.util.CriteriaQueryRunner;
/**
* This bean provides functionality to CRUD saved search patterns.
@@ -79,6 +83,18 @@ public class SavedSearchManagerBean implements SavedSearchManagerLocal /* local
return savedSearch;
}
+ public PageList<SavedSearch> findSavedSearchesByCriteria(Subject subject, SavedSearchCriteria criteria) {
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
+
+ if (!authorizationManager.isInventoryManager(subject)) {
+ generator.setAuthorizationCustomConditionFragment("(subject.id=" + subject.getId() + " OR global=true)");
+ }
+
+ CriteriaQueryRunner<SavedSearch> queryRunner = new CriteriaQueryRunner<SavedSearch>(criteria, generator,
+ entityManager);
+ return queryRunner.execute();
+ }
+
private void validateManipulatePermission(Subject subject, SavedSearch savedSearch) {
if (savedSearch.isGlobal()) {
if (!authorizationManager.isInventoryManager(subject)) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
index a1615ec..ffd4255 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -25,7 +25,9 @@ import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.system.ServerVersion;
@@ -99,4 +101,18 @@ public interface SavedSearchManagerRemote {
public SavedSearch getSavedSearchById( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "savedSearchId") int savedSearchId);
+
+ /**
+ * Returns the {@link PageList} of {@link SavedSearch} entities that match the criteria filters that are visible
+ * to the user
+ *
+ * @param subject the logged in user requesting the {@link PageList} of {@link SavedSearch} to be returned
+ * @param criteria the {@link SavedSearchCriteria} object that will filter the returned results
+ *
+ * @return the {@link PageList} of {@link SavedSearch} entities that match the criteria filters, an empty list
+ * will be returned if no results were found or none matches the given filters
+ */
+ public PageList<SavedSearch> findSavedSearchesByCriteria( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "criteria") SavedSearchCriteria criteria);
}
commit 8bee964f9c9fb494fc08a3baaa307361d826b445
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 02:48:32 2010 -0500
enhance the CriteriaQueryGenerator to allow more flexible authorization:
support users to set a completely arbitrary authorization fragment, which
will be inserted into the list of conditions for the generated query
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 9c62eed..bb0c072 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -58,13 +58,14 @@ public final class CriteriaQueryGenerator {
public enum AuthorizationTokenType {
RESOURCE, // specifies the resource alias to join on for standard res-group-role-subject authorization checking
- GROUP; // specifies the group alias to join on for standard group-role-subject authorization checking
+ GROUP; // specifies the group alias to join on for standard group-role-subject authorization checking
}
private Criteria criteria;
private String authorizationJoinFragment;
private String authorizationPermsFragment;
+ private String authorizationCustomConditionFragment;
private int authorizationSubjectId;
private String alias;
@@ -89,6 +90,10 @@ public final class CriteriaQueryGenerator {
this.alias = aliasBuilder.toString();
}
+ public void setAuthorizationCustomConditionFragment(String fragment) {
+ this.authorizationCustomConditionFragment = fragment;
+ }
+
public void setAuthorizationResourceFragment(AuthorizationTokenType type, int subjectId) {
String defaultFragment = null;
if (type == AuthorizationTokenType.RESOURCE) {
@@ -260,6 +265,16 @@ public final class CriteriaQueryGenerator {
}
}
+ if (authorizationCustomConditionFragment != null) {
+ if (firstCrit) {
+ firstCrit = false;
+ } else {
+ // always want AND for security, regardless of conjunctiveFragment
+ results.append(NL).append(" AND ");
+ }
+ results.append(this.authorizationCustomConditionFragment);
+ }
+
if (countQuery == false) {
boolean overridden = true;
PageControl pc = criteria.getPageControlOverrides();
commit d065f478b829887eda067308a10f98edef113b66
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Feb 23 00:50:35 2010 -0500
initial SLSB support basic CRUD, with security restrictions, for saved search patterns
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
new file mode 100644
index 0000000..f672ac7
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerBean.java
@@ -0,0 +1,104 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
+import org.rhq.enterprise.server.authz.PermissionException;
+
+/**
+ * This bean provides functionality to CRUD saved search patterns.
+ *
+ * @author Joseoh Marques
+ */
+@Stateless
+public class SavedSearchManagerBean implements SavedSearchManagerLocal /* local already implements remote interface */{
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ @EJB
+ private AuthorizationManagerLocal authorizationManager;
+
+ /**
+ * @see SavedSearchManagerRemote#createSavedSearch(Subject, SavedSearch)
+ */
+ public void createSavedSearch(Subject subject, SavedSearch savedSearch) {
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.persist(savedSearch);
+ return;
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#updateSavedSearch(Subject, SavedSearch)
+ */
+ public void updateSavedSearch(Subject subject, SavedSearch savedSearch) {
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.merge(savedSearch);
+ return;
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#deleteSavedSearch(Subject, int)
+ */
+ public void deleteSavedSearch(Subject subject, int savedSearchId) {
+ SavedSearch savedSearch = entityManager.find(SavedSearch.class, savedSearchId);
+ validateManipulatePermission(subject, savedSearch);
+ entityManager.remove(savedSearch);
+ }
+
+ /**
+ * @see SavedSearchManagerRemote#getSavedSearchById(Subject, int)
+ */
+ public SavedSearch getSavedSearchById(Subject subject, int savedSearchId) {
+ SavedSearch savedSearch = entityManager.find(SavedSearch.class, savedSearchId);
+ validateReadPermission(subject, savedSearch);
+ return savedSearch;
+ }
+
+ private void validateManipulatePermission(Subject subject, SavedSearch savedSearch) {
+ if (savedSearch.isGlobal()) {
+ if (!authorizationManager.isInventoryManager(subject)) {
+ throw new PermissionException("Only inventory managers can manipulate global saved searches");
+ }
+ // note: inventory managers can modify any saved search pattern, not just their own
+ } else {
+ if (subject.equals(savedSearch.getSubject())) {
+ throw new PermissionException("Users without inventory manager permission "
+ + "can only manipulate their own saved searches");
+ }
+ }
+ }
+
+ private void validateReadPermission(Subject subject, SavedSearch savedSearch) {
+ if (!savedSearch.isGlobal()) {
+ if (subject.equals(savedSearch.getSubject())) {
+ throw new PermissionException("Users without inventory manager permission "
+ + "can only view their own or global saved saved searches");
+ }
+ }
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java
new file mode 100644
index 0000000..7ced552
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerLocal.java
@@ -0,0 +1,31 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.Local;
+
+/**
+ * The local interface to the SavedSearchManager.
+ *
+ * @author Joseph Marques
+ */
+@Local
+public interface SavedSearchManagerLocal extends SavedSearchManagerRemote {
+ // there are currently no methods in the local interface that do not exist in the remote interface
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
new file mode 100644
index 0000000..a1615ec
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/SavedSearchManagerRemote.java
@@ -0,0 +1,102 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.search;
+
+import javax.ejb.Remote;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.enterprise.server.authz.PermissionException;
+import org.rhq.enterprise.server.system.ServerVersion;
+
+/**
+ * The remote interface to the SavedSearchManager.
+ *
+ * @author Joseph Marques
+ */
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(targetNamespace = ServerVersion.namespace)
+@Remote
+public interface SavedSearchManagerRemote {
+
+ /**
+ * Persisted a new {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} deletion
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be deleted
+ *
+ * @throws PermissionException if the user is not authorized to create the {@link SavedSearch}. Only inventory
+ * managers can create global saved searches. Regular users can only create {@link SavedSearch}es against
+ * their own accounts.
+ */
+ @WebMethod
+ public void createSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearch") SavedSearch savedSearch);
+
+ /**
+ * Saves all changes to the passed {@link SavedSearch} database, correlating it to the record already
+ * persisted with the same primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} persisted modification
+ * @param savedSearchId the {@link SavedSearch} which will have its modifications persisted
+ *.
+ * @throws PermissionException if the user is not authorized to modify the {@link SavedSearch}. Only inventory
+ * managers can update global saved searches. Regular users can only update {@link SavedSearch}es from
+ * their own accounts.
+ */
+ @WebMethod
+ public void updateSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearch") SavedSearch savedSearch);
+
+ /**
+ * Deletes the {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} deletion
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be deleted
+ *
+ * @throws PermissionException if the user is not authorized to delete the {@link SavedSearch}. Only inventory
+ * managers can delete global saved searches. Regular users can only delete {@link SavedSearch}es from
+ * their own accounts.
+ */
+ @WebMethod
+ public void deleteSavedSearch( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearchId") int savedSearchId);
+
+ /**
+ * Returns the {@link SavedSearch} with the given primary key
+ *
+ * @param subject the logged in user requesting the {@link SavedSearch} to be loaded
+ * @param savedSearchId the primary key of the {@link SavedSearch} to be loaded
+ *
+ * @return the {@link SavedSearch} or <code>null</code> if it wasn't found
+ * @throws PermissionException if the user is not authorized to view the {@link SavedSearch}. Regular users can
+ * only view {@link SavedSearch}es from their own accounts.
+ */
+ @WebMethod
+ public SavedSearch getSavedSearchById( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "savedSearchId") int savedSearchId);
+}
commit c95388946134a47b002f5821c3a168db6f549355
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:31 2010 -0500
saved search hibernate entities
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
new file mode 100644
index 0000000..9142772
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
@@ -0,0 +1,253 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.search;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.auth.Subject;
+
+/**
+ * The data model for saved searches. Each users has his or her own set of
+ * saved searches, but inventory managers are allowed to "promote" their
+ * saved searches to GLOBAL status, which makes them available to all users
+ * under that installation of RHQ.
+ *
+ * There are two levels of pre-computed data within this structured. After
+ * the {@link SavedSearch} is created, the pattern will be translated into its
+ * JPQL equivalent and stored. If the {@link SavedSearch} is ever modified
+ * and saved, the JPQL will be re-computed.
+ *
+ * Periodically, the count-query version of the {@link SavedSearch} will be
+ * executed (using the stored JPQL), and the number of matching records will
+ * be stored. If this {@link SavedSearch} ever needs to be displayed on the
+ * user interface, it will by default retrieve this cached result count.
+ *
+ * @author Joseph Marques
+ */
+@Entity
+@SequenceGenerator(name = "id", sequenceName = "RHQ_SAVED_SEARCH_ID_SEQ")
+@Table(name = "RHQ_SAVED_SEARCH")
+public class SavedSearch {
+
+ @Id
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
+ private Integer id;
+
+ @Column(name = "CONTEXT", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private SearchContext context;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+ @Column(name = "PATTERN", nullable = false)
+ private String pattern;
+
+ @Column(name = "JPQL_TRANSLATION")
+ private String jpqlTranslation;
+
+ @Column(name = "LAST_COMPUTE_TIME", nullable = false)
+ private long lastComputeTime;
+
+ @Column(name = "RESULT_COUNT")
+ private Long resultCount;
+
+ @Column(name = "SUBJECT_ID", nullable = false)
+ private Subject subject;
+
+ @Column(name = "RESOURCE_ID", insertable = false, updatable = false)
+ private int subjectId;
+
+ @Column(name = "GLOBAL", nullable = false)
+ private boolean global;
+
+ protected SavedSearch() {
+ // no-arg ctor for Hibernate
+ }
+
+ public SavedSearch(SearchContext context, String name, String pattern, Subject subject) {
+ // call setters to go through parameter validation
+ setContext(context);
+ setPattern(pattern);
+ setSubject(subject);
+ setName(name); // name can be null, to allow for saving searches quickly
+
+ this.description = null;
+ this.jpqlTranslation = null; // null value for pre-computed JPQL implies computation is needed
+ this.lastComputeTime = 0; // further imply that computation needs to occur
+ this.resultCount = null; // NULL resultCount implies either computation failed or hasn't begun yet
+ this.global = false; // user must promote saved search to be a global after creation
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public SearchContext getContext() {
+ return context;
+ }
+
+ private void setContext(SearchContext context) {
+ if (context == null) {
+ throw new IllegalArgumentException("All saved searches must be bound to a SearchContext");
+ }
+ this.context = context;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ private void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public void setPattern(String pattern) {
+ if (pattern == null || pattern.trim().equals("")) {
+ throw new IllegalArgumentException("All saved searches must have a non-empty pattern");
+ }
+ this.pattern = pattern;
+ }
+
+ public String getJpqlTranslation() {
+ return jpqlTranslation;
+ }
+
+ public void setJpqlTransation(String jpqlTranslation) {
+ this.jpqlTranslation = jpqlTranslation;
+ }
+
+ public long getLastComputeTime() {
+ return lastComputeTime;
+ }
+
+ public void setLastComputeTime(long lastComputeTime) {
+ this.lastComputeTime = lastComputeTime;
+ }
+
+ public Long getResultCount() {
+ return resultCount;
+ }
+
+ public void setResultCount(Long resultCount) {
+ this.resultCount = resultCount;
+ }
+
+ public Subject getSubject() {
+ return subject;
+ }
+
+ private void setSubject(Subject subject) {
+ if (subject == null) {
+ throw new IllegalArgumentException("All saved searches must be owned by a specific user");
+ }
+ this.subject = subject;
+ this.subjectId = subject.getId();
+ }
+
+ public int getSubjectId() {
+ return subjectId;
+ }
+
+ public boolean isGlobal() {
+ return global;
+ }
+
+ public void setGlobal(boolean global) {
+ this.global = global;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + subjectId;
+ result = (prime * result) + context.hashCode();
+ result = (prime * result) + ((name == null) ? 0 : name.hashCode());
+ result = (prime * result) + pattern.hashCode();
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof SavedSearch))) {
+ return false;
+ }
+
+ final SavedSearch other = (SavedSearch) obj;
+
+ if (subjectId != other.subjectId) {
+ return false;
+ }
+
+ if (context != other.context) {
+ return false;
+ }
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ if (!pattern.equals(other.pattern)) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java
new file mode 100644
index 0000000..bb045d5
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchContext.java
@@ -0,0 +1,38 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.search;
+
+/**
+ * The search mechanism is generic and, thus, suited to finding data in any
+ * RHQ subsystem, including its own. Each individual page in the UI can have
+ * different advanced syntax. This enum will serve as a unique identifier
+ * for which context is currently active. You can think of it as a piece of
+ * meta-data that annotates each saved search, representing which context it
+ * belongs to. This will also affect which grammar is used to auto-complete
+ * search expressions.
+ *
+ * @author Joseph Marques
+ */
+public enum SearchContext {
+ Resource, Group;
+}
commit c9d080cc510d6e4bf5c26c34f7b9050544736da3
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:19 2010 -0500
saved search dbupgrade scripts
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 1d4d3dd..2fb6a90 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.79</db.schema.version>
+ <db.schema.version>2.82</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 9af6aa5..834e9ce 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3202,6 +3202,31 @@
</statement>
</schema-directSQL>
</schemaSpec>
+
+ <schemaSpec version="2.82">
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_SAVED_SEARCH">
+ CREATE TABLE RHQ_SAVED_SEARCH ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" columnType="VARCHAR2" precision="25" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="CONTEXT" nullable="FALSE" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="PATTERN" columnType="VARCHAR2" precision="1000" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="PATTERN" nullable="FALSE" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="JPQL_TRANSLATION" columnType="VARCHAR2" precision="4000" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" columnType="LONG" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="LAST_COMPUTE_TIME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="RESULT_COUNT" columnType="LONG" />
+
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="SUBJECT_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" columnType="BOOLEAN" />
+ <schema-alterColumn table="RHQ_SAVED_SEARCH" column="GLOBAL" nullable="FALSE" />
+ </schemaSpec>
</dbupgrade>
</target>
</project>
commit afc78a9b2bfcb14b5b079ffb29aa82c4e6b0e81f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Feb 22 21:06:07 2010 -0500
saved searches dbsetup scripts
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
index 047d615..f5e4eae 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup-build.xml
@@ -39,7 +39,7 @@ To run the default target, you must set one of the following properties to true:
<property name="dbsetup.scripts.dir" value="${basedir}/src/main/scripts/dbsetup" />
<property name="dbsetup.output.dir" value="${basedir}/target/dbsetup" /> <!-- away from classes so it doesn't go into the jar -->
<!-- define the setup creation processing order. note, removals are done in the reverse order -->
- <property name="dbsetup.subsystems" value="config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
+ <property name="dbsetup.subsystems" value="search,config,cluster,inventory,auth,authz,operation,event,alert,sysconfig,scheduler,amps,measurement,content,resource-request,jms,obsolete"/>
<property name="dbsetup.combined.schema" value="${dbsetup.output.dir}/all-schema.xml" />
<property name="dbsetup.combined.data" value="${dbsetup.output.dir}/all-data.xml" />
<property name="dbsetup.tstamp.file" value="${dbsetup.output.dir}/dbsetup-combine.tstamp" />
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
new file mode 100644
index 0000000..7c0de23
--- /dev/null
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<dbsetup name="amps-schema.xml"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-dbsetup-schema">
+
+ <table name="RHQ_SAVED_SEARCH">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="CONTEXT" type="VARCHAR2" size="25" required="true"/>
+
+ <column name="NAME" type="VARCHAR2" size="200" required="true"/>
+ <column name="DESCRIPTION" type="VARCHAR2" size="500" required="false"/>
+ <column name="PATTERN" type="VARCHAR2" size="1000" required="true"/>
+
+ <column name="JPQL_TRANSLATION" type="VARCHAR2" size="4000" required="false"/>
+ <column name="LAST_COMPUTE_TIME" type="LONG" required="true"/>
+ <column name="RESULT_COUNT" type="LONG" required="false"/>
+
+ <column name="SUBJECT_ID" type="INTEGER" references="RHQ_SUBJECT" required="true"/>
+ <column name="ENABLED" type="BOOLEAN" required="true"/>
+ </table>
+
+</dbsetup>
\ No newline at end of file
commit 6d87241b69c095bd2928f4e3b03bc9dcfbeeefd1
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Sat Feb 20 10:49:01 2010 +0100
Fix potential NPE
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
index 5ed6d4f..b90def3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
@@ -113,8 +113,8 @@ public class AlertNotificationLog implements Serializable {
@PrePersist
@PreUpdate
public void trimMessage() {
- if (message.length()>255)
- message = message.substring(0,254);
+ if (message!=null && message.length()>255)
+ message = message.substring(0,255);
}
protected AlertNotificationLog() {
commit 2d38d85bb4500c1a873aba7b193fb9984d00539d
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Sat Feb 20 09:47:10 2010 +0100
Truncate the message at 140 chars, as identi.ca bails out on longer messages; seems to improve stability with Twitter too.
Introduce abbreviated versions of the messages as space on Microblog etc is scarce. BZ 555091
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
index ba75940..5ed6d4f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationLog.java
@@ -38,6 +38,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -108,6 +110,13 @@ public class AlertNotificationLog implements Serializable {
@Transient
transient List<String> transientEmails = new ArrayList<String>();
+ @PrePersist
+ @PreUpdate
+ public void trimMessage() {
+ if (message.length()>255)
+ message = message.substring(0,254);
+ }
+
protected AlertNotificationLog() {
} // JPA
@@ -130,7 +139,6 @@ public class AlertNotificationLog implements Serializable {
public AlertNotificationLog(Alert alert, String senderName, ResultState state, String message) {
this.alert = alert;
- this.sender = sender;
this.resultState = state;
this.message = message;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
index 454b9a9..ff4025f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
@@ -780,7 +780,7 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
Map<String, String> alertMessage = emailManager.getAlertEmailMessage(
prettyPrintResourceHierarchy(alertDefinition.getResource()), alertDefinition.getResource().getName(),
alertDefinition.getName(), alertDefinition.getPriority().toString(), new Date(alert.getCtime()).toString(),
- prettyPrintAlertConditions(alert.getConditionLogs()), prettyPrintAlertURL(alert));
+ prettyPrintAlertConditions(alert.getConditionLogs(), false), prettyPrintAlertURL(alert));
String messageSubject = alertMessage.keySet().iterator().next();
String messageBody = alertMessage.values().iterator().next();
@@ -834,13 +834,14 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
/**
* Create a human readable description of the conditions that led to this alert.
* @param alert Alert to create human readable condition description
+ * @param shortVersion if true the messages printed are abbreviated to save space
* @return human readable condition log
*/
- public String prettyPrintAlertConditions(Alert alert) {
- return prettyPrintAlertConditions(alert.getConditionLogs());
+ public String prettyPrintAlertConditions(Alert alert, boolean shortVersion) {
+ return prettyPrintAlertConditions(alert.getConditionLogs(), shortVersion);
}
- private String prettyPrintAlertConditions(Set<AlertConditionLog> conditionLogs) {
+ private String prettyPrintAlertConditions(Set<AlertConditionLog> conditionLogs, boolean shortVersion) {
StringBuilder builder = new StringBuilder();
int conditionCounter = 1;
@@ -858,16 +859,27 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
builder.append(NEW_LINE);
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT,
- conditionCounter, prettyPrintAlertCondition(aLog.getCondition()), new SimpleDateFormat(
- "yyyy/MM/dd HH:mm:ss z").format(new Date(aLog.getCtime())), formattedValue));
+ String format;
+ if (shortVersion)
+ format = AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT_SHORT;
+ else
+ format = AlertI18NResourceKeys.ALERT_EMAIL_CONDITION_LOG_FORMAT;
+ SimpleDateFormat dateFormat;
+ if (shortVersion)
+ dateFormat= new SimpleDateFormat(
+ "yy/MM/dd HH:mm:ss z");
+ else
+ dateFormat= new SimpleDateFormat(
+ "yyyy/MM/dd HH:mm:ss z");
+ builder.append(AlertI18NFactory.getMessage(format,
+ conditionCounter, prettyPrintAlertCondition(aLog.getCondition(), shortVersion), dateFormat.format(new Date(aLog.getCtime())), formattedValue));
conditionCounter++;
}
return builder.toString();
}
- private String prettyPrintAlertCondition(AlertCondition condition) {
+ private String prettyPrintAlertCondition(AlertCondition condition, boolean shortVersion) {
StringBuilder builder = new StringBuilder();
AlertConditionCategory category = condition.getCategory();
@@ -915,19 +927,38 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
} else if ((category == AlertConditionCategory.RESOURCE_CONFIG) || (category == AlertConditionCategory.CHANGE)
|| (category == AlertConditionCategory.TRAIT)) {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED));
+
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CURRENT_LIST_VALUE_CHANGED));
+
} else if (category == AlertConditionCategory.EVENT) {
if ((condition.getOption() != null) && (condition.getOption().length() > 0)) {
+ String propsCbEventSeverityRegexMatch;
+ if (shortVersion)
+ propsCbEventSeverityRegexMatch = AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH_SHORT;
+ else
+ propsCbEventSeverityRegexMatch = AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH;
+
builder.append(AlertI18NFactory.getMessage(
- AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH, condition.getName(),
+ propsCbEventSeverityRegexMatch, condition.getName(),
condition.getOption()));
} else {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY,
- condition.getName()));
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT,
+ condition.getName()));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY,
+ condition.getName()));
}
} else if (category == AlertConditionCategory.AVAILABILITY) {
- builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
- condition.getOption()));
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT,
+ condition.getOption()));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
+ condition.getOption()));
} else {
// do nothing
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
index 996f245..e482ffa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java
@@ -96,9 +96,10 @@ public interface AlertManagerLocal {
/**
* Create a human readable description of the conditions that led to this alert.
* @param alert Alert to create human readable condition description
+ * @param shortVersion if true the messages printed are abbreviated to save space
* @return human readable condition log
*/
- String prettyPrintAlertConditions(Alert alert);
+ String prettyPrintAlertConditions(Alert alert, boolean shortVersion);
/**
* Tells us if the definition of the passed alert will be disabled after this alert was fired
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
index 8734771..1de3d85 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
@@ -32,20 +32,41 @@ public interface AlertI18NResourceKeys {
@I18NMessage(locale = "de", value = "Verfgbarkeit wird {0}") })
String ALERT_CONFIG_PROPS_CB_AVAILABILITY = "alert.config.props.CB.Availability";
+ @I18NMessages( { @I18NMessage("Avail goes {0}"),
+ @I18NMessage(locale = "de", value = "Verf. wird {0}") })
+ String ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT = "alert.config.props.CB.Availability.short";
+
@I18NMessages( { @I18NMessage("Event Severity: {0}"),
@I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0}") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY = "alert.config.props.CB.EventSeverity";
+ @I18NMessages( { @I18NMessage("Sev: {0}"),
+ @I18NMessage(locale = "de", value = "Schwere: {0}") })
+ String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT = "alert.config.props.CB.EventSeverity.short";
+
@I18NMessages( { @I18NMessage("Event Severity: {0} and matching expression \"{1}\""),
@I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0} und zugehriger Ausdruck \"{1}\"") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH = "alert.config.props.CB.EventSeverity.RegexMatch";
+ @I18NMessages( { @I18NMessage("Sev: {0} & exp \"{1}\""),
+ @I18NMessage(locale = "de", value = "Schwere: {0} & Ausdruck \"{1}\"") })
+ String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH_SHORT = "alert.config.props.CB.EventSeverity.RegexMatch.short";
+
@I18NMessages( { @I18NMessage("value changed"), @I18NMessage(locale = "de", value = "Der Wert hat sich gendert") })
String ALERT_CURRENT_LIST_VALUE_CHANGED = "alert.current.list.ValueChanged";
+ @I18NMessages( { @I18NMessage("val chg"), @I18NMessage(locale = "de", value = "Wertnd.") })
+ String ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT = "alert.current.list.ValueChanged.short";
+
@I18NMessages( {
@I18NMessage("\\ - Condition {0}: {1}\\n\\\n" + "\\ - Date/Time: {2}\\n\\\n" + "\\ - Details: {3}\\n\\\n"),
@I18NMessage(locale = "de", value = " - Bedingung {0}: {1}\\n\\\n - Datum/Uhrzeit: {2}\\n\\\n"
+ "\\ - Details: {3}\\n\\\n") })
String ALERT_EMAIL_CONDITION_LOG_FORMAT = "alert.email.condition.log.format";
+
+ @I18NMessages( {
+ @I18NMessage("\\ - Cond {0}: {1}\\n\\\n" + "\\ - Time: {2}\\n\\\n" + "\\ - Det: {3}\\n\\\n"),
+ @I18NMessage(locale = "de", value = " - Bed {0}: {1}\\n\\\n - Zeit: {2}\\n\\\n"
+ + "\\ - Det: {3}\\n\\\n") })
+ String ALERT_EMAIL_CONDITION_LOG_FORMAT_SHORT = "alert.email.condition.log.format.short";
}
\ No newline at end of file
diff --git a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
index 93eecc6..95abdb9 100644
--- a/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
+++ b/modules/enterprise/server/plugins/alert-irc/src/main/java/org/rhq/enterprise/server/plugins/alertIrc/IrcSender.java
@@ -65,7 +65,7 @@ public class IrcSender extends AlertSender<IrcAlertComponent> {
b.append("): ");
b.append(alertManager.prettyPrintAlertURL(alert));
b.append("\n");
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, false));
return b.toString();
}
diff --git a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
index 257b315..b13763e 100644
--- a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
+++ b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
@@ -57,14 +57,19 @@ public class MicroblogSender extends AlertSender {
b.append("' (");
b.append(alert.getAlertDefinition().getResource().getId());
b.append("): ");
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, true));
b.append("-by @JBossJopr"); // TODO not for production :-)
// TODO use some alert url shortening service
SenderResult result ;
String txt = "user@baseUrl [" + user + "@" + baseUrl + "]:";
try {
- Status status = twitter.updateStatus(b.toString());
+ String msg = b.toString();
+ if (msg.length()>140)
+ msg = msg.substring(0,140);
+
+ Status status = twitter.updateStatus(msg);
+
result = new SenderResult(ResultState.SUCCESS,"Send notification to " + txt + ", msg-id: " + status.getId());
} catch (TwitterException e) {
diff --git a/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java b/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
index 649d6ed..b14c85d 100644
--- a/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
+++ b/modules/enterprise/server/plugins/alert-mobicents/src/main/java/org/rhq/enterprise/server/plugins/alertMobicents/MobicentsSender.java
@@ -74,7 +74,7 @@ public class MobicentsSender extends AlertSender {
// Switch locale to english, as the voice synthesizer expects this for now
Locale currentLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
- b.append(alertManager.prettyPrintAlertConditions(alert));
+ b.append(alertManager.prettyPrintAlertConditions(alert, false));
Locale.setDefault(currentLocale);
boolean willBeDisabled = alertManager.willDefinitionBeDisabled(alert);
diff --git a/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java b/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
index 985d890..bac51fb 100644
--- a/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
+++ b/modules/enterprise/server/plugins/alert-scriptlang/src/main/java/org.rhq.enterprise.server.plugins.alertScriptlang/ScriptLangSender.java
@@ -93,7 +93,7 @@ public class ScriptLangSender extends AlertSender<ScriptLangComponent> {
Object[] args = new Object[3];
args[0] = alert;
args[1] = alertManager.prettyPrintAlertURL(alert);
- args[2] = alertManager.prettyPrintAlertConditions(alert);
+ args[2] = alertManager.prettyPrintAlertConditions(alert, false);
result = ((Invocable) engine).invokeFunction("sendAlert", args);
if (result == null) {
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
index 3fd5d79..045c3bb 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSender.java
@@ -68,7 +68,7 @@ public class SnmpSender extends AlertSender {
String result;
List<Resource> lineage = resourceManager.getResourceLineage(alert.getAlertDefinition().getResource().getId());
String platformName = lineage.get(0).getName();
- String conditions = alertManager.prettyPrintAlertConditions(alert);
+ String conditions = alertManager.prettyPrintAlertConditions(alert, false);
String alertUrl = alertManager.prettyPrintAlertURL(alert);
SenderResult res ;
commit 798ac30ead634c43a72beed52446a38d9bfc1f09
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:51:53 2010 -0500
i think this should report an error always on lock acq failure. we'll leave the flag alone - don't set it to true - let the next call take care of whether or not the init callback should be invoked or not
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 8c37b50..cd3b479 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -588,11 +588,9 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
writeLock.unlock();
}
} else {
- if (m_needToCallInitializeCallback) {
- Throwable t = new Throwable("Initialize callback lock could not be acquired");
- LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
- return new GenericCommandResponse(command, false, null, t);
- }
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
}
}
return null;
commit 9746ea32492b638eacb741d608d9ce17349c925d
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:44:11 2010 -0500
should not worry about the lock failure if the init callback doesn't need to be invoked anyway
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 762b9b4..8c37b50 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -588,10 +588,11 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
writeLock.unlock();
}
} else {
- m_needToCallInitializeCallback = true; // can't invoke callback, we'll want to still call it later
- Throwable t = new Throwable("Initialize callback lock could not be acquired");
- LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
- return new GenericCommandResponse(command, false, null, t);
+ if (m_needToCallInitializeCallback) {
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
+ }
}
}
return null;
commit c2cca917c88986ca48c84bbbdaf3408753299bf1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 17:38:16 2010 -0500
BZ 537396 - to not block indefinitely if a lock cannot be acquired before attempting to invoke the initialize callback
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 3775212..762b9b4 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -21,6 +21,9 @@ package org.rhq.enterprise.communications.command.client;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import mazz.i18n.Logger;
@@ -95,10 +98,22 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
private InitializeCallback m_initializeCallback;
/**
- * When the first element is <code>true</code>, the initialize callback will need to be called prior
- * to sending any commands. This is an array because the array itself is used for its lock.
+ * When <code>true</code>, the initialize callback will need to be called prior
+ * to sending any commands. Used in conjunection with its associated RW lock.
*/
- private final boolean[] m_needToCallInitializeCallback;
+ private boolean m_needToCallInitializeCallback;
+
+ /**
+ * RW lock when needing to access its associated atomic boolean flag.
+ */
+ private final ReentrantReadWriteLock m_needToCallInitializeCallbackLock;
+
+ /**
+ * Number of minutes to wait while attempting to aquire a lock before attempting
+ * to invoke the initialize callback. If this amount of minutes expires before the lock
+ * is acquired, an error will occur and the initialize callback will have to be attempted later.
+ */
+ private final long m_initializeCallbackLockAcquisitionTimeoutMins;
/**
* Constructor for {@link JBossRemotingRemoteCommunicator} that initializes the client with no invoker locator
@@ -200,7 +215,17 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
m_clientConfiguration.putAll(client_config);
}
- m_needToCallInitializeCallback = new boolean[] { false };
+ m_needToCallInitializeCallback = false;
+ m_needToCallInitializeCallbackLock = new ReentrantReadWriteLock();
+
+ long mins;
+ try {
+ String minsStr = System.getProperty("rhq.communications.initial-callback-lock-wait-mins", "60");
+ mins = Long.parseLong(minsStr);
+ } catch (Throwable t) {
+ mins = 60L;
+ }
+ m_initializeCallbackLockAcquisitionTimeoutMins = mins;
return;
}
@@ -319,7 +344,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
if (m_remotingClient != null) {
m_remotingClient.disconnect();
m_remotingClient = null;
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
LOG.info(CommI18NResourceKeys.COMMUNICATOR_CHANGING_ENDPOINT, m_invokerLocator, locator);
@@ -377,7 +402,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void setInitializeCallback(InitializeCallback callback) {
m_initializeCallback = callback;
- m_needToCallInitializeCallback[0] = (callback != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (callback != null); // specifically do not synchrononize by using lock, just set it
}
public String getRemoteEndpoint() {
@@ -403,7 +428,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void connect() throws Exception {
if ((m_remotingClient != null) && !m_remotingClient.isConnected()) {
m_remotingClient.connect();
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
return;
@@ -412,7 +437,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void disconnect() {
if (m_remotingClient != null) {
m_remotingClient.disconnect();
- m_needToCallInitializeCallback[0] = (getInitializeCallback() != null); // specifically do not synchronize, just set it
+ m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
}
return;
@@ -535,18 +560,38 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
private CommandResponse invokeInitializeCallbackIfNeeded(Command command) {
InitializeCallback callback = getInitializeCallback();
if (callback != null) {
- // block here - in effect, this will stop all commands from going out until the callback is done
- synchronized (m_needToCallInitializeCallback) {
- if (m_needToCallInitializeCallback[0]) {
- try {
- m_needToCallInitializeCallback[0] = !callback.sendingInitialCommand(this, command);
- LOG.debug(CommI18NResourceKeys.INITIALIZE_CALLBACK_DONE, m_needToCallInitializeCallback[0]);
- } catch (Throwable t) {
- m_needToCallInitializeCallback[0] = true; // callback failed, we'll want to call it again
- LOG.error(t, CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, ThrowableUtil.getAllMessages(t));
- return new GenericCommandResponse(command, false, null, t);
+ // block here - in effect, this will stop all commands from going out until the callback is done
+ // to avoid infinite blocking, we'll only wait for a set time (though long).
+
+ WriteLock writeLock = m_needToCallInitializeCallbackLock.writeLock();
+ boolean locked;
+ try {
+ locked = writeLock.tryLock(m_initializeCallbackLockAcquisitionTimeoutMins, TimeUnit.MINUTES);
+ } catch (InterruptedException ie) {
+ locked = false;
+ }
+
+ if (locked) {
+ try {
+ if (m_needToCallInitializeCallback) {
+ try {
+ m_needToCallInitializeCallback = (!callback.sendingInitialCommand(this, command));
+ LOG.debug(CommI18NResourceKeys.INITIALIZE_CALLBACK_DONE, m_needToCallInitializeCallback);
+ } catch (Throwable t) {
+ m_needToCallInitializeCallback = true; // callback failed, we'll want to call it again
+ LOG.error(t, CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, ThrowableUtil
+ .getAllMessages(t));
+ return new GenericCommandResponse(command, false, null, t);
+ }
}
+ } finally {
+ writeLock.unlock();
}
+ } else {
+ m_needToCallInitializeCallback = true; // can't invoke callback, we'll want to still call it later
+ Throwable t = new Throwable("Initialize callback lock could not be acquired");
+ LOG.error(CommI18NResourceKeys.INITIALIZE_CALLBACK_FAILED, t.getMessage());
+ return new GenericCommandResponse(command, false, null, t);
}
}
return null;
commit 55ba6f8778820bdd417e99909220136a2e1e091f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 19 11:10:53 2010 -0500
BZ 566724 - if classloader fails to be created, master PC will skip the plugin
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
index f46eaf5..bd4feac 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
@@ -136,16 +136,23 @@ public class MasterServerPluginContainer {
String pluginName = descriptor.getName();
ServerPluginType pluginType = new ServerPluginType(descriptor);
PluginKey pluginKey = PluginKey.createServerPluginKey(pluginType.stringify(), pluginName);
- ClassLoader classLoader = this.classLoaderManager.obtainServerPluginClassLoader(pluginKey);
- log.debug("Pre-loading server plugin [" + pluginKey + "] from [" + pluginUrl
- + "] into its plugin container");
try {
- ServerPluginEnvironment env = new ServerPluginEnvironment(pluginUrl, classLoader, descriptor);
- boolean enabled = !allDisabledPlugins.contains(pluginKey);
- pc.loadPlugin(env, enabled);
- log.info("Preloaded server plugin [" + pluginKey.getPluginName() + "]");
+ ClassLoader classLoader = this.classLoaderManager.obtainServerPluginClassLoader(pluginKey);
+ log.debug("Pre-loading server plugin [" + pluginKey + "] from [" + pluginUrl
+ + "] into its plugin container");
+ try {
+ ServerPluginEnvironment env = new ServerPluginEnvironment(pluginUrl, classLoader,
+ descriptor);
+ boolean enabled = !allDisabledPlugins.contains(pluginKey);
+ pc.loadPlugin(env, enabled);
+ log.info("Preloaded server plugin [" + pluginName + "]");
+ } catch (Exception e) {
+ log.warn("Failed to preload server plugin [" + pluginName + "] from URL [" + pluginUrl
+ + "]", e);
+ }
} catch (Exception e) {
- log.warn("Failed to preload server plugin [" + pluginUrl + "]", e);
+ log.warn("Failed to preload server plugin [" + pluginName
+ + "]; cannot get its classloader from URL [ " + pluginUrl + "]", e);
}
} else {
log.warn("There is no server plugin container to support plugin: " + pluginUrl);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
index 9f27ce9..fa26970 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
@@ -64,7 +64,7 @@ public class ServerPluginClassLoader extends URLClassLoader {
try {
unpackedDirectory = unpackEmbeddedJars(pluginJarName, pluginUrl, classpathUrlList, tmpDirectory);
} catch (Exception e) {
- throw new Exception("Failed to unpack embedded JARs within: " + pluginUrl);
+ throw new Exception("Failed to unpack embedded JARs within: " + pluginUrl, e);
}
}
}
commit 2ffc564d7ff69a427755fa374419bc5980e47f94
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Fri Feb 19 13:37:36 2010 +0100
Fix link to definitions BZ 566004
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
index b6e386c..fd09f82 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertHistory.xhtml
@@ -148,8 +148,7 @@
</onc:sortableColumnHeader>
</f:facet>
- <h:outputLink value="/alerts/Config.do">
- <f:param name="mode" value="viewRoles"/>
+ <h:outputLink value="/rhq/resource/alert/viewAlert.xhtml">
<f:param name="id" value="#{Resource.id}"/>
<f:param name="ad" value="#{item.alert.alertDefinition.id}"/>
<h:outputText value="#{item.alert.alertDefinition.name}" />
14 years, 2 months
[rhq] Branch 'linux-config' - 13 commits - modules/plugins
by lkrejci
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 12 +
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 8 -
modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java | 5
modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml | 3
modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java | 2
modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java | 2
modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java | 2
modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java | 2
modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml | 2
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java | 5
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java | 2
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java | 76 +++++++++-
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java | 2
modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java | 3
modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml | 3
modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml | 12 -
modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java | 2
modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java | 10 -
modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java | 2
modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java | 2
20 files changed, 116 insertions(+), 41 deletions(-)
New commits:
commit 589df77934ed96b0361db10481a2dc61d4424c16
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 26 18:14:49 2010 +0100
Postgres plugin resources renamed.
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java
index 060ee03..5236fd3 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java
@@ -45,7 +45,7 @@ public class PostgresDatabaseDiscoveryComponent implements ResourceDiscoveryComp
while (resultSet.next()) {
String databaseName = resultSet.getString("datname");
DiscoveredResourceDetails database = new DiscoveredResourceDetails(context.getResourceType(),
- databaseName, databaseName + " Database", null, "The " + databaseName
+ databaseName, databaseName, null, "The " + databaseName
+ " Postgres Database Instance", null, null);
database.getPluginConfiguration().put(new PropertySimple("databaseName", databaseName));
databases.add(database);
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
index 5e0a83d..825a4a3 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
@@ -26,14 +26,19 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.*;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.plugins.postgres.util.PostgresqlConfFile;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -56,6 +61,8 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
private static final String PGDATA_ENV_VAR = "PGDATA";
private static final String DEFAULT_RESOURCE_DESCRIPTION = "Postgres relational database server";
+ private static final String POSTGRES_DEFAULT_DATABASE_NAME = "postgres";
+
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
Set<DiscoveredResourceDetails> servers = new LinkedHashSet<DiscoveredResourceDetails>();
@@ -140,9 +147,10 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
Configuration pluginConfiguration, @Nullable
ProcessInfo processInfo) {
String key = buildUrl(pluginConfiguration);
- String db = pluginConfiguration.getSimple(DB_CONFIGURATION_PROPERTY).getStringValue();
- String name = "Postgres [" + db + "]";
- String version = getVersion(pluginConfiguration);
+ Connection conn = getConnection(pluginConfiguration);
+ String name = getServerResourceName(pluginConfiguration, conn);
+ String version = getVersion(pluginConfiguration, conn);
+ JDBCUtil.safeClose(conn);
return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, version,
DEFAULT_RESOURCE_DESCRIPTION, pluginConfiguration, processInfo);
}
@@ -155,11 +163,12 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
return url;
}
- protected static String getVersion(Configuration config) {
+ protected static String getVersion(Configuration config, Connection conn) {
String version = null;
try {
- Connection conn = buildConnection(config);
- version = conn.getMetaData().getDatabaseProductVersion();
+ if (conn != null) {
+ version = conn.getMetaData().getDatabaseProductVersion();
+ }
} catch (SQLException e) {
// TODO GH: How to put this back to the server while inventorying this resource in an unconfigured state
log.info("Exception detecting postgres instance", e);
@@ -182,7 +191,12 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
String principal = configuration.getSimple(PRINCIPAL_CONFIGURATION_PROPERTY).getStringValue();
String credentials = configuration.getSimple(CREDENTIALS_CONFIGURATION_PROPERTY).getStringValue();
- return DriverManager.getConnection(url, principal, credentials);
+ try {
+ return DriverManager.getConnection(url, principal, credentials);
+ } catch (SQLException e) {
+ log.info("Failed to connect to the database", e);
+ return null;
+ }
}
@Nullable
@@ -239,4 +253,52 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
return configFilePath;
}
+
+ private static Connection getConnection(Configuration config) {
+ try {
+ return buildConnection(config);
+ } catch (SQLException e) {
+ log.info("Failed to connect to postgres database.", e);
+
+ return null;
+ }
+ }
+
+ public static List<String> getDatabases(Configuration pluginConfiguration) {
+ return getDatabaseNames(pluginConfiguration, getConnection(pluginConfiguration));
+ }
+
+ private static List<String> getDatabaseNames(Configuration config, Connection conn) {
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ List<String> ret = new ArrayList<String>();
+
+ statement = conn.createStatement();
+ resultSet = statement
+ .executeQuery("SELECT *, pg_database_size(datname) FROM pg_database where datistemplate = false");
+ while (resultSet.next()) {
+ String databaseName = resultSet.getString("datname");
+ ret.add(databaseName);
+ }
+
+ return ret;
+ } catch (SQLException e) {
+ log.info("Failed to obtain the list of databases in a postgres instance", e);
+ return Collections.emptyList();
+ } finally {
+ JDBCUtil.safeClose(statement, resultSet);
+ }
+ }
+
+ private static String getServerResourceName(Configuration config, Connection conn) {
+ List<String> schemas = getDatabaseNames(config, conn);
+ if (schemas.size() > 0 && schemas.size() < 3) {
+ String firstDatabase = schemas.get(0);
+ String secondDatabase = schemas.get(1);
+ return POSTGRES_DEFAULT_DATABASE_NAME.equals(firstDatabase) ? secondDatabase : firstDatabase;
+ } else {
+ return config.getSimpleValue(DB_CONFIGURATION_PROPERTY, POSTGRES_DEFAULT_DATABASE_NAME);
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java
index a48deb1..c0d0273 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java
@@ -61,7 +61,7 @@ public class PostgresUserDiscoveryComponent implements ResourceDiscoveryComponen
while (resultSet.next()) {
String userName = resultSet.getString("rolname");
DiscoveredResourceDetails service = new DiscoveredResourceDetails(context.getResourceType(), userName,
- userName + " User", null, "A Postgres user", null, null);
+ userName, null, "A Postgres user", null, null);
service.getPluginConfiguration().put(new PropertySimple("userName", userName));
discoveredUsers.add(service);
}
commit 6602a4542a782cec37f434b97cfe6089277e0eae
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Feb 25 09:39:07 2010 +0100
IIS plugin resources renamed.
diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
index 50b9448..f4cbceb 100644
--- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
+++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
@@ -78,7 +78,7 @@ public class IISServerDiscoveryComponent implements ResourceDiscoveryComponent {
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- imagePath, discoveryContext.getSystemInformation().getHostname() + " IIS Server", version, "IIS Server on "
+ imagePath, "IIS", version, "IIS Server on "
+ discoveryContext.getSystemInformation().getHostname(), pluginConfig, null);
return Collections.singleton(details);
diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
index 9ea5aa9..a6fc8a1 100644
--- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
+++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
@@ -86,7 +86,7 @@ public class IISVHostDiscoveryComponent implements ResourceDiscoveryComponent<II
config.put(new PropertySimple("logDirectory", "C:\\Windows\\System32\\LogFiles\\W3SVC" + info.getId()));
DiscoveredResourceDetails details = new DiscoveredResourceDetails(resourceDiscoveryContext
- .getResourceType(), siteName, siteName + " VHost", "1.0", siteName + " Virtual Host", config, null);
+ .getResourceType(), siteName, siteName, "1.0", siteName + " Virtual Host", config, null);
hostDetails.add(details);
}
commit bc19e61c3b7fc42f1aec1dc603ed6c637f3d7b79
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Feb 24 18:34:18 2010 +0100
Virt plugin resources renamed.
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java
index fe7b2ce..98f1979 100644
--- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java
+++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationBlockDeviceDiscoveryComponent.java
@@ -49,7 +49,7 @@ public class VirtualizationBlockDeviceDiscoveryComponent implements ResourceDisc
String device = intf.getSimple("targetDevice").getStringValue();
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- device, device + " virtual device", null, "Virtual block device", null, null);
+ device, device, null, "Virtual block device", null, null);
details.add(detail);
}
}
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java
index 7829c9f..7d769d6 100644
--- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java
+++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationInterfaceDiscoveryComponent.java
@@ -49,7 +49,7 @@ public class VirtualizationInterfaceDiscoveryComponent implements ResourceDiscov
String path = intf.getSimple("target").getStringValue();
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- path, path + " virtual interface", null, "Virtual network interface", null, null);
+ path, path, null, "Virtual network interface", null, null);
details.add(detail);
}
}
commit 51cd46a911b27118e02ccc589dda2952c17af66a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Feb 24 11:19:36 2010 +0100
Snmptrapd plugin resources renamed.
diff --git a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
index ec741a4..aab6d6e 100644
--- a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
+++ b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
@@ -37,6 +37,8 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
*/
public class SnmpTrapdDiscovery implements ResourceDiscoveryComponent<SnmpTrapdComponent>, ManualAddFacet<SnmpTrapdComponent> {
+ private static final String PORT_PROPERTY = "port";
+
/*
* Autodiscovery is not supported.
*/
@@ -52,11 +54,11 @@ public class SnmpTrapdDiscovery implements ResourceDiscoveryComponent<SnmpTrapdC
*/
public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
ResourceDiscoveryContext<SnmpTrapdComponent> ctx) throws InvalidPluginConfigurationException {
-
- String pcName = ctx.getPluginContainerName();
- String key = "Trapd (" + pcName + ")";
+
+ String port = pluginConfiguration.getSimpleValue(PORT_PROPERTY, null);
+ String key = "Trapd " + port;
String name = key;
- String description = "SNMP Trap receiver on " + pcName;
+ String description = "SNMP Trap receiver on port " + port;
ResourceType resourceType = ctx.getResourceType();
DiscoveredResourceDetails details = new DiscoveredResourceDetails(resourceType, key, name, null, description,
pluginConfiguration, null);
commit 7e2477a7d75fe8ff2de499f3b1143022b3d8e385
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 17:50:48 2010 +0100
Script2 plugin resources renamed.
diff --git a/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java b/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java
index 25411ee..4847261 100644
--- a/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java
+++ b/modules/plugins/script2/src/main/java/org/rhq/modules/plugins/script2/ScriptDiscovery.java
@@ -47,7 +47,7 @@ public class ScriptDiscovery implements ResourceDiscoveryComponent,ManualAddFace
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
context.getResourceType(), // ResourceType
key, // resource key
- "Script " + lang + "::" + script, // resource name TODO get via configuration
+ script, // resource name TODO get via configuration
null, // version
lang + "Script " + script, // Description
pluginConfiguration, // Configuration
commit e167b466c5a2b32c64bc2b8afe83e1213eb12460
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 17:48:06 2010 +0100
RHQ Server plugin resources renamed.
diff --git a/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
index 3b0b5da..1cc0925 100644
--- a/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
@@ -19,7 +19,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq:service=AlertConditionCacheMonitor"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Alerts Engine Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Alert Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Statistics for the RHQ Server Alerts Engine Subsystem."/>
</plugin-configuration>
@@ -88,7 +88,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq:service=MeasurementMonitor"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Measurement Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Measurement Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Statistics for the RHQ Server Measurement Subsystem."/>
</plugin-configuration>
@@ -144,7 +144,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq:service=GroupDefinitionRecalculationThreadMonitor"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Group Definition / DynaGroups Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Group Definition Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Statistics for the RHQ Server Group Definition / DynaGroups Subsystem."/>
</plugin-configuration>
@@ -189,7 +189,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq:service=ServerCommunications"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Communications Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Communications Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Details on communications with agents"/>
</plugin-configuration>
@@ -265,7 +265,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq.remoting:type=RemoteApiMetrics"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Remote API Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Remote API Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Details on remote API communications with external clients, including the CLI"/>
</plugin-configuration>
@@ -309,7 +309,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="rhq.serverplugin:service=ServerPluginService"/>
- <c:simple-property name="nameTemplate" default="RHQ Server Plugin Subsystem"/>
+ <c:simple-property name="nameTemplate" default="Plugin Subsystem"/>
<c:simple-property name="descriptionTemplate" default="Details on the server-side plugin container subsystem"/>
</plugin-configuration>
commit bdf73e8c82c4568ea9a52b678d0b67b82926ffde
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 17:44:00 2010 +0100
RHQ agent plugin resources renamed.
diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
index 9580b69..52d9ac2 100644
--- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
+++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
@@ -65,8 +65,7 @@ public class AgentDiscoveryComponent implements ResourceDiscoveryComponent {
try {
AgentManagementMBean mbean = getAgentManagementMBean();
- String agentName = mbean.getAgentConfiguration().getProperty(AgentConfigurationConstants.NAME);
- String name = agentName + " RHQ Agent";
+ String name = "RHQ Agent";
String key = name; // our key IS our name - its unique since there is only one per platform
String version = mbean.getVersion();
String description = "RHQ Management Agent";
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index ab76cb6..45af5ba 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -13,7 +13,8 @@
<server name="RHQ Agent"
discovery="AgentDiscoveryComponent"
class="AgentServerComponent"
- description="Management Agent">
+ description="Management Agent"
+ singleton="true">
<plugin-configuration>
<c:group name="event" displayName="Log Tracking">
commit f0ba96ddb125030a5ce73106e47b33fc03a11c9d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 15:06:09 2010 +0100
Platforms plugin resources renamed.
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java
index dbd207f..b7960c2 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java
@@ -63,10 +63,9 @@ public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent<
}
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
try {
- String name = ((hostname == null) ? "" : (hostname + " ")) + " File System ("
- + fs.getFileSystem().getTypeName() + ") " + fs.getMountPoint();
+ String key = fs.getMountPoint();
DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- fs.getMountPoint(), name, null, fs.getFileSystem().getDevName() + ": "
+ key, key, null, fs.getFileSystem().getDevName() + ": "
+ fs.getFileSystem().getDirName(), pluginConfig, null);
results.add(details);
} catch (Exception e) {
commit 0790ffbfc48e7e7dd9eb43a43510282861f1bbd0
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 15:03:22 2010 +0100
Oracle plugin resources renamed.
diff --git a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
index 985058a..2340f0b 100644
--- a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
+++ b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
@@ -92,7 +92,7 @@ public class OracleDiscoveryComponent implements ResourceDiscoveryComponent, Man
Configuration pluginConfig, String version, @Nullable
ProcessInfo processInfo) {
String key = pluginConfig.getSimpleValue("sid", "XE");
- String name = "Oracle (" + key + ")";
+ String name = key;
String description = "Oracle " + version + " (" + key + ")";
return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, version, description,
pluginConfig, processInfo);
diff --git a/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
index 9478f12..11eb232 100644
--- a/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
@@ -580,7 +580,7 @@
<c:simple-property name="table" default="DBA_USERS"/>
<c:simple-property name="metricQuery" default="SELECT * FROM DBA_USERS"/>
<c:simple-property name="keyColumn" default="username"/>
- <c:simple-property name="name" default="Oracle User - {key}"/>
+ <c:simple-property name="name" default="{key}"/>
<c:simple-property name="description" default="Oracle User"/>
</plugin-configuration>
commit 112fadec0620f71058ca4f422753b6d3fe67a28c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 14:54:13 2010 +0100
Jira plugin resources renamed.
diff --git a/modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java b/modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java
index 1585ba0..7349dfc 100644
--- a/modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java
+++ b/modules/plugins/jira/src/main/java/org/rhq/plugins/jira/JiraServerDiscoveryComponent.java
@@ -50,7 +50,7 @@ public class JiraServerDiscoveryComponent implements ResourceDiscoveryComponent,
new DiscoveredResourceDetails(
resourceDiscoveryContext.getResourceType(),
url,
- "Jira " + url,
+ url,
info.getVersion(),
info.getEdition(),
config,
commit 58b5f646641ffa0b2acb5ee117873f564b503deb
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 23 14:47:26 2010 +0100
Grub plugin resources renamed.
diff --git a/modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java b/modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java
index 53022f1..4233bab 100644
--- a/modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java
+++ b/modules/plugins/grub/src/main/java/org/rhq/plugins/grub/GrubDiscoveryComponent.java
@@ -21,6 +21,8 @@ package org.rhq.plugins.grub;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
+
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
@@ -38,8 +40,9 @@ public class GrubDiscoveryComponent implements ResourceDiscoveryComponent {
File grubFile = new File("/etc/grub.conf");
if (grubFile.exists()) {
+ ResourceType resourceType = resourceDiscoveryContext.getResourceType();
DiscoveredResourceDetails resource =
- new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(), "grub", "GRUB Boot Loader",
+ new DiscoveredResourceDetails(resourceType, "grub", resourceType.getName(),
"1.0", "GRUB configuration on the machine.", null, null);
details.add(resource);
diff --git a/modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml
index bf4d069..b5f9ab8 100644
--- a/modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/grub/src/main/resources/META-INF/rhq-plugin.xml
@@ -11,7 +11,8 @@
<server name="GRUB"
description="The GRUB boot loader"
discovery="GrubDiscoveryComponent"
- class="GrubComponent">
+ class="GrubComponent"
+ singleton="true">
<plugin-configuration>
<c:group name="augeas" displayName="Augeas Settings">
commit 881e397532a18850d9c9d01e6bea00816dd2b277
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 16 13:40:10 2010 +0100
Slight updates to the apache resource names.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index f19f2e3..b87b3d6 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -21,6 +21,7 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
+import java.net.URI;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -216,7 +217,15 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
Configuration pluginConfig, ProcessInfo processInfo, ApacheBinaryInfo binaryInfo) throws Exception {
String httpdConf = pluginConfig.getSimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF).getStringValue();
String version = binaryInfo.getVersion();
- String name = httpdConf;
+ String serverUrl = pluginConfig.getSimpleValue(ApacheServerComponent.PLUGIN_CONFIG_PROP_URL, null);
+ //use the server url if we could detect it, otherwise use something unique
+ String name;
+ if (serverUrl == null) {
+ name = httpdConf;
+ } else {
+ URI uri = new URI(serverUrl);
+ name = uri.getHost() + ":" + uri.getPort();
+ }
DiscoveredResourceDetails resourceDetails = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
httpdConf, name, version, PRODUCT_DESCRIPTION, pluginConfig, processInfo);
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 024517f..ad8ab5e 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -251,7 +251,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
DiscoveredResourceDetails mainServer = new DiscoveredResourceDetails(resourceType,
- ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY, "Main Server", null, null,
+ ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY, "Main", null, null,
mainServerPluginConfig, null);
discoveredResources.add(mainServer);
}
commit 29e014aca53d7d1ab417005f81a204069f1d9ae7
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Feb 15 13:12:13 2010 +0100
apache renaming
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index dae7df0..f19f2e3 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -216,8 +216,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
Configuration pluginConfig, ProcessInfo processInfo, ApacheBinaryInfo binaryInfo) throws Exception {
String httpdConf = pluginConfig.getSimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF).getStringValue();
String version = binaryInfo.getVersion();
- String hostname = discoveryContext.getSystemInformation().getHostname();
- String name = hostname + " Apache " + version + " (" + httpdConf + ")";
+ String name = httpdConf;
DiscoveredResourceDetails resourceDetails = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
httpdConf, name, version, PRODUCT_DESCRIPTION, pluginConfig, processInfo);
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 7e41eb4..024517f 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -135,11 +135,11 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
pluginConfiguration.put(rtLogProp);
- String resourceName = "Virtual Host ";
+ String resourceName;
if (serverName != null) {
- resourceName += address.host + ":" + address.port;
+ resourceName = address.host + ":" + address.port;
} else {
- resourceName += resourceKey;
+ resourceName = resourceKey;
}
discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
14 years, 2 months