[rhq] Branch 'gwt' - modules/common
by mazz
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java | 20 +++++++---
1 file changed, 15 insertions(+), 5 deletions(-)
New commits:
commit 43e85fb5f3ff7526794ffeaced196a7e7471eda9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 30 14:33:40 2010 -0400
provide ant contrib tasks out of box for user
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
index b184274..86e397f 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
@@ -26,9 +26,11 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.PrintWriter;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -42,14 +44,17 @@ import org.rhq.core.domain.configuration.definition.PropertySimpleType;
public class AntLauncher {
// currently, the bundle plugins don't need custom ant tasks, but there is an ant task stubbed for future use here
- private static final String ANT_TASKS = "bundle-ant-tasks.properties";
+ private static final String BUNDLE_ANT_TASKS = "bundle-ant-tasks.properties";
+
+ // "out of box" we will provide the antcontrib optional tasks
+ private static final String ANTCONTRIB_ANT_TASKS = "net/sf/antcontrib/antcontrib.properties";
/**
* Launches ANT and parses the given build file and optionally executes it.
*
* @param buildFile the build file that ANT will run
* @param target the target to run, <code>null</code> will run the default target
- * @param customTaskDefs the properties file found in classloader that contains all the taskdef definitions
+ * @param customTaskDefs the properties files found in classloader that contains all the taskdef definitions
* @param properties set of properties to set for the ANT task to access
* @param logFile where ANT messages will be logged
* @param logStdOut if <code>true</code>, log messages will be sent to stdout as well as the log file
@@ -57,7 +62,7 @@ public class AntLauncher {
*
* @throws RuntimeException
*/
- public BundleAntProject startAnt(File buildFile, String target, String customTaskDefs, Properties properties,
+ public BundleAntProject startAnt(File buildFile, String target, Set<String> customTaskDefs, Properties properties,
File logFile, boolean logStdOut, boolean execute) {
PrintWriter logFileOutput = null;
@@ -67,9 +72,14 @@ public class AntLauncher {
ClassLoader classLoader = getClass().getClassLoader();
+ if (customTaskDefs == null) {
+ customTaskDefs = new HashSet<String>(1);
+ }
+ customTaskDefs.add(ANTCONTRIB_ANT_TASKS); // we always want to provide these
+
Properties taskDefs = new Properties();
- if (customTaskDefs != null) {
- InputStream taskDefsStream = classLoader.getResourceAsStream(customTaskDefs);
+ for (String customTaskDef : customTaskDefs) {
+ InputStream taskDefsStream = classLoader.getResourceAsStream(customTaskDef);
try {
taskDefs.load(taskDefsStream);
} finally {
14 years, 1 month
[rhq] 2 commits - modules/plugins
by ips
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 38 ++++++++--
1 file changed, 32 insertions(+), 6 deletions(-)
New commits:
commit 722cd2d5bef232d55e3f4c44cf822cd5e3612531
Merge: cffa6ea... 1282e2d...
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Tue Mar 30 10:39:26 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit cffa6eace4a2139bc89db5a23be3b657dbc708a1
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Mar 29 11:31:53 2010 -0400
fix getServerRoot() so that if server root from httpd command line is a relative path, it will be resolved relative to the httpd process's cwd, not the cwd of the Agent process (see https://bugzilla.redhat.com/show_bug.cgi?id=536328)
(cherry picked from commit 237ee88dbecd6809cefea82865bbe0b1d3b5582d)
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 b87b3d6..95c2bfc 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
@@ -20,7 +20,6 @@ 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;
@@ -35,7 +34,6 @@ import org.jetbrains.annotations.Nullable;
import org.rhq.augeas.AugeasProxy;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
-import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.util.Glob;
import org.rhq.augeas.util.GlobFilter;
import org.rhq.core.domain.configuration.Configuration;
@@ -49,6 +47,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.pluginapi.util.FileUtils;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.core.system.SystemInfoException;
import org.rhq.plugins.apache.augeas.AugeasConfigurationApache;
import org.rhq.plugins.apache.augeas.AugeasTreeBuilderApache;
import org.rhq.plugins.apache.util.ApacheBinaryInfo;
@@ -293,24 +292,51 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
@Nullable
private String getServerRoot(@NotNull ApacheBinaryInfo binaryInfo, @NotNull ProcessInfo processInfo) {
+ // First see if -d was specified on the httpd command line.
String[] cmdLine = processInfo.getCommandLine();
String root = getCommandLineOption(cmdLine, "-d");
+ // If not, extract the path from the httpd binary.
if (root == null) {
root = binaryInfo.getRoot();
}
- if (root != null) {
- root = FileUtils.getCanonicalPath(root);
+ if (root == null) {
+ // We have failed to determine the server root :(
+ return null;
+ }
+
+ // If the path is relative, convert it to an absolute path, resolving it relative to the cwd of the httpd process.
+ File rootFile = new File(root);
+ if (!rootFile.isAbsolute()) {
+ String currentWorkingDir;
+ try {
+ currentWorkingDir = processInfo.getCurrentWorkingDirectory();
+ } catch (Exception e) {
+ log.error("Unable to determine current working directory of Apache process [" + processInfo
+ + "], which is needed to determine the server root of the Apache instance.", e);
+ return null;
+ }
+ if (currentWorkingDir == null) {
+ log.error("Unable to determine current working directory of Apache process [" + processInfo
+ + "], which is needed to determine the server root of the Apache instance.");
+ return null;
+ } else {
+ rootFile = new File(currentWorkingDir, root);
+ root = rootFile.getPath();
+ }
}
+ // And finally canonicalize the path, but using our own getCanonicalPath() method, which preserves symlinks.
+ root = FileUtils.getCanonicalPath(root);
+
return root;
}
@Nullable
private File getServerConfigFile(ApacheBinaryInfo binaryInfo, ProcessInfo processInfo, String serverRoot) {
- String[] cmdLine = processInfo.getCommandLine();
// First see if -f was specified on the httpd command line.
+ String[] cmdLine = processInfo.getCommandLine();
String serverConfigFile = getCommandLineOption(cmdLine, "-f");
// If not, extract the path from the httpd binary.
@@ -330,7 +356,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
serverConfigFile = file.getPath();
}
- // And now canonicalize the path, but using our own getCanonicalPath() method, which preserves symlinks.
+ // And finally canonicalize the path, but using our own getCanonicalPath() method, which preserves symlinks.
serverConfigFile = FileUtils.getCanonicalPath(serverConfigFile);
return new File(serverConfigFile);
14 years, 1 month
[rhq] Branch 'bugfixes' - modules/enterprise
by ips
modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/HtmlUtility.java | 117 ----------
modules/enterprise/server/plugins/jboss-software/src/test/java/org/rhq/enterprise/server/plugins/jboss/software/HtmlUtilityTest.java | 15 -
2 files changed, 132 deletions(-)
New commits:
commit 0b250a4c5d886ceeca36ca19a34c864dfd687e3b
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Tue Mar 30 10:37:25 2010 -0400
delete HtmlUtility class and its test, since it is no longer used
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/HtmlUtility.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/HtmlUtility.java
deleted file mode 100644
index bc1ec97..0000000
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/HtmlUtility.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.rhq.enterprise.server.plugins.jboss.software;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Ian Springer
- */
-public class HtmlUtility {
- private static final Map<String, Character> ENTITY_TO_CHAR_MAP = new HashMap<String, Character>();
-
- static {
- ENTITY_TO_CHAR_MAP.put("<", '<');
- ENTITY_TO_CHAR_MAP.put(">", '>');
- ENTITY_TO_CHAR_MAP.put("&", '&');
- ENTITY_TO_CHAR_MAP.put(""", '"');
- ENTITY_TO_CHAR_MAP.put("à", 'à');
- ENTITY_TO_CHAR_MAP.put("À", 'À');
- ENTITY_TO_CHAR_MAP.put("â", 'â');
- ENTITY_TO_CHAR_MAP.put("ä", 'ä');
- ENTITY_TO_CHAR_MAP.put("Ä", 'Ä');
- ENTITY_TO_CHAR_MAP.put("Â", 'Â');
- ENTITY_TO_CHAR_MAP.put("å", 'å');
- ENTITY_TO_CHAR_MAP.put("Å", 'Å');
- ENTITY_TO_CHAR_MAP.put("æ", 'æ');
- ENTITY_TO_CHAR_MAP.put("Æ", 'Æ');
- ENTITY_TO_CHAR_MAP.put("ç", 'ç');
- ENTITY_TO_CHAR_MAP.put("Ç", 'Ç');
- ENTITY_TO_CHAR_MAP.put("é", 'é');
- ENTITY_TO_CHAR_MAP.put("É", 'É');
- ENTITY_TO_CHAR_MAP.put("è", 'è');
- ENTITY_TO_CHAR_MAP.put("È", 'È');
- ENTITY_TO_CHAR_MAP.put("ê", 'ê');
- ENTITY_TO_CHAR_MAP.put("Ê", 'Ê');
- ENTITY_TO_CHAR_MAP.put("ë", 'ë');
- ENTITY_TO_CHAR_MAP.put("Ë", 'Ë');
- ENTITY_TO_CHAR_MAP.put("ï", 'ï');
- ENTITY_TO_CHAR_MAP.put("Ï", 'Ï');
- ENTITY_TO_CHAR_MAP.put("ô", 'ô');
- ENTITY_TO_CHAR_MAP.put("Ô", 'Ô');
- ENTITY_TO_CHAR_MAP.put("ö", 'ö');
- ENTITY_TO_CHAR_MAP.put("Ö", 'Ö');
- ENTITY_TO_CHAR_MAP.put("ø", 'ø');
- ENTITY_TO_CHAR_MAP.put("Ø", 'Ø');
- ENTITY_TO_CHAR_MAP.put("ß", 'ß');
- ENTITY_TO_CHAR_MAP.put("ù", 'ù');
- ENTITY_TO_CHAR_MAP.put("Ù", 'Ù');
- ENTITY_TO_CHAR_MAP.put("û", 'û');
- ENTITY_TO_CHAR_MAP.put("Û", 'Û');
- ENTITY_TO_CHAR_MAP.put("ü", 'ü');
- ENTITY_TO_CHAR_MAP.put("Ü", 'Ü');
- ENTITY_TO_CHAR_MAP.put(" ", ' ');
- ENTITY_TO_CHAR_MAP.put("®", '\u00a9');
- ENTITY_TO_CHAR_MAP.put("©", '\u00ae');
- ENTITY_TO_CHAR_MAP.put("€", '\u20a0');
- }
-
- public static String unescapeHTML(String string) {
- if (string == null) {
- return null;
- }
- if (string.length() < 4) {
- // This is an optimization, since we know that no entities are less than 4 characters in length
- // (< and > are the shortest ones).
- return string;
- }
-
- StringBuilder unescapedString = new StringBuilder((int) (string.length() * 1.1));
- int index = 0;
- while (index < string.length()) {
- int ampersandIndex = string.indexOf("&", index);
- if (ampersandIndex >= 0 && ampersandIndex < (string.length() - 3)) {
- int semicolonIndex = string.indexOf(";", ampersandIndex + 1);
- if (semicolonIndex >= 0) {
- // Found an entity.
-
- // Append the substring from the index up to but not including the ampersand.
- unescapedString.append(string.substring(index, ampersandIndex));
-
- String entity = string.substring(ampersandIndex, semicolonIndex + 1);
- // See if the entity is one we grok.
- Character c = ENTITY_TO_CHAR_MAP.get(entity);
- if (c != null) {
- // If we were able to map the entity to a character, append the character.
- unescapedString.append(c);
- } else {
- // Otherwise, append the unknown entity as is.
- unescapedString.append(entity);
- }
-
- index = semicolonIndex + 1;
- } else {
- // No semicolon found - not an entity. Append the substring from the index up to and including the
- // ampersand.
- unescapedString.append(string.substring(index, ampersandIndex + 1));
- index = ampersandIndex + 1;
- }
- } else {
- // No more entities in the string - append the rest of the original string.
- unescapedString.append(string.substring(index));
- index = string.length();
- }
- }
-
- return unescapedString.toString();
- }
-
- public static void main(String[] args) {
- if (args.length != 1) {
- System.err.println("Usage: java " + HtmlUtility.class.getName() + " html");
- System.exit(1);
- }
- String html = args[0];
- String unescapedHtml = unescapeHTML(html);
- System.out.println(unescapedHtml);
- }
-}
diff --git a/modules/enterprise/server/plugins/jboss-software/src/test/java/org/rhq/enterprise/server/plugins/jboss/software/HtmlUtilityTest.java b/modules/enterprise/server/plugins/jboss-software/src/test/java/org/rhq/enterprise/server/plugins/jboss/software/HtmlUtilityTest.java
deleted file mode 100644
index 5333080..0000000
--- a/modules/enterprise/server/plugins/jboss-software/src/test/java/org/rhq/enterprise/server/plugins/jboss/software/HtmlUtilityTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.rhq.enterprise.server.plugins.jboss.software;
-
-import org.testng.annotations.Test;
-
-/**
- * @author Ian Springer
- */
-public class HtmlUtilityTest {
- @Test
- public void testUnescapeHTML() throws Exception {
- String result = HtmlUtility.unescapeHTML(" <html>\nblah \n</html>&foo&bleh;");
- System.out.println("result=[" + result + "]");
- assert result.equals(" <html>\nblah \n</html>&foo&bleh;");
- }
-}
14 years, 1 month
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml | 58 ++--------
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml | 4
2 files changed, 19 insertions(+), 43 deletions(-)
New commits:
commit 1282e2df1d35f8d6b3febeb1d03e8e6c007c9e5d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 30 14:20:50 2010 +0200
Revert navigation to the struts-based alert-configuration
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
index a9dd7b4..a28536b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
@@ -17,19 +17,19 @@
<navigation-case>
<from-outcome>createNewAlertDefinition</from-outcome>
- <to-view-id>/rhq/resource/alert/newAlert.xhtml?id=#{param.id}</to-view-id>
+ <to-view-id>/alerts/Config.do?id=#{param.id}&mode=new</to-view-id>
<redirect/>
</navigation-case>
-
+
<navigation-case>
- <!-- sorting rule -->
+ <!-- sorting rule -->
<from-outcome>sort</from-outcome>
<to-view-id>/rhq/resource/alert/listAlertDefinitions.xhtml?id=#{param.id}</to-view-id>
<redirect/>
- </navigation-case>
-
+ </navigation-case>
+
</navigation-rule>
-
+
<!-- Alert Templates List -->
<navigation-rule>
<from-view-id>/rhq/admin/listAlertTemplates.xhtml</from-view-id>
@@ -46,16 +46,16 @@
<to-view-id>/alerts/Config.do?type=#{param.type}&mode=new</to-view-id>
<redirect/>
</navigation-case>
-
+
<navigation-case>
- <!-- sorting rule -->
+ <!-- sorting rule -->
<from-outcome>sort</from-outcome>
<to-view-id>/rhq/admin/listAlertTemplates.xhtml?type=#{param.type}</to-view-id>
<redirect/>
- </navigation-case>
-
+ </navigation-case>
+
</navigation-rule>
-
+
<!-- Alert History List -->
<navigation-rule>
<from-view-id>/rhq/resource/alert/listAlertHistory.xhtml</from-view-id>
@@ -73,14 +73,14 @@
<to-view-id>/rhq/resource/alert/listAlertHistory.xhtml?id=#{param.id}</to-view-id>
<redirect/>
</navigation-case>
-
+
<navigation-case>
- <!-- sorting rule -->
+ <!-- sorting rule -->
<from-outcome>sort</from-outcome>
<to-view-id>/rhq/resource/alert/listAlertHistory.xhtml?id=#{param.id}</to-view-id>
<redirect/>
- </navigation-case>
-
+ </navigation-case>
+
</navigation-rule>
<navigation-rule>
@@ -89,7 +89,7 @@
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/rhq/resource/alert/viewAlert.xhtml?ad=#{alertDefinition.id}&nid=#{alertNotificationsUIBean.activeNotification.id}</to-view-id>
-
+
<redirect />
</navigation-case>
@@ -119,30 +119,4 @@
</navigation-rule>
- <navigation-rule>
- <from-view-id>/rhq/resource/alert/listConditions.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>success</from-outcome>
- <to-view-id>/rhq/resource/alert/viewAlert.xhtml?ad=#{alertDefinition.id}</to-view-id>
-
- <redirect />
- </navigation-case>
-
- </navigation-rule>
-
- <navigation-rule>
- <from-view-id>/rhq/resource/alert/newAlert.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>success</from-outcome>
- <to-view-id>/rhq/resource/alert/viewAlert.xhtml?ad=#{alertDefinition.id}</to-view-id>
-
- <redirect />
- </navigation-case>
-
- </navigation-rule>
-
-
-
</faces-config>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml
index ef13121..8f369b7 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml
@@ -108,8 +108,10 @@
<h:outputText styleClass="headerText" value="Parent" />
</f:facet>
- <h:outputLink value="http://localhost:7080/rhq/resource/alert/viewAlert.xhtml" rendered="#{item.parentId ne 0}">
+ <h:outputLink value="/alerts/Config.do" rendered="#{item.parentId ne 0}">
+ <f:param name="mode" value="viewRoles"/>
<f:param name="type" value="#{item.resource.resourceType.id}"/>
+ <f:param name="from" value="#{item.id}"/>
<f:param name="ad" value="#{item.parentId}"/>
<h:outputText value="View Template" />
</h:outputLink>
14 years, 1 month
[rhq] Branch 'bugfixes' - modules/core modules/enterprise
by ips
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java | 1 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 6 ------
2 files changed, 1 insertion(+), 6 deletions(-)
New commits:
commit 1e97f6285b5f17b6d254f17d2b790eb769a6171b
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Mar 29 19:54:04 2010 -0400
add CascadeType.DELETE_ORPHAN to propertyDefinitions field in ConfigurationDefinition so removals from the propertyDefinitions Map are propogated to the DB when merge is called on the parent ConfigurationDefinition
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
index 5c28844..d38b302 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
@@ -93,6 +93,7 @@ public class ConfigurationDefinition implements Serializable {
@MapKey(name = "name")
@OneToMany(mappedBy = "configurationDefinition", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@OrderBy
private Map<String, PropertyDefinition> propertyDefinitions = new LinkedHashMap<String, PropertyDefinition>();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 24c9148..a3ea7ea 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -204,11 +204,6 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
return updateReport;
}
- /**
- * Updates a template
- * @param existingDT
- * @param newDT
- */
private void updateTemplate(ConfigurationTemplate existingDT, ConfigurationTemplate newDT) {
try {
@@ -295,7 +290,6 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
for (PropertyDefinition propDef : propDefsToDelete) {
existingConfigDef.getPropertyDefinitions().remove(propDef.getName());
existingProperties.remove(propDef); // does not operate on original list!!
- entityManager.remove(propDef);
}
entityManager.merge(existingConfigDef);
}
14 years, 1 month
[rhq] Branch 'bugfixes' - 2 commits - modules/enterprise
by ips
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ContentProviderDetailsUIBean.java | 28 +++--
modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 48 +++++-----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java | 9 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java | 8 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/metadata/ContentSourceMetadataManagerBean.java | 19 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java | 23 +---
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/ContentSourcePluginHandlingTest.java | 1
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/TestBase.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerSyncContentProviderTest.java | 11 +-
10 files changed, 84 insertions(+), 69 deletions(-)
New commits:
commit fafa6dddfc95d38c6bb1b893d03d01838295a387
Merge: a6eb18d... acda1f0...
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Mar 29 19:12:19 2010 -0400
Merge branch 'bugfixes' of ssh://git.fedorahosted.org/git/rhq/rhq into bugfixes
commit a6eb18d233b2781478f2c19602490e14fd75f5ea
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Mon Mar 29 19:09:55 2010 -0400
fix issue causing ContentSourcePluginHandlingTest.testUpdateContentSourceTypes() to fail; improve some variable names
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ContentProviderDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ContentProviderDetailsUIBean.java
index 52b011f..4b89f50 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ContentProviderDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ContentProviderDetailsUIBean.java
@@ -27,6 +27,7 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.content.ContentSource;
import org.rhq.core.domain.content.DownloadMode;
import org.rhq.core.gui.util.FacesContextUtility;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -66,13 +67,15 @@ public class ContentProviderDetailsUIBean {
public String test() {
ContentSourceManagerLocal manager = LookupUtil.getContentSourceManager();
- if (manager.testContentSourceConnection(contentSource.getId())) {
+ try {
+ manager.testContentSourceConnection(this.contentSource.getId());
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Test passed - the remote repository for [" + contentSource.getName() + "] is available.");
- } else {
+ "Test passed - the remote repository for [" + this.contentSource.getName() + "] is available.");
+ } catch (Exception e) {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN,
- "Test failed - failed to connect to the remote repository for [" + contentSource.getName()
- + "] - check the configuration and make sure the remote repository is up and reachable.");
+ "Test failed - failed to connect to the remote repository for [" + this.contentSource.getName()
+ + "] - check the configuration and make sure the remote repository is up and reachable. Details: "
+ + ThrowableUtil.getAllMessages(e));
}
return "success";
@@ -81,21 +84,24 @@ public class ContentProviderDetailsUIBean {
public String sync() {
// Test the content provider connection before proceeding.
ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
- if (!contentSourceManager.testContentSourceConnection(contentSource.getId())) {
+ try {
+ contentSourceManager.testContentSourceConnection(this.contentSource.getId());
+ } catch (Exception e) {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
- "Failed to connect to the remote repository for [" + contentSource.getName()
- + "] - check the configuration and make sure the remote repository is up and reachable.");
+ "Failed to connect to the remote repository for [" + this.contentSource.getName()
+ + "] - check the configuration and make sure the remote repository is up and reachable. Details: "
+ + ThrowableUtil.getAllMessages(e));
return "success";
}
Subject subject = EnterpriseFacesContextUtility.getSubject();
try {
- contentSourceManager.synchronizeAndLoadContentSource(subject, contentSource.getId());
+ contentSourceManager.synchronizeAndLoadContentSource(subject, this.contentSource.getId());
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Synchronizing content provider ["
- + contentSource.getName() + "] now.");
+ + this.contentSource.getName() + "] now.");
} catch (Exception e) {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN,
- "Failed to start the synchronization process for [" + contentSource.getName() + "]", e);
+ "Failed to start the synchronization process for [" + this.contentSource.getName() + "]", e);
}
return "success";
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 91a35b4..a58e826 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -332,6 +332,9 @@
<!-- colspan 8:7 for the debug 'id' column -->
<rich:column colspan="#{param.debug ? 8 : 7}"
width="100%">
+
+ <ui:remove>
+ <!-- The ability to associate/disassociate repos with content sources is not needed for JON. -->
<h:commandButton
action="#{RepoContentSourcesUIBean.associateWithContentProviders}"
value="ASSOCIATE..."
@@ -341,6 +344,7 @@
value="DISASSOCIATE SELECTED"
target="selectedRepoContentProviders"
styleClass="on-pager-button buttonsmall" />
+ </ui:remove>
<ui:param name="paginationDataTableName"
value="repoContentProvidersDataTable" />
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 8814a06..24c9148 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -28,6 +28,8 @@ import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -47,6 +49,8 @@ import org.rhq.enterprise.server.RHQConstants;
*/
@Stateless
public class ConfigurationMetadataManagerBean implements ConfigurationMetadataManagerLocal {
+ private final Log log = LogFactory.getLog(this.getClass());
+
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
private EntityManager entityManager;
@@ -76,9 +80,9 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
}
// delete outdated properties
- removeNolongerUsedProperties(newDefinition, existingDefinition, existingPropertyDefinitions, null);
+ removeNoLongerUsedProperties(newDefinition, existingDefinition, existingPropertyDefinitions);
} else {
- // TODO what if exisitingDefinitions is null?
+ // TODO what if existingDefinitions is null?
// we probably don't run in here, as the initial persisting is done
// somewhere else.
}
@@ -132,8 +136,8 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
}
// delete outdated properties of this group
- removeNolongerUsedProperties(newDefinition, existingDefinition, existingDefinition
- .getPropertiesInGroup(groupName), group);
+ removeNoLongerUsedProperties(newDefinition, existingDefinition, existingDefinition
+ .getPropertiesInGroup(groupName));
}
entityManager.flush();
@@ -270,28 +274,30 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
/**
* Removes PropertyDefinition items from the configuration
*
- * @param newDefinition new configuration to persist
- * @param existingDefinition existing persisted configuration
- * @param existingProperties list of existing properties
- * @param groupDef TODO
+ * @param newConfigDef new configuration being merged into the existing one
+ * @param existingConfigDef existing persisted configuration
+ * @param existingProperties list of existing properties to inspect for potential removal
*/
- private void removeNolongerUsedProperties(ConfigurationDefinition newDefinition,
- ConfigurationDefinition existingDefinition, List<PropertyDefinition> existingProperties,
- PropertyGroupDefinition groupDef) {
-
- List<PropertyDefinition> definitionsToDelete = new ArrayList<PropertyDefinition>();
- for (PropertyDefinition exDef : existingProperties) {
- PropertyDefinition nDef = newDefinition.get(exDef.getName());
- if (nDef == null) {
+ private void removeNoLongerUsedProperties(ConfigurationDefinition newConfigDef,
+ ConfigurationDefinition existingConfigDef,
+ List<PropertyDefinition> existingProperties) {
+ List<PropertyDefinition> propDefsToDelete = new ArrayList<PropertyDefinition>();
+ for (PropertyDefinition existingPropDef : existingProperties) {
+ PropertyDefinition newPropDef = newConfigDef.get(existingPropDef.getName());
+ if (newPropDef == null) {
// not in new configuration
- definitionsToDelete.add(exDef);
+ propDefsToDelete.add(existingPropDef);
}
}
- // System.out.println("Props to delete " + definitionsToDelete);
- for (PropertyDefinition def : definitionsToDelete) {
- existingDefinition.getPropertyDefinitions().remove(def.getName());
- existingProperties.remove(def); // does not operate on original list!!
+ if (!propDefsToDelete.isEmpty()) {
+ log.debug("Deleting obsolete props from configDef [" + existingConfigDef + "]: " + propDefsToDelete);
+ for (PropertyDefinition propDef : propDefsToDelete) {
+ existingConfigDef.getPropertyDefinitions().remove(propDef.getName());
+ existingProperties.remove(propDef); // does not operate on original list!!
+ entityManager.remove(propDef);
+ }
+ entityManager.merge(existingConfigDef);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
index 20ad6bc..37c72a0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
@@ -556,16 +556,15 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
}
- public boolean testContentSourceConnection(int contentSourceId) {
+ public void testContentSourceConnection(int contentSourceId) throws Exception {
try {
- ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
- return pc.getAdapterManager().testConnection(contentSourceId);
+ ContentServerPluginContainer contentServerPluginContainer = ContentManagerHelper.getPluginContainer();
+ contentServerPluginContainer.getAdapterManager().testConnection(contentSourceId);
} catch (Exception e) {
log.info("Failed to test connection to [" + contentSourceId + "]. Cause: "
+ ThrowableUtil.getAllMessages(e));
log.debug("Content source test connection failure stack follows for [" + contentSourceId + "]", e);
-
- return false;
+ throw e;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java
index 4ff85fe..a934f95 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java
@@ -203,13 +203,13 @@ public interface ContentSourceManagerLocal {
/**
* Given a content source ID, this will test that the adapter responsible for pulling data from the content source's
- * remote repository can actually connect to that repository.
+ * remote repository can actually connect to that repository, and if not, throw an Exception.
*
- * @param contentSourceId The id of the content source on which to test the connection.
+ * @param contentSourceId the id of the content source on which to test the connection
*
- * @return <code>true</code> if the remote content souce can be reached
+ * @throws Exception if the test failed
*/
- boolean testContentSourceConnection(int contentSourceId);
+ void testContentSourceConnection(int contentSourceId) throws Exception;
/**
* Requests that the identified content source be synchronized and if not lazy-loading to also download its
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/metadata/ContentSourceMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/metadata/ContentSourceMetadataManagerBean.java
index 9b83fca..7a41902 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/metadata/ContentSourceMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/metadata/ContentSourceMetadataManagerBean.java
@@ -96,25 +96,26 @@ public class ContentSourceMetadataManagerBean implements ContentSourceMetadataMa
}
private void updateConfigurationDefinition(ContentSourceType newType, ContentSourceType existingType) {
- ConfigurationDefinition newConfig = newType.getContentSourceConfigurationDefinition();
- ConfigurationDefinition existingConfig = existingType.getContentSourceConfigurationDefinition();
+ ConfigurationDefinition newConfigDef = newType.getContentSourceConfigurationDefinition();
+ ConfigurationDefinition existingConfigDef = existingType.getContentSourceConfigurationDefinition();
- if (newConfig != null) {
- if (existingConfig == null) {
+ if (newConfigDef != null) {
+ if (existingConfigDef == null) {
// everything is new
- entityManager.persist(newConfig);
- existingType.setContentSourceConfigurationDefinition(newConfig);
+ entityManager.persist(newConfigDef);
+ existingType.setContentSourceConfigurationDefinition(newConfigDef);
} else {
// both new and existing had some kind of configuration, update the existing to match the new
- configurationMetadataManager.updateConfigurationDefinition(newConfig, existingConfig);
+ configurationMetadataManager.updateConfigurationDefinition(newConfigDef, existingConfigDef);
}
} else {
// the new config is null -> remove the existing config
- if (existingConfig != null) {
+ if (existingConfigDef != null) {
existingType.setContentSourceConfigurationDefinition(null);
- entityManager.remove(existingConfig);
+ entityManager.remove(existingConfigDef);
}
}
+ return;
}
/**
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
index a6d8d2a..bba2be0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
@@ -512,24 +512,15 @@ public class ContentProviderManager {
/**
* Tests the connection to the content source that has the given ID.
*
- * @param contentSourceId
- * refers to a valid content source in the database
- * @return <code>true</code> if there is an adapter that can successfully
- * connect to the given content source <code>false</code> if there
- * is an adapter but it cannot connect
- * @throws Exception
- * if failed to get an adapter to attempt the connection
+ * @param contentSourceId the id of the content source to be tested
+ *
+ * @throws Exception if the test connection to the specified content source failed
*/
- public boolean testConnection(int contentSourceId) throws Exception {
+ public void testConnection(int contentSourceId) throws Exception {
ContentProvider adapter = getIsolatedContentProvider(contentSourceId);
-
- try {
- adapter.testConnection();
- } catch (Throwable t) {
- return false;
- }
-
- return true;
+ adapter.testConnection();
+ //noinspection UnnecessaryReturnStatement
+ return;
}
/**
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/ContentSourcePluginHandlingTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/ContentSourcePluginHandlingTest.java
index 912deeb..cb310c9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/ContentSourcePluginHandlingTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/ContentSourcePluginHandlingTest.java
@@ -107,6 +107,7 @@ public class ContentSourcePluginHandlingTest extends TestBase {
// now hot deploy a new version of that plugin
registerPlugin("./test/metadata/content-source-update-v2.xml");
+ getEntityManager().clear();
type1 = getContentSourceType("testCSPHT1");
type2 = getContentSourceType("testCSPHT2");
type3 = getContentSourceType("testCSPHT3");
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/TestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/TestBase.java
index 13af653..45d250f 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/TestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/metadata/test/TestBase.java
@@ -56,7 +56,7 @@ public class TestBase extends AbstractEJB3Test {
protected ContentSourceType getContentSourceType(String typeName) throws Exception {
getTransactionManager().begin();
- EntityManager em = getEntityManager();
+ EntityManager em = getEntityManager();
try {
Query q = em.createNamedQuery(ContentSourceType.QUERY_FIND_BY_NAME_WITH_CONFIG_DEF);
ContentSourceType type = (ContentSourceType) q.setParameter("name", typeName).getSingleResult();
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerSyncContentProviderTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerSyncContentProviderTest.java
index c3bec3a..567f8f5 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerSyncContentProviderTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerSyncContentProviderTest.java
@@ -211,8 +211,15 @@ public class ContentProviderManagerSyncContentProviderTest extends AbstractEJB3T
// Test
// --------------------------------------------
// TestContentProviderManager providerManager = new TestContentProviderManager();
- boolean tested = pluginService.getContentProviderManager().testConnection(syncSource.getId());
- assert tested;
+ boolean tested = false;
+ try {
+ pluginService.getContentProviderManager().testConnection(syncSource.getId());
+ tested = true;
+ } catch (Exception e) {
+ System.err.println("testConnection() failed: " + e);
+ e.printStackTrace();
+ }
+ assert tested : "testConnection()";
boolean completed = pluginService.getContentProviderManager().synchronizeContentProvider(syncSource.getId());
assert completed;
14 years, 1 month
[rhq] Branch 'bugfixes' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java | 13 ++++++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 16 ++++++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java | 10 ++++++
3 files changed, 31 insertions(+), 8 deletions(-)
New commits:
commit acda1f052f9e0d711213ded8b0164a72940e814f
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Mar 29 16:48:31 2010 -0400
[BZ 573982] Moving the authorization check into MeasurementChartsManagerBean
Previously, a call to getMetricDisplaySummariesForCompatibleGroup
resulted in NxM calls to AuthorizationManagerLocal.canViewResources
where N = number of measurement defs and M = number of resources. Those
NxM calls have been reduced to a single call to the new
canViewResources method in AuhtorizationManagerLocal.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java
index 5ecc627..b3c240f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java
@@ -52,6 +52,8 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
+import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
+import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.common.PerformanceMonitorInterceptor;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
@@ -95,6 +97,8 @@ public class MeasurementChartsManagerBean implements MeasurementChartsManagerLoc
private ResourceGroupManagerLocal resourceGroupManager;
@EJB
private MeasurementViewManagerLocal viewManager;
+ @EJB
+ private AuthorizationManagerLocal authorizationManager;
public List<MetricDisplaySummary> getMetricDisplaySummariesForAutoGroup(Subject subject,
int autoGroupParentResourceId, int autoGroupChildResourceTypeId, int[] measurementDefinitionIds, long begin,
@@ -449,15 +453,18 @@ public class MeasurementChartsManagerBean implements MeasurementChartsManagerLoc
return data;
}
- // TODO if cannot view resources throw permission exception
+ if (!authorizationManager.canViewResources(subject, ArrayUtils.wrapInList(resourceIds))) {
+ throw new PermissionException("User[" + subject.getName() + "] does not have permission to view metric " +
+ "schedules for resource ids, " + ArrayUtils.wrapInList(resourceIds));
+ }
MeasurementDataManagerUtility dataUtil = MeasurementDataManagerUtility.getInstance(rhqDs);
// Loop over the definitions, find matching schedules and create a MetricDisplaySummary for each definition
for (int definitionId : measurementDefinitionIds) {
int collecting = 0;
- List<MeasurementSchedule> schedules = scheduleManager.findSchedulesByResourceIdsAndDefinitionId(subject,
- resourceIds, definitionId);
+ List<MeasurementSchedule> schedules = scheduleManager.findSchedulesByResourceIdsAndDefinitionIds(resourceIds,
+ new int[] {definitionId});
int[] scheduleIds = new int[schedules.size()];
for (int i = 0; i < schedules.size(); i++) {
MeasurementSchedule schedule = schedules.get(i);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index 4a95ac1..3d5401c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -256,6 +256,15 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
return findSchedulesByResourcesAndDefinitions(subject, resourceIds, new int[] { definitionId });
}
+ public List<MeasurementSchedule> findSchedulesByResourceIdsAndDefinitionIds(int[] resourceIds,
+ int[] definitionIds) {
+ Query query = entityManager.createNamedQuery(MeasurementSchedule.FIND_BY_RESOURCE_IDS_AND_DEFINITION_IDS);
+ query.setParameter("definitionIds", ArrayUtils.wrapInList(definitionIds));
+ query.setParameter("resourceIds", ArrayUtils.wrapInList(resourceIds));
+ List<MeasurementSchedule> results = query.getResultList();
+ return results;
+ }
+
@SuppressWarnings("unchecked")
private List<MeasurementSchedule> findSchedulesByResourcesAndDefinitions(Subject subject, int[] resourceIds,
int[] definitionIds) {
@@ -266,13 +275,10 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
}
}
- Query query = entityManager.createNamedQuery(MeasurementSchedule.FIND_BY_RESOURCE_IDS_AND_DEFINITION_IDS);
- query.setParameter("definitionIds", ArrayUtils.wrapInList(definitionIds));
- query.setParameter("resourceIds", ArrayUtils.wrapInList(resourceIds));
- List<MeasurementSchedule> results = query.getResultList();
- return results;
+ return findSchedulesByResourceIdsAndDefinitionIds(resourceIds, definitionIds);
}
+
/**
* Find MeasurementSchedules that are attached to a certain definition and a resource
*
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java
index 4436294..5403878 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java
@@ -261,6 +261,16 @@ public interface MeasurementScheduleManagerLocal {
int definitionId);
/**
+ * Return a list of MeasurementSchedules for the given definition ids and resource ids. Note that this method does
+ * not take a Subject argument. Security checks are the responsibility of the caller.
+ *
+ * @param resourceIds The ids of the resource for which schedules are being fetched
+ * @param definitionIds The ids of the the measurement definitions
+ * @return A list of MeasurementSchedules
+ */
+ List<MeasurementSchedule> findSchedulesByResourceIdsAndDefinitionIds(int[] resourceIds, int[] definitionIds);
+
+ /**
* Get the MeasurementSchedule composites for an autogroup
*
* @param subject
14 years, 1 month
[rhq] Branch 'bugfixes' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerLocal.java | 9 ++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java | 34 ++++++++++
2 files changed, 43 insertions(+)
New commits:
commit f3b48e0c748335dfb3f170b7ab31264d5f17842e
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Mar 29 16:00:26 2010 -0400
[BZ 573983] Adding javadocs and another test for a scenario in which resources span multiple groups
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerLocal.java
index ce8ad68..8efe3c7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerLocal.java
@@ -45,6 +45,15 @@ public interface AuthorizationManagerLocal {
*/
boolean canViewResource(Subject subject, int resourceId);
+ /**
+ * Returns true if the current user has a role attached to a group that contains the specified resources. Note that
+ * this method will return true if the resources span multiple groups so long has the user is in one or more roles
+ * granting view permission for those groups containing the resources.
+ *
+ * @param subject The current subject or caller
+ * @param resourceIds The resource ids against which we are checking whether the subject has access
+ * @return true only if the subject has a role attached to a group that contains all of the specified resources
+ */
boolean canViewResources(Subject subject, List<Integer> resourceIds);
/**
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java
index 4ce5e6e..a663b72 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java
@@ -406,6 +406,40 @@ public class AuthorizationManagerBeanTest extends AbstractEJB3Test {
}
@Test
+ public void testCanViewResourceWhenSubjectIsInMultipleRolesAndResourcesInMultipleGroups() throws Exception {
+ getTransactionManager().begin();
+ EntityManager entityMgr = getEntityManager();
+
+ try {
+ Subject subject = SessionTestHelper.createNewSubject(entityMgr, "testSubject");
+
+ Role role1 = SessionTestHelper.createNewRoleForSubject(entityMgr, subject, "role1");
+ role1.addPermission(Permission.VIEW_RESOURCE);
+
+ Role role2 = SessionTestHelper.createNewRoleForSubject(entityMgr, subject, "role2");
+ role2.addPermission(Permission.VIEW_RESOURCE);
+
+ ResourceGroup group1 = SessionTestHelper.createNewCompatibleGroupForRole(entityMgr, role1, "group 1");
+ ResourceGroup group2 = SessionTestHelper.createNewCompatibleGroupForRole(entityMgr, role2, "group 2");
+
+ Resource r1 = SessionTestHelper.createNewResourceForGroup(entityMgr, group1, "r1");
+ Resource r2 = SessionTestHelper.createNewResourceForGroup(entityMgr, group2, "r2");
+
+ entityMgr.flush();
+
+ List<Integer> resourceIds = Arrays.asList(r1.getId(), r2.getId());
+
+ assertTrue(
+ "The subject should have permission to view the resources in different groups since the subject is in roles for those groups",
+ authorizationManager.canViewResources(subject, resourceIds)
+ );
+ }
+ finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+ @Test
public void testCanViewResourcesWhenSubjectIsNotInRole() throws Exception {
getTransactionManager().begin();
EntityManager entityMgr = getEntityManager();
14 years, 1 month
[rhq] Branch 'gwt' - 6 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java | 48 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/BundleDeployWizard.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployNowStep.java | 76 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployOptionsStep.java | 96 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java | 67 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployTargetStep.java | 68 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectPlatformsStep.java | 71 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/AbstractSelector.java | 254 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java | 81 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java | 231 ---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java | 12
13 files changed, 613 insertions(+), 409 deletions(-)
New commits:
commit c43e74fbf53cfd2dd58ee9babd328c5866dacb8c
Merge: b3313d9... 96a5298...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 29 15:39:05 2010 -0400
Merge branch 'bundle-jay' into gwt
Conflicts:
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/ProcessingRecipeContext.java
commit b3313d96a919adf6168c4dc3065e54fdc71ae69c
Merge: ef3638d... 8bd78f0...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 29 15:37:14 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit ef3638df66757fbfd2f84f03c38af3dfa3556513
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 29 15:35:55 2010 -0400
Incorporate group deployment into bundle deploy wizard. Make initial
use of Selection widgets. Refactored Pulled AbstractSelector out of
ResourceSelector and subclassed ResourceGroupSelector as well.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
index 5b11249..369569b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleDeployDefinition;
import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
@@ -33,14 +34,15 @@ public abstract class AbstractBundleDeployWizard extends AbstractBundleWizard {
private BundleVersion bundleVersion;
private BundleDeployDefinition bundleDeployDefinition;
private BundleDeployment bundleDeployment;
+ private BundleGroupDeployment bundleGroupDeployment;
private String name;
private String description;
private ConfigurationTemplate template;
private Configuration config;
- private Integer platformGroupId;
- private Integer platformId;
+ private Integer deployTargetId;
private Boolean newDefinition = Boolean.TRUE;
- private Boolean deployNow = null;
+ private boolean deployNow = true;
+ private boolean resourceDeploy = true;
public Bundle getBundle() {
return bundle;
@@ -110,32 +112,36 @@ public abstract class AbstractBundleDeployWizard extends AbstractBundleWizard {
this.newDefinition = newDefinition;
}
- public boolean isDeployNow() {
- return Boolean.TRUE.equals(deployNow);
+ public Integer getPlatformGroupId() {
+ return deployTargetId;
}
- public Boolean getDeployNow() {
- return deployNow;
+ public void setPlatformGroupId(Integer platformGroupId) {
+ this.deployTargetId = platformGroupId;
}
- public void setDeployNow(Boolean deployNow) {
- this.deployNow = deployNow;
+ public Integer getDeployTargetId() {
+ return deployTargetId;
}
- public Integer getPlatformGroupId() {
- return platformGroupId;
+ public void setDeployTargetId(Integer deployTargetId) {
+ this.deployTargetId = deployTargetId;
}
- public void setPlatformGroupId(Integer platformGroupId) {
- this.platformGroupId = platformGroupId;
+ public boolean isResourceDeploy() {
+ return resourceDeploy;
+ }
+
+ public Boolean isDeployNow() {
+ return deployNow;
}
- public Integer getPlatformId() {
- return platformId;
+ public void setDeployNow(Boolean deployNow) {
+ this.deployNow = deployNow;
}
- public void setPlatformId(Integer platformId) {
- this.platformId = platformId;
+ public void setResourceDeploy(boolean resourceDeploy) {
+ this.resourceDeploy = resourceDeploy;
}
public BundleDeployment getBundleDeployment() {
@@ -146,4 +152,12 @@ public abstract class AbstractBundleDeployWizard extends AbstractBundleWizard {
this.bundleDeployment = bundleDeployment;
}
+ public BundleGroupDeployment getBundleGroupDeployment() {
+ return bundleGroupDeployment;
+ }
+
+ public void setBundleGroupDeployment(BundleGroupDeployment bundleGroupDeployment) {
+ this.bundleGroupDeployment = bundleGroupDeployment;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/BundleDeployWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/BundleDeployWizard.java
index 284d94c..b1b2671 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/BundleDeployWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/BundleDeployWizard.java
@@ -36,8 +36,8 @@ public class BundleDeployWizard extends AbstractBundleDeployWizard {
steps.add(new BundleDeployDefinitionInfoStep(this));
steps.add(new SelectTemplateStep(this));
steps.add(new CreateConfigStep(this));
- steps.add(new DeployNowStep(this));
- steps.add(new SelectPlatformsStep(this));
+ steps.add(new DeployOptionsStep(this));
+ steps.add(new DeployTargetStep(this));
steps.add(new DeployStep(this));
}
@@ -49,8 +49,8 @@ public class BundleDeployWizard extends AbstractBundleDeployWizard {
steps.add(new BundleDeployDefinitionInfoStep(this));
steps.add(new SelectTemplateStep(this));
steps.add(new CreateConfigStep(this));
- steps.add(new DeployNowStep(this));
- steps.add(new SelectPlatformsStep(this));
+ steps.add(new DeployOptionsStep(this));
+ steps.add(new DeployTargetStep(this));
steps.add(new DeployStep(this));
}
@@ -63,8 +63,8 @@ public class BundleDeployWizard extends AbstractBundleDeployWizard {
steps.add(new SelectTemplateStep(this));
steps.add(new CreateConfigStep(this));
- steps.add(new DeployNowStep(this));
- steps.add(new SelectPlatformsStep(this));
+ steps.add(new DeployOptionsStep(this));
+ steps.add(new DeployTargetStep(this));
steps.add(new DeployStep(this));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployNowStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployNowStep.java
deleted file mode 100644
index aacf46f..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployNowStep.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
-
-import java.util.LinkedHashMap;
-
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-
-import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
-
-public class DeployNowStep implements WizardStep {
-
- static private final String DEPLOY_LATER = "later";
- static private final String DEPLOY_NOW = "now";
-
- private final BundleDeployWizard wizard;
- private DynamicForm form;
-
- public DeployNowStep(BundleDeployWizard bundleCreationWizard) {
- this.wizard = bundleCreationWizard;
- }
-
- public String getName() {
- return "Deploy Now or Later";
- }
-
- public Canvas getCanvas() {
- if (form == null) {
- form = new DynamicForm();
- form.setWidth100();
- form.setNumCols(2);
- form.setColWidths("50%", "*");
-
- RadioGroupItem radioGroupItem = new RadioGroupItem("deployTime", "Deployment Time");
- LinkedHashMap<String, String> radioGroupValues = new LinkedHashMap<String, String>();
- radioGroupValues.put(DEPLOY_NOW, "Deploy Now");
- radioGroupValues.put(DEPLOY_LATER, "Save Definition and Deploy Later");
- radioGroupItem.setRequired(true);
- radioGroupItem.setValueMap(radioGroupValues);
- radioGroupItem.setValue(DEPLOY_NOW);
- wizard.setDeployNow(true);
- radioGroupItem.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent event) {
- wizard.setDeployNow(DEPLOY_NOW.equals(event.getValue()));
- }
- });
-
- form.setItems(radioGroupItem);
- }
- return form;
- }
-
- public boolean nextPage() {
- return form.validate();
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployOptionsStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployOptionsStep.java
new file mode 100644
index 0000000..730a466
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployOptionsStep.java
@@ -0,0 +1,96 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
+
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+
+import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
+
+public class DeployOptionsStep implements WizardStep {
+
+ static private final String DEPLOY_LATER = "later";
+ static private final String DEPLOY_NOW = "now";
+
+ static private final String DEPLOY_GROUP = "group";
+ static private final String DEPLOY_RESOURCE = "resource";
+
+ private final BundleDeployWizard wizard;
+ private DynamicForm form;
+ private RadioGroupItem rgDeployTimeItem;
+ private RadioGroupItem rgDeployTypeItem;
+
+ public DeployOptionsStep(BundleDeployWizard bundleCreationWizard) {
+ this.wizard = bundleCreationWizard;
+ }
+
+ public String getName() {
+ return "Deploy Options";
+ }
+
+ public Canvas getCanvas() {
+ if (form == null) {
+ form = new DynamicForm();
+ form.setWidth100();
+ form.setNumCols(2);
+ form.setColWidths("50%", "*");
+
+ rgDeployTimeItem = new RadioGroupItem("deployTime", "Deployment Time");
+ LinkedHashMap<String, String> deployTimeValues = new LinkedHashMap<String, String>();
+ deployTimeValues.put(DEPLOY_NOW, "Deploy Now");
+ deployTimeValues.put(DEPLOY_LATER, "Deploy Later");
+ rgDeployTimeItem.setRequired(true);
+ rgDeployTimeItem.setValueMap(deployTimeValues);
+ rgDeployTimeItem.setValue(DEPLOY_NOW);
+ wizard.setDeployNow(true);
+ rgDeployTimeItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ wizard.setDeployNow(DEPLOY_NOW.equals(event.getValue()));
+ rgDeployTypeItem.setDisabled(!wizard.isDeployNow());
+ }
+ });
+
+ rgDeployTypeItem = new RadioGroupItem("deployTarget", "Deployment Target");
+ LinkedHashMap<String, String> deployTypeValues = new LinkedHashMap<String, String>();
+ deployTypeValues.put(DEPLOY_RESOURCE, "Deploy to Single Resource");
+ deployTypeValues.put(DEPLOY_GROUP, "Deploy to Group of Resources");
+ rgDeployTypeItem.setRequired(true);
+ rgDeployTypeItem.setValueMap(deployTypeValues);
+ rgDeployTypeItem.setValue(DEPLOY_RESOURCE);
+ wizard.setResourceDeploy(true);
+ rgDeployTypeItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ wizard.setResourceDeploy(DEPLOY_RESOURCE.equals(event.getValue()));
+ }
+ });
+
+ form.setItems(rgDeployTimeItem, rgDeployTypeItem);
+ }
+ return form;
+ }
+
+ public boolean nextPage() {
+ return form.validate();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
index bf3b8b1..197bd9f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployStep.java
@@ -28,6 +28,7 @@ import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.bundle.BundleDeployDefinition;
import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
@@ -80,27 +81,51 @@ public class DeployStep implements WizardStep {
+ result.getDescription(), Severity.Info));
wizard.setBundleDeployDefinition(result);
- bundleServer.scheduleBundleDeployment(wizard.getBundleDeployDefinition().getId(), wizard
- .getPlatformId(), //
- new AsyncCallback<BundleDeployment>() {
- public void onSuccess(BundleDeployment result) {
- deployingImage.setSrc("/images/status_complete.gif");
- deployingMessage.setText("Bundle Deployment Scheduled!");
- CoreGUI.getMessageCenter().notify(
- new Message("Schedule bundle deployment ["
- + wizard.getBundleDeployDefinition().getName() + "] resource ["
- + result.getResource() + "]", Severity.Info));
- wizard.setBundleDeployment(result);
- }
-
- public void onFailure(Throwable caught) {
- deployingImage.setSrc("/images/status_error.gif");
- deployingMessage.setText("Failed to Schedule Deployment!");
- CoreGUI.getErrorHandler().handleError(
- "Failed to schedule deployment: " + caught.getMessage(), caught);
- wizard.setBundleDeployment(null);
- }
- });
+ if (wizard.isResourceDeploy()) {
+ bundleServer.scheduleBundleDeployment(wizard.getBundleDeployDefinition().getId(),
+ wizard.getDeployTargetId(), //
+ new AsyncCallback<BundleDeployment>() {
+ public void onSuccess(BundleDeployment result) {
+ deployingImage.setSrc("/images/status_complete.gif");
+ deployingMessage.setText("Bundle Deployment Scheduled!");
+ CoreGUI.getMessageCenter().notify(
+ new Message("Schedule bundle deployment ["
+ + wizard.getBundleDeployDefinition().getName() + "] resource ["
+ + result.getResource() + "]", Severity.Info));
+ wizard.setBundleDeployment(result);
+ }
+
+ public void onFailure(Throwable caught) {
+ deployingImage.setSrc("/images/status_error.gif");
+ deployingMessage.setText("Failed to Schedule Deployment!");
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to schedule deployment: " + caught.getMessage(), caught);
+ wizard.setBundleDeployment(null);
+ }
+ });
+ } else {
+ bundleServer.scheduleBundleGroupDeployment(wizard.getBundleDeployDefinition().getId(),
+ wizard.getDeployTargetId(), //
+ new AsyncCallback<BundleGroupDeployment>() {
+ public void onSuccess(BundleGroupDeployment result) {
+ deployingImage.setSrc("/images/status_complete.gif");
+ deployingMessage.setText("Bundle Group Deployment Scheduled!");
+ CoreGUI.getMessageCenter().notify(
+ new Message("Schedule bundle group deployment ["
+ + wizard.getBundleDeployDefinition().getName()
+ + "] resource group [" + result.getGroup() + "]", Severity.Info));
+ wizard.setBundleGroupDeployment(result);
+ }
+
+ public void onFailure(Throwable caught) {
+ deployingImage.setSrc("/images/status_error.gif");
+ deployingMessage.setText("Failed to Schedule Group Deployment!");
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to schedule group deployment: " + caught.getMessage(), caught);
+ wizard.setBundleGroupDeployment(null);
+ }
+ });
+ }
}
public void onFailure(Throwable caught) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployTargetStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployTargetStep.java
new file mode 100644
index 0000000..b6803bb
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/DeployTargetStep.java
@@ -0,0 +1,68 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
+
+import java.util.HashSet;
+
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.AbstractSelector;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceGroupSelector;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
+
+public class DeployTargetStep implements WizardStep {
+
+ private final BundleDeployWizard wizard;
+
+ private AbstractSelector selector;
+
+ public DeployTargetStep(BundleDeployWizard bundleCreationWizard) {
+ this.wizard = bundleCreationWizard;
+ }
+
+ public String getName() {
+ return this.wizard.isResourceDeploy() ? "Select Target Resource" : "Select Target Group";
+ }
+
+ public Canvas getCanvas() {
+ if ((null == selector) || isMismatch()) {
+ selector = this.wizard.isResourceDeploy() ? new ResourceSelector() : new ResourceGroupSelector();
+ }
+
+ return selector;
+ }
+
+ private boolean isMismatch() {
+ return ((selector instanceof ResourceSelector && !this.wizard.isResourceDeploy()) || (selector instanceof ResourceGroupSelector && this.wizard
+ .isResourceDeploy()));
+ }
+
+ public boolean nextPage() {
+ HashSet<Integer> selection = selector.getSelection();
+ if (selection.size() != 1) {
+ SC.warn("Select only a single target resource for deployment. Use group deploy for multiple targets.");
+ return false;
+ }
+
+ wizard.setDeployTargetId(selection.iterator().next());
+ return true;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectPlatformsStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectPlatformsStep.java
deleted file mode 100644
index 1e38fab..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectPlatformsStep.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
-
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.TextItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-
-import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
-
-public class SelectPlatformsStep implements WizardStep {
-
- private final BundleDeployWizard wizard;
- private DynamicForm form;
-
- public SelectPlatformsStep(BundleDeployWizard bundleCreationWizard) {
- this.wizard = bundleCreationWizard;
- }
-
- public String getName() {
- return "Select Target Platforms";
- }
-
- public Canvas getCanvas() {
- if (form == null) {
- form = new DynamicForm();
- form.setWidth100();
- form.setNumCols(2);
- form.setColWidths("50%", "*");
-
- // TODO: this is temporary until we have a resource selection step
- final TextItem platformIdTextItem = new TextItem("platformId", "Platform Resource Id");
- platformIdTextItem.setRequired(true);
- platformIdTextItem.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent event) {
- Object value = event.getValue();
- if (value == null) {
- value = "";
- }
- wizard.setPlatformId(Integer.valueOf(value.toString()));
- }
- });
-
- form.setItems(platformIdTextItem);
- }
-
- return form;
- }
-
- public boolean nextPage() {
- return form.validate();
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
index 5743653..b55c172 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/BundleGWTService.java
@@ -26,6 +26,7 @@ import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleDeployDefinition;
import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
@@ -63,4 +64,7 @@ public interface BundleGWTService extends RemoteService {
ArrayList<BundleType> getAllBundleTypes() throws Exception;
BundleDeployment scheduleBundleDeployment(int bundleDeployDefinitionId, int resourceId) throws Exception;
+
+ BundleGroupDeployment scheduleBundleGroupDeployment(int bundleDeployDefinitionId, int resourceGroupId)
+ throws Exception;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index 421a66e..7499f0b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -54,7 +54,7 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
return INSTANCE;
}
- private ResourceGroupsDataSource() {
+ public ResourceGroupsDataSource() {
super("ResourceGroups");
DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/AbstractSelector.java
new file mode 100644
index 0000000..06c322c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/AbstractSelector.java
@@ -0,0 +1,254 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection;
+
+import java.util.HashSet;
+
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.DragDataAction;
+import com.smartgwt.client.types.DragTrackerMode;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.ImgProperties;
+import com.smartgwt.client.widgets.TransferImgButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.events.KeyPressEvent;
+import com.smartgwt.client.widgets.events.KeyPressHandler;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
+import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordDropEvent;
+import com.smartgwt.client.widgets.grid.events.RecordDropHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionEvent;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.layout.VStack;
+
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Greg Hinkle
+ */
+public abstract class AbstractSelector extends HLayout {
+
+ protected HashSet<Integer> selection = new HashSet<Integer>();
+
+ protected ListGrid availableGrid;
+ protected ListGrid assignedGrid;
+
+ protected TransferImgButton addButton;
+ protected TransferImgButton removeButton;
+ protected TransferImgButton addAllButton;
+ protected TransferImgButton removeAllButton;
+
+ protected Criteria latestCriteria;
+
+ public AbstractSelector() {
+ setAlign(VerticalAlignment.BOTTOM);
+ setHeight(380);
+ }
+
+ public HashSet<Integer> getSelection() {
+ return selection;
+ }
+
+ protected abstract DynamicForm getAvailableFilterForm();
+
+ protected abstract RPCDataSource<?> getDataSource();
+
+ protected abstract Criteria getLatestCriteria(DynamicForm availableFilterForm);
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ final DynamicForm availableFilterForm = getAvailableFilterForm();
+
+ VLayout availableLayout = new VLayout();
+ availableLayout.addMember(new LayoutSpacer());
+
+ availableLayout.addMember(availableFilterForm);
+
+ availableGrid = new ListGrid();
+ availableGrid.setHeight(350);
+ availableGrid.setCanDragRecordsOut(true);
+ availableGrid.setDragTrackerMode(DragTrackerMode.ICON);
+ availableGrid.setTrackerImage(new ImgProperties("types/Service_up_16.png", 16, 16));
+ availableGrid.setDragDataAction(DragDataAction.COPY);
+ availableGrid.setDataSource(getDataSource());
+ availableGrid.setFetchDelay(700);
+
+ availableGrid.setAutoFetchData(true);
+ availableGrid.setFields(new ListGridField("icon", 50), new ListGridField("name"));
+
+ availableLayout.addMember(availableGrid);
+
+ addMember(availableLayout);
+
+ availableFilterForm.addItemChangedHandler(new ItemChangedHandler() {
+ public void onItemChanged(ItemChangedEvent itemChangedEvent) {
+ latestCriteria = getLatestCriteria(availableFilterForm);
+
+ Timer t = new Timer() {
+ @Override
+ public void run() {
+ if (latestCriteria != null) {
+ Criteria c = latestCriteria;
+ latestCriteria = null;
+ availableGrid.fetchData(c);
+ }
+ }
+ };
+ t.schedule(500);
+ }
+ });
+
+ VStack moveButtonStack = new VStack(6);
+ moveButtonStack.setAlign(VerticalAlignment.CENTER);
+ moveButtonStack.setWidth(40);
+
+ addButton = new TransferImgButton(TransferImgButton.RIGHT);
+ addButton.setDisabled(true);
+ removeButton = new TransferImgButton(TransferImgButton.LEFT);
+ removeButton.setDisabled(true);
+ addAllButton = new TransferImgButton(TransferImgButton.RIGHT_ALL);
+ removeAllButton = new TransferImgButton(TransferImgButton.LEFT_ALL);
+ removeAllButton.setDisabled(true);
+
+ moveButtonStack.addMember(addButton);
+ moveButtonStack.addMember(removeButton);
+ moveButtonStack.addMember(addAllButton);
+ moveButtonStack.addMember(removeAllButton);
+
+ addMember(moveButtonStack);
+
+ VLayout assignedLayout = new VLayout();
+ assignedLayout.addMember(new LayoutSpacer());
+
+ assignedGrid = new ListGrid();
+ assignedGrid.setHeight(350);
+ assignedGrid.setCanReorderRecords(true);
+ assignedGrid.setCanDragRecordsOut(true);
+
+ assignedGrid.setCanAcceptDroppedRecords(true);
+ ListGridField iconField = new ListGridField("icon", 50);
+ iconField.setType(ListGridFieldType.ICON);
+ assignedGrid.setFields(iconField, new ListGridField("name"));
+
+ assignedLayout.addMember(assignedGrid);
+ addMember(assignedLayout);
+
+ addButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ assignedGrid.transferSelectedData(availableGrid);
+ select(assignedGrid.getSelection());
+ updateButtons();
+ }
+ });
+ removeButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ deselect(assignedGrid.getSelection());
+ assignedGrid.removeSelectedData();
+ updateButtons();
+ }
+ });
+ addAllButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ availableGrid.selectAllRecords();
+ assignedGrid.transferSelectedData(availableGrid);
+ select(availableGrid.getSelection());
+ updateButtons();
+ }
+ });
+ removeAllButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ assignedGrid.selectAllRecords();
+ deselect(assignedGrid.getSelection());
+ assignedGrid.removeSelectedData();
+ updateButtons();
+ }
+ });
+
+ availableGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ updateButtons();
+ }
+ });
+
+ assignedGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ updateButtons();
+ }
+ });
+
+ assignedGrid.addKeyPressHandler(new KeyPressHandler() {
+ public void onKeyPress(KeyPressEvent event) {
+ if ("Delete".equals(event.getKeyName())) {
+ deselect(assignedGrid.getSelection());
+ assignedGrid.removeSelectedData();
+ }
+ }
+ });
+
+ assignedGrid.addRecordDropHandler(new RecordDropHandler() {
+ public void onRecordDrop(RecordDropEvent recordDropEvent) {
+ select(recordDropEvent.getDropRecords());
+ }
+ });
+ }
+
+ protected void updateButtons() {
+ addButton.setDisabled(!availableGrid.anySelected() || availableGrid.getTotalRows() == 0);
+ removeButton.setDisabled(!assignedGrid.anySelected() || assignedGrid.getTotalRows() == 0);
+ addAllButton.setDisabled(availableGrid.getTotalRows() == 0);
+ removeAllButton.setDisabled(assignedGrid.getTotalRows() == 0);
+ }
+
+ protected void select(ListGridRecord[] records) {
+ availableGrid.deselectAllRecords();
+ for (ListGridRecord record : records) {
+ record.setEnabled(false);
+ selection.add(record.getAttributeAsInt("id"));
+ }
+ }
+
+ protected void deselect(ListGridRecord[] records) {
+ HashSet<Integer> toRemove = new HashSet<Integer>();
+ for (ListGridRecord record : records) {
+ toRemove.add(record.getAttributeAsInt("id"));
+ }
+ selection.removeAll(toRemove);
+
+ for (Integer id : toRemove) {
+ Record r = availableGrid.getDataAsRecordList().find("id", id);
+ if (r != null) {
+ ((ListGridRecord) r).setEnabled(true);
+ }
+ }
+ availableGrid.markForRedraw();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
new file mode 100644
index 0000000..06f6e4b
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -0,0 +1,81 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ResourceGroupSelector extends AbstractSelector {
+
+ public ResourceGroupSelector() {
+ super();
+ }
+
+ protected DynamicForm getAvailableFilterForm() {
+ DynamicForm availableFilterForm = new DynamicForm();
+ availableFilterForm.setNumCols(4);
+ final TextItem search = new TextItem("search", "Search");
+
+ SelectItem groupCategorySelect = new SelectItem("groupCategory", "Group Category");
+ groupCategorySelect.setValueMap("Compatible", "Mixed");
+ groupCategorySelect.setAllowEmptyValue(true);
+ availableFilterForm.setItems(search, groupCategorySelect);
+
+ return availableFilterForm;
+ }
+
+ protected RPCDataSource<?> getDataSource() {
+ return new SelectedResourceGroupsDataSource();
+ }
+
+ protected Criteria getLatestCriteria(DynamicForm availableFilterForm) {
+ Criteria latestCriteria = new Criteria();
+ Object search = availableFilterForm.getValue("search");
+ Object category = availableFilterForm.getValue("groupCategory");
+ latestCriteria.setAttribute("name", search);
+ latestCriteria.setAttribute("groupCategory", category);
+
+ return latestCriteria;
+ }
+
+ private class SelectedResourceGroupsDataSource extends ResourceGroupsDataSource {
+
+ @Override
+ public ListGridRecord[] buildRecords(PageList<ResourceGroup> resourceGroups) {
+ ListGridRecord[] records = super.buildRecords(resourceGroups);
+ for (ListGridRecord record : records) {
+ if (selection.contains(record.getAttributeAsInt("id"))) {
+ record.setEnabled(false);
+ }
+ }
+ return records;
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
index a309ce1..ea092d5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
@@ -18,72 +18,30 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection;
-import java.util.HashSet;
-
-import com.google.gwt.user.client.Timer;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.types.DragDataAction;
-import com.smartgwt.client.types.DragTrackerMode;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.types.VerticalAlignment;
-import com.smartgwt.client.widgets.ImgProperties;
-import com.smartgwt.client.widgets.TransferImgButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.events.KeyPressEvent;
-import com.smartgwt.client.widgets.events.KeyPressHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
-import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
import com.smartgwt.client.widgets.form.fields.IPickTreeItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.grid.events.RecordDropEvent;
-import com.smartgwt.client.widgets.grid.events.RecordDropHandler;
-import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
-import com.smartgwt.client.widgets.grid.events.SelectionEvent;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.LayoutSpacer;
-import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.layout.VStack;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeTreeDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ResourceSelector extends HLayout {
-
- private HashSet<Integer> selection = new HashSet<Integer>();
-
- private ListGrid availableGrid;
- private ListGrid assignedGrid;
-
- private TransferImgButton addButton;
- private TransferImgButton removeButton;
- private TransferImgButton addAllButton;
- private TransferImgButton removeAllButton;
-
- private Criteria latestCriteria;
+public class ResourceSelector extends AbstractSelector {
public ResourceSelector() {
- setAlign(VerticalAlignment.BOTTOM);
- setHeight(380);
+ super();
}
- @Override
- protected void onDraw() {
- super.onDraw();
-
-
- final DynamicForm availableFilterForm = new DynamicForm();
+ protected DynamicForm getAvailableFilterForm() {
+ DynamicForm availableFilterForm = new DynamicForm();
availableFilterForm.setNumCols(6);
final TextItem search = new TextItem("search", "Search");
@@ -93,190 +51,29 @@ public class ResourceSelector extends HLayout {
typeSelectItem.setCanSelectParentItems(true);
typeSelectItem.setLoadDataOnDemand(false);
-
SelectItem categorySelect = new SelectItem("category", "Category");
categorySelect.setValueMap("Platform", "Server", "Service");
categorySelect.setAllowEmptyValue(true);
availableFilterForm.setItems(search, typeSelectItem, categorySelect);
- VLayout availableLayout = new VLayout();
- availableLayout.addMember(new LayoutSpacer());
-
- availableLayout.addMember(availableFilterForm);
-
- availableGrid = new ListGrid();
- availableGrid.setHeight(350);
- availableGrid.setCanDragRecordsOut(true);
- availableGrid.setDragTrackerMode(DragTrackerMode.ICON);
- availableGrid.setTrackerImage(new ImgProperties("types/Service_up_16.png", 16, 16));
- availableGrid.setDragDataAction(DragDataAction.COPY);
- availableGrid.setDataSource(new SelectedResourceDataSource());
- availableGrid.setFetchDelay(700);
-
- availableGrid.setAutoFetchData(true);
- availableGrid.setFields(new ListGridField("icon", 50), new ListGridField("name"));
-
- availableLayout.addMember(availableGrid);
-
- addMember(availableLayout);
-
-
- availableFilterForm.addItemChangedHandler(new ItemChangedHandler() {
- public void onItemChanged(ItemChangedEvent itemChangedEvent) {
- latestCriteria = new Criteria();
- latestCriteria.setAttribute("name", availableFilterForm.getValue("search"));
- latestCriteria.setAttribute("type", availableFilterForm.getValue("type"));
- latestCriteria.setAttribute("category", availableFilterForm.getValue("category"));
-
- Timer t = new Timer() {
- @Override
- public void run() {
- if (latestCriteria != null) {
- Criteria c = latestCriteria;
- latestCriteria = null;
- availableGrid.fetchData(c);
- }
- }
- };
- t.schedule(500);
- }
- });
-
-
- VStack moveButtonStack = new VStack(6);
- moveButtonStack.setAlign(VerticalAlignment.CENTER);
- moveButtonStack.setWidth(40);
-
- addButton = new TransferImgButton(TransferImgButton.RIGHT);
- addButton.setDisabled(true);
- removeButton = new TransferImgButton(TransferImgButton.LEFT);
- removeButton.setDisabled(true);
- addAllButton = new TransferImgButton(TransferImgButton.RIGHT_ALL);
- removeAllButton = new TransferImgButton(TransferImgButton.LEFT_ALL);
- removeAllButton.setDisabled(true);
-
- moveButtonStack.addMember(addButton);
- moveButtonStack.addMember(removeButton);
- moveButtonStack.addMember(addAllButton);
- moveButtonStack.addMember(removeAllButton);
-
- addMember(moveButtonStack);
-
-
- VLayout assignedLayout = new VLayout();
- assignedLayout.addMember(new LayoutSpacer());
-
- assignedGrid = new ListGrid();
- assignedGrid.setHeight(350);
- assignedGrid.setCanReorderRecords(true);
- assignedGrid.setCanDragRecordsOut(true);
-
- assignedGrid.setCanAcceptDroppedRecords(true);
- ListGridField iconField = new ListGridField("icon", 50);
- iconField.setType(ListGridFieldType.ICON);
- assignedGrid.setFields(iconField, new ListGridField("name"));
-
- assignedLayout.addMember(assignedGrid);
- addMember(assignedLayout);
-
-
-
- addButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- assignedGrid.transferSelectedData(availableGrid);
- select(assignedGrid.getSelection());
- updateButtons();
- }
- });
- removeButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- deselect(assignedGrid.getSelection());
- assignedGrid.removeSelectedData();
- updateButtons();
- }
- });
- addAllButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- availableGrid.selectAllRecords();
- assignedGrid.transferSelectedData(availableGrid);
- select(availableGrid.getSelection());
- updateButtons();
- }
- });
- removeAllButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- assignedGrid.selectAllRecords();
- deselect(assignedGrid.getSelection());
- assignedGrid.removeSelectedData();
- updateButtons();
- }
- });
-
- availableGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- updateButtons();
- }
- });
-
- assignedGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- updateButtons();
- }
- });
-
- assignedGrid.addKeyPressHandler(new KeyPressHandler() {
- public void onKeyPress(KeyPressEvent event) {
- if ("Delete".equals(event.getKeyName())) {
- deselect(assignedGrid.getSelection());
- assignedGrid.removeSelectedData();
- }
- }
- });
-
-
- assignedGrid.addRecordDropHandler(new RecordDropHandler() {
- public void onRecordDrop(RecordDropEvent recordDropEvent) {
- select(recordDropEvent.getDropRecords());
- }
- });
+ return availableFilterForm;
}
- private void updateButtons() {
- addButton.setDisabled(!availableGrid.anySelected() || availableGrid.getTotalRows() == 0);
- removeButton.setDisabled(!assignedGrid.anySelected() || assignedGrid.getTotalRows() == 0);
- addAllButton.setDisabled(availableGrid.getTotalRows() == 0);
- removeAllButton.setDisabled(assignedGrid.getTotalRows() == 0);
+ protected RPCDataSource<?> getDataSource() {
+ return new SelectedResourceDataSource();
}
- private void select(ListGridRecord[] records) {
- availableGrid.deselectAllRecords();
- for (ListGridRecord record : records) {
- record.setEnabled(false);
- selection.add(record.getAttributeAsInt("id"));
- }
- }
+ protected Criteria getLatestCriteria(DynamicForm availableFilterForm) {
+ Criteria latestCriteria = new Criteria();
+ latestCriteria.setAttribute("name", availableFilterForm.getValue("search"));
+ latestCriteria.setAttribute("type", availableFilterForm.getValue("type"));
+ latestCriteria.setAttribute("category", availableFilterForm.getValue("category"));
- private void deselect(ListGridRecord[] records) {
- HashSet<Integer> toRemove = new HashSet<Integer>();
- for (ListGridRecord record : records) {
- toRemove.add(record.getAttributeAsInt("id"));
- }
- selection.removeAll(toRemove);
-
-
- for (Integer id : toRemove) {
- Record r = availableGrid.getDataAsRecordList().find("id", id);
- if (r != null) {
- ((ListGridRecord) r).setEnabled(true);
- }
- }
- availableGrid.markForRedraw();
+ return latestCriteria;
}
-
private class SelectedResourceDataSource extends ResourceDatasource {
-
@Override
public ListGridRecord[] buildRecords(PageList<Resource> resources) {
ListGridRecord[] records = super.buildRecords(resources);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
index 5473a94..1477e95 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleDeployDefinition;
import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
@@ -163,4 +164,15 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
+
+ public BundleGroupDeployment scheduleBundleGroupDeployment(int bundleDeployDefinitionId, int resourceGroupId)
+ throws Exception {
+ try {
+ BundleGroupDeployment result = bundleManager.scheduleBundleGroupDeployment(getSessionSubject(),
+ bundleDeployDefinitionId, resourceGroupId);
+ return SerialUtility.prepare(result, "scheduleBundleGroupDeployment");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
}
\ No newline at end of file
commit 96a5298c91a6ced21500f864a96f636973179e4b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 17 16:37:25 2010 -0400
Just added some debug logging confirming successful command handling.
diff --git a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/ProcessingRecipeContext.java b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/ProcessingRecipeContext.java
index f4cb102..090ea3d 100644
--- a/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/ProcessingRecipeContext.java
+++ b/modules/plugins/filetemplate-bundle/src/main/java/org/rhq/plugins/filetemplate/ProcessingRecipeContext.java
@@ -29,6 +29,9 @@ import java.util.List;
import java.util.Map;
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.content.PackageVersion;
@@ -45,6 +48,8 @@ import org.rhq.core.util.file.FileUtil;
*/
public class ProcessingRecipeContext extends RecipeContext {
+ private final Log log = LogFactory.getLog(this.getClass());
+
private final Map<PackageVersion, File> packageVersionFiles;
private final SystemInfo systemInfo;
private String baseWorkingDirectory;
@@ -73,12 +78,14 @@ public class ProcessingRecipeContext extends RecipeContext {
throw new RuntimeException("Failed to unbundle file [" + pe + "]: " + results);
}
// existingFile.delete(); WOULD WE WANT TO REMOVE THE COMPRESSED FILE?
+ log.debug("bundle deploy: unzipped " + existingFile + " to " + directory);
} else {
// not a zipped format - just move the file to the directory as-is
File newFile = new File(directory, filename);
if (!existingFile.renameTo(newFile)) {
throw new RuntimeException("Failed to move [" + existingFile + "] to [" + newFile + "]");
}
+ log.debug("bundle deploy: renamed " + existingFile + " to " + newFile);
}
}
@@ -92,6 +99,8 @@ public class ProcessingRecipeContext extends RecipeContext {
try {
destinationFile.getParentFile().mkdirs();
FileUtil.copyFile(sourceFile, destinationFile);
+
+ log.debug("bundle file: copied " + sourceFile + " to " + destinationFile);
} catch (Exception e) {
throw new RuntimeException("Failed to copy file [" + sourceFile + "] to [" + destinationFile + "]", e);
}
@@ -132,6 +141,8 @@ public class ProcessingRecipeContext extends RecipeContext {
if (!realizedTmpFile.renameTo(trueFile)) {
throw new RuntimeException("Failed to rename realized tmp file [" + realizedTmpFile + "]");
}
+
+ log.debug("bundle realize file: renamed realized" + realizedTmpFile + " to " + trueFile);
} catch (Exception e) {
throw new RuntimeException("Cannot realize file [" + file + "]", e);
} finally {
@@ -175,6 +186,8 @@ public class ProcessingRecipeContext extends RecipeContext {
if (results.getError() != null) {
throw new RuntimeException("Could not execute script [" + pe + "]: " + results, results.getError());
}
+
+ log.debug("bundle script: executed script [" + pe + "]");
}
@Override
@@ -191,6 +204,8 @@ public class ProcessingRecipeContext extends RecipeContext {
if (results.getError() != null) {
throw new RuntimeException("Could not execute command [" + pe + "]: " + results, results.getError());
}
+
+ log.debug("bundle command: executed command [" + pe + "]");
}
private void ensureExecutable(File scriptFile) {
commit 99a7975b4cb031510616a62060c4d2699ca33b6f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 17 14:47:43 2010 -0400
Add unique indexes to various bundle tables to avoid logical duplicates.
Also, fixed up a lot of advisory-related db-upgrade stuff left over from
the former core team. The db-upgrade, at least for this stuff, now matches
the schema definitions. Also, got the db-upgrade to run through from a
2.3.1 db on postgres. Also tweaked a couple of entity classes to match the
schema.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index b2663d4..683c991 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -410,8 +410,8 @@
<column name="SEVERITY" size="64" type="VARCHAR2" required="false"/>
<column name="ISSUE_DATE" type="LONG" required="false"/>
<column name="UPDATE_DATE" type="LONG" required="false"/>
- <column name="CTIME" type="LONG" required="false"/>
- <column name="LAST_MODIFIED" type="LONG" required="false"/>
+ <column name="CTIME" type="LONG" required="true"/>
+ <column name="LAST_MODIFIED" type="LONG" required="true"/>
<index name="RHQ_ADVISORY_NAME_UQ" unique="true">
<field ref="ADVISORY_NAME"/>
@@ -423,23 +423,18 @@
<index name="RHQ_ADVISORY_UDATE_IDX" unique="false">
<field ref="UPDATE_DATE"/>
- </index>
-
- <index name="RHQ_ADVISORY_SYN_IDX" unique="false">
- <field ref="SYNOPSIS"/>
- </index>
-
+ </index>
</table>
<table name="RHQ_ADVISORY_PACKAGE">
- <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="ADVISORY_ID" type="INTEGER" required="true" references="RHQ_ADVISORY"/>
<column name="PACKAGE_VERSION_ID" type="INTEGER" required="true" references="RHQ_PACKAGE_VERSION"/>
- <column name="LAST_MODIFIED" type="LONG" required="false"/>
+ <column name="LAST_MODIFIED" type="LONG" required="true"/>
<index name="RHQ_ADVISORY_PKG_IDX" unique="true">
<field ref="ADVISORY_ID"/>
- <field ref="PACKAGE_VERSIOn_ID"/>
+ <field ref="PACKAGE_VERSION_ID"/>
</index>
</table>
@@ -492,6 +487,11 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="RESOURCE_TYPE_ID" type="INTEGER" required="true" references="RHQ_RESOURCE_TYPE"/>
+
+ <!-- This index is for constraint, not performance -->
+ <index name="RHQ_BUNDLE_TYPE_UNIQUE" unique="true">
+ <field ref="NAME"/>
+ </index>
</table>
<!-- BUNDLE is a named piece of content that can be versioned and installed somewhere -->
@@ -501,6 +501,12 @@
<column name="DESCRIPTION" size="500" type="VARCHAR2" required="false"/>
<column name="BUNDLE_TYPE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_TYPE"/>
<column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
+
+ <!-- This index is for constraint, not performance -->
+ <index name="RHQ_BUNDLE_UNIQUE" unique="true">
+ <field ref="BUNDLE_TYPE_ID"/>
+ <field ref="NAME"/>
+ </index>
</table>
<!-- BUNDLE_VERSION represents an actual piece of content that needs to be installed somewhere -->
@@ -513,6 +519,13 @@
<column name="CONFIG_DEF_ID" type="INTEGER" required="false" references="RHQ_CONFIG_DEF" />
<column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
<column name="DISTRIBUTION_ID" type="INTEGER" required="false" references="RHQ_DISTRIBUTION"/>
+
+ <!-- This index is for constraint, not performance -->
+ <index name="RHQ_BUNDLE_VERSION_UNIQUE" unique="true">
+ <field ref="BUNDLE_ID"/>
+ <field ref="NAME"/>
+ <field ref="VERSION"/>
+ </index>
</table>
<!-- Many-to-many table that links many repos to a particular bundle version -->
@@ -548,6 +561,12 @@
<column name="ENFORCEMENT_INTERVAL" type="INTEGER" required="false"/>
<column name="BUNDLE_VERSION_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_VERSION"/>
<column name="BUNDLE_ID" type="INTEGER" required="false" references="RHQ_BUNDLE"/>
+
+ <!-- This index is for constraint, not performance -->
+ <index name="RHQ_BUNDLE_DEPLOY_DEF_UNIQUE" unique="true">
+ <field ref="BUNDLE_VERSION_ID"/>
+ <field ref="NAME"/>
+ </index>
</table>
<!-- Represents a bundle version that is deployed on a platform resource -->
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 85fe084..23f1fbd 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2219,337 +2219,80 @@
<!-- RHQ Advisory Representation -->
<schemaSpec version="2.71">
- <schema-directSQL>
- <statement>
- CREATE TABLE RHQ_ADVISORY_TYPE ( ID INTEGER PRIMARY KEY )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ADVISORY_TYPE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_TYPE" column="NAME" precision="200" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY_TYPE" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_TYPE" column="DESCRIPTION" precision="500" columnType="VARCHAR2" />
- <schema-directSQL>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_TYPE ( ID, NAME, DESCRIPTION )
- VALUES ( 101, 'Bug Fix Advisory', 'Bug fix(RHBA) Advisory' )
- </statement>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_TYPE ( ID, NAME, DESCRIPTION )
- VALUES ( 102, 'Product Enhancement Advisory', 'Product Enhancement(RHEA) Advisory' )
- </statement>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_TYPE ( ID, NAME, DESCRIPTION )
- VALUES ( 103, 'Security Advisory', 'Security Advisory(RHSA) Advisory' )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement>
- CREATE TABLE RHQ_ADVISORY_SEVERITY ( ID INTEGER PRIMARY KEY )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ADVISORY_SEVERITY" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_SEVERITY" column="RANK" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY_SEVERITY" column="RANK" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_SEVERITY" column="LABEL" precision="40" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY_SEVERITY" column="LABEL" nullable="false" />
- <schema-directSQL>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_TYPE ( ID, RANK, LABEL)
- VALUES ( 101, 0, 'errata.sev.label.critical' )
- </statement>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_TYPE ( ID, RANK, LABEL)
- VALUES ( 102, 1, 'errata.sev.label.important' )
- </statement>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_TYPE ( ID, RANK, LABEL)
- VALUES ( 103, 2, 'errata.sev.label.moderate' )
- </statement>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_TYPE ( ID, RANK, LABEL)
- VALUES ( 104, 3, 'errata.sev.label.low' )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement>
- CREATE TABLE RHQ_ADVISORY_FILE_TYPE ( ID INTEGER PRIMARY KEY )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ADVISORY_FILE_TYPE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_FILE_TYPE" column="LABEL" precision="40" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY_FILE_TYPE" column="LABEL" nullable="false" />
- <schema-directSQL>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_FILE_TYPE ( ID, LABEL)
- VALUES ( 101, 'RPM' )
- </statement>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_FILE_TYPE ( ID, LABEL)
- VALUES ( 102, 'SRPM' )
- </statement>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_FILE_TYPE ( ID, LABEL)
- VALUES ( 103, 'IMG')
- </statement>
- <statement>
- INSERT INTO
- RHQ_ADVISORY_FILE_TYPE ( ID, LABEL)
- VALUES ( 104, 'OVAL')
- </statement>
- </schema-directSQL>
<schema-createSequence name="RHQ_ADVISORY_SEQ" initial="10001" />
<schema-directSQL>
-
<statement desc="Creating table RHQ_ADVISORY">
CREATE TABLE RHQ_ADVISORY ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
+
<schema-alterColumn table="RHQ_ADVISORY" column="ID" nullable="false" columnType="INTEGER" />
<schema-addColumn table="RHQ_ADVISORY" column="ADVISORY" precision="64" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_NAME" precision="64" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY_NAME" nullable="false" />
+ <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE" precision="64" columnType="VARCHAR2" />
+ <schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY_TYPE" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_REL" precision="64" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY" column="ADVISORY_REL" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY" column="DESCRIPTION" precision="4000" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY" column="DESCRIPTION" nullable="false" />
+ <schema-addColumn table="RHQ_ADVISORY" column="ADVISORY_NAME" precision="64" columnType="VARCHAR2" />
+ <schema-addColumn table="RHQ_ADVISORY" column="DESCRIPTION" precision="4000" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ADVISORY" column="SYNOPSIS" precision="4000" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY" column="SYNOPSIS" nullable="false" />
+ <schema-alterColumn table="RHQ_ADVISORY" column="SYNOPSIS" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="TOPIC" precision="4000" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY" column="TOPIC" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="SOLUTION" precision="4000" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY" column="SOLUTION" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY" column="SEVERITY_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY" column="SEVERITY_ID" nullable="false" />
+ <schema-addColumn table="RHQ_ADVISORY" column="SEVERITY" precision="64" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ADVISORY" column="ISSUE_DATE" columnType="LONG" />
- <schema-alterColumn table="RHQ_ADVISORY" column="ISSUE_DATE" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="UPDATE_DATE" columnType="LONG" />
- <schema-alterColumn table="RHQ_ADVISORY" column="UPDATE_DATE" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="CTIME" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY" column="CTIME" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY" column="LAST_MODIFIED" nullable="false" />
- <schema-directSQL>
- <statement targetDBVendor="postgresql">
- CREATE UNIQUE INDEX RHQ_ADVISORY_NAME_UQ
- ON RHQ_ADVISORY ( ADVISORY_NAME )
- </statement>
- <statement targetDBVendor="oracle">
- CREATE UNIQUE INDEX RHQ_ADVISORY_NAME_UQ
- ON RHQ_ADVISORY ( ADVISORY_NAME )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement targetDBVendor="postgresql">
- CREATE UNIQUE INDEX RHQ_ADVISORY_UQ
- ON RHQ_ADVISORY ( ADVISORY )
- </statement>
- <statement targetDBVendor="oracle">
- CREATE UNIQUE INDEX RHQ_ADVISORY_UQ
- ON RHQ_ADVISORY ( ADVISORY )
- </statement>
- </schema-directSQL>
-
- <schema-directSQL>
- <statement targetDBVendor="postgresql">
- CREATE INDEX RHQ_ADVISORY_UDATE_IDX
- ON RHQ_ADVISORY (UPDATE_DATE )
- </statement>
- <statement targetDBVendor="oracle">
- CREATE INDEX RHQ_ADVISORY_UDATE_IDX
- ON RHQ_ADVISORY (UPDATE_DATE )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement targetDBVendor="postgresql">
- CREATE INDEX RHQ_ADVISORY_SYN_IDX
- ON RHQ_ADVISORY ( SYNOPSIS )
- </statement>
- <statement targetDBVendor="oracle">
- CREATE INDEX RHQ_ADVISORY_SYN_IDX
- ON RHQ_ADVISORY ( SYNOPSIS )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY
- ADD CONSTRAINT RHQ_ADV_TYPE_FKEY
- FOREIGN KEY ( ADVISORY_TYPE_ID )
- REFERENCES RHQ_ADVISORY_TYPE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY
- ADD CONSTRAINT RHQ_ADV_TYPE_FKEY
- FOREIGN KEY ( ADVISORY_TYPE_ID )
- REFERENCES RHQ_ADVISORY_TYPE ( ID )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY
- ADD CONSTRAINT RHQ_ADV_SEV_FKEY
- FOREIGN KEY ( SEVERITY_ID )
- REFERENCES RHQ_ADVISORY_SEVERITY ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY
- ADD CONSTRAINT RHQ_ADV_SEV_FKEY
- FOREIGN KEY ( SEVERITY_ID )
- REFERENCES RHQ_ADVISORY_SEVERITY ( ID )
- </statement>
- </schema-directSQL>
- <schema-createSequence name="RHQ_ADVISORY_FILE_SEQ" initial="10001" />
+
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_ADVISORY_FILE ( ID INTEGER )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ADVISORY_FILE" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_FILE" column="ADVISORY_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY_FILE" column="ADVISORY_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_FILE" column="FILE_TYPE_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY_FILE" column="FILE_TYPE_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_FILE" column="RELATIVE_FILENAME" precision="256" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY_FILE" column="RELATIVE_FILENAME" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_FILE" column="MD5SUM" precision="64" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ADVISORY_FILE" column="MD5SUM" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_FILE" column="LAST_MODIFIED" columnType="LONG" />
- <schema-alterColumn table="RHQ_ADVISORY_FILE" column="LAST_MODIFIED" nullable="false" />
- <schema-directSQL>
- <statement targetDBVendor="postgresql">
- CREATE UNIQUE INDEX RHQ_ADVISORY_ID_FILE_UQ
- ON RHQ_ADVISORY_FILE ( ADVISORY_ID, RELATIVE_FILENAME )
- </statement>
- <statement targetDBVendor="oracle">
- CREATE UNIQUE INDEX RHQ_ADVISORY_ID_FILE_UQ
- ON RHQ_ADVISORY_FILE ( ADVISORY_ID, RELATIVE_FILENAME )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_FILE
- ADD CONSTRAINT RHQ_ADV_FILE_FKEY
- FOREIGN KEY ( ADVISORY_ID)
- REFERENCES RHQ_ADVISORY ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_FILE
- ADD CONSTRAINT RHQ_ADV_FILE_FKEY
- FOREIGN KEY ( ADVISORY_ID)
- REFERENCES RHQ_ADVISORY ( ID )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_FILE
- ADD CONSTRAINT RHQ_ADV_FILE_TYPE_FKEY
- FOREIGN KEY ( FILE_TYPE_ID )
- REFERENCES RHQ_ADVISORY_FILE_TYPE ( ID )
+ CREATE UNIQUE INDEX RHQ_ADVISORY_NAME_UQ ON RHQ_ADVISORY ( ADVISORY_NAME )
</statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_FILE
- ADD CONSTRAINT RHQ_ADV_FILE_TYPE_FKEY
- FOREIGN KEY ( FILE_TYPE_TYPE )
- REFERENCES RHQ_ADVISORY_FILE_TYPE ( ID )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
<statement>
- CREATE TABLE RHQ_ADVISORY_PACKAGE_MAP ( ADVISORY_ID INTEGER )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ADVISORY_PACKAGE_MAP" column="ADVISORY_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_PACKAGE_MAP" column="PACKAGE_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY_PACKAGE_MAP" column="PACKAGE_ID" nullable="false" />
- <schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_PACKAGE_MAP
- ADD CONSTRAINT RHQ_ADV_PKG_MAP_KEY
- PRIMARY KEY ( ADVISORY_ID, PACKAGE_ID )
+ CREATE UNIQUE INDEX RHQ_ADVISORY_UQ ON RHQ_ADVISORY ( ADVISORY )
</statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_PACKAGE_MAP
- ADD CONSTRAINT RHQ_ADV_PKG_MAP_KEY
- PRIMARY KEY ( ADVISORY_ID, PACKAGE_ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_PACKAGE_MAP
- ADD FOREIGN KEY ( ADVISORY_ID )
- REFERENCES RHQ_ADVISORY ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_PACKAGE_MAP
- ADD FOREIGN KEY ( ADVISORY_ID )
- REFERENCES RHQ_ADVISORY ( ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_PACKAGE_MAP
- ADD FOREIGN KEY ( PACKAGE_ID )
- REFERENCES RHQ_PACKAGE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_PACKAGE_MAP
- ADD FOREIGN KEY ( PACKAGE_ID )
- REFERENCES RHQ_PACKAGE ( ID )
+ <statement>
+ CREATE INDEX RHQ_ADVISORY_UDATE_IDX ON RHQ_ADVISORY (UPDATE_DATE )
</statement>
</schema-directSQL>
+ <schema-createSequence name="RHQ_ADVISORY_PACKAGE_SEQ" initial="10001" />
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_ADVISORY_FILE_PKG_MAP ( ADVISORY_ID INTEGER )
+ CREATE TABLE RHQ_ADVISORY_PACKAGE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
- <schema-alterColumn table="RHQ_ADVISORY_FILE_PKG_MAP" column="ADVISORY_FILE_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_FILE_PKG_MAP" column="PACKAGE_ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY_FILE_PKG_MAP" column="PACKAGE_ID" nullable="false" />
+ <schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="ID" nullable="false" />
+ <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="ADVISORY_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="ADVISORY_ID" nullable="false" />
+ <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="PACKAGE_VERSION_ID" nullable="false" />
+ <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="LAST_MODIFIED" columnType="LONG" />
+ <schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_FILE_PKG_MAP
- ADD CONSTRAINT RHQ_ADV_FILE_PKG_MAP_KEY
- PRIMARY KEY ( ADVISORY_FILE_ID, PACKAGE_ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_FILE_PKG_MAP
- ADD CONSTRAINT RHQ_ADV_FILE_PKG_MAP_KEY
- PRIMARY KEY ( ADVISORY_FILE_ID, PACKAGE_ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_FILE_PKG_MAP
- ADD FOREIGN KEY ( ADVISORY_FILE_ID )
- REFERENCES RHQ_ADVISORY_FILE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_FILE_PKG_MAP
- ADD FOREIGN KEY ( ADVISORY_FILE_ID )
- REFERENCES RHQ_ADVISORY_FILE ( ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_FILE_PKG_MAP
- ADD FOREIGN KEY ( PACKAGE_ID )
- REFERENCES RHQ_PACKAGE ( ID )
+ <statement>
+ CREATE UNIQUE INDEX RHQ_ADVISORY_PACKAGE_UQ ON RHQ_ADVISORY_PACKAGE ( ADVISORY_ID, PACKAGE_VERSION_ID )
</statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_FILE_PKG_MAP
- ADD FOREIGN KEY ( PACKAGE_ID )
- REFERENCES RHQ_PACKAGE ( ID )
+ <statement>
+ ALTER TABLE RHQ_ADVISORY_PACKAGE
+ ADD CONSTRAINT RHQ_ADVISORY_FKEY
+ FOREIGN KEY ( ADVISORY_ID )
+ REFERENCES RHQ_ADVISORY ( ID )
+ </statement>
+ <statement>
+ ALTER TABLE RHQ_ADVISORY_PACKAGE
+ ADD CONSTRAINT RHQ_PACKAGE_VERSION_FKEY
+ FOREIGN KEY ( PACKAGE_VERSION_ID )
+ REFERENCES RHQ_PACKAGE_VERSION ( ID )
</statement>
</schema-directSQL>
+
<schema-createSequence name="RHQ_CVE_SEQ" initial="101" />
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_CVE ( ID INTEGER )
+ CREATE TABLE RHQ_CVE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_CVE" column="ID" nullable="false" />
@@ -2558,84 +2301,60 @@
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_ADVISORY_CVE ( ADVISORY_ID INTEGER )
+ CREATE TABLE RHQ_ADVISORY_CVE ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
+ <schema-alterColumn table="RHQ_ADVISORY_CVE" column="ID" nullable="false" />
+ <schema-addColumn table="RHQ_ADVISORY_CVE" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="ADVISORY_ID" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_CVE" column="CVE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="CVE_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_CVE" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ADVISORY_CVE" column="CTIME" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_CVE" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY_CVE" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_CVE
- ADD CONSTRAINT RHQ_ADV_CVE_MAP_KEY
- PRIMARY KEY ( ADVISORY_ID, CVE_ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_CVE
- ADD CONSTRAINT RHQ_ADV_CVE_MAP_KEY
- PRIMARY KEY ( ADVISORY_ID, CVE_ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_CVE
- ADD FOREIGN KEY ( ADVISORY_ID )
- REFERENCES RHQ_ADVISORY ( ID )
+ <statement>
+ CREATE UNIQUE INDEX RHQ_ADVISORY_CVE_UQ ON RHQ_ADVISORY_CVE ( ADVISORY_ID, CVE_ID )
</statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_ADVISORY_CVE
- ADD FOREIGN KEY ( ADVISORY_ID )
+ ADD CONSTRAINT RHQ_ADVISORY_FKEY
+ FOREIGN KEY ( ADVISORY_ID )
REFERENCES RHQ_ADVISORY ( ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_CVE
- ADD FOREIGN KEY ( CVE_ID )
- REFERENCES RHQ_CVE ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_CVE
- ADD FOREIGN KEY ( CVE_ID )
- REFERENCES RHQ_CVE ( ID )
- </statement>
+ <statement>
+ ALTER TABLE RHQ_ADVISORY_CVE
+ ADD CONSTRAINT RHQ_CVE_FKEY
+ FOREIGN KEY ( CVE_ID )
+ REFERENCES RHQ_CVE ( ID )
+ </statement>
</schema-directSQL>
+ <schema-createSequence name="RHQ_ADVISORY_BUGLIST_SEQ" initial="10001" />
<schema-directSQL>
<statement>
- CREATE TABLE RHQ_ADVISORY_BUGLIST ( ADVISORY_ID INTEGER )
+ CREATE TABLE RHQ_ADVISORY_BUGLIST ( ID INTEGER PRIMARY KEY)
</statement>
</schema-directSQL>
+ <schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="ID" nullable="false" />
+ <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="ADVISORY_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="BUG_ID" columnType="INTEGER" />
+ <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="BUG_ID" PRECISION="256" columnType="VARCHAR2" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="BUG_ID" nullable="false" />
- <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="CTIME" nullable="false" />
<schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_BUGLIST
- ADD CONSTRAINT RHQ_ADV_BUG_LIST_KEY
- PRIMARY KEY ( ADVISORY_ID, BUG_ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_BUGLIST
- ADD CONSTRAINT RHQ_ADV_BUG_LIST_KEY
- PRIMARY KEY ( ADVISORY_ID, BUG_ID )
- </statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_ADVISORY_BUGLIST
- ADD FOREIGN KEY ( ADVISORY_ID )
- REFERENCES RHQ_ADVISORY ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_ADVISORY_BUGLIST
- ADD FOREIGN KEY ( ADVISORY_ID )
- REFERENCES RHQ_ADVISORY ( ID )
- </statement>
+ <statement>
+ CREATE UNIQUE INDEX RHQ_ADVISORY_BUGLIST_UQ ON RHQ_ADVISORY_BUGLIST ( ADVISORY_ID, BUG_ID )
+ </statement>
+ <statement>
+ ALTER TABLE RHQ_ADVISORY_BUGLIST
+ ADD CONSTRAINT RHQ_ADVISORY_FKEY
+ FOREIGN KEY ( ADVISORY_ID )
+ REFERENCES RHQ_ADVISORY ( ID )
+ </statement>
</schema-directSQL>
+
<schema-directSQL>
<statement>
CREATE TABLE RHQ_REPO_ADVISORY ( REPO_ID INTEGER )
@@ -2644,40 +2363,25 @@
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="REPO_ID" nullable="false" />
<schema-addColumn table="RHQ_REPO_ADVISORY" column="ADVISORY_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="ADVISORY_ID" nullable="false" />
- <schema-addColumn table="RHQ_REPO_ADVISORY" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_REPO_ADVISORY" column="CTIME" nullable="false" />
<schema-addColumn table="RHQ_REPO_ADVISORY" column="LAST_MODIFIED" columnType="LONG" />
<schema-alterColumn table="RHQ_REPO_ADVISORY" column="LAST_MODIFIED" nullable="false" />
<schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_ADVISORY
- ADD CONSTRAINT RHQ_REPO_ADV_MAP_KEY
- PRIMARY KEY ( REPO_ID, ADVISORY_ID )
- </statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_ADVISORY
ADD CONSTRAINT RHQ_REPO_ADV_MAP_KEY
PRIMARY KEY ( REPO_ID, ADVISORY_ID )
</statement>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_REPO_ADVISORY
- ADD FOREIGN KEY ( ADVISORY_ID )
- REFERENCES RHQ_ADVISORY ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_REPO_ADVISORY
- ADD FOREIGN KEY ( ADVISORY_ID )
- REFERENCES RHQ_ADVISORY ( ID )
- </statement>
- <statement targetDBVendor="oracle">
+ <statement>
ALTER TABLE RHQ_REPO_ADVISORY
- ADD FOREIGN KEY ( REPO_ID )
+ ADD CONSTRAINT RHQ_REPO_FKEY
+ FOREIGN KEY ( REPO_ID )
REFERENCES RHQ_REPO ( ID )
</statement>
- <statement targetDBVendor="postgresql">
+ <statement>
ALTER TABLE RHQ_REPO_ADVISORY
- ADD FOREIGN KEY ( REPO_ID )
- REFERENCES RHQ_REPO ( ID )
+ ADD CONSTRAINT RHQ_ADVISORY_FKEY
+ FOREIGN KEY ( ADVISORY_ID )
+ REFERENCES RHQ_ADVISORY ( ID )
</statement>
</schema-directSQL>
</schemaSpec>
@@ -2710,54 +2414,6 @@
</schema-directSQL>
</schemaSpec>
- <schemaSpec version="2.74">
- <schema-createSequence name="RHQ_ADVISORY_ID_SEQ" initial="10001" />
- <schema-createSequence name="RHQ_ADVISORY_CVE_ID_SEQ" initial="10001" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ADVISORY_CVE DROP CONSTRAINT RHQ_ADV_CVE_MAP_KEY
- </statement>
- </schema-directSQL>
- <schema-addColumn table="RHQ_ADVISORY_CVE" column="ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY_CVE" column="ID" nullable="false" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ADVISORY_CVE ALTER COLUMN ID SET DEFAULT NEXTVAL('RHQ_ADVISORY_CVE_SEQ')
- </statement>
- </schema-directSQL>
- <schema-createSequence name="RHQ_ADVISORY_BUGLIST_ID_SEQ" initial="10001" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ADVISORY_BUGLIST DROP CONSTRAINT RHQ_ADV_BUG_LIST_KEY
- </statement>
- </schema-directSQL>
- <schema-addColumn table="RHQ_ADVISORY_BUGLIST" column="ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY_BUGLIST" column="ID" nullable="false" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ADVISORY_BUGLIST ALTER COLUMN ID SET DEFAULT NEXTVAL('RHQ_ADVISORY_BUG_SEQ')
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ADVISORY_PACKAGE_MAP RENAME TO RHQ_ADVISORY_PACKAGE
- </statement>
- </schema-directSQL>
- <schema-createSequence name="RHQ_ADVISORY_PACKAGE_ID_SEQ" initial="10001" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ADVISORY_PACKAGE DROP CONSTRAINT RHQ_ADV_PKG_MAP_KEY
- </statement>
- </schema-directSQL>
- <schema-addColumn table="RHQ_ADVISORY_PACKAGE" column="ID" columnType="INTEGER" />
- <schema-alterColumn table="RHQ_ADVISORY_PACKAGE" column="ID" nullable="false" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ADVISORY_PACKAGE ALTER COLUMN ID SET DEFAULT NEXTVAL('RHQ_ADVISORY_PKG_SEQ')
- </statement>
- </schema-directSQL>
- </schemaSpec>
-
<schemaSpec version="2.75">
<schema-addColumn table="RHQ_REPO" column="SYNC_SCHEDULE" columnType="VARCHAR2" precision="64" />
</schemaSpec>
@@ -3211,6 +2867,32 @@
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="DESCRIPTION" columnType="VARCHAR2" precision="500" />
</schemaSpec>
+ <schemaSpec version="2.78.3">
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_TYPE unique constraint">
+ CREATE UNIQUE INDEX RHQ_BUNDLE_TYPE_UNIQUE ON RHQ_BUNDLE_TYPE (name)
+ </statement>
+ </schema-directSQL>
+
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE unique constraint">
+ CREATE UNIQUE INDEX RHQ_BUNDLE_UNIQUE ON RHQ_BUNDLE (bundle_type_id, name)
+ </statement>
+ </schema-directSQL>
+
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION unique constraint">
+ CREATE UNIQUE INDEX RHQ_BUNDLE_VERSION_UNIQUE ON RHQ_BUNDLE_VERSION (bundle_id, name, version)
+ </statement>
+ </schema-directSQL>
+
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOY_DEF unique constraint">
+ CREATE UNIQUE INDEX RHQ_BUNDLE_DEPLOY_DEF_UNIQUE ON RHQ_BUNDLE_DEPLOY_DEF (bundle_version_id, name)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
<schemaSpec version="2.79">
<schema-directSQL>
<statement desc="Normalizing resource group descriptions">
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
index 32d2518..205d1cc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
@@ -89,10 +89,10 @@ public class Advisory implements Serializable {
@Column(name = "UPDATE_DATE", nullable = true)
private long update_date;
- @Column(name = "CTIME", nullable = true)
+ @Column(name = "CTIME", nullable = false)
private long ctime;
- @Column(name = "LAST_MODIFIED", nullable = true)
+ @Column(name = "LAST_MODIFIED", nullable = false)
private long lastModifiedDate;
@OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@@ -264,9 +264,15 @@ public class Advisory implements Serializable {
return true;
}
+ public long getCtime() {
+ return ctime;
+ }
+
@PrePersist
void onPersist() {
- this.setLastModifiedDate(System.currentTimeMillis());
+ long now = System.currentTimeMillis();
+ this.ctime = now;
+ this.setLastModifiedDate(now);
}
@PreUpdate
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
index 17bd2d8..2185c65 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
@@ -79,7 +79,7 @@ public class AdvisoryPackage implements Serializable {
@JoinColumn(name = "PACKAGE_VERSION_ID", referencedColumnName = "ID", nullable = false)
private PackageVersion pkg;
- @Column(name = "LAST_MODIFIED", nullable = true)
+ @Column(name = "LAST_MODIFIED", nullable = false)
private long lastModifiedDate;
protected AdvisoryPackage() {
commit b2cc4bca855a6a34e22f4b64ceea0f61638a4608
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 17 14:53:04 2010 -0400
LT
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/timeline/ajax/api/scripts/units.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/timeline/ajax/api/scripts/units.js
index 54f2a5b..7bdcd0d 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/timeline/ajax/api/scripts/units.js
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/timeline/ajax/api/scripts/units.js
@@ -1,64 +1,64 @@
-/*==================================================
- * Default Unit
- *==================================================
- */
-
-SimileAjax.NativeDateUnit = new Object();
-
-SimileAjax.NativeDateUnit.makeDefaultValue = function() {
- return new Date();
-};
-
-SimileAjax.NativeDateUnit.cloneValue = function(v) {
- return new Date(v.getTime());
-};
-
-SimileAjax.NativeDateUnit.getParser = function(format) {
- if (typeof format == "string") {
- format = format.toLowerCase();
- }
- return (format == "iso8601" || format == "iso 8601") ?
- SimileAjax.DateTime.parseIso8601DateTime :
- SimileAjax.DateTime.parseGregorianDateTime;
-};
-
-SimileAjax.NativeDateUnit.parseFromObject = function(o) {
- return SimileAjax.DateTime.parseGregorianDateTime(o);
-};
-
-SimileAjax.NativeDateUnit.toNumber = function(v) {
- return v.getTime();
-};
-
-SimileAjax.NativeDateUnit.fromNumber = function(n) {
- return new Date(n);
-};
-
-SimileAjax.NativeDateUnit.compare = function(v1, v2) {
- var n1, n2;
- if (typeof v1 == "object") {
- n1 = v1.getTime();
- } else {
- n1 = Number(v1);
- }
- if (typeof v2 == "object") {
- n2 = v2.getTime();
- } else {
- n2 = Number(v2);
- }
-
- return n1 - n2;
-};
-
-SimileAjax.NativeDateUnit.earlier = function(v1, v2) {
- return SimileAjax.NativeDateUnit.compare(v1, v2) < 0 ? v1 : v2;
-};
-
-SimileAjax.NativeDateUnit.later = function(v1, v2) {
- return SimileAjax.NativeDateUnit.compare(v1, v2) > 0 ? v1 : v2;
-};
-
-SimileAjax.NativeDateUnit.change = function(v, n) {
- return new Date(v.getTime() + n);
-};
-
+/*==================================================
+ * Default Unit
+ *==================================================
+ */
+
+SimileAjax.NativeDateUnit = new Object();
+
+SimileAjax.NativeDateUnit.makeDefaultValue = function() {
+ return new Date();
+};
+
+SimileAjax.NativeDateUnit.cloneValue = function(v) {
+ return new Date(v.getTime());
+};
+
+SimileAjax.NativeDateUnit.getParser = function(format) {
+ if (typeof format == "string") {
+ format = format.toLowerCase();
+ }
+ return (format == "iso8601" || format == "iso 8601") ?
+ SimileAjax.DateTime.parseIso8601DateTime :
+ SimileAjax.DateTime.parseGregorianDateTime;
+};
+
+SimileAjax.NativeDateUnit.parseFromObject = function(o) {
+ return SimileAjax.DateTime.parseGregorianDateTime(o);
+};
+
+SimileAjax.NativeDateUnit.toNumber = function(v) {
+ return v.getTime();
+};
+
+SimileAjax.NativeDateUnit.fromNumber = function(n) {
+ return new Date(n);
+};
+
+SimileAjax.NativeDateUnit.compare = function(v1, v2) {
+ var n1, n2;
+ if (typeof v1 == "object") {
+ n1 = v1.getTime();
+ } else {
+ n1 = Number(v1);
+ }
+ if (typeof v2 == "object") {
+ n2 = v2.getTime();
+ } else {
+ n2 = Number(v2);
+ }
+
+ return n1 - n2;
+};
+
+SimileAjax.NativeDateUnit.earlier = function(v1, v2) {
+ return SimileAjax.NativeDateUnit.compare(v1, v2) < 0 ? v1 : v2;
+};
+
+SimileAjax.NativeDateUnit.later = function(v1, v2) {
+ return SimileAjax.NativeDateUnit.compare(v1, v2) > 0 ? v1 : v2;
+};
+
+SimileAjax.NativeDateUnit.change = function(v, n) {
+ return new Date(v.getTime() + n);
+};
+
14 years, 1 month
[rhq] Branch 'bugfixes' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java | 42 ++++++++--
1 file changed, 36 insertions(+), 6 deletions(-)
New commits:
commit 97474717d5c36881296b38aca4ee7f222ea3ae11
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Mar 29 15:35:17 2010 -0400
[BZ 573982] Adding test for when user does not have perms to view resources
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java
index 9d31668..4ce5e6e 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/AuthorizationManagerBeanTest.java
@@ -374,28 +374,25 @@ public class AuthorizationManagerBeanTest extends AbstractEJB3Test {
}
@Test
- public void testCanViewResources() throws Exception {
+ public void testCanViewResourcesWhenSubjectIsInRole() throws Exception {
getTransactionManager().begin();
EntityManager entityMgr = getEntityManager();
try {
Subject subject = SessionTestHelper.createNewSubject(entityMgr, "testSubject");
- Subject anotherSubject = SessionTestHelper.createNewSubject(entityMgr, "anotherTestSubject");
Role roleWithSubject = SessionTestHelper.createNewRoleForSubject(entityMgr, subject, "role with subject");
roleWithSubject.addPermission(Permission.VIEW_RESOURCE);
- Role roleWithoutSubject = SessionTestHelper.createNewRoleForSubject(entityMgr, anotherSubject,
- "role without subject");
-
ResourceGroup group = SessionTestHelper.createNewCompatibleGroupForRole(entityMgr, roleWithSubject,
"accessible group");
Resource r1 = SessionTestHelper.createNewResourceForGroup(entityMgr, group, "r1");
+ Resource r2 = SessionTestHelper.createNewResourceForGroup(entityMgr, group, "r2");
entityMgr.flush();
- List<Integer> resourceIds = Arrays.asList(r1.getId());
+ List<Integer> resourceIds = Arrays.asList(r1.getId(), r2.getId());
assertTrue(
"The subject should have permission to view the resources",
@@ -408,6 +405,39 @@ public class AuthorizationManagerBeanTest extends AbstractEJB3Test {
}
}
+ @Test
+ public void testCanViewResourcesWhenSubjectIsNotInRole() throws Exception {
+ getTransactionManager().begin();
+ EntityManager entityMgr = getEntityManager();
+
+ try {
+ Subject subject = SessionTestHelper.createNewSubject(entityMgr, "testSubject");
+ Subject subjectNotInRole = SessionTestHelper.createNewSubject(entityMgr, "subjectNotInRole");
+
+ Role roleWithSubject = SessionTestHelper.createNewRoleForSubject(entityMgr, subject, "role with subject");
+ roleWithSubject.addPermission(Permission.VIEW_RESOURCE);
+
+ ResourceGroup group = SessionTestHelper.createNewCompatibleGroupForRole(entityMgr, roleWithSubject,
+ "accessible group");
+
+ Resource r1 = SessionTestHelper.createNewResourceForGroup(entityMgr, group, "r1");
+ Resource r2 = SessionTestHelper.createNewResourceForGroup(entityMgr, group, "r2");
+
+ entityMgr.flush();
+
+ List<Integer> resourceIds = Arrays.asList(r1.getId(), r2.getId());
+
+ assertFalse(
+ "The subject should not have permission to view the resources",
+ authorizationManager.canViewResources(subjectNotInRole, resourceIds)
+ );
+
+ }
+ finally {
+ getTransactionManager().rollback();
+ }
+ }
+
/*
* Test methods: getResourcePermissions(Subject, Resource) hasResourcePermission(Subject, Permission, Resource)
* hasResourcePermission(Subject, Permission, Collection<Resource>)
14 years, 1 month