101. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/11/2019 10:54:11 AM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

101.1 Files compared

# Location File Last Modified
1 HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\batchprocess AbstractTasklet.java Wed May 29 15:26:02 2019 UTC
2 HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\batchprocess AbstractTasklet.java Mon Jun 10 19:19:21 2019 UTC

101.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 532
Changed 1 2
Inserted 0 0
Removed 0 0

101.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

101.4 Active regular expressions

No regular expressions were active.

101.5 Comparison detail

  1   /********* ********** ********** ********** ********** ********** *********
  2    * Copyrii ght 2008 V HA. All ri ghts reser ved
  3    ********* ********** ********** ********** ********** ********** *********/
  4   package go v.va.med.f w.batchpro cess;
  5  
  6   import jav a.io.Buffe redReader;
  7   import jav a.io.File;
  8   import jav a.io.FileR eader;
  9   import jav a.io.Filen ameFilter;
  10   import jav a.net.Inet Address;
  11   import jav a.util.Arr ayList;
  12   import jav a.util.Dat e;
  13   import jav a.util.Lis t;
  14  
  15   import org .apache.co mmons.lang .Validate;
  16   //import o rg.springf ramework.b atch.core. BatchStatu s;
  17   import org .springfra mework.bat ch.core.Ex itStatus;
  18   import org .springfra mework.bat ch.core.St epExecutio n;
  19   import org .springfra mework.bat ch.core.St epExecutio nListener;
  20   import org .springfra mework.bat ch.core.st ep.tasklet .Tasklet;
  21   import org .springfra mework.cor e.io.FileS ystemResou rce;
  22  
  23   import gov .va.med.fw .io.parser .WildcardF ileFilter;
  24   import gov .va.med.fw .model.bat chprocess. JobConfig;
  25   import gov .va.med.fw .service.A bstractCom ponent;
  26   import gov .va.med.fw .util.Stri ngUtils;
  27  
  28   /**
  29    * 
  30    * 
  31    * CISS ci ss_framewo rk Nov 19,  2008
  32    * 
  33    * @author   DNS
  34    */
  35   public abs tract clas s Abstract Tasklet ex tends Abst ractCompon ent implem ents StepE xecutionLi stener, Ta sklet {
  36  
  37           pr ivate Proc essStatist icsMailer  processSta tisticsMai ler = null ;
  38           pr ivate Proc essStatist ics proces sStatistic s = null;
  39           pr ivate Stri ng process Name = "Ba tchProcess ";
  40           pr ivate Batc hProcessSe rvice batc hProcessSe rvice;
  41  
  42           pu blic ExitS tatus afte rStep(Step Execution  stepExecut ion) {
  43                    proc essStatist ics.setPro cessingEnd Date(new D ate());
  44                    proc essStatist ics.setExe cutedOnSer ver(getSer verName()) ;
  45  
  46                    Exit Status exi tStatus =  stepExecut ion.getExi tStatus();
  47                    //Ba tchStatus  status = s tepExecuti on.getStat us();
  48                    if ( exitStatus  != null)  {
  49                             if ("C OMPLETED". equals(exi tStatus.ge tExitCode( ))) {              
  50                                      // send  email
  51                                      if (proc essStatist icsMailer  != null) {
  52                                               List<Strin g> address List = get EmailDistr ibutionLis t();
  53                                               if (addres sList == n ull || add ressList.s ize() == 0 ) {
  54                                                       pr ocessStati sticsMaile r.processS tatistics( processSta tistics);
  55                                               } else {
  56                                                       pr ocessStati sticsMaile r.processS tatisticsW ithDynamic Recipients (processSt atistics,
  57                                                                         addres sList);
  58                                               }
  59                                      }
  60                                      return c reateExist Status(Exi tStatus.CO MPLETED, p rocessStat istics.toF ormattedSt ring());
  61                             }
  62                             else i f ("FAILED ".equals(e xitStatus. getExitCod e())) {
  63                                      if (proc essStatist icsMailer  != null) {
  64                                               List<Strin g> address List = get EmailDistr ibutionLis t();
  65                                               if (addres sList == n ull || add ressList.s ize() == 0 ) {
  66                                                       pr ocessStati sticsMaile r.processF ailure(pro cessName,  null,null) ;
  67                                               } else {
  68                                                       pr ocessStati sticsMaile r.processF ailure(pro cessName,  null,addre ssList);
  69                                               }                
  70                                      }
  71                                      return c reateExist Status(Exi tStatus.FA ILED, proc essStatist ics.toForm attedStrin g());
  72                             }                         
  73                    }
  74                    retu rn stepExe cution.get ExitStatus ();
  75           }
  76  
  77           pu blic void  beforeStep (StepExecu tion arg0)  {
  78                    proc essStatist ics = new  ProcessSta tistics();
  79                    proc essStatist ics.setPro cessName(g etProcessN ame());
  80                    proc essStatist ics.setPro cessingSta rtDate(new  Date());
  81           }
  82  
  83           pu blic ExitS tatus onEr rorInStep( StepExecut ion arg0,  Throwable  arg1) {
  84                    if ( processSta tisticsMai ler != nul l) {
  85                             List<S tring> add ressList =  getEmailD istributio nList();
  86                             if (ad dressList  == null ||  addressLi st.size()  == 0) {
  87                                      processS tatisticsM ailer.proc essFailure (processNa me, arg1.g etMessage( ),null);
  88                             } else  {
  89                                      processS tatisticsM ailer.proc essFailure (processNa me, arg1.g etMessage( ),addressL ist);
  90                             }                
  91                    }
  92                    retu rn ExitSta tus.FAILED ;
  93           }
  94  
  95           pr otected Li st<String>  getEmailD istributio nList() {
  96                    try  {
  97                             JobCon fig jobCon fig = batc hProcessSe rvice.getJ obConfig(p rocessName , null);
  98                             if (jo bConfig !=  null && S tringUtils .isNotEmpt y(jobConfi g.getEmail Distributi onList()))  {
  99                                      String e mail = job Config.get EmailDistr ibutionLis t();
  100                                      String[]  addressli st = email .split("," );
  101                                      // trim  the spaces
  102                                      List<Str ing> list  = new Arra yList<Stri ng>();
  103                                      for (Str ing addres s : addres slist) {
  104                                               list.add(a ddress.tri m());
  105                                      }
  106                                      return l ist;
  107                             }
  108                    } ca tch (Excep tion e) {
  109                             // log  and ignor e
  110                             logger .error("Un able to ge t Job Conf iguration  for " + pr ocessName,  e);
  111                    }
  112                    retu rn null;
  113           }
  114  
  115           pu blic Strin g getProce ssName() {
  116                    retu rn process Name;
  117           }
  118  
  119           pu blic void  setProcess Name(Strin g processN ame) {
  120                    this .processNa me = proce ssName;
  121           }
  122  
  123           pu blic Proce ssStatisti cs getProc essStatist ics() {
  124                    if ( processSta tistics ==  null) {
  125                             proces sStatistic s = new Pr ocessStati stics();
  126                    }
  127                    retu rn process Statistics ;
  128           }
  129  
  130           pu blic void  setProcess Statistics (ProcessSt atistics p rocessStat istics) {
  131                    this .processSt atistics =  processSt atistics;
  132           }
  133  
  134           pu blic Proce ssStatisti csMailer g etProcessS tatisticsM ailer() {
  135                    retu rn process Statistics Mailer;
  136           }
  137  
  138           pu blic void  setProcess Statistics Mailer(Pro cessStatis ticsMailer  processSt atisticsMa iler) {
  139                    this .processSt atisticsMa iler = pro cessStatis ticsMailer ;
  140           }
  141  
  142           pu blic Batch ProcessSer vice getBa tchProcess Service()  {
  143                    retu rn batchPr ocessServi ce;
  144           }
  145  
  146           pu blic void  setBatchPr ocessServi ce(BatchPr ocessServi ce batchPr ocessServi ce) {
  147                    this .batchProc essService  = batchPr ocessServi ce;
  148           }
  149  
  150           pr otected st atic boole an isValid File(Strin g path) {
  151                    if ( StringUtil s.isNotEmp ty(path))  {
  152                             FileSy stemResour ce fileSys temResourc e = new Fi leSystemRe source(pat h);
  153                             if (fi leSystemRe source.exi sts() && f ileSystemR esource.is Readable() ) {
  154                                      return t rue;
  155                             }
  156                    }
  157                    retu rn false;
  158           }
  159  
  160           pr otected st atic boole an renameF ile(String  oldName,  String new Name) {
  161                    if ( StringUtil s.isNotEmp ty(oldName ) && Strin gUtils.isN otEmpty(ne wName)) {
  162                             File o ldFile = n ew File(ol dName);
  163                             File n ewFile = n ew File(ne wName);
  164                             return  oldFile.r enameTo(ne wFile);
  165                    }
  166                    retu rn false;
  167           }
  168  
  169           pr otected st atic List< String> ge tFileNameL ist(String  path) thr ows Except ion {
  170                    List <String> f iles = new  ArrayList <String>() ;
  171                    File nameFilter  inputFile Filter = n ull;
  172                    Stri ng inputFi leLocation  = path;
  173                    // d etermine t he file lo cation and  the filte r
  174                    if ( path.index Of("*") !=  -1) {
  175                             // Get  the last  index of f ile path s eparator ' /' or '\'i n the file
  176                             // loc ation
  177                             int la stIndex =  path.lastI ndexOf("/" );
  178                             if (la stIndex ==  -1)
  179                                      lastInde x = path.l astIndexOf ("\\");
  180  
  181                             inputF ileFilter  = new Wild cardFileFi lter(path. substring( lastIndex  + 1), true );
  182                             inputF ileLocatio n = path.s ubstring(0 , lastInde x);
  183                    }
  184  
  185                    File SystemReso urce fileS ystemResou rce = new  FileSystem Resource(i nputFileLo cation);
  186                    if ( fileSystem Resource.g etFile().i sDirectory ()) {
  187                             // fil ter the li st
  188                             String [] fileNam es = null;
  189                             if (in putFileFil ter != nul l) {
  190                                      fileName s = fileSy stemResour ce.getFile ().list(in putFileFil ter);
  191                             } else  {
  192                                      fileName s = fileSy stemResour ce.getFile ().list();
  193                             }
  194                             if (fi leNames !=  null && f ileNames.l ength > 0)  {
  195                                      for (int  i = 0; i  < fileName s.length;  i++) {
  196                                               FileSystem Resource f ileResourc e = new Fi leSystemRe source(fil eSystemRes ource
  197                                                                .get File().get AbsolutePa th()
  198                                                                + Fi le.separat or + fileN ames[i]);
  199                                               File file  = fileReso urce.getFi le();
  200                                               if (!file. isDirector y() && fil e.exists() ) {
  201                                                       fi les.add(fi le.getAbso lutePath() );
  202                                               }
  203                                      }
  204                             }
  205                    } el se if (fil eSystemRes ource.getF ile().exis ts()) {
  206                             files. add(fileSy stemResour ce.getFile ().getAbso lutePath() );
  207                    }
  208  
  209                    retu rn files;
  210           }
  211  
  212           pr otected Ex itStatus c reateExist Status(Exi tStatus ex itStatus,  String msg ) {
  213                    retu rn exitSta tus.addExi tDescripti on(msg);
  214           }
  215  
  216           /* *
  217            *  Size limi ted to 1MB
  218            *  
  219            *  @param fu llPathFile name
  220            *  @param ma xLength
  221            *  @return
  222            *  @throws E xception
  223            * /
  224           pr otected st atic Strin g readText File(Strin g fullPath Filename,  long maxLe ngth) thro ws Excepti on {
  225                    File  file = ne w File(ful lPathFilen ame);
  226                    if ( file.exist s() && fil e.canRead( )) {
  227                             
  228                             if (ma xLength <=  0)
  229                                      maxLengt h = 1024 *  1024;
  230                             String Builder sb  = new Str ingBuilder (1024);
  231                             Buffer edReader r eader = ne w Buffered Reader(new  FileReade r(fullPath Filename)) ;
  232                              //Add  try and f inalize to  fix Forti fy Issue
  233                             try {
  234                                      char[] c hars = new  char[1024 ];
  235                                      int size  = 0;
  236                                      int numR ead = 0;
  237                                      while (s ize < maxL ength && ( numRead =  reader.rea d(chars))  > -1) {
  238                                               sb.append( String.val ueOf(chars ));
  239                                               size += nu mRead;
  240                                      }
  241                                      reader.c lose();
  242           
  243                                      return s b.toString ();
  244                             }
  245                              final ly {
  246                                       reader. close();
  247                              }
  248                    } el se {
  249                             return  null;
  250                    }
  251           }
  252           
  253           pr ivate Stri ng getServ erName() {
  254                    try  {
  255                             return  InetAddre ss.getLoca lHost().ge tHostName( );
  256                    } ca tch (Excep tion e) {
  257                             return  "Unknown" ;
  258                    }
  259           }
  260           
  261           @O verride
  262           pu blic void  afterPrope rtiesSet()  throws Ex ception {
  263                    supe r.afterPro pertiesSet ();
  264                    // c heck for r equired pr operties
  265                    Vali date.notNu ll(batchPr ocessServi ce, "Requi red BatchP rocessServ ice is not  configure d");
  266           }
  267   }