etc/eclipse-tools/templates/schema.xmlcatalog
| 8
modules/core/dbutils/pom.xml
| 2
modules/core/dbutils/src/main/scripts/dbsetup/amps-schema.xml
| 1
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
| 165 +-
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
| 68
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DeepCopyable.java
| 2
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Property.java
| 7
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
| 12
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
| 12
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertySimple.java
| 30
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java
| 7
modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
| 93 -
modules/core/domain/src/main/java/org/rhq/core/domain/plugin/PluginStatusType.java
| 29
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java
| 111 +
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyListTest.java
| 59
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyMapTest.java
| 53
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertySimpleTest.java
| 16
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
| 32
modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
| 134 +
modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
| 9
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginComponent.java
| 73
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
| 71
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
| 47
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigCollection.java
| 2
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
| 1
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/admin-beans.xml
| 7
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/admin-navigation.xml
| 11
modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
| 775 +++++-----
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-edit.xhtml
| 24
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-view.xhtml
| 27
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
| 15
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
| 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerHelper.java
| 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
| 23
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
| 315 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
| 88 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java
| 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
| 79 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginType.java
| 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
| 50
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
| 359 ++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
| 16
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
| 9
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
| 9
modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
| 5
45 files changed, 2091 insertions(+), 807 deletions(-)
New commits:
commit 36af4242ed2ec52213f62b68fb052cebbf138e93
Merge: 8ddbab0... db605e7...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Nov 26 22:51:46 2009 -0500
Merge branch 'master' into ssh-install
commit db605e78ebfb82d01f0ce4130f327c45170540c7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 25 17:18:29 2009 -0500
get rid of the update query we don't need anymore
fix tests so they don't rely on that old update query
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
index eda26d8..4047d10 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
@@ -187,25 +187,6 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " LEFT JOIN p.scheduledJobsConfiguration " //
+ " WHERE p.deployment = 'SERVER' AND p.status =
'INSTALLED' "), //
- // this query does not update the content blob or ctime
- @NamedQuery(name = Plugin.UPDATE_ALL_BUT_CONTENT, query = "" //
- + "UPDATE Plugin p " //
- + " SET p.name = :name, " //
- + " p.displayName = :displayName, " //
- + " p.description = :description, " //
- + " p.enabled = :enabled, " //
- + " p.status = :status, " //
- + " p.help = :help, " //
- + " p.version = :version, " //
- + " p.ampsVersion = :ampsVersion," //
- + " p.deployment = :deployment, " //
- + " p.pluginConfiguration = :pluginConfiguration, " //
- + " p.scheduledJobsConfiguration = :scheduledJobsConfiguration, "
//
- + " p.path = :path, " //
- + " p.md5 = :md5, " //
- + " p.mtime = :mtime " //
- + " WHERE p.id = :id"),
-
// this query is how you enable and disable plugins
@NamedQuery(name = Plugin.UPDATE_PLUGINS_ENABLED_BY_IDS, query = "" //
+ "UPDATE Plugin p " //
@@ -256,7 +237,6 @@ public class Plugin implements Serializable {
public static final String QUERY_FIND_BY_IDS_AND_TYPE =
"Plugin.findByIdsAndType";
public static final String QUERY_GET_NAMES_BY_ENABLED_AND_TYPE =
"Plugin.findByEnabledAndType";
public static final String QUERY_GET_STATUS_BY_NAME_AND_TYPE =
"Plugin.getStatusByNameAndType";
- public static final String UPDATE_ALL_BUT_CONTENT =
"Plugin.updateAllButContent";
public static final String UPDATE_PLUGINS_ENABLED_BY_IDS =
"Plugin.updatePluginsEnabledByIds";
@Column(name = "ID", nullable = false)
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
index 07f8f97..729f7c2 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
@@ -131,23 +131,39 @@ public class PluginTest extends AbstractEJB3Test {
em.persist(jobsConfig);
em.flush(); // gotta get those two persists to flush to the DB
- q = em.createNamedQuery(Plugin.UPDATE_ALL_BUT_CONTENT);
- q.setParameter("id", id); // same as the one we just persisted
- q.setParameter("name", name);
- q.setParameter("path", path);
- q.setParameter("displayName", displayName);
- q.setParameter("enabled", enabled);
- q.setParameter("status", status);
- q.setParameter("md5", md5);
- q.setParameter("version", version);
- q.setParameter("ampsVersion", ampsVersion);
- q.setParameter("deployment", deployment);
- q.setParameter("pluginConfiguration", pluginConfig);
- q.setParameter("scheduledJobsConfiguration", jobsConfig);
- q.setParameter("description", description);
- q.setParameter("help", help);
- q.setParameter("mtime", System.currentTimeMillis());
- assert q.executeUpdate() == 1 : "Failed to update the plugin";
+ // do what
ServerPluginsBean/ResourceMetadataManagerBean.updateServerPluginExceptContent does
+ Configuration config = plugin.getPluginConfiguration();
+ if (config != null) {
+ config = em.merge(config);
+ plugin.setPluginConfiguration(config);
+ }
+ config = plugin.getScheduledJobsConfiguration();
+ if (config != null) {
+ config = em.merge(config);
+ plugin.setScheduledJobsConfiguration(config);
+ }
+
+ Plugin pluginEntity = em.getReference(Plugin.class, plugin.getId());
+ pluginEntity.setName(name);
+ pluginEntity.setPath(path);
+ pluginEntity.setDisplayName(displayName);
+ pluginEntity.setEnabled(enabled);
+ pluginEntity.setStatus(status);
+ pluginEntity.setMd5(md5);
+ pluginEntity.setVersion(version);
+ pluginEntity.setAmpsVersion(ampsVersion);
+ pluginEntity.setDeployment(deployment);
+ pluginEntity.setPluginConfiguration(pluginConfig);
+ pluginEntity.setScheduledJobsConfiguration(jobsConfig);
+ pluginEntity.setDescription(description);
+ pluginEntity.setHelp(help);
+ pluginEntity.setMtime(System.currentTimeMillis());
+
+ try {
+ em.flush(); // make sure we push this out to the DB now
+ } catch (Exception e) {
+ throw new Exception("Failed to update a plugin that matches ["
+ plugin + "]", e);
+ }
em.close();
getTransactionManager().commit(); // must commit now
@@ -163,7 +179,7 @@ public class PluginTest extends AbstractEJB3Test {
assert plugin.isEnabled() == enabled;
assert plugin.getMD5().equals(md5);
assert plugin.getVersion().equals(version);
- q.setParameter("ampsVersion", ampsVersion);
+ assert plugin.getAmpsVersion().equals(ampsVersion);
assert plugin.getDescription().equals(description);
assert plugin.getDeployment() == PluginDeploymentType.SERVER;
assert plugin.getPluginConfiguration().equals(pluginConfig);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
index 9c971e0..d502f4e 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
@@ -198,49 +198,38 @@ public class ResourceMetadataManagerBean implements
ResourceMetadataManagerLocal
entityManager.persist(plugin);
} else {
// agent plugins don't support these configs, but if/when they do in the
future, this will support it
- boolean needFlush = false;
+ // make sure we create (if necessary) and attach the configs
Configuration config = plugin.getPluginConfiguration();
if (config != null) {
- if (config.getId() > 0) {
- config = entityManager.getReference(Configuration.class,
config.getId());
- plugin.setPluginConfiguration(config);
- } else {
- entityManager.persist(config);
- needFlush = true;
- }
+ config = entityManager.merge(config);
+ plugin.setPluginConfiguration(config);
}
config = plugin.getScheduledJobsConfiguration();
if (config != null) {
- if (config.getId() > 0) {
- config = entityManager.getReference(Configuration.class,
config.getId());
- plugin.setScheduledJobsConfiguration(config);
- } else {
- entityManager.persist(config);
- needFlush = true;
- }
- }
- if (needFlush) {
- entityManager.flush(); // must be flushed to the DB so the JPQL update
below works
+ config = entityManager.merge(config);
+ plugin.setScheduledJobsConfiguration(config);
}
// update all the fields except content
- Query q = entityManager.createNamedQuery(Plugin.UPDATE_ALL_BUT_CONTENT);
- q.setParameter("id", plugin.getId());
- q.setParameter("name", plugin.getName());
- q.setParameter("path", plugin.getPath());
- q.setParameter("displayName", plugin.getDisplayName());
- q.setParameter("enabled", plugin.isEnabled());
- q.setParameter("status", plugin.getStatus());
- q.setParameter("md5", plugin.getMD5());
- q.setParameter("version", plugin.getVersion());
- q.setParameter("ampsVersion", plugin.getAmpsVersion());
- q.setParameter("deployment", plugin.getDeployment());
- q.setParameter("pluginConfiguration",
plugin.getPluginConfiguration());
- q.setParameter("scheduledJobsConfiguration",
plugin.getScheduledJobsConfiguration());
- q.setParameter("description", plugin.getDescription());
- q.setParameter("help", plugin.getHelp());
- q.setParameter("mtime", plugin.getMtime());
- if (q.executeUpdate() != 1) {
+ Plugin pluginEntity = entityManager.getReference(Plugin.class,
plugin.getId());
+ pluginEntity.setName(plugin.getName());
+ pluginEntity.setPath(plugin.getPath());
+ pluginEntity.setDisplayName(plugin.getDisplayName());
+ pluginEntity.setEnabled(plugin.isEnabled());
+ pluginEntity.setStatus(plugin.getStatus());
+ pluginEntity.setMd5(plugin.getMD5());
+ pluginEntity.setVersion(plugin.getVersion());
+ pluginEntity.setAmpsVersion(plugin.getAmpsVersion());
+ pluginEntity.setDeployment(plugin.getDeployment());
+ pluginEntity.setPluginConfiguration(plugin.getPluginConfiguration());
+
pluginEntity.setScheduledJobsConfiguration(plugin.getScheduledJobsConfiguration());
+ pluginEntity.setDescription(plugin.getDescription());
+ pluginEntity.setHelp(plugin.getHelp());
+ pluginEntity.setMtime(plugin.getMtime());
+
+ try {
+ entityManager.flush(); // make sure we push this out to the DB now
+ } catch (Exception e) {
throw new Exception("Failed to update a plugin that matches ["
+ plugin + "]");
}
}
commit dfd17347dd6d8c2707bfab6ced27bd44b66f9120
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 25 16:42:23 2009 -0500
fix the update method so it can handle the config updates
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index ff7d6ca..49d6e53 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -383,56 +383,39 @@ public class ServerPluginsBean implements ServerPluginsLocal {
if (plugin.getId() == 0) {
throw new IllegalArgumentException("Plugin must already exist to update
it");
} else {
- // make sure the configs are in the DB properly and we have their refs
- // this is because we are using JPQL update, so we need to do some of this
"manually"
- boolean needFlush = false;
+ // make sure we create (if necessary) and attach the configs
Configuration config = plugin.getPluginConfiguration();
if (config != null) {
- if (config.getId() > 0) {
- config = entityManager.getReference(Configuration.class,
config.getId());
- plugin.setPluginConfiguration(config);
- } else {
- entityManager.persist(config);
- needFlush = true;
- }
+ config = entityManager.merge(config);
+ plugin.setPluginConfiguration(config);
}
config = plugin.getScheduledJobsConfiguration();
if (config != null) {
- if (config.getId() > 0) {
- config = entityManager.getReference(Configuration.class,
config.getId());
- plugin.setScheduledJobsConfiguration(config);
- } else {
- entityManager.persist(config);
- needFlush = true;
- }
- }
- if (needFlush) {
- entityManager.flush(); // must be flushed to the DB so the JPQL update
below works
+ config = entityManager.merge(config);
+ plugin.setScheduledJobsConfiguration(config);
}
- // now we can JPQL update the row - all but content is updated here.
- // we assured our configs are persisted/attached above
- Query q = entityManager.createNamedQuery(Plugin.UPDATE_ALL_BUT_CONTENT);
- q.setParameter("id", plugin.getId());
- q.setParameter("name", plugin.getName());
- q.setParameter("path", plugin.getPath());
- q.setParameter("displayName", plugin.getDisplayName());
- q.setParameter("enabled", plugin.isEnabled());
- q.setParameter("status", plugin.getStatus());
- q.setParameter("md5", plugin.getMD5());
- q.setParameter("version", plugin.getVersion());
- q.setParameter("ampsVersion", plugin.getAmpsVersion());
- q.setParameter("deployment", plugin.getDeployment());
- q.setParameter("pluginConfiguration",
plugin.getPluginConfiguration());
- q.setParameter("scheduledJobsConfiguration",
plugin.getScheduledJobsConfiguration());
- q.setParameter("description", plugin.getDescription());
- q.setParameter("help", plugin.getHelp());
- q.setParameter("mtime", plugin.getMtime());
- if (q.executeUpdate() != 1) {
- throw new Exception("Failed to update a plugin that matches ["
+ plugin + "]");
- }
+ Plugin pluginEntity = entityManager.getReference(Plugin.class,
plugin.getId());
+ pluginEntity.setName(plugin.getName());
+ pluginEntity.setPath(plugin.getPath());
+ pluginEntity.setDisplayName(plugin.getDisplayName());
+ pluginEntity.setEnabled(plugin.isEnabled());
+ pluginEntity.setStatus(plugin.getStatus());
+ pluginEntity.setMd5(plugin.getMD5());
+ pluginEntity.setVersion(plugin.getVersion());
+ pluginEntity.setAmpsVersion(plugin.getAmpsVersion());
+ pluginEntity.setDeployment(plugin.getDeployment());
+ pluginEntity.setPluginConfiguration(plugin.getPluginConfiguration());
+
pluginEntity.setScheduledJobsConfiguration(plugin.getScheduledJobsConfiguration());
+ pluginEntity.setDescription(plugin.getDescription());
+ pluginEntity.setHelp(plugin.getHelp());
+ pluginEntity.setMtime(plugin.getMtime());
- entityManager.flush(); // make sure we push this out to the DB now
+ try {
+ entityManager.flush(); // make sure we push this out to the DB now
+ } catch (Exception e) {
+ throw new Exception("Failed to update a plugin that matches ["
+ plugin + "]", e);
+ }
}
return plugin;
}
commit aadfbe12066b4cab890bc04fbd9a55c76df87fb4
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 25 13:19:15 2009 -0500
provide an API to get a list of all enabled and disabled plugins grouped by their
type
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerHelper.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerHelper.java
index a79dff5..bbeb84c 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerHelper.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerHelper.java
@@ -42,7 +42,7 @@ public class ContentManagerHelper {
}
MasterServerPluginContainer master = mbean.getMasterPluginContainer();
- pc = master.getPluginContainer(ContentServerPluginContainer.class);
+ pc = master.getPluginContainerByClass(ContentServerPluginContainer.class);
} catch (IllegalStateException ise) {
throw ise;
} catch (Exception e) {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 2d67f3f..ff7d6ca 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -26,7 +26,9 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -54,6 +56,7 @@ import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceManagement;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginType;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.xmlschema.ServerPluginDescriptorUtil;
import
org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType;
@@ -173,7 +176,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
String pluginName = doomedPlugin.getName();
doomedPlugins.add(pluginName);
if (master != null) {
- AbstractTypeServerPluginContainer pc =
master.getPluginContainer(pluginName);
+ AbstractTypeServerPluginContainer pc =
master.getPluginContainerByPlugin(pluginName);
if (pc != null) {
try {
pc.unschedulePluginJobs(pluginName);
@@ -216,7 +219,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
String pluginName = doomedPlugin.getName();
doomedPlugins.add(pluginName);
if (master != null) {
- AbstractTypeServerPluginContainer pc =
master.getPluginContainer(pluginName);
+ AbstractTypeServerPluginContainer pc =
master.getPluginContainerByPlugin(pluginName);
if (pc != null) {
try {
pc.unschedulePluginJobs(pluginName);
@@ -447,6 +450,27 @@ public class ServerPluginsBean implements ServerPluginsLocal {
return status;
}
+ // we need this method to talk to the master plugin container because the plugin data
model
+ // does not contain information as to what type a plugin is. It only has information
about
+ // where the plugin is deployed (agent or server) but it doesn't indicate if a
plugin
+ // if of type "alert plugin" or "generic plugin". That is only
known when the plugin descriptor
+ // is parsed, which happens when the master plugin container is initialized.
Therefore, this
+ // needs to get plugin info from the master plugin container while the master is
running.
+ public Map<ServerPluginType, List<String>> getAllPluginsGroupedByType()
{
+ Map<ServerPluginType, List<String>> allPlugins = new
HashMap<ServerPluginType, List<String>>();
+
+ MasterServerPluginContainer master =
LookupUtil.getServerPluginService().getMasterPluginContainer();
+ if (master != null) {
+ List<ServerPluginType> types = master.getServerPluginTypes();
+ for (ServerPluginType type : types) {
+ List<String> plugins = master.getAllPluginsByPluginType(type);
+ allPlugins.put(type, plugins);
+ }
+ }
+
+ return allPlugins;
+ }
+
/**
* This will write the contents of the given plugin file to the database.
* This will assume the MD5 in the database is already correct, so this
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
index df685d4..a6a09bf 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
@@ -2,6 +2,7 @@ package org.rhq.enterprise.server.plugin;
import java.io.File;
import java.util.List;
+import java.util.Map;
import javax.ejb.Local;
import javax.persistence.NoResultException;
@@ -9,6 +10,7 @@ import javax.persistence.NoResultException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.plugin.PluginStatusType;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginType;
import
org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType;
/**
@@ -173,4 +175,13 @@ public interface ServerPluginsLocal {
* <code>null</code> indicates an unknown plugin.
*/
PluginStatusType getServerPluginStatus(String pluginName);
+
+ /**
+ * This will return a map containing all plugins currently known to the master plugin
container.
+ * This will return installed plugins that are both enabled and disabled.
+ * Note that if the master plugin container is not running, an empty map is
returned.
+ *
+ * @return names of all enabled and disabled plugins, keyed on their types
+ */
+ Map<ServerPluginType, List<String>> getAllPluginsGroupedByType();
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
index 8ebabd4..4ab3fb2 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.server.plugin.pc;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -46,11 +47,22 @@ import
org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDe
public class MasterServerPluginContainer {
private static final Log log = LogFactory.getLog(MasterServerPluginContainer.class);
+ /** The configuration for the master plugin container itself. */
private MasterServerPluginContainerConfiguration configuration;
+
+ /** the plugin containers for all the different types of plugins that are supported
*/
private Map<ServerPluginType, AbstractTypeServerPluginContainer>
pluginContainers = new HashMap<ServerPluginType,
AbstractTypeServerPluginContainer>();
+
+ /** the object that provides all the classloaders for all plugins */
private ClassLoaderManager classLoaderManager;
/**
+ * Because the individual plugin containers are only managing enabled plugins (they
are never told about plugins that disabled).
+ * this map contains the lists of plugins that are disabled so others can find out
what plugins are registered but not running.
+ */
+ private Map<ServerPluginType, List<String>> disabledPlugins = new
HashMap<ServerPluginType, List<String>>();
+
+ /**
* Starts the master plugin container, which will load all plugins and begin managing
them.
*
* @param config the master configuration
@@ -188,6 +200,7 @@ public class MasterServerPluginContainer {
}
this.pluginContainers.clear();
+ this.disabledPlugins.clear();
this.classLoaderManager = null;
this.configuration = null;
@@ -238,6 +251,55 @@ public class MasterServerPluginContainer {
}
/**
+ * Given a plugin type, this will return the names of all known plugins of that
type.
+ * This includes all types that are currently started as well as plugins
+ * that have been disabled.
+ *
+ * If the master plugin container has not been started, this returns an empty list.
+ *
+ * @param pluginType
+ *
+ * @return list of both enabled and disabled plugins of the given type
+ */
+ public List<String> getAllPluginsByPluginType(ServerPluginType pluginType) {
+ List<String> allPlugins = new ArrayList<String>();
+
+ AbstractTypeServerPluginContainer pc =
getPluginContainerByPluginType(pluginType);
+ if (pc != null) {
+ // add the enabled plugins
+ ServerPluginManager pluginManager = pc.getPluginManager();
+ if (pluginManager != null) {
+ Collection<ServerPluginEnvironment> envs =
pluginManager.getPluginEnvironments();
+ if (envs != null) {
+ for (ServerPluginEnvironment env : envs) {
+ allPlugins.add(env.getPluginName());
+ }
+ }
+ }
+
+ // add the disabled plugins
+ List<String> disabled = this.disabledPlugins.get(pluginType);
+ if (disabled != null) {
+ allPlugins.addAll(disabled);
+ }
+ }
+
+ return allPlugins;
+ }
+
+ /**
+ * This will return all known server plugins types. These are the types of plugins
+ * that are supported by a server plugin container. You can obtain the server
+ * plugin container that manages a particular server plugin type via
+ * {@link #getPluginContainerByPluginType(ServerPluginType)}.
+ *
+ * @return all known server plugin types
+ */
+ public synchronized List<ServerPluginType> getServerPluginTypes() {
+ return new ArrayList<ServerPluginType>(this.pluginContainers.keySet());
+ }
+
+ /**
* Get the plugin container of the given class. This method provides a strongly typed
return value,
* based on the type of plugin container the caller wants returned.
*
@@ -245,7 +307,7 @@ public class MasterServerPluginContainer {
* @return the plugin container of the given class (<code>null</code> if
none found)
*/
@SuppressWarnings("unchecked")
- public synchronized <T extends AbstractTypeServerPluginContainer> T
getPluginContainer(Class<T> clazz) {
+ public synchronized <T extends AbstractTypeServerPluginContainer> T
getPluginContainerByClass(Class<T> clazz) {
for (AbstractTypeServerPluginContainer pc : this.pluginContainers.values()) {
if (clazz.isInstance(pc)) {
return (T) pc;
@@ -262,7 +324,7 @@ public class MasterServerPluginContainer {
* @param pluginName
* @return the plugin container that is managing the named plugin of
<code>null</code>
*/
- public synchronized <T extends AbstractTypeServerPluginContainer> T
getPluginContainer(String pluginName) {
+ public synchronized <T extends AbstractTypeServerPluginContainer> T
getPluginContainerByPlugin(String pluginName) {
for (AbstractTypeServerPluginContainer pc : this.pluginContainers.values()) {
if (null != pc.getPluginManager().getPluginEnvironment(pluginName)) {
return (T) pc;
@@ -319,7 +381,7 @@ public class MasterServerPluginContainer {
if (pluginFiles != null) {
- List<String> disabledPlugins = getDisabledPluginNames();
+ List<String> allDisabledPlugins = getDisabledPluginNames();
for (File pluginFile : pluginFiles) {
if (pluginFile.getName().endsWith(".jar")) {
@@ -329,12 +391,19 @@ public class MasterServerPluginContainer {
ServerPluginDescriptorType descriptor;
descriptor =
ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(pluginUrl);
if (descriptor != null) {
- if (!disabledPlugins.contains(descriptor.getName())) {
+ if (!allDisabledPlugins.contains(descriptor.getName()))
{
log.debug("pre-loaded server plugin from URL:
" + pluginUrl);
plugins.put(pluginUrl, descriptor);
} else {
log.info("Server plugin [" +
descriptor.getName()
+ "] is disabled and will not be
initialized");
+ ServerPluginType pluginType = new
ServerPluginType(descriptor);
+ List<String> disabledByType =
this.disabledPlugins.get(pluginType);
+ if (disabledByType == null) {
+ disabledByType = new ArrayList<String>(1);
+ this.disabledPlugins.put(pluginType,
disabledByType);
+ }
+ disabledByType.add(descriptor.getName());
}
}
} catch (Throwable t) {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginType.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginType.java
index feba2fc..3e6bb34 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginType.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginType.java
@@ -29,6 +29,22 @@ import
org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDe
public class ServerPluginType {
private final Class<? extends ServerPluginDescriptorType> descriptorType;
+ /**
+ * Given an actual plugin descriptor object, this will create a plugin type
+ * that represents that kind of plugin.
+ *
+ * @param descriptor an actual descriptor parsed from a plugin
+ */
+ public ServerPluginType(ServerPluginDescriptorType descriptor) {
+ this((descriptor != null) ? descriptor.getClass() : null);
+ }
+
+ /**
+ * Given a type of plugin descriptor, this will create a plugin type
+ * that represents that kind of plugin.
+ *
+ * @param descriptorType
+ */
public ServerPluginType(Class<? extends ServerPluginDescriptorType>
descriptorType) {
if (descriptorType == null) {
throw new NullPointerException("descriptorType must not be null");
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
index 1dace0b..9f0026b 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
@@ -23,6 +23,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.List;
+import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
@@ -32,12 +33,16 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.util.stream.StreamUtil;
+import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginType;
import org.rhq.enterprise.server.plugin.pc.generic.TestGenericServerPluginService.State;
import
org.rhq.enterprise.server.plugin.pc.generic.TestGenericServerPluginService.TestGenericPluginManager;
import
org.rhq.enterprise.server.plugin.pc.generic.TestGenericServerPluginService.TestGenericServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.generic.TestLifecycleListener.LifecycleState;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.xmlschema.ScheduledJobDefinition;
+import
org.rhq.enterprise.server.xmlschema.generated.serverplugin.generic.GenericPluginDescriptorType;
@Test
public class GenericServerPluginTest extends AbstractEJB3Test {
@@ -76,10 +81,21 @@ public class GenericServerPluginTest extends AbstractEJB3Test {
List<ScheduledJobDefinition> schedules = component.context.getSchedules();
assert schedules == null;
+ ServerPluginsLocal serverPluginsLocal = LookupUtil.getServerPlugins();
+ Map<ServerPluginType, List<String>> map =
serverPluginsLocal.getAllPluginsGroupedByType();
+ assert map.size() == 1;
+ List<String> pluginNames = map.get(new
ServerPluginType(GenericPluginDescriptorType.class));
+ assert pluginNames.size() == 1;
+ assert pluginNames.get(0).equals("TestSimpleGenericPlugin");
+
// make sure everything is shutdown
this.pluginService.stopMasterPluginContainer();
assert pc.state == State.UNINITIALIZED;
assert component.state == LifecycleState.UNINITIALIZED;
+
+ // with the master down, this method should return an empty map
+ map = serverPluginsLocal.getAllPluginsGroupedByType();
+ assert map.size() == 0;
}
private File createPluginJar(String jarName, String descriptorXmlFilename) throws
Exception {
commit 07ae93f34338458daa75082ef519b4b1851ddc0c
Merge: 5e17b2f... 2d97557...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 25 11:08:38 2009 -0500
Merge branch 'master' into pc
commit 2d97557a1e09ab13248f5da0e81a8d530731ed78
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Nov 25 11:03:16 2009 -0500
Eagerly initializing underlying list and map in PropertyList and PropertyMap to avoid
NPEs
This change was already made in the raw-config branch a while back, and needed to be
ported over.
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
index 2bc77f9..c3e26a0 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
@@ -68,7 +68,7 @@ public class PropertyList extends Property {
@Cascade( { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH,
CascadeType.DELETE_ORPHAN })
@OneToMany(mappedBy = "parentList", targetEntity = Property.class, fetch =
FetchType.EAGER)
//@IndexColumn(name = "list_index") TODO GH: This seems broken
- private List<Property> list;
+ private List<Property> list = new ArrayList<Property>();
@Transient
String memberPropertyName;
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
index 114720f..e8e15b7 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
@@ -68,7 +68,7 @@ public class PropertyMap extends Property implements AbstractPropertyMap
{
@Cascade( { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH,
CascadeType.DELETE_ORPHAN })
@MapKey(name = "name")
@OneToMany(mappedBy = "parentMap", fetch = FetchType.EAGER)
- private Map<String, Property> map;
+ private Map<String, Property> map = new LinkedHashMap<String,
Property>();
/**
* Creates a new unnamed and empty {@link PropertyMap} object.
commit 5e17b2f3837504924ab1ec1b7ba48d017f258ef2
Merge: 45e0f2f... ee2e8e8...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 25 10:17:56 2009 -0500
Merge branch 'master' into pc
commit 45e0f2f25b7230d65bc561bc63bd1e1cdd7c65f8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 25 10:15:39 2009 -0500
use the new deepCopy()
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 8cbffc9..2d67f3f 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -96,13 +96,13 @@ public class ServerPluginsBean implements ServerPluginsLocal {
Configuration config = plugin.getPluginConfiguration();
if (config != null) {
config = entityManager.find(Configuration.class, config.getId());
- plugin.setPluginConfiguration(config.deepCopyWithoutProxies());
+ plugin.setPluginConfiguration(config.deepCopy());
}
config = plugin.getScheduledJobsConfiguration();
if (config != null) {
config = entityManager.find(Configuration.class, config.getId());
- plugin.setScheduledJobsConfiguration(config.deepCopyWithoutProxies());
+ plugin.setScheduledJobsConfiguration(config.deepCopy());
}
return plugin;
commit b3a962cfa61b2f05b4258b9a25e6e72819473191
Merge: c995032... 37bb080...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 25 09:57:31 2009 -0500
Merge branch 'master' into pc
commit ee2e8e847b18491a6093135b6ca906d6063679de
Merge: 1bca0f7... 37bb080...
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Nov 25 09:54:22 2009 -0500
Merge branch 'master' of
ssh://git.fedorahosted.org/git/rhq/rhq
commit 1bca0f7c0327498c0dcb7ccb5953d3158c83a563
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Nov 25 09:53:41 2009 -0500
Fixing compilation error that happened as a result of my refactoring
RawConfiguration.deepCopy()
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigCollection.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigCollection.java
index a4ce93b..491612a 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigCollection.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigCollection.java
@@ -165,7 +165,7 @@ public class RawConfigCollection implements Serializable {
String u2 = updated.substring(2);
String original = new String(getCurrent().getContents());
if (!u2.equals(original)) {
- current = current.deepCopy();
+ current = current.deepCopy(false);
current.setContents(updated.getBytes());
//TODO update other values like MD5
modified.put(current.getPath(), current);
commit c995032cbc61261e353c523259810d076d586519
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 25 09:51:34 2009 -0500
fix NPE when plugin config or scheduled jobs config is null
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 1415bb5..8cbffc9 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -93,12 +93,17 @@ public class ServerPluginsBean implements ServerPluginsLocal {
public Plugin getServerPluginRelationships(Plugin plugin) {
plugin = getServerPlugin(plugin.getName()); // refresh all but the content field
- int pluginConfigId = plugin.getPluginConfiguration().getId();
- int scheduledJobsId = plugin.getScheduledJobsConfiguration().getId();
- Configuration pluginConfig = entityManager.find(Configuration.class,
pluginConfigId);
- Configuration scheduledJobs = entityManager.find(Configuration.class,
scheduledJobsId);
- plugin.setPluginConfiguration(pluginConfig.deepCopyWithoutProxies());
- plugin.setScheduledJobsConfiguration(scheduledJobs.deepCopyWithoutProxies());
+ Configuration config = plugin.getPluginConfiguration();
+ if (config != null) {
+ config = entityManager.find(Configuration.class, config.getId());
+ plugin.setPluginConfiguration(config.deepCopyWithoutProxies());
+ }
+
+ config = plugin.getScheduledJobsConfiguration();
+ if (config != null) {
+ config = entityManager.find(Configuration.class, config.getId());
+ plugin.setScheduledJobsConfiguration(config.deepCopyWithoutProxies());
+ }
return plugin;
}
@@ -239,7 +244,8 @@ public class ServerPluginsBean implements ServerPluginsLocal {
File currentFile = new File(pluginDir, doomedPlugin.getPath());
currentFile.delete();
} catch (Exception e) {
- log.error("Failed to delete the undeployed plugin [" +
doomedPlugin.getPath() + "]. Cause: " + ThrowableUtil.getAllMessages(e));
+ log.error("Failed to delete the undeployed plugin [" +
doomedPlugin.getPath() + "]. Cause: "
+ + ThrowableUtil.getAllMessages(e));
}
}
}
@@ -275,7 +281,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void setServerPluginStatus(Subject subject, List<Integer> pluginIds,
PluginStatusType status)
- throws Exception {
+ throws Exception {
if (pluginIds == null || pluginIds.size() == 0) {
return; // nothing to do
}
@@ -291,7 +297,8 @@ public class ServerPluginsBean implements ServerPluginsLocal {
public Plugin registerServerPlugin(Subject subject, Plugin plugin, File pluginFile)
throws Exception {
if (plugin.getDeployment() != PluginDeploymentType.SERVER) {
- throw new IllegalArgumentException("Plugin [" + plugin.getName() +
"] must be a server plugin to be registered");
+ throw new IllegalArgumentException("Plugin [" + plugin.getName()
+ + "] must be a server plugin to be registered");
}
Plugin existingPlugin = null;
@@ -304,7 +311,8 @@ public class ServerPluginsBean implements ServerPluginsLocal {
if (existingPlugin != null) {
if (existingPlugin.getStatus() == PluginStatusType.DELETED) {
- throw new IllegalArgumentException("Cannot register plugin [" +
plugin.getName() + "], it has been marked as deleted");
+ throw new IllegalArgumentException("Cannot register plugin [" +
plugin.getName()
+ + "], it has been marked as deleted");
}
Plugin obsolete = ServerPluginDescriptorUtil.determineObsoletePlugin(plugin,
existingPlugin);
if (obsolete == existingPlugin) { // yes use == for reference equality
@@ -322,7 +330,8 @@ public class ServerPluginsBean implements ServerPluginsLocal {
if (plugin.getId() == 0) {
PluginStatusType status = getServerPluginStatus(plugin.getName());
if (PluginStatusType.DELETED == status) {
- throw new IllegalArgumentException("Cannot register plugin
[" + plugin.getName() + "], it has been previously marked as deleted.");
+ throw new IllegalArgumentException("Cannot register plugin
[" + plugin.getName()
+ + "], it has been previously marked as deleted.");
}
entityManager.persist(plugin);
} else {
@@ -364,7 +373,8 @@ public class ServerPluginsBean implements ServerPluginsLocal {
// to entityManager.merge that plugin POJO, it would null out that blob column.
if (plugin.getDeployment() != PluginDeploymentType.SERVER) {
- throw new IllegalArgumentException("Plugin [" + plugin.getName() +
"] must be a server plugin to be updated");
+ throw new IllegalArgumentException("Plugin [" + plugin.getName()
+ + "] must be a server plugin to be updated");
}
if (plugin.getId() == 0) {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
index 803f7cf..df685d4 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
@@ -42,6 +42,7 @@ public interface ServerPluginsLocal {
*
* @param plugin
* @return the same plugin, with the relationship data loaded
+ * @throws NoResultException when no plugin with that name exists
*/
Plugin getServerPluginRelationships(Plugin plugin);
commit 37bb080675c956c976ffc3110361c11e19ae87a0
Author: Galder Zamarreno <rnd(a)zamarreno.com>
Date: Wed Nov 25 15:20:34 2009 +0100
Operation returns only one result now.
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index 0388d8a..a657f42 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -527,7 +527,7 @@ public class Props {
private String displayName;
private String description;
private Set<SimpleProperty> params = new
LinkedHashSet<SimpleProperty>();
- private Set<SimpleProperty> results = new
LinkedHashSet<SimpleProperty>();
+ private SimpleProperty result;
public OperationProps(String name) {
this.name = name;
@@ -557,8 +557,12 @@ public class Props {
return params;
}
- public Set<SimpleProperty> getResults() {
- return results;
+ public SimpleProperty getResult() {
+ return result;
+ }
+
+ public void setResult(SimpleProperty result) {
+ this.result = result;
}
}
}
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
index ca498b5..0343787 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -60,11 +60,9 @@ name="${props.name}" <#-- TODO separate out plugin name
and service name -->
</#list>
</parameters>
</#if>
- <#if operation.results?has_content>
+ <#if operation.result??>
<results>
- <#list operation.results as results>
- <c:simple-property name="${results.name}" />
- </#list>
+ <c:simple-property name="${operation.result.name}" />
</results>
</#if>
</operation>
commit cc1b2af501010b1734b42d4a70e30a43db65d3ee
Author: Galder Zamarreno <rnd(a)zamarreno.com>
Date: Wed Nov 25 14:37:33 2009 +0100
Returns for operations can now be generated.
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index 76b374b..0388d8a 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -527,6 +527,7 @@ public class Props {
private String displayName;
private String description;
private Set<SimpleProperty> params = new
LinkedHashSet<SimpleProperty>();
+ private Set<SimpleProperty> results = new
LinkedHashSet<SimpleProperty>();
public OperationProps(String name) {
this.name = name;
@@ -555,5 +556,9 @@ public class Props {
public Set<SimpleProperty> getParams() {
return params;
}
+
+ public Set<SimpleProperty> getResults() {
+ return results;
+ }
}
}
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
index a148a61..ca498b5 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -60,6 +60,13 @@ name="${props.name}" <#-- TODO separate out plugin name
and service name -->
</#list>
</parameters>
</#if>
+ <#if operation.results?has_content>
+ <results>
+ <#list operation.results as results>
+ <c:simple-property name="${results.name}" />
+ </#list>
+ </results>
+ </#if>
</operation>
</#list>
<#else>
commit a0ab1b28c3ef8ab152c4decf9e8dbaebbede80dd
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Nov 25 00:08:22 2009 -0500
Deleting directory that accidentally included in a previous commit
diff --git a/modules/core/domain/src/main/java/META-INF/MANIFEST.MF
b/modules/core/domain/src/main/java/META-INF/MANIFEST.MF
deleted file mode 100644
index 3090f97..0000000
--- a/modules/core/domain/src/main/java/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,4 +0,0 @@
-Manifest-Version: 1.0
-Class-Path: i18nlog-1.0.9.jar jaxb-api-2.1.jar stax-api-1.0-2.jar acti
- vation-1.1.jar rhq-core-util-1.4.0-SNAPSHOT.jar jdom-1.0.jar
-
commit 1643800fb94b472d11bedc1d5d4d756b4ad54ee0
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Nov 25 00:07:18 2009 -0500
[US 6] Refactoring Configuration.deepCopy() to properly handle hibernate proxies.
Refactoring implementors of DeepCopyable to take a boolean flag that indicates
whether or not to copy the id field. Unit tests have been updated to reflect the
change.
Conflicts:
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
diff --git a/modules/core/domain/src/main/java/META-INF/MANIFEST.MF
b/modules/core/domain/src/main/java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..3090f97
--- /dev/null
+++ b/modules/core/domain/src/main/java/META-INF/MANIFEST.MF
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Class-Path: i18nlog-1.0.9.jar jaxb-api-2.1.jar stax-api-1.0-2.jar acti
+ vation-1.1.jar rhq-core-util-1.4.0-SNAPSHOT.jar jdom-1.0.jar
+
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
index 3ce2965..62bd8ce 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
@@ -454,55 +454,40 @@ public class Configuration implements Externalizable, Cloneable,
AbstractPropert
* @return the new copy
*/
public Configuration deepCopy(boolean keepIds) {
- Configuration copy;
+ Configuration copy = new Configuration();
- try {
- copy = clone();
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException("CloneNotSupported can't happen");
+ if (keepIds) {
+ copy.id = this.id;
}
- if (!keepIds) {
- copy.id = 0;
-
- for (Property property : copy.properties.values()) {
- clearIds(property);
- }
- }
+ copy.notes = this.notes;
+ copy.version = this.version;
+ createDeepCopyOfProperties(copy, keepIds);
+ createDeepCopyOfRawConfigs(copy, keepIds);
return copy;
}
- private void clearIds(Property property) {
- property.setId(0);
-
- if (property instanceof PropertyList) {
- for (Property childProperty : ((PropertyList) property).getList()) {
- clearIds(childProperty);
- }
- } else if (property instanceof PropertyMap) {
- for (Property childProperty : ((PropertyMap) property).getMap().values()) {
- clearIds(childProperty);
- }
- }
-
- return;
- }
-
public Configuration deepCopyWithoutProxies() {
Configuration copy = new Configuration();
copy.notes = this.notes;
copy.version = this.version;
+ createDeepCopyOfProperties(copy, false);
+ createDeepCopyOfRawConfigs(copy, false);
- for (Property property : this.properties.values()) {
- copy.put(property.deepCopy());
- }
+ return copy;
+ }
+ private void createDeepCopyOfRawConfigs(Configuration copy, boolean keepId) {
for (RawConfiguration rawConfig : rawConfigurations) {
- copy.addRawConfiguration(rawConfig.deepCopy());
+ copy.addRawConfiguration(rawConfig.deepCopy(keepId));
}
+ }
- return copy;
+ private void createDeepCopyOfProperties(Configuration copy, boolean keepId) {
+ for (Property property : this.properties.values()) {
+ copy.put(property.deepCopy(keepId));
+ }
}
/**
@@ -664,7 +649,22 @@ public class Configuration implements Externalizable, Cloneable,
AbstractPropert
out.writeLong(version);
out.writeLong(ctime);
out.writeLong(mtime);
+ }
// Explicitly do not send the history relationship
+ private Map<String, Property> createDeepCopyOfMap() {
+ Map<String, Property> copy = new HashMap<String, Property>();
+ for (Map.Entry<String, Property> entry : this.properties.entrySet()) {
+ copy.put(entry.getKey(), entry.getValue().deepCopy(true));
+ }
+ return copy;
+ }
+
+ private Set<RawConfiguration> createDeepCopyOfRawConfigs() {
+ Set<RawConfiguration> copy = new HashSet<RawConfiguration>();
+ for (RawConfiguration rawConfig : this.rawConfigurations) {
+ copy.add(rawConfig.deepCopy(true));
+ }
+ return copy;
}
@SuppressWarnings("unchecked")
@@ -694,4 +694,4 @@ public class Configuration implements Externalizable, Cloneable,
AbstractPropert
public Map<String, Property> getAllProperties() {
return this.properties;
}
-}
\ No newline at end of file
+}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DeepCopyable.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DeepCopyable.java
index e3e56d5..c680b04 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DeepCopyable.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DeepCopyable.java
@@ -25,6 +25,6 @@ package org.rhq.core.domain.configuration;
public interface DeepCopyable<T> {
- T deepCopy();
+ T deepCopy(boolean keepId);
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Property.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Property.java
index f4494c8..5c1ba79 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Property.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Property.java
@@ -127,7 +127,10 @@ public class Property implements Externalizable,
DeepCopyable<Property> {
public Property() {
}
- protected Property(Property original) {
+ protected Property(Property original, boolean keepId) {
+ if (keepId) {
+ this.id = original.id;
+ }
this.errorMessage = original.errorMessage;
this.name = original.name;
}
@@ -284,7 +287,7 @@ public class Property implements Externalizable,
DeepCopyable<Property> {
return ((this.name != null) ? this.name.hashCode() : 0);
}
- public Property deepCopy() {
+ public Property deepCopy(boolean keepId) {
return null;
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
index a2223d9..2bc77f9 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyList.java
@@ -86,8 +86,8 @@ public class PropertyList extends Property {
setName(name);
}
- protected PropertyList(PropertyList original) {
- super(original);
+ protected PropertyList(PropertyList original, boolean keepId) {
+ super(original, keepId);
}
/**
@@ -212,11 +212,11 @@ public class PropertyList extends Property {
return result;
}
- public PropertyList deepCopy() {
- PropertyList copy = new PropertyList(this);
+ public PropertyList deepCopy(boolean keepId) {
+ PropertyList copy = new PropertyList(this, keepId);
for (Property property : list) {
- copy.add(property.deepCopy());
+ copy.add(property.deepCopy(false));
}
return copy;
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
index 137c6fe..114720f 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyMap.java
@@ -76,8 +76,8 @@ public class PropertyMap extends Property implements AbstractPropertyMap
{
public PropertyMap() {
}
- protected PropertyMap(PropertyMap original) {
- super(original);
+ protected PropertyMap(PropertyMap original, boolean keepId) {
+ super(original, keepId);
}
/**
@@ -263,11 +263,11 @@ public class PropertyMap extends Property implements
AbstractPropertyMap {
return result;
}
- public PropertyMap deepCopy() {
- PropertyMap copy = new PropertyMap(this);
+ public PropertyMap deepCopy(boolean keepId) {
+ PropertyMap copy = new PropertyMap(this, keepId);
for (Property property : map.values()) {
- copy.put(property.deepCopy());
+ copy.put(property.deepCopy(keepId));
}
return copy;
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertySimple.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertySimple.java
index 0824553..04aeb7e 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertySimple.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertySimple.java
@@ -70,8 +70,8 @@ public class PropertySimple extends Property implements Externalizable
{
override = Boolean.FALSE;
}
- protected PropertySimple(PropertySimple original) {
- super(original);
+ protected PropertySimple(PropertySimple original, boolean keepId) {
+ super(original, keepId);
this.override = original.override;
this.unmaskedStringValue = original.unmaskedStringValue;
this.stringValue = original.stringValue;
@@ -85,9 +85,7 @@ public class PropertySimple extends Property implements Externalizable
{
* @param name
* @param value
*/
- public PropertySimple(@NotNull
- String name, @Nullable
- Object value) {
+ public PropertySimple(@NotNull String name, @Nullable Object value) {
setName(name);
setValue(value);
}
@@ -98,8 +96,7 @@ public class PropertySimple extends Property implements Externalizable
{
*
* @param value
*/
- public void setValue(@Nullable
- Object value) {
+ public void setValue(@Nullable Object value) {
if (value == null) {
stringValue = null;
return;
@@ -131,8 +128,7 @@ public class PropertySimple extends Property implements Externalizable
{
*
* @param value
*/
- public void setStringValue(@Nullable
- String value) {
+ public void setStringValue(@Nullable String value) {
this.setValue(value);
}
@@ -157,8 +153,7 @@ public class PropertySimple extends Property implements Externalizable
{
*
* @param value
*/
- public void setBooleanValue(@Nullable
- Boolean value) {
+ public void setBooleanValue(@Nullable Boolean value) {
this.setValue(value);
}
@@ -207,8 +202,7 @@ public class PropertySimple extends Property implements Externalizable
{
*
* @param value
*/
- public void setIntegerValue(@Nullable
- Integer value) {
+ public void setIntegerValue(@Nullable Integer value) {
this.setValue(value);
}
@@ -232,8 +226,7 @@ public class PropertySimple extends Property implements Externalizable
{
*
* @param value
*/
- public void setFloatValue(@Nullable
- Float value) {
+ public void setFloatValue(@Nullable Float value) {
this.setValue(value);
}
@@ -257,8 +250,7 @@ public class PropertySimple extends Property implements Externalizable
{
*
* @param value
*/
- public void setDoubleValue(@Nullable
- Double value) {
+ public void setDoubleValue(@Nullable Double value) {
this.setValue(value);
}
@@ -336,8 +328,8 @@ public class PropertySimple extends Property implements Externalizable
{
return result;
}
- public PropertySimple deepCopy() {
- return new PropertySimple(this);
+ public PropertySimple deepCopy(boolean keepId) {
+ return new PropertySimple(this, keepId);
}
@Override
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java
index ca02070..22a7161 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java
@@ -243,9 +243,14 @@ public class RawConfiguration implements Serializable,
DeepCopyable<RawConfigura
.toString();
}
- public RawConfiguration deepCopy() {
+ public RawConfiguration deepCopy(boolean keepId) {
RawConfiguration copy = new RawConfiguration();
+ if (keepId) {
+ copy.id = this.id;
+ }
+
copy.path = this.path;
+
if (this.contents != null) {
copy.setContents(this.getContents());
}
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java
index 36084ec..85afc00 100644
---
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java
@@ -38,59 +38,107 @@ import java.util.Set;
public class ConfigurationTest {
@Test
- public void deepCopyWithoutProxiesShouldNotReturnReferenceToOriginalObject() {
+ public void deepCopyShouldNotReturnReferenceToOriginalObjectWhenKeepingIds() {
Configuration original = createConfiguration();
- Configuration copy = original.deepCopyWithoutProxies();
+ Configuration copy = original.deepCopy(true);
assertNotSame(copy, original, "Expected a reference to a new Configuration
object, not the original object being copied");
}
@Test
- public void deepCopyWithoutProxiesShouldCopySimpleFields() {
+ public void deepCopyShouldNotReturnReferenceToOriginalObjectWhenNotKeepingIds() {
Configuration original = createConfiguration();
- Configuration copy = original.deepCopyWithoutProxies();
+ Configuration copy = original.deepCopy(false);
+ assertNotSame(copy, original, "Expected a reference to a new Configuration
object, not the original object being copied");
+ }
+
+ @Test
+ public void deepCopyShouldCopyAllSimpleFieldsWhenKeepingIds() {
+ Configuration original = createConfiguration();
+ Configuration copy = original.deepCopy(true);
+
+ assertEquals(copy.getId(), original.getId(), "Failed to copy the id
property");
assertEquals(copy.getNotes(), original.getNotes(), "Failed to copy the notes
property");
assertEquals(copy.getVersion(), original.getVersion(), "Failed to copy
version property");
}
@Test
- public void deepCopyWithoutProxiesShouldNotCopyIdProperty() {
+ public void deepCopyShouldNotCopyIdWhenNotKeepingIds() {
Configuration original = createConfiguration();
- Configuration copy = original.deepCopyWithoutProxies();
+ Configuration copy = original.deepCopy(false);
assertFalse(copy.getId() == original.getId(), "The original id property
should not be copied");
+ assertEquals(copy.getNotes(), original.getNotes(), "Failed to copy the notes
property");
+ assertEquals(copy.getVersion(), original.getVersion(), "Failed to copy
version property");
+ }
+
+ @Test
+ public void deepCopyShouldCopyPropertiesWhenKeepingIds() {
+ Configuration original = createConfiguration();
+ original.put(new PropertySimple("simpleProperty", "Simple
Property"));
+
+ Configuration copy = original.deepCopy(true);
+
+ assertNotSame(copy.getProperties(), original.getProperties(), "The
properties property should not refer to the properties in the original object");
+ assertEquals(copy.getProperties(), original.getProperties(), "Failed to copy
the contents of the properties collection");
}
@Test
- public void deepCopyWithoutProxiesShouldCopyProperties() {
+ public void deepCopyShouldCopyPropertiesWhenNotKeepingIds() {
Configuration original = createConfiguration();
original.put(new PropertySimple("simpleProperty", "Simple
Property"));
- Configuration copy = original.deepCopyWithoutProxies();
+ Configuration copy = original.deepCopy(false);
assertNotSame(copy.getProperties(), original.getProperties(), "The
properties property should not refer to the properties in the original object");
assertEquals(copy.getProperties(), original.getProperties(), "Failed to copy
the contents of the properties collection");
}
@Test
- public void deepCopyWithoutProxiesShouldNotReturnCopyReferenceOfOriginalProperty() {
+ public void deepCopyShouldNotReturnCopyReferenceOfOriginalPropertyWhenKeepingIds() {
Configuration original = createConfiguration();
String propertyName = "simpleProperty";
original.put(new PropertySimple(propertyName, "Simple Property"));
- Configuration copy = original.deepCopyWithoutProxies();
+ Configuration copy = original.deepCopy(true);
assertNotSame(copy.get(propertyName), original.get(propertyName), "Expected
a refernce to a new property, not the original property being copied");
}
@Test
- public void deepCopyWithoutProxiesShouldSetParentReferenceOfCopiedProperties() {
+ public void deepCopyShouldNotReturnCopyReferenceOfOriginalPropertyWhenNotKeepingIds()
{
+ Configuration original = createConfiguration();
+ String propertyName = "simpleProperty";
+ original.put(new PropertySimple(propertyName, "Simple Property"));
+
+ Configuration copy = original.deepCopy(false);
+
+ assertNotSame(copy.get(propertyName), original.get(propertyName), "Expected
a refernce to a new property, not the original property being copied");
+ }
+
+ @Test
+ public void deepCopyShouldSetParentReferenceOfCopiedPropertiesWhenKeepingIds() {
+ Configuration original = createConfiguration();
+ String propertyName = "simpleProperty";
+ original.put(new PropertySimple(propertyName, "Simple Property"));
+
+ Configuration copy = original.deepCopy(true);
+
+ assertSame(
+ copy.get(propertyName).getConfiguration(),
+ copy,
+ "The reference to the parent configuration should point to the newly
copied configuration, not the original configuration"
+ );
+ }
+
+ @Test
+ public void deepCopyShouldSetParentReferenceOfCopiedPropertiesWhenNotKeepingIds() {
Configuration original = createConfiguration();
String propertyName = "simpleProperty";
original.put(new PropertySimple(propertyName, "Simple Property"));
- Configuration copy = original.deepCopyWithoutProxies();
+ Configuration copy = original.deepCopy(false);
assertSame(
copy.get(propertyName).getConfiguration(),
@@ -100,11 +148,27 @@ public class ConfigurationTest {
}
@Test
- public void deepCopyWithoutProxiesShouldCopyRawConfigurations() {
+ public void deepCopyShouldCopyRawConfigurationsWhenKeepingIds() {
Configuration original = createConfiguration();
original.addRawConfiguration(createRawConfiguration("/tmp/foo"));
- Configuration copy = original.deepCopyWithoutProxies();
+ Configuration copy = original.deepCopy(true);
+
+ assertNotSame(
+ copy.getRawConfigurations(),
+ original.getRawConfigurations(),
+ "The rawConfigurations property should not refer to the original
rawConfigurations of the copied object."
+ );
+
+ assertRawConfigurationsEquals(copy.getRawConfigurations(),
original.getRawConfigurations(), "Failed to copy rawConfigurations property.");
+ }
+
+ @Test
+ public void deepCopyShouldCopyRawConfigurationsWhenNotKeepingIds() {
+ Configuration original = createConfiguration();
+ original.addRawConfiguration(createRawConfiguration("/tmp/foo"));
+
+ Configuration copy = original.deepCopy(false);
assertNotSame(
copy.getRawConfigurations(),
@@ -123,11 +187,26 @@ public class ConfigurationTest {
}
@Test
- public void deepCopyWithoutProxiesShouldSetParentReferenceOfCopiedRawConfigurations()
{
+ public void deepCopyShouldSetParentReferenceOfCopiedRawConfigurationsWhenKeepingIds()
{
+ Configuration original = createConfiguration();
+ original.addRawConfiguration(createRawConfiguration("/tmp/foo"));
+
+ Configuration copy = original.deepCopy(true);
+ RawConfiguration copiedRawConfig = getCopiedRawConfiguration(copy);
+
+ assertSame(
+ copiedRawConfig.getConfiguration(),
+ copy,
+ "The reference to the parent configuration should point to the newly
copied configuration, not the original configuration."
+ );
+ }
+
+ @Test
+ public void
deepCopyShouldSetParentReferenceOfCopiedRawConfigurationsWhenNotKeepingIds() {
Configuration original = createConfiguration();
original.addRawConfiguration(createRawConfiguration("/tmp/foo"));
- Configuration copy = original.deepCopyWithoutProxies();
+ Configuration copy = original.deepCopy(false);
RawConfiguration copiedRawConfig = getCopiedRawConfiguration(copy);
assertSame(
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyListTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyListTest.java
index d298001..56d3887 100644
---
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyListTest.java
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyListTest.java
@@ -30,41 +30,52 @@ import org.testng.annotations.Test;
public class PropertyListTest {
@Test
- public void deepCopyShouldCopySimpleFields() {
+ public void deepCopyShouldCopyAllSimpleFields() {
PropertyList original = createPropertyList();
- PropertyList copy = original.deepCopy();
+ PropertyList copy = original.deepCopy(true);
assertNotSame(copy, original, "The copy should not reference the original
object");
-
+
+ assertEquals(copy.getId(), original.getId(), "Failed to copy the id
property");
assertEquals(copy.getName(), original.getName(), "Failed to copy the name
property");
assertEquals(copy.getErrorMessage(), original.getErrorMessage(), "Failed to
copy the errorMessage property");
}
@Test
- public void deepCopyShouldNotCopyIdField() {
+ public void deepCopyShouldNotCopyIdFieldWhenFlagIsFalse() {
PropertyList original = createPropertyList();
- PropertyList copy = original.deepCopy();
+ PropertyList copy = original.deepCopy(false);
assertFalse(copy.getId() == original.getId(), "The original id property
should not be copied.");
+ assertEquals(copy.getName(), original.getName(), "Failed to copy the name
property");
+ assertEquals(copy.getErrorMessage(), original.getErrorMessage(), "Failed to
copy the errorMessage property");
+ }
+
+ @Test
+ public void deepCopyShouldNotCopyReferenceOfUnderlyingListWhenIdIncluded() {
+ PropertyList original = createPropertyList();
+ PropertyList copy = original.deepCopy(true);
+
+ assertNotSame(original.getList(), copy.getList(), "The values in the
underlying list should be copied, not the variable reference to the list.");
}
@Test
- public void deepCopyShouldNotCopyReferenceOfUnderlyingList() {
+ public void deepCopyShouldNotCopyReferenceOfUnderlyingListWhenIdNotIncluded() {
PropertyList original = createPropertyList();
- PropertyList copy = original.deepCopy();
+ PropertyList copy = original.deepCopy(false);
assertNotSame(original.getList(), copy.getList(), "The values in the
underlying list should be copied, not the variable reference to the list.");
}
@Test
- public void deepCopyShouldCopyProperty() {
+ public void deepCopyShouldCopyPropertyWhenIdIncluded() {
PropertyList original = createPropertyList();
PropertySimple simpleProperty = new PropertySimple("simeplProperty",
"Simple Property");
original.add(simpleProperty);
- PropertyList copy = original.deepCopy();
+ PropertyList copy = original.deepCopy(true);
assertEquals(copy.getList().size(), original.getList().size(), "Failed to
copy simple property contained in original property list");
@@ -72,13 +83,39 @@ public class PropertyListTest {
}
@Test
- public void deepCopyShouldSetParentOfCopiedProperty() {
+ public void deepCopyShouldCopyPropertyWhenIdNotIncluded() {
+ PropertyList original = createPropertyList();
+
+ PropertySimple simpleProperty = new PropertySimple("simeplProperty",
"Simple Property");
+ original.add(simpleProperty);
+
+ PropertyList copy = original.deepCopy(false);
+
+ assertEquals(copy.getList().size(), original.getList().size(), "Failed to
copy simple property contained in original property list");
+
+ assertNotSame(copy.getList().get(0), original.getList().get(0), "Properties
in the list should be copied by value as opposed to just copying the references");
+ }
+
+ @Test
+ public void deepCopyShouldSetParentOfCopiedPropertyWhenIdIncluded() {
+ PropertyList original = createPropertyList();
+
+ PropertySimple simpleProperty = new PropertySimple("simpleProperty",
"Simple Property");
+ original.add(simpleProperty);
+
+ PropertyList copy = original.deepCopy(true);
+
+ assertSame(copy.getList().get(0).getParentList(), copy, "The parentList
property of copied properties should be set to the new PropertyList");
+ }
+
+ @Test
+ public void deepCopyShouldSetParentOfCopiedPropertyWhenIdNotIncluded() {
PropertyList original = createPropertyList();
PropertySimple simpleProperty = new PropertySimple("simpleProperty",
"Simple Property");
original.add(simpleProperty);
- PropertyList copy = original.deepCopy();
+ PropertyList copy = original.deepCopy(false);
assertSame(copy.getList().get(0).getParentList(), copy, "The parentList
property of copied properties should be set to the new PropertyList");
}
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyMapTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyMapTest.java
index 4a999b6..e73d835 100644
---
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyMapTest.java
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertyMapTest.java
@@ -30,40 +30,55 @@ import org.testng.annotations.Test;
public class PropertyMapTest {
@Test
- public void deepCopyShouldCopySimpleFields() {
+ public void deepCopyShouldCopyAllSimpleFields() {
PropertyMap original = createPropertyMap();
- PropertyMap copy = original.deepCopy();
+ PropertyMap copy = original.deepCopy(true);
assertNotSame(copy, original, "The copy should not reference the original
object");
+ assertEquals(copy.getId(), original.getId(), "Failed to copy the id
property");
assertEquals(copy.getName(), original.getName(), "Failed to copy the name
property");
assertEquals(copy.getErrorMessage(), original.getErrorMessage(), "Failed to
copy the errorMessage property");
}
@Test
- public void deepCopyShouldNotCopyIdField() {
+ public void deepCopyShouldNotCopyIdFieldWhenFlagIsFalse() {
PropertyMap original = createPropertyMap();
- PropertyMap copy = original.deepCopy();
+ PropertyMap copy = original.deepCopy(false);
+
+ assertNotSame(copy, original, "The copy should not reference the original
object");
assertFalse(copy.getId() == original.getId(), "The original id property
should not be copied.");
+ assertEquals(copy.getName(), original.getName(), "Failed to copy the name
property");
+ assertEquals(copy.getErrorMessage(), original.getErrorMessage(), "Failed to
copy the errorMessage property");
}
@Test
- public void deepCopyShouldNotCopyReferenceOfUnderlyingMap() {
+ public void deepCopyShouldCopyPropertyWhenIdIncluded() {
PropertyMap original = createPropertyMap();
- PropertyMap copy = original.deepCopy();
- assertNotSame(copy.getMap(), original.getMap(), "The values in the
underlying map should be copied, not the reference to the map itself");
+ PropertySimple simpleProperty = new PropertySimple("simeplProperty",
"Simple Property");
+ original.put(simpleProperty);
+
+ PropertyMap copy = original.deepCopy(true);
+
+ assertEquals(copy.getMap().size(), original.getMap().size(), "Failed to copy
simple property contained in original property map");
+
+ assertNotSame(
+ copy.getMap().get(simpleProperty.getName()),
+ original.getMap().get(simpleProperty.getName()),
+ "Properties in the map should be copied by value as opposed to just
copying the references"
+ );
}
@Test
- public void deepCopyShouldCopyProperty() {
+ public void deepCopyShouldCopyPropertyWhenIdNotIncluded() {
PropertyMap original = createPropertyMap();
PropertySimple simpleProperty = new PropertySimple("simeplProperty",
"Simple Property");
original.put(simpleProperty);
- PropertyMap copy = original.deepCopy();
+ PropertyMap copy = original.deepCopy(false);
assertEquals(copy.getMap().size(), original.getMap().size(), "Failed to copy
simple property contained in original property map");
@@ -75,13 +90,29 @@ public class PropertyMapTest {
}
@Test
- public void deepCopyShouldSetParentOfCopiedProperty() {
+ public void deepCopyShouldSetParentOfCopiedPropertyWhenIdIncluded() {
+ PropertyMap original = createPropertyMap();
+
+ PropertySimple simpleProperty = new PropertySimple("simpleProperty",
"Simple Property");
+ original.put(simpleProperty);
+
+ PropertyMap copy = original.deepCopy(true);
+
+ assertSame(
+ copy.get(simpleProperty.getName()).getParentMap(),
+ copy,
+ "The parentMap property of copied properties should be set to the new
PropertyMap"
+ );
+ }
+
+ @Test
+ public void deepCopyShouldSetParentOfCopiedPropertyWhenIdNotIncluded() {
PropertyMap original = createPropertyMap();
PropertySimple simpleProperty = new PropertySimple("simpleProperty",
"Simple Property");
original.put(simpleProperty);
- PropertyMap copy = original.deepCopy();
+ PropertyMap copy = original.deepCopy(false);
assertSame(
copy.get(simpleProperty.getName()).getParentMap(),
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertySimpleTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertySimpleTest.java
index c1b76aa..7b49837 100644
---
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertySimpleTest.java
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PropertySimpleTest.java
@@ -30,13 +30,14 @@ import org.testng.annotations.Test;
public class PropertySimpleTest {
@Test
- public void deepCopyShouldCopySimpleFields() {
+ public void deepCopyShouldCopyAllSimpleFields() {
PropertySimple original = createProperty();
- PropertySimple copy = original.deepCopy();
+ PropertySimple copy = original.deepCopy(true);
assertNotSame(copy, original, "The copy should not reference the original
object");
-
+
+ assertEquals(copy.getId(), original.getId(), "Failed to copy the id
property");
assertEquals(copy.getName(), original.getName(), "Failed to copy the name
property");
assertEquals(copy.getErrorMessage(), original.getErrorMessage(), "Failed to
copy the errorMessage property");
assertEquals(copy.getOverride(), original.getOverride(), "Failed to copy the
override property");
@@ -45,12 +46,17 @@ public class PropertySimpleTest {
}
@Test
- public void deepCopyShouldNotCopyIdField() {
+ public void deepCopyShouldNotCopyIdFieldWhenFlagIsFalse() {
PropertySimple original = createProperty();
- PropertySimple copy = original.deepCopy();
+ PropertySimple copy = original.deepCopy(false);
assertFalse(copy.getId() == original.getId(), "The original id property
should not be copied.");
+ assertEquals(copy.getName(), original.getName(), "Failed to copy the name
property");
+ assertEquals(copy.getErrorMessage(), original.getErrorMessage(), "Failed to
copy the errorMessage property");
+ assertEquals(copy.getOverride(), original.getOverride(), "Failed to copy the
override property");
+ assertEquals(copy.getUnmaskedStringValue(), original.getUnmaskedStringValue(),
"Failed to copy the unmaskedStringValue property");
+ assertEquals(copy.getStringValue(), original.getStringValue(), "Failed to
copy the stringValue property");
}
private PropertySimple createProperty() {
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
index fb926af..8f0aac8 100644
---
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
@@ -212,33 +212,49 @@ public class RawConfigurationTest {
}
@Test
- public void deepCopyShouldCopyPath() {
+ public void deepCopyShouldCopyPathAndIdWhenIdIncluded() {
RawConfiguration original = new RawConfiguration();
original.setPath("/tmp/foo");
+ original.setId(-1);
- RawConfiguration copy = original.deepCopy();
+ RawConfiguration copy = original.deepCopy(true);
+ assertEquals(copy.getId(), copy.getId(), "Failed to copy the id
property.");
assertEquals(copy.getPath(), original.getPath(), "Failed to copy the path
property.");
}
@Test
- public void deepCopyShouldCopyContents() {
+ public void deepCopyShouldCopyPathAndIdWhenIdNotIncluded() {
+ RawConfiguration original = new RawConfiguration();
+ original.setPath("/tmp/foo");
+ original.setId(-1);
+
+ RawConfiguration copy = original.deepCopy(false);
+
+ assertFalse(copy.getId() == original.getId(), "The original id property
should not be copied.");
+ assertEquals(copy.getPath(), original.getPath(), "Failed to copy the path
property.");
+ }
+
+ @Test
+ public void deepCopyShouldCopyContentsWhenCopyingId() {
RawConfiguration original = new RawConfiguration();
original.setContents(new byte[] {1, 2, 3, 4, 5});
- RawConfiguration copy = original.deepCopy();
+ RawConfiguration copy = original.deepCopy(true);
assertFalse(original.getContents() == copy.getContents(), "The values in the
contents array should be copied, not the reference to the original object.");
assertEquals(copy.getContents(), original.getContents(), "Failed to copy
contents property.");
}
@Test
- public void deepCopyShouldNotCopyIdProperty() {
+ public void deepCopyShouldCopyContentsWhenNotCopyingId() {
RawConfiguration original = new RawConfiguration();
- original.setId(1);
+ original.setContents(new byte[] {1, 2, 3, 4, 5});
- RawConfiguration copy = original.deepCopy();
+ RawConfiguration copy = original.deepCopy(false);
- assertFalse(original.getId() == copy.getId(), "The id property should not be
copied.");
+ assertFalse(original.getContents() == copy.getContents(), "The values in the
contents array should be copied, not the reference to the original object.");
+ assertEquals(copy.getContents(), original.getContents(), "Failed to copy
contents property.");
}
+
}
commit 9994ec529ecf93914ab48d25023327ee0eb3f503
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Nov 24 16:41:38 2009 -0500
add a test to confirm that snapshot versions are considered older than candidate
releases or releases
diff --git
a/modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
b/modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
index d9c2a9f..dfee3a5 100644
---
a/modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
+++
b/modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
@@ -161,5 +161,14 @@ public class ComparableVersionTest {
assert ver2.compareTo(ver2) == 0;
assert ver1.compareTo(ver2) > 0; // ver1 is after ver2!
assert ver2.compareTo(ver1) < 0; // ver1 is after ver2!
+
+ ver1 = new ComparableVersion("4.0.0-SNAPSHOT");
+ ver2 = new ComparableVersion("4.0.0.CR2"); // CR is an alias for RC
+ assert !ver1.equals(ver2);
+ assert !ver2.equals(ver1);
+ assert ver1.compareTo(ver1) == 0;
+ assert ver2.compareTo(ver2) == 0;
+ assert ver1.compareTo(ver2) < 0;
+ assert ver2.compareTo(ver1) > 0;
}
}
commit 93cd6e74d101d7dc645ac38168b4d0157752bf8d
Author: Justin Harris <jharris(a)redhat.com>
Date: Tue Nov 24 14:57:46 2009 -0500
Moving in some seam functionality to allow for page scoped beans in form submission.
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginComponent.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginComponent.java
new file mode 100644
index 0000000..0bb87bd
--- /dev/null
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginComponent.java
@@ -0,0 +1,73 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.admin.plugin;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.web.RequestParameter;
+import org.rhq.core.domain.plugin.Plugin;
+import org.rhq.core.domain.plugin.PluginDeploymentType;
+import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * Component responsible for looking up a {@link Plugin}, obtaining
+ * the <code>name</code> and <code>type</code> from request
parameters.
+ *
+ * @author jharris
+ */
+@Name("installedPlugin")
+public class InstalledPluginComponent {
+
+ @RequestParameter("plugin")
+ private String name;
+ @RequestParameter("pluginType")
+ private PluginDeploymentType type;
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public PluginDeploymentType getType() {
+ return this.type;
+ }
+
+ public void setType(PluginDeploymentType type) {
+ this.type = type;
+ }
+
+ @Factory(value="plugin", autoCreate=true, scope=ScopeType.PAGE)
+ public Plugin lookupPlugin() {
+ if (this.type == PluginDeploymentType.AGENT) {
+ return LookupUtil.getResourceMetadataManager().getPlugin(this.name);
+ } else if (this.type == PluginDeploymentType.SERVER) {
+ ServerPluginsLocal serverPluginsBean = LookupUtil.getServerPlugins();
+ Plugin plugin = serverPluginsBean.getServerPlugin(this.name);
+ return serverPluginsBean.getServerPluginRelationships(plugin);
+ }
+
+ return null;
+ }
+}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
index b6db223..3fe6988 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
@@ -21,8 +21,13 @@ package org.rhq.enterprise.gui.admin.plugin;
import javax.faces.application.FacesMessage;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
@@ -40,21 +45,24 @@ import
org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDe
* @author Greg Hinkle
* @author John Mazzitelli
*/
+(a)Scope(ScopeType.PAGE)
+@Name("InstalledPluginUIBean")
public class InstalledPluginUIBean {
- private final Log log = LogFactory.getLog(InstalledPluginUIBean.class);
+ private static final String OUTCOME_SUCCESS = "success";
public static final String MANAGED_BEAN_NAME =
InstalledPluginUIBean.class.getSimpleName();
-
+ private final Log log = LogFactory.getLog(InstalledPluginUIBean.class);
+ @In
private Plugin plugin;
private ConfigurationDefinition pluginConfigurationDefinition;
private ConfigurationDefinition scheduledJobsDefinition;
- public InstalledPluginUIBean() {
- lookupPlugin();
+ public Plugin getPlugin() {
+ return plugin;
}
- public Plugin getPlugin() {
- return this.plugin;
+ public void setPlugin(Plugin plugin) {
+ this.plugin = plugin;
}
public ConfigurationDefinition getPluginConfigurationDefinition() {
@@ -65,40 +73,39 @@ public class InstalledPluginUIBean {
return this.scheduledJobsDefinition;
}
- public void updatePlugin() {
+ public boolean isEditable() {
+ return this.pluginConfigurationDefinition != null || this.scheduledJobsDefinition
!= null;
+ }
+
+ public String updatePlugin() {
ServerPluginsLocal serverPlugins = LookupUtil.getServerPlugins();
try {
serverPlugins.updateServerPluginExceptContent(EnterpriseFacesContextUtility.getSubject(),
plugin);
-
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Configuration settings saved.");
+ "Configuration settings saved.");
+
+ return OUTCOME_SUCCESS;
} catch (Exception e) {
log.error("Error updating the plugin configurations.", e);
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
- "There was an error changing the
configuration settings.", e);
- }
+ "There was an error changing the configuration settings.",
e);
- lookupPlugin();
+ return null;
+ }
}
- private void lookupPlugin() {
+ @Create
+ public void lookupConfigDefinitions() {
hasPermission();
- String pluginName =
FacesContextUtility.getRequiredRequestParameter("plugin", String.class);
- String pluginType =
FacesContextUtility.getRequiredRequestParameter("pluginType", String.class);
- PluginDeploymentType deploymentType = PluginDeploymentType.valueOf(pluginType);
- if (deploymentType == PluginDeploymentType.AGENT) {
- this.plugin = LookupUtil.getResourceMetadataManager().getPlugin(pluginName);
- } else {
- ServerPluginsLocal serverPluginsBean = LookupUtil.getServerPlugins();
- this.plugin = serverPluginsBean.getServerPlugin(pluginName);
- this.plugin = serverPluginsBean.getServerPluginRelationships(this.plugin);
+ String pluginName = this.plugin.getName();
+
+ if (this.plugin.getDeployment() == PluginDeploymentType.SERVER) {
try {
+ ServerPluginsLocal serverPluginsBean = LookupUtil.getServerPlugins();
ServerPluginDescriptorType descriptor =
serverPluginsBean.getServerPluginDescriptor(pluginName);
- this.pluginConfigurationDefinition =
ConfigurationMetadataParser.parse("pc:" + pluginName, descriptor
- .getPluginConfiguration());
- this.scheduledJobsDefinition =
ConfigurationMetadataParser.parse("jobs:" + pluginName, descriptor
- .getScheduledJobs());
+ this.pluginConfigurationDefinition =
ConfigurationMetadataParser.parse("pc:" + pluginName,
descriptor.getPluginConfiguration());
+ this.scheduledJobsDefinition =
ConfigurationMetadataParser.parse("jobs:" + pluginName,
descriptor.getScheduledJobs());
} catch (Exception e) {
String err = "Cannot determine what the plugin configuration or
scheduled jobs configuration looks like";
log.error(err + " - Cause: " + e);
@@ -114,8 +121,7 @@ public class InstalledPluginUIBean {
private void hasPermission() {
Subject subject = EnterpriseFacesContextUtility.getSubject();
if (!LookupUtil.getAuthorizationManager().hasGlobalPermission(subject,
Permission.MANAGE_SETTINGS)) {
- throw new PermissionException("User [" + subject.getName()
- + "] does not have the proper permissions to view or manage
plugins");
+ throw new PermissionException("User [" + subject.getName() +
"] does not have the proper permissions to view or manage plugins");
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
index bacb535..64bd31e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
@@ -11,6 +11,7 @@
<component name="org.jboss.seam.core.init">
<property name="debug">false</property> <!-- enable only
when needed -->
<property
name="transactionManagementEnabled">false</property>
+ <property
name="jndi-pattern">rhq/#{ejbName}/local</property>
</component>
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/admin-beans.xml
b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/admin-beans.xml
index 11dadd0..a80402b 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/admin-beans.xml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/admin-beans.xml
@@ -20,13 +20,6 @@
<managed-bean-class>org.rhq.enterprise.gui.admin.plugin.InstalledPluginsUIBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
- <managed-bean>
- <description>Visibility for the installed agent and server
plugins</description>
- <display-name>Installed Plugin</display-name>
- <managed-bean-name>InstalledPluginUIBean</managed-bean-name>
-
<managed-bean-class>org.rhq.enterprise.gui.admin.plugin.InstalledPluginUIBean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
- </managed-bean>
<managed-bean>
<description>Access to downloads information</description>
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/admin-navigation.xml
b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/admin-navigation.xml
index 93932df..7f19f4d 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/admin-navigation.xml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/admin-navigation.xml
@@ -28,6 +28,17 @@
</navigation-case>
</navigation-rule>
+
+ <navigation-rule>
+
<from-view-id>/rhq/admin/plugin/plugin-details-edit.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+
<to-view-id>/rhq/admin/plugin/plugin-details-view.xhtml?plugin=#{plugin.name}&pluginType=#{plugin.deployment}</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ </navigation-rule>
<navigation-rule>
<navigation-case>
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-edit.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-edit.xhtml
new file mode 100644
index 0000000..d88afe7
--- /dev/null
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-edit.xhtml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:onc="http://jboss.org/on/component"
+
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
+
+<ui:composition template="/rhq/admin/plugin/plugin-details.xhtml">
+ <ui:param name="editMode" value="true"/>
+
+ <ui:define name="post-config">
+ <rich:panel rendered="#{InstalledPluginUIBean.editable}">
+ <h:commandButton value="SAVE" type="submit"
action="#{InstalledPluginUIBean.updatePlugin}"
+ alt="Click to Save Changes"
styleClass="buttonmed" />
+ <h:commandButton value="RESET" type="reset"
immediate="true"
+ title="Click to Reset Fields"
styleClass="buttonmed"/>
+ </rich:panel>
+ </ui:define>
+</ui:composition>
+
+</html>
\ No newline at end of file
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-view.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-view.xhtml
new file mode 100644
index 0000000..389923a
--- /dev/null
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details-view.xhtml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:onc="http://jboss.org/on/component"
+
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
+
+<ui:composition template="/rhq/admin/plugin/plugin-details.xhtml">
+ <ui:param name="editMode" value="false"/>
+
+ <ui:define name="pre-config">
+ <h:panelGrid columns="1" styleClass="buttons-table"
columnClasses="button-cell"
+ rendered="#{InstalledPluginUIBean.editable}">
+ <h:outputLink value="/rhq/admin/plugin/plugin-details-edit.xhtml"
+ styleClass="buttonmed">
+ <f:param name="plugin"
value="#{installedPlugin.name}"/>
+ <f:param name="pluginType"
value="#{installedPlugin.type}"/>
+ <h:outputText value="EDIT"/>
+ </h:outputLink>
+ </h:panelGrid>
+ </ui:define>
+ </ui:composition>
+
+</html>
\ No newline at end of file
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
index fa46dc8..cc11203 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
@@ -35,8 +35,6 @@
layout="table"
width="100%"/>
-
-
<h:form id="pluginsForm">
<rich:panel>
@@ -66,7 +64,6 @@
</h:panelGrid>
-
<rich:panel>
<f:facet name="header">
<h:outputText value="Plugin Help"/>
@@ -76,6 +73,7 @@
</rich:panel>
+ <ui:insert name="pre-config" />
<rich:panel
rendered="#{InstalledPluginUIBean.plugin.pluginConfiguration != null}">
<f:facet name="header">
@@ -83,7 +81,8 @@
</f:facet>
<onc:config
configurationDefinition="#{InstalledPluginUIBean.pluginConfigurationDefinition}"
-
configuration="#{InstalledPluginUIBean.plugin.pluginConfiguration}" />
+
configuration="#{InstalledPluginUIBean.plugin.pluginConfiguration}"
+ readOnly="#{not editMode}" />
</rich:panel>
<rich:panel
rendered="#{InstalledPluginUIBean.plugin.scheduledJobsConfiguration !=
null}">
@@ -92,17 +91,11 @@
</f:facet>
<onc:config
configurationDefinition="#{InstalledPluginUIBean.scheduledJobsDefinition}"
-
configuration="#{InstalledPluginUIBean.plugin.scheduledJobsConfiguration}"
/>
+
configuration="#{InstalledPluginUIBean.plugin.scheduledJobsConfiguration}"
+ readOnly="#{not editMode}" />
</rich:panel>
- <input type="hidden" name="plugin"
value="#{param.plugin}"/>
- <input type="hidden" name="pluginType"
value="#{param.pluginType}"/>
-
- <rich:panel
rendered="#{InstalledPluginUIBean.plugin.pluginConfiguration != null ||
-
InstalledPluginUIBean.plugin.scheduledJobsConfiguration != null}">
- <h:commandButton value="OK" type="submit"
action="#{InstalledPluginUIBean.updatePlugin}"
- alt="Click to Save Plugin"
styleClass="buttonmed" />
- </rich:panel>
+ <ui:insert name="post-config" />
</rich:panel>
</h:form>
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
index 72f941e..5654368 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
@@ -75,7 +75,7 @@
<h:outputText styleClass="headerText"
value="Name"/>
</f:facet>
- <h:outputLink
value="/rhq/admin/plugin/plugin-details.xhtml">
+ <h:outputLink
value="/rhq/admin/plugin/plugin-details-view.xhtml">
<f:param name="plugin"
value="#{agentPlugin.name}"/>
<f:param name="pluginType" value="AGENT"/>
<h:outputText value="#{agentPlugin.displayName}"/>
@@ -160,7 +160,7 @@
<h:outputText styleClass="headerText"
value="Name"/>
</f:facet>
- <h:outputLink
value="/rhq/admin/plugin/plugin-details.xhtml">
+ <h:outputLink
value="/rhq/admin/plugin/plugin-details-view.xhtml">
<f:param name="plugin"
value="#{serverPlugin.name}"/>
<f:param name="pluginType" value="SERVER"/>
<h:outputText value="#{serverPlugin.displayName}"/>
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index ce603da..1415bb5 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.enterprise.server.plugin;
import java.io.BufferedInputStream;
@@ -67,14 +66,12 @@ import
org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDe
@Stateless
@javax.annotation.Resource(name = "RHQ_DS", mappedName =
RHQConstants.DATASOURCE_JNDI_NAME)
public class ServerPluginsBean implements ServerPluginsLocal {
- private final Log log = LogFactory.getLog(ServerPluginsBean.class);
+ private final Log log = LogFactory.getLog(ServerPluginsBean.class);
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
private EntityManager entityManager;
-
@javax.annotation.Resource(name = "RHQ_DS")
private DataSource dataSource;
-
@EJB
private ServerPluginsLocal serverPluginsBean; //self
@@ -242,8 +239,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
File currentFile = new File(pluginDir, doomedPlugin.getPath());
currentFile.delete();
} catch (Exception e) {
- log.error("Failed to delete the undeployed plugin [" +
doomedPlugin.getPath() + "]. Cause: "
- + ThrowableUtil.getAllMessages(e));
+ log.error("Failed to delete the undeployed plugin [" +
doomedPlugin.getPath() + "]. Cause: " + ThrowableUtil.getAllMessages(e));
}
}
}
@@ -279,7 +275,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void setServerPluginStatus(Subject subject, List<Integer> pluginIds,
PluginStatusType status)
- throws Exception {
+ throws Exception {
if (pluginIds == null || pluginIds.size() == 0) {
return; // nothing to do
}
@@ -295,8 +291,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
public Plugin registerServerPlugin(Subject subject, Plugin plugin, File pluginFile)
throws Exception {
if (plugin.getDeployment() != PluginDeploymentType.SERVER) {
- throw new IllegalArgumentException("Plugin [" + plugin.getName()
- + "] must be a server plugin to be registered");
+ throw new IllegalArgumentException("Plugin [" + plugin.getName() +
"] must be a server plugin to be registered");
}
Plugin existingPlugin = null;
@@ -309,8 +304,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
if (existingPlugin != null) {
if (existingPlugin.getStatus() == PluginStatusType.DELETED) {
- throw new IllegalArgumentException("Cannot register plugin [" +
plugin.getName()
- + "], it has been marked as deleted");
+ throw new IllegalArgumentException("Cannot register plugin [" +
plugin.getName() + "], it has been marked as deleted");
}
Plugin obsolete = ServerPluginDescriptorUtil.determineObsoletePlugin(plugin,
existingPlugin);
if (obsolete == existingPlugin) { // yes use == for reference equality
@@ -328,8 +322,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
if (plugin.getId() == 0) {
PluginStatusType status = getServerPluginStatus(plugin.getName());
if (PluginStatusType.DELETED == status) {
- throw new IllegalArgumentException("Cannot register plugin
[" + plugin.getName()
- + "], it has been previously marked as deleted.");
+ throw new IllegalArgumentException("Cannot register plugin
[" + plugin.getName() + "], it has been previously marked as deleted.");
}
entityManager.persist(plugin);
} else {
@@ -371,8 +364,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
// to entityManager.merge that plugin POJO, it would null out that blob column.
if (plugin.getDeployment() != PluginDeploymentType.SERVER) {
- throw new IllegalArgumentException("Plugin [" + plugin.getName()
- + "] must be a server plugin to be updated");
+ throw new IllegalArgumentException("Plugin [" + plugin.getName() +
"] must be a server plugin to be updated");
}
if (plugin.getId() == 0) {
commit c8a8622dce3142a91725a0a152bee94be64a9259
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Nov 23 14:05:06 2009 -0500
because we put the byte[] content directly in the plugin entity, we can't
entityManager.find() because that would load the full plugin content.
instead, use getReference. when we need to load the relationships, we have to play
games by
loading in the configs directly and doing a deep copy (mainly to workaround a
hibernate bug)
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 157911d..ce603da 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -94,11 +94,14 @@ public class ServerPluginsBean implements ServerPluginsLocal {
}
public Plugin getServerPluginRelationships(Plugin plugin) {
- plugin = entityManager.find(Plugin.class, plugin.getId());
+ plugin = getServerPlugin(plugin.getName()); // refresh all but the content field
- // force eager load
- plugin.getPluginConfiguration().getProperties().size();
- plugin.getScheduledJobsConfiguration().getProperties().size();
+ int pluginConfigId = plugin.getPluginConfiguration().getId();
+ int scheduledJobsId = plugin.getScheduledJobsConfiguration().getId();
+ Configuration pluginConfig = entityManager.find(Configuration.class,
pluginConfigId);
+ Configuration scheduledJobs = entityManager.find(Configuration.class,
scheduledJobsId);
+ plugin.setPluginConfiguration(pluginConfig.deepCopyWithoutProxies());
+ plugin.setScheduledJobsConfiguration(scheduledJobs.deepCopyWithoutProxies());
return plugin;
}
@@ -146,9 +149,9 @@ public class ServerPluginsBean implements ServerPluginsLocal {
}
@RequiredPermission(Permission.MANAGE_SETTINGS)
- public List<Plugin> disableServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception {
+ public List<String> disableServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception {
if (pluginIds == null || pluginIds.size() == 0) {
- return new ArrayList<Plugin>(); // nothing to do
+ return new ArrayList<String>(); // nothing to do
}
serverPluginsBean.setServerPluginEnabledFlag(subject, pluginIds, false);
@@ -156,19 +159,24 @@ public class ServerPluginsBean implements ServerPluginsLocal {
ServerPluginServiceManagement serverPluginService =
LookupUtil.getServerPluginService();
MasterServerPluginContainer master =
serverPluginService.getMasterPluginContainer();
- List<Plugin> doomedPlugins = new ArrayList<Plugin>();
+ List<String> doomedPlugins = new ArrayList<String>();
for (Integer pluginId : pluginIds) {
- Plugin doomedPlugin = entityManager.find(Plugin.class, pluginId);
+ Plugin doomedPlugin = null;
+ try {
+ doomedPlugin = entityManager.getReference(Plugin.class, pluginId);
+ } catch (Exception ignore) {
+ }
if (doomedPlugin != null) {
- doomedPlugins.add(doomedPlugin);
+ String pluginName = doomedPlugin.getName();
+ doomedPlugins.add(pluginName);
if (master != null) {
- AbstractTypeServerPluginContainer pc =
master.getPluginContainer(doomedPlugin.getName());
+ AbstractTypeServerPluginContainer pc =
master.getPluginContainer(pluginName);
if (pc != null) {
try {
- pc.unschedulePluginJobs(doomedPlugin.getName());
+ pc.unschedulePluginJobs(pluginName);
} catch (Exception e) {
- log.warn("Failed to unschedule jobs for plugin [" +
doomedPlugin.getName() + "]", e);
+ log.warn("Failed to unschedule jobs for plugin [" +
pluginName + "]", e);
}
}
}
@@ -184,9 +192,9 @@ public class ServerPluginsBean implements ServerPluginsLocal {
}
@RequiredPermission(Permission.MANAGE_SETTINGS)
- public List<Plugin> undeployServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception {
+ public List<String> undeployServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception {
if (pluginIds == null || pluginIds.size() == 0) {
- return new ArrayList<Plugin>(); // nothing to do
+ return new ArrayList<String>(); // nothing to do
}
serverPluginsBean.setServerPluginEnabledFlag(subject, pluginIds, false);
@@ -194,19 +202,24 @@ public class ServerPluginsBean implements ServerPluginsLocal {
ServerPluginServiceManagement serverPluginService =
LookupUtil.getServerPluginService();
MasterServerPluginContainer master =
serverPluginService.getMasterPluginContainer();
- List<Plugin> doomedPlugins = new ArrayList<Plugin>();
+ List<String> doomedPlugins = new ArrayList<String>();
for (Integer pluginId : pluginIds) {
- Plugin doomedPlugin = entityManager.find(Plugin.class, pluginId);
+ Plugin doomedPlugin = null;
+ try {
+ doomedPlugin = entityManager.getReference(Plugin.class, pluginId);
+ } catch (Exception ignore) {
+ }
if (doomedPlugin != null) {
- doomedPlugins.add(doomedPlugin);
+ String pluginName = doomedPlugin.getName();
+ doomedPlugins.add(pluginName);
if (master != null) {
- AbstractTypeServerPluginContainer pc =
master.getPluginContainer(doomedPlugin.getName());
+ AbstractTypeServerPluginContainer pc =
master.getPluginContainer(pluginName);
if (pc != null) {
try {
- pc.unschedulePluginJobs(doomedPlugin.getName());
+ pc.unschedulePluginJobs(pluginName);
} catch (Exception e) {
- log.warn("Failed to unschedule jobs for plugin [" +
doomedPlugin.getName() + "]", e);
+ log.warn("Failed to unschedule jobs for plugin [" +
pluginName + "]", e);
}
}
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
index 6f3600e..803f7cf 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
@@ -86,20 +86,20 @@ public interface ServerPluginsLocal {
*
* @param subject user making the request
* @param pluginIds the plugins to be disabled
- * @return the list of plugins that were disabled
+ * @return the list of names of the plugins that were disabled
* @throws Exception if failed to disable a plugin
*/
- List<Plugin> disableServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception;
+ List<String> disableServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception;
/**
* Removes the plugin from the system and restarts the server plugin container.
*
* @param subject user making the request
* @param pluginIds
- * @return the list of plugins that were undeployed
+ * @return the list of names of plugins that were undeployed
* @throws Exception if failed to undeploy a plugin
*/
- List<Plugin> undeployServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception;
+ List<String> undeployServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception;
/**
* Turns on or off the enabled flag in the database but does NOT restart the server
plugin container.
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
index e1796bf..d1a6aba 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
@@ -135,6 +135,24 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
assetLazyInitializationException(plugins.get(1));
}
+ public void testUpdatePlugins() throws Exception {
+ Plugin p1 = registerPlugin(1);
+ p1 = this.serverPluginsBean.getServerPlugin(p1.getName());
+ p1 = this.serverPluginsBean.getServerPluginRelationships(p1);
+
+ Plugin p1update =
this.serverPluginsBean.updateServerPluginExceptContent(getOverlord(), p1);
+ p1update = this.serverPluginsBean.getServerPluginRelationships(p1update);
+
+ assert p1update.getId() == p1.getId() : p1update;
+ assert p1update.getId() == p1.getId() : p1update;
+ assert p1update.getName().equals(p1.getName()) : p1update;
+ assert p1update.getName().equals(p1.getName()) : p1update;
+ assert p1update.getPluginConfiguration().equals(p1.getPluginConfiguration()) :
p1update;
+ assert
p1update.getScheduledJobsConfiguration().equals(p1.getScheduledJobsConfiguration()) :
p1update;
+ p1update.getPluginConfiguration().equals(p1.getPluginConfiguration());
+
p1update.getScheduledJobsConfiguration().equals(p1.getScheduledJobsConfiguration());
+ }
+
public void testDisableEnablePlugins() throws Exception {
Plugin p1 = registerPlugin(1);
Plugin p2 = registerPlugin(2);
@@ -142,12 +160,13 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
List<Integer> ids = new ArrayList<Integer>(2);
ids.add(p1.getId());
ids.add(p2.getId());
- List<Plugin> disabled =
this.serverPluginsBean.disableServerPlugins(getOverlord(), ids);
+ List<String> disabled =
this.serverPluginsBean.disableServerPlugins(getOverlord(), ids);
assert disabled.size() == 2 : disabled;
- assert disabled.contains(p1) : disabled;
- assert disabled.contains(p2) : disabled;
- assert disabled.get(0).getStatus() == PluginStatusType.INSTALLED; // still
installed
- assert disabled.get(1).getStatus() == PluginStatusType.INSTALLED; // still
installed
+ assert disabled.contains(p1.getName()) : disabled;
+ assert disabled.contains(p2.getName()) : disabled;
+ ;
+ assert this.serverPluginsBean.getServerPlugin(p1.getName()).getStatus() ==
PluginStatusType.INSTALLED; // still installed
+ assert this.serverPluginsBean.getServerPlugin(p2.getName()).getStatus() ==
PluginStatusType.INSTALLED; // still installed
List<String> pluginNames =
this.serverPluginsBean.getServerPluginNamesByEnabled(false);
assert pluginNames.contains(p1.getName()) : pluginNames;
assert pluginNames.contains(p2.getName()) : pluginNames;
@@ -195,12 +214,14 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
List<Integer> ids = new ArrayList<Integer>(2);
ids.add(p1.getId());
ids.add(p2.getId());
- List<Plugin> undeployed =
this.serverPluginsBean.undeployServerPlugins(getOverlord(), ids);
+ List<String> undeployed =
this.serverPluginsBean.undeployServerPlugins(getOverlord(), ids);
assert undeployed.size() == 2 : undeployed;
- assert undeployed.contains(p1) : undeployed;
- assert undeployed.contains(p2) : undeployed;
- assert undeployed.get(0).getStatus() == PluginStatusType.DELETED;
- assert undeployed.get(1).getStatus() == PluginStatusType.DELETED;
+ assert undeployed.contains(p1.getName()) : undeployed;
+ assert undeployed.contains(p2.getName()) : undeployed;
+ Plugin p1deleted = getDeletedPluginInTx(p1.getName());
+ Plugin p2deleted = getDeletedPluginInTx(p2.getName());
+ assert p1deleted.getStatus() == PluginStatusType.DELETED;
+ assert p2deleted.getStatus() == PluginStatusType.DELETED;
List<String> pluginNames =
this.serverPluginsBean.getServerPluginNamesByEnabled(false);
assert !pluginNames.contains(p1.getName()) : "deleted plugins should not be
returned even here" + pluginNames;
@@ -230,16 +251,18 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
List<Integer> ids = new ArrayList<Integer>(2);
ids.add(p1.getId());
ids.add(p2.getId());
- List<Plugin> undeployed =
this.serverPluginsBean.undeployServerPlugins(getOverlord(), ids);
+ List<String> undeployed =
this.serverPluginsBean.undeployServerPlugins(getOverlord(), ids);
assert undeployed.size() == 2 : undeployed;
- assert undeployed.contains(p1) : undeployed;
- assert undeployed.contains(p2) : undeployed;
- assert undeployed.get(0).getStatus() == PluginStatusType.DELETED;
- assert undeployed.get(0).getPluginConfiguration() == null; // undeploy should
have removed this
- assert undeployed.get(0).getScheduledJobsConfiguration() == null; // undeploy
should have removed this
- assert undeployed.get(1).getStatus() == PluginStatusType.DELETED;
- assert undeployed.get(1).getPluginConfiguration() == null; // undeploy should
have removed this
- assert undeployed.get(1).getScheduledJobsConfiguration() == null; // undeploy
should have removed this
+ assert undeployed.contains(p1.getName()) : undeployed;
+ assert undeployed.contains(p2.getName()) : undeployed;
+ Plugin p1deleted = getDeletedPluginInTx(p1.getName());
+ assert p1deleted.getStatus() == PluginStatusType.DELETED;
+ assert p1deleted.getPluginConfiguration() == null; // undeploy should have
removed this
+ assert p1deleted.getScheduledJobsConfiguration() == null; // undeploy should have
removed this
+ Plugin p2deleted = getDeletedPluginInTx(p1.getName());
+ assert p2deleted.getStatus() == PluginStatusType.DELETED;
+ assert p2deleted.getPluginConfiguration() == null; // undeploy should have
removed this
+ assert p2deleted.getScheduledJobsConfiguration() == null; // undeploy should have
removed this
List<String> pluginNames =
this.serverPluginsBean.getServerPluginNamesByEnabled(false);
assert !pluginNames.contains(p1.getName()) : "deleted plugins should not be
returned even here" + pluginNames;
@@ -320,4 +343,17 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
private Subject getOverlord() {
return LookupUtil.getSubjectManager().getOverlord();
}
+
+ private Plugin getDeletedPluginInTx(String pluginName) throws Exception {
+ EntityManager em = getEntityManager();
+ getTransactionManager().begin();
+ try {
+ Query q = em.createNamedQuery(Plugin.QUERY_FIND_ANY_BY_NAME_AND_TYPE);
+ q.setParameter("name", pluginName);
+ q.setParameter("type", PluginDeploymentType.SERVER);
+ return (Plugin) q.getSingleResult();
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
}
commit 263227e335728de980194c0632ae04938396536e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Nov 23 11:36:47 2009 -0500
put the proper values in the query params
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 3697caa..157911d 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -405,8 +405,8 @@ public class ServerPluginsBean implements ServerPluginsLocal {
q.setParameter("version", plugin.getVersion());
q.setParameter("ampsVersion", plugin.getAmpsVersion());
q.setParameter("deployment", plugin.getDeployment());
- q.setParameter("pluginConfiguration", config);
- q.setParameter("scheduledJobsConfiguration", config);
+ q.setParameter("pluginConfiguration",
plugin.getPluginConfiguration());
+ q.setParameter("scheduledJobsConfiguration",
plugin.getScheduledJobsConfiguration());
q.setParameter("description", plugin.getDescription());
q.setParameter("help", plugin.getHelp());
q.setParameter("mtime", plugin.getMtime());
commit e77a657abf17907a25dba4498b6e4993604ed38c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Nov 23 10:48:13 2009 -0500
the column should be "enabled" since everywhere else we talk about a plugin
being enabled or disabled, not active/inactive
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
index 9f7f6b7..72f941e 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-list.xhtml
@@ -105,7 +105,7 @@
<rich:column>
<f:facet name="header">
- <h:outputText styleClass="headerText"
value="Active"/>
+ <h:outputText styleClass="headerText"
value="Enabled"/>
</f:facet>
<h:outputText value="#{agentPlugin.enabled}"/>
@@ -190,7 +190,7 @@
<rich:column>
<f:facet name="header">
- <h:outputText styleClass="headerText"
value="Active"/>
+ <h:outputText styleClass="headerText"
value="Enabled"/>
</f:facet>
<h:outputText value="#{serverPlugin.enabled}"/>
commit 9af95de196ccc8b854a8f1c952af3a6cfa18e78d
Author: Justin Harris <jharris(a)redhat.com>
Date: Mon Nov 23 10:18:55 2009 -0500
Updating update plugin call to new naming scheme.
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
index fac4661..b6db223 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
@@ -69,7 +69,7 @@ public class InstalledPluginUIBean {
ServerPluginsLocal serverPlugins = LookupUtil.getServerPlugins();
try {
-
serverPlugins.updatePluginExceptContent(EnterpriseFacesContextUtility.getSubject(),
plugin);
+
serverPlugins.updateServerPluginExceptContent(EnterpriseFacesContextUtility.getSubject(),
plugin);
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
"Configuration settings saved.");
@@ -78,6 +78,8 @@ public class InstalledPluginUIBean {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
"There was an error changing the
configuration settings.", e);
}
+
+ lookupPlugin();
}
private void lookupPlugin() {
commit 556be90ec7e0285dc9205766805aaa91da2ef258
Author: Justin Harris <jharris(a)redhat.com>
Date: Fri Nov 20 18:34:52 2009 -0500
Adding save button to plugin details page.
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
index f6eee0d..fac4661 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginUIBean.java
@@ -65,6 +65,21 @@ public class InstalledPluginUIBean {
return this.scheduledJobsDefinition;
}
+ public void updatePlugin() {
+ ServerPluginsLocal serverPlugins = LookupUtil.getServerPlugins();
+
+ try {
+
serverPlugins.updatePluginExceptContent(EnterpriseFacesContextUtility.getSubject(),
plugin);
+
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
+ "Configuration settings saved.");
+ } catch (Exception e) {
+ log.error("Error updating the plugin configurations.", e);
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,
+ "There was an error changing the
configuration settings.", e);
+ }
+ }
+
private void lookupPlugin() {
hasPermission();
String pluginName =
FacesContextUtility.getRequiredRequestParameter("plugin", String.class);
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
index 3921b8e..fa46dc8 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/plugin/plugin-details.xhtml
@@ -76,24 +76,32 @@
</rich:panel>
- <rich:panel>
+
+ <rich:panel
rendered="#{InstalledPluginUIBean.plugin.pluginConfiguration != null}">
<f:facet name="header">
<h:outputText value="Plugin Configuration"/>
</f:facet>
<onc:config
configurationDefinition="#{InstalledPluginUIBean.pluginConfigurationDefinition}"
-
configuration="#{InstalledPluginUIBean.plugin.pluginConfiguration}"
- readOnly="true" />
+
configuration="#{InstalledPluginUIBean.plugin.pluginConfiguration}" />
</rich:panel>
- <rich:panel>
+ <rich:panel
rendered="#{InstalledPluginUIBean.plugin.scheduledJobsConfiguration !=
null}">
<f:facet name="header">
<h:outputText value="Scheduled Jobs"/>
</f:facet>
<onc:config
configurationDefinition="#{InstalledPluginUIBean.scheduledJobsDefinition}"
-
configuration="#{InstalledPluginUIBean.plugin.scheduledJobsConfiguration}"
- readOnly="true" />
+
configuration="#{InstalledPluginUIBean.plugin.scheduledJobsConfiguration}"
/>
+ </rich:panel>
+
+ <input type="hidden" name="plugin"
value="#{param.plugin}"/>
+ <input type="hidden" name="pluginType"
value="#{param.pluginType}"/>
+
+ <rich:panel
rendered="#{InstalledPluginUIBean.plugin.pluginConfiguration != null ||
+
InstalledPluginUIBean.plugin.scheduledJobsConfiguration != null}">
+ <h:commandButton value="OK" type="submit"
action="#{InstalledPluginUIBean.updatePlugin}"
+ alt="Click to Save Plugin"
styleClass="buttonmed" />
</rich:panel>
</rich:panel>
commit e144f9a55590182e130ae768b9b494b13f03c2a6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Nov 22 22:42:30 2009 -0500
convert CRLF to LF
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
index a7c0cbc..2c47b0a 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
@@ -1,397 +1,397 @@
-<%@ page import="java.io.ByteArrayOutputStream" %>
-<%@ page import="java.io.PrintStream" %>
-
-<%@ page import="org.rhq.core.domain.auth.Subject" %>
-<%@ page import="org.rhq.core.domain.util.PersistenceUtility" %>
-
-<%@ page import="org.rhq.enterprise.gui.legacy.util.SessionUtils"%>
-<%@ page import="org.rhq.enterprise.gui.util.WebUtility"%>
-
-<%@ page
import="org.rhq.enterprise.server.measurement.MeasurementPreferences" %>
-<%@ page
import="org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences"
%>
-
-<%@ page import="org.rhq.enterprise.server.test.CoreTestLocal" %>
-<%@ page import="org.rhq.enterprise.server.test.DiscoveryTestLocal" %>
-<%@ page import="org.rhq.enterprise.server.test.MeasurementTestLocal" %>
-<%@ page import="org.rhq.enterprise.server.test.ResourceGroupTestBeanLocal"
%>
-<%@ page import="org.rhq.enterprise.server.test.SubjectRoleTestBeanLocal"
%>
-<%@ page import="org.rhq.enterprise.server.test.AlertTemplateTestLocal"
%>
-<%@ page
import="org.rhq.enterprise.server.cloud.instance.ServerManagerLocal" %>
-<%@ page import="org.rhq.enterprise.server.test.ResourceGroupTestBeanLocal"
%>
-<%@ page
import="org.rhq.enterprise.server.measurement.MeasurementBaselineManagerLocal"
%>
-<%@ page
import="org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal"
%>
-<%@ page import="org.rhq.enterprise.server.core.AgentManagerLocal" %>
-<%@ page import="org.rhq.enterprise.server.system.SystemManagerLocal" %>
-<%@ page import="org.rhq.enterprise.server.auth.SubjectManagerLocal" %>
-<%@ page import="org.rhq.enterprise.server.support.SupportManagerLocal"
%>
-<%@page
import="org.rhq.enterprise.server.plugin.ServerPluginsLocal"%><html>
-<%@ page import="org.rhq.enterprise.server.util.LookupUtil" %>
-<%@ page
import="org.rhq.enterprise.server.scheduler.jobs.DataPurgeJob"%>
-
-<%@ page
import="org.rhq.enterprise.server.resource.ResourceTypeManagerRemote"%>
-<%@ page import="org.rhq.core.domain.criteria.ResourceTypeCriteria"%>
-<%@ page import="org.rhq.core.domain.resource.ResourceType"%>
-
-<%@ page import="javax.naming.NamingException" %>
-
-<%@ page contentType="text/html;charset=UTF-8" language="java"
%>
-<%@ taglib
uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"
%>
-<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
-
-<html>
-<head><title>RHQ Test Control Page</title></head>
-<body>
-
-<jsp:include page="/admin/include/adminTestLinks.html"
flush="true" />
-
-<%
- CoreTestLocal coreTestBean;
- DiscoveryTestLocal discoveryTestBean;
- MeasurementTestLocal measurementTestBean;
- ResourceGroupTestBeanLocal resourceGroupTestBean;
- SubjectRoleTestBeanLocal subjectRoleTestBean;
- ServerManagerLocal serverManager;
- AlertTemplateTestLocal alertTemplateTestBean;
- MeasurementBaselineManagerLocal measurementBaselineManager;
- MeasurementScheduleManagerLocal measurementScheduleManager;
- AgentManagerLocal agentManager;
- SystemManagerLocal systemManager;
- SubjectManagerLocal subjectManager;
- SupportManagerLocal supportManager;
- ResourceTypeManagerRemote typeManager;
- ServerPluginsLocal serverPlugins;
-
- coreTestBean = LookupUtil.getCoreTest();
- discoveryTestBean = LookupUtil.getDiscoveryTest();
- measurementTestBean = LookupUtil.getMeasurementTest();
- resourceGroupTestBean = LookupUtil.getResourceGroupTestBean();
- subjectRoleTestBean = LookupUtil.getSubjectRoleTestBean();
- serverManager = LookupUtil.getServerManager();
- alertTemplateTestBean = LookupUtil.getAlertTemplateTestBean();
- measurementBaselineManager = LookupUtil.getMeasurementBaselineManager();
- measurementScheduleManager = LookupUtil.getMeasurementScheduleManager();
- agentManager = LookupUtil.getAgentManager();
- systemManager = LookupUtil.getSystemManager();
- subjectManager = LookupUtil.getSubjectManager();
- supportManager = LookupUtil.getSupportManager();
- typeManager = LookupUtil.getResourceTypeManagerRemote();
- serverPlugins = LookupUtil.getServerPlugins();
-
- String result = null;
- String mode = pageContext.getRequest().getParameter("mode");
- String failure = null;
- try
- {
- if ("registerTestAgent".equals(mode))
- {
- coreTestBean.registerTestAgent();
- }
- else if ("registerTestPluginAndTypeInfo".equals(mode))
- {
- discoveryTestBean.registerTestPluginAndTypeInfo();
- }
- else if ("removeTestPluginAndTypeInfo".equals(mode))
- {
- discoveryTestBean.removeTestPluginAndTypeInfo();
- }
- else if ("sendTestFullInventoryReport".equals(mode))
- {
- discoveryTestBean.sendTestFullInventoryReport();
- }
- else if ("sendTestRuntimeInventoryReport".equals(mode))
- {
- discoveryTestBean.sendTestRuntimeInventoryReport();
- }
- else if ("sendTestMeasurementReport".equals(mode))
- {
- measurementTestBean.sendTestMeasurementReport();
- }
- else if ("sendNewPlatform".equals(mode))
- {
- String address = request.getParameter("address");
- int servers = Integer.parseInt(request.getParameter("servers"));
- int servicesPerServer =
Integer.parseInt(request.getParameter("servicesPerServer"));
- discoveryTestBean.sendNewPlatform(address, servers, servicesPerServer);
- }
- else if ("setupCompatibleGroups".equals(mode))
- {
- resourceGroupTestBean.setupCompatibleGroups();
- }
- else if ("setupUberMixedGroup".equals(mode))
- {
- resourceGroupTestBean.setupUberMixedGroup();
- }
- else if ("startStats".equals(mode))
- {
- coreTestBean.enableHibernateStatistics();
- }
- else if ("addProblemResource".equals(mode))
- {
- measurementTestBean.addProblemResource();
- }
- else if ("setAgentCurrentlyScheduledMetrics".equals(mode))
- {
- String value = pageContext.getRequest().getParameter("v");
- measurementTestBean.setAgentCurrentlyScheduledMetrics(Double.valueOf(value));
- }
- else if ("addSubjectsAndRoles".equals(mode))
- {
- String roleCount =
pageContext.getRequest().getParameter("roleCount");
- String usersInRoleCount =
pageContext.getRequest().getParameter("usersInRoleCount");
- subjectRoleTestBean.createRolesAndUsers(Integer.parseInt(roleCount),
Integer.parseInt(usersInRoleCount));
- }
- else if ("clusterGetIdentity".equals(mode))
- {
- String serverName = serverManager.getIdentity();
- pageContext.setAttribute("serverName", "(serverName = " +
serverName + ")");
- }
- else if ("cloneAlertTemplate".equals(mode))
- {
- String alertTemplateId =
pageContext.getRequest().getParameter("alertTemplateId");
- String numberOfClones =
pageContext.getRequest().getParameter("numberOfClones");
- alertTemplateTestBean.cloneAlertTemplate(Integer.parseInt(alertTemplateId),
Integer.parseInt(numberOfClones));
- }
- else if ("calculateAutoBaselines".equals(mode))
- {
- // for now, baselines aren't calculated until we hit our day limit, we force
it here
- java.util.Properties props = systemManager.getSystemConfiguration();
- props.put("CAM_BASELINE_LASTTIME", "0");
- systemManager.setSystemConfiguration(subjectManager.getOverlord(), props,true);
-
- measurementBaselineManager.calculateAutoBaselines();
- }
- else if ("calculateOOBs".equals(mode))
- {
- DataPurgeJob dpj = new DataPurgeJob();
- dpj.calculateOOBs();
- }
- else if ("checkForSuspectAgents".equals(mode))
- {
- agentManager.checkForSuspectAgents();
- }
- else if ("dataPurgeJob".equals(mode))
- {
- DataPurgeJob.purgeNow();
- }
- else if ("dbMaintenance".equals(mode))
- {
- systemManager.vacuum(subjectManager.getOverlord());
- systemManager.reindex(subjectManager.getOverlord());
- systemManager.analyze(subjectManager.getOverlord());
- }
- else if ("metricDisplayRange".equals(mode))
- {
- int lastHours =
Integer.parseInt(pageContext.getRequest().getParameter("lastHours"));
- Subject subject = WebUtility.getSubject(request);
- MeasurementPreferences prefs = new MeasurementPreferences(subject);
- MetricRangePreferences rangePrefs = prefs.getMetricRangePreferences();
- rangePrefs.lastN = lastHours;
- prefs.setMetricRangePreferences(rangePrefs);
- }
- else if ("errorCorrectSchedules".equals("mode"))
- {
- measurementScheduleManager.errorCorrectSchedules();
- }
- else if ("generateSnapshotReport".equals(mode))
- {
- int resourceId =
Integer.parseInt(request.getParameter("resourceId"));
- String name = request.getParameter("name");
- String description = request.getParameter("description");
- java.net.URL url =
supportManager.getSnapshotReport(subjectManager.getOverlord(), resourceId, name,
description);
- result = "Snapshot Report is located here: " + url.toString();
- }
- else if ("purgeServerPlugin".equals(mode))
- {
- String serverPluginName = request.getParameter("serverPluginName");
- serverPlugins.purgeServerPlugin(subjectManager.getOverlord(),
serverPluginName);
- result = "OK - you can now try to re-register a plugin with the name
[" + serverPluginName + "]";
- }
- else if ("typeManagerRemote".equals(mode))
- {
- int typeId = Integer.parseInt(request.getParameter("typeId"));
- ResourceTypeCriteria criteria = new ResourceTypeCriteria();
- criteria.addFilterId(typeId);
- criteria.fetchMetricDefinitions(true);
- java.util.List<ResourceType> types =
typeManager.findResourceTypesByCriteria(subjectManager.getOverlord(), criteria);
- result = "";
- for (ResourceType type : types) {
- result += type.getName() + " has " + (type.getMetricDefinitions()
!= null ? type.getMetricDefinitions().size() : "empty") + " metric
definitions";
- }
- }
- }
- catch (Exception e)
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- e.printStackTrace(new PrintStream(baos));
- failure = baos.toString();
- }
-
- pageContext.setAttribute("executed", mode);
- pageContext.setAttribute("result", result);
- pageContext.setAttribute("failure", failure);
- pageContext.setAttribute("testAgentReported",
Boolean.valueOf(coreTestBean.isTestAgentReported()));
-
-%>
-
-<c:if test="${executed != null}">
- <b>Executed <c:out value="${executed}"/>: </b> <c:out
value="${result}"/><br>
- <c:if test="${failure != null}">
- <pre style="background-color: yellow;"><c:out
value="${failure}"/></pre>
- </c:if>
-</c:if>
-
-<h2>Administration</h2>
-
-<c:url var="url"
value="/admin/test/control.jsp?mode=addSubjectsAndRoles"/>
-Add Lots of Users and Roles
-<form action="<c:out value="${url}"/>"
method="get">
- <input type="hidden" name="mode"
value="addSubjectsAndRoles"/>
- Number of Roles: <input type="text" name="roleCount"
size="5"/><br/>
- Number of Users in each Role: <input type="text"
name="usersInRoleCount" size="5"/><br/>
- <input type="submit" value="Send" name="Send"/>
-</form>
-
-
-<ul>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=addSubjectsAndRoles"/>
- <a href="<c:out value="${url}"/>">Report Test
Agent</a> (done = <c:out value="${testAgentReported}"/>)</li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=registerTestPluginAndTypeInfo"/>
- <a href="<c:out value="${url}"/>">Register test
plugin metadata</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=removeTestPluginAndTypeInfo"/>
- <a href="<c:out value="${url}"/>">Remove test
plugin metadata</a></li>
-</ul>
-
-<h2>Core</h2>
-
-<ul>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=registerTestAgent"/>
- <a href="<c:out value="${url}"/>">Report Test
Agent</a> (done = <c:out value="${testAgentReported}"/>)</li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=registerTestPluginAndTypeInfo"/>
- <a href="<c:out value="${url}"/>">Register test
plugin metadata</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=removeTestPluginAndTypeInfo"/>
- <a href="<c:out value="${url}"/>">Remove test
plugin metadata</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=dbMaintenance"/>
- <a href="<c:out value="${url}"/>">Perform All
Database Maintenance Now</a></li>
-</ul>
-
-<h2>Cluster</h2>
-
-<ul>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=clusterGetIdentity"/>
- <a href="<c:out value="${url}"/>">Get
Identity</a> <c:out value="${serverName}"/></li>
-</ul>
-
-<h2>Inventory</h2>
-
-<ul>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=sendTestFullInventoryReport"/>
- <a href="<c:out value="${url}"/>">Send Full
Inventory Report</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=sendTestRuntimeInventoryReport"/>
- <a href="<c:out value="${url}"/>">Send Runtime
Inventory Report</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=setupCompatibleGroups"/>
- <a href="<c:out value="${url}"/>">Setup Compatible
Groups</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=setupUberMixedGroup"/>
- <a href="<c:out value="${url}"/>">Setup Uber Mixed
Group</a></li>
-</ul>
-
-<c:url var="url"
value="/admin/test/control.jsp?mode=sendNewPlatform"/>
-Send New Platform Inventory Report
-<form action="<c:out value="${url}"/>"
method="get">
- <input type="hidden" name="mode"
value="sendNewPlatform"/>
- Address: <input type="text" name="address"
size="30"/><br/>
- Servers: <input type="text" name="servers"
size="5"/><br/>
- Services Per Server: <input type="text"
name="servicesPerServer" size="5"/><br/>
- <input type="submit" value="Send" name="Send"/>
-</form>
-
-
-<h2>Measurement</h2>
-
-<ul>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=calculateAutoBaselines"/>
- <a href="<c:out value="${url}"/>">Calculate Auto
Baselines</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=sendTestMeasurementReport"/>
- <a href="<c:out value="${url}"/>">Send Measurement
Report</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=addProblemResource"/>
- <a href="<c:out value="${url}"/>">Add problem
Resource</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=setAgentCurrentlyScheduledMetrics&v=100"/>
- <a href="<c:out value="${url}"/>">Set RHQ Agent
'CurrentlyScheduleMetrics' to 100</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=setAgentCurrentlyScheduledMetrics&v=50"/>
- <a href="<c:out value="${url}"/>">Set RHQ Agent
'CurrentlyScheduleMetrics' to 50</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=checkForSuspectAgents"/>
- <a href="<c:out value="${url}"/>">Check For Suspect
Agents</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=dataPurgeJob"/>
- <a href="<c:out value="${url}"/>">Force Data Purge
Now</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=calculateOOBs"/>
- <a href="<c:out value="${url}"/>">Force calculation
of OOBs</a></li>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=errorCorrectSchedules"/>
- <a href="<c:out value="${url}"/>">Error-Correct
Measurement Schedules</a></li>
-</ul>
-
-<h2>Alerts</h2>
-
-<c:url var="url"
value="/admin/test/control.jsp?mode=cloneAlertTemplate"/>
-Template Cloning
-<form action="<c:out value="${url}"/>"
method="get">
- <input type="hidden" name="mode"
value="cloneAlertTemplate"/>
- Alert Template ID: <input type="text" name="alertTemplateId"
size="5"/><br/>
- Number of Clones: <input type="text" name="numberOfClones"
size="5"/><br/>
- <input type="submit" value="Send" name="Send"/>
-</form>
-
-<h2>Utilities</h2>
-<ul>
- <li><c:url var="url"
value="/admin/test/control.jsp?mode=startStats"/>
- <a href="<c:out value="${url}"/>">Start Hibernate
Statistics Collection</a></li>
-</ul>
-
-
-<h2>User Preferences</h2>
-<%
- Subject subject = WebUtility.getSubject(request);
- MeasurementPreferences prefs = new MeasurementPreferences(subject);
- MetricRangePreferences rangePrefs = prefs.getMetricRangePreferences();
- pageContext.setAttribute("lastHours", String.valueOf(rangePrefs.lastN));
-%>
-<form action="<c:out value="${url}"/>"
method="get">
- <input type="hidden" name="mode"
value="metricDisplayRange"/>
- Last X hours: <input type="text" name="lastHours"
size="5" value="<c:out
value="${lastHours}"/>"/><br/>
- <input type="submit" value="Send" name="Send"/>
-</form>
-
-<h2>Snapshot Report</h2>
-
-<c:url var="url"
value="/admin/test/control.jsp?mode=generateSnapshotReport"/>
-Generate Snapshot Report
-<form action="<c:out value="${url}"/>"
method="get">
- <input type="hidden" name="mode"
value="generateSnapshotReport"/>
- Resource ID: <input type="text" name="resourceId"
size="10"/><br/>
- Name: <input type="text" name="name"
size="30"/><br/>
- Description: <input type="text" name="description"
size="100"/><br/>
- <input type="submit" value="Generate Snapshot"
name="Generate Snapshot"/>
-</form>
-
-<h2>Server Plugins</h2>
-
-<c:url var="url"
value="/admin/test/control.jsp?mode=purgeServerPlugin"/>
-Purge Server Plugin (allowing you to re-register it again later)
-<form action="<c:out value="${url}"/>"
method="get">
- <input type="hidden" name="mode"
value="purgeServerPlugin"/>
- ServerPluginName: <input type="text" name="serverPluginName"
size="30"/><br/>
- <input type="submit" value="Purge Server Plugin"
name="Purge Server Plugin"/>
-</form>
-
-<h2>Resource Type Criteria</h2>
-
-<c:url var="url"
value="/admin/test/control.jsp?mode=typeManagerRemote"/>
-Query ResourceTypes by Criteria
-<form action="<c:out value="${url}"/>"
method="get">
- <input type="hidden" name="mode"
value="typeManagerRemote"/>
- ResourceType ID: <input type="text" name="typeId"
size="10"/><br/>
- <input type="submit" value="Query by Criteria" name="Query
by Criteria"/>
-</form>
-
-
-
-</body>
-</html>
+<%@ page import="java.io.ByteArrayOutputStream" %>
+<%@ page import="java.io.PrintStream" %>
+
+<%@ page import="org.rhq.core.domain.auth.Subject" %>
+<%@ page import="org.rhq.core.domain.util.PersistenceUtility" %>
+
+<%@ page import="org.rhq.enterprise.gui.legacy.util.SessionUtils"%>
+<%@ page import="org.rhq.enterprise.gui.util.WebUtility"%>
+
+<%@ page
import="org.rhq.enterprise.server.measurement.MeasurementPreferences" %>
+<%@ page
import="org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences"
%>
+
+<%@ page import="org.rhq.enterprise.server.test.CoreTestLocal" %>
+<%@ page import="org.rhq.enterprise.server.test.DiscoveryTestLocal" %>
+<%@ page import="org.rhq.enterprise.server.test.MeasurementTestLocal" %>
+<%@ page import="org.rhq.enterprise.server.test.ResourceGroupTestBeanLocal"
%>
+<%@ page import="org.rhq.enterprise.server.test.SubjectRoleTestBeanLocal"
%>
+<%@ page import="org.rhq.enterprise.server.test.AlertTemplateTestLocal"
%>
+<%@ page
import="org.rhq.enterprise.server.cloud.instance.ServerManagerLocal" %>
+<%@ page import="org.rhq.enterprise.server.test.ResourceGroupTestBeanLocal"
%>
+<%@ page
import="org.rhq.enterprise.server.measurement.MeasurementBaselineManagerLocal"
%>
+<%@ page
import="org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal"
%>
+<%@ page import="org.rhq.enterprise.server.core.AgentManagerLocal" %>
+<%@ page import="org.rhq.enterprise.server.system.SystemManagerLocal" %>
+<%@ page import="org.rhq.enterprise.server.auth.SubjectManagerLocal" %>
+<%@ page import="org.rhq.enterprise.server.support.SupportManagerLocal"
%>
+<%@page
import="org.rhq.enterprise.server.plugin.ServerPluginsLocal"%><html>
+<%@ page import="org.rhq.enterprise.server.util.LookupUtil" %>
+<%@ page
import="org.rhq.enterprise.server.scheduler.jobs.DataPurgeJob"%>
+
+<%@ page
import="org.rhq.enterprise.server.resource.ResourceTypeManagerRemote"%>
+<%@ page import="org.rhq.core.domain.criteria.ResourceTypeCriteria"%>
+<%@ page import="org.rhq.core.domain.resource.ResourceType"%>
+
+<%@ page import="javax.naming.NamingException" %>
+
+<%@ page contentType="text/html;charset=UTF-8" language="java"
%>
+<%@ taglib
uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"
%>
+<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
+
+<html>
+<head><title>RHQ Test Control Page</title></head>
+<body>
+
+<jsp:include page="/admin/include/adminTestLinks.html"
flush="true" />
+
+<%
+ CoreTestLocal coreTestBean;
+ DiscoveryTestLocal discoveryTestBean;
+ MeasurementTestLocal measurementTestBean;
+ ResourceGroupTestBeanLocal resourceGroupTestBean;
+ SubjectRoleTestBeanLocal subjectRoleTestBean;
+ ServerManagerLocal serverManager;
+ AlertTemplateTestLocal alertTemplateTestBean;
+ MeasurementBaselineManagerLocal measurementBaselineManager;
+ MeasurementScheduleManagerLocal measurementScheduleManager;
+ AgentManagerLocal agentManager;
+ SystemManagerLocal systemManager;
+ SubjectManagerLocal subjectManager;
+ SupportManagerLocal supportManager;
+ ResourceTypeManagerRemote typeManager;
+ ServerPluginsLocal serverPlugins;
+
+ coreTestBean = LookupUtil.getCoreTest();
+ discoveryTestBean = LookupUtil.getDiscoveryTest();
+ measurementTestBean = LookupUtil.getMeasurementTest();
+ resourceGroupTestBean = LookupUtil.getResourceGroupTestBean();
+ subjectRoleTestBean = LookupUtil.getSubjectRoleTestBean();
+ serverManager = LookupUtil.getServerManager();
+ alertTemplateTestBean = LookupUtil.getAlertTemplateTestBean();
+ measurementBaselineManager = LookupUtil.getMeasurementBaselineManager();
+ measurementScheduleManager = LookupUtil.getMeasurementScheduleManager();
+ agentManager = LookupUtil.getAgentManager();
+ systemManager = LookupUtil.getSystemManager();
+ subjectManager = LookupUtil.getSubjectManager();
+ supportManager = LookupUtil.getSupportManager();
+ typeManager = LookupUtil.getResourceTypeManagerRemote();
+ serverPlugins = LookupUtil.getServerPlugins();
+
+ String result = null;
+ String mode = pageContext.getRequest().getParameter("mode");
+ String failure = null;
+ try
+ {
+ if ("registerTestAgent".equals(mode))
+ {
+ coreTestBean.registerTestAgent();
+ }
+ else if ("registerTestPluginAndTypeInfo".equals(mode))
+ {
+ discoveryTestBean.registerTestPluginAndTypeInfo();
+ }
+ else if ("removeTestPluginAndTypeInfo".equals(mode))
+ {
+ discoveryTestBean.removeTestPluginAndTypeInfo();
+ }
+ else if ("sendTestFullInventoryReport".equals(mode))
+ {
+ discoveryTestBean.sendTestFullInventoryReport();
+ }
+ else if ("sendTestRuntimeInventoryReport".equals(mode))
+ {
+ discoveryTestBean.sendTestRuntimeInventoryReport();
+ }
+ else if ("sendTestMeasurementReport".equals(mode))
+ {
+ measurementTestBean.sendTestMeasurementReport();
+ }
+ else if ("sendNewPlatform".equals(mode))
+ {
+ String address = request.getParameter("address");
+ int servers = Integer.parseInt(request.getParameter("servers"));
+ int servicesPerServer =
Integer.parseInt(request.getParameter("servicesPerServer"));
+ discoveryTestBean.sendNewPlatform(address, servers, servicesPerServer);
+ }
+ else if ("setupCompatibleGroups".equals(mode))
+ {
+ resourceGroupTestBean.setupCompatibleGroups();
+ }
+ else if ("setupUberMixedGroup".equals(mode))
+ {
+ resourceGroupTestBean.setupUberMixedGroup();
+ }
+ else if ("startStats".equals(mode))
+ {
+ coreTestBean.enableHibernateStatistics();
+ }
+ else if ("addProblemResource".equals(mode))
+ {
+ measurementTestBean.addProblemResource();
+ }
+ else if ("setAgentCurrentlyScheduledMetrics".equals(mode))
+ {
+ String value = pageContext.getRequest().getParameter("v");
+ measurementTestBean.setAgentCurrentlyScheduledMetrics(Double.valueOf(value));
+ }
+ else if ("addSubjectsAndRoles".equals(mode))
+ {
+ String roleCount =
pageContext.getRequest().getParameter("roleCount");
+ String usersInRoleCount =
pageContext.getRequest().getParameter("usersInRoleCount");
+ subjectRoleTestBean.createRolesAndUsers(Integer.parseInt(roleCount),
Integer.parseInt(usersInRoleCount));
+ }
+ else if ("clusterGetIdentity".equals(mode))
+ {
+ String serverName = serverManager.getIdentity();
+ pageContext.setAttribute("serverName", "(serverName = " +
serverName + ")");
+ }
+ else if ("cloneAlertTemplate".equals(mode))
+ {
+ String alertTemplateId =
pageContext.getRequest().getParameter("alertTemplateId");
+ String numberOfClones =
pageContext.getRequest().getParameter("numberOfClones");
+ alertTemplateTestBean.cloneAlertTemplate(Integer.parseInt(alertTemplateId),
Integer.parseInt(numberOfClones));
+ }
+ else if ("calculateAutoBaselines".equals(mode))
+ {
+ // for now, baselines aren't calculated until we hit our day limit, we force
it here
+ java.util.Properties props = systemManager.getSystemConfiguration();
+ props.put("CAM_BASELINE_LASTTIME", "0");
+ systemManager.setSystemConfiguration(subjectManager.getOverlord(), props,true);
+
+ measurementBaselineManager.calculateAutoBaselines();
+ }
+ else if ("calculateOOBs".equals(mode))
+ {
+ DataPurgeJob dpj = new DataPurgeJob();
+ dpj.calculateOOBs();
+ }
+ else if ("checkForSuspectAgents".equals(mode))
+ {
+ agentManager.checkForSuspectAgents();
+ }
+ else if ("dataPurgeJob".equals(mode))
+ {
+ DataPurgeJob.purgeNow();
+ }
+ else if ("dbMaintenance".equals(mode))
+ {
+ systemManager.vacuum(subjectManager.getOverlord());
+ systemManager.reindex(subjectManager.getOverlord());
+ systemManager.analyze(subjectManager.getOverlord());
+ }
+ else if ("metricDisplayRange".equals(mode))
+ {
+ int lastHours =
Integer.parseInt(pageContext.getRequest().getParameter("lastHours"));
+ Subject subject = WebUtility.getSubject(request);
+ MeasurementPreferences prefs = new MeasurementPreferences(subject);
+ MetricRangePreferences rangePrefs = prefs.getMetricRangePreferences();
+ rangePrefs.lastN = lastHours;
+ prefs.setMetricRangePreferences(rangePrefs);
+ }
+ else if ("errorCorrectSchedules".equals("mode"))
+ {
+ measurementScheduleManager.errorCorrectSchedules();
+ }
+ else if ("generateSnapshotReport".equals(mode))
+ {
+ int resourceId =
Integer.parseInt(request.getParameter("resourceId"));
+ String name = request.getParameter("name");
+ String description = request.getParameter("description");
+ java.net.URL url =
supportManager.getSnapshotReport(subjectManager.getOverlord(), resourceId, name,
description);
+ result = "Snapshot Report is located here: " + url.toString();
+ }
+ else if ("purgeServerPlugin".equals(mode))
+ {
+ String serverPluginName = request.getParameter("serverPluginName");
+ serverPlugins.purgeServerPlugin(subjectManager.getOverlord(),
serverPluginName);
+ result = "OK - you can now try to re-register a plugin with the name
[" + serverPluginName + "]";
+ }
+ else if ("typeManagerRemote".equals(mode))
+ {
+ int typeId = Integer.parseInt(request.getParameter("typeId"));
+ ResourceTypeCriteria criteria = new ResourceTypeCriteria();
+ criteria.addFilterId(typeId);
+ criteria.fetchMetricDefinitions(true);
+ java.util.List<ResourceType> types =
typeManager.findResourceTypesByCriteria(subjectManager.getOverlord(), criteria);
+ result = "";
+ for (ResourceType type : types) {
+ result += type.getName() + " has " + (type.getMetricDefinitions()
!= null ? type.getMetricDefinitions().size() : "empty") + " metric
definitions";
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ e.printStackTrace(new PrintStream(baos));
+ failure = baos.toString();
+ }
+
+ pageContext.setAttribute("executed", mode);
+ pageContext.setAttribute("result", result);
+ pageContext.setAttribute("failure", failure);
+ pageContext.setAttribute("testAgentReported",
Boolean.valueOf(coreTestBean.isTestAgentReported()));
+
+%>
+
+<c:if test="${executed != null}">
+ <b>Executed <c:out value="${executed}"/>: </b> <c:out
value="${result}"/><br>
+ <c:if test="${failure != null}">
+ <pre style="background-color: yellow;"><c:out
value="${failure}"/></pre>
+ </c:if>
+</c:if>
+
+<h2>Administration</h2>
+
+<c:url var="url"
value="/admin/test/control.jsp?mode=addSubjectsAndRoles"/>
+Add Lots of Users and Roles
+<form action="<c:out value="${url}"/>"
method="get">
+ <input type="hidden" name="mode"
value="addSubjectsAndRoles"/>
+ Number of Roles: <input type="text" name="roleCount"
size="5"/><br/>
+ Number of Users in each Role: <input type="text"
name="usersInRoleCount" size="5"/><br/>
+ <input type="submit" value="Send" name="Send"/>
+</form>
+
+
+<ul>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=addSubjectsAndRoles"/>
+ <a href="<c:out value="${url}"/>">Report Test
Agent</a> (done = <c:out value="${testAgentReported}"/>)</li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=registerTestPluginAndTypeInfo"/>
+ <a href="<c:out value="${url}"/>">Register test
plugin metadata</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=removeTestPluginAndTypeInfo"/>
+ <a href="<c:out value="${url}"/>">Remove test
plugin metadata</a></li>
+</ul>
+
+<h2>Core</h2>
+
+<ul>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=registerTestAgent"/>
+ <a href="<c:out value="${url}"/>">Report Test
Agent</a> (done = <c:out value="${testAgentReported}"/>)</li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=registerTestPluginAndTypeInfo"/>
+ <a href="<c:out value="${url}"/>">Register test
plugin metadata</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=removeTestPluginAndTypeInfo"/>
+ <a href="<c:out value="${url}"/>">Remove test
plugin metadata</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=dbMaintenance"/>
+ <a href="<c:out value="${url}"/>">Perform All
Database Maintenance Now</a></li>
+</ul>
+
+<h2>Cluster</h2>
+
+<ul>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=clusterGetIdentity"/>
+ <a href="<c:out value="${url}"/>">Get
Identity</a> <c:out value="${serverName}"/></li>
+</ul>
+
+<h2>Inventory</h2>
+
+<ul>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=sendTestFullInventoryReport"/>
+ <a href="<c:out value="${url}"/>">Send Full
Inventory Report</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=sendTestRuntimeInventoryReport"/>
+ <a href="<c:out value="${url}"/>">Send Runtime
Inventory Report</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=setupCompatibleGroups"/>
+ <a href="<c:out value="${url}"/>">Setup Compatible
Groups</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=setupUberMixedGroup"/>
+ <a href="<c:out value="${url}"/>">Setup Uber Mixed
Group</a></li>
+</ul>
+
+<c:url var="url"
value="/admin/test/control.jsp?mode=sendNewPlatform"/>
+Send New Platform Inventory Report
+<form action="<c:out value="${url}"/>"
method="get">
+ <input type="hidden" name="mode"
value="sendNewPlatform"/>
+ Address: <input type="text" name="address"
size="30"/><br/>
+ Servers: <input type="text" name="servers"
size="5"/><br/>
+ Services Per Server: <input type="text"
name="servicesPerServer" size="5"/><br/>
+ <input type="submit" value="Send" name="Send"/>
+</form>
+
+
+<h2>Measurement</h2>
+
+<ul>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=calculateAutoBaselines"/>
+ <a href="<c:out value="${url}"/>">Calculate Auto
Baselines</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=sendTestMeasurementReport"/>
+ <a href="<c:out value="${url}"/>">Send Measurement
Report</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=addProblemResource"/>
+ <a href="<c:out value="${url}"/>">Add problem
Resource</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=setAgentCurrentlyScheduledMetrics&v=100"/>
+ <a href="<c:out value="${url}"/>">Set RHQ Agent
'CurrentlyScheduleMetrics' to 100</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=setAgentCurrentlyScheduledMetrics&v=50"/>
+ <a href="<c:out value="${url}"/>">Set RHQ Agent
'CurrentlyScheduleMetrics' to 50</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=checkForSuspectAgents"/>
+ <a href="<c:out value="${url}"/>">Check For Suspect
Agents</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=dataPurgeJob"/>
+ <a href="<c:out value="${url}"/>">Force Data Purge
Now</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=calculateOOBs"/>
+ <a href="<c:out value="${url}"/>">Force calculation
of OOBs</a></li>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=errorCorrectSchedules"/>
+ <a href="<c:out value="${url}"/>">Error-Correct
Measurement Schedules</a></li>
+</ul>
+
+<h2>Alerts</h2>
+
+<c:url var="url"
value="/admin/test/control.jsp?mode=cloneAlertTemplate"/>
+Template Cloning
+<form action="<c:out value="${url}"/>"
method="get">
+ <input type="hidden" name="mode"
value="cloneAlertTemplate"/>
+ Alert Template ID: <input type="text" name="alertTemplateId"
size="5"/><br/>
+ Number of Clones: <input type="text" name="numberOfClones"
size="5"/><br/>
+ <input type="submit" value="Send" name="Send"/>
+</form>
+
+<h2>Utilities</h2>
+<ul>
+ <li><c:url var="url"
value="/admin/test/control.jsp?mode=startStats"/>
+ <a href="<c:out value="${url}"/>">Start Hibernate
Statistics Collection</a></li>
+</ul>
+
+
+<h2>User Preferences</h2>
+<%
+ Subject subject = WebUtility.getSubject(request);
+ MeasurementPreferences prefs = new MeasurementPreferences(subject);
+ MetricRangePreferences rangePrefs = prefs.getMetricRangePreferences();
+ pageContext.setAttribute("lastHours", String.valueOf(rangePrefs.lastN));
+%>
+<form action="<c:out value="${url}"/>"
method="get">
+ <input type="hidden" name="mode"
value="metricDisplayRange"/>
+ Last X hours: <input type="text" name="lastHours"
size="5" value="<c:out
value="${lastHours}"/>"/><br/>
+ <input type="submit" value="Send" name="Send"/>
+</form>
+
+<h2>Snapshot Report</h2>
+
+<c:url var="url"
value="/admin/test/control.jsp?mode=generateSnapshotReport"/>
+Generate Snapshot Report
+<form action="<c:out value="${url}"/>"
method="get">
+ <input type="hidden" name="mode"
value="generateSnapshotReport"/>
+ Resource ID: <input type="text" name="resourceId"
size="10"/><br/>
+ Name: <input type="text" name="name"
size="30"/><br/>
+ Description: <input type="text" name="description"
size="100"/><br/>
+ <input type="submit" value="Generate Snapshot"
name="Generate Snapshot"/>
+</form>
+
+<h2>Server Plugins</h2>
+
+<c:url var="url"
value="/admin/test/control.jsp?mode=purgeServerPlugin"/>
+Purge Server Plugin (allowing you to re-register it again later)
+<form action="<c:out value="${url}"/>"
method="get">
+ <input type="hidden" name="mode"
value="purgeServerPlugin"/>
+ ServerPluginName: <input type="text" name="serverPluginName"
size="30"/><br/>
+ <input type="submit" value="Purge Server Plugin"
name="Purge Server Plugin"/>
+</form>
+
+<h2>Resource Type Criteria</h2>
+
+<c:url var="url"
value="/admin/test/control.jsp?mode=typeManagerRemote"/>
+Query ResourceTypes by Criteria
+<form action="<c:out value="${url}"/>"
method="get">
+ <input type="hidden" name="mode"
value="typeManagerRemote"/>
+ ResourceType ID: <input type="text" name="typeId"
size="10"/><br/>
+ <input type="submit" value="Query by Criteria" name="Query
by Criteria"/>
+</form>
+
+
+
+</body>
+</html>
commit f04ef82719012571ecfa157eb270c6b0424ad0ac
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Nov 22 22:39:34 2009 -0500
mistakenly deleted the html tag, put it back
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
index 4d5cfd5..a7c0cbc 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
@@ -38,7 +38,7 @@
<%@ taglib
uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"
%>
<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
-
+<html>
<head><title>RHQ Test Control Page</title></head>
<body>
commit a5fcd064dc1d1eea47c2806754c3244e1c000235
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Nov 22 01:59:12 2009 -0500
since there is no current way to "revive" a undeployed plugin from the real
GUI, at least provide _some_ way to get back to a state that will let you re-register a
plugin again using the test control.jsp page
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
index f3f0a35..4d5cfd5 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
@@ -24,6 +24,7 @@
<%@ page import="org.rhq.enterprise.server.system.SystemManagerLocal" %>
<%@ page import="org.rhq.enterprise.server.auth.SubjectManagerLocal" %>
<%@ page import="org.rhq.enterprise.server.support.SupportManagerLocal"
%>
+<%@page
import="org.rhq.enterprise.server.plugin.ServerPluginsLocal"%><html>
<%@ page import="org.rhq.enterprise.server.util.LookupUtil" %>
<%@ page
import="org.rhq.enterprise.server.scheduler.jobs.DataPurgeJob"%>
@@ -37,7 +38,7 @@
<%@ taglib
uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"
%>
<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
-<html>
+
<head><title>RHQ Test Control Page</title></head>
<body>
@@ -58,6 +59,7 @@
SubjectManagerLocal subjectManager;
SupportManagerLocal supportManager;
ResourceTypeManagerRemote typeManager;
+ ServerPluginsLocal serverPlugins;
coreTestBean = LookupUtil.getCoreTest();
discoveryTestBean = LookupUtil.getDiscoveryTest();
@@ -73,6 +75,7 @@
subjectManager = LookupUtil.getSubjectManager();
supportManager = LookupUtil.getSupportManager();
typeManager = LookupUtil.getResourceTypeManagerRemote();
+ serverPlugins = LookupUtil.getServerPlugins();
String result = null;
String mode = pageContext.getRequest().getParameter("mode");
@@ -197,6 +200,12 @@
java.net.URL url =
supportManager.getSnapshotReport(subjectManager.getOverlord(), resourceId, name,
description);
result = "Snapshot Report is located here: " + url.toString();
}
+ else if ("purgeServerPlugin".equals(mode))
+ {
+ String serverPluginName = request.getParameter("serverPluginName");
+ serverPlugins.purgeServerPlugin(subjectManager.getOverlord(),
serverPluginName);
+ result = "OK - you can now try to re-register a plugin with the name
[" + serverPluginName + "]";
+ }
else if ("typeManagerRemote".equals(mode))
{
int typeId = Integer.parseInt(request.getParameter("typeId"));
@@ -362,6 +371,16 @@ Generate Snapshot Report
<input type="submit" value="Generate Snapshot"
name="Generate Snapshot"/>
</form>
+<h2>Server Plugins</h2>
+
+<c:url var="url"
value="/admin/test/control.jsp?mode=purgeServerPlugin"/>
+Purge Server Plugin (allowing you to re-register it again later)
+<form action="<c:out value="${url}"/>"
method="get">
+ <input type="hidden" name="mode"
value="purgeServerPlugin"/>
+ ServerPluginName: <input type="text" name="serverPluginName"
size="30"/><br/>
+ <input type="submit" value="Purge Server Plugin"
name="Purge Server Plugin"/>
+</form>
+
<h2>Resource Type Criteria</h2>
<c:url var="url"
value="/admin/test/control.jsp?mode=typeManagerRemote"/>
commit 5413dbb476c615effd97d698ae54b051bcfa02c5
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Nov 21 16:17:38 2009 -0500
actually remove all jobs for the undeployed server plugin
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 8a4ab80..3697caa 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -235,6 +235,8 @@ public class ServerPluginsBean implements ServerPluginsLocal {
}
}
+ log.info("Server plugins " + doomedPlugins + " have been
undeployed");
+
// only restart if the master was started to begin with; otherwise, leave it
down
if (master != null) {
serverPluginService.restartMasterPluginContainer();
@@ -257,6 +259,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
throw new Exception("Failed to update [" + pluginIds.size() +
"] plugins. Count was [" + count + "]");
}
+ log.info((enabled ? "Enabling" : "Disabling") + " server
plugins with plugin IDs of " + pluginIds);
return;
}
@@ -324,7 +327,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
entityManager.flush();
streamPluginFileContentToDatabase(plugin.getId(), pluginFile);
}
- log.debug("Updated plugin entity [" + plugin + "]");
+ log.info("Server plugin [" + plugin.getName() + "] has been
registered in the database");
}
return plugin;
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java
index 3256bf5..e88e5fd 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java
@@ -235,7 +235,21 @@ public abstract class AbstractTypeServerPluginContainer {
*/
public void unschedulePluginJobs(String pluginName) throws Exception {
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- scheduler.resumeJobGroup(pluginName);
+
+ // note: all jobs for a plugin are placed in the same group, where the group name
is the plugin name
+ String groupName = pluginName;
+
+ scheduler.pauseJobGroup(groupName);
+ String[] jobNames = scheduler.getJobNames(groupName);
+ if (jobNames != null) {
+ for (String jobName : jobNames) {
+ boolean deleted = scheduler.deleteJob(jobName, groupName);
+ if (!deleted) {
+ log.warn("Plugin [" + pluginName + "] failed to get
its job [" + jobName + "] unscheduled!");
+ }
+ }
+ }
+
return;
}
commit 1093e91f666af1848a7bd5d4fb93ed6cdb9b9c50
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Nov 21 13:24:26 2009 -0500
provide API that will allow us to later build a user interface to
"resurrect" a deleted plugin - to re-install it if it was undelpoyed before.
this also fixes some tests - server/jar and core/domain plugin tests now all pass
properly
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
index 67ffc53..eda26d8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
@@ -114,6 +114,31 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " LEFT JOIN p.scheduledJobsConfiguration " //
+ " WHERE p.name=:name AND p.status = 'INSTALLED' "), //
+ // gets the plugin, even if it is deleted
+ // this query does not load the content blob, but loads everything else
+ @NamedQuery(name = Plugin.QUERY_FIND_ANY_BY_NAME_AND_TYPE, query = "" //
+ + " SELECT new org.rhq.core.domain.plugin.Plugin( " //
+ + " p.id, " //
+ + " p.name, " //
+ + " p.path, " //
+ + " p.displayName, " //
+ + " p.enabled, " //
+ + " p.status, " //
+ + " p.description, " //
+ + " p.help, " //
+ + " p.md5, " //
+ + " p.version, " //
+ + " p.ampsVersion, " //
+ + " p.deployment, " //
+ + " p.pluginConfiguration, " //
+ + " p.scheduledJobsConfiguration, " //
+ + " p.ctime, " //
+ + " p.mtime) " //
+ + " FROM Plugin AS p " //
+ + " LEFT JOIN p.pluginConfiguration " //
+ + " LEFT JOIN p.scheduledJobsConfiguration " //
+ + " WHERE p.name=:name AND p.deployment = :type "), //
+
// this query does not load the content blob, but loads everything else
@NamedQuery(name = Plugin.QUERY_FIND_ALL_AGENT, query = "" //
+ " SELECT new org.rhq.core.domain.plugin.Plugin( " //
@@ -227,6 +252,7 @@ public class Plugin implements Serializable {
public static final String QUERY_FIND_ALL_AGENT = "Plugin.findAllAgent";
public static final String QUERY_FIND_ALL_SERVER = "Plugin.findAllServer";
public static final String QUERY_FIND_BY_NAME = "Plugin.findByName";
+ public static final String QUERY_FIND_ANY_BY_NAME_AND_TYPE =
"Plugin.findAnyByNameAndType";
public static final String QUERY_FIND_BY_IDS_AND_TYPE =
"Plugin.findByIdsAndType";
public static final String QUERY_GET_NAMES_BY_ENABLED_AND_TYPE =
"Plugin.findByEnabledAndType";
public static final String QUERY_GET_STATUS_BY_NAME_AND_TYPE =
"Plugin.getStatusByNameAndType";
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
index 8ab3171..07f8f97 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
@@ -48,7 +48,7 @@ import org.rhq.core.util.stream.StreamUtil;
@Test
public class PluginTest extends AbstractEJB3Test {
- public void testUpdate() throws Exception {
+ public void testUpdate() throws Throwable {
boolean done = false;
getTransactionManager().begin();
EntityManager em = getEntityManager();
@@ -81,8 +81,8 @@ public class PluginTest extends AbstractEJB3Test {
em.persist(plugin);
id = plugin.getId();
assert id > 0;
- assert plugin.getPluginConfiguration().getId() > 0 : "did not persist
config";
- assert plugin.getScheduledJobsConfiguration().getId() > 0 : "did not
persist jobs config";
+ assert plugin.getPluginConfiguration() == null : "there was no config
that should have been here";
+ assert plugin.getScheduledJobsConfiguration() == null : "there was no
config that should have been here";
q = em.createNamedQuery(Plugin.QUERY_GET_STATUS_BY_NAME_AND_TYPE);
q.setParameter("name", plugin.getName());
@@ -127,6 +127,10 @@ public class PluginTest extends AbstractEJB3Test {
getTransactionManager().begin();
em = getEntityManager();
+ em.persist(pluginConfig);
+ em.persist(jobsConfig);
+ em.flush(); // gotta get those two persists to flush to the DB
+
q = em.createNamedQuery(Plugin.UPDATE_ALL_BUT_CONTENT);
q.setParameter("id", id); // same as the one we just persisted
q.setParameter("name", name);
@@ -173,12 +177,19 @@ public class PluginTest extends AbstractEJB3Test {
getTransactionManager().commit();
getTransactionManager().begin();
em = getEntityManager();
- em.createNativeQuery("DELETE FROM " + Plugin.TABLE_NAME + "
WHERE ID = " + id).executeUpdate();
+ q = em.createNamedQuery(Plugin.QUERY_FIND_ANY_BY_NAME_AND_TYPE);
+ q.setParameter("name", plugin.getName());
+ q.setParameter("type", plugin.getDeployment());
+ Plugin doomed = (Plugin) q.getSingleResult();
+ doomed = em.getReference(Plugin.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the
plugin";
em.close();
getTransactionManager().commit();
done = true;
} catch (Throwable t) {
t.printStackTrace();
+ throw t;
} finally {
if (!done) {
getTransactionManager().rollback();
@@ -486,7 +497,13 @@ public class PluginTest extends AbstractEJB3Test {
getTransactionManager().commit();
getTransactionManager().begin();
em = getEntityManager();
- em.createNativeQuery("DELETE FROM " + Plugin.TABLE_NAME + "
WHERE ID = " + plugin.getId()).executeUpdate();
+ Query q = em.createNamedQuery(Plugin.QUERY_FIND_ANY_BY_NAME_AND_TYPE);
+ q.setParameter("name", plugin.getName());
+ q.setParameter("type", plugin.getDeployment());
+ Plugin doomed = (Plugin) q.getSingleResult();
+ doomed = em.getReference(Plugin.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the
plugin";
em.close();
getTransactionManager().commit();
done = true;
@@ -595,8 +612,13 @@ public class PluginTest extends AbstractEJB3Test {
getTransactionManager().commit();
getTransactionManager().begin();
em = getEntityManager();
- em.createNativeQuery("DELETE FROM " + Plugin.TABLE_NAME + "
WHERE ID = " + plugin.getId()).executeUpdate();
- em.close();
+ Query q = em.createNamedQuery(Plugin.QUERY_FIND_ANY_BY_NAME_AND_TYPE);
+ q.setParameter("name", plugin.getName());
+ q.setParameter("type", plugin.getDeployment());
+ Plugin doomed = (Plugin) q.getSingleResult();
+ doomed = em.getReference(Plugin.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the
plugin";
getTransactionManager().commit();
done = true;
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 67d5efd..8a4ab80 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -44,6 +44,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.plugin.PluginDeploymentType;
import org.rhq.core.domain.plugin.PluginStatusType;
@@ -213,8 +214,14 @@ public class ServerPluginsBean implements ServerPluginsLocal {
// if this plugin ever gets re-installed, let's support the use-case
where the new plugin
// will have different config metadata. Here we null out the old config
so the new
// config can be set to the new cofig definition's default values.
- doomedPlugin.setPluginConfiguration(null);
- doomedPlugin.setScheduledJobsConfiguration(null);
+ if (doomedPlugin.getPluginConfiguration() != null) {
+ entityManager.remove(doomedPlugin.getPluginConfiguration());
+ doomedPlugin.setPluginConfiguration(null);
+ }
+ if (doomedPlugin.getScheduledJobsConfiguration() != null) {
+ entityManager.remove(doomedPlugin.getScheduledJobsConfiguration());
+ doomedPlugin.setScheduledJobsConfiguration(null);
+ }
doomedPlugin.setStatus(PluginStatusType.DELETED);
try {
@@ -324,6 +331,22 @@ public class ServerPluginsBean implements ServerPluginsLocal {
}
@RequiredPermission(Permission.MANAGE_SETTINGS)
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public void purgeServerPlugin(Subject subject, String pluginName) {
+ Query q =
this.entityManager.createNamedQuery(Plugin.QUERY_FIND_ANY_BY_NAME_AND_TYPE);
+ q.setParameter("name", pluginName);
+ q.setParameter("type", PluginDeploymentType.SERVER);
+ Plugin doomed = (Plugin) q.getSingleResult();
+
+ // get the reference to attach to em and use the em.remove. this cascade deletes
too.
+ doomed = this.entityManager.getReference(Plugin.class, doomed.getId());
+ this.entityManager.remove(doomed);
+
+ log.debug("Server plugin [" + pluginName + "] has been purged from
the db");
+ return;
+ }
+
+ @RequiredPermission(Permission.MANAGE_SETTINGS)
public Plugin updateServerPluginExceptContent(Subject subject, Plugin plugin) throws
Exception {
// this method is here because we need a way to update the plugin's
information
@@ -339,6 +362,35 @@ public class ServerPluginsBean implements ServerPluginsLocal {
if (plugin.getId() == 0) {
throw new IllegalArgumentException("Plugin must already exist to update
it");
} else {
+ // make sure the configs are in the DB properly and we have their refs
+ // this is because we are using JPQL update, so we need to do some of this
"manually"
+ boolean needFlush = false;
+ Configuration config = plugin.getPluginConfiguration();
+ if (config != null) {
+ if (config.getId() > 0) {
+ config = entityManager.getReference(Configuration.class,
config.getId());
+ plugin.setPluginConfiguration(config);
+ } else {
+ entityManager.persist(config);
+ needFlush = true;
+ }
+ }
+ config = plugin.getScheduledJobsConfiguration();
+ if (config != null) {
+ if (config.getId() > 0) {
+ config = entityManager.getReference(Configuration.class,
config.getId());
+ plugin.setScheduledJobsConfiguration(config);
+ } else {
+ entityManager.persist(config);
+ needFlush = true;
+ }
+ }
+ if (needFlush) {
+ entityManager.flush(); // must be flushed to the DB so the JPQL update
below works
+ }
+
+ // now we can JPQL update the row - all but content is updated here.
+ // we assured our configs are persisted/attached above
Query q = entityManager.createNamedQuery(Plugin.UPDATE_ALL_BUT_CONTENT);
q.setParameter("id", plugin.getId());
q.setParameter("name", plugin.getName());
@@ -350,14 +402,16 @@ public class ServerPluginsBean implements ServerPluginsLocal {
q.setParameter("version", plugin.getVersion());
q.setParameter("ampsVersion", plugin.getAmpsVersion());
q.setParameter("deployment", plugin.getDeployment());
- q.setParameter("pluginConfiguration",
plugin.getPluginConfiguration());
- q.setParameter("scheduledJobsConfiguration",
plugin.getScheduledJobsConfiguration());
+ q.setParameter("pluginConfiguration", config);
+ q.setParameter("scheduledJobsConfiguration", config);
q.setParameter("description", plugin.getDescription());
q.setParameter("help", plugin.getHelp());
q.setParameter("mtime", plugin.getMtime());
if (q.executeUpdate() != 1) {
throw new Exception("Failed to update a plugin that matches ["
+ plugin + "]");
}
+
+ entityManager.flush(); // make sure we push this out to the DB now
}
return plugin;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
index 68afc0e..6f3600e 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
@@ -126,7 +126,8 @@ public interface ServerPluginsLocal {
void setServerPluginStatus(Subject subject, List<Integer> pluginIds,
PluginStatusType status) throws Exception;
/**
- * Registers the given plugin to the database.
+ * Registers the given plugin to the database. This does nothing with the master
plugin container,
+ * all it does is ensure the database is up-to-date with this new plugin.
*
* @param subject the user that needs to have permissions to add a plugin to the
system
* @param plugin the plugin definition
@@ -149,6 +150,20 @@ public interface ServerPluginsLocal {
Plugin updateServerPluginExceptContent(Subject subject, Plugin plugin) throws
Exception;
/**
+ * Purges the server plugin from the database. This ensures that, after this method
returns,
+ * the given plugin will be unknown. The plugin can be installed again later.
+ *
+ * This has "requires new" semantics, so the results are committed
immediately upon return.
+ * This is really a supporting method for {@link #reRegisterServerPlugin(Subject,
Plugin, File)} - you'll
+ * probably want to use that instead. Do not blindly purge server plugins using this
method unless you
+ * know what you are doing.
+ *
+ * @param subject user making the request
+ * @param pluginName the name of the server plugin to delete
+ */
+ void purgeServerPlugin(Subject subject, String pluginName);
+
+ /**
* Given the name of a server plugin, this will return the status of that plugin.
* Use this to determine if a plugin has been deleted or not.
*
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
index 8250c7d..9c971e0 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
@@ -50,6 +50,7 @@ import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.event.EventDefinition;
@@ -196,6 +197,33 @@ public class ResourceMetadataManagerBean implements
ResourceMetadataManagerLocal
if (plugin.getId() == 0) {
entityManager.persist(plugin);
} else {
+ // agent plugins don't support these configs, but if/when they do in the
future, this will support it
+ boolean needFlush = false;
+ Configuration config = plugin.getPluginConfiguration();
+ if (config != null) {
+ if (config.getId() > 0) {
+ config = entityManager.getReference(Configuration.class,
config.getId());
+ plugin.setPluginConfiguration(config);
+ } else {
+ entityManager.persist(config);
+ needFlush = true;
+ }
+ }
+ config = plugin.getScheduledJobsConfiguration();
+ if (config != null) {
+ if (config.getId() > 0) {
+ config = entityManager.getReference(Configuration.class,
config.getId());
+ plugin.setScheduledJobsConfiguration(config);
+ } else {
+ entityManager.persist(config);
+ needFlush = true;
+ }
+ }
+ if (needFlush) {
+ entityManager.flush(); // must be flushed to the DB so the JPQL update
below works
+ }
+
+ // update all the fields except content
Query q = entityManager.createNamedQuery(Plugin.UPDATE_ALL_BUT_CONTENT);
q.setParameter("id", plugin.getId());
q.setParameter("name", plugin.getName());
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
index d5817a2..e1796bf 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
@@ -74,10 +74,11 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
getTransactionManager().begin();
em = getEntityManager();
- Query q = em.createQuery("SELECT p FROM Plugin p WHERE p.name LIKE
'serverplugintest%'");
+ Query q = em
+ .createQuery("SELECT p FROM Plugin p LEFT JOIN FETCH
p.pluginConfiguration LEFT JOIN FETCH p.scheduledJobsConfiguration WHERE p.name LIKE
'serverplugintest%'");
List<Plugin> doomed = q.getResultList();
for (Plugin plugin : doomed) {
- em.remove(plugin);
+ em.remove(em.getReference(Plugin.class, plugin.getId()));
}
getTransactionManager().commit();
@@ -207,17 +208,70 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(true);
assert !pluginNames.contains(p1.getName()) : pluginNames;
assert !pluginNames.contains(p2.getName()) : pluginNames;
+ }
+
+ public void testReRegisterPlugins() throws Exception {
+
+ PluginStatusType status;
+
+ status = this.serverPluginsBean.getServerPluginStatus(TEST_PLUGIN_NAME_PREFIX +
"1");
+ assert status == null;
+ status = this.serverPluginsBean.getServerPluginStatus(TEST_PLUGIN_NAME_PREFIX +
"2");
+ assert status == null;
+
+ Plugin p1 = registerPlugin(1);
+ Plugin p2 = registerPlugin(2);
+
+ status = this.serverPluginsBean.getServerPluginStatus(p1.getName());
+ assert status == PluginStatusType.INSTALLED;
+ status = this.serverPluginsBean.getServerPluginStatus(p2.getName());
+ assert status == PluginStatusType.INSTALLED;
- // re-install them - need to implement this feature
- // this.serverPluginsBean.enableServerPlugins(getOverlord(), ids);
- // pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(true);
- // assert pluginNames.contains(p1.getName()) : pluginNames;
- // assert pluginNames.contains(p2.getName()) : pluginNames;
- // assert undeployed.get(0).getStatus() == PluginStatusType.INSTALLED;
- // assert undeployed.get(1).getStatus() == PluginStatusType.INSTALLED;
- // pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(false);
- // assert !pluginNames.contains(p1.getName()) : pluginNames;
- // assert !pluginNames.contains(p2.getName()) : pluginNames;
+ List<Integer> ids = new ArrayList<Integer>(2);
+ ids.add(p1.getId());
+ ids.add(p2.getId());
+ List<Plugin> undeployed =
this.serverPluginsBean.undeployServerPlugins(getOverlord(), ids);
+ assert undeployed.size() == 2 : undeployed;
+ assert undeployed.contains(p1) : undeployed;
+ assert undeployed.contains(p2) : undeployed;
+ assert undeployed.get(0).getStatus() == PluginStatusType.DELETED;
+ assert undeployed.get(0).getPluginConfiguration() == null; // undeploy should
have removed this
+ assert undeployed.get(0).getScheduledJobsConfiguration() == null; // undeploy
should have removed this
+ assert undeployed.get(1).getStatus() == PluginStatusType.DELETED;
+ assert undeployed.get(1).getPluginConfiguration() == null; // undeploy should
have removed this
+ assert undeployed.get(1).getScheduledJobsConfiguration() == null; // undeploy
should have removed this
+
+ List<String> pluginNames =
this.serverPluginsBean.getServerPluginNamesByEnabled(false);
+ assert !pluginNames.contains(p1.getName()) : "deleted plugins should not be
returned even here" + pluginNames;
+ assert !pluginNames.contains(p2.getName()) : "deleted plugins should not be
returned even here" + pluginNames;
+ pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(true);
+ assert !pluginNames.contains(p1.getName()) : pluginNames;
+ assert !pluginNames.contains(p2.getName()) : pluginNames;
+
+ // purge them completely from the DB to prepare to re-register them
+ this.serverPluginsBean.purgeServerPlugin(getOverlord(), p1.getName());
+ this.serverPluginsBean.purgeServerPlugin(getOverlord(), p2.getName());
+
+ // we just purged the database, make sure our entity ID's are all zero, since
the original IDs are gone
+ p1.setId(0);
+ p2.setId(0);
+ p1.setPluginConfiguration(p1.getPluginConfiguration().deepCopy(false));
+ p2.setPluginConfiguration(p2.getPluginConfiguration().deepCopy(false));
+
p1.setScheduledJobsConfiguration(p1.getScheduledJobsConfiguration().deepCopy(false));
+
p2.setScheduledJobsConfiguration(p2.getScheduledJobsConfiguration().deepCopy(false));
+
+ // re-register them now
+ Plugin p1again = this.serverPluginsBean.registerServerPlugin(getOverlord(), p1,
null);
+ Plugin p2again = this.serverPluginsBean.registerServerPlugin(getOverlord(), p2,
null);
+
+ pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(true);
+ assert pluginNames.contains(p1.getName()) : pluginNames;
+ assert pluginNames.contains(p2.getName()) : pluginNames;
+ assert p1again.getStatus() == PluginStatusType.INSTALLED;
+ assert p2again.getStatus() == PluginStatusType.INSTALLED;
+ pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(false);
+ assert !pluginNames.contains(p1.getName()) : pluginNames;
+ assert !pluginNames.contains(p2.getName()) : pluginNames;
}
private Plugin registerPlugin(int index) throws Exception {
commit 45180dcd79713f2f29e7051b2f1bed396dce9d2b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Nov 21 10:42:18 2009 -0500
do not attempt to register plugins that were previously undeployed.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
index 552179f..67ffc53 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
@@ -56,6 +56,11 @@ import org.rhq.core.util.MessageDigestGenerator;
@Entity
@NamedQueries( {
//
+ @NamedQuery(name = Plugin.QUERY_GET_STATUS_BY_NAME_AND_TYPE, query = "" //
+ + " SELECT p.status " //
+ + " FROM Plugin AS p " //
+ + " WHERE p.name = :name AND p.deployment = :type "), //
+
@NamedQuery(name = Plugin.QUERY_GET_NAMES_BY_ENABLED_AND_TYPE, query = ""
//
+ " SELECT p.name " //
+ " FROM Plugin AS p " //
@@ -224,6 +229,7 @@ public class Plugin implements Serializable {
public static final String QUERY_FIND_BY_NAME = "Plugin.findByName";
public static final String QUERY_FIND_BY_IDS_AND_TYPE =
"Plugin.findByIdsAndType";
public static final String QUERY_GET_NAMES_BY_ENABLED_AND_TYPE =
"Plugin.findByEnabledAndType";
+ public static final String QUERY_GET_STATUS_BY_NAME_AND_TYPE =
"Plugin.getStatusByNameAndType";
public static final String UPDATE_ALL_BUT_CONTENT =
"Plugin.updateAllButContent";
public static final String UPDATE_PLUGINS_ENABLED_BY_IDS =
"Plugin.updatePluginsEnabledByIds";
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
index 7e3ad25..8ab3171 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
@@ -73,12 +73,22 @@ public class PluginTest extends AbstractEJB3Test {
plugin.setHelp(null);
plugin.setContent(content);
+ Query q = em.createNamedQuery(Plugin.QUERY_GET_STATUS_BY_NAME_AND_TYPE);
+ q.setParameter("name", plugin.getName());
+ q.setParameter("type", plugin.getDeployment());
+ assert q.getResultList().size() == 0; // not in the db yet
+
em.persist(plugin);
id = plugin.getId();
assert id > 0;
assert plugin.getPluginConfiguration().getId() > 0 : "did not persist
config";
assert plugin.getScheduledJobsConfiguration().getId() > 0 : "did not
persist jobs config";
+ q = em.createNamedQuery(Plugin.QUERY_GET_STATUS_BY_NAME_AND_TYPE);
+ q.setParameter("name", plugin.getName());
+ q.setParameter("type", plugin.getDeployment());
+ assert ((PluginStatusType) q.getSingleResult()) ==
PluginStatusType.INSTALLED;
+
plugin = em.find(Plugin.class, id);
assert plugin != null;
assert plugin.getId() == id;
@@ -117,7 +127,7 @@ public class PluginTest extends AbstractEJB3Test {
getTransactionManager().begin();
em = getEntityManager();
- Query q = em.createNamedQuery(Plugin.UPDATE_ALL_BUT_CONTENT);
+ q = em.createNamedQuery(Plugin.UPDATE_ALL_BUT_CONTENT);
q.setParameter("id", id); // same as the one we just persisted
q.setParameter("name", name);
q.setParameter("path", path);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
index a172719..6bd8c0f 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
@@ -53,6 +53,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.plugin.PluginDeploymentType;
+import org.rhq.core.domain.plugin.PluginStatusType;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.core.util.stream.StreamUtil;
@@ -175,8 +176,17 @@ public class ServerPluginScanner {
}
ServerPluginsLocal serverPluginsManager = LookupUtil.getServerPlugins();
- SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
- serverPluginsManager.registerPlugin(subjectManager.getOverlord(), plugin,
pluginFile);
+
+ // see if this plugin has been deleted previously; if so, don't register
and delete the file
+ PluginStatusType status =
serverPluginsManager.getServerPluginStatus(pluginName);
+ if (PluginStatusType.DELETED == status) {
+ log.warn("Plugin file [" + pluginFile + "] has been
detected but that plugin with name [" + pluginName
+ + "] was previously undeployed. Will not re-register that plugin
and the file will be deleted.");
+ pluginFile.delete();
+ } else {
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+ serverPluginsManager.registerServerPlugin(subjectManager.getOverlord(),
plugin, pluginFile);
+ }
} catch (Exception e) {
log.error("Failed to register RHQ plugin file [" + pluginFile +
"]", e);
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 577ea92..67d5efd 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -121,7 +121,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
return descriptor;
}
- public List<String> getPluginNamesByEnabled(boolean enabled) {
+ public List<String> getServerPluginNamesByEnabled(boolean enabled) {
Query query =
entityManager.createNamedQuery(Plugin.QUERY_GET_NAMES_BY_ENABLED_AND_TYPE);
query.setParameter("enabled", Boolean.valueOf(enabled));
query.setParameter("type", PluginDeploymentType.SERVER);
@@ -134,7 +134,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
return; // nothing to do
}
- serverPluginsBean.setPluginEnabledFlag(subject, pluginIds, true);
+ serverPluginsBean.setServerPluginEnabledFlag(subject, pluginIds, true);
// only restart the master if it was started to begin with
ServerPluginServiceManagement serverPluginService =
LookupUtil.getServerPluginService();
@@ -150,7 +150,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
return new ArrayList<Plugin>(); // nothing to do
}
- serverPluginsBean.setPluginEnabledFlag(subject, pluginIds, false);
+ serverPluginsBean.setServerPluginEnabledFlag(subject, pluginIds, false);
ServerPluginServiceManagement serverPluginService =
LookupUtil.getServerPluginService();
MasterServerPluginContainer master =
serverPluginService.getMasterPluginContainer();
@@ -188,7 +188,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
return new ArrayList<Plugin>(); // nothing to do
}
- serverPluginsBean.setPluginEnabledFlag(subject, pluginIds, false);
+ serverPluginsBean.setServerPluginEnabledFlag(subject, pluginIds, false);
ServerPluginServiceManagement serverPluginService =
LookupUtil.getServerPluginService();
MasterServerPluginContainer master =
serverPluginService.getMasterPluginContainer();
@@ -238,7 +238,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- public void setPluginEnabledFlag(Subject subject, List<Integer> pluginIds,
boolean enabled) throws Exception {
+ public void setServerPluginEnabledFlag(Subject subject, List<Integer>
pluginIds, boolean enabled) throws Exception {
if (pluginIds == null || pluginIds.size() == 0) {
return; // nothing to do
}
@@ -255,20 +255,21 @@ public class ServerPluginsBean implements ServerPluginsLocal {
@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- public void setPluginStatus(Subject subject, List<Integer> pluginIds,
PluginStatusType status) throws Exception {
+ public void setServerPluginStatus(Subject subject, List<Integer> pluginIds,
PluginStatusType status)
+ throws Exception {
if (pluginIds == null || pluginIds.size() == 0) {
return; // nothing to do
}
List<Plugin> plugins = getServerPluginsById(pluginIds);
for (Plugin plugin : plugins) {
plugin.setStatus(status);
- updatePluginExceptContent(subject, plugin);
+ updateServerPluginExceptContent(subject, plugin);
}
return;
}
@RequiredPermission(Permission.MANAGE_SETTINGS)
- public Plugin registerPlugin(Subject subject, Plugin plugin, File pluginFile) throws
Exception {
+ public Plugin registerServerPlugin(Subject subject, Plugin plugin, File pluginFile)
throws Exception {
if (plugin.getDeployment() != PluginDeploymentType.SERVER) {
throw new IllegalArgumentException("Plugin [" + plugin.getName()
@@ -302,9 +303,14 @@ public class ServerPluginsBean implements ServerPluginsLocal {
}
if (plugin.getId() == 0) {
+ PluginStatusType status = getServerPluginStatus(plugin.getName());
+ if (PluginStatusType.DELETED == status) {
+ throw new IllegalArgumentException("Cannot register plugin
[" + plugin.getName()
+ + "], it has been previously marked as deleted.");
+ }
entityManager.persist(plugin);
} else {
- plugin = updatePluginExceptContent(subject, plugin);
+ plugin = updateServerPluginExceptContent(subject, plugin);
}
if (pluginFile != null) {
@@ -318,11 +324,18 @@ public class ServerPluginsBean implements ServerPluginsLocal {
}
@RequiredPermission(Permission.MANAGE_SETTINGS)
- public Plugin updatePluginExceptContent(Subject subject, Plugin plugin) throws
Exception {
+ public Plugin updateServerPluginExceptContent(Subject subject, Plugin plugin) throws
Exception {
+
// this method is here because we need a way to update the plugin's
information
// without blowing away the content data. Because we do not want to load the
// content blob in memory, the plugin's content field will be null - if we
were
// to entityManager.merge that plugin POJO, it would null out that blob column.
+
+ if (plugin.getDeployment() != PluginDeploymentType.SERVER) {
+ throw new IllegalArgumentException("Plugin [" + plugin.getName()
+ + "] must be a server plugin to be updated");
+ }
+
if (plugin.getId() == 0) {
throw new IllegalArgumentException("Plugin must already exist to update
it");
} else {
@@ -349,6 +362,19 @@ public class ServerPluginsBean implements ServerPluginsLocal {
return plugin;
}
+ public PluginStatusType getServerPluginStatus(String pluginName) {
+ Query q =
entityManager.createNamedQuery(Plugin.QUERY_GET_STATUS_BY_NAME_AND_TYPE);
+ q.setParameter("name", pluginName);
+ q.setParameter("type", PluginDeploymentType.SERVER);
+ PluginStatusType status;
+ try {
+ status = (PluginStatusType) q.getSingleResult();
+ } catch (NoResultException nre) {
+ status = null; // doesn't exist in the DB, tell the caller this by
returning null
+ }
+ return status;
+ }
+
/**
* This will write the contents of the given plugin file to the database.
* This will assume the MD5 in the database is already correct, so this
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
index 528d87c..68afc0e 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
@@ -70,7 +70,7 @@ public interface ServerPluginsLocal {
* if <code>false</code>, return only the names of plugins
that are disabled.
* @return list of plugin names that match the enabled criteria
*/
- List<String> getPluginNamesByEnabled(boolean enabled);
+ List<String> getServerPluginNamesByEnabled(boolean enabled);
/**
* Enables the plugins and restarts the server plugin container.
@@ -110,7 +110,7 @@ public interface ServerPluginsLocal {
* @param enabled the value of the enabled flag for the plugins
* @throws if failed to update a plugin
*/
- void setPluginEnabledFlag(Subject subject, List<Integer> pluginIds, boolean
enabled) throws Exception;
+ void setServerPluginEnabledFlag(Subject subject, List<Integer> pluginIds,
boolean enabled) throws Exception;
/**
* Sets the status flag in the database but does NOT restart the server plugin
container.
@@ -123,7 +123,7 @@ public interface ServerPluginsLocal {
* @param enabled the value of the enabled flag for the plugins
* @throws if failed to update one of the plugins
*/
- void setPluginStatus(Subject subject, List<Integer> pluginIds, PluginStatusType
status) throws Exception;
+ void setServerPluginStatus(Subject subject, List<Integer> pluginIds,
PluginStatusType status) throws Exception;
/**
* Registers the given plugin to the database.
@@ -134,7 +134,7 @@ public interface ServerPluginsLocal {
* @return the plugin after being persisted
* @throws Exception if failed to fully register the plugin
*/
- Plugin registerPlugin(Subject subject, Plugin plugin, File pluginFile) throws
Exception;
+ Plugin registerServerPlugin(Subject subject, Plugin plugin, File pluginFile) throws
Exception;
/**
* Given a plugin that already exists, this will update that plugin's data in the
database,
@@ -146,5 +146,15 @@ public interface ServerPluginsLocal {
* @return the updated plugin
* @throws Exception if the plugin did not already exist or an error occurred that
caused the update to fail
*/
- public Plugin updatePluginExceptContent(Subject subject, Plugin plugin) throws
Exception;
+ Plugin updateServerPluginExceptContent(Subject subject, Plugin plugin) throws
Exception;
+
+ /**
+ * Given the name of a server plugin, this will return the status of that plugin.
+ * Use this to determine if a plugin has been deleted or not.
+ *
+ * @param pluginName the name of the plugin whose status is to be returned.
+ * @return the status of the plugin, to indicate if the plugin has been deleted or is
installed.
+ * <code>null</code> indicates an unknown plugin.
+ */
+ PluginStatusType getServerPluginStatus(String pluginName);
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
index 40bb776..8ebabd4 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
@@ -357,7 +357,7 @@ public class MasterServerPluginContainer {
* @return names of "blacklisted" plugins that should not be loaded
*/
protected List<String> getDisabledPluginNames() {
- List<String> disabledPlugins =
LookupUtil.getServerPlugins().getPluginNamesByEnabled(false);
+ List<String> disabledPlugins =
LookupUtil.getServerPlugins().getServerPluginNamesByEnabled(false);
return disabledPlugins;
}
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
index 3301ba0..d5817a2 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
@@ -46,6 +46,9 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
@Test
public class ServerPluginsBeanTest extends AbstractEJB3Test {
+
+ private static final String TEST_PLUGIN_NAME_PREFIX = "serverplugintest";
+
private ServerPluginsLocal serverPluginsBean;
@BeforeMethod
@@ -96,10 +99,10 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
public void testGetPlugins() throws Exception {
Plugin p1 = registerPlugin(1);
Plugin p2 = registerPlugin(2);
- List<String> pluginNames =
this.serverPluginsBean.getPluginNamesByEnabled(true);
+ List<String> pluginNames =
this.serverPluginsBean.getServerPluginNamesByEnabled(true);
assert pluginNames.contains(p1.getName()) : pluginNames;
assert pluginNames.contains(p2.getName()) : pluginNames;
- pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(false);
+ pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(false);
assert !pluginNames.contains(p1.getName()) : pluginNames;
assert !pluginNames.contains(p2.getName()) : pluginNames;
@@ -144,19 +147,19 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
assert disabled.contains(p2) : disabled;
assert disabled.get(0).getStatus() == PluginStatusType.INSTALLED; // still
installed
assert disabled.get(1).getStatus() == PluginStatusType.INSTALLED; // still
installed
- List<String> pluginNames =
this.serverPluginsBean.getPluginNamesByEnabled(false);
+ List<String> pluginNames =
this.serverPluginsBean.getServerPluginNamesByEnabled(false);
assert pluginNames.contains(p1.getName()) : pluginNames;
assert pluginNames.contains(p2.getName()) : pluginNames;
- pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(true);
+ pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(true);
assert !pluginNames.contains(p1.getName()) : pluginNames;
assert !pluginNames.contains(p2.getName()) : pluginNames;
// re-enable them
this.serverPluginsBean.enableServerPlugins(getOverlord(), ids);
- pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(true);
+ pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(true);
assert pluginNames.contains(p1.getName()) : pluginNames;
assert pluginNames.contains(p2.getName()) : pluginNames;
- pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(false);
+ pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(false);
assert !pluginNames.contains(p1.getName()) : pluginNames;
assert !pluginNames.contains(p2.getName()) : pluginNames;
@@ -173,9 +176,21 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
public void testUndeployPlugins() throws Exception {
+ PluginStatusType status;
+
+ status = this.serverPluginsBean.getServerPluginStatus(TEST_PLUGIN_NAME_PREFIX +
"1");
+ assert status == null;
+ status = this.serverPluginsBean.getServerPluginStatus(TEST_PLUGIN_NAME_PREFIX +
"2");
+ assert status == null;
+
Plugin p1 = registerPlugin(1);
Plugin p2 = registerPlugin(2);
+ status = this.serverPluginsBean.getServerPluginStatus(p1.getName());
+ assert status == PluginStatusType.INSTALLED;
+ status = this.serverPluginsBean.getServerPluginStatus(p2.getName());
+ assert status == PluginStatusType.INSTALLED;
+
List<Integer> ids = new ArrayList<Integer>(2);
ids.add(p1.getId());
ids.add(p2.getId());
@@ -186,10 +201,10 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
assert undeployed.get(0).getStatus() == PluginStatusType.DELETED;
assert undeployed.get(1).getStatus() == PluginStatusType.DELETED;
- List<String> pluginNames =
this.serverPluginsBean.getPluginNamesByEnabled(false);
+ List<String> pluginNames =
this.serverPluginsBean.getServerPluginNamesByEnabled(false);
assert !pluginNames.contains(p1.getName()) : "deleted plugins should not be
returned even here" + pluginNames;
assert !pluginNames.contains(p2.getName()) : "deleted plugins should not be
returned even here" + pluginNames;
- pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(true);
+ pluginNames = this.serverPluginsBean.getServerPluginNamesByEnabled(true);
assert !pluginNames.contains(p1.getName()) : pluginNames;
assert !pluginNames.contains(p2.getName()) : pluginNames;
@@ -206,12 +221,12 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
}
private Plugin registerPlugin(int index) throws Exception {
- Plugin plugin = new Plugin(0, "serverplugintest" + index,
"path", "displayName", true,
+ Plugin plugin = new Plugin(0, TEST_PLUGIN_NAME_PREFIX + index, "path",
"displayName", true,
PluginStatusType.INSTALLED, "description", "help",
"md5", "version", "ampsVersion",
PluginDeploymentType.SERVER, createPluginConfiguration(),
createScheduledJobsConfiguration(), System
.currentTimeMillis(), System.currentTimeMillis());
- plugin = this.serverPluginsBean.registerPlugin(getOverlord(), plugin, null);
+ plugin = this.serverPluginsBean.registerServerPlugin(getOverlord(), plugin,
null);
assert plugin.getId() > 0;
assert plugin.isEnabled() == true;
assert plugin.getDeployment() == PluginDeploymentType.SERVER;
commit 26c981d4720dbb65e02ea9ae5994d0888e8275c5
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 20 18:20:27 2009 -0500
do not stream plugins to filesystem if the database flagged it as deleted
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
index d6cf6fe..a172719 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
@@ -353,7 +353,7 @@ public class ServerPluginScanner {
// get all the plugins
ps = conn.prepareStatement("SELECT NAME, PATH, MD5, MTIME, VERSION FROM
" + Plugin.TABLE_NAME
- + " WHERE DEPLOYMENT = 'SERVER'");
+ + " WHERE DEPLOYMENT = 'SERVER' AND STATUS =
'INSTALLED' ");
rs = ps.executeQuery();
while (rs.next()) {
String name = rs.getString(1);
@@ -451,7 +451,7 @@ public class ServerPluginScanner {
// write all our updated plugins to the file system
ps = conn.prepareStatement("SELECT CONTENT FROM " +
Plugin.TABLE_NAME
- + " WHERE DEPLOYMENT = 'SERVER' AND NAME = ?");
+ + " WHERE DEPLOYMENT = 'SERVER' AND STATUS =
'INSTALLED' AND NAME = ?");
for (Plugin plugin : updatedPlugins) {
File file = new File(this.getServerPluginDir(), plugin.getPath());
@@ -516,8 +516,9 @@ public class ServerPluginScanner {
ResultSet rs = null;
TransactionManager tm = null;
- String sql = "UPDATE " + Plugin.TABLE_NAME
- + " SET CONTENT = ?, MD5 = ?, MTIME = ?, PATH = ? WHERE DEPLOYMENT =
'SERVER' AND NAME = ?";
+ String sql = "UPDATE "
+ + Plugin.TABLE_NAME
+ + " SET CONTENT = ?, MD5 = ?, MTIME = ?, PATH = ? WHERE DEPLOYMENT =
'SERVER' AND STATUS = 'INSTALLED' AND NAME = ?";
// if 'different' is true, give bogus data so the plugin deployer will
think the plugin on the file system is new
String md5 = (!different) ? MessageDigestGenerator.getDigestString(file) :
"TO BE UPDATED";
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index bfd828d..577ea92 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -284,6 +284,10 @@ public class ServerPluginsBean implements ServerPluginsLocal {
}
if (existingPlugin != null) {
+ if (existingPlugin.getStatus() == PluginStatusType.DELETED) {
+ throw new IllegalArgumentException("Cannot register plugin [" +
plugin.getName()
+ + "], it has been marked as deleted");
+ }
Plugin obsolete = ServerPluginDescriptorUtil.determineObsoletePlugin(plugin,
existingPlugin);
if (obsolete == existingPlugin) { // yes use == for reference equality
newOrUpdated = true;
commit 487407253bff60da59588b7bc814e6d14b0fb04c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 20 17:47:29 2009 -0500
add the ability to mark a plugin DELETED. add authz to server plugin SLSB calls. add
tests
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 6f6f12b..8f466be 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.69</db.schema.version>
+ <db.schema.version>2.69.1</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/amps-schema.xml
b/modules/core/dbutils/src/main/scripts/dbsetup/amps-schema.xml
index 5120803..dbc4a19 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/amps-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/amps-schema.xml
@@ -12,6 +12,7 @@
<column name="VERSION" size="200"
type="VARCHAR2" required="false"/>
<column name="AMPS_VERSION" size="16"
type="VARCHAR2" required="false"/>
<column name="ENABLED" type="BOOLEAN"
required="true"/>
+ <column name="STATUS" size="16" type="VARCHAR2"
required="true"/>
<column name="HELP" type="CLOB"
required="false"/>
<column name="PATH" size="500" type="VARCHAR2"
required="true"/>
<column name="MD5" size="100" type="VARCHAR2"
required="true"/>
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 4cc035a..07831eb 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2172,6 +2172,17 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.69.1">
+ <!-- add the new column that indicates if this is plugin has been deleted
-->
+ <schema-addColumn table="RHQ_PLUGIN" column="STATUS"
columnType="VARCHAR2" precision="16"/>
+ <schema-directSQL>
+ <statement desc="Updating existing plugins with status of
INSTALLED">
+ UPDATE RHQ_PLUGIN SET STATUS = 'INSTALLED'
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_PLUGIN" column="STATUS"
nullable="FALSE"/>
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
index 2b3913d..552179f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
@@ -59,7 +59,7 @@ import org.rhq.core.util.MessageDigestGenerator;
@NamedQuery(name = Plugin.QUERY_GET_NAMES_BY_ENABLED_AND_TYPE, query = ""
//
+ " SELECT p.name " //
+ " FROM Plugin AS p " //
- + " WHERE p.enabled = :enabled AND p.deployment = :type"), //
+ + " WHERE p.enabled = :enabled AND p.deployment = :type AND p.status =
'INSTALLED' "), //
// this query does not load the content blob, but loads everything else
@NamedQuery(name = Plugin.QUERY_FIND_BY_IDS_AND_TYPE, query = "" //
@@ -69,6 +69,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " p.path, " //
+ " p.displayName, " //
+ " p.enabled, " //
+ + " p.status, " //
+ " p.description, " //
+ " p.help, " //
+ " p.md5, " //
@@ -82,7 +83,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " FROM Plugin AS p " //
+ " LEFT JOIN p.pluginConfiguration " //
+ " LEFT JOIN p.scheduledJobsConfiguration " //
- + " WHERE p.id IN (:ids) AND p.deployment = :type"), //
+ + " WHERE p.id IN (:ids) AND p.deployment = :type AND p.status =
'INSTALLED' "), //
// this query does not load the content blob, but loads everything else
@NamedQuery(name = Plugin.QUERY_FIND_BY_NAME, query = "" //
@@ -92,6 +93,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " p.path, " //
+ " p.displayName, " //
+ " p.enabled, " //
+ + " p.status, " //
+ " p.description, " //
+ " p.help, " //
+ " p.md5, " //
@@ -105,7 +107,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " FROM Plugin AS p " //
+ " LEFT JOIN p.pluginConfiguration " //
+ " LEFT JOIN p.scheduledJobsConfiguration " //
- + " WHERE p.name=:name"), //
+ + " WHERE p.name=:name AND p.status = 'INSTALLED' "), //
// this query does not load the content blob, but loads everything else
@NamedQuery(name = Plugin.QUERY_FIND_ALL_AGENT, query = "" //
@@ -115,6 +117,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " p.path, " //
+ " p.displayName, " //
+ " p.enabled, " //
+ + " p.status, " //
+ " p.description, " //
+ " p.help, " //
+ " p.md5, " //
@@ -128,7 +131,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " FROM Plugin AS p " //
+ " LEFT JOIN p.pluginConfiguration " //
+ " LEFT JOIN p.scheduledJobsConfiguration " //
- + " WHERE p.deployment = 'AGENT'"), //
+ + " WHERE p.deployment = 'AGENT' AND p.status =
'INSTALLED' "), //
// this query does not load the content blob, but loads everything else
@NamedQuery(name = Plugin.QUERY_FIND_ALL_SERVER, query = "" //
@@ -138,6 +141,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " p.path, " //
+ " p.displayName, " //
+ " p.enabled, " //
+ + " p.status, " //
+ " p.description, " //
+ " p.help, " //
+ " p.md5, " //
@@ -151,7 +155,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " FROM Plugin AS p " //
+ " LEFT JOIN p.pluginConfiguration " //
+ " LEFT JOIN p.scheduledJobsConfiguration " //
- + " WHERE p.deployment = 'SERVER'"), //
+ + " WHERE p.deployment = 'SERVER' AND p.status =
'INSTALLED' "), //
// this query does not update the content blob or ctime
@NamedQuery(name = Plugin.UPDATE_ALL_BUT_CONTENT, query = "" //
@@ -160,6 +164,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " p.displayName = :displayName, " //
+ " p.description = :description, " //
+ " p.enabled = :enabled, " //
+ + " p.status = :status, " //
+ " p.help = :help, " //
+ " p.version = :version, " //
+ " p.ampsVersion = :ampsVersion," //
@@ -185,6 +190,7 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " p.path, " //
+ " p.displayName, " //
+ " p.enabled, " //
+ + " p.status, " //
+ " p.description, " //
+ " p.help, " //
+ " p.md5, " //
@@ -198,7 +204,8 @@ import org.rhq.core.util.MessageDigestGenerator;
+ " FROM Plugin p " //
+ " LEFT JOIN p.pluginConfiguration " //
+ " LEFT JOIN p.scheduledJobsConfiguration " //
- + " WHERE p.name IN ( SELECT rt.plugin " //
+ + " WHERE p.status = 'INSTALLED' AND " //
+ + " p.name IN ( SELECT rt.plugin " //
+ " FROM Resource res " //
+ " JOIN res.resourceType rt " //
+ " WHERE ( rt.category = :resourceCategory OR
:resourceCategory IS NULL ) " //
@@ -249,6 +256,10 @@ public class Plugin implements Serializable {
@Column(name = "ENABLED", nullable = false)
private boolean enabled = true;
+ @Column(name = "STATUS", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private PluginStatusType status = PluginStatusType.INSTALLED;
+
@Column(name = "HELP", nullable = true)
private String help;
@@ -334,6 +345,7 @@ public class Plugin implements Serializable {
* @param path
* @param displayName
* @param enabled
+ * @param status
* @param description
* @param help
* @param md5
@@ -345,14 +357,16 @@ public class Plugin implements Serializable {
* @param ctime
* @param mtime
*/
- public Plugin(int id, String name, String path, String displayName, boolean enabled,
String description,
- String help, String md5, String version, String ampsVersion, PluginDeploymentType
deployment,
- Configuration pluginConfig, Configuration scheduledJobsConfig, long ctime, long
mtime) {
+ public Plugin(int id, String name, String path, String displayName, boolean enabled,
PluginStatusType status,
+ String description, String help, String md5, String version, String ampsVersion,
+ PluginDeploymentType deployment, Configuration pluginConfig, Configuration
scheduledJobsConfig, long ctime,
+ long mtime) {
this.id = id;
this.name = name;
this.path = path;
this.displayName = displayName;
this.enabled = enabled;
+ this.status = status;
this.description = description;
this.help = help;
this.md5 = md5;
@@ -455,6 +469,17 @@ public class Plugin implements Serializable {
this.enabled = enabled;
}
+ public PluginStatusType getStatus() {
+ return status;
+ }
+
+ public void setStatus(PluginStatusType status) {
+ this.status = status;
+ if (this.status == PluginStatusType.DELETED) {
+ this.enabled = false;
+ }
+ }
+
public String getHelp() {
return help;
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/PluginStatusType.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/PluginStatusType.java
new file mode 100644
index 0000000..40fd9ab
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/PluginStatusType.java
@@ -0,0 +1,29 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.plugin;
+
+/**
+ * Indicates if a plugin is installed or has been deleted.
+ *
+ * @author John Mazzitelli
+ */
+public enum PluginStatusType {
+ INSTALLED, DELETED
+}
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
index 77d9312..7e3ad25 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java
@@ -41,6 +41,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.plugin.PluginDeploymentType;
+import org.rhq.core.domain.plugin.PluginStatusType;
import org.rhq.core.domain.test.AbstractEJB3Test;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.stream.StreamUtil;
@@ -58,12 +59,14 @@ public class PluginTest extends AbstractEJB3Test {
String path = "/test/Update";
String displayName = "Plugin Test - testUpdate";
boolean enabled = true;
+ PluginStatusType status = PluginStatusType.INSTALLED;
String md5 = "abcdef";
byte[] content = "the content is here".getBytes();
Plugin plugin = new Plugin(name, path);
plugin.setDisplayName(displayName);
plugin.setEnabled(enabled);
+ plugin.setStatus(status);
plugin.setMD5(md5);
plugin.setVersion(null);
plugin.setDescription(null);
@@ -83,6 +86,7 @@ public class PluginTest extends AbstractEJB3Test {
assert plugin.getPath().equals(path);
assert plugin.getDisplayName().equals(displayName);
assert plugin.isEnabled() == enabled;
+ assert plugin.getStatus() == PluginStatusType.INSTALLED;
assert plugin.getMD5().equals(md5);
assert plugin.getVersion() == null;
assert plugin.getDescription() == null;
@@ -119,6 +123,7 @@ public class PluginTest extends AbstractEJB3Test {
q.setParameter("path", path);
q.setParameter("displayName", displayName);
q.setParameter("enabled", enabled);
+ q.setParameter("status", status);
q.setParameter("md5", md5);
q.setParameter("version", version);
q.setParameter("ampsVersion", ampsVersion);
@@ -179,11 +184,13 @@ public class PluginTest extends AbstractEJB3Test {
String path = "/test/Persist";
String displayName = "Plugin Test - testPersist";
boolean enabled = true;
+ PluginStatusType status = PluginStatusType.INSTALLED;
String md5 = "abcdef";
Plugin plugin = new Plugin(name, path);
plugin.setDisplayName(displayName);
plugin.setEnabled(enabled);
+ plugin.setStatus(status);
plugin.setMD5(md5);
// the following are the only nullable fields
@@ -202,6 +209,7 @@ public class PluginTest extends AbstractEJB3Test {
assert plugin.getPath().equals(path);
assert plugin.getDisplayName().equals(displayName);
assert plugin.isEnabled() == enabled;
+ assert plugin.getStatus() == PluginStatusType.INSTALLED;
assert plugin.getMD5().equals(md5);
assert plugin.getVersion() == null;
assert plugin.getDescription() == null;
@@ -210,6 +218,17 @@ public class PluginTest extends AbstractEJB3Test {
assert plugin.getScheduledJobsConfiguration() == null;
assert plugin.getHelp() == null;
assert plugin.getContent() == null;
+
+ // side check - see that "deleting" a plugin also sets enabled to
false
+ assert plugin.isEnabled() == true;
+ assert plugin.getStatus() == PluginStatusType.INSTALLED;
+ plugin.setStatus(PluginStatusType.DELETED);
+ assert plugin.getStatus() == PluginStatusType.DELETED;
+ assert plugin.isEnabled() == false;
+ plugin = em.merge(plugin);
+ assert plugin.getStatus() == PluginStatusType.DELETED;
+ assert plugin.isEnabled() == false;
+
} finally {
getTransactionManager().rollback();
}
@@ -334,6 +353,25 @@ public class PluginTest extends AbstractEJB3Test {
}
assert got_it : "findAll query failed to get our plugin";
+ // mark a plugin deleted - all of our queries should then never see it
+ plugin.setStatus(PluginStatusType.DELETED);
+ em.merge(plugin);
+
+ query = em.createNamedQuery(Plugin.QUERY_FIND_BY_NAME);
+ query.setParameter("name", name);
+ List<?> results = query.getResultList();
+ assert results.size() == 0;
+
+ query = em.createNamedQuery(Plugin.QUERY_FIND_BY_IDS_AND_TYPE);
+ query.setParameter("ids",
Arrays.asList(Integer.valueOf(plugin.getId())));
+ query.setParameter("type", plugin.getDeployment());
+ results = query.getResultList();
+ assert results.size() == 0;
+
+ query = em.createNamedQuery(Plugin.QUERY_FIND_ALL_SERVER);
+ results = query.getResultList();
+ assert results.size() == 0;
+
} finally {
getTransactionManager().rollback();
}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
index 9fd46f2..cfc99cf 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
@@ -38,6 +38,7 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.core.gui.util.StringUtility;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.authz.PermissionException;
@@ -79,9 +80,7 @@ public class InstalledPluginsUIBean {
scanner.scanAndRegister();
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Done
scanning for updated plugins.");
} catch (Exception e) {
- String err = "Failed to scan for updated plugins";
- log.error(err + " - Cause: " + e);
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, err, e);
+ processException("Failed to scan for updated plugins", e);
}
}
@@ -118,9 +117,7 @@ public class InstalledPluginsUIBean {
+ "]. A scan is required now in order to register it.");
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "New plugin
uploaded: " + newPluginFilename);
} catch (Exception e) {
- String err = "Failed to process uploaded plugin";
- log.error(err + " - Cause: " + e);
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, err, e);
+ processException("Failed to process uploaded plugin", e);
}
return;
@@ -132,8 +129,15 @@ public class InstalledPluginsUIBean {
for (Plugin selectedPlugin : selectedPlugins) {
selectedPluginNames.add(selectedPlugin.getName());
}
- serverPluginsBean.enableServerPlugins(getIds(selectedPlugins));
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Enabled server
plugins: " + selectedPluginNames);
+
+ try {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ serverPluginsBean.enableServerPlugins(subject, getIds(selectedPlugins));
+ FacesContextUtility
+ .addMessage(FacesMessage.SEVERITY_INFO, "Enabled server plugins:
" + selectedPluginNames);
+ } catch (Exception e) {
+ processException("Failed to enable server plugins", e);
+ }
return;
}
@@ -143,8 +147,15 @@ public class InstalledPluginsUIBean {
for (Plugin selectedPlugin : selectedPlugins) {
selectedPluginNames.add(selectedPlugin.getName());
}
- serverPluginsBean.disableServerPlugins(getIds(selectedPlugins));
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Disabled server
plugins: " + selectedPluginNames);
+
+ try {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ serverPluginsBean.disableServerPlugins(subject, getIds(selectedPlugins));
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Disabled
server plugins: "
+ + selectedPluginNames);
+ } catch (Exception e) {
+ processException("Failed to disable server plugins", e);
+ }
return;
}
@@ -154,8 +165,15 @@ public class InstalledPluginsUIBean {
for (Plugin selectedPlugin : selectedPlugins) {
selectedPluginNames.add(selectedPlugin.getName());
}
- serverPluginsBean.undeployServerPlugins(getIds(selectedPlugins));
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Undeployed
server plugins: " + selectedPluginNames);
+
+ try {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ serverPluginsBean.undeployServerPlugins(subject, getIds(selectedPlugins));
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Undeployed
server plugins: "
+ + selectedPluginNames);
+ } catch (Exception e) {
+ processException("Failed to undeploy server plugins", e);
+ }
return;
}
@@ -193,4 +211,9 @@ public class InstalledPluginsUIBean {
+ "] does not have the proper permissions to view or manage
plugins");
}
}
+
+ private void processException(String errMsg, Exception e) {
+ log.error(errMsg + ". Cause: " + ThrowableUtil.getAllMessages(e));
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, errMsg, e);
+ }
}
\ No newline at end of file
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
index fc4b6eb..d6cf6fe 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/ServerPluginScanner.java
@@ -176,7 +176,7 @@ public class ServerPluginScanner {
ServerPluginsLocal serverPluginsManager = LookupUtil.getServerPlugins();
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
- serverPluginsManager.registerPlugin(subjectManager.getOverlord(), plugin,
descriptor, pluginFile);
+ serverPluginsManager.registerPlugin(subjectManager.getOverlord(), plugin,
pluginFile);
} catch (Exception e) {
log.error("Failed to register RHQ plugin file [" + pluginFile +
"]", e);
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
index 27234f8..bfd828d 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsBean.java
@@ -46,6 +46,8 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.plugin.PluginDeploymentType;
+import org.rhq.core.domain.plugin.PluginStatusType;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.RequiredPermission;
@@ -102,7 +104,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
public List<Plugin> getServerPluginsById(List<Integer> pluginIds) {
if (pluginIds == null || pluginIds.size() == 0) {
- return new ArrayList<Plugin>();
+ return new ArrayList<Plugin>(); // nothing to do
}
Query query = entityManager.createNamedQuery(Plugin.QUERY_FIND_BY_IDS_AND_TYPE);
query.setParameter("ids", pluginIds);
@@ -126,14 +128,29 @@ public class ServerPluginsBean implements ServerPluginsLocal {
return query.getResultList();
}
- public void enableServerPlugins(List<Integer> pluginIds) {
- serverPluginsBean.setPluginEnabledFlag(pluginIds, true);
- LookupUtil.getServerPluginService().restartMasterPluginContainer();
+ @RequiredPermission(Permission.MANAGE_SETTINGS)
+ public void enableServerPlugins(Subject subject, List<Integer> pluginIds)
throws Exception {
+ if (pluginIds == null || pluginIds.size() == 0) {
+ return; // nothing to do
+ }
+
+ serverPluginsBean.setPluginEnabledFlag(subject, pluginIds, true);
+
+ // only restart the master if it was started to begin with
+ ServerPluginServiceManagement serverPluginService =
LookupUtil.getServerPluginService();
+ if (serverPluginService.isMasterPluginContainerStarted()) {
+ serverPluginService.restartMasterPluginContainer();
+ }
return;
}
- public List<Plugin> disableServerPlugins(List<Integer> pluginIds) {
- serverPluginsBean.setPluginEnabledFlag(pluginIds, false);
+ @RequiredPermission(Permission.MANAGE_SETTINGS)
+ public List<Plugin> disableServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception {
+ if (pluginIds == null || pluginIds.size() == 0) {
+ return new ArrayList<Plugin>(); // nothing to do
+ }
+
+ serverPluginsBean.setPluginEnabledFlag(subject, pluginIds, false);
ServerPluginServiceManagement serverPluginService =
LookupUtil.getServerPluginService();
MasterServerPluginContainer master =
serverPluginService.getMasterPluginContainer();
@@ -144,23 +161,34 @@ public class ServerPluginsBean implements ServerPluginsLocal {
Plugin doomedPlugin = entityManager.find(Plugin.class, pluginId);
if (doomedPlugin != null) {
doomedPlugins.add(doomedPlugin);
- AbstractTypeServerPluginContainer pc =
master.getPluginContainer(doomedPlugin.getName());
- if (pc != null) {
- try {
- pc.unschedulePluginJobs(doomedPlugin.getName());
- } catch (Exception e) {
- log.warn("Failed to unschedule jobs for plugin [" +
doomedPlugin.getName() + "]", e);
+ if (master != null) {
+ AbstractTypeServerPluginContainer pc =
master.getPluginContainer(doomedPlugin.getName());
+ if (pc != null) {
+ try {
+ pc.unschedulePluginJobs(doomedPlugin.getName());
+ } catch (Exception e) {
+ log.warn("Failed to unschedule jobs for plugin [" +
doomedPlugin.getName() + "]", e);
+ }
}
}
}
}
- serverPluginService.restartMasterPluginContainer();
+ // only restart if the master was started to begin with; otherwise, leave it
down
+ if (master != null) {
+ serverPluginService.restartMasterPluginContainer();
+ }
+
return doomedPlugins;
}
- public List<Plugin> undeployServerPlugins(List<Integer> pluginIds) {
- serverPluginsBean.setPluginEnabledFlag(pluginIds, false);
+ @RequiredPermission(Permission.MANAGE_SETTINGS)
+ public List<Plugin> undeployServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception {
+ if (pluginIds == null || pluginIds.size() == 0) {
+ return new ArrayList<Plugin>(); // nothing to do
+ }
+
+ serverPluginsBean.setPluginEnabledFlag(subject, pluginIds, false);
ServerPluginServiceManagement serverPluginService =
LookupUtil.getServerPluginService();
MasterServerPluginContainer master =
serverPluginService.getMasterPluginContainer();
@@ -171,12 +199,14 @@ public class ServerPluginsBean implements ServerPluginsLocal {
Plugin doomedPlugin = entityManager.find(Plugin.class, pluginId);
if (doomedPlugin != null) {
doomedPlugins.add(doomedPlugin);
- AbstractTypeServerPluginContainer pc =
master.getPluginContainer(doomedPlugin.getName());
- if (pc != null) {
- try {
- pc.unschedulePluginJobs(doomedPlugin.getName());
- } catch (Exception e) {
- log.warn("Failed to unschedule jobs for plugin [" +
doomedPlugin.getName() + "]", e);
+ if (master != null) {
+ AbstractTypeServerPluginContainer pc =
master.getPluginContainer(doomedPlugin.getName());
+ if (pc != null) {
+ try {
+ pc.unschedulePluginJobs(doomedPlugin.getName());
+ } catch (Exception e) {
+ log.warn("Failed to unschedule jobs for plugin [" +
doomedPlugin.getName() + "]", e);
+ }
}
}
@@ -185,35 +215,65 @@ public class ServerPluginsBean implements ServerPluginsLocal {
// config can be set to the new cofig definition's default values.
doomedPlugin.setPluginConfiguration(null);
doomedPlugin.setScheduledJobsConfiguration(null);
-
- // TODO: this really won't do anything, our server plugin scanner
will see it missing
- // and stream it back on the file system. Need to add a DELETED
column to RHQ_PLUGIN
- // and call doomedPlugin.setDeleted(true). When deleted is true,
our scanner can
- // skip writing the file to disk. All plugin queries should avoid
returning
- // plugin rows that have deleted=true. Only then will removing it
from the
- // file system as we do below actually help.
- File pluginDir = serverPluginService.getServerPluginsDirectory();
- File currentFile = new File(pluginDir, doomedPlugin.getPath());
- currentFile.delete();
+ doomedPlugin.setStatus(PluginStatusType.DELETED);
+
+ try {
+ File pluginDir = serverPluginService.getServerPluginsDirectory();
+ File currentFile = new File(pluginDir, doomedPlugin.getPath());
+ currentFile.delete();
+ } catch (Exception e) {
+ log.error("Failed to delete the undeployed plugin [" +
doomedPlugin.getPath() + "]. Cause: "
+ + ThrowableUtil.getAllMessages(e));
+ }
}
}
- serverPluginService.restartMasterPluginContainer();
+ // only restart if the master was started to begin with; otherwise, leave it
down
+ if (master != null) {
+ serverPluginService.restartMasterPluginContainer();
+ }
+
return doomedPlugins;
}
+ @RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- public void setPluginEnabledFlag(List<Integer> pluginIds, boolean enabled) {
+ public void setPluginEnabledFlag(Subject subject, List<Integer> pluginIds,
boolean enabled) throws Exception {
+ if (pluginIds == null || pluginIds.size() == 0) {
+ return; // nothing to do
+ }
Query q = entityManager.createNamedQuery(Plugin.UPDATE_PLUGINS_ENABLED_BY_IDS);
q.setParameter("ids", pluginIds);
q.setParameter("enabled", Boolean.valueOf(enabled));
- q.executeUpdate();
+ int count = q.executeUpdate();
+ if (count != pluginIds.size()) {
+ throw new Exception("Failed to update [" + pluginIds.size() +
"] plugins. Count was [" + count + "]");
+ }
+
+ return;
+ }
+
+ @RequiredPermission(Permission.MANAGE_SETTINGS)
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public void setPluginStatus(Subject subject, List<Integer> pluginIds,
PluginStatusType status) throws Exception {
+ if (pluginIds == null || pluginIds.size() == 0) {
+ return; // nothing to do
+ }
+ List<Plugin> plugins = getServerPluginsById(pluginIds);
+ for (Plugin plugin : plugins) {
+ plugin.setStatus(status);
+ updatePluginExceptContent(subject, plugin);
+ }
return;
}
@RequiredPermission(Permission.MANAGE_SETTINGS)
- public void registerPlugin(Subject subject, Plugin plugin, ServerPluginDescriptorType
descriptor, File pluginFile)
- throws Exception {
+ public Plugin registerPlugin(Subject subject, Plugin plugin, File pluginFile) throws
Exception {
+
+ if (plugin.getDeployment() != PluginDeploymentType.SERVER) {
+ throw new IllegalArgumentException("Plugin [" + plugin.getName()
+ + "] must be a server plugin to be registered");
+ }
Plugin existingPlugin = null;
boolean newOrUpdated = false;
@@ -240,7 +300,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
if (plugin.getId() == 0) {
entityManager.persist(plugin);
} else {
- plugin = updatePluginExceptContent(plugin);
+ plugin = updatePluginExceptContent(subject, plugin);
}
if (pluginFile != null) {
@@ -250,10 +310,11 @@ public class ServerPluginsBean implements ServerPluginsLocal {
log.debug("Updated plugin entity [" + plugin + "]");
}
- return;
+ return plugin;
}
- public Plugin updatePluginExceptContent(Plugin plugin) throws Exception {
+ @RequiredPermission(Permission.MANAGE_SETTINGS)
+ public Plugin updatePluginExceptContent(Subject subject, Plugin plugin) throws
Exception {
// this method is here because we need a way to update the plugin's
information
// without blowing away the content data. Because we do not want to load the
// content blob in memory, the plugin's content field will be null - if we
were
@@ -267,6 +328,7 @@ public class ServerPluginsBean implements ServerPluginsLocal {
q.setParameter("path", plugin.getPath());
q.setParameter("displayName", plugin.getDisplayName());
q.setParameter("enabled", plugin.isEnabled());
+ q.setParameter("status", plugin.getStatus());
q.setParameter("md5", plugin.getMD5());
q.setParameter("version", plugin.getVersion());
q.setParameter("ampsVersion", plugin.getAmpsVersion());
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
index 64efe4d..528d87c 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
@@ -8,6 +8,7 @@ import javax.persistence.NoResultException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.plugin.Plugin;
+import org.rhq.core.domain.plugin.PluginStatusType;
import
org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType;
/**
@@ -40,7 +41,6 @@ public interface ServerPluginsLocal {
* Call this method to fill in that data that wasn't originally loaded.
*
* @param plugin
- *
* @return the same plugin, with the relationship data loaded
*/
Plugin getServerPluginRelationships(Plugin plugin);
@@ -49,7 +49,6 @@ public interface ServerPluginsLocal {
* Get a list of plugins from their IDs.
*
* @param pluginIds the IDs of the plugins to load.
- *
* @return plugins matching the given IDs
*/
List<Plugin> getServerPluginsById(List<Integer> pluginIds);
@@ -76,56 +75,76 @@ public interface ServerPluginsLocal {
/**
* Enables the plugins and restarts the server plugin container.
*
+ * @param subject user making the request
* @param pluginIds the plugins to be enabled
+ * @throws Exception if failed to disable a plugin
*/
- void enableServerPlugins(List<Integer> pluginIds);
+ void enableServerPlugins(Subject subject, List<Integer> pluginIds) throws
Exception;
/**
* Disables the plugins and restarts the server plugin container.
*
+ * @param subject user making the request
* @param pluginIds the plugins to be disabled
- *
* @return the list of plugins that were disabled
+ * @throws Exception if failed to disable a plugin
*/
- List<Plugin> disableServerPlugins(List<Integer> pluginIds);
+ List<Plugin> disableServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception;
/**
* Removes the plugin from the system and restarts the server plugin container.
*
+ * @param subject user making the request
* @param pluginIds
- *
* @return the list of plugins that were undeployed
+ * @throws Exception if failed to undeploy a plugin
*/
- List<Plugin> undeployServerPlugins(List<Integer> pluginIds);
+ List<Plugin> undeployServerPlugins(Subject subject, List<Integer>
pluginIds) throws Exception;
/**
* Turns on or off the enabled flag in the database but does NOT restart the server
plugin container.
+ * This has "requires new" semantics, so the results are committed
immediately upon return.
+ *
+ * @param subject user making the request
+ * @param pluginIds the plugins to be enabled
+ * @param enabled the value of the enabled flag for the plugins
+ * @throws if failed to update a plugin
+ */
+ void setPluginEnabledFlag(Subject subject, List<Integer> pluginIds, boolean
enabled) throws Exception;
+
+ /**
+ * Sets the status flag in the database but does NOT restart the server plugin
container.
+ * If the status is {@link PluginStatusType#DELETED}, the enabled flag is also
flipped to <code>false</code>.
*
+ * This has "requires new" semantics, so the results are committed
immediately upon return.
+ *
+ * @param subject user making the request
* @param pluginIds the plugins to be enabled
* @param enabled the value of the enabled flag for the plugins
+ * @throws if failed to update one of the plugins
*/
- void setPluginEnabledFlag(List<Integer> pluginIds, boolean enabled);
+ void setPluginStatus(Subject subject, List<Integer> pluginIds, PluginStatusType
status) throws Exception;
/**
* Registers the given plugin to the database.
*
* @param subject the user that needs to have permissions to add a plugin to the
system
* @param plugin the plugin definition
- * @param descriptor the plugin descriptor that was found in the plugin file
* @param pluginFile the actual plugin file itself
+ * @return the plugin after being persisted
* @throws Exception if failed to fully register the plugin
*/
- void registerPlugin(Subject subject, Plugin plugin, ServerPluginDescriptorType
descriptor, File pluginFile)
- throws Exception;
+ Plugin registerPlugin(Subject subject, Plugin plugin, File pluginFile) throws
Exception;
/**
* Given a plugin that already exists, this will update that plugin's data in the
database,
* except for the content, which is left as-is. If the plugin did not yet exist, an
exception is thrown.
* You can use this to update the plugin's scheduled jobs configuration and
plugin configuration.
*
+ * @param subject user making the request
* @param plugin existing plugin with updated data
* @return the updated plugin
* @throws Exception if the plugin did not already exist or an error occurred that
caused the update to fail
*/
- public Plugin updatePluginExceptContent(Plugin plugin) throws Exception;
+ public Plugin updatePluginExceptContent(Subject subject, Plugin plugin) throws
Exception;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
index 90639d2..8250c7d 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
@@ -202,6 +202,7 @@ public class ResourceMetadataManagerBean implements
ResourceMetadataManagerLocal
q.setParameter("path", plugin.getPath());
q.setParameter("displayName", plugin.getDisplayName());
q.setParameter("enabled", plugin.isEnabled());
+ q.setParameter("status", plugin.getStatus());
q.setParameter("md5", plugin.getMD5());
q.setParameter("version", plugin.getVersion());
q.setParameter("ampsVersion", plugin.getAmpsVersion());
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
new file mode 100644
index 0000000..3301ba0
--- /dev/null
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
@@ -0,0 +1,254 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.server.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.hibernate.LazyInitializationException;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.plugin.Plugin;
+import org.rhq.core.domain.plugin.PluginDeploymentType;
+import org.rhq.core.domain.plugin.PluginStatusType;
+import org.rhq.enterprise.server.plugin.pc.generic.TestGenericServerPluginService;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author John Mazzitelli
+ */
+@Test
+public class ServerPluginsBeanTest extends AbstractEJB3Test {
+ private ServerPluginsLocal serverPluginsBean;
+
+ @BeforeMethod
+ public void beforeMethod() {
+ TestGenericServerPluginService pluginService;
+ pluginService = new TestGenericServerPluginService();
+ prepareCustomServerPluginService(pluginService);
+
+ serverPluginsBean = LookupUtil.getServerPlugins();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void afterMethod() {
+
+ EntityManager em = null;
+
+ try {
+ unprepareServerPluginService();
+ } catch (Exception e) {
+ }
+
+ try {
+ getTransactionManager().begin();
+ em = getEntityManager();
+
+ Query q = em.createQuery("SELECT p FROM Plugin p WHERE p.name LIKE
'serverplugintest%'");
+ List<Plugin> doomed = q.getResultList();
+ for (Plugin plugin : doomed) {
+ em.remove(plugin);
+ }
+
+ getTransactionManager().commit();
+ em.close();
+ em = null;
+ } catch (Exception e) {
+ try {
+ System.out.println("CANNOT CLEAN UP TEST: Cause: " + e);
+ getTransactionManager().rollback();
+ } catch (Exception ignore) {
+ }
+ } finally {
+ if (null != em) {
+ em.close();
+ }
+ }
+ }
+
+ public void testGetPlugins() throws Exception {
+ Plugin p1 = registerPlugin(1);
+ Plugin p2 = registerPlugin(2);
+ List<String> pluginNames =
this.serverPluginsBean.getPluginNamesByEnabled(true);
+ assert pluginNames.contains(p1.getName()) : pluginNames;
+ assert pluginNames.contains(p2.getName()) : pluginNames;
+ pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(false);
+ assert !pluginNames.contains(p1.getName()) : pluginNames;
+ assert !pluginNames.contains(p2.getName()) : pluginNames;
+
+ Plugin plugin = this.serverPluginsBean.getServerPlugin(p1.getName());
+ assert plugin.getId() == p1.getId() : plugin;
+ assert plugin.getName().equals(p1.getName()) : plugin;
+ assetLazyInitializationException(plugin);
+
+ plugin = this.serverPluginsBean.getServerPluginRelationships(plugin);
+ assert plugin.getPluginConfiguration() != null;
+ assert plugin.getScheduledJobsConfiguration() != null;
+ assert plugin.getPluginConfiguration().equals(p1.getPluginConfiguration());
+ assert
plugin.getScheduledJobsConfiguration().equals(p1.getScheduledJobsConfiguration());
+
+ List<Plugin> plugins = this.serverPluginsBean.getServerPlugins();
+ assert plugins.contains(p1) : plugins;
+ assert plugins.contains(p2) : plugins;
+ assetLazyInitializationException(plugins.get(0));
+ assetLazyInitializationException(plugins.get(1));
+
+ List<Integer> ids = new ArrayList<Integer>(2);
+ ids.add(p1.getId());
+ ids.add(p2.getId());
+ plugins = this.serverPluginsBean.getServerPluginsById(ids);
+ assert plugins.size() == 2 : plugins;
+ assert plugins.contains(p1) : plugins;
+ assert plugins.contains(p2) : plugins;
+ assetLazyInitializationException(plugins.get(0));
+ assetLazyInitializationException(plugins.get(1));
+ }
+
+ public void testDisableEnablePlugins() throws Exception {
+ Plugin p1 = registerPlugin(1);
+ Plugin p2 = registerPlugin(2);
+
+ List<Integer> ids = new ArrayList<Integer>(2);
+ ids.add(p1.getId());
+ ids.add(p2.getId());
+ List<Plugin> disabled =
this.serverPluginsBean.disableServerPlugins(getOverlord(), ids);
+ assert disabled.size() == 2 : disabled;
+ assert disabled.contains(p1) : disabled;
+ assert disabled.contains(p2) : disabled;
+ assert disabled.get(0).getStatus() == PluginStatusType.INSTALLED; // still
installed
+ assert disabled.get(1).getStatus() == PluginStatusType.INSTALLED; // still
installed
+ List<String> pluginNames =
this.serverPluginsBean.getPluginNamesByEnabled(false);
+ assert pluginNames.contains(p1.getName()) : pluginNames;
+ assert pluginNames.contains(p2.getName()) : pluginNames;
+ pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(true);
+ assert !pluginNames.contains(p1.getName()) : pluginNames;
+ assert !pluginNames.contains(p2.getName()) : pluginNames;
+
+ // re-enable them
+ this.serverPluginsBean.enableServerPlugins(getOverlord(), ids);
+ pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(true);
+ assert pluginNames.contains(p1.getName()) : pluginNames;
+ assert pluginNames.contains(p2.getName()) : pluginNames;
+ pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(false);
+ assert !pluginNames.contains(p1.getName()) : pluginNames;
+ assert !pluginNames.contains(p2.getName()) : pluginNames;
+
+ // make sure none of these enable/disable settings lost our config
+ Plugin plugin = this.serverPluginsBean.getServerPlugin(p1.getName());
+ plugin = this.serverPluginsBean.getServerPluginRelationships(plugin);
+ assert plugin.getPluginConfiguration() != null; // no LazyInitException should be
thrown!
+ assert plugin.getPluginConfiguration().equals(p1.getPluginConfiguration());
+ plugin = this.serverPluginsBean.getServerPlugin(p2.getName());
+ plugin = this.serverPluginsBean.getServerPluginRelationships(plugin);
+ assert plugin.getPluginConfiguration() != null; // no LazyInitException should be
thrown!
+ assert plugin.getPluginConfiguration().equals(p1.getPluginConfiguration());
+ }
+
+ public void testUndeployPlugins() throws Exception {
+
+ Plugin p1 = registerPlugin(1);
+ Plugin p2 = registerPlugin(2);
+
+ List<Integer> ids = new ArrayList<Integer>(2);
+ ids.add(p1.getId());
+ ids.add(p2.getId());
+ List<Plugin> undeployed =
this.serverPluginsBean.undeployServerPlugins(getOverlord(), ids);
+ assert undeployed.size() == 2 : undeployed;
+ assert undeployed.contains(p1) : undeployed;
+ assert undeployed.contains(p2) : undeployed;
+ assert undeployed.get(0).getStatus() == PluginStatusType.DELETED;
+ assert undeployed.get(1).getStatus() == PluginStatusType.DELETED;
+
+ List<String> pluginNames =
this.serverPluginsBean.getPluginNamesByEnabled(false);
+ assert !pluginNames.contains(p1.getName()) : "deleted plugins should not be
returned even here" + pluginNames;
+ assert !pluginNames.contains(p2.getName()) : "deleted plugins should not be
returned even here" + pluginNames;
+ pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(true);
+ assert !pluginNames.contains(p1.getName()) : pluginNames;
+ assert !pluginNames.contains(p2.getName()) : pluginNames;
+
+ // re-install them - need to implement this feature
+ // this.serverPluginsBean.enableServerPlugins(getOverlord(), ids);
+ // pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(true);
+ // assert pluginNames.contains(p1.getName()) : pluginNames;
+ // assert pluginNames.contains(p2.getName()) : pluginNames;
+ // assert undeployed.get(0).getStatus() == PluginStatusType.INSTALLED;
+ // assert undeployed.get(1).getStatus() == PluginStatusType.INSTALLED;
+ // pluginNames = this.serverPluginsBean.getPluginNamesByEnabled(false);
+ // assert !pluginNames.contains(p1.getName()) : pluginNames;
+ // assert !pluginNames.contains(p2.getName()) : pluginNames;
+ }
+
+ private Plugin registerPlugin(int index) throws Exception {
+ Plugin plugin = new Plugin(0, "serverplugintest" + index,
"path", "displayName", true,
+ PluginStatusType.INSTALLED, "description", "help",
"md5", "version", "ampsVersion",
+ PluginDeploymentType.SERVER, createPluginConfiguration(),
createScheduledJobsConfiguration(), System
+ .currentTimeMillis(), System.currentTimeMillis());
+
+ plugin = this.serverPluginsBean.registerPlugin(getOverlord(), plugin, null);
+ assert plugin.getId() > 0;
+ assert plugin.isEnabled() == true;
+ assert plugin.getDeployment() == PluginDeploymentType.SERVER;
+ assert plugin.getStatus() == PluginStatusType.INSTALLED;
+ assert plugin.getPluginConfiguration() != null;
+ assert plugin.getScheduledJobsConfiguration() != null;
+ return plugin;
+ }
+
+ private void assetLazyInitializationException(Plugin plugin) {
+ try {
+ plugin.getPluginConfiguration().toString();
+ assert false : "Should have thrown a lazy-initialization exception - we
didn't load config";
+ } catch (LazyInitializationException ok) {
+ }
+ try {
+ plugin.getScheduledJobsConfiguration().toString();
+ assert false : "Should have thrown a lazy-initialization exception - we
didn't load config";
+ } catch (LazyInitializationException ok) {
+ }
+ }
+
+ private Configuration createPluginConfiguration() {
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("simpleprop1",
"simpleprop1value"));
+ return config;
+ }
+
+ private Configuration createScheduledJobsConfiguration() {
+ Configuration config = new Configuration();
+ PropertyMap map = new PropertyMap("jobname");
+ config.put(map);
+ map.put(new PropertySimple("methodName",
"methodNameValue"));
+ return config;
+ }
+
+ private Subject getOverlord() {
+ return LookupUtil.getSubjectManager().getOverlord();
+ }
+}
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
index 2d30403..592a3d9 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
@@ -29,6 +29,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.plugin.PluginDeploymentType;
+import org.rhq.core.domain.plugin.PluginStatusType;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
@@ -195,10 +196,10 @@ public class TestGenericServerPluginService extends
ServerPluginService implemen
File pluginFile = new File(env.getPluginUrl().toURI());
Plugin plugin = new Plugin(0, env.getPluginName(), pluginFile.getName(),
pluginDescriptor
- .getDisplayName(), true, pluginDescriptor.getDescription(),
"", MessageDigestGenerator
- .getDigestString(pluginFile), pluginDescriptor.getVersion(),
pluginDescriptor.getVersion(),
- PluginDeploymentType.SERVER, pluginConfig, scheduledJobsConfig,
System.currentTimeMillis(), System
- .currentTimeMillis());
+ .getDisplayName(), true, PluginStatusType.INSTALLED,
pluginDescriptor.getDescription(), "",
+ MessageDigestGenerator.getDigestString(pluginFile),
pluginDescriptor.getVersion(), pluginDescriptor
+ .getVersion(), PluginDeploymentType.SERVER, pluginConfig,
scheduledJobsConfig, System
+ .currentTimeMillis(), System.currentTimeMillis());
return plugin;
} catch (Exception e) {
throw new RuntimeException(e);
commit d191decc1328210999f7ace3be051dde164b29f9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 20 14:52:19 2009 -0500
out out tabs! fix formatting
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 3e12bad..4cc035a 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -1484,39 +1484,39 @@
</schema-directSQL>
<schema-addColumn table="RHQ_RAW_CONFIG"
column="CONFIG_ID" columnType="INTEGER"/>
- <schema-alterColumn table="RHQ_RAW_CONFIG"
- column="CONFIG_ID"
+ <schema-alterColumn table="RHQ_RAW_CONFIG"
+ column="CONFIG_ID"
columnType="INTEGER"
nullable="false"/>
<schema-addColumn table="RHQ_RAW_CONFIG" column="PATH"
columnType="VARCHAR2"/>
- <schema-alterColumn table="RHQ_RAW_CONFIG"
- column="PATH"
+ <schema-alterColumn table="RHQ_RAW_CONFIG"
+ column="PATH"
columnType="VARCHAR2"
precision="512"/>
<schema-addColumn table="RHQ_RAW_CONFIG" column="CONTENTS"
columnType="BLOB"/>
- <schema-alterColumn table="RHQ_RAW_CONFIG"
- column="CONTENTS"
+ <schema-alterColumn table="RHQ_RAW_CONFIG"
+ column="CONTENTS"
columnType="BLOB"
nullable="false"/>
<schema-addColumn table="RHQ_RAW_CONFIG" column="SHA256"
columnType="VARCHAR2"/>
- <schema-alterColumn table="RHQ_RAW_CONFIG"
- column="SHA256"
+ <schema-alterColumn table="RHQ_RAW_CONFIG"
+ column="SHA256"
columnType="VARCHAR2"
- precision="64"
+ precision="64"
nullable="false"/>
<schema-addColumn table="RHQ_RAW_CONFIG" column="CTIME"
columnType="LONG"/>
- <schema-alterColumn table="RHQ_RAW_CONFIG"
- column="CTIME"
+ <schema-alterColumn table="RHQ_RAW_CONFIG"
+ column="CTIME"
columnType="LONG"
nullable="false"/>
<schema-addColumn table="RHQ_RAW_CONFIG" column="MTIME"
columnType="LONG"/>
- <schema-alterColumn table="RHQ_RAW_CONFIG"
- column="MTIME"
+ <schema-alterColumn table="RHQ_RAW_CONFIG"
+ column="MTIME"
columnType="LONG"
nullable="false"/>
@@ -2024,62 +2024,60 @@
<schema-addColumn table="RHQ_REPO" column="IS_CANDIDATE"
columnType="BOOLEAN"/>
<schema-alterColumn table="RHQ_REPO"
column="IS_CANDIDATE" nullable="false" />
</schemaSpec>
-
- <!-- Generic tagging support -->
+
+ <!-- Generic tagging support -->
<schemaSpec version="2.64">
- <schema-createSequence name="RHQ_TAG_ID_SEQ" initial="10001"
/>
- <schema-directSQL>
- <statement>
- CREATE TABLE RHQ_TAG ( ID INTEGER PRIMARY KEY )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_TAG" column="ID"
nullable="false" />
- <schema-addColumn table="RHQ_TAG" column="NAME"
precision="200" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_TAG" column="NAME"
nullable="false" />
- <schema-addColumn table="RHQ_TAG" column="DESCRIPTION"
precision="500" columnType="VARCHAR2" />
- </schemaSpec>
-
- <!-- Distribution Files -->
- <schemaSpec version="2.65">
- <schema-directSQL>
- <statement>
- CREATE TABLE RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID INTEGER )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="DISTRIBUTION_ID" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION_FILE"
column="RELATIVE_FILENAME" precision="256"
columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="RELATIVE_FILENAME" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION_FILE"
column="MD5SUM" precision="64" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="MD5SUM" nullable="false" />
- <schema-addColumn table="RHQ_DISTRIBUTION_FILE"
column="LAST_MODIFIED" columnType="LONG" />
- <schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="LAST_MODIFIED" nullable="false" />
- <schema-directSQL>
- <statement targetDBVendor="postgresql">
- CREATE UNIQUE INDEX RHQ_DISTRIBUTION_FILE_IDX
- ON RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID, RELATIVE_FILENAME )
- </statement>
- <statement targetDBVendor="oracle">
- CREATE UNIQUE INDEX RHQ_DISTRIBUTION_FILE_IDX
- ON RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID, RELATIVE_FILENAME )
- </statement>
- </schema-directSQL>
- <schema-directSQL>
- <statement targetDBVendor="oracle">
- ALTER TABLE RHQ_DISTRIBUTION_FILE
- ADD CONSTRAINT RHQ_DIST_FILE_FKEY
- FOREIGN KEY ( DISTRIBUTION_ID)
- REFERENCES RHQ_DISTRIBUTION ( ID )
- </statement>
- <statement targetDBVendor="postgresql">
- ALTER TABLE RHQ_DISTRIBUTION_FILE
- ADD CONSTRAINT RHQ_DIST_FILE_FKEY
- FOREIGN KEY ( DISTRIBUTION_ID)
- REFERENCES RHQ_DISTRIBUTION ( ID )
- </statement>
- </schema-directSQL>
-
+ <schema-createSequence name="RHQ_TAG_ID_SEQ" initial="10001"
/>
+ <schema-directSQL>
+ <statement>
+ CREATE TABLE RHQ_TAG ( ID INTEGER PRIMARY KEY )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_TAG" column="ID"
nullable="false" />
+ <schema-addColumn table="RHQ_TAG" column="NAME"
precision="200" columnType="VARCHAR2" />
+ <schema-alterColumn table="RHQ_TAG" column="NAME"
nullable="false" />
+ <schema-addColumn table="RHQ_TAG" column="DESCRIPTION"
precision="500" columnType="VARCHAR2" />
</schemaSpec>
+ <!-- Distribution Files -->
+ <schemaSpec version="2.65">
+ <schema-directSQL>
+ <statement>
+ CREATE TABLE RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="DISTRIBUTION_ID" nullable="false" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_FILE"
column="RELATIVE_FILENAME" precision="256"
columnType="VARCHAR2" />
+ <schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="RELATIVE_FILENAME" nullable="false" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_FILE"
column="MD5SUM" precision="64" columnType="VARCHAR2" />
+ <schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="MD5SUM" nullable="false" />
+ <schema-addColumn table="RHQ_DISTRIBUTION_FILE"
column="LAST_MODIFIED" columnType="LONG" />
+ <schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="LAST_MODIFIED" nullable="false" />
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql">
+ CREATE UNIQUE INDEX RHQ_DISTRIBUTION_FILE_IDX
+ ON RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID, RELATIVE_FILENAME )
+ </statement>
+ <statement targetDBVendor="oracle">
+ CREATE UNIQUE INDEX RHQ_DISTRIBUTION_FILE_IDX
+ ON RHQ_DISTRIBUTION_FILE ( DISTRIBUTION_ID, RELATIVE_FILENAME )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement targetDBVendor="oracle">
+ ALTER TABLE RHQ_DISTRIBUTION_FILE
+ ADD CONSTRAINT RHQ_DIST_FILE_FKEY
+ FOREIGN KEY ( DISTRIBUTION_ID)
+ REFERENCES RHQ_DISTRIBUTION ( ID )
+ </statement>
+ <statement targetDBVendor="postgresql">
+ ALTER TABLE RHQ_DISTRIBUTION_FILE
+ ADD CONSTRAINT RHQ_DIST_FILE_FKEY
+ FOREIGN KEY ( DISTRIBUTION_ID)
+ REFERENCES RHQ_DISTRIBUTION ( ID )
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
<!-- RHQ_REPO_TAG_MAP -->
<schemaSpec version="2.66">
@@ -2123,23 +2121,23 @@
</schemaSpec>
<schemaSpec version="2.68">
- <schema-createSequence name="RHQ_DISTRIBUTION_FILE_SEQ"
initial="10001" />
+ <schema-createSequence name="RHQ_DISTRIBUTION_FILE_SEQ"
initial="10001" />
<schema-directSQL>
- <statement>
- ALTER TABLE RHQ_DISTRIBUTION_FILE DROP CONSTRAINT
RHQ_DISTRIBUTION_FILE_PKEY
- </statement>
+ <statement>
+ ALTER TABLE RHQ_DISTRIBUTION_FILE DROP CONSTRAINT RHQ_DISTRIBUTION_FILE_PKEY
+ </statement>
</schema-directSQL>
-
+
<schema-addColumn table="RHQ_DISTRIBUTION_FILE"
column="ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_DISTRIBUTION_FILE"
column="ID" nullable="false" />
-
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_DISTRIBUTION_FILE ALTER COLUMN ID SET DEFAULT
NEXTVAL('RHQ_DISTRIBUTION_FILE_ID_SEQ')
- </statement>
+
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_DISTRIBUTION_FILE ALTER COLUMN ID SET DEFAULT
NEXTVAL('RHQ_DISTRIBUTION_FILE_ID_SEQ')
+ </statement>
</schema-directSQL>
- </schemaSpec>
-
+ </schemaSpec>
+
<!-- Add support for server-side plugins -->
<schemaSpec version="2.69">
<!-- add the new column that indicates if this is deployed on the SERVER or
AGENT -->
commit ccefb1d4df35a99cc4b241781668662380f65625
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 20 13:58:48 2009 -0500
update schema catalog for eclipse usrs
diff --git a/etc/eclipse-tools/templates/schema.xmlcatalog
b/etc/eclipse-tools/templates/schema.xmlcatalog
index 3107878..d4054bb 100644
--- a/etc/eclipse-tools/templates/schema.xmlcatalog
+++ b/etc/eclipse-tools/templates/schema.xmlcatalog
@@ -2,6 +2,10 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uri name="urn:xmlns:rhq-configuration"
uri="platform:/resource/rhq/modules/core/client-api/src/main/resources/rhq-configuration.xsd"/>
<uri name="urn:xmlns:rhq-plugin"
uri="platform:/resource/rhq/modules/core/client-api/src/main/resources/rhq-plugin.xsd"/>
-<uri name="urn:xmlns:rhq-serverplugin.content"
uri="platform:/resource/rhq/modules/core/client-api/src/main/resources/rhq-serverplugin-content.xsd"/>
-<uri name="urn:xmlns:rhq-perspective"
uri="platform:/resource/rhq/modules/core/client-api/src/main/resources/rhq-perspective.xsd"/>
+<uri name="urn:xmlns:rhq-contentsource-packagedetails"
uri="platform:/resource/rhq/modules/enterprise/server/xml-schemas/src/main/resources/rhq-contentsource-packagedetails.xsd"/>
+<uri name="urn:xmlns:rhq-serverplugin"
uri="platform:/resource/rhq/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin.xsd"/>
+<uri name="urn:xmlns:rhq-serverplugin.generic"
uri="platform:/resource/rhq/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-generic.xsd"/>
+<uri name="urn:xmlns:rhq-serverplugin.alert"
uri="platform:/resource/rhq/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-alert.xsd"/>
+<uri name="urn:xmlns:rhq-serverplugin.content"
uri="platform:/resource/rhq/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-content.xsd"/>
+<uri name="urn:xmlns:rhq-serverplugin.perspective"
uri="platform:/resource/rhq/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd"/>
</catalog>