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
| 20
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
| 52
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/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/plugin/ServerPluginsBean.java
| 154 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/ServerPluginsLocal.java
| 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java
| 77
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
| 59
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
| 74
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
| 16
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
| 9
modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
| 5
36 files changed, 1228 insertions(+), 708 deletions(-)
New commits:
commit 1bc8c0ef34db2b4584914fea447befe023a62efb
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Thu Nov 26 20:19:20 2009 +0100
Squashed commit of the following:
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
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
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
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.
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()
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()
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
commit 37bb080675c956c976ffc3110361c11e19ae87a0
Author: Galder Zamarreno <rnd(a)zamarreno.com>
Date: Wed Nov 25 15:20:34 2009 +0100
Operation returns only one result now.
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.
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
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
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
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.
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)
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
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
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.
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.
commit e144f9a55590182e130ae768b9b494b13f03c2a6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Nov 22 22:42:30 2009 -0500
convert CRLF to LF
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
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/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..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;
@@ -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..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.
@@ -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/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/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.");
}
+
}
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/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;
}
}
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 f6eee0d..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,23 +73,39 @@ public class InstalledPluginUIBean {
return this.scheduledJobsDefinition;
}
- private void lookupPlugin() {
+ 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.");
+
+ 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);
+
+ return null;
+ }
+ }
+
+ @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);
@@ -97,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/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);
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/admin/test/control.jsp
b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/control.jsp
index f3f0a35..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,378 +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.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;
-
- 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();
-
- 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 ("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>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>
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 3921b8e..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,25 +73,29 @@
</rich:panel>
- <rich:panel>
+ <ui:insert name="pre-config" />
+
+ <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" />
+ readOnly="#{not editMode}" />
</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" />
+ readOnly="#{not editMode}" />
</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 9f7f6b7..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}"/>
@@ -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}"/>
@@ -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}"/>
@@ -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}"/>
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 3697caa..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
@@ -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;
@@ -27,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;
@@ -55,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;
@@ -67,14 +69,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
@@ -94,11 +94,19 @@ 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
+
+ Configuration config = plugin.getPluginConfiguration();
+ if (config != null) {
+ config = entityManager.find(Configuration.class, config.getId());
+ plugin.setPluginConfiguration(config.deepCopy());
+ }
- // force eager load
- plugin.getPluginConfiguration().getProperties().size();
- plugin.getScheduledJobsConfiguration().getProperties().size();
+ config = plugin.getScheduledJobsConfiguration();
+ if (config != null) {
+ config = entityManager.find(Configuration.class, config.getId());
+ plugin.setScheduledJobsConfiguration(config.deepCopy());
+ }
return plugin;
}
@@ -146,9 +154,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 +164,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.getPluginContainerByPlugin(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 +197,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 +207,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.getPluginContainerByPlugin(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);
}
}
}
@@ -365,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", 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 + "]");
- }
+ 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;
}
@@ -432,6 +433,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 6f3600e..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;
/**
@@ -42,6 +44,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);
@@ -86,20 +89,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.
@@ -172,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/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 + "]");
}
}
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();
+ }
+ }
}
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 {
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..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,6 +527,7 @@ public class Props {
private String displayName;
private String description;
private Set<SimpleProperty> params = new
LinkedHashSet<SimpleProperty>();
+ private SimpleProperty result;
public OperationProps(String name) {
this.name = name;
@@ -555,5 +556,13 @@ public class Props {
public Set<SimpleProperty> getParams() {
return params;
}
+
+ 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 a148a61..0343787 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -60,6 +60,11 @@ name="${props.name}" <#-- TODO separate out plugin name
and service name -->
</#list>
</parameters>
</#if>
+ <#if operation.result??>
+ <results>
+ <c:simple-property name="${operation.result.name}" />
+ </results>
+ </#if>
</operation>
</#list>
<#else>