1 22 package org.objectweb.petals.component.common.util; 23 24 29 public class ManagementMessageUtil { 30 31 public static final String TASK_RESULT_FAILED = "FAILED"; 32 33 public static final String TASK_RESULT_SUCCESS = "SUCCESS"; 34 35 public static final String MESSAGE_TYPE_ERROR = "ERROR"; 36 37 public static final String MESSAGE_TYPE_WARNING = "WARNING"; 38 39 public static final String MESSAGE_TYPE_INFO = "INFO"; 40 41 private static final String XMLNS = "http://java.sun.com/xml/ns/jbi/management-message"; 42 43 private static final String TASK_RESULT_DETAILS = "task-result-details"; 44 45 private static final String TASK_ID = "task-id"; 46 47 private static final String TASK_RESULT = "task-result"; 48 49 private static final String MESSAGE_TYPE = "message-type"; 50 51 private static final String EXCEPTION_INFO = "exception-info"; 52 53 private static final String NESTING_LEVEL = "nesting-level"; 54 55 private static final String MSG_LOC_INFO = "msg-loc-info"; 56 57 private static final String LOC_TOKEN = "loc-token"; 58 59 private static final String LOC_MESSAGE = "loc-message"; 60 61 private static final String LOC_PARAM = "loc-param"; 62 63 private static final String STACK_TRACE = "stack-trace"; 64 65 private static final String COMPONENT_TASK_RESULT = "component-task-result"; 66 67 private static final String COMPONENT_TASK_RESULT_DETAILS = "component-task-result-details"; 68 69 private static final String COMPONENT_NAME = "component-name"; 70 71 82 public static String getComponentTaskResult(String componentName, 83 String taskId, String taskResult) { 84 return ManagementMessageUtil.getComponentTaskResult(componentName, 85 taskId, taskResult, null, null, null, null, null, null, null); 86 } 87 88 109 public static String getComponentTaskResult(String componentName, 110 String taskId, String taskResult, String messageType, 111 String nestingLevel, String exceptionMessage, 112 String [] exceptionMessageParams, String stackStrace) { 113 return getComponentTaskResult(componentName, taskId, taskResult, 114 messageType, null, null, nestingLevel, exceptionMessage, 115 exceptionMessageParams, stackStrace); 116 } 117 118 135 public static String getComponentTaskResult(String componentName, 136 String taskId, String taskResult, String messageType, 137 String message, String [] messageParams) { 138 return getComponentTaskResult(componentName, taskId, taskResult, 139 messageType, message, messageParams, null, null, null, null); 140 } 141 142 167 public static String getComponentTaskResult(String componentName, 168 String taskId, String taskResult, String messageType, 169 String message, String [] messageParams, String nestingLevel, 170 String exceptionMessage, String [] exceptionMessageParams, 171 String stackStrace) { 172 StringBuffer xmlInput = new StringBuffer (); 173 xmlInput.append("\t\t<" + ManagementMessageUtil.COMPONENT_TASK_RESULT 174 + ">\n"); 175 xmlInput.append("\t\t\t<" + ManagementMessageUtil.COMPONENT_NAME + ">" 176 + componentName + "</" + ManagementMessageUtil.COMPONENT_NAME 177 + ">\n"); 178 xmlInput.append("\t\t\t<" 179 + ManagementMessageUtil.COMPONENT_TASK_RESULT_DETAILS 180 + " xmlns='" + ManagementMessageUtil.XMLNS + "'>\n"); 181 xmlInput.append("\t\t\t\t<" + ManagementMessageUtil.TASK_RESULT_DETAILS 182 + ">\n"); 183 xmlInput.append("\t\t\t\t\t<" + ManagementMessageUtil.TASK_ID + ">" 184 + taskId + "</" + ManagementMessageUtil.TASK_ID + ">\n"); 185 xmlInput 186 .append("\t\t\t\t\t<" + ManagementMessageUtil.TASK_RESULT + ">" 187 + taskResult + "</" + ManagementMessageUtil.TASK_RESULT 188 + ">\n"); 189 if (messageType != null) { 190 xmlInput.append("\t\t\t\t\t<" + ManagementMessageUtil.MESSAGE_TYPE 191 + ">" + messageType + "</" 192 + ManagementMessageUtil.MESSAGE_TYPE + ">\n"); 193 if (message != null) { 194 xmlInput.append("\t\t\t\t\t<" 195 + ManagementMessageUtil.MSG_LOC_INFO + ">\n"); 196 xmlInput.append("\t\t\t\t\t\t<" 200 + ManagementMessageUtil.LOC_TOKEN + ">jbimsg</" 201 + ManagementMessageUtil.LOC_TOKEN + ">\n"); 202 xmlInput.append("\t\t\t\t\t\t<" 203 + ManagementMessageUtil.LOC_MESSAGE + ">" + message 204 + "</" + ManagementMessageUtil.LOC_MESSAGE + ">\n"); 205 for (String string : messageParams) { 206 xmlInput.append("\t\t\t\t\t\t<" 207 + ManagementMessageUtil.LOC_PARAM + ">" + string 208 + "</" + ManagementMessageUtil.LOC_PARAM + ">\n"); 209 } 210 xmlInput.append("\t\t\t\t\t</" 211 + ManagementMessageUtil.MSG_LOC_INFO + ">\n"); 212 } 213 if (exceptionMessage != null) { 214 xmlInput.append("\t\t\t\t\t<" 215 + ManagementMessageUtil.EXCEPTION_INFO + ">\n"); 216 xmlInput.append("\t\t\t\t\t\t<" 217 + ManagementMessageUtil.NESTING_LEVEL + ">" 218 + nestingLevel + "</" 219 + ManagementMessageUtil.NESTING_LEVEL + ">\n"); 220 xmlInput.append("\t\t\t\t\t\t<" 221 + ManagementMessageUtil.MSG_LOC_INFO + ">\n"); 222 xmlInput.append("\t\t\t\t\t\t\t<" 226 + ManagementMessageUtil.LOC_TOKEN + ">jbimsg</" 227 + ManagementMessageUtil.LOC_TOKEN + ">\n"); 228 xmlInput.append("\t\t\t\t\t\t\t<" 229 + ManagementMessageUtil.LOC_MESSAGE + ">" 230 + exceptionMessage + "</" 231 + ManagementMessageUtil.LOC_MESSAGE + ">\n"); 232 for (String string : exceptionMessageParams) { 233 xmlInput.append("\t\t\t\t\t\t\t<" 234 + ManagementMessageUtil.LOC_PARAM + ">" + string 235 + "</" + ManagementMessageUtil.LOC_PARAM + ">\n"); 236 } 237 xmlInput.append("\t\t\t\t\t\t</" 238 + ManagementMessageUtil.MSG_LOC_INFO + ">\n"); 239 if (stackStrace != null) { 240 xmlInput.append("\t\t\t\t\t\t<" 241 + ManagementMessageUtil.STACK_TRACE + ">" 242 + stackStrace + "</" 243 + ManagementMessageUtil.STACK_TRACE + ">\n"); 244 } 245 xmlInput.append("\t\t\t\t</" 246 + ManagementMessageUtil.EXCEPTION_INFO + ">\n"); 247 } 248 } 249 xmlInput.append("\t\t\t\t</" 250 + ManagementMessageUtil.TASK_RESULT_DETAILS + ">\n"); 251 xmlInput.append("\t\t\t</" 252 + ManagementMessageUtil.COMPONENT_TASK_RESULT_DETAILS + ">\n"); 253 xmlInput.append("\t\t</" + ManagementMessageUtil.COMPONENT_TASK_RESULT 254 + ">\n"); 255 return xmlInput.toString(); 256 } 257 258 } 259 | Popular Tags |