Changeset 1020 for DCWoRMS


Ignore:
Timestamp:
03/26/13 11:54:04 (12 years ago)
Author:
gosiaw
Message:

log4j added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/test/DEBBTranslator/src/PLMXMLTranslator.java

    r1019 r1020  
    1212import javax.xml.transform.TransformerFactory; 
    1313 
     14import org.apache.log4j.BasicConfigurator; 
     15import org.apache.log4j.Logger; 
     16 
    1417/** 
    1518 * @author gosiaw 
     
    1720 */ 
    1821public class PLMXMLTranslator { 
     22         
     23        private static Logger logger = Logger.getLogger(PLMXMLTranslator.class); 
     24         
    1925        private static final String DEFAULT_PLMXML_TRANSFORMATION_FILE_NAME = "src/test/DEBBTranslator/xml/PLMXMLTranslator.xsl"; 
    2026        private static final String DEFAULT_UPDATE_TRANSFORMATION_FILE_NAME = "src/test/DEBBTranslator/xml/DCWoRMSDEBBUpdater.xsl"; 
     
    4147         */ 
    4248        public static void main(String[] args) throws Exception { 
     49                 
     50                //      To initialize log4j properly 
     51                BasicConfigurator.configure(); 
     52                 
    4353                String inputFileName = null; 
    4454                String outputFileName = null; 
     
    4858                 
    4959                if (args == null || args.length == 0) { 
    50                         throw new IOException("No arguments specified. Please specify at least input file path."); 
     60                        String errorMessage = "No arguments specified. Please specify at least input file path."; 
     61                        logger.error(errorMessage); 
     62                        throw new IOException(errorMessage); 
    5163                } 
    5264                 
     
    5668                                || (inputFileName != null && inputFileName.isEmpty() == true)) { 
    5769 
    58                         throw new IOException("Input file not specified!"); 
     70                        String errorMessage = "Input file not specified!"; 
     71                        logger.error(errorMessage); 
     72                         
     73                        throw new IOException(errorMessage); 
    5974                } 
    6075 
     
    7186                        } else { 
    7287                                String pathSeparator = File.separator; 
    73 //                              System.out.println("pathSeparator=" + pathSeparator);    
     88//                              logger.debug("pathSeparator=" + pathSeparator);  
    7489                                 
    7590                                //      Otherwise add DCWORMS_ prefix 
     
    7994                                        path = inputFileName.substring(0, position); 
    8095                                } 
    81 //                              System.out.println("path=" + path);      
     96//                              logger.debug("path=" + path);    
    8297                                 
    8398                                String name = inputFileName.substring(position + 1); 
    84 //                              System.out.println("name=" + name);              
     99//                              logger.debug("name=" + name);            
    85100                                outputFileName = path + "DCWORMS" + "_" + name; 
    86101                        } 
     
    109124                } 
    110125                         
    111                 System.out.println("inputFileName=" + inputFileName); 
    112                 System.out.println("outputFileName=" + outputFileName); 
    113                 System.out.println("schedulersAndEstimatorsFileName=" + schedulersAndEstimatorsFileName); 
    114                 System.out.println("templateStartLevel=" + templateStartLevel); 
     126                logger.debug("inputFileName=" + inputFileName); 
     127                logger.debug("outputFileName=" + outputFileName); 
     128                logger.debug("schedulersAndEstimatorsFileName=" + schedulersAndEstimatorsFileName); 
     129                logger.debug("templateStartLevel=" + templateStartLevel); 
    115130                         
    116131                 
    117132                if (inputFileName.compareTo(outputFileName) == 0) { 
    118133                        String errorMessage = "Input and output file cannot be the same"; 
    119                         System.out.println("errorMessage"); 
     134                        logger.error("errorMessage"); 
    120135                        throw new Exception(errorMessage); 
    121136                } 
     
    152167                                        new javax.xml.transform.stream.StreamResult( 
    153168                                                        new FileOutputStream(outputFileName))); 
    154                         System.out.println("File " + inputFileName + " transformed into " + outputFileName + " file"); 
     169                        logger.debug("File " + inputFileName + " transformed into " + outputFileName + " file"); 
    155170                         
    156171                        String debbUpdateTransformationFileName = DEFAULT_UPDATE_TRANSFORMATION_FILE_NAME; 
     
    161176                        updateTransformer.transform(new javax.xml.transform.stream.StreamSource(outputFileName),  
    162177                                        new javax.xml.transform.stream.StreamResult(outputFileName)); 
    163                         System.out.println("File " + outputFileName + " transformed (sorted and updated) into " + outputFileName + " file"); 
     178                        logger.debug("File " + outputFileName + " transformed (sorted and updated) into " + outputFileName + " file"); 
    164179                } catch (Exception e) { 
    165180                        e.printStackTrace(); 
Note: See TracChangeset for help on using the changeset viewer.