| I took a bit of time this morning to try some experiments. I created an Admin Command that fills an ActionReport with data. It exercises all of the different ways of doing that. Source Code java file
ActionReport.MessagePart top = report.getTopMessagePart();
ActionReport.MessagePart sub1 = top.addChild();
ActionReport.MessagePart sub2 = top.addChild();
sub1.setChildrenType("childrentype-1");
sub2.setChildrenType("childrentype-2");
top.setChildrenType("childrentype-top");
sub1.setMessage("sub1 message");
sub2.setMessage("sub2 message");
top.setMessage("top message");
sub1.addProperty("sub1-key1", "sub1-value1");
sub2.addProperty("sub2-key1", "sub2-value1");
top.addProperty("top-key1", "top-value1");
Properties extraProps = new Properties();
extraProps.setProperty("extra-key1", "extra-value1");
report.setExtraProperties(extraProps);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
Notice that the extra properties are not in the Manifest object. Feel free to investigate why! ------- RAW RESPONSE --------- Signature-Version: 1.0 message: top message%%%EOL%%% top-key1_name: top-key1 keys: top-key1 top-key1_value: top-value1 children: sub1 message;sub2 message use-main-children-attribute: false children-type: childrentype-top exit-code: SUCCESS Name: sub1 message sub1-key1_name: sub1-key1 message: top message%%%EOL%%% sub1-key1_value: sub1-value1 keys: sub1-key1 Name: sub2 message message: top message%%%EOL%%% keys: sub2-key1 sub2-key1_name: sub2-key1 sub2-key1_value: sub2-value1 Here is the normal (non-debug) asadmin output.Notice how the properties are NOT shown. This may be useful! C:\gf\v3\cluster\admin>asadmin output-tester top message childrentype-top : sub1 message childrentype-top : sub2 message Command output-tester executed successfully. Here is the output in a browser from http://localhost:4848/__asadmin/output-tester.xml
This XML file does not appear to have any style information associated with it. The document tree is shown below.
−
<action-report description="output-tester AdminCommand" exit-code="SUCCESS">
−
<message-part message="top message">
<property name="top-key1" value="top-value1"/>
−
<message-part message="sub1 message" type="childrentype-1">
<property name="sub1-key1" value="sub1-value1"/>
</message-part>
−
<message-part message="sub2 message" type="childrentype-2">
<property name="sub2-key1" value="sub2-value1"/>
</message-part>
</message-part>
</action-report>
And finally here is the output from http://localhost:4848/__asadmin/output-tester.json – it was all one line. I added some linefeeds to make it easier to read. { "name":"top message" , "command":"output-tester AdminCommand" ,
"exit_code":"SUCCESS" ,"properties" : { "top-key1" : "top-value1" } ,
"result" : [ { "name":"sub1 message" ,"properties" : { "sub1-key1"
: "sub1-value1" } } , { "name":"sub2 message" ,"properties"
: { "sub2-key1" : "sub2-value1" } } ] }
Is this the Answer – Use the top-message properties private void two(ActionReport report) {
ActionReport.MessagePart top = report.getTopMessagePart();
top.setMessage("Here is a big fancy list-instances output%%%EOL%%%Second Line Here");
top.addProperty("instance1", "running");
top.addProperty("instance2", "running");
top.addProperty("instance3", "not running");
Properties extraProps = new Properties();
extraProps.setProperty("XXinstance1", "running");
extraProps.setProperty("XXinstance2", "running");
extraProps.setProperty("XXinstance3", "not running");
report.setExtraProperties(extraProps);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Manifest Object contents
------- RAW RESPONSE --------- Signature-Version: 1.0 message: Here is a big fancy list-instances output%%%EOL%%%Second Line Here%%%EOL%%% keys: instance3;instance2;instance1 instance2_name: instance2 instance1_name: instance1 instance1_value: running use-main-children-attribute: false instance2_value: running instance3_name: instance3 instance3_value: not running exit-code: SUCCESS ------- RAW RESPONSE --------- |
Here is a big fancy list-instances output Second Line Here Command output-tester executed successfully.
<action-report description="output-tester AdminCommand" exit-code="SUCCESS"> <message-part message="Here is a big fancy list-instances output%%%EOL%%%Second Line Here"> <property name="instance3" value="not running"/> <property name="instance2" value="running"/> <property name="instance1" value="running"/> </message-part> </action-report>
{ "name":"Here is a big fancy list-instances output%%%EOL%%%Second Line Here" ,
"command":"output-tester AdminCommand" , "exit_code":"SUCCESS" ,"properties" :
{ "instance3" : "not running" ,
"instance2" : "running" ,
"instance1" : "running" } }