Version Differences for Miscellaneous Scripts

(AHPSCRIPTS-20)
(AHPSCRIPTS-20)
Line 2011:
  writer.write("</body></html>");    writer.write("</body></html>"); 
  writer.close();</pre>    writer.close();</pre> 
       
    + = Put the Output of a Step in an E-Mail =  
       
    + ==== AHPSCRIPTS-103 ====  
    + <pre>import com.urbancode.anthill3.domain.jobtrace.*;  
    + import com.urbancode.anthill3.domain.workflow.*;  
    + import com.urbancode.anthill3.runtime.paths.*;  
    + import com.urbancode.anthill3.services.file.*;  
    + import com.urbancode.devilfish.services.file.FileInfo;  
    + import java.io.*;  
       
    + private String getStreamAsString(InputStream inStream)  
    + throws IOException {  
    + StringBuffer result = new StringBuffer();  
    + try {  
    + byte[] buffer = new byte[4096];  
    + int length = 0;  
    + while ((length = inStream.read(buffer)) > 0) {  
    + result.append(new String(buffer, 0, length));  
    + }  
    + }  
    + finally {  
    + try {  
    + inStream.close();  
    + }  
    + catch (Exception e) {}  
    + }  
    + return result.toString();  
    + }  
       
       
    + String STEP_NAME = "ant-build"; // change to the name of the step  
       
    + WorkflowCase workflow = (WorkflowCase) context.get("workflow");  
    + JobTrace[] jobTraceArray = workflow.getJobTraceArray();  
       
    + // find the job trace you want in some meaningful way (this uses the first)  
    + JobTrace jobTrace = jobTraceArray[0];  
       
    + StepTrace[] stepTraces = jobTrace.getStepTraceArray();  
    + for (int s=0; s<stepTraces.length; s++) {  
    + if (STEP_NAME.equals(stepTraces[s].getName())) {  
    + // this is the step  
    + CommandTrace cmdTrace = stepTraces[s].getCommandTraceArray()[0];  
    + FileInfo outputFile = LogPathHelper.getInstance().getLogFileInfoArray(cmdTrace)[0];  
    + InputStream inStream = FileInfoService.getInstance().getFileInfoAsStream(outputFile);  
    + context.put("ant-output", getStreamAsString(inStream));  
    + break;  
    + }  
    + }</pre>