private void writePart(Element actionReport, MessagePart part, String childType) { Document d = actionReport.getOwnerDocument(); Element messagePart = d.createElement("message-part"); actionReport.appendChild(messagePart); if (childType != null) { messagePart.setAttribute("type", childType); } for (Map.Entry prop : part.getProps().entrySet()) { Element p = d.createElement("property"); messagePart.appendChild(p); p.setAttribute("name", prop.getKey().toString()); p.setAttribute("value", prop.getValue().toString()); } messagePart.setAttribute("message", part.getMessage()); for (MessagePart subPart : part.getChildren()) writeSubPart(messagePart, subPart, subPart.getChildrenType()); }
private String simpleGetOutputData() { StringBuilder out = new StringBuilder(); String tm = topMessage.getMessage(); String body = sb.toString(); if (ok(tm) && !ok(body)) body = tm; if (ok(body)) { out.append(body); } return out.toString(); }
private void writePart(Element actionReport, MessagePart part, String childType) { Document d = actionReport.getOwnerDocument(); Element messagePart = d.createElement("message-part"); actionReport.appendChild(messagePart); if (childType != null) { messagePart.setAttribute("type", childType); } for (Map.Entry prop : part.getProps().entrySet()) { Element p = d.createElement("property"); messagePart.appendChild(p); p.setAttribute("name", prop.getKey().toString()); Object value = prop.getValue(); if (value instanceof List) { addListElement(p, (List)value); } else if (value instanceof Map) { addMapElement(p, (Map)value); } else { p.setAttribute("value", prop.getValue().toString()); } } messagePart.setAttribute("message", part.getMessage()); for (MessagePart subPart : part.getChildren()) { writePart(messagePart, subPart, subPart.getChildrenType()); } }
if (preSupplementalReturn.equals(ActionReport.ExitCode.FAILURE)) { report.setActionExitCode(preSupplementalReturn); if (!StringUtils.ok(report.getTopMessagePart().getMessage())) { report.setMessage(adminStrings.getLocalString("commandrunner.executor.supplementalcmdfailed", "A supplemental command failed; cannot proceed further"));
if (preSupplementalReturn.equals(ActionReport.ExitCode.FAILURE)) { report.setActionExitCode(preSupplementalReturn); if (!StringUtils.ok(report.getTopMessagePart().getMessage())) { report.setMessage(adminStrings.getLocalString("commandrunner.executor.supplementalcmdfailed", "A supplemental command failed; cannot proceed further"));
for (ActionReport.MessagePart cp : subPart.getChildren()) { ActionReport.MessagePart resourcesChildPart = childPart.addChild(); resourcesChildPart.setMessage(" " + cp.getMessage());
String cm = child.getMessage(); if (cm != null) { try {
List<String> rcmds = new ArrayList<String>(children.size()); for (ActionReport.MessagePart msg : children) { if (!localnames.contains(msg.getMessage())) { rcmds.add(msg.getMessage());
private void messageToString(int indentLevel, String id, MessagePart msg, StringBuilder sb) { if (msg == null) { return; } addIndent(indentLevel, sb); sb.append("MESSAGE - ").append(id).append(EOL); if (msg.getMessage() != null && !msg.getMessage().isEmpty()) { addIndent(indentLevel, sb); sb.append(" : ").append(msg.getMessage()).append(EOL); } if (msg.getChildrenType() != null) { addIndent(indentLevel, sb); sb.append(" childrenType: ").append(msg.getChildrenType()).append(EOL); } for (Map.Entry<Object, Object> entry : msg.getProps().entrySet()) { addIndent(indentLevel, sb); sb.append(" >").append(entry.getKey()).append(" = ").append(entry.getValue()); sb.append(EOL); } if (msg.getChildren() != null) { int counter = 0; for (MessagePart child : msg.getChildren()) { messageToString(indentLevel + 1, id + ".M" + counter, child, sb); counter++; } } }
private void write(MessagePart part, PrintWriter writer) { writer.println("{ " + quote("name") + ":" + quote(part.getMessage())); if (top) { writer.println(", " + quote("command") + ":" + quote(actionDescription)); writer.println(", " + quote("exit_code") + ":" + quote("" + this.exitCode)); top = false; } writeProperties(part.getProps(), writer); boolean first = true; for (MessagePart child : part.getChildren()) { if (first == true) { writer.println(", " + quote("result") + " : ["); } else { writer.println(","); } first = false; write(child, writer); } if (first == false) { //close the array writer.println("]"); } writer.println("}"); }
private void displayAppScopedResources(String applicationName, ActionReport report, ActionReport.MessagePart part) { Application application = null; List<Application> applications = domain.getApplicationsInTarget(target); for (Application app : applications) { if (app.getName().equals(applicationName)) { application = app; } } if (application != null) { ActionReport subReport = report.addSubActionsReport(); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("_list-resources", subReport); final ParameterMap parameters = new ParameterMap(); parameters.add("appname", application.getName()); inv.parameters(parameters).execute(); ActionReport.MessagePart subPart = subReport.getTopMessagePart(); for (ActionReport.MessagePart cp: subPart.getChildren()) { ActionReport.MessagePart resourcesChildPart = part.addChild(); resourcesChildPart.setMessage(cp.getMessage()); } } }
private void copyMessagePart(MessagePart source, MessagePart dest) { if (source == null || dest == null) { return; } dest.setMessage(source.getMessage()); dest.setChildrenType(source.getChildrenType()); Properties props = source.getProps(); if (props != null) { for (Map.Entry<Object, Object> entry : props.entrySet()) { dest.addProperty((String) entry.getKey(), (String) entry.getValue()); } } for (MessagePart chmp : source.getChildren()) { copyMessagePart(chmp, dest.addChild()); } }
private static void addSubMessages(String indentPrefix, ActionReport.MessagePart mp, StringBuilder sb) { if (mp == null || sb == null) { return; } if (indentPrefix == null) { indentPrefix = ""; } List<ActionReport.MessagePart> children = mp.getChildren(); if (children != null) { for (ActionReport.MessagePart subPart : children) { if (sb.length() > 0) { sb.append(EOL); } if (ok(subPart.getMessage())) { sb.append(subPart.getMessage()); } addSubMessages(indentPrefix + " ", subPart, sb); } } }
private void displaySubComponents(String appName, ActionReport report, ActionReport.MessagePart part) { ActionReport subReport = report.addSubActionsReport(); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("list-sub-components", subReport); final ParameterMap parameters = new ParameterMap(); parameters.add("DEFAULT", appName); parameters.add("terse", "true"); parameters.add("resources", resources.toString()); inv.parameters(parameters).execute(); ActionReport.MessagePart subPart = subReport.getTopMessagePart(); for (ActionReport.MessagePart childPart: subPart.getChildren()) { ActionReport.MessagePart actualChildPart = part.addChild(); actualChildPart.setMessage(" " + childPart.getMessage()); for(ActionReport.MessagePart grandChildPart : childPart.getChildren()){ actualChildPart.addChild().setMessage(grandChildPart.getMessage()); } } }
private void write(int level, MessagePart part, PrintWriter writer) { String mess = part.getMessage(); if (mess==null){ mess = "";//better than a null string output } if (level>6) { writer.println(mess); } else { writer.println("<h" + level + ">" + mess + "</h" + level + ">"); } write(part.getProps(), writer); for (MessagePart child : part.getChildren()) { write(level+1, child, writer); } }
@Override public String getMessage() { return topMessage.getMessage(); }
@Override public String getMessage() { return topMessage.getMessage(); }
private void write(String indent, MessagePart part, StringBuilder out) { out.append(indent).append(part.getMessage()).append('\n'); write(indent + INDENT, part.getProps(), out); for (MessagePart child : part.getChildren()) { write(indent + INDENT, child, out); } }