modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
| 21 +-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
| 3
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 80 ++++++++++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
| 30 +++
4 files changed, 119 insertions(+), 15 deletions(-)
New commits:
commit 33f3c425d2c908379eb4a03f225690e214280287
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon May 9 17:02:00 2011 +0200
Fix uploading of deployments
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 b369a95..80e8ea4 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
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -42,7 +43,9 @@ import org.codehaus.jackson.map.ObjectMapper;
*/
public class ASUploadConnection {
- private static final String BOUNDARY =
"-----------------------------261773107125236";
+ private static final String BOUNDARY_PARAM = "NeAG1QNIHHOyB5joAS7Rox!!";
+
+ private static final String BOUNDARY = "--" + BOUNDARY_PARAM;
private static final String CRLF = "\r\n";
@@ -71,6 +74,7 @@ public class ASUploadConnection {
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod(POST_REQUEST_METHOD);
+ connection.setRequestProperty("Content-Type",
"multipart/form-data; boundary=" + BOUNDARY_PARAM);
// Grab the test WAR file and get a stream to its contents to be included in
the POST.
os = new BufferedOutputStream(connection.getOutputStream());
@@ -92,6 +96,7 @@ public class ASUploadConnection {
os.flush();
int code = connection.getResponseCode();
+ System.err.println("Response code " + code);
if (code==500)
is = connection.getErrorStream();
else
@@ -128,15 +133,13 @@ public class ASUploadConnection {
}
- private byte[] buildPostRequestHeader(String fileName) {
+ private byte[] buildPostRequestHeader(String fileName) throws
UnsupportedEncodingException {
final StringBuilder builder = new StringBuilder();
- builder.append(buildPostRequestHeaderSection("form-data;
name=\"test1\"", "", "test1"));
- builder.append(buildPostRequestHeaderSection("form-data;
name=\"test2\"", "", "test2"));
builder.append(buildPostRequestHeaderSection("form-data;
name=\"file\"; filename=\""+fileName+"\"",
"application/octet-stream", ""));
- return builder.toString().getBytes();
+ return builder.toString().getBytes("US-ASCII");
}
- private String buildPostRequestHeaderSection(final String contentDisposition, final
String contentType, final String content) {
+ private StringBuilder buildPostRequestHeaderSection(final String contentDisposition,
final String contentType, final String content) {
final StringBuilder builder = new StringBuilder();
builder.append(BOUNDARY);
builder.append(CRLF);
@@ -152,16 +155,16 @@ public class ASUploadConnection {
builder.append(content);
}
builder.append(CRLF);
- return builder.toString();
+ return builder;
}
- private byte[] buildPostRequestFooter() {
+ private byte[] buildPostRequestFooter() throws UnsupportedEncodingException{
final StringBuilder builder = new StringBuilder();
builder.append(CRLF);
builder.append(BOUNDARY);
builder.append("--");
builder.append(CRLF);
- return builder.toString().getBytes();
+ return builder.toString().getBytes("US-ASCII");
}
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 48b0094..50939ae 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
@@ -531,9 +531,9 @@
<c:simple-property name="bean-validation-enabled"
required="true" type="boolean" readOnly="true"
description="Specify whether bean validation is
enabled"/>
<c:simple-property name="archive-validation-enabled"
type="boolean" readOnly="true" description="Enabling the
validation"/>
- <c:simple-property name="archive-validation-fail-on-error"
type="boolean" readOnly="true"
+ <c:simple-property name="archive-validation-fail-on-error"
type="boolean" readOnly="true" default="true"
description="Should an archive validation error
report fail the deployment. Default: true"/>
- <c:simple-property name="archive-validation-fail-on-warn"
type="boolean" readOnly="true"
+ <c:simple-property name="archive-validation-fail-on-warn"
type="boolean" readOnly="true" default="false"
description="Should an archive validation warning
report fail the deployment. Default: false"/>
<c:simple-property name="cached-connection-manager-debug"
type="boolean" readOnly="true"
description="enable/disable debug information logging
for cached connection manager"/>
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 e4e9d70..b1eb277 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
@@ -30,6 +30,7 @@ import org.testng.annotations.Test;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.Result;
/**
* Test uploading and deploying to the domain
@@ -46,6 +47,17 @@ public class UploadAndDeployTest {
private static final int DC_HTTP_PORT = 9990;
@Test(timeOut = 60*1000L, enabled = true)
+ public void testUploadOnly() throws Exception {
+
+ String bytes_value = prepare();
+
+ assert bytes_value != null;
+
+ System.out.println("sha: " + bytes_value);
+
+ }
+
+ @Test(timeOut = 60*1000L, enabled = true)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -79,7 +91,7 @@ public class UploadAndDeployTest {
System.out.println("Add to server group done: " + ret);
System.out.flush();
- assert ret.has("outcome") : "Ret not valied " +
ret.toString();
+ assert ret.has("outcome") : "Ret not valid " +
ret.toString();
assert ret.get("outcome").getTextValue().equals("success") :
"add to sg was no success " + ret.getTextValue();
@@ -88,7 +100,7 @@ public class UploadAndDeployTest {
Operation undeploy = new Operation("remove",serverGroupAddress);
ret = connection.executeRaw(undeploy);
- assert ret.has("outcome") : "Ret not valied " +
ret.toString();
+ assert ret.has("outcome") : "Ret not valid " +
ret.toString();
assert ret.get("outcome").getTextValue().equals("success") :
"remove from sg was no success " + ret.getTextValue();
@@ -97,7 +109,7 @@ public class UploadAndDeployTest {
Operation remove = new Operation("remove",deploymentsAddress);
ret = connection.executeRaw(remove);
- assert ret.has("outcome") : "Ret not valied " +
ret.toString();
+ assert ret.has("outcome") : "Ret not valid " +
ret.toString();
assert ret.get("outcome").getTextValue().equals("success") :
"remove from domain was no success " + ret.getTextValue();
System.out.flush();
@@ -156,13 +168,19 @@ public class UploadAndDeployTest {
InputStream fis = getClass().getClassLoader().getResourceAsStream(UPLOAD_FILE);
- int b;
- while ((b = fis.read())!=-1) {
- os.write(b);
+ final byte[] buffer = new byte[1024];
+ int numRead = 0;
+
+ while(numRead > -1) {
+ numRead = fis.read(buffer);
+ if(numRead > 0) {
+ os.write(buffer,0,numRead);
+ }
}
fis.close();
JsonNode node = conn.finishUpload();
System.out.println(node);
+ assert node != null : "No result from upload - node was null";
assert node.has("outcome") : "No outcome from upload";
String outcome = node.get("outcome").getTextValue();
assert outcome.equals("success") : "Upload was no success" +
outcome;
commit 2f14177fb1381441fafb767076439f1e401d15bc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 6 11:24:52 2011 +0200
Add more subsystems
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 04686c4..48b0094 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
@@ -507,6 +507,42 @@
</server>
+ <server name="General JCA connectors"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ description="General settings of the JCA engine. Not nexessarily for
end-users"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile"
plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true"
default="subsystem=connector"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property
name="default-workmanager-short-running-thread-pool" required="true"
type="string" readOnly="true"
+ description="Specify the name of short running thread
pool"/>
+ <c:simple-property
name="default-workmanager-long-running-thread-pool" required="true"
type="string" readOnly="true"
+ description="Specify the name of long running thread
pool"/>
+ <c:simple-property name="bean-validation-enabled"
required="true" type="boolean" readOnly="true"
+ description="Specify whether bean validation is
enabled"/>
+ <c:simple-property name="archive-validation-enabled"
type="boolean" readOnly="true" description="Enabling the
validation"/>
+ <c:simple-property name="archive-validation-fail-on-error"
type="boolean" readOnly="true"
+ description="Should an archive validation error
report fail the deployment. Default: true"/>
+ <c:simple-property name="archive-validation-fail-on-warn"
type="boolean" readOnly="true"
+ description="Should an archive validation warning
report fail the deployment. Default: false"/>
+ <c:simple-property name="cached-connection-manager-debug"
type="boolean" readOnly="true"
+ description="enable/disable debug information logging
for cached connection manager"/>
+ <c:simple-property name="cached-connection-manager-error"
type="boolean" readOnly="true"
+ description="enable/disable error information logging
for cached connection manager"/>
+ </resource-configuration>
+
+ </server>
+
<server name="Datasources"
discovery="SubsystemDiscovery"
class="BaseComponent"
@@ -629,6 +665,23 @@
</server>
+ <server name="ResourceAdapters"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile"
plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true"
default="subsystem=resource-adapters"/>
+ </plugin-configuration>
+ </server>
+
+
<server name="Threads"
discovery="SubsystemDiscovery"
class="BaseComponent"
@@ -689,6 +742,33 @@
</server>
+ <server name="Webservices"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile"
plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true"
default="subsystem=webservices"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="modify-soap-address"
required="true" type="boolean" readOnly="true"
+ description="Whether the soap address can be
modified."/>
+ <c:simple-property name="webservice-host"
required="true" type="string" readOnly="true"
+ description="The WSDL, that is a required deployment
artifact for an endpoint, has a &soap:address> element which points to the
location of the endpoint. JBoss supports rewriting of that SOAP address. If the content of
&soap:address> is a valid URL, JBossWS will not rewrite it unless
'modifySOAPAddress' is true. If the content of &soap:address> is not a
valid URL, JBossWS will rewrite it using the attribute values given below. If
'webServiceHost' is set to 'jbossws.undefined.host', JBossWS uses
requesters host when rewriting the &soap:address>"/>
+ <c:simple-property name="webservice-port"
type="integer" readOnly="true"
+ description="The non-secure port that will be used
for rewriting the SOAP address. If absent the port will be identified by querying the list
of installed connectors."/>
+ <c:simple-property name="webservice-secure-port"
type="integer" readOnly="true"
+ description="The non-secure port that will be used
for rewriting the SOAP address. If absent the port will be identified by querying the list
of installed connectors."/>
+ </resource-configuration>
+ </server>
+
<service name="NetworkInterface"
discovery="SubsystemDiscovery"
class="BaseComponent"
commit fa33a38abec2ac915f128af5a9e262edc36c2f3f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 5 12:07:00 2011 +0200
Prevent a possible NPE.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index 8e42fdf..e61ff3c 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -99,6 +99,9 @@ public class Domain2Descriptor {
}
private void createProperties(boolean doMetrcis, Map<String, Object>
attributesMap, int indent) {
+ if (attributesMap==null)
+ return;
+
for (Map.Entry<String,Object> entry : attributesMap.entrySet()) {
Map<String,Object> props = (Map<String, Object>)
entry.getValue();