[rhq] Branch 'raw-config' - etc/m2
by Adam Young
etc/m2/settings-rawconfig.xml | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
New commits:
commit 4ad17fb7a0bbe6d1f48534d824fb1d99289fde69
Author: Adam Young <ayoung(a)redhat.com>
Date: Fri Oct 23 13:22:34 2009 -0400
added config file for hudson
diff --git a/etc/m2/settings-rawconfig.xml b/etc/m2/settings-rawconfig.xml
new file mode 100644
index 0000000..4014541
--- /dev/null
+++ b/etc/m2/settings-rawconfig.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--===== a sample Maven 2 user settings file for the RHQ build =====-->
+<!-- See: http://maven.apache.org/settings.html -->
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+
+ <!--
+ The below line can be uncommented if you want your local repo to be
+ in a more convenient location under Windows.
+ -->
+ <!--<localRepository>C:\.m2-repo</localRepository>-->
+
+ <!--
+ **************************** PROFILES ****************************
+ -->
+
+ <!--
+ See:
+ http://maven.apache.org/guides/introduction/introduction-to-profiles.html
+ and: http://docs.codehaus.org/display/MAVENUSER/Profiles
+ -->
+
+ <activeProfiles>
+ <activeProfile>test.rawconfig</activeProfile>
+ </activeProfiles>
+
+ <profiles>
+ <profile>
+ <!-- Profile to use to point test runs at a different db -->
+ <id>test.rawconfig</id>
+ <properties>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.test.ds.connection-url>
+ <DatabaseTest.nofail>true</DatabaseTest.nofail>
+ </properties>
+ </profile>
+ </profiles>
+ <pluginGroups>
+ <!--
+ This will allow you to invoke "org.rhq" Maven goals using the
+ "rhq" prefix
+ -->
+ <pluginGroup>org.rhq</pluginGroup>
+ </pluginGroups>
+</settings>
14 years, 7 months
[rhq] Branch 'content' - 8 commits - modules/enterprise modules/helpers modules/plugins
by Mike McCune
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 22
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java | 39
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java | 39
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java | 38
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java | 43
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java | 38
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java | 41
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqMetric.java | 35
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqOperation.java | 34
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java | 38
modules/helpers/pluginGen/pom.xml | 5
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java | 786 ++++++----
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java | 11
modules/helpers/pluginGen/src/main/resources/component.ftl | 16
modules/helpers/pluginGen/src/main/resources/descriptor.ftl | 27
modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl | 78
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 69
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java | 3
modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml | 4
19 files changed, 947 insertions(+), 419 deletions(-)
New commits:
commit d43138d14b50869756be019daf82eb6c32142f4b
Merge: 9ec84ca... fdd23ec...
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Oct 23 10:08:25 2009 -0700
Merge branch 'master' into content2
Conflicts:
.classpath
commit fdd23ec2bb428e6bde53e70d9b31c6ae22465da0
Author: Ian P. Springer <ips(a)jetengine.springer.net>
Date: Wed Oct 21 12:37:01 2009 -0400
mtime also needs to be set on Resources when inventoryStatus is updated (this is the rest of the fix for http://jira.rhq-project.org/browse/RHQ-1996)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 2b1b330..55c0693 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -479,26 +479,20 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
long now = System.currentTimeMillis();
-
- resource.setInventoryStatus(newStatus);
- resource.setItime(now);
-
+ updateInventoryStatus(resource, newStatus, now);
resource = entityManager.merge(resource);
+
if (setDescendents) {
for (Resource childResource : resource.getChildResources()) {
- childResource.setInventoryStatus(newStatus);
- childResource.setItime(now);
-
+ updateInventoryStatus(childResource, newStatus, now);
childResource = entityManager.merge(childResource);
setResourceStatus(user, childResource, newStatus, setDescendents);
}
} else if (resource.getResourceType().getCategory() == ResourceCategory.PLATFORM) {
- // Commit platform services when the platform is committed
+ // Commit platform services when the platform is committed.
for (Resource childResource : resource.getChildResources()) {
if (childResource.getResourceType().getCategory() == ResourceCategory.SERVICE) {
- childResource.setInventoryStatus(newStatus);
- childResource.setItime(now);
-
+ updateInventoryStatus(childResource, newStatus, now);
childResource = entityManager.merge(childResource);
setResourceStatus(user, childResource, newStatus, setDescendents);
}
@@ -508,6 +502,12 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return resource;
}
+ private void updateInventoryStatus(Resource resource, InventoryStatus newStatus, long now) {
+ resource.setInventoryStatus(newStatus);
+ resource.setItime(now);
+ resource.setMtime(now);
+ }
+
@SuppressWarnings("unchecked")
public Resource getResourceById(Subject user, int resourceId) {
Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_BY_ID);
commit a2d134f41f2fa7e3d25d8e317ae19cef790c9e7a
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Wed Oct 21 17:38:39 2009 +0200
More changes to the plugin generator to allow for annotation processing and thus automatic descriptor creation.
Thanks to Galder Zamarreño
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
index 770278d..a416079 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
@@ -23,14 +23,14 @@
package org.rhq.helpers.pluginAnnotations.agent;
/**
- * RhqDataType.
- *
+ * DataType.
+ *
* @author Galder Zamarreño
* @since 4.0
*/
public enum DataType {
MEASUREMENT, TRAIT, CALLTIME;
-
+
@Override
public String toString() {
return super.toString().toLowerCase();
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
index 7d4c1cb..49551ef 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
@@ -23,8 +23,8 @@
package org.rhq.helpers.pluginAnnotations.agent;
/**
- * RhqDisplayType.
- *
+ * DisplayType.
+ *
* @author Galder Zamarreño
* @since 4.0
*/
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
index b63d957..0ae4011 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
@@ -23,14 +23,14 @@
package org.rhq.helpers.pluginAnnotations.agent;
/**
- * RhqUnits.
- *
+ * Metric Units.
+ *
* @author Galder Zamarreño
* @since 4.0
*/
public enum Units {
NONE, MILLISECONDS, SECONDS, PERCENTAGE;
-
+
@Override
public String toString() {
return super.toString().toLowerCase();
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index a38edcc..e58e36d 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -85,5 +85,10 @@
<artifactId>freemarker</artifactId>
<version>2.3.11</version>
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-pluginAnnotations</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
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 c39f3a1..76b374b 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
@@ -19,8 +19,15 @@
package org.rhq.helpers.pluginGen;
import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
+import org.rhq.helpers.pluginAnnotations.agent.DataType;
+import org.rhq.helpers.pluginAnnotations.agent.DisplayType;
+import org.rhq.helpers.pluginAnnotations.agent.Metric;
+import org.rhq.helpers.pluginAnnotations.agent.Units;
+
/**
* The properties needed to generate a new plugin skeleton
*
@@ -28,266 +35,525 @@ import java.util.Set;
*/
public class Props {
- /** What category is this ? */
- private ResourceCategory category;
- /** The name of this item */
- private String name;
- /** A description of the plugin */
- private String description;
- /** Package name prefix */
- private String packagePrefix;
- /** String package */
- private String pkg;
- /** The name of the DiscoveryClass */
- private String discoveryClass;
- /** The name of the Component class */
- private String componentClass;
- /** The type of the parent we run in */
- private String parentType;
- /** Filesytem root */
- private String fileSystemRoot;
- /** Should this service do monitoring ? */
- private boolean monitoring;
- /** Should this service do operations ? */
- private boolean operations;
- /** Is this service a singleton (e.g. a XYZ subsystem) */
- private boolean singleton;
- /** Does the service support configuration ? */
- private boolean resourceConfiguration;
- /** Does the service support events */
- private boolean events;
- /** Does the service support the support facet? */
- private boolean supportFacet;
- /** Can the service create children ? */
- private boolean createChildren;
- /** Can the service delete children ? */
- private boolean deleteChildren;
- /** Use externals chars in the plugin jar ? */
- private boolean usesExternalJarsInPlugin;
- /** Does it support manuall add of children ? */
- private boolean manualAddOfResourceType;
- /** Does it use the PluginLifecycleListener api ? */
- private boolean usePluginLifecycleListenerApi;
- /** Depends on JMX plugin ? */
- private boolean dependsOnJmxPlugin;
- /** What version of RHQ should this plugin's pom use ? */
- private String rhqVersion = "1.4.0-SNAPSHOT";
-
- /** Embedded children */
- private Set<Props> children = new HashSet<Props>();
+ /** What category is this ? */
+ private ResourceCategory category;
+ /** The name of this item */
+ private String name;
+ /** A description of the plugin */
+ private String description;
+ /** Package name prefix */
+ private String packagePrefix;
+ /** String package */
+ private String pkg;
+ /** The name of the DiscoveryClass */
+ private String discoveryClass;
+ /** The name of the Component class */
+ private String componentClass;
+ /** The type of the parent we run in */
+ private String parentType;
+ /** Filesytem root */
+ private String fileSystemRoot;
+ /** Should this service do monitoring ? */
+ private boolean hasMetrics;
+ /** Should this service do operations ? */
+ private boolean hasOperations;
+ /** Is this service a singleton (e.g. a XYZ subsystem) */
+ private boolean singleton;
+ /** Does the service support configuration ? */
+ private boolean resourceConfiguration;
+ /** Does the service support events */
+ private boolean events;
+ /** Does the service support the support facet? */
+ private boolean supportFacet;
+ /** Can the service create children ? */
+ private boolean createChildren;
+ /** Can the service delete children ? */
+ private boolean deleteChildren;
+ /** Use externals chars in the plugin jar ? */
+ private boolean usesExternalJarsInPlugin;
+ /** Does it support manuall add of children ? */
+ private boolean manualAddOfResourceType;
+ /** Does it use the PluginLifecycleListener api ? */
+ private boolean usePluginLifecycleListenerApi;
+ /** Depends on JMX plugin ? */
+ private boolean dependsOnJmxPlugin;
+ /** What version of RHQ should this plugin's pom use ? */
+ private String rhqVersion = "1.4.0-SNAPSHOT";
+
+ /** Embedded children */
+ private Set<Props> children = new HashSet<Props>();
+
+ private Set<SimpleProperty> simpleProps = new LinkedHashSet<SimpleProperty>();
+
+ private Set<Template> templates = new HashSet<Template>();
+
+ private Set<MetricProps> metrics = new LinkedHashSet<MetricProps>();;
+
+ private Set<OperationProps> operations = new LinkedHashSet<OperationProps>();;
+
+ private String pluginName;
+ private String pluginDescription;
public ResourceCategory getCategory() {
- return category;
- }
-
- public void setCategory(ResourceCategory category) {
- this.category = category;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDiscoveryClass() {
- return discoveryClass;
- }
-
- public void setDiscoveryClass(String discoveryClass) {
- this.discoveryClass = discoveryClass;
- }
-
- public String getComponentClass() {
- return componentClass;
- }
-
- public void setComponentClass(String componentClass) {
- this.componentClass = componentClass;
- }
-
- public String getParentType() {
- return parentType;
- }
-
- public void setParentType(String parentType) {
- this.parentType = parentType;
- }
-
- public boolean isMonitoring() {
- return monitoring;
- }
-
- public void setMonitoring(boolean monitoring) {
- this.monitoring = monitoring;
- }
-
- public boolean isOperations() {
- return operations;
- }
-
- public void setOperations(boolean operations) {
- this.operations = operations;
- }
-
- public boolean isSingleton() {
- return singleton;
- }
-
- public void setSingleton(boolean singleton) {
- this.singleton = singleton;
- }
-
- public boolean isResourceConfiguration() {
- return resourceConfiguration;
- }
-
- public void setResourceConfiguration(boolean resourceConfiguration) {
- this.resourceConfiguration = resourceConfiguration;
- }
-
- public boolean isEvents() {
- return events;
- }
-
- public void setEvents(boolean events) {
- this.events = events;
- }
-
- public boolean isSupportFacet() {
- return supportFacet;
- }
-
- public void setSupportFacet(boolean supportFacet) {
- this.supportFacet = supportFacet;
- }
-
- public boolean isCreateChildren() {
- return createChildren;
- }
-
- public void setCreateChildren(boolean createChildren) {
- this.createChildren = createChildren;
- }
-
- public Set<Props> getChildren() {
- return children;
- }
-
- public void setChildren(Set<Props> children) {
- this.children = children;
- }
-
- public String getPackagePrefix() {
- return packagePrefix;
- }
-
- public void setPackagePrefix(String packagePrefix) {
- this.packagePrefix = packagePrefix;
- }
-
- public String getFileSystemRoot() {
- return fileSystemRoot;
- }
-
- public void setFileSystemRoot(String fileSystemRoot) {
- this.fileSystemRoot = fileSystemRoot;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public boolean isUsesExternalJarsInPlugin() {
- return usesExternalJarsInPlugin;
- }
-
- public void setUsesExternalJarsInPlugin(boolean usesExternalJarsInPlugin) {
- this.usesExternalJarsInPlugin = usesExternalJarsInPlugin;
- }
-
- public boolean isDeleteChildren() {
- return deleteChildren;
- }
-
- public void setDeleteChildren(boolean deleteChildren) {
- this.deleteChildren = deleteChildren;
- }
-
- public boolean isManualAddOfResourceType() {
- return manualAddOfResourceType;
- }
-
- public void setManualAddOfResourceType(boolean manualAddOfResourceType) {
- this.manualAddOfResourceType = manualAddOfResourceType;
- }
-
- public void setPkg(String pkg) {
- this.pkg = pkg;
- }
-
- public String getPkg() {
- return this.pkg;
- }
-
- public boolean isUsePluginLifecycleListenerApi() {
- return usePluginLifecycleListenerApi;
- }
-
- public void setUsePluginLifecycleListenerApi(boolean usePluginLifecycleListenerApi) {
- this.usePluginLifecycleListenerApi = usePluginLifecycleListenerApi;
- }
-
- public boolean isDependsOnJmxPlugin() {
- return dependsOnJmxPlugin;
- }
-
- public void setDependsOnJmxPlugin(boolean dependsOnJmxPlugin) {
- this.dependsOnJmxPlugin = dependsOnJmxPlugin;
- }
-
- public String getRhqVersion() {
- return rhqVersion;
- }
-
- public void setRhqVersion(String rhqVersion) {
- this.rhqVersion = rhqVersion;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("Props");
- sb.append("{category=").append(category);
- sb.append(", name='").append(name).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append(", packagePrefix='").append(packagePrefix).append('\'');
- sb.append(", pkg='").append(pkg).append('\'');
- sb.append(", discoveryClass='").append(discoveryClass).append('\'');
- sb.append(", componentClass='").append(componentClass).append('\'');
- sb.append(", parentType='").append(parentType).append('\'');
- sb.append(", fileSystemRoot='").append(fileSystemRoot).append('\'');
- sb.append(", monitoring=").append(monitoring);
- sb.append(", operations=").append(operations);
- sb.append(", singleton=").append(singleton);
- sb.append(", resourceConfiguration=").append(resourceConfiguration);
- sb.append(", events=").append(events);
- sb.append(", supportFacet=").append(supportFacet);
- sb.append(", createChildren=").append(createChildren);
- sb.append(", deleteChildren=").append(deleteChildren);
- sb.append(", usesExternalJarsInPlugin=").append(usesExternalJarsInPlugin);
- sb.append(", manualAddOfResourceType=").append(manualAddOfResourceType);
- sb.append(", usePluginLifecycleListenerApi=").append(usePluginLifecycleListenerApi);
- sb.append(", dependsOnJmxPlugin=").append(dependsOnJmxPlugin);
- sb.append(", rhqVersion='").append(rhqVersion).append('\'');
- sb.append(", children=").append(children);
- sb.append('}');
- return sb.toString();
- }
+ return category;
+ }
+
+ public void setCategory(ResourceCategory category) {
+ this.category = category;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDiscoveryClass() {
+ return discoveryClass;
+ }
+
+ public void setDiscoveryClass(String discoveryClass) {
+ this.discoveryClass = discoveryClass;
+ }
+
+ public String getComponentClass() {
+ return componentClass;
+ }
+
+ public void setComponentClass(String componentClass) {
+ this.componentClass = componentClass;
+ }
+
+ public String getParentType() {
+ return parentType;
+ }
+
+ public void setParentType(String parentType) {
+ this.parentType = parentType;
+ }
+
+ public boolean isHasMetrics() {
+ return hasMetrics;
+ }
+
+ public void setHasMetrics(boolean hasMetrics) {
+ this.hasMetrics = hasMetrics;
+ }
+
+ public boolean isHasOperations() {
+ return hasOperations;
+ }
+
+ public void setHasOperations(boolean hasOperations) {
+ this.hasOperations = hasOperations;
+ }
+
+ public boolean isSingleton() {
+ return singleton;
+ }
+
+ public void setSingleton(boolean singleton) {
+ this.singleton = singleton;
+ }
+
+ public boolean isResourceConfiguration() {
+ return resourceConfiguration;
+ }
+
+ public void setResourceConfiguration(boolean resourceConfiguration) {
+ this.resourceConfiguration = resourceConfiguration;
+ }
+
+ public boolean isEvents() {
+ return events;
+ }
+
+ public void setEvents(boolean events) {
+ this.events = events;
+ }
+
+ public boolean isSupportFacet() {
+ return supportFacet;
+ }
+
+ public void setSupportFacet(boolean supportFacet) {
+ this.supportFacet = supportFacet;
+ }
+
+ public boolean isCreateChildren() {
+ return createChildren;
+ }
+
+ public void setCreateChildren(boolean createChildren) {
+ this.createChildren = createChildren;
+ }
+
+ public Set<Props> getChildren() {
+ return children;
+ }
+
+ public void setChildren(Set<Props> children) {
+ this.children = children;
+ }
+
+ public String getPackagePrefix() {
+ return packagePrefix;
+ }
+
+ public void setPackagePrefix(String packagePrefix) {
+ this.packagePrefix = packagePrefix;
+ }
+
+ public String getFileSystemRoot() {
+ return fileSystemRoot;
+ }
+
+ public void setFileSystemRoot(String fileSystemRoot) {
+ this.fileSystemRoot = fileSystemRoot;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isUsesExternalJarsInPlugin() {
+ return usesExternalJarsInPlugin;
+ }
+
+ public void setUsesExternalJarsInPlugin(boolean usesExternalJarsInPlugin) {
+ this.usesExternalJarsInPlugin = usesExternalJarsInPlugin;
+ }
+
+ public boolean isDeleteChildren() {
+ return deleteChildren;
+ }
+
+ public void setDeleteChildren(boolean deleteChildren) {
+ this.deleteChildren = deleteChildren;
+ }
+
+ public boolean isManualAddOfResourceType() {
+ return manualAddOfResourceType;
+ }
+
+ public void setManualAddOfResourceType(boolean manualAddOfResourceType) {
+ this.manualAddOfResourceType = manualAddOfResourceType;
+ }
+
+ public void setPkg(String pkg) {
+ this.pkg = pkg;
+ }
+
+ public String getPkg() {
+ return this.pkg;
+ }
+
+ public boolean isUsePluginLifecycleListenerApi() {
+ return usePluginLifecycleListenerApi;
+ }
+
+ public void setUsePluginLifecycleListenerApi(boolean usePluginLifecycleListenerApi) {
+ this.usePluginLifecycleListenerApi = usePluginLifecycleListenerApi;
+ }
+
+ public boolean isDependsOnJmxPlugin() {
+ return dependsOnJmxPlugin;
+ }
+
+ public void setDependsOnJmxPlugin(boolean dependsOnJmxPlugin) {
+ this.dependsOnJmxPlugin = dependsOnJmxPlugin;
+ }
+
+ public String getRhqVersion() {
+ return rhqVersion;
+ }
+
+ public void setRhqVersion(String rhqVersion) {
+ this.rhqVersion = rhqVersion;
+ }
+
+ public Set<SimpleProperty> getSimpleProps() {
+ return simpleProps;
+ }
+
+ public void setSimpleProps(Set<SimpleProperty> simpleProps) {
+ this.simpleProps = simpleProps;
+ }
+
+ public Set<Template> getTemplates() {
+ return templates;
+ }
+
+ public void setTemplates(Set<Template> templates) {
+ this.templates = templates;
+ }
+
+ public Set<MetricProps> getMetrics() {
+ return metrics;
+ }
+
+ public void setMetrics(Set<MetricProps> metricProps) {
+ this.metrics = metricProps;
+ }
+
+ public Set<OperationProps> getOperations() {
+ return operations;
+ }
+
+ public void setOperations(Set<OperationProps> opProps) {
+ this.operations = opProps;
+ }
+
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ public void setPluginName(String pluginName) {
+ this.pluginName = pluginName;
+ }
+
+ public String getPluginDescription() {
+ return pluginDescription;
+ }
+
+ public void setPluginDescription(String pluginDescription) {
+ this.pluginDescription = pluginDescription;
+ }
+
+ public void populateMetrics(List<Class> classes) {
+ for (Class<?> clazz : classes) {
+ Metric metricAnnot = clazz.getAnnotation(Metric.class);
+ if (metricAnnot != null) {
+ MetricProps metric = new MetricProps(metricAnnot.property());
+ metric.setDisplayName(metricAnnot.displayName());
+ metric.setDisplayType(metricAnnot.displayType());
+ metric.setDataType(metricAnnot.dataType());
+ metric.setDescription(metricAnnot.description());
+ metrics.add(metric);
+ }
+
+ }
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Props");
+ sb.append("{category=").append(category);
+ sb.append(", name='").append(name).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append(", packagePrefix='").append(packagePrefix).append('\'');
+ sb.append(", pkg='").append(pkg).append('\'');
+ sb.append(", discoveryClass='").append(discoveryClass).append('\'');
+ sb.append(", componentClass='").append(componentClass).append('\'');
+ sb.append(", parentType='").append(parentType).append('\'');
+ sb.append(", fileSystemRoot='").append(fileSystemRoot).append('\'');
+ sb.append(", monitoring=").append(hasMetrics);
+ sb.append(", operations=").append(hasOperations);
+ sb.append(", metricProps=").append(metrics);
+ sb.append(", operationProps=").append(operations);
+ sb.append(", singleton=").append(singleton);
+ sb.append(", resourceConfiguration=").append(resourceConfiguration);
+ sb.append(", events=").append(events);
+ sb.append(", supportFacet=").append(supportFacet);
+ sb.append(", createChildren=").append(createChildren);
+ sb.append(", deleteChildren=").append(deleteChildren);
+ sb.append(", usesExternalJarsInPlugin=").append(usesExternalJarsInPlugin);
+ sb.append(", manualAddOfResourceType=").append(manualAddOfResourceType);
+ sb.append(", usePluginLifecycleListenerApi=").append(usePluginLifecycleListenerApi);
+ sb.append(", dependsOnJmxPlugin=").append(dependsOnJmxPlugin);
+ sb.append(", rhqVersion='").append(rhqVersion).append('\'');
+ sb.append(", children=").append(children);
+ sb.append(", simpleProps=").append(simpleProps);
+ sb.append(", templates=").append(templates);
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public static class SimpleProperty {
+ private final String name;
+ private String description;
+ private String type;
+ private boolean readOnly;
+ private String displayName;
+ private String defaultValue;
+
+ public SimpleProperty(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ }
+
+ public static class Template {
+ private final String name;
+ private String description;
+ private Set<SimpleProperty> simpleProps = new HashSet<SimpleProperty>();
+
+ public Template(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Set<SimpleProperty> getSimpleProps() {
+ return simpleProps;
+ }
+
+ public void setSimpleProps(Set<SimpleProperty> simpleProps) {
+ this.simpleProps = simpleProps;
+ }
+
+ public String getName() {
+ return name;
+ }
+ }
+
+ public static class MetricProps {
+ private final String property;
+ private String displayName;
+ private String description;
+ private DisplayType displayType;
+ private DataType dataType;
+ private Units units;
+
+ public MetricProps(String property) {
+ this.property = property;
+ }
+
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(DataType dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public DisplayType getDisplayType() {
+ return displayType;
+ }
+
+ public void setDisplayType(DisplayType displayType) {
+ this.displayType = displayType;
+ }
+
+ public Units getUnits() {
+ return units;
+ }
+
+ public void setUnits(Units units) {
+ this.units = units;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ }
+
+ public static class OperationProps {
+ private final String name;
+ private String displayName;
+ private String description;
+ private Set<SimpleProperty> params = new LinkedHashSet<SimpleProperty>();
+
+ public OperationProps(String name) {
+ this.name = name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Set<SimpleProperty> getParams() {
+ return params;
+ }
+ }
}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java
index 46362af..3c4c48e 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java
@@ -34,19 +34,23 @@ public class Test {
Props p = new Props();
p.setName("foo");
+ p.setPluginName("fooPlugin");
+ p.setPluginDescription("fooDescription");
+ p.setPkg("a.package");
p.setCategory(ResourceCategory.SERVER);
p.setPackagePrefix("com.acme.plugin");
p.setDiscoveryClass("FooDiscovery");
p.setComponentClass("FooComponent");
p.setResourceConfiguration(true);
- p.setMonitoring(true);
- p.setOperations(true);
+ p.setHasMetrics(true);
+ p.setHasOperations(true);
p.setEvents(true);
p.setCreateChildren(true);
p.setSingleton(true);
Props child = new Props();
child.setName("FooChild1");
+ child.setPkg("child.package1");
child.setCategory(ResourceCategory.SERVICE);
child.setPackagePrefix(p.getPackagePrefix());
child.setDiscoveryClass("ChildDiscovery1");
@@ -58,12 +62,15 @@ public class Test {
child = new Props();
child.setName("FooChild2");
+ child.setPkg("child.package2");
child.setCategory(ResourceCategory.SERVICE);
child.setParentType("FooComponent");
child.setPackagePrefix(p.getPackagePrefix());
child.setDiscoveryClass("ChildDiscovery2");
child.setComponentClass("ChildComponent2");
child.setEvents(true);
+ child.setHasMetrics(true);
+ child.setHasOperations(true);
p.getChildren().add(child);
diff --git a/modules/helpers/pluginGen/src/main/resources/component.ftl b/modules/helpers/pluginGen/src/main/resources/component.ftl
index 54776e8..e9961fc 100644
--- a/modules/helpers/pluginGen/src/main/resources/component.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/component.ftl
@@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.domain.measurement.AvailabilityType;
-<#if props.monitoring>
+<#if props.metrics??>
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
@@ -49,13 +49,13 @@ import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
</#if>
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-<#if props.monitoring>
+<#if props.metrics??>
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
</#if>
<#if props.events>
import org.rhq.core.pluginapi.event.EventContext;
</#if>
-<#if props.operations>
+<#if props.operations??>
import org.rhq.core.pluginapi.operation.OperationContext;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
@@ -72,10 +72,10 @@ import org.rhq.core.pluginapi.support.SupportFacet;
public class ${props.componentClass} implements ResourceComponent<#if props.parentType??><${props.parentType}></#if>
-<#if props.monitoring>
+<#if props.metrics??>
, MeasurementFacet
</#if>
-<#if props.operations>
+<#if props.operations??>
, OperationFacet
</#if>
<#if props.resourceConfiguration>
@@ -164,7 +164,7 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
}
-<#if props.monitoring>
+<#if props.metrics??>
/**
* Gather measurement data
@@ -182,7 +182,7 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
}
</#if>
-<#if props.operations>
+<#if props.operations??>
public void startOperationFacet(OperationContext context) {
@@ -271,4 +271,4 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
return null;
}
</#if>
-}
\ No newline at end of file
+}
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptor.ftl b/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
index b05e25c..a62af11 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
@@ -20,8 +20,9 @@
-->
<#-- @ftlvariable name="props" type="org.rhq.helpers.pluginGen.Props" -->
<?xml version="1.0"?>
-<plugin name="${props.name}"
- displayName="${props.name}Plugin"
+<plugin name="${props.pluginName}"
+ displayName="${props.pluginName}Plugin"
+ description="${props.pluginDescription}"
<#if props.usePluginLifecycleListenerApi>
pluginLifecycleListener="${props.componentClass}"
</#if>
@@ -31,20 +32,16 @@
xmlns:c="urn:xmlns:rhq-configuration">
<#if props.dependsOnJmxPlugin>
- <depends plugin="JMX" useClasses="true"/>
-</#if>
-
- <${props.category.lowerName}
- <#include "descriptorMain.ftl"/>
-
- <#-- Those are the embedded children -->
- <#list props.children as props>
- <${props.category.lowerName}
- <#include "./descriptorMain.ftl"/>
- </${props.category.lowerName}>
+ <depends plugin="JMX" useClasses="true"/>
+</#if>
- </#list>
- </${props.category.lowerName}>
+ <${props.category.lowerName} <#include "descriptorMain.ftl"/>
+ <#-- Those are the embedded children -->
+ <#list props.children as props>
+ <${props.category.lowerName} <#include "./descriptorMain.ftl"/>
+ </${props.category.lowerName}>
+ </#list>
+ </${props.category.lowerName}>
</plugin>
\ No newline at end of file
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
index 41420ff..a148a61 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -24,50 +24,68 @@
platform/server/service. It is called by descriptor.ftl
-->
- name="${props.name}" <#-- TODO separate out plugin name and service name -->
+name="${props.name}" <#-- TODO separate out plugin name and service name -->
discovery="${props.discoveryClass}"
class="${props.componentClass}"
- <#if props.singleton>
- singleton="true"
- </#if>
- <#if props.manualAddOfResourceType>
- supportsManualAdd="true"
- </#if>
- <#if props.createChildren && props.deleteChildren>
- createDeletePolicy="both"
- <#elseif props.createChildren && !props.deleteChildren>
- createDeletePolicy="create-only"
- <#elseif !props.createChildren && props.deleteChildren>
- createDeletePolicy="delete-only"
- <#else > <#-- Dont mention it, as 'neither' is default -->
- </#if>
- >
+ <#if props.singleton>singleton="true"</#if>
+ <#if props.manualAddOfResourceType>supportsManualAdd="true"</#if>
+ <#if props.createChildren && props.deleteChildren>createDeletePolicy="both"<#elseif props.createChildren && !props.deleteChildren>createDeletePolicy="create-only"<#elseif !props.createChildren && props.deleteChildren>createDeletePolicy="delete-only"<#else > <#-- Dont mention it, as 'neither' is default --></#if>
+ >
+ <#if props.simpleProps?has_content>
<plugin-configuration>
- <!-- TODO add your own here -->
- <c:simple-property name="dummy"/>
+ <#list props.simpleProps as simpleProps>
+ <c:simple-property name="${simpleProps.name}" description="${simpleProps.description}" <#if simpleProps.type??>type="${simpleProps.type}"</#if> <#if simpleProps.readOnly>readOnly="true"</#if>/>
+ </#list>
+ <!-- The template section is only for manual resource additions, and default parameters and the ones presented to the user. -->
+ <#list props.templates as templates>
+ <c:template name="${templates.name}" description="${templates.description}">
+ <#list templates.simpleProps as innerSimpleProps>
+ <c:simple-property name="${innerSimpleProps.name}" displayName="${innerSimpleProps.displayName}"
+ defaultValue="${innerSimpleProps.defaultValue}"/>
+ </#list>
+ </c:template>
+ </#list>
</plugin-configuration>
+ </#if>
- <!-- TODO process scans -->
-
- <#if props.operations>
- <operation name="dummyOperation">
- <!-- TODO supply parameters and return values -->
- </operation>
-
+ <#if props.hasOperations>
+ <#if props.operations?has_content>
+ <#list props.operations as operation>
+ <operation name="${operation.name}" displayName="${operation.displayName}" description="${operation.description}">
+ <#if operation.params?has_content>
+ <parameters>
+ <#list operation.params as param>
+ <c:simple-property name="${param.name}" <#if param.description??>description="${param.description}"</#if>/>
+ </#list>
+ </parameters>
+ </#if>
+ </operation>
+ </#list>
+ <#else>
+ <operation name="dummyOperation">
+ <!-- TODO supply parameters and return values -->
+ </operation>
</#if>
- <#if props.monitoring>
- <metric property="dummyMetric" displayName="Dummy display name"/>
+ </#if>
+ <#if props.hasMetrics>
+ <#if props.metrics?has_content>
+ <#list props.metrics as metric>
+ <metric property="${metric.property}" displayName="${metric.displayName}" displayType="${metric.displayType}" units="${metric.units}" dataType="${metric.dataType}"
+ description="${metric.description}" />
+ </#list>
+ <#else>
+ <metric property="dummyMetric" displayName="Dummy display name"/>
</#if>
+ </#if>
+
<#if props.events>
<event name="${props.name}DummyEvent"/>
-
</#if>
<#if props.resourceConfiguration>
<resource-configuration>
<!-- TODO supply your configuration parameters -->
<c:simple-property name="dummy"/>
</resource-configuration>
-
- </#if>
+ </#if>
\ No newline at end of file
commit 455c073b6bb2745c833db83e1213ef1e9dd36f6d
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Wed Oct 21 09:39:46 2009 +0200
Annotations to allow for (semi-)automatic descriptor generation.
Thanks Galder Zamareño.
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
new file mode 100644
index 0000000..770278d
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+/**
+ * RhqDataType.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public enum DataType {
+ MEASUREMENT, TRAIT, CALLTIME;
+
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+
+}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
new file mode 100644
index 0000000..7d4c1cb
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+/**
+ * RhqDisplayType.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public enum DisplayType {
+ SUMMARY, DETAIL;
+
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+
+}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
new file mode 100644
index 0000000..c797e81
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+/**
+ * MeasurementType.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public enum MeasurementType {
+ DYNAMIC, TRENDSUP, TRENDSDOWN;
+
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
new file mode 100644
index 0000000..c1482f1
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
@@ -0,0 +1,43 @@
+/*
+ * 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.helpers.pluginAnnotations.agent;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to denote a metric that should be measured
+ *
+ * @author Heiko W. Rupp
+ * @author Galder Zamarreo
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD, ElementType.METHOD })
+public @interface Metric {
+ String property() default "";
+ String displayName() default "";
+ String description() default "";
+ long defaultInterval() default 120000000L; // 20 min
+ DisplayType displayType() default DisplayType.DETAIL;
+ DataType dataType() default DataType.MEASUREMENT;
+ Units units() default Units.NONE;
+ MeasurementType measurementType() default MeasurementType.DYNAMIC;
+ }
\ No newline at end of file
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
new file mode 100644
index 0000000..ba60955
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
@@ -0,0 +1,38 @@
+/*
+ * 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.helpers.pluginAnnotations.agent;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that denotes an Operation that can be executed
+ *
+ * @author Heiko W. Rupp
+ * @author Galder Zamarreo
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface Operation {
+ String name() default "";
+ String displayName() default "";
+ String description() default "";
+}
\ No newline at end of file
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
new file mode 100644
index 0000000..4b82a13
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Parameter.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+(a)Target(ElementType.PARAMETER)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Parameter {
+ String name() default "";
+ String description() default "";
+}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
new file mode 100644
index 0000000..b63d957
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+/**
+ * RhqUnits.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public enum Units {
+ NONE, MILLISECONDS, SECONDS, PERCENTAGE;
+
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+}
commit 755916036ba1bf5ce6e715f2a898aa0b94c55528
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Wed Oct 21 09:38:14 2009 +0200
Annotations to allow for (semi-)automatic descriptor generation.
Thanks Galder Zamareño.
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqMetric.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqMetric.java
deleted file mode 100644
index 5397a85..0000000
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqMetric.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.helpers.pluginAnnotations.agent;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to denote a metric that should be measured
- * @author Heiko W. Rupp
- */
-(a)Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.FIELD, ElementType.METHOD})
-public @interface RhqMetric {
- String name();
- long defaultInterval() default 120000000L; // 20 min
-}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqOperation.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqOperation.java
deleted file mode 100644
index bdcda47..0000000
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqOperation.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.helpers.pluginAnnotations.agent;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation that denotes an Operation that can be executed
- * @author Heiko W. Rupp
- */
-(a)Retention(RetentionPolicy.CLASS)
-(a)Target(ElementType.METHOD)
-public @interface RhqOperation {
- String name();
-}
commit d6f2370fd84b6942ee68b22e2621b4c466144bfb
Author: Partha Aji <paji(a)redhat.com>
Date: Tue Oct 20 14:15:17 2009 -0400
Revert "back out my augeas/hosts plugin changes from last Friday (6dc0d3ff445cb0e5fdd4957577327ccf24a15db6)"
This reverts commit 7beb55bb72dcc52bfd7d4ac6915efcb7c10b45af.
The last friday commit actually fixed a lot of issues.
It is essential that this fix be in master. This fix has already been
tested on raw-config branch and has been proved to work.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index d51e43e..3ef73bd 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -19,6 +19,7 @@
package org.rhq.plugins.augeas;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
@@ -60,6 +61,8 @@ import org.rhq.plugins.platform.PlatformComponent;
*/
public class AugeasConfigurationComponent implements ResourceComponent<PlatformComponent>, ConfigurationFacet {
public static final String CONFIGURATION_FILE_PROP = "configurationFile";
+ public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
+ public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
private static final boolean IS_WINDOWS = (File.separatorChar == '\\');
private static final String AUGEAS_LOAD_PATH = "/usr/local/share/augeas/lenses";
@@ -70,8 +73,8 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
private ResourceContext resourceContext;
private File configFile;
private Augeas augeas;
- private AugeasNode augeasConfigFileNode;
private AugeasNode augeasConfigFileMetadataNode;
+ private AugeasNode resourceConfigRootNode;
public void start(ResourceContext<PlatformComponent> resourceContext) throws InvalidPluginConfigurationException,
Exception {
@@ -81,9 +84,21 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
this.configFile = new File(configFilePath);
this.augeas = createAugeas();
if (this.augeas != null) {
- this.augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
+ AugeasNode augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
+ // This is the metadata portion of the tree for this config file (e.g. /augeas/files/etc/hosts, where error
+ // messages are stored as node values.
this.augeasConfigFileMetadataNode = new AugeasNode("/augeas/files" + AugeasNode.SEPARATOR_CHAR
- + this.configFile.getPath());
+ + this.configFile.getPath());
+ String resourceConfigRootNodePath = pluginConfig.getSimpleValue(RESOURCE_CONFIGURATION_ROOT_NODE_PROP, null);
+ if (resourceConfigRootNodePath != null) {
+ if (resourceConfigRootNodePath.indexOf(AugeasNode.SEPARATOR_CHAR) == 0) {
+ this.resourceConfigRootNode = new AugeasNode(resourceConfigRootNodePath);
+ } else {
+ this.resourceConfigRootNode = new AugeasNode(augeasConfigFileNode, resourceConfigRootNodePath);
+ }
+ } else {
+ this.resourceConfigRootNode = augeasConfigFileNode;
+ }
}
}
@@ -119,7 +134,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
for (PropertyDefinition propDef : propDefs) {
- loadProperty(propDef, resourceConfig, this.augeas, this.augeasConfigFileNode);
+ loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
}
return resourceConfig;
@@ -127,16 +142,27 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
if (!validateResourceConfiguration(report)) {
+ log.debug("Validation of updated Resource configuration for "
+ + this.getResourceContext().getResourceType() + " Resource with key '"
+ + this.getResourceContext().getResourceKey() + "' failed with the following errors: "
+ + report.getErrorMessage());
report.setStatus(ConfigurationUpdateStatus.FAILURE);
return;
}
if (!this.configFile.canWrite()) {
- report.setErrorMessage("Configuration file '" + this.configFile + "' is not writeable.");
+ report.setErrorMessage("Configuration file '" + this.configFile + "' is not writable.");
return;
}
- // Load the config file from disk and build a tree representation of it.
+ File configFileParentDir = this.configFile.getParentFile();
+ if (!configFileParentDir.canWrite()) {
+ report.setErrorMessage("Configuration file parent directory '" + configFileParentDir
+ + "' is not writable.");
+ return;
+ }
+
+ // Load the config file from disk and build a tree representation of it in memory.
this.augeas.load();
ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
@@ -145,7 +171,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, this.augeasConfigFileNode);
+ setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
}
// Write the updated tree out to the config file.
@@ -193,7 +219,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
private Augeas createAugeas() {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String augeasModuleName = pluginConfig.getSimpleValue("augeasModuleName", null);
+ String augeasModuleName = pluginConfig.getSimpleValue(AUGEAS_MODULE_NAME_PROP, null);
if (augeasModuleName == null) {
return null;
}
@@ -285,10 +311,10 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
PropertyList propList = new PropertyList(propDefList.getName());
String mapKey = getListMemberMapKey(propDefList);
- List<String> listMemberPaths = augeas.match(node.getPath());
+ String listMemberPathsExpression = node.getPath() + AugeasNode.SEPARATOR_CHAR + listMemberPropDefMap.getName();
+ List<String> listMemberPaths = augeas.match(listMemberPathsExpression);
for (String listMemberPath : listMemberPaths) {
AugeasNode listMemberNode = new AugeasNode(listMemberPath);
-
PropertyMap listMemberPropMap = new PropertyMap(listMemberPropDefMap.getName());
propList.add(listMemberPropMap);
@@ -297,6 +323,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
PropertySimple keyProp = new PropertySimple(mapKey, listMemberNode.getName());
listMemberPropMap.put(keyProp);
}
+
// Populate the rest of the map child properties.
populatePropertyMap(listMemberPropDefMap, listMemberPropMap, augeas, listMemberNode);
}
@@ -379,11 +406,15 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
"Invalid Resource ConfigurationDefinition - only lists of maps are supported.");
}
PropertyDefinitionMap listMemberPropDefMap = (PropertyDefinitionMap) listMemberPropDef;
- String mapKey = getListMemberMapKey(propDefList);
- Set<String> keys = new HashSet<String>();
int listIndex = 0;
- Set<AugeasNode> updatedMemberNodes = new HashSet<AugeasNode>();
+ List<String> existingListMemberPaths = augeas.match(listNode.getPath() + AugeasNode.SEPARATOR_CHAR
+ + listMemberPropDefMap.getName());
+ List<AugeasNode> existingListMemberNodes = new ArrayList<AugeasNode>();
+ for (String existingListMemberPath : existingListMemberPaths) {
+ existingListMemberNodes.add(new AugeasNode(existingListMemberPath));
+ }
+ Set<AugeasNode> updatedListMemberNodes = new HashSet<AugeasNode>();
for (Property listMemberProp : propList.getList()) {
PropertyMap listMemberPropMap = (PropertyMap) listMemberProp;
AugeasNode memberNodeToUpdate = getExistingChildNodeForListMemberPropertyMap(listNode, propDefList,
@@ -391,11 +422,11 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
if (memberNodeToUpdate != null) {
// Keep track of the existing nodes that we'll be updating, so that we can remove all other existing
// nodes.
- updatedMemberNodes.add(memberNodeToUpdate);
+ updatedListMemberNodes.add(memberNodeToUpdate);
} else {
// The maps in the list are non-keyed, or there is no map in the list with the same key as the map
// being added, so create a new node for the map to add to the list.
- memberNodeToUpdate = new AugeasNode(listNode, "0" + listIndex);
+ memberNodeToUpdate = new AugeasNode(listNode, "0" + (listIndex++));
}
// Update the node's children.
@@ -403,11 +434,9 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
}
// Now remove any existing nodes that we did not update in the previous loop.
- List<String> existingListMemberPaths = augeas.match(listNode.getPath() + "/*");
- for (String existingListMemberPath : existingListMemberPaths) {
- AugeasNode existingListMemberNode = new AugeasNode(existingListMemberPath);
- if (!updatedMemberNodes.contains(existingListMemberNode)) {
- augeas.remove(existingListMemberPath);
+ for (AugeasNode existingListMemberNode : existingListMemberNodes) {
+ if (!updatedListMemberNodes.contains(existingListMemberNode)) {
+ augeas.remove(existingListMemberNode.getPath());
}
}
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index 875a4c1..8e944db 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -54,7 +54,6 @@ public class HostsComponent extends AugeasConfigurationComponent {
"(([a-zA-Z\\d]|[a-zA-Z\\d][a-zA-Z\\d\\-]*[a-zA-Z\\d])\\.)*([A-Za-z]|[A-Za-z][A-Za-z\\d\\-]*[A-Za-z\\d])";
private static final Pattern DOMAIN_NAME_PATTERN = Pattern.compile(DOMAIN_NAME_REGEX);
-
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception {
super.start(resourceContext);
}
@@ -188,7 +187,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
String existingIpaddr = augeas.get(ipaddrNode.getPath());
int existingIpAddressVersion = (existingIpaddr.indexOf(':') == -1) ? 4 : 6;
if (existingIpAddressVersion == ipAddressVersion) {
- return ipaddrNode;
+ return childNode;
}
}
return null;
diff --git a/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
index 07e30fb..326eec6 100644
--- a/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
@@ -41,8 +41,8 @@
</plugin-configuration>
<resource-configuration>
- <c:list-property name="/*" displayName="Entries">
- <c:map-property name="entry">
+ <c:list-property name="." displayName="Entries">
+ <c:map-property name="*[canonical]">
<c:simple-property name="ipaddr" displayName="IP Address" type="string" required="true" activationPolicy="immediate"
description="The IP address of the host entry. The address may be an IPv4 address (e.g., 192.168.1.10) or an IPv6 address (e.g., fec0:0:0:bebe::2)."/>
commit b8acc4e5a3faeba55e32cb6884d04d58d9081480
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Oct 20 10:50:24 2009 -0700
adding generated source for antlr plugin
diff --git a/.classpath b/.classpath
index a774301..4186c24 100644
--- a/.classpath
+++ b/.classpath
@@ -74,6 +74,7 @@
<classpathentry kind="src" path="modules/plugins/netservices/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/iis/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/perftest/target/generated-sources/xjc"/>
+ <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/>
<classpathentry kind="src" path="modules/plugins/perftest/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/perftest/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/apt/src/test/java"/>
commit 6cd27378f6f85912275418ef03cd2fac53e953fd
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Oct 20 10:29:57 2009 -0400
do not include virt plugin in ear until errors in it are fixed
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 7403400..0aaf838 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -341,13 +341,13 @@
<artifactId>rhq-sshd-plugin</artifactId>
<version>${project.version}</version>
</artifactItem>
-
+<!-- TODO: Uncomment once errors in virt plugin have been fixed.
<artifactItem>
<groupId>org.rhq</groupId>
<artifactId>rhq-virt-plugin</artifactId>
<version>${project.version}</version>
</artifactItem>
-
+-->
</artifactItems>
<outputDirectory>${earDirectory}/rhq-downloads/rhq-plugins</outputDirectory>
</configuration>
14 years, 7 months
[rhq] Branch 'linux-config' - 8 commits - modules/plugins
by lkrejci
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 153 +++++----
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java | 161 +++++++---
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java | 37 +-
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasVariable.java | 41 ++
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/Glob.java | 138 ++++++++
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/GlobFilter.java | 112 ++++++
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsDiscoveryComponent.java | 11
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/HostsComponentHelper.java | 7
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java | 4
9 files changed, 533 insertions(+), 131 deletions(-)
New commits:
commit 9e97187c25823c2e0b0c589a11284c319767ca3b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Oct 23 18:05:14 2009 +0200
small fixes...
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index d9a5405..1330800 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -21,6 +21,7 @@ package org.rhq.plugins.augeas;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -160,18 +161,24 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent>
return bld.toString();
}
- private PropertySimple getGlobList(String name, List<String> simples) {
+ public static PropertySimple getGlobList(String name, List<String> simples) {
StringBuilder bld = new StringBuilder();
if (simples != null) {
for(String s : simples) {
bld.append(s).append("|");
}
}
- bld.deleteCharAt(bld.length() - 1);
+ if (bld.length() > 0) {
+ bld.deleteCharAt(bld.length() - 1);
+ }
return new PropertySimple(name, bld.toString());
}
- private List<String> getGlobList(PropertySimple list) {
- return Arrays.asList(list.getStringValue().split("\\s*\\|\\s*"));
+ public static List<String> getGlobList(PropertySimple list) {
+ if (list != null) {
+ return Arrays.asList(list.getStringValue().split("\\s*\\|\\s*"));
+ } else {
+ return Collections.emptyList();
+ }
}
}
commit 5763c7fe335d0ed22c3aa8d998284b0e2cef73a0
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Oct 23 18:04:26 2009 +0200
default root node is "/files//" instead of "/" which could theoretically match stuff in /augeas as well.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index c7f4627..d0e4243 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -97,7 +97,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
this.resourceConfigRootNode = new AugeasNode("/files//", resourceConfigRootNodePath);
}
} else {
- this.resourceConfigRootNode = new AugeasNode("/");
+ this.resourceConfigRootNode = new AugeasNode("/files//");
}
}
}
commit 6639dcab5f87764dbc85892705aa48fc668cb352
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Oct 22 13:20:57 2009 +0200
Made Augeas*Component inheritable by correctly specifying the type parameter, made the propery loading/saving methods protected so that they can be overriden in the subclasses.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index f343126..c7f4627 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -61,7 +61,7 @@ import org.rhq.plugins.augeas.helper.Glob;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, ConfigurationFacet {
+public class AugeasConfigurationComponent<T extends ResourceComponent> implements ResourceComponent<T>, ConfigurationFacet {
public static final String INCLUDE_GLOBS_PROP = "configurationFilesInclusionPatterns";
public static final String EXCLUDE_GLOBS_PROP = "configurationFilesExclusionPatterns";
public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
@@ -260,7 +260,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implem
return true;
}
- private void loadProperty(PropertyDefinition propDef, AbstractPropertyMap parentPropMap, Augeas augeas,
+ protected void loadProperty(PropertyDefinition propDef, AbstractPropertyMap parentPropMap, Augeas augeas,
AugeasNode parentNode) {
String propName = propDef.getName();
AugeasNode node = (propName.equals(".")) ? parentNode : new AugeasNode(parentNode, propName);
@@ -277,7 +277,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implem
parentPropMap.put(prop);
}
- private Property createPropertySimple(PropertyDefinitionSimple propDefSimple, Augeas augeas, AugeasNode node) {
+ protected Property createPropertySimple(PropertyDefinitionSimple propDefSimple, Augeas augeas, AugeasNode node) {
String value;
if (propDefSimple.getType() == PropertySimpleType.LONG_STRING) {
List<String> childPaths = augeas.match(node.getPath());
@@ -299,13 +299,13 @@ public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implem
return new PropertySimple(propDefSimple.getName(), value);
}
- private PropertyMap createPropertyMap(PropertyDefinitionMap propDefMap, Augeas augeas, AugeasNode node) {
+ protected PropertyMap createPropertyMap(PropertyDefinitionMap propDefMap, Augeas augeas, AugeasNode node) {
PropertyMap propMap = new PropertyMap(propDefMap.getName());
populatePropertyMap(propDefMap, propMap, augeas, node);
return propMap;
}
- private Property createPropertyList(PropertyDefinitionList propDefList, Augeas augeas, AugeasNode node) {
+ protected Property createPropertyList(PropertyDefinitionList propDefList, Augeas augeas, AugeasNode node) {
PropertyDefinition listMemberPropDef = propDefList.getMemberDefinition();
if (!(listMemberPropDef instanceof PropertyDefinitionMap)) {
throw new IllegalArgumentException(
@@ -336,14 +336,14 @@ public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implem
return propList;
}
- private void populatePropertyMap(PropertyDefinitionMap propDefMap, PropertyMap propMap, Augeas augeas,
+ protected void populatePropertyMap(PropertyDefinitionMap propDefMap, PropertyMap propMap, Augeas augeas,
AugeasNode mapNode) {
for (PropertyDefinition mapEntryPropDef : propDefMap.getPropertyDefinitions().values()) {
loadProperty(mapEntryPropDef, propMap, augeas, mapNode);
}
}
- private void setNode(PropertyDefinition propDef, AbstractPropertyMap parentPropMap, Augeas augeas,
+ protected void setNode(PropertyDefinition propDef, AbstractPropertyMap parentPropMap, Augeas augeas,
AugeasNode parentNode) {
String propName = propDef.getName();
AugeasNode node = (propName.equals(".")) ? parentNode : new AugeasNode(parentNode, propName);
@@ -373,7 +373,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implem
}
}
- private void setNodeFromPropertySimple(Augeas augeas, AugeasNode node, PropertyDefinitionSimple propDefSimple,
+ protected void setNodeFromPropertySimple(Augeas augeas, AugeasNode node, PropertyDefinitionSimple propDefSimple,
PropertySimple propSimple) {
String value = propSimple.getStringValue();
if (propDefSimple.getType() == PropertySimpleType.LONG_STRING) {
@@ -396,14 +396,14 @@ public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implem
}
}
- private void setNodeFromPropertyMap(PropertyDefinitionMap propDefMap, PropertyMap propMap, Augeas augeas,
+ protected void setNodeFromPropertyMap(PropertyDefinitionMap propDefMap, PropertyMap propMap, Augeas augeas,
AugeasNode mapNode) {
for (PropertyDefinition mapEntryPropDef : propDefMap.getPropertyDefinitions().values()) {
setNode(mapEntryPropDef, propMap, augeas, mapNode);
}
}
- private void setNodeFromPropertyList(PropertyDefinitionList propDefList, PropertyList propList, Augeas augeas,
+ protected void setNodeFromPropertyList(PropertyDefinitionList propDefList, PropertyList propList, Augeas augeas,
AugeasNode listNode) {
PropertyDefinition listMemberPropDef = propDefList.getMemberDefinition();
if (!(listMemberPropDef instanceof PropertyDefinitionMap)) {
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index f0b6fec..d9a5405 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -45,7 +45,7 @@ import org.rhq.plugins.augeas.helper.Glob;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T>, ManualAddFacet<T> {
+public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent> implements ResourceDiscoveryComponent<T>, ManualAddFacet<T> {
private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> discoveryContext) throws InvalidPluginConfigurationException,
commit e0192453b1077a6f6bc81eceb1a88cf6c4b8e816
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Oct 22 11:56:20 2009 +0200
fixing small bugfixes uncovered during basic functional tests.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index 8617448..f343126 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -62,8 +62,8 @@ import org.rhq.plugins.augeas.helper.Glob;
* @author Lukas Krejci
*/
public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, ConfigurationFacet {
- public static final String INCLUDE_GLOBS_PROP = "includeConfigurationFilesPatterns";
- public static final String EXCLUDE_GLOBS_PROP = "excludeConfigurationFilesPatterns";
+ public static final String INCLUDE_GLOBS_PROP = "configurationFilesInclusionPatterns";
+ public static final String EXCLUDE_GLOBS_PROP = "configurationFilesExclusionPatterns";
public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
@@ -489,9 +489,9 @@ public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implem
includeGlobs = new ArrayList<String>();
excludeGlobs = new ArrayList<String>();
- includeGlobs.addAll(Arrays.asList(includes.getStringValue().split("\\s*|\\s*")));
+ includeGlobs.addAll(Arrays.asList(includes.getStringValue().split("\\s*\\|\\s*")));
if (excludes != null) {
- excludeGlobs.addAll(Arrays.asList(excludes.getStringValue().split("\\s*|\\s*")));
+ excludeGlobs.addAll(Arrays.asList(excludes.getStringValue().split("\\s*\\|\\s*")));
}
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index 97a3319..f0b6fec 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -111,29 +111,22 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
}
private void checkFiles(Configuration pluginConfiguration) {
- PropertyList includeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
- PropertyList excludeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
+ PropertySimple includeGlobsProp = pluginConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
+ PropertySimple excludeGlobsProp = pluginConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
File root = new File(AugeasConfigurationComponent.AUGEAS_ROOT_PATH);
- ArrayList<String> includeGlobs = new ArrayList<String>();
+ List<String> includeGlobs = getGlobList(includeGlobsProp);
if (includeGlobsProp == null) {
throw new IllegalStateException("Expecting at least once inclusion pattern for configuration files.");
}
- for(Property p : includeGlobsProp.getList()) {
- PropertySimple include = (PropertySimple)p;
- includeGlobs.add(include.getStringValue());
- }
-
List<File> files = Glob.matchAll(root, includeGlobs);
if (excludeGlobsProp != null) {
- for(Property p : excludeGlobsProp.getList()) {
- PropertySimple exclude = (PropertySimple)p;
- Glob.exclude(files, exclude.getStringValue());
- }
+ List<String> excludeGlobs = getGlobList(excludeGlobsProp);
+ Glob.excludeAll(files, excludeGlobs);
}
for(File configFile : files) {
@@ -179,6 +172,6 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
}
private List<String> getGlobList(PropertySimple list) {
- return Arrays.asList(list.getStringValue().split("\\s*|\\s*"));
+ return Arrays.asList(list.getStringValue().split("\\s*\\|\\s*"));
}
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/Glob.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/Glob.java
index a22f0f2..0a2fc52 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/Glob.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/Glob.java
@@ -81,7 +81,12 @@ public class Glob {
//move the parent path down to the nearest parent of the wildcard part of the
//glob pattern
parentPath = new File(parentPath, globPattern.substring(0, globParentIdx));
+ globPattern = parentPath.getAbsolutePath() + globPattern.substring(globParentIdx);
+ } else {
+ globPattern = parentPath.getAbsolutePath() + globPattern;
}
+ } else {
+ globPattern = parentPath.getAbsolutePath() + globPattern;
}
return Arrays.asList(parentPath.listFiles(new GlobFilter(globPattern)));
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/GlobFilter.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/GlobFilter.java
index 548ba2f..e17276b 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/GlobFilter.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/GlobFilter.java
@@ -98,6 +98,9 @@ public class GlobFilter implements FileFilter {
case '/':
regexPattern.append("\\/");
break;
+ default:
+ regexPattern.append(globPattern.charAt(i));
+ break;
}
i++;
}
commit cfbcbdbce17ddbfe86b91c72c7188f18565aa207
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 21 14:26:39 2009 +0200
The (in|ex)clusion patterns are now specified as simple properties so that they can be defaulted.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index 682b404..8617448 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -20,6 +20,7 @@ package org.rhq.plugins.augeas;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
@@ -63,7 +64,6 @@ import org.rhq.plugins.augeas.helper.Glob;
public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, ConfigurationFacet {
public static final String INCLUDE_GLOBS_PROP = "includeConfigurationFilesPatterns";
public static final String EXCLUDE_GLOBS_PROP = "excludeConfigurationFilesPatterns";
- public static final String GLOB_PATTERN_PROP = "pattern";
public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
@@ -483,20 +483,15 @@ public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implem
}
private void initGlobs(Configuration pluginConfiguration) {
- PropertyList includes = pluginConfiguration.getList(INCLUDE_GLOBS_PROP);
- PropertyList excludes = pluginConfiguration.getList(EXCLUDE_GLOBS_PROP);
+ PropertySimple includes = pluginConfiguration.getSimple(INCLUDE_GLOBS_PROP);
+ PropertySimple excludes = pluginConfiguration.getSimple(EXCLUDE_GLOBS_PROP);
includeGlobs = new ArrayList<String>();
excludeGlobs = new ArrayList<String>();
- for(Property p : includes.getList()) {
- PropertySimple include = (PropertySimple) p;
- includeGlobs.add(include.getStringValue());
- }
-
- for(Property p : excludes.getList()) {
- PropertySimple exclude = (PropertySimple)p;
- excludeGlobs.add(exclude.getStringValue());
+ includeGlobs.addAll(Arrays.asList(includes.getStringValue().split("\\s*|\\s*")));
+ if (excludes != null) {
+ excludeGlobs.addAll(Arrays.asList(excludes.getStringValue().split("\\s*|\\s*")));
}
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index 0735227..97a3319 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -20,6 +20,7 @@ package org.rhq.plugins.augeas;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -55,8 +56,8 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
List<String> excludes = determineExcludeGlobs(discoveryContext);
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
- PropertyList includeProps = getGlobList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP, AugeasConfigurationComponent.GLOB_PATTERN_PROP, includes);
- PropertyList excludeProps = getGlobList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP, AugeasConfigurationComponent.GLOB_PATTERN_PROP, excludes);
+ PropertySimple includeProps = getGlobList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP, includes);
+ PropertySimple excludeProps = getGlobList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP, excludes);
pluginConfig.put(includeProps);
pluginConfig.put(excludeProps);
@@ -90,7 +91,7 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
protected List<String> determineIncludeGlobs(ResourceDiscoveryContext<T> discoveryContext) {
Configuration pluginConfiguration = discoveryContext.getDefaultPluginConfiguration();
- PropertyList includeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
+ PropertySimple includeGlobsProp = pluginConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
List<String> ret = getGlobList(includeGlobsProp);
if (ret == null || ret.size() == 0) {
@@ -102,7 +103,7 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
protected List<String> determineExcludeGlobs(ResourceDiscoveryContext<T> discoveryContext) {
Configuration pluginConfiguration = discoveryContext.getDefaultPluginConfiguration();
- PropertyList excludeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
+ PropertySimple excludeGlobsProp = pluginConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
List<String> ret = getGlobList(excludeGlobsProp);
@@ -149,22 +150,16 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
}
private String composeResourceKey(Configuration pluginConfiguration) {
- PropertyList includeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
- PropertyList excludeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
+ PropertySimple includeGlobsProp = pluginConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
+ PropertySimple excludeGlobsProp = pluginConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
StringBuilder bld = new StringBuilder();
- for (Property p : includeGlobsProp.getList()) {
- PropertySimple include = (PropertySimple) p;
- bld.append(include.getStringValue()).append(File.pathSeparatorChar);
- }
+ bld.append(includeGlobsProp.getStringValue());
- if (excludeGlobsProp != null && excludeGlobsProp.getList().size() > 0) {
+ if (excludeGlobsProp != null && excludeGlobsProp.getStringValue().length() > 0) {
bld.append("---");
- for (Property p : excludeGlobsProp.getList()) {
- PropertySimple exclude = (PropertySimple) p;
- bld.append(exclude.getStringValue()).append(File.pathSeparatorChar);
- }
+ bld.append(excludeGlobsProp.getStringValue());
}
bld.deleteCharAt(bld.length() - 1);
@@ -172,24 +167,18 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
return bld.toString();
}
- private PropertyList getGlobList(String name, String simpleName, List<String> simples) {
- PropertyList ret = new PropertyList(name);
+ private PropertySimple getGlobList(String name, List<String> simples) {
+ StringBuilder bld = new StringBuilder();
if (simples != null) {
for(String s : simples) {
- PropertySimple simple = new PropertySimple(simpleName, s);
- ret.add(simple);
+ bld.append(s).append("|");
}
}
- return ret;
+ bld.deleteCharAt(bld.length() - 1);
+ return new PropertySimple(name, bld.toString());
}
- private List<String> getGlobList(PropertyList list) {
- if (list == null) return null;
- ArrayList<String> ret = new ArrayList<String>();
- for(Property p : list.getList()) {
- ret.add(((PropertySimple)p).getStringValue());
- }
-
- return ret;
+ private List<String> getGlobList(PropertySimple list) {
+ return Arrays.asList(list.getStringValue().split("\\s*|\\s*"));
}
}
commit 873aeeb060e3bfb65c0498f06f635b2a1dd9e034
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 21 13:37:58 2009 +0200
Make it possible for the discovery subclasses to override the inclusion and exclusion patterns. Made it all compile again..
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index aa3a574..682b404 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -63,6 +63,7 @@ import org.rhq.plugins.augeas.helper.Glob;
public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, ConfigurationFacet {
public static final String INCLUDE_GLOBS_PROP = "includeConfigurationFilesPatterns";
public static final String EXCLUDE_GLOBS_PROP = "excludeConfigurationFilesPatterns";
+ public static final String GLOB_PATTERN_PROP = "pattern";
public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index 584d755..0735227 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -51,10 +51,17 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
Exception {
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(1);
- checkConfigurationFiles(discoveryContext.getDefaultPluginConfiguration());
-
+ List<String> includes = determineIncludeGlobs(discoveryContext);
+ List<String> excludes = determineExcludeGlobs(discoveryContext);
+
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
-
+ PropertyList includeProps = getGlobList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP, AugeasConfigurationComponent.GLOB_PATTERN_PROP, includes);
+ PropertyList excludeProps = getGlobList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP, AugeasConfigurationComponent.GLOB_PATTERN_PROP, excludes);
+ pluginConfig.put(includeProps);
+ pluginConfig.put(excludeProps);
+
+ checkFiles(pluginConfig);
+
DiscoveredResourceDetails resource = createResourceDetails(discoveryContext, pluginConfig);
discoveredResources.add(resource);
log.debug("Discovered " + discoveryContext.getResourceType().getName() + " Resource with key ["
@@ -66,7 +73,7 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
public DiscoveredResourceDetails discoverResource(Configuration pluginConfig,
ResourceDiscoveryContext<T> discoveryContext) throws InvalidPluginConfigurationException {
- checkConfigurationFiles(pluginConfig);
+ checkFiles(pluginConfig);
DiscoveredResourceDetails resource = createResourceDetails(discoveryContext, pluginConfig);
return resource;
@@ -81,7 +88,28 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
return resource;
}
- private void checkConfigurationFiles(Configuration pluginConfiguration) {
+ protected List<String> determineIncludeGlobs(ResourceDiscoveryContext<T> discoveryContext) {
+ Configuration pluginConfiguration = discoveryContext.getDefaultPluginConfiguration();
+ PropertyList includeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
+
+ List<String> ret = getGlobList(includeGlobsProp);
+ if (ret == null || ret.size() == 0) {
+ throw new IllegalStateException("Expecting at least once inclusion pattern for configuration files.");
+ }
+
+ return ret;
+ }
+
+ protected List<String> determineExcludeGlobs(ResourceDiscoveryContext<T> discoveryContext) {
+ Configuration pluginConfiguration = discoveryContext.getDefaultPluginConfiguration();
+ PropertyList excludeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
+
+ List<String> ret = getGlobList(excludeGlobsProp);
+
+ return ret;
+ }
+
+ private void checkFiles(Configuration pluginConfiguration) {
PropertyList includeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
PropertyList excludeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
@@ -143,4 +171,25 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
return bld.toString();
}
+
+ private PropertyList getGlobList(String name, String simpleName, List<String> simples) {
+ PropertyList ret = new PropertyList(name);
+ if (simples != null) {
+ for(String s : simples) {
+ PropertySimple simple = new PropertySimple(simpleName, s);
+ ret.add(simple);
+ }
+ }
+ return ret;
+ }
+
+ private List<String> getGlobList(PropertyList list) {
+ if (list == null) return null;
+ ArrayList<String> ret = new ArrayList<String>();
+ for(Property p : list.getList()) {
+ ret.add(((PropertySimple)p).getStringValue());
+ }
+
+ return ret;
+ }
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsDiscoveryComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsDiscoveryComponent.java
index b63230e..bfd82a1 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsDiscoveryComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsDiscoveryComponent.java
@@ -19,6 +19,8 @@
package org.rhq.plugins.hosts;
import java.io.File;
+import java.util.Collections;
+import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -54,7 +56,7 @@ public class HostsDiscoveryComponent extends AugeasConfigurationDiscoveryCompone
}
@Override
- protected File getConfigurationFile(ResourceDiscoveryContext discoveryContext)
+ protected List<String> determineIncludeGlobs(ResourceDiscoveryContext discoveryContext)
{
File hostsFile;
if (IS_WINDOWS) {
@@ -63,7 +65,12 @@ public class HostsDiscoveryComponent extends AugeasConfigurationDiscoveryCompone
} else {
hostsFile = new File("/etc/hosts");
}
- return hostsFile;
+ return Collections.singletonList(hostsFile.getAbsolutePath());
+ }
+
+ @Override
+ protected List<String> determineExcludeGlobs(ResourceDiscoveryContext discoveryContext) {
+ return null;
}
private File getWindowsDir() {
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/HostsComponentHelper.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/HostsComponentHelper.java
index c3041fc..3bf0ba6 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/HostsComponentHelper.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/HostsComponentHelper.java
@@ -23,6 +23,7 @@
package org.rhq.plugins.hosts.helper;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.plugins.hosts.HostsComponent;
@@ -33,17 +34,17 @@ import java.io.File;
*/
public class HostsComponentHelper {
public static File getHostsFile(Configuration pluginConfig) {
- String hostsFilePath = pluginConfig.getSimple(HostsComponent.CONFIGURATION_FILE_PROP).getStringValue();
+ String hostsFilePath = ((PropertySimple)pluginConfig.getList(HostsComponent.INCLUDE_GLOBS_PROP).getList().get(0)).getStringValue();
return new File(hostsFilePath);
}
public static void validateHostFileExists(File hostsFile) throws InvalidPluginConfigurationException {
if (!hostsFile.exists()) {
- throw new InvalidPluginConfigurationException("Location specified by '" + HostsComponent.CONFIGURATION_FILE_PROP
+ throw new InvalidPluginConfigurationException("Location specified by '" + HostsComponent.INCLUDE_GLOBS_PROP
+ "' connection property does not exist.");
}
if (hostsFile.isDirectory()) {
- throw new InvalidPluginConfigurationException("Location specified by '" + HostsComponent.CONFIGURATION_FILE_PROP
+ throw new InvalidPluginConfigurationException("Location specified by '" + HostsComponent.INCLUDE_GLOBS_PROP
+ "' connection property is a directory, not a regular file.");
}
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
index b58b8f2..8856938 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
@@ -51,7 +51,7 @@ public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet
public Configuration loadResourceConfiguration() throws Exception {
Configuration resourceConfig = new Configuration();
- File hostsFile = this.hostsComponent.getConfigurationFiles().get(0);
+ File hostsFile = (File)this.hostsComponent.getConfigurationFiles().get(0);
Hosts hosts = Hosts.load(hostsFile);
resourceConfig.setNotes("Loaded at " + new Date());
@@ -135,7 +135,7 @@ public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet
return;
}
- File hostsFile = this.hostsComponent.getConfigurationFiles().get(0);
+ File hostsFile = (File)this.hostsComponent.getConfigurationFiles().get(0);
try {
Hosts.store(newHosts, hostsFile);
}
commit 1a360ba3fdb402a0f35ee9cf817884384307929e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 21 13:11:45 2009 +0200
changed the way the resourceKey is determined.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index 32a1c7c..584d755 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -75,7 +75,7 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
protected DiscoveredResourceDetails createResourceDetails(ResourceDiscoveryContext<T> discoveryContext,
Configuration pluginConfig) {
ResourceType resourceType = discoveryContext.getResourceType();
- String resourceKey = pluginConfig.getSimpleValue(AugeasConfigurationComponent.AUGEAS_MODULE_NAME_PROP, null);
+ String resourceKey = composeResourceKey(pluginConfig);
DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceType
.getName(), null, resourceType.getDescription(), pluginConfig, null);
return resource;
@@ -119,4 +119,28 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?
}
}
}
+
+ private String composeResourceKey(Configuration pluginConfiguration) {
+ PropertyList includeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
+ PropertyList excludeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
+
+ StringBuilder bld = new StringBuilder();
+
+ for (Property p : includeGlobsProp.getList()) {
+ PropertySimple include = (PropertySimple) p;
+ bld.append(include.getStringValue()).append(File.pathSeparatorChar);
+ }
+
+ if (excludeGlobsProp != null && excludeGlobsProp.getList().size() > 0) {
+ bld.append("---");
+ for (Property p : excludeGlobsProp.getList()) {
+ PropertySimple exclude = (PropertySimple) p;
+ bld.append(exclude.getStringValue()).append(File.pathSeparatorChar);
+ }
+ }
+
+ bld.deleteCharAt(bld.length() - 1);
+
+ return bld.toString();
+ }
}
commit b33fcfc0e604fa48025d9e292d1c3e60047b6ba1
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 21 13:02:53 2009 +0200
Modified Augeas plugin to support configuring multiple files at once.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index fcdcf01..aa3a574 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -54,50 +54,49 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import org.rhq.plugins.platform.PlatformComponent;
+import org.rhq.plugins.augeas.helper.Glob;
/**
* @author Ian Springer
+ * @author Lukas Krejci
*/
-public class AugeasConfigurationComponent implements ResourceComponent<PlatformComponent>, ConfigurationFacet {
- public static final String CONFIGURATION_FILE_PROP = "configurationFile";
+public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, ConfigurationFacet {
+ public static final String INCLUDE_GLOBS_PROP = "includeConfigurationFilesPatterns";
+ public static final String EXCLUDE_GLOBS_PROP = "excludeConfigurationFilesPatterns";
public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
private static final boolean IS_WINDOWS = (File.separatorChar == '\\');
private static final String AUGEAS_LOAD_PATH = "/usr/share/augeas/lenses";
- private static final String AUGEAS_ROOT_PATH = "/";
+ public static final String AUGEAS_ROOT_PATH = "/";
private final Log log = LogFactory.getLog(this.getClass());
- private ResourceContext resourceContext;
- private File configFile;
+ private ResourceContext<T> resourceContext;
+ private List<String> includeGlobs;
+ private List<String> excludeGlobs;
private Augeas augeas;
- private AugeasNode augeasConfigFileMetadataNode;
private AugeasNode resourceConfigRootNode;
- public void start(ResourceContext<PlatformComponent> resourceContext) throws InvalidPluginConfigurationException,
+ public void start(ResourceContext<T> resourceContext) throws InvalidPluginConfigurationException,
Exception {
this.resourceContext = resourceContext;
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String configFilePath = pluginConfig.getSimple(CONFIGURATION_FILE_PROP).getStringValue();
- this.configFile = new File(configFilePath);
+
+ initGlobs(pluginConfig);
+
this.augeas = createAugeas();
+
if (this.augeas != null) {
- AugeasNode augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
- // This is the metadata portion of the tree for this config file (e.g. /augeas/files/etc/hosts, where error
- // messages are stored as node values.
- this.augeasConfigFileMetadataNode = new AugeasNode("/augeas/files" + AugeasNode.SEPARATOR_CHAR
- + this.configFile.getPath());
String resourceConfigRootNodePath = pluginConfig.getSimpleValue(RESOURCE_CONFIGURATION_ROOT_NODE_PROP, null);
if (resourceConfigRootNodePath != null) {
if (resourceConfigRootNodePath.indexOf(AugeasNode.SEPARATOR_CHAR) == 0) {
this.resourceConfigRootNode = new AugeasNode(resourceConfigRootNodePath);
} else {
- this.resourceConfigRootNode = new AugeasNode(augeasConfigFileNode, resourceConfigRootNodePath);
+ this.resourceConfigRootNode = new AugeasNode("/files//", resourceConfigRootNodePath);
}
} else {
- this.resourceConfigRootNode = augeasConfigFileNode;
+ this.resourceConfigRootNode = new AugeasNode("/");
}
}
}
@@ -107,19 +106,10 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
}
public AvailabilityType getAvailability() {
- if (!this.configFile.isAbsolute()) {
- throw new InvalidPluginConfigurationException("Location specified by '" + CONFIGURATION_FILE_PROP
- + "' connection property is not an absolute path.");
- }
- if (!this.configFile.exists()) {
- throw new InvalidPluginConfigurationException("Location specified by '" + CONFIGURATION_FILE_PROP
- + "' connection property does not exist.");
- }
- if (this.configFile.isDirectory()) {
- throw new InvalidPluginConfigurationException("Location specified by '" + CONFIGURATION_FILE_PROP
- + "' connection property is a directory, not a regular file.");
+ for(File f : getConfigurationFiles()) {
+ singleFileAvailabilityCheck(f);
}
- return this.configFile.exists() ? AvailabilityType.UP : AvailabilityType.DOWN;
+ return AvailabilityType.UP;
}
public Configuration loadResourceConfiguration() throws Exception {
@@ -150,18 +140,6 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
return;
}
- if (!this.configFile.canWrite()) {
- report.setErrorMessage("Configuration file '" + this.configFile + "' is not writable.");
- return;
- }
-
- File configFileParentDir = this.configFile.getParentFile();
- if (!configFileParentDir.canWrite()) {
- report.setErrorMessage("Configuration file parent directory '" + configFileParentDir
- + "' is not writable.");
- return;
- }
-
// Load the config file from disk and build a tree representation of it in memory.
this.augeas.load();
@@ -220,12 +198,14 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
return resourceConfigRootNode;
}
- public ResourceContext getResourceContext() {
+ public ResourceContext<T> getResourceContext() {
return resourceContext;
}
- public File getConfigurationFile() {
- return this.configFile;
+ public List<File> getConfigurationFiles() {
+ List<File> files = Glob.matchAll(new File(AUGEAS_ROOT_PATH), includeGlobs);
+ Glob.excludeAll(files, excludeGlobs);
+ return files;
}
public Augeas getAugeas() {
@@ -247,7 +227,15 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
try {
augeas = new Augeas(AUGEAS_ROOT_PATH, AUGEAS_LOAD_PATH, Augeas.NO_MODL_AUTOLOAD);
augeas.set("/augeas/load/" + augeasModuleName + "/lens", augeasModuleName + ".lns");
- augeas.set("/augeas/load/" + augeasModuleName + "/incl", this.configFile.getPath());
+
+ int idx = 1;
+ for(String incl : includeGlobs) {
+ augeas.set("/augeas/load/" + augeasModuleName + "/incl[" + (idx++) + "]", incl);
+ }
+ idx = 1;
+ for(String excl : excludeGlobs) {
+ augeas.set("/augeas/load/" + augeasModuleName + "/excl[" + (idx++) + "]", excl);
+ }
} catch (RuntimeException e) {
augeas = null;
log.warn("Failed to initialize Augeas Java API.", e);
@@ -489,18 +477,57 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
try {
this.augeas.save();
} catch (AugeasException e) {
- StringBuilder buffer = new StringBuilder("Failed to save " + this.configFile + ".");
- AugeasNode errorNode = new AugeasNode(this.augeasConfigFileMetadataNode, "error");
- String error = this.augeas.get(errorNode.getPath());
- if (error != null) {
- buffer.append(" Cause: ").append(error);
- AugeasNode errorMessageNode = new AugeasNode(errorNode, "message");
- String errorMessage = this.augeas.get(errorMessageNode.getPath());
- if (errorMessage != null) {
- buffer.append(": ").append(errorMessage);
- }
+ throw new RuntimeException(summarizeAugeasError(), e);
+ }
+ }
+
+ private void initGlobs(Configuration pluginConfiguration) {
+ PropertyList includes = pluginConfiguration.getList(INCLUDE_GLOBS_PROP);
+ PropertyList excludes = pluginConfiguration.getList(EXCLUDE_GLOBS_PROP);
+
+ includeGlobs = new ArrayList<String>();
+ excludeGlobs = new ArrayList<String>();
+
+ for(Property p : includes.getList()) {
+ PropertySimple include = (PropertySimple) p;
+ includeGlobs.add(include.getStringValue());
+ }
+
+ for(Property p : excludes.getList()) {
+ PropertySimple exclude = (PropertySimple)p;
+ excludeGlobs.add(exclude.getStringValue());
+ }
+ }
+
+ private void singleFileAvailabilityCheck(File f) {
+ if (!f.isAbsolute()) {
+ throw new InvalidPluginConfigurationException("Path '" + f.getPath()
+ + "' is not an absolute path.");
+ }
+ if (!f.exists()) {
+ throw new InvalidPluginConfigurationException("File '" + f.getPath()
+ + "' does not exist.");
+ }
+ if (f.isDirectory()) {
+ throw new InvalidPluginConfigurationException("Path '" + f.getPath()
+ + "' is a directory, not a regular file.");
+ }
+ }
+
+ private String summarizeAugeasError() {
+ StringBuilder summary = new StringBuilder();
+ String metadataNodePrefix = "/augeas/files";
+ for(String glob : includeGlobs) {
+ AugeasNode metadataNode = new AugeasNode(metadataNodePrefix, glob);
+ AugeasNode errorNode = new AugeasNode(metadataNode, "error");
+ List<String> nodePaths = this.augeas.match(errorNode.getPath());
+ for (String path : nodePaths) {
+ String error = this.augeas.get(path);
+ summary.append("File '").append(path.substring(metadataNodePrefix.length(), path.length() - 5))
+ .append("':\n").append(error).append("\n");
}
- throw new RuntimeException(buffer.toString(), e);
}
+
+ return summary.toString();
}
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index e0e8afa..32a1c7c 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -19,45 +19,42 @@
package org.rhq.plugins.augeas;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ManualAddFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.augeas.helper.Glob;
/**
* @author Ian Springer
+ * @author Lukas Krejci
*/
-public class AugeasConfigurationDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
+public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T>, ManualAddFacet<T> {
private final Log log = LogFactory.getLog(this.getClass());
- public Set discoverResources(ResourceDiscoveryContext discoveryContext) throws InvalidPluginConfigurationException,
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> discoveryContext) throws InvalidPluginConfigurationException,
Exception {
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(1);
- File configFile = getConfigurationFile(discoveryContext);
- if (!configFile.isAbsolute()) {
- throw new IllegalStateException("getConfigurationFile() returned a non-absolute file.");
- }
- if (!configFile.exists()) {
- throw new IllegalStateException("getConfigurationFile() returned a non-existent file.");
- }
- if (configFile.isDirectory()) {
- throw new IllegalStateException("getConfigurationFile() returned a directory.");
- }
+ checkConfigurationFiles(discoveryContext.getDefaultPluginConfiguration());
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
- pluginConfig
- .put(new PropertySimple(AugeasConfigurationComponent.CONFIGURATION_FILE_PROP, configFile.getPath()));
+
DiscoveredResourceDetails resource = createResourceDetails(discoveryContext, pluginConfig);
discoveredResources.add(resource);
log.debug("Discovered " + discoveryContext.getResourceType().getName() + " Resource with key ["
@@ -67,43 +64,59 @@ public class AugeasConfigurationDiscoveryComponent implements ResourceDiscoveryC
}
public DiscoveredResourceDetails discoverResource(Configuration pluginConfig,
- ResourceDiscoveryContext discoveryContext) throws InvalidPluginConfigurationException {
- String configFilePath = pluginConfig.getSimple(AugeasConfigurationComponent.CONFIGURATION_FILE_PROP)
- .getStringValue();
-
- File configFile = new File(configFilePath);
- if (!configFile.isAbsolute()) {
- throw new InvalidPluginConfigurationException("Location specified by '"
- + AugeasConfigurationComponent.CONFIGURATION_FILE_PROP
- + "' connection property is not an absolute path.");
- }
- if (!configFile.exists()) {
- throw new InvalidPluginConfigurationException("Location specified by '"
- + AugeasConfigurationComponent.CONFIGURATION_FILE_PROP + "' connection property does not exist.");
- }
- if (configFile.isDirectory()) {
- throw new InvalidPluginConfigurationException("Location specified by '"
- + AugeasConfigurationComponent.CONFIGURATION_FILE_PROP
- + "' connection property is a directory, not a regular file.");
- }
+ ResourceDiscoveryContext<T> discoveryContext) throws InvalidPluginConfigurationException {
+
+ checkConfigurationFiles(pluginConfig);
DiscoveredResourceDetails resource = createResourceDetails(discoveryContext, pluginConfig);
return resource;
}
- protected File getConfigurationFile(ResourceDiscoveryContext discoveryContext) {
- Configuration defaultPluginConfig = discoveryContext.getDefaultPluginConfiguration();
- String configFilePath = defaultPluginConfig.getSimple(AugeasConfigurationComponent.CONFIGURATION_FILE_PROP)
- .getStringValue();
- return new File(configFilePath);
- }
-
- protected DiscoveredResourceDetails createResourceDetails(ResourceDiscoveryContext discoveryContext,
+ protected DiscoveredResourceDetails createResourceDetails(ResourceDiscoveryContext<T> discoveryContext,
Configuration pluginConfig) {
ResourceType resourceType = discoveryContext.getResourceType();
- String resourceKey = getConfigurationFile(discoveryContext).getPath();
+ String resourceKey = pluginConfig.getSimpleValue(AugeasConfigurationComponent.AUGEAS_MODULE_NAME_PROP, null);
DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceType
.getName(), null, resourceType.getDescription(), pluginConfig, null);
return resource;
}
+
+ private void checkConfigurationFiles(Configuration pluginConfiguration) {
+ PropertyList includeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
+ PropertyList excludeGlobsProp = pluginConfiguration.getList(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
+
+ File root = new File(AugeasConfigurationComponent.AUGEAS_ROOT_PATH);
+
+ ArrayList<String> includeGlobs = new ArrayList<String>();
+
+ if (includeGlobsProp == null) {
+ throw new IllegalStateException("Expecting at least once inclusion pattern for configuration files.");
+ }
+
+ for(Property p : includeGlobsProp.getList()) {
+ PropertySimple include = (PropertySimple)p;
+ includeGlobs.add(include.getStringValue());
+ }
+
+ List<File> files = Glob.matchAll(root, includeGlobs);
+
+ if (excludeGlobsProp != null) {
+ for(Property p : excludeGlobsProp.getList()) {
+ PropertySimple exclude = (PropertySimple)p;
+ Glob.exclude(files, exclude.getStringValue());
+ }
+ }
+
+ for(File configFile : files) {
+ if (!configFile.isAbsolute()) {
+ throw new IllegalStateException("Configuration files inclusion patterns contain a non-absolute file.");
+ }
+ if (!configFile.exists()) {
+ throw new IllegalStateException("Configuration files inclusion patterns refer to a non-existent file.");
+ }
+ if (configFile.isDirectory()) {
+ throw new IllegalStateException("Configuration files inclusion patterns refer to a directory.");
+ }
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java
index 6bff878..0c007d9 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java
@@ -60,21 +60,6 @@ public class AugeasNode {
this(new AugeasNode(parentPath), name);
}
- private AugeasNode(AugeasNode child) {
- String path = child.getPath();
- if (path.equals(SEPARATOR)) {
- // special case - parent of "/" is "/".
- this.path = path;
- } else {
- char lastChar = path.charAt(path.length() - 1);
- if (lastChar == SEPARATOR_CHAR) {
- path = path.substring(0, path.length() - 1);
- }
- int lastSlashIndex = path.lastIndexOf(SEPARATOR_CHAR);
- this.path = path.substring(0, lastSlashIndex);
- }
- }
-
public String getName() {
int lastSlashIndex = this.path.lastIndexOf(SEPARATOR_CHAR);
return (lastSlashIndex == 0) ? this.path : this.path.substring(lastSlashIndex + 1);
@@ -85,7 +70,12 @@ public class AugeasNode {
}
public AugeasNode getParent() {
- return new AugeasNode(this);
+ String parentPath = getParentPath();
+ if (parentPath.indexOf(SEPARATOR_CHAR) == -1 && parentPath.startsWith(AugeasVariable.VARIABLE_NAME_PREFIX)) {
+ return new AugeasVariable(parentPath.substring(AugeasVariable.VARIABLE_NAME_PREFIX.length()));
+ } else {
+ return new AugeasNode(parentPath);
+ }
}
@Override
@@ -112,4 +102,19 @@ public class AugeasNode {
public String toString() {
return this.path;
}
+
+ protected String getParentPath() {
+ String path = getPath();
+ if (path.equals(SEPARATOR)) {
+ // special case - parent of "/" is "/".
+ return path;
+ } else {
+ char lastChar = path.charAt(path.length() - 1);
+ if (lastChar == SEPARATOR_CHAR) {
+ path = path.substring(0, path.length() - 1);
+ }
+ int lastSlashIndex = path.lastIndexOf(SEPARATOR_CHAR);
+ return path.substring(0, lastSlashIndex);
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasVariable.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasVariable.java
new file mode 100644
index 0000000..e25e128
--- /dev/null
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasVariable.java
@@ -0,0 +1,41 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.plugins.augeas.helper;
+
+/**
+ * A specialization of {@link AugeasNode} that represents an Augeas variable.
+ *
+ * @author Lukas Krejci
+ */
+public class AugeasVariable extends AugeasNode {
+
+ public static final String VARIABLE_NAME_PREFIX = "$";
+
+ /**
+ * @param path
+ */
+ public AugeasVariable(String name) {
+ super(VARIABLE_NAME_PREFIX + name);
+ }
+}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/Glob.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/Glob.java
new file mode 100644
index 0000000..a22f0f2
--- /dev/null
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/Glob.java
@@ -0,0 +1,133 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.plugins.augeas.helper;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A helper class for easy work with glob patterns.
+ *
+ * @author Lukas Krejci
+ */
+public class Glob {
+
+ private Glob() {
+
+ }
+
+ public static boolean isWildcard(String globPattern) {
+ for(char specialChar : GlobFilter.WILDCARD_CHARS) {
+ if (globPattern.indexOf(specialChar) >= 0) return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns a fixed size list of matches.
+ *
+ * The parent path specifies the "root" from which the glob pattern applies.
+ * The glob pattern can span several directories with wildcards present only
+ * on the lowest level.
+ * The glob pattern is always relative to the specified parent path, even if it denotes
+ * an absolute path. In that case, the leading root path is chopped off and the rest is
+ * appended to the parent path.
+ *
+ * @param parentPath the parent path to start the pattern search
+ * @param globPattern the glob pattern to match against
+ * @return the list of matches
+ */
+ public static List<File> match(File parentPath, String globPattern) {
+ String rootPortion = rootPortion(globPattern);
+ globPattern = globPattern.substring(rootPortion.length());
+
+ //now search for the first special character in the patterns
+ int specialCharIdx = globPattern.length();
+ for(char specialChar : GlobFilter.WILDCARD_CHARS) {
+ int idx = globPattern.indexOf(specialChar);
+ if (idx >= 0 && specialCharIdx > idx) {
+ specialCharIdx = idx;
+ }
+ }
+
+ if (specialCharIdx > 0) {
+ //now search for the first path separator preceeding the special char
+ int globParentIdx = globPattern.lastIndexOf(File.separatorChar, specialCharIdx);
+ if (globParentIdx > 0) {
+ //move the parent path down to the nearest parent of the wildcard part of the
+ //glob pattern
+ parentPath = new File(parentPath, globPattern.substring(0, globParentIdx));
+ }
+ }
+
+ return Arrays.asList(parentPath.listFiles(new GlobFilter(globPattern)));
+ }
+
+ public static List<File> matchAll(File parentPath, String... globPattern) {
+ return matchAll(parentPath, Arrays.asList(globPattern));
+ }
+
+ public static List<File> matchAll(File parentPath, List<String> globPatterns) {
+ ArrayList<File> matches = new ArrayList<File>();
+ for(String p : globPatterns) {
+ matches.addAll(match(parentPath, p));
+ }
+
+ return matches;
+ }
+
+ public static void exclude(List<File> matches, String globPattern) {
+ GlobFilter filter = new GlobFilter(globPattern);
+
+ Iterator<File> it = matches.iterator();
+ while (it.hasNext()) {
+ if (filter.accept(it.next())) {
+ it.remove();
+ }
+ }
+ }
+
+ public static void excludeAll(List<File> matches, String... globPattern) {
+ excludeAll(matches, Arrays.asList(globPattern));
+ }
+
+ public static void excludeAll(List<File> matches, List<String> globPatterns) {
+ for(String p : globPatterns) {
+ exclude(matches, p);
+ }
+ }
+
+ private static String rootPortion(String path) {
+ for (File root : File.listRoots()) {
+ if (path.startsWith(root.getPath())) {
+ return root.getPath();
+ }
+ }
+
+ return "";
+ }
+}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/GlobFilter.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/GlobFilter.java
new file mode 100644
index 0000000..548ba2f
--- /dev/null
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/GlobFilter.java
@@ -0,0 +1,109 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.plugins.augeas.helper;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.regex.Pattern;
+
+/**
+ * A filter implementing a glob pattern match.
+ *
+ * @author Lukas Krejci
+ */
+public class GlobFilter implements FileFilter {
+
+ private String globPattern;
+ private Pattern regexPattern;
+
+ public static final char[] WILDCARD_CHARS;
+
+ static {
+ if (File.separatorChar == '\\') {
+ WILDCARD_CHARS = new char[] { '*', '?' };
+ } else {
+ WILDCARD_CHARS = new char[] { '*', '?', '[', ']'};
+ }
+ }
+
+ public GlobFilter(String globPattern) {
+ if (globPattern == null) {
+ throw new IllegalArgumentException("The glob pattern cannot be null.");
+ }
+
+ this.globPattern = globPattern;
+ this.regexPattern = convert(globPattern);
+ }
+
+
+ public String getGlobPattern() {
+ return globPattern;
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.FileFilter#accept(java.io.File)
+ */
+ public boolean accept(File pathname) {
+ return regexPattern.matcher(pathname.getAbsolutePath()).matches();
+ }
+
+ private static Pattern convert(String globPattern) {
+ StringBuilder regexPattern = new StringBuilder("^");
+ int i = 0;
+ while (i < globPattern.length()) {
+ switch (globPattern.charAt(i)) {
+ case '\\' :
+ if (File.separatorChar == '\\') {
+ //we're on windows, \ is a separator
+ regexPattern.append("\\\\");
+ } else {
+ //anywhere else, \ is a escape sequence
+ if (i == globPattern.length() - 1) {
+ throw new IllegalArgumentException("Illegal glob pattern: " + globPattern);
+ }
+ regexPattern.append("\\").append(globPattern.charAt(i + 1));
+ i += 1; //just skip the next character
+ }
+ break;
+ case '*':
+ regexPattern.append(".*");
+ break;
+ case '?':
+ regexPattern.append(".?");
+ break;
+ case '.':
+ regexPattern.append("\\.");
+ break;
+ case '/':
+ regexPattern.append("\\/");
+ break;
+ }
+ i++;
+ }
+
+ regexPattern.append("$");
+
+ return Pattern.compile(regexPattern.toString());
+ }
+}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
index 38cf18e..b58b8f2 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
@@ -51,7 +51,7 @@ public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet
public Configuration loadResourceConfiguration() throws Exception {
Configuration resourceConfig = new Configuration();
- File hostsFile = this.hostsComponent.getConfigurationFile();
+ File hostsFile = this.hostsComponent.getConfigurationFiles().get(0);
Hosts hosts = Hosts.load(hostsFile);
resourceConfig.setNotes("Loaded at " + new Date());
@@ -135,7 +135,7 @@ public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet
return;
}
- File hostsFile = this.hostsComponent.getConfigurationFile();
+ File hostsFile = this.hostsComponent.getConfigurationFiles().get(0);
try {
Hosts.store(newHosts, hostsFile);
}
14 years, 7 months
[rhq] Branch 'content' - modules/core modules/enterprise
by jdob
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 6 --
modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationship.java | 7 ++
modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoRelationship.java | 7 ++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java | 5 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 24 +++++-----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/content/ContentProviderManager.java | 10 +++-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/content/ContentProviderManagerTest.java | 24 +++++++++-
7 files changed, 63 insertions(+), 20 deletions(-)
New commits:
commit 9ec84ca856da420847bee0fc1f9674223a767f99
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Oct 23 11:33:08 2009 -0400
310 - Added ability to establish parent/child repo relationships during sync.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index e47b267..6f50eb8 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -94,14 +94,8 @@
<table name="RHQ_REPO_RELATION">
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
-
<column name="RELATED_REPO_ID" type="INTEGER" references="RHQ_REPO" required="true"/>
-
<column name="REPO_RELATION_TYPE_ID" type="INTEGER" references="RHQ_REPO_RELATION_TYPE" required="true"/>
-
- <index name="RHQ_REPO_RELATION_IDX" unique="true">
- <field ref="REPO_RELATION_TYPE_ID"/>
- </index>
</table>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationship.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationship.java
index 624dbd7..d278390 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationship.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationship.java
@@ -37,6 +37,8 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
/**
* A RepoRelationship represents relationship with a {@link Repo}
@@ -47,6 +49,9 @@ import javax.persistence.Table;
*/
@Entity
+@NamedQueries({
+ @NamedQuery(name = RepoRelationship.DELETE_BY_RELATED_REPO_ID, query = "DELETE RepoRelationship rr WHERE rr.relatedRepo.id = :relatedRepoId")
+})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_REPO_RELATION_ID_SEQ")
@Table(name = "RHQ_REPO_RELATION")
public class RepoRelationship implements Serializable {
@@ -54,6 +59,8 @@ public class RepoRelationship implements Serializable {
private static final long serialVersionUID = 1L;
+ public static final String DELETE_BY_RELATED_REPO_ID = "RepoRelationship.deleteByRelatedRepoId";
+
// Attributes --------------------------------------------
@Column(name = "ID", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoRelationship.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoRelationship.java
index 39e2c51..c93f374 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoRelationship.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRepoRelationship.java
@@ -33,6 +33,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
/**
* This is the many-to-many entity that correlates a repo with a repo relationship.
@@ -43,12 +45,17 @@ import javax.persistence.Table;
*/
@Entity
+@NamedQueries({
+ @NamedQuery(name = RepoRepoRelationship.DELETE_BY_REPO_ID, query = "DELETE RepoRepoRelationship rrr WHERE rrr.repo.id = :repoId")
+})
@IdClass(RepoRepoRelationshipPK.class)
@Table(name = "RHQ_REPO_REPO_RELATION_MAP")
public class RepoRepoRelationship implements Serializable {
private static final long serialVersionUID = 1L;
+ public static final String DELETE_BY_REPO_ID = "RepoRepoRelationship.deleteByRepoId";
+
/*
* http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings in the
* @IdClass and ignore these here, even though the mappings should be here and no mappings should be needed in the
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
index 98a231a..a1c807e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
@@ -48,6 +48,7 @@ public class RepoCriteria extends Criteria {
private boolean fetchRepoContentSources;
private boolean fetchRepoPackageVersions;
private boolean fetchRepoRepoGroups;
+ private boolean fetchRepoRepoRelationships;
private PageOrdering sortName;
@@ -89,6 +90,10 @@ public class RepoCriteria extends Criteria {
this.fetchRepoRepoGroups = fetchRepoRepoGroups;
}
+ public void fetchRepoRepoRelationships(boolean fetchRepoRepoRelationships) {
+ this.fetchRepoRepoRelationships = fetchRepoRepoRelationships;
+ }
+
public void addSortName(PageOrdering sortName) {
addSortField("name");
this.sortName = sortName;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
index 4d71897..b85d59e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
@@ -47,6 +47,7 @@ import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
import org.rhq.core.domain.content.RepoRelationshipType;
import org.rhq.core.domain.content.RepoRelationship;
+import org.rhq.core.domain.content.RepoRepoRelationship;
import org.rhq.core.domain.content.composite.RepoComposite;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
@@ -566,25 +567,28 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
- @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
public void addRepoRelationship(Subject subject, int repoId, int relatedRepoId, String relationshipTypeName) {
- Repo repo = getRepo(subject, repoId);
- Repo relatedRepo = getRepo(subject, relatedRepoId);
+ Repo repo = entityManager.find(Repo.class, repoId);
+ Repo relatedRepo = entityManager.find(Repo.class, relatedRepoId);
Query typeQuery = entityManager.createNamedQuery(RepoRelationshipType.QUERY_FIND_BY_NAME);
typeQuery.setParameter("name", relationshipTypeName);
-
RepoRelationshipType relationshipType = (RepoRelationshipType) typeQuery.getSingleResult();
- RepoRelationship relationship = new RepoRelationship();
- relationship.setRelatedRepo(relatedRepo);
- relationship.setRepoRelationshipType(relationshipType);
- relationship.addRepo(repo);
+ RepoRelationship repoRelationship = new RepoRelationship();
+ repoRelationship.setRelatedRepo(relatedRepo);
+ repoRelationship.setRepoRelationshipType(relationshipType);
+ repoRelationship.addRepo(repo);
+
+ entityManager.persist(repoRelationship);
+ relatedRepo.addRepoRelationship(repoRelationship);
- entityManager.persist(relationship);
+ RepoRepoRelationship repoRepoRelationship = new RepoRepoRelationship(repo, repoRelationship);
- repo.addRepoRelationship(relationship);
+ entityManager.persist(repoRepoRelationship);
+ repo.addRepoRelationship(repoRelationship);
}
private void validateRepo(Repo c) throws RepoException {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/content/ContentProviderManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/content/ContentProviderManager.java
index 67845e7..0caa3f3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/content/ContentProviderManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/content/ContentProviderManager.java
@@ -59,6 +59,8 @@ import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerLocal;
@@ -74,6 +76,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class ContentProviderManager {
private static final Log log = LogFactory.getLog(ContentProviderManager.class);
+ private static final String PARENT_RELATIONSHIP_NAME = "parent";
+
private ContentProviderPluginContainerConfiguration configuration;
private ContentProviderPluginManager pluginManager;
private Map<ContentSource, ContentProvider> adapters;
@@ -372,6 +376,8 @@ public class ContentProviderManager {
repo.addRepoGroup(group);
}
+ repo = repoManager.createRepo(overlord, repo);
+
String parentName = createMe.getParentRepoName();
if (parentName != null) {
List<Repo> parentList = repoManager.getRepoByName(parentName);
@@ -383,11 +389,11 @@ public class ContentProviderManager {
throw new RepoException(error);
}
else {
- // TODO: Establish relationship and associate with repo
+ Repo parent = parentList.get(0);
+ repoManager.addRepoRelationship(overlord, repo.getId(), parent.getId(), PARENT_RELATIONSHIP_NAME);
}
}
- repo = repoManager.createRepo(overlord, repo);
}
else {
repo = existingRepo.get(0);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/content/ContentProviderManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/content/ContentProviderManagerTest.java
index 99feb5f..da041b1 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/content/ContentProviderManagerTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/content/ContentProviderManagerTest.java
@@ -41,6 +41,8 @@ import org.rhq.core.domain.content.PackageVersionContentSource;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoRepoGroup;
+import org.rhq.core.domain.content.RepoRepoRelationship;
+import org.rhq.core.domain.content.RepoRelationship;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
@@ -87,6 +89,8 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
private List<Integer> reposToDelete = new ArrayList<Integer>();
private List<Integer> repoGroupsToDelete = new ArrayList<Integer>();
private List<Integer> packagesToDelete = new ArrayList<Integer>();
+ private Integer repoId;
+ private Integer relatedRepoId;
@BeforeMethod
public void setupBeforeMethod() throws Exception {
@@ -137,6 +141,13 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
Subject overlord = subjectManager.getOverlord();
+ // Delete the repo relationships
+ entityManager.createNamedQuery(RepoRepoRelationship.DELETE_BY_REPO_ID).setParameter(
+ "repoId", repoId).executeUpdate();
+
+ entityManager.createNamedQuery(RepoRelationship.DELETE_BY_RELATED_REPO_ID).setParameter(
+ "relatedRepoId", relatedRepoId).executeUpdate();
+
// Delete any repos that were created in this test
for (Integer repoId : reposToDelete) {
repoManager.deleteRepo(overlord, repoId);
@@ -233,12 +244,22 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
retrievedRepos = repoManager.getRepoByName("testRepo3");
assert retrievedRepos.size() == 1;
reposToDelete.add(retrievedRepos.get(0).getId());
+ relatedRepoId = retrievedRepos.get(0).getId();
retrievedRepos = repoManager.getRepoByName("testRepo4");
assert retrievedRepos.size() == 1;
reposToDelete.add(retrievedRepos.get(0).getId());
+ repoId = retrievedRepos.get(0).getId();
+
+ RepoCriteria findWithRelationships = new RepoCriteria();
+ findWithRelationships.addFilterName("testRepo4");
+ findWithRelationships.fetchRepoRepoRelationships(true);
+ PageList<Repo> childRepoList = repoManager.findReposByCriteria(overlord, findWithRelationships);
+ assert childRepoList.size() == 1;
- // TODO: Test parent relationship
+ Repo childRepo = childRepoList.get(0);
+ Set<RepoRepoRelationship> childRepoRepoRelationship = childRepo.getRepoRepoRelationships();
+ assert childRepoRepoRelationship.size() == 1;
// -> Non-existent repo
retrievedRepos = repoManager.getRepoByName("testRepoFoo");
@@ -291,7 +312,6 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
// Repo with a parent repo created in this sync
// Parent explicitly added to this list *after* this child to ensure that's not a problem
RepoDetails repo3 = new RepoDetails("testRepo3");
- repo3.setParentRepoName("testRepo1");
report.addRepo(repo3);
RepoDetails repo4 = new RepoDetails("testRepo4");
14 years, 7 months
[rhq] Branch 'content' - etc/m2 pom.xml
by Mike McCune
etc/m2/settings-content.xml | 48 ++++++++++++++++++++++++++++++++++++++++++++
pom.xml | 8 -------
2 files changed, 48 insertions(+), 8 deletions(-)
New commits:
commit a378a5e41ad5a04e4572b04f3fc59cb8759b45b6
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Thu Oct 22 16:23:30 2009 -0700
400 - switching to settings file
diff --git a/etc/m2/settings-content.xml b/etc/m2/settings-content.xml
new file mode 100644
index 0000000..04c4845
--- /dev/null
+++ b/etc/m2/settings-content.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+ <!--===== a sample Maven 2 user settings file for the RHQ build =====-->
+
+ <!-- See: http://maven.apache.org/settings.html -->
+
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
+ http://maven.apache.org/xsd/settings-1.0.0.xsd">
+
+ <!--
+ The below line can be uncommented if you want your local repo to be
+ in a more convenient location under Windows.
+ -->
+ <!--<localRepository>C:\.m2-repo</localRepository>-->
+
+ <!--
+ **************************** PROFILES ****************************
+ -->
+
+ <!--
+ See:
+ http://maven.apache.org/guides/introduction/introduction-to-profiles.html
+ and: http://docs.codehaus.org/display/MAVENUSER/Profiles
+ -->
+
+ <activeProfiles>
+ <activeProfile>test.content</activeProfile>
+ </activeProfiles>
+
+ <profiles>
+ <profile>
+ <!-- Profile to use to point test runs at a different db -->
+ <id>test.content</id>
+ <properties>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
+ <DatabaseTest.nofail>true</DatabaseTest.nofail>
+ </properties>
+ </profile>
+ </profiles>
+ <pluginGroups>
+ <!--
+ This will allow you to invoke "org.rhq" Maven goals using the
+ "rhq" prefix
+ -->
+ <pluginGroup>org.rhq</pluginGroup>
+ </pluginGroups>
+</settings>
diff --git a/pom.xml b/pom.xml
index 1ed8998..4662410 100644
--- a/pom.xml
+++ b/pom.xml
@@ -695,14 +695,6 @@
<profiles>
<profile>
- <!-- Profile to use to point test runs at a different db -->
- <id>test.content</id>
- <properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
- <DatabaseTest.nofail>true</DatabaseTest.nofail>
- </properties>
- </profile>
- <profile>
<id>ojdbc-driver</id>
<dependencies>
14 years, 7 months
[rhq] Branch 'content' - modules/enterprise
by Pradeep Kilambi
modules/enterprise/server/plugins/rhnhosted/src/main/resources/META-INF/rhq-serverplugin-content.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit b8c522f622b379fbd6e6c1b45163a5d7f97bbb36
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Thu Oct 22 19:08:51 2009 -0400
bug fix on typos
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/resources/META-INF/rhq-serverplugin-content.xml b/modules/enterprise/server/plugins/rhnhosted/src/main/resources/META-INF/rhq-serverplugin-content.xml
index 5979181..bb3c87a 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/resources/META-INF/rhq-serverplugin-content.xml
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/resources/META-INF/rhq-serverplugin-content.xml
@@ -23,7 +23,7 @@
name="certificate"
type="longString"
required="true"
- description="certificate for cerdentials."/>
+ description="RHQ subscription Certificate for activation ."/>
<!--<c:group name="repos" displayName="repo list">
<c:simple-property name="repos" type="string" default="rhn-tools-rhel-i386-server-5"/>
14 years, 7 months
[rhq] Branch 'content' - pom.xml
by Mike McCune
pom.xml | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
New commits:
commit d80ff52043a4a5afdeccfd10ac2ff421f552ce28
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Thu Oct 22 14:43:08 2009 -0700
400 - adding profile to allow pointing test runs at alt db
diff --git a/pom.xml b/pom.xml
index 3067644..1ed8998 100644
--- a/pom.xml
+++ b/pom.xml
@@ -694,7 +694,14 @@
</modules>
<profiles>
-
+ <profile>
+ <!-- Profile to use to point test runs at a different db -->
+ <id>test.content</id>
+ <properties>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
+ <DatabaseTest.nofail>true</DatabaseTest.nofail>
+ </properties>
+ </profile>
<profile>
<id>ojdbc-driver</id>
14 years, 7 months
[rhq] Branch 'raw-config' - modules/enterprise
by Adam Young
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigCollection.java | 101 +++++++---
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml | 6
modules/enterprise/gui/portal-war/src/main/webapp/images/download.png |binary
modules/enterprise/gui/portal-war/src/main/webapp/images/upload.png |binary
modules/enterprise/gui/portal-war/src/main/webapp/images/viewfullscreen.png |binary
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml | 8
6 files changed, 83 insertions(+), 32 deletions(-)
New commits:
commit 2d21c50e3564d5c55ad32f252c20e9adcd4b8c11
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Oct 22 17:08:31 2009 -0400
Second interim checking for raw config editing
Made RawConfigCollection conversation scoped, driven off of annotations.
Added an 'init' method to start the conversation, because seam doesn't allow
starting a conversation based on a constructor.
There is still a bug with one file showing up as modified after a commit
The commit code does not yet send code to the back end.
In order to show behavior, the mock code is enabled. This will be removed before going live, probably when the back save gets enabled.
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 dcbffb0..63a9ec5 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
@@ -1,41 +1,69 @@
package org.rhq.enterprise.gui.configuration.resource;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.TreeMap;
-import javax.faces.component.UIComponent;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.End;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.faces.Redirect;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.RawConfiguration;
+import org.rhq.enterprise.gui.legacy.ParamConstants;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
-//@Name("RawConfigCollection")
-//(a)Scope(ScopeType.CONVERSATION)
-public class RawConfigCollection {
+@Name("RawConfigCollection")
+(a)Scope(ScopeType.CONVERSATION)
+public class RawConfigCollection implements Serializable {
- UIComponent binding;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4837157548556168146L;
private String selectedPath;
private TreeMap<String, RawConfiguration> raws;
private TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>();
- protected ConfigurationManagerLocal configurationManager = LookupUtil.getConfigurationManager();
- RawConfiguration current;
- private Configuration configuration;
+ private RawConfiguration current = null;
+ @In(value = "org.jboss.seam.faces.redirect")
+ private Redirect redirect;
- //This is for development, to prevent actually going to the EJBs.
- //It should be set to false prior to check in
- private static final boolean useMock = false;
+ public Redirect getRedirect() {
+ return redirect;
+ }
- public UIComponent getBinding() {
- return binding;
+ public void setRedirect(Redirect redirect) {
+ this.redirect = redirect;
}
- public void setBinding(UIComponent binding) {
- this.binding = binding;
+ @Create
+ @Begin
+ public void init() {
+
+ }
+
+ /**
+ * These values are transient due to the need to save and restore the view.
+ * We can always fetch them again.
+ */
+ transient private ConfigurationManagerLocal configurationManager;
+ transient private Configuration configuration = null;
+
+ //This is for development, to prevent actually going to the EJBs.
+ //It should be set to false prior to check in
+ private static final boolean useMock = true;
+
+ public RawConfigCollection() {
}
public void select(String s) {
@@ -43,16 +71,35 @@ public class RawConfigCollection {
setCurrentPath(selectedPath);
}
- public int getConfigId() {
-
+ public Configuration getConfiguration() {
if (null == configuration) {
Subject subject = EnterpriseFacesContextUtility.getSubject();
int resourceId = EnterpriseFacesContextUtility.getResource().getId();
- AbstractResourceConfigurationUpdate configurationUpdate = this.configurationManager
+ AbstractResourceConfigurationUpdate configurationUpdate = this.getConfigurationManager()
.getLatestResourceConfigurationUpdate(subject, resourceId);
configuration = (configurationUpdate != null) ? configurationUpdate.getConfiguration() : null;
}
- return configuration.getId();
+
+ return configuration;
+ }
+
+ public int getConfigId() {
+
+ return getConfiguration().getId();
+ }
+
+ @End
+ public void commit() {
+ // configurationManager.findRawConfigurationsByConfigurationId(getConfigId());
+
+ for (RawConfiguration raw : modified.values()) {
+ getRaws().put(raw.getPath(), raw);
+ }
+ getConfigurationManager();
+ // getConfigurationManager().setRawConfigurations(configId, raws.values());
+
+ this.redirect.setParameter(ParamConstants.CONFIG_ID_PARAM, getConfigId());
+ this.redirect.setViewId("http://localhost:7080/rhq/resource/configuration/history.xhtml");
}
public TreeMap<String, RawConfiguration> getRaws() {
@@ -69,7 +116,8 @@ public class RawConfigCollection {
}
private void populateRawsMock() {
- String[] files = { "/etc/mock/file1", "/etc/mock/file2", "/etc/mock/file2" };
+ String[] files = { "/etc/mock/file1", "/etc/mock/file2", "/etc/mock/file3", "/etc/mock/me/will/you",
+ "/etc/mock/turtle/soup", "/etc/mock/mysmock/iclean/yourclock" };
for (String file : files) {
RawConfiguration raw = new RawConfiguration();
@@ -81,16 +129,13 @@ public class RawConfigCollection {
}
private void populateRaws() {
- Collection<RawConfiguration> rawConfigurations = configurationManager
+ Collection<RawConfiguration> rawConfigurations = getConfigurationManager()
.findRawConfigurationsByConfigurationId(getConfigId());
for (RawConfiguration raw : rawConfigurations) {
raws.put(raw.getPath(), raw);
}
}
- public RawConfigCollection() {
- }
-
public RawConfiguration getCurrent() {
if (null == current) {
Iterator<RawConfiguration> iterator = getRaws().values().iterator();
@@ -146,4 +191,12 @@ public class RawConfigCollection {
public boolean isModified(String path) {
return modified.keySet().contains(path);
}
+
+ private ConfigurationManagerLocal getConfigurationManager() {
+ if (null == configurationManager) {
+ configurationManager = LookupUtil.getConfigurationManager();
+ }
+
+ return configurationManager;
+ }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
index 9aa968e..1383c31 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
@@ -58,12 +58,6 @@
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
- <managed-bean>
- <managed-bean-name>RawConfigCollection</managed-bean-name>
- <managed-bean-class>org.rhq.enterprise.gui.configuration.resource.RawConfigCollection</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- </managed-bean>
-
</faces-config>
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/download.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/download.png
new file mode 100644
index 0000000..84e60d2
Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/download.png differ
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/upload.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/upload.png
new file mode 100644
index 0000000..ea6c3bb
Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/upload.png differ
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/viewfullscreen.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/viewfullscreen.png
new file mode 100644
index 0000000..0a11ba9
Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/viewfullscreen.png differ
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml
index d0bcbf8..7aa0260 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit-raw.xhtml
@@ -38,7 +38,7 @@ THIS TEXT WILL BE REMOVED.
<td bgcolor="lightblue" width="25%" valign="top">
Files
- <h:panelGroup layout="vertical">
+ <h:panelGroup id="changedFiles" layout="vertical">
<ui:repeat value="#{RawConfigCollection.paths}" var="path">
<div>
<h:outputText value="*" rendered="#{RawConfigCollection.isModified(path) }"/>
@@ -51,13 +51,17 @@ THIS TEXT WILL BE REMOVED.
</h:panelGroup>
<div>______________________________________</div>
+ <div> * File contains uncommited changes. </div>
+
+ <a4j:commandButton action="#{RawConfigCollection.commit}" value="commit changes" reRender="changedFiles"/>
+
</td>
<td>
<h:panelGroup id="title">
<h:outputText value="#{RawConfigCollection.current.path}" styleClass="outhello" />
</h:panelGroup>
- [Icon]View Full Screen [^] Upload Now [v] Download
+ <a href="#"><img src="/images/viewfullscreen.png" />View Full Screen</a> <a href="#"><img src="/images/download.png" /> Download</a>
<rich:editor
id="editor" width="600" height="400"
14 years, 7 months
[rhq] Branch 'content' - modules/core modules/enterprise
by jdob
modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationshipType.java | 8 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 26 +++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java | 12 ++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java | 45 ++++++++++
4 files changed, 91 insertions(+)
New commits:
commit 3f873828c5e7181e6efd5611d887f50fe99933e6
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Oct 22 16:28:33 2009 -0400
310 - Added EJB methods for creating repo relationships.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationshipType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationshipType.java
index 46bbacf..3a40635 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationshipType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoRelationshipType.java
@@ -35,6 +35,8 @@ import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
/**
* Defines a type of (@link RepoRelationship) e.g. Clone, Parent-child are types of
@@ -43,12 +45,18 @@ import javax.persistence.Table;
*/
@Entity
+@NamedQueries( {
+ @NamedQuery(name = RepoRelationshipType.QUERY_FIND_BY_NAME, query = "SELECT r FROM RepoRelationshipType r WHERE r.name = :name")
+})
+
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_REPO_RELATION_TYPE_ID_SEQ")
@Table(name = "RHQ_REPO_RELATION_TYPE")
public class RepoRelationshipType implements Serializable {
private static final long serialVersionUID = 1L;
+ public static final String QUERY_FIND_BY_NAME = "RepoRelationshipType.findByName";
+
// Attributes --------------------------------------------
@Column(name = "ID", nullable = false)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
index 1c8b466..4d71897 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
@@ -25,6 +25,8 @@ import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@@ -43,6 +45,8 @@ import org.rhq.core.domain.content.PackageVersionContentSource;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.RepoRelationshipType;
+import org.rhq.core.domain.content.RepoRelationship;
import org.rhq.core.domain.content.composite.RepoComposite;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
@@ -561,6 +565,28 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return new PageList<PackageVersion>(packageVersions, (int) count, criteria.getPageControl());
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void addRepoRelationship(Subject subject, int repoId, int relatedRepoId, String relationshipTypeName) {
+
+ Repo repo = getRepo(subject, repoId);
+ Repo relatedRepo = getRepo(subject, relatedRepoId);
+
+ Query typeQuery = entityManager.createNamedQuery(RepoRelationshipType.QUERY_FIND_BY_NAME);
+ typeQuery.setParameter("name", relationshipTypeName);
+
+ RepoRelationshipType relationshipType = (RepoRelationshipType) typeQuery.getSingleResult();
+
+ RepoRelationship relationship = new RepoRelationship();
+ relationship.setRelatedRepo(relatedRepo);
+ relationship.setRepoRelationshipType(relationshipType);
+ relationship.addRepo(repo);
+
+ entityManager.persist(relationship);
+
+ repo.addRepoRelationship(relationship);
+ }
+
private void validateRepo(Repo c) throws RepoException {
if (c.getName() == null || c.getName().trim().equals("")) {
throw new RepoException("Repo name is required");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
index 4697830..8044b8e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
@@ -116,6 +116,18 @@ public interface RepoManagerLocal {
*/
long getPackageVersionCountFromRepo(Subject subject, int repoId);
+ /**
+ * Creates a relationship between two repos. The relationship will be marked as being the specified
+ * type. For relationships where the order matters, think of the <code>repoId</code> as being the source
+ * of the relationship and <code>relatedRepoId</code> as being the destination or target of it.
+ *
+ * @param subject user making the relationship
+ * @param repoId must reference a valid repo in the system the user has permissions to access
+ * @param relatedRepoId must reference a valid repo in the system the user has permissions to access
+ * @param relationshipTypeName must identify an existing relationship in the database
+ */
+ void addRepoRelationship(Subject subject, int repoId, int relatedRepoId, String relationshipTypeName);
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// The following are shared with the Remote Interface
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
index d2671f0..a0c9376 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
@@ -29,11 +29,17 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.RepoRelationshipType;
+import org.rhq.core.domain.content.RepoRepoRelationship;
+import org.rhq.core.domain.criteria.RepoCriteria;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
+import java.util.Set;
+
public class RepoManagerBeanTest extends AbstractEJB3Test {
private final static boolean ENABLED = true;
@@ -171,4 +177,43 @@ public class RepoManagerBeanTest extends AbstractEJB3Test {
entityManager.remove(type);
entityManager.flush();
}
+
+ @Test(enabled = ENABLED)
+ public void addRepoRelationship() throws Exception {
+ // Setup
+ EntityManager entityManager = getEntityManager();
+
+ Repo repo = new Repo("repo1");
+ Repo relatedRepo = new Repo("repo2");
+
+ repo = repoManager.createRepo(overlord, repo);
+ relatedRepo = repoManager.createRepo(overlord, relatedRepo);
+
+ String relationshipTypeName = "testRelationshipType";
+ RepoRelationshipType relationshipType = new RepoRelationshipType(relationshipTypeName);
+ entityManager.persist(relationshipType);
+ entityManager.flush();
+
+ // Test
+ repoManager.addRepoRelationship(overlord, repo.getId(), relatedRepo.getId(), relationshipTypeName);
+
+ // Verify
+ RepoCriteria repoCriteria = new RepoCriteria();
+ repoCriteria.fetchRepoRepoGroups(true);
+ repoCriteria.addFilterId(repo.getId());
+
+ PageList<Repo> repoPageList = repoManager.findReposByCriteria(overlord, repoCriteria);
+ assert repoPageList.size() == 1;
+
+ Repo persistedRepo = repoPageList.get(0);
+ Set<RepoRepoRelationship> relationships = persistedRepo.getRepoRepoRelationships();
+ assert relationships.size() == 1;
+
+ RepoRepoRelationship relationship = relationships.iterator().next();
+ assert relationship.getRepoRepoRelationshipPK().getRepo().getName().equals("repo1");
+ assert relationship.getRepoRepoRelationshipPK().getRepoRelationship().getRelatedRepo().getName().equals("repo2");
+ assert relationship.getRepoRepoRelationshipPK().getRepoRelationship().getRepoRelationshipType().getName().equals(relationshipTypeName);
+
+ // Cleanup handled by rollback in tear down method
+ }
}
\ No newline at end of file
14 years, 7 months
[rhq] Branch 'content' - modules/enterprise
by John Matthews
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnDownloader.java | 13 +-
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnHttpURLConnectionFactory.java | 31 ++++++
modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnHttpURLConnection.java | 51 ++++++++++
modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java | 24 +++-
modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnCommTest.java | 10 +
5 files changed, 117 insertions(+), 12 deletions(-)
New commits:
commit a18adad5942a29ae2ee631a640890b0c5c67ce30
Author: John Matthews <jmatthew(a)redhat.com>
Date: Thu Oct 22 15:59:21 2009 -0400
400 - add to mock interface for getRPM and getKickstart tests
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnDownloader.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnDownloader.java
index 6f59b28..34afa1e 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnDownloader.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnDownloader.java
@@ -25,6 +25,10 @@ public class RhnDownloader {
return this.serverUrl;
}
+ protected HttpURLConnection getNewConnection(String urlIn) throws IOException {
+ return (HttpURLConnection) RhnHttpURLConnectionFactory.openConnection(new URL(urlIn));
+ }
+
/**
* Expected return header values for: X-Client-Version, X-RHN-Server-Id, X-RHN-Auth
* X-RHN-Auth-User-Id, X-RHN-Auth-Expire-Offset, X-RHN-Auth-Server-Time
@@ -49,8 +53,7 @@ public class RhnDownloader {
XmlRpcException {
String extra = "/SAT/$RHN/" + channelName + "/getPackage/" + rpmName;
- URL url = new URL(serverUrl + extra);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ HttpURLConnection conn = getNewConnection(serverUrl + extra);
Map props = login(systemId);
for (Object key : props.keySet()) {
conn.setRequestProperty((String) key, props.get(key).toString());
@@ -76,8 +79,7 @@ public class RhnDownloader {
public InputStream getRPMStream(String systemId, String locationUrl) throws IOException, XmlRpcException {
- URL url = new URL(locationUrl);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ HttpURLConnection conn = getNewConnection(locationUrl);
Map props = login(systemId);
for (Object key : props.keySet()) {
conn.setRequestProperty((String) key, props.get(key).toString());
@@ -93,8 +95,7 @@ public class RhnDownloader {
throws IOException, XmlRpcException {
String extra = "/SAT/$RHN/" + channelName + "/getKickstartFile/" + ksTreeLabel + "/" + ksFilePath;
- URL url = new URL(serverUrl + extra);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ HttpURLConnection conn = getNewConnection(serverUrl + extra);
Map props = login(systemId);
for (Object key : props.keySet()) {
conn.setRequestProperty((String) key, props.get(key).toString());
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnHttpURLConnectionFactory.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnHttpURLConnectionFactory.java
new file mode 100644
index 0000000..b13fece
--- /dev/null
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnHttpURLConnectionFactory.java
@@ -0,0 +1,31 @@
+package org.rhq.enterprise.server.plugins.rhnhosted.xmlrpc;
+
+import org.rhq.enterprise.server.util.MethodUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+import java.net.URL;
+import java.net.HttpURLConnection;
+import java.io.IOException;
+
+
+public class RhnHttpURLConnectionFactory {
+
+ final public static String RHN_MOCK_HTTP_URL_CONNECTION = "RhnMockHttpUrlConnection";
+ final private static Log log = LogFactory.getLog(RhnHttpURLConnectionFactory.class);
+
+ public static HttpURLConnection openConnection(URL urlIn) throws IOException {
+
+ String propMockHttpURLConn = System.getProperty(RHN_MOCK_HTTP_URL_CONNECTION);
+ if (StringUtils.isBlank(propMockHttpURLConn)) {
+ return (HttpURLConnection) urlIn.openConnection();
+ }
+ log.info("Using a Mock HttpURLConnection object, Property for RHN_MOCK_HTTP_URL_CONNECTION is " +
+ propMockHttpURLConn);
+ Object[] args = { urlIn };
+ HttpURLConnection retval =
+ (HttpURLConnection) MethodUtil.getClassFromSystemProperty(RHN_MOCK_HTTP_URL_CONNECTION, args);
+ return retval;
+ }
+}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnHttpURLConnection.java b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnHttpURLConnection.java
new file mode 100644
index 0000000..a355d3a
--- /dev/null
+++ b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnHttpURLConnection.java
@@ -0,0 +1,51 @@
+package org.rhq.enterprise.server.plugins.rhnhosted.xmlrpc;
+
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+
+public class MockRhnHttpURLConnection extends HttpURLConnection {
+
+ protected Map props;
+ protected URL url;
+
+ public MockRhnHttpURLConnection(URL u) {
+ super(u);
+ props = new HashMap();
+ }
+
+ @Override
+ public void setRequestProperty(String key, String value) {
+ props.put(key, value);
+ }
+
+
+ @Override
+ public String getRequestProperty(String key) {
+ return (String)props.get(key);
+ }
+
+ public void disconnect() {
+
+ }
+
+ public boolean usingProxy() {
+ return false;
+ }
+
+
+ public void connect() throws IOException {
+
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return new ByteArrayInputStream("Test Data".getBytes());
+ }
+}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java
index 1b7c712..80bc290 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java
@@ -34,12 +34,15 @@ import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnChannelFamiliesType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnChannelFamilyType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnChannelType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnChannelsType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnKickstartableTreeType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnKickstartableTreesType;
+import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnKickstartFileType;
+import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnKickstartFilesType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnPackageShortType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnPackageType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnPackagesShortType;
@@ -125,8 +128,9 @@ public class MockRhnXmlRpcExecutor implements XmlRpcExecutor {
} else if (methodName.equals("dump.kickstartable_trees")) {
JAXBElement element = getRhnSatelliteType();
RhnSatelliteType retval = (RhnSatelliteType) element.getValue();
+ RhnKickstartableTreesType parentKSTree = new RhnKickstartableTreesType();
+ List<RhnKickstartableTreeType> ksTreeList = parentKSTree.getRhnKickstartableTree();
List<String> kstids = (List<String>) params[1];
- List<RhnKickstartableTreeType> rhnKickstartableTree = new LinkedList<RhnKickstartableTreeType>();
for (String kid : kstids) {
RhnKickstartableTreeType kstype = new RhnKickstartableTreeType();
kstype.setBasePath("basepath");
@@ -138,12 +142,20 @@ public class MockRhnXmlRpcExecutor implements XmlRpcExecutor {
kstype.setKstreeTypeName("type");
kstype.setLabel("label");
kstype.setLastModified("lastmod");
- rhnKickstartableTree.add(kstype);
-
- RhnKickstartableTreesType pshortypes = new RhnKickstartableTreesType();
- setPrivateList("rhnKickstartableTree", pshortypes, rhnKickstartableTree);
- retval.setRhnKickstartableTrees(pshortypes);
+ // Need to add ks file
+ RhnKickstartFilesType parentFiles = new RhnKickstartFilesType();
+ List<RhnKickstartFileType> files = parentFiles.getRhnKickstartFile();
+ RhnKickstartFileType f = new RhnKickstartFileType();
+ f.setFileSize("192");
+ f.setLastModified("tbd");
+ f.setMd5Sum("tbd");
+ f.setRelativePath("path");
+ files.add(f);
+ kstype.setRhnKickstartFiles(parentFiles);
+
+ ksTreeList.add(kstype);
}
+ retval.setRhnKickstartableTrees(parentKSTree);
return element;
} else if (methodName.equals("dump.packages")) {
if (systemid.contains("<value><string>ID-0000000000</string></value>")) {
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnCommTest.java b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnCommTest.java
index 390284e..cfa622c 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnCommTest.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/RhnCommTest.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.net.URL;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -53,6 +54,8 @@ public class RhnCommTest extends TestCase {
super(testName);
/* OVERRIDE THE XMLRPC CLIENT WITH A MOCK OBJECT */
System.setProperty(ApacheXmlRpcExecutor.class.getName(), MockRhnXmlRpcExecutor.class.getName());
+ System.setProperty(RhnHttpURLConnectionFactory.RHN_MOCK_HTTP_URL_CONNECTION,
+ MockRhnHttpURLConnection.class.getName());
/* Comment this out if you want to actually connect to RHN Hosted. */
}
@@ -315,6 +318,12 @@ public class RhnCommTest extends TestCase {
}
public void testGetRPM_withBadSystemId() throws Exception {
+ String prop = System.getProperty(RhnHttpURLConnectionFactory.RHN_MOCK_HTTP_URL_CONNECTION);
+ if (!StringUtils.isEmpty(prop)) {
+ System.err.println("Skipping testGetRPM_withBadSystemId() since we are mocking the HTTP connection.");
+ return;
+ }
+
boolean success = false;
try {
RhnDownloader comm = new RhnDownloader(serverUrl);
@@ -343,6 +352,7 @@ public class RhnCommTest extends TestCase {
List<RhnKickstartableTreeType> ksTrees = comm.getKickstartTreeMetadata(getSystemId(), reqLabels);
RhnKickstartableTreeType tree = ksTrees.get(0);
RhnKickstartFilesType ksFiles = tree.getRhnKickstartFiles();
+ System.err.println("ksFiles = " + ksFiles);
List<RhnKickstartFileType> files = ksFiles.getRhnKickstartFile();
RhnKickstartFileType f = files.get(0);
//Only fetching one kickstart file to save time.
14 years, 7 months