1 23 package com.sun.enterprise.diagnostics.collect; 24 import com.sun.enterprise.diagnostics.DiagnosticException; 25 import com.sun.enterprise.diagnostics.Data; 26 import com.sun.enterprise.diagnostics.Defaults; 27 import com.sun.enterprise.diagnostics.util.FileUtils; 28 import com.sun.logging.LogDomains; 29 30 import java.io.IOException ; 31 import java.util.logging.Level ; 32 import java.util.logging.Logger ; 33 34 38 public class CustomerInputCollector implements Collector{ 39 40 String customerInputFile; 41 String customerInput; 42 String intermediateReportLocation; 43 boolean local; 44 45 protected static Logger logger = 46 LogDomains.getLogger(LogDomains.ADMIN_LOGGER); 47 48 49 public CustomerInputCollector(String customerInputFile , String customerInput, 50 String intermediateReportLocation, boolean local) { 51 this.intermediateReportLocation = intermediateReportLocation; 52 this.customerInput = customerInput; 53 this.customerInputFile = customerInputFile; 54 this.local = local; 55 } 56 57 public Data capture() throws DiagnosticException { 58 if(customerInputFile != null) 59 return copyCustomerInputFile(customerInputFile); 60 if(customerInput != null && customerInput.trim().length() > 0) { 61 WritableDataImpl customerInfo = new WritableDataImpl(DataType.CUSTOMER_INFO); 62 customerInfo.addValue(customerInput); 63 return customerInfo; 64 } 65 return null; 66 } 67 68 72 private Data copyCustomerInputFile(String inputFile) { 73 if(inputFile != null) { 74 try { 75 String destFile = intermediateReportLocation + 76 Defaults.CUSTOMER_INPUT; 77 FileUtils.copyFile(inputFile, destFile); 78 return new FileData(destFile, 79 DataType.CUSTOMER_INFO); 80 } catch (IOException ioe) { 81 logger.log(Level.WARNING, "diagnostic-service.copy_failed", 82 new Object []{inputFile, ioe.getMessage()}); 83 } 84 } 85 return null; 86 } 87 88 } 89 | Popular Tags |