modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
| 38 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
| 140 +++++
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
| 1
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
| 1
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
| 1
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
| 18
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
| 8
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
| 35 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
| 11
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
| 3
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
| 9
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 62 ++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
| 17
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
| 71 ++
pom.xml
| 242 ++++------
16 files changed, 463 insertions(+), 200 deletions(-)
New commits:
commit e7a18e96f8d3082a19150238181edc184c01e27e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jun 30 09:15:02 2011 +0200
Use the name as value and not the id.
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index 8463123..e872a80 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -2438,7 +2438,7 @@ public class ConfigurationManagerBean implements
ConfigurationManagerLocal, Conf
if (tt== PropertyOptionsSource.TargetType.RESOURCE) {
- PropertyDefinitionEnumeration pde = new
PropertyDefinitionEnumeration(composite.getResource().getName(),""+composite.getResource().getId());
+ PropertyDefinitionEnumeration pde = new
PropertyDefinitionEnumeration(composite.getResource().getName(),""+composite.getResource().getName());
// TODO filter -- or leave up to search expression??
pds.getEnumeratedValues().add(pde);
}
commit 2a6258a05ea75e43108153c182d2e7ed90e0f65d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 29 22:36:14 2011 +0200
Fix detection of mod_cluster subsystem.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 41c5c58..870ad38 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -177,28 +177,6 @@
<c:simple-property name="path" default="profile"
readOnly="true"/>
</plugin-configuration>
- <service name="ModCluster"
- class="BaseComponent"
- discovery="SubsystemDiscovery"
- description="Mod_cluster support">
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true"
default="subsystem=modcluster"/>
- </plugin-configuration>
-
- <operation name="list-proxies" description="Read the
list of httpd contected to the nodes.">
- </operation>
-
- <operation name="validate-address" description="Read
the list of httpd contected to the nodes.">
- </operation>
-
- <resource-configuration>
- <c:simple-property name="advertise-socket"
displayName="Advertise Socket" type="string">
- <c:option-source target="configuration"
expression="socket-binding=name:type=SocketBindingGroup"/>
- </c:simple-property>
- </resource-configuration>
- </service>
-
</server>
<server name="ServerGroup"
@@ -1376,6 +1354,36 @@ working area for individual server
instances</li></ul>"/>
</service>
</server>
+ <server name="ModCluster"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ description="Mod_cluster support"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile"
plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/> <!-- FAKE as "runs inside Profile" only
does not work -->
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true"
default="subsystem=modcluster"/>
+ </plugin-configuration>
+
+ <operation name="list-proxies" description="Read the list of
httpd connected to the nodes.">
+ </operation>
+
+ <operation name="validate-address" >
+ </operation>
+
+ <resource-configuration>
+ <c:simple-property name="advertise-socket"
displayName="Advertise Socket" type="string">
+ <c:option-source target="configuration"
expression="socket-binding=name:type=SocketBindingGroup"/>
+ </c:simple-property>
+ </resource-configuration>
+ </server>
+
+
<service name="NetworkInterface"
discovery="SubsystemDiscovery"
class="BaseComponent"
commit feea96566b815c58623fe8141568ee2420bb80af
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 29 22:01:09 2011 +0200
Change upload code because of a bug in the server (AS7-1145), add a property to enable
json logging.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index f2bb47f..d89f4c4 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -43,21 +43,27 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
*/
public class ASConnection {
+ public static final String MANAGEMENT = "/management";
+// public static final String MANAGEMENT = "/domain-api"; // Old one - leave
it here for the moment for tests.
private final Log log = LogFactory.getLog(ASConnection.class);
URL url;
String urlString;
private ObjectMapper mapper;
- boolean verbose = true; // This is a variable on purpose, so devs can switch it on in
the debugger
+ public static boolean verbose = false; // This is a variable on purpose, so devs can
switch it on in the debugger or in the agent
public ASConnection(String host, int port) {
try {
- url = new URL("http",host,port,"/management");
+ url = new URL("http",host,port, MANAGEMENT);
urlString = url.toString();
+
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e.getMessage());
}
+ // read system property "as7plugin.verbose"
+ verbose = Boolean.getBoolean("as7plugin.verbose");
+
mapper = new ObjectMapper();
}
@@ -107,8 +113,7 @@ public class ASConnection {
String result = mapper.writeValueAsString(operation);
if (verbose) {
- System.out.println("Json to send: " + result);
- System.out.flush();
+ log.info("Json to send: " + result);
}
mapper.writeValue(out, operation);
@@ -141,8 +146,7 @@ public class ASConnection {
ObjectMapper om2 = new ObjectMapper();
om2.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
String tmp = om2.writeValueAsString(operationResult);
- System.out.println(tmp);
- System.out.flush();
+ log.info(tmp);
}
}
else {
@@ -156,8 +160,6 @@ public class ASConnection {
}
else {
log.error("IS was null and code was " + responseCode);
- if (verbose)
- System.err.println("IS was null and code was " +
responseCode);
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index d876c80..3ab7c3c 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -51,7 +51,7 @@ public class ASUploadConnection {
private static final String POST_REQUEST_METHOD = "POST";
- private static final String UPLOAD_URL_PATH = "/management/add-content";
+ private static final String UPLOAD_URL_PATH = ASConnection.MANAGEMENT +
"/add-content";
private final Log log = LogFactory.getLog(ASUploadConnection.class);
@@ -96,7 +96,7 @@ public class ASUploadConnection {
os.flush();
int code = connection.getResponseCode();
- System.err.println("Response code " + code);
+ log.info("Response code for file upload: " + code);
if (code==500)
is = connection.getErrorStream();
else
@@ -116,10 +116,10 @@ public class ASUploadConnection {
if (s!=null)
tree = mapper.readTree(s);
else
- System.out.println("- no result received from InputStream
-");
+ log.warn("- no result received from InputStream -");
}
else
- System.out.println("- no InputStream available -");
+ log.warn("- no InputStream available -");
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index a51a96a..2ac49d0 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -80,6 +80,7 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
String key;
String host;
int port;
+ private boolean verbose = ASConnection.verbose;
/**
* Return availability of this resource
@@ -305,7 +306,9 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName,
details.getKey(), out);
JsonNode uploadResult = uploadConnection.finishUpload();
- System.out.println(uploadResult);
+ if (verbose)
+ log.info(uploadResult);
+
if (ASConnection.isErrorReply(uploadResult)) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage(ASConnection.getFailureDescription(uploadResult));
@@ -319,7 +322,8 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
fileName=fileName.substring("C:\\fakepath\\".length());
}
- log.info("Deploying [" + fileName + "] ...");
+ boolean toServerGroup =
context.getResourceKey().contains("server-group=");
+ log.info("Deploying [" + fileName + "] to domain only= " +
!toServerGroup + " ...");
String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
@@ -338,15 +342,22 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
step1.addAdditionalProperty("name", tmpName);
step1.addAdditionalProperty("runtime-name", fileName);
- CompositeOperation cop = new CompositeOperation();
- cop.addStep(step1);
String resourceKey;
-
+ JsonNode result ;
/*
* We need to check here if this is an upload to /deployment only
* or if this should be deployed to a server group too
*/
- if (context.getResourceKey().contains("server-group=")) {
+
+ if (!toServerGroup) {
+
+ result = connection.executeRaw(step1);
+ resourceKey = addressToPath(step1.getAddress());
+
+ }
+ else {
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
List<PROPERTY_VALUE> serverGroupAddress = new
ArrayList<PROPERTY_VALUE>();
serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
@@ -359,19 +370,13 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
cop.addStep(step3);
resourceKey = addressToPath(serverGroupAddress);
- }
- else {
-/*
- List<PROPERTY_VALUE> address = step1.getAddress();
- Operation step3 = new Operation("deploy",address);
- cop.addStep(step3);
-*/
+ if (verbose)
+ log.info("Deploy operation: " + cop);
- resourceKey = addressToPath(step1.getAddress());
+ result = connection.executeRaw(cop);
}
- JsonNode result = connection.executeRaw(cop);
if (ASConnection.isErrorReply(result)) {
String failureDescription = ASConnection.getFailureDescription(result);
report.setErrorMessage(failureDescription);
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 3f57a06..3946dbe 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -98,6 +98,9 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
}
config.put(new
PropertySimple("socket-binding-port-offset",serverInfo.portOffset));
+ String path = "host=" + hostName + ",server-config="
+ serverInfo.name;
+ config.put(new PropertySimple("path",path));
+
// TODO this fails for the downed servers.
@@ -241,6 +244,14 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
boolean autoStart;
int portOffset;
String bindingGroup;
+
+ @Override
+ public String toString() {
+ return "ServerInfo{" +
+ "name='" + name + '\'' +
+ ", group='" + group + '\'' +
+ '}';
+ }
}
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index a3ab676..60fc615 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -101,7 +101,8 @@ public class SubsystemDiscovery implements
ResourceDiscoveryComponent<BaseCompon
if (cpath.contains("="))
path += "," + cpath;
- System.out.println("total path: [" + path + "]");
+ if (Boolean.getBoolean("as7plugin.verbose"))
+ log.info("total path: [" + path + "]");
JsonNode json ;
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 76d1bcf..41c5c58 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -169,14 +169,38 @@
<server name="Profile"
- description="One profile in a domain"
+ description="One profile in a domain. Profiles are assigned to
server groups."
discovery="SubsystemDiscovery"
class="BaseComponent">
<plugin-configuration>
<c:simple-property name="path" default="profile"
readOnly="true"/>
</plugin-configuration>
+
+ <service name="ModCluster"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ description="Mod_cluster support">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true"
default="subsystem=modcluster"/>
+ </plugin-configuration>
+
+ <operation name="list-proxies" description="Read the
list of httpd contected to the nodes.">
+ </operation>
+
+ <operation name="validate-address" description="Read
the list of httpd contected to the nodes.">
+ </operation>
+
+ <resource-configuration>
+ <c:simple-property name="advertise-socket"
displayName="Advertise Socket" type="string">
+ <c:option-source target="configuration"
expression="socket-binding=name:type=SocketBindingGroup"/>
+ </c:simple-property>
+ </resource-configuration>
+ </service>
+
</server>
+
<server name="ServerGroup"
description="Server groups on this domain"
discovery="SubsystemDiscovery"
@@ -190,8 +214,12 @@
<resource-configuration>
- <c:simple-property name="profile" />
- <c:simple-property name="socket-binding-group"/>
+ <c:simple-property name="profile" description="The
profile name" required="true"/>
+ <c:simple-property name="socket-binding-group"
readOnly="false" required="true">
+ <c:option-source target="resource"
expression="type=SocketBindingGroup"/>
+ </c:simple-property>
+ <c:simple-property name="socket-binding-port-offset"
required="false" defaultValue="0" type="integer"
+ description="The default offset to be added to
the port values given by the socket binding group."/>
<c:simple-property name="jvm"
required="false"/>
</resource-configuration>
@@ -236,7 +264,9 @@
<operation name="domain-deployment:promote"
displayName="Deploy to Server-Group" description="Deploy this deployment to
a server group">
<parameters>
- <c:simple-property name="server-group"
required="true" description="Server group to deploy to"
type="string"/>
+ <c:simple-property name="server-group"
required="true" description="Server group to deploy to"
type="string">
+ <c:option-source target="resource"
expression="type=ServerGroup" />
+ </c:simple-property>
<c:simple-property name="enabled"
required="true" default="true" description="Should the deployment
be enabled on the server group?" type="boolean"/>
</parameters>
<results>
@@ -327,6 +357,7 @@
<c:simple-property name="group" readOnly="true"
displayName="Server Group" description="Server Group this instance belongs
to."/>
<c:simple-property name="socket-binding-group"
readOnly="true" displayName="Socket binding group"
description="Socket bindngs to use"/>
<c:simple-property name="socket-binding-port-offset"
readOnly="true" displayName="Port Offset" type="integer"
default="0" description="Offset to the base ports"/>
+ <c:simple-property name="path" readOnly="true" />
&logSources;
</plugin-configuration>
@@ -351,7 +382,8 @@
</results>
</operation>
-
+ <metric property="status" dataType="trait"
displayName="Server state" description="Detailed server state"
+ displayType="summary"/>
</server>
@@ -1387,8 +1419,8 @@ working area for individual server
instances</li></ul>"/>
<c:simple-property name="interface"
description="Name of the interface to which the socket should be bound, or, for
multicast sockets, the interface on which it should listen. This should be one of the
declared interfaces." required="false"/>
<c:simple-property name="port" description="Number
of the port to which the socket should be bound." type="integer"/>
<c:simple-property name="fixed-port"
description="Whether the port value should remain fixed even if numeric offsets are
applied to the other sockets in the socket group." type="boolean"/>
- <c:simple-property name="multicast-address"
description="Multicast address on which the socket should receive multicast traffic.
If unspecified, the socket will not be configured to receive multicast." />
- <c:simple-property name="multicast-port"
description="Port on which the socket should receive multicast traffic. Must be
configured if 'multicast-address' is configured."
type="integer"/>
+ <c:simple-property name="multicast-address"
description="Multicast address on which the socket should receive multicast traffic.
If unspecified, the socket will not be configured to receive multicast."
required="false"/>
+ <c:simple-property name="multicast-port"
description="Port on which the socket should receive multicast traffic. Must be
configured if 'multicast-address' is configured." type="integer"
required="false"/>
</c:map-property>
</c:list-property>
</resource-configuration>
@@ -1420,5 +1452,4 @@ working area for individual server
instances</li></ul>"/>
</service>
-
</plugin>
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index b0d68ee..e18193d 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -41,7 +41,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* the UPLOAD_FILE must point to a valid archive in the resources directory.
* @author Heiko W. Rupp
*/
-@Test(enabled = true) // TODO add an "integration test profile" that is able to
fire the server before running the test
+@Test(enabled = UploadAndDeployTest.isEnabled) // TODO add an "integration test
profile" that is able to fire the server before running the test
public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
@@ -49,8 +49,10 @@ public class UploadAndDeployTest {
private static final String DC_HOST = "localhost";
private static final int DC_HTTP_PORT = 9990;
+ protected static final boolean isEnabled = false;
- @Test(timeOut = 60*1000L, enabled=true)
+
+ @Test(timeOut = 60*1000L, enabled=isEnabled)
public void testUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -62,7 +64,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L, enabled=true)
+ @Test(timeOut = 60*1000L, enabled=isEnabled)
public void testDoubleUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -75,7 +77,7 @@ public class UploadAndDeployTest {
assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
- @Test(timeOut = 60*1000L,enabled=true)
+ @Test(timeOut = 60*1000L,enabled=isEnabled)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -155,7 +157,7 @@ public class UploadAndDeployTest {
}
// Test for AS7-853
- @Test(timeOut = 60*1000L,enabled = true)
+ @Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadIndividualSteps2() throws Exception {
String bytes_value = prepare();
@@ -229,7 +231,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L,enabled = true)
+ @Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
@@ -295,7 +297,7 @@ public class UploadAndDeployTest {
* Test uploading to domain only, but not to a server group
* @throws Exception
*/
- @Test(timeOut = 60*1000L,enabled = true)
+ @Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadComposite2() throws Exception {
String bytes_value = prepare();
commit 1b2fddb44dfa4175e5c095de2d2857988af0e827
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 29 15:18:52 2011 +0200
Add a test for a composite operation with only one member operation (i.e. deploy to
domain only)
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index dfa9fd9..b0d68ee 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -41,7 +41,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* the UPLOAD_FILE must point to a valid archive in the resources directory.
* @author Heiko W. Rupp
*/
-@Test(enabled = false) // TODO add an "integration test profile" that is able
to fire the server before running the test
+@Test(enabled = true) // TODO add an "integration test profile" that is able to
fire the server before running the test
public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
@@ -49,7 +49,8 @@ public class UploadAndDeployTest {
private static final String DC_HOST = "localhost";
private static final int DC_HTTP_PORT = 9990;
- @Test(timeOut = 60*1000L, enabled=false)
+
+ @Test(timeOut = 60*1000L, enabled=true)
public void testUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -61,7 +62,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L, enabled=false)
+ @Test(timeOut = 60*1000L, enabled=true)
public void testDoubleUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -74,7 +75,7 @@ public class UploadAndDeployTest {
assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
- @Test(timeOut = 60*1000L,enabled=false)
+ @Test(timeOut = 60*1000L,enabled=true)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -154,7 +155,7 @@ public class UploadAndDeployTest {
}
// Test for AS7-853
- @Test(timeOut = 60*1000L,enabled = false)
+ @Test(timeOut = 60*1000L,enabled = true)
public void testUploadIndividualSteps2() throws Exception {
String bytes_value = prepare();
@@ -228,7 +229,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L,enabled = false)
+ @Test(timeOut = 60*1000L,enabled = true)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
@@ -290,6 +291,62 @@ public class UploadAndDeployTest {
}
+ /**
+ * Test uploading to domain only, but not to a server group
+ * @throws Exception
+ */
+ @Test(timeOut = 60*1000L,enabled = true)
+ public void testUploadComposite2() throws Exception {
+
+ String bytes_value = prepare();
+
+ System.out.println("Prepare done");
+ System.out.flush();
+
+ List<PROPERTY_VALUE> deploymentsAddress = new
ArrayList<PROPERTY_VALUE>(1);
+ deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Operation step1 = new Operation("add",deploymentsAddress);
+ List<Object> content = new ArrayList<Object>(1);
+ Map<String,Object> contentValues = new HashMap<String,Object>();
+ contentValues.put("hash",new
PROPERTY_VALUE("BYTES_VALUE",bytes_value));
+ content.add(contentValues);
+ step1.addAdditionalProperty("content", content);
+ step1.addAdditionalProperty("name", TEST_WAR); // this needs to be
unique per upload
+
+
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
+
+
+ ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT);
+ JsonNode ret = connection.executeRaw(cop);
+ System.out.println(ret);
+ System.out.flush();
+
+ assert ret.has("outcome") : "Ret not valid " +
ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") :
"Composite deploy was no success " + ret.getTextValue();
+
+ // Wait for AS to settle
+ Thread.sleep(1000);
+
+
+ // Now undeploy again to clean up
+
+ cop = new CompositeOperation();
+ Operation step4 = new Operation("remove",deploymentsAddress);
+
+ cop.addStep(step4);
+ ret = connection.executeRaw(cop);
+
+ System.out.println(ret);
+ System.out.flush();
+
+ assert ret.has("outcome") : "Ret not valid " +
ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") :
"Composite remove was no success " + ret.getTextValue();
+
+
+ }
+
private String prepare() throws IOException {
ASUploadConnection conn = new ASUploadConnection(DC_HOST, DC_HTTP_PORT);
OutputStream os = conn.getOutputStream("test.war");
commit ba4a00ce03d3d15001d70529c2cb8c2fd41ea4cd
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jun 28 17:40:42 2011 -0400
make sure the Build-Number and Build-Time Manifest attributes always get set
to valid values, even for SNAPSHOT builds; however, if the project dir is not a
git working dir or the git executable is not available on the PATH, the
Build-Number attribute will not get set to a valid value, but the build should
not fail
diff --git a/pom.xml b/pom.xml
index 719a827..3c8cc4c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -607,7 +607,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
- <version>1.0-beta-4</version>
+ <version>1.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -842,6 +842,113 @@
</configuration>
</plugin>
+ <!-- As of v1.0 of the buildnumber plugin, the create goal doesn't work,
+ and the create-timestamp goal doesn't provide a way to specify
+ a locale or a timezone, so comment this out for now and instead use
+ our own homemade mix of antrun and properties-file plugin executions
+ (just below this commented out block). (ips, 06/28/11)
+ -->
+ <!--
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <id>setBuildNumber</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <configuration>
+ <useLastCommittedRevision>true</useLastCommittedRevision>
+ <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
+ <revisionOnScmFailure></revisionOnScmFailure>
+ <doCheck>false</doCheck>
+ <doUpdate>false</doUpdate>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>setBuildTime</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>create-timestamp</goal>
+ </goals>
+ <configuration>
+ <timestampFormat>MM/dd/yy hh:mm aa z</timestampFormat>
+ <timestampPropertyName>buildTime</timestampPropertyName>
+ </configuration>
+ </execution>
+
+ </executions>
+ </plugin>
+ -->
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>write-build-properties-file</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="target" />
+
+ <tstamp>
+ <format property="buildTime"
pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT"
/>
+ </tstamp>
+ <echo file="target/build.properties">buildTime
= ${buildTime}${line.separator}</echo>
+
+ <exec executable="git"
outputproperty="buildNumber" failonerror="false"
failifexecutionfails="false">
+ <arg value="log"/>
+ <arg value="--pretty=format:%h"/>
+ <arg value="-n1"/>
+ </exec>
+ <echo file="target/build.properties"
append="true">buildNumber = ${buildNumber}${line.separator}</echo>
+ </tasks>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>echo-build-properties</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <echo level="debug">buildTime =
${buildTime}</echo>
+ <echo level="debug">buildNumber =
${buildNumber}</echo>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>properties-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>read-build-properties-file</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>read-project-properties</goal>
+ </goals>
+ <configuration>
+ <files>
+
<file>${project.build.directory}/build.properties</file>
+ </files>
+ <quiet>true</quiet>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
@@ -990,7 +1097,9 @@
</properties>
</profile>
- <!-- Set the java6.home prop to a Java6 JRE dir to enforce that only Java6 APIs
are used. -->
+ <!-- Set the java6.home prop to a Java6 JRE dir to enforce that only Java6 APIs
are used.
+ If using Java7 to run the build, this will ensure no APIs introduced in Java7
are
+ used. -->
<profile>
<id>check-java-api</id>
<activation>
@@ -1031,133 +1140,6 @@
</build>
</profile>
- <!-- Use buildnumber plugin only if SVN metadata is present. -->
- <profile>
- <id>build-number-generation</id>
- <activation>
- <file>
- <exists>.svn</exists>
- </file>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>buildnumber-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>validate</phase>
- <goals>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
- <revisionOnScmFailure>0</revisionOnScmFailure>
- <doCheck>false</doCheck>
- <doUpdate>false</doUpdate>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>build-properties</id>
- <activation>
- <file>
- <exists>.git</exists>
- </file>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>write-build-time-properties-file</id>
- <goals>
- <goal>run</goal>
- </goals>
- <phase>generate-sources</phase>
- <configuration>
- <tasks>
- <tstamp>
- <format property="buildTime"
pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT"
/>
- </tstamp>
- <mkdir dir="target" />
- <echo file="target/build-time.properties"
level="error">buildTime = ${buildTime}
- </echo>
- </tasks>
- </configuration>
- </execution>
-
- <execution>
- <id>echo-build-properties</id>
- <phase>compile</phase>
- <inherited>false</inherited>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <echo level="debug">buildTime =
${buildTime}</echo>
- <echo level="debug">buildNumber =
${buildNumber}</echo>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-build-number-properties</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>git</executable>
- <arguments>
- <argument>log</argument>
- <argument>--pretty=format:buildNumber =
%h</argument>
- <argument>-n1</argument>
- </arguments>
-
<outputFile>${project.build.directory}/build-number.properties</outputFile>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>properties-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>read-build-properties</id>
- <phase>process-sources</phase>
- <goals>
- <goal>read-project-properties</goal>
- </goals>
- <configuration>
- <files>
-
<file>${project.build.directory}/build-time.properties</file>
-
<file>${project.build.directory}/build-number.properties</file>
- </files>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
<!-- This profile should be enabled when a release is being published.
It will ensure that sources and javadoc jars are built and published
for each source module. -->
@@ -1262,7 +1244,7 @@
<licenses>
<license>
<name>GPL</name>
- <url>http://gnu.org</url>
+ <
url>http://www.gnu.org/licenses/gpl.html</url>
</license>
</licenses>
commit 4c9c387956d25621791eda3441d36822b13f404f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 22 13:30:29 2011 +0200
Add a dependent value for the web connector
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 0ccacf6..76d1bcf 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -548,6 +548,7 @@
<service name="Connector"
discovery="SubsystemDiscovery"
class="BaseComponent"
+ createDeletePolicy="both"
<plugin-configuration>
<c:simple-property name="path" readOnly="true"
default="connector"/>
@@ -563,8 +564,10 @@
<resource-configuration>
<c:simple-property name="protocol" required="true"
type="string" readOnly="true" description="The web connector
protocol."/>
- <c:simple-property name="socket-binding"
required="true" type="string" readOnly="true"
- description="The web connector socket-binding
reference, this connector should be bound to."/>
+ <c:simple-property name="socket-binding"
required="true" type="string" readOnly="false"
+ description="The web connector socket-binding
reference, this connector should be bound to.">
+ <c:option-source target="configuration"
expression="socket-binding=name:type=SocketBindingGroup"/>
+ </c:simple-property>
<c:simple-property name="scheme" type="string"
readOnly="true" default="http" description="The web connector
scheme."/>
<c:simple-property name="executor" type="string"
readOnly="true" required="false"
description="The name of the executor that should
be used for the processing threads of this connector. Defaults to using an internal
pool."/>
commit 15a7a42ad63eaf69b184a08b2f522efa99fbda10
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 21:59:52 2011 +0200
Support the new "rolled-back" element in the JSON response from the AS.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index a5583b7..63c5262 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -40,6 +40,8 @@ public class Result {
private /*List<Map<String, String>>*/Object failureDescription;
@JsonIgnore
private boolean success = false;
+ @JsonProperty("rolled-back")
+ private boolean rolledBack = false;
public Result() {
@@ -83,4 +85,11 @@ public class Result {
this.failureDescription = failureDescription;
}
+ public boolean isRolledBack() {
+ return rolledBack;
+ }
+
+ public void setRolledBack(boolean rolledBack) {
+ this.rolledBack = rolledBack;
+ }
}
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 53ac89e..b36a03b 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -185,7 +185,7 @@ public class OperationJsonTest {
public void arrayResult1() throws Exception {
- String resultString =
"{\"outcome\":\"success\",\"result\":[\"standard-sockets\",\"messaging-sockets\"],\"compensating-operation\":null}";
+ String resultString =
"{\"outcome\":\"success\",\"result\":[\"standard-sockets\",\"messaging-sockets\"],\"compensating-operation\":null,
\"rolled-back\" : false}";
ObjectMapper mapper = new ObjectMapper();
Result result = mapper.readValue(resultString,Result.class);
@@ -197,6 +197,21 @@ public class OperationJsonTest {
assert stringList.size()==2;
assert stringList.get(0).equals("standard-sockets");
assert stringList.get(1).equals("messaging-sockets");
+ assert !result.isRolledBack();
+
+ }
+
+ public void rolledBack() throws Exception {
+
+ String resultString = "{\"outcome\":\"failed\",
\"rolled-back\" : true}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("failed");
+ assert !result.isSuccess();
+ assert result.isRolledBack();
}
commit bfde7283adbcfc558707c3d208a066d5626d88c7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 13:43:36 2011 -0500
Fix dbunit setup failures after a new table was added to the schema.
diff --git
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
index e4ef940..ce93e9e 100644
---
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
+++
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
@@ -10,8 +10,8 @@
mtime="123456"/>
<rhq_config_def/>
- <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
index 1f7b34b..50f27e4 100644
---
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
+++
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
@@ -1,7 +1,7 @@
<dataset>
<rhq_config_def/>
- <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
index d584809..29351c4 100644
---
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
+++
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
@@ -2,6 +2,7 @@
<rhq_config_def/>
<rhq_config_prop_grp_def/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
<rhq_config/>
commit 0fd8d03434a22a88a59fb19936dda22c7663eb09
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 17:30:10 2011 +0200
/domain-api got renamed to /management.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index c51f275..f2bb47f 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -52,7 +52,7 @@ public class ASConnection {
public ASConnection(String host, int port) {
try {
- url = new URL("http",host,port,"/domain-api");
+ url = new URL("http",host,port,"/management");
urlString = url.toString();
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e.getMessage());
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index 80e8ea4..d876c80 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -51,7 +51,7 @@ public class ASUploadConnection {
private static final String POST_REQUEST_METHOD = "POST";
- private static final String UPLOAD_URL_PATH = "/domain-api/add-content";
+ private static final String UPLOAD_URL_PATH = "/management/add-content";
private final Log log = LogFactory.getLog(ASUploadConnection.class);
commit 3f5888c667e51c6114a1b192c3b146de7c407aaa
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 09:58:25 2011 -0500
Attempt to correct the dbunit setup failures after a new table was added to the
schema.
diff --git
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
index fe4dfd4..e4ef940 100644
---
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
+++
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
@@ -10,6 +10,7 @@
mtime="123456"/>
<rhq_config_def/>
+ <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
index 2ac6566..1f7b34b 100644
---
a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
+++
b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
@@ -1,5 +1,6 @@
<dataset>
<rhq_config_def/>
+ <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
commit c34278c7a2c5f6aade874c84442326389b706074
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 13:51:40 2011 +0200
First cut at handling target=configuration and using DV in the resource config
editor.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index 2df653a..8f1a058 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceComposite;
@@ -40,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.RefreshableView;
import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import
org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
import
org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
+import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceDetailView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
@@ -127,19 +129,31 @@ public class ResourceConfigurationEditView extends LocatableVLayout
implements P
@Override
public void onTypesLoaded(ResourceType type) {
- editor = new
ConfigurationEditor(extendLocatorId("Editor"), type
- .getResourceConfigurationDefinition(),
result.getConfiguration());
- editor.setOverflow(Overflow.AUTO);
-
editor.addPropertyValueChangeListener(ResourceConfigurationEditView.this);
-
editor.setReadOnly(!resourcePermission.isConfigureWrite());
- addMember(editor);
-
- saveButton.disable();
- buttonbar.setVisible(true);
- markForRedraw();
- refreshing = false;
+ ConfigurationGWTServiceAsync configurationService =
GWTServiceLookup.getConfigurationService();
+
configurationService.getOptionValuesForConfigDefinition(type.getResourceConfigurationDefinition(),new
AsyncCallback<ConfigurationDefinition>(){
+ @Override
+ public void onFailure(Throwable throwable) {
+ refreshing = false;
+
CoreGUI.getErrorHandler().handleError("Failed to load configuration.",
throwable);
+ }
+
+ @Override
+ public void onSuccess(ConfigurationDefinition
configurationDefinition) {
+
+ editor = new
ConfigurationEditor(extendLocatorId("Editor"), configurationDefinition,
result.getConfiguration());
+ editor.setOverflow(Overflow.AUTO);
+
editor.addPropertyValueChangeListener(ResourceConfigurationEditView.this);
+
editor.setReadOnly(!resourcePermission.isConfigureWrite());
+ addMember(editor);
+
+ saveButton.disable();
+ buttonbar.setVisible(true);
+ markForRedraw();
+ refreshing = false;
+ }
+ });
}
- });
+ });
}
@Override
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index f810129..8463123 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -59,6 +59,9 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.composite.ConfigurationUpdateComposite;
@@ -77,6 +80,7 @@ import
org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
@@ -87,8 +91,6 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.core.domain.search.SearchSubsystem;
-import org.rhq.core.domain.search.SearchSuggestion;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
@@ -118,7 +120,6 @@ import
org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupNotFoundException;
import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
-import org.rhq.enterprise.server.search.execution.SearchAssistManager;
import org.rhq.enterprise.server.system.ServerVersion;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -2412,21 +2413,136 @@ public class ConfigurationManagerBean implements
ConfigurationManagerLocal, Conf
if (pds.getOptionsSource()!=null) {
// evaluate the source parameters
PropertyOptionsSource pos = pds.getOptionsSource();
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.setSearchExpression(pos.getExpression());
- // TODO for groups we need to talk to the group manager
- List<ResourceComposite> composites =
resourceManager.findResourceCompositesByCriteria(subject,criteria);
- for (ResourceComposite composite : composites) {
+ PropertyOptionsSource.TargetType tt = pos.getTargetType();
+ String expression = pos.getExpression();
+ if (tt== PropertyOptionsSource.TargetType.RESOURCE || tt==
PropertyOptionsSource.TargetType.CONFIGURATION) {
+ ResourceCriteria criteria = new ResourceCriteria();
+
+
+ if (tt==PropertyOptionsSource.TargetType.CONFIGURATION) {
+ // split out expression part for target=configuration
+ // return if no property specifier is given
+ String expr = expression;
+ if (!expr.contains(":")) {
+ log.warn("Option source expression for property " +
pds.getName() + " and target configuration contains no ':'");
+ return;
+ }
+ }
+ else {
+ criteria.setSearchExpression(expression);
+ }
+
+
+ List<ResourceComposite> composites =
resourceManager.findResourceCompositesByCriteria(subject,criteria);
+ for (ResourceComposite composite : composites) {
+
+ if (tt== PropertyOptionsSource.TargetType.RESOURCE) {
+
+ PropertyDefinitionEnumeration pde = new
PropertyDefinitionEnumeration(composite.getResource().getName(),""+composite.getResource().getId());
+ // TODO filter -- or leave up to search expression??
+ pds.getEnumeratedValues().add(pde);
+ }
+ else if (tt== PropertyOptionsSource.TargetType.CONFIGURATION) {
+ // for configuration we need to drill down into the resource
configuration
+ if (!handleConfigurationTarget(pds, expression,
composite.getResource())) return;
+
+ }
+ }
+ }
+ else if (tt == PropertyOptionsSource.TargetType.GROUP) {
+ // for groups we need to talk to the group manager
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.setSearchExpression(expression);
+
+
resourceGroupManager.findResourceGroupCompositesByCriteria(subject,criteria);
+ }
+ // TODO plugin and resourceType
+ }
- // TODO for configuration we need to drill down into the resource
configuration
- PropertyDefinitionEnumeration pde = new
PropertyDefinitionEnumeration(composite.getResource().getName(),""+composite.getResource().getId());
+ }
- // TODO filter -- or leave up to search expression??
+ /**
+ * Drill down in the case the user set up a target of "configuration". We
need to check
+ * that the target property actually exiists and that it has a format we understand
+ * @param pds Propertydefinition to examine
+ * @param expression The whole expression starting with identifier: for the
configuration
+ * identifier. This looks like <i>listname</i> for list of
+ * property simple or <i>mapname=mapkey</i> for a map with simple
properties
+ * @param resource the
+ * @return false if the property can not be resolved, true otherwise
+ */
+ private boolean handleConfigurationTarget(PropertyDefinitionSimple pds, String
expression,
+ Resource resource) {
+ Configuration configuration = resource.getResourceConfiguration();
+ Property p;
+ String propName = expression.substring(0, expression.indexOf(":"));
+ boolean isMap = expression.contains("=");
+
+ if (isMap) {
+ String mapPropName = propName.substring(0, propName.indexOf("="));
+ p = configuration.get(mapPropName);
+ } else
+ p = configuration.get(propName);
+
+ if (p == null) {
+ log.warn("Option source expression for property " + pds.getName() +
" and target configuration not found");
+ return false;
+ }
+ if (!(p instanceof PropertyList)) {
+ log.warn("Option source expression for property " + pds.getName() +
" and target configuration does not point to a list");
+ return false;
+ }
+ PropertyList pl = (PropertyList) p;
+ List<Property> propertyList = pl.getList();
+ if (propertyList.size()==0)
+ return false;
+
+ // Now List of simple or list of maps (of simple) ?
+
+ if (propertyList.get(0) instanceof PropertySimple) {
+ if (isMap) {
+ log.warn(" expected a List of Maps, but got a list of
simple");
+ return false;
+ }
- pds.getEnumeratedValues().add(pde);
+ for (Property tmp : propertyList) {
+ PropertySimple ps= (PropertySimple) tmp;
+ String name = ps.getStringValue();
+ if (name!=null) {
+ PropertyDefinitionEnumeration pde = new
PropertyDefinitionEnumeration(name, name);
+ pds.getEnumeratedValues().add(pde);
+ }
+ }
+ } else if (propertyList.get(0) instanceof PropertyMap) {
+ if (!isMap) {
+ log.warn(" expected a List of simple, but got a list of
Maps");
+ return false;
+ }
+ String subPropName ;
+ subPropName = propName.substring(propName.indexOf("=") + 1);
+
+ for (Property tmp : propertyList) {
+ PropertyMap pm = (PropertyMap) tmp;
+ Property ps = pm.get(subPropName);
+ if (ps==null) {
+ log.warn("Option source expression for property " +
pds.getName() + " and target configuration does not have a map element " +
subPropName);
+ return false;
+ }
+ if (!(ps instanceof PropertySimple)) {
+ log.warn("ListOfMapOf!Simple are not supported");
+ return false;
+ }
+ PropertySimple propertySimple = (PropertySimple) ps;
+ String name = propertySimple.getStringValue();
+ if (name!=null) {
+ PropertyDefinitionEnumeration pde = new
PropertyDefinitionEnumeration(name, name);
+ pds.getEnumeratedValues().add(pde);
+ }
}
}
+
+ return true;
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
commit 0700bd617ccefd674486f627b670e64333aa63dd
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 27 21:53:06 2011 +0200
Prevent a possible NPE later on if value is null.
diff --git
a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java
b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java
index a6f76b8..0592390 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java
@@ -145,6 +145,10 @@ public class ObjectUtil {
* @return the value read from the object's property path
*/
public static Object lookupDeepAttributeProperty(Object value, String propertyPath)
{
+
+ if (value==null)
+ return null;
+
String[] ps = propertyPath.split("\\.", 2);
String searchProperty = ps[0];
@@ -181,4 +185,4 @@ public class ObjectUtil {
// Prevent instantiation of this class.
private ObjectUtil() {
}
- }
\ No newline at end of file
+ }