122. 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.

122.1 Files compared

# Location File Last Modified
1 HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\batchprocess ProcessStatisticsMailer.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 ProcessStatisticsMailer.java Mon Jun 10 19:30:05 2019 UTC

122.2 Comparison summary

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

122.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

122.4 Active regular expressions

No regular expressions were active.

122.5 Comparison detail

  1   /********* ********** ********** ********** ********** ********** *********
  2    * Copyrii ght 2005 V HA. All ri ghts reser ved
  3    ********* ********** ********** ********** ********** ********** *********/
  4  
  5   package go v.va.med.f w.batchpro cess;
  6  
  7   import jav a.net.Inet Address;
  8   import jav a.util.Arr ayList;
  9   import jav a.util.Lis t;
  10  
  11   import org .apache.co mmons.lang .StringUti ls;
  12   import org .apache.co mmons.lang .Validate;
  13   import org .springfra mework.mai l.MailExce ption;
  14   import org .springfra mework.mai l.SimpleMa ilMessage;
  15  
  16   import gov .va.med.cc ht.util.ES APIValidat ionType;
  17   import gov .va.med.cc ht.util.ES APIValidat or;
  18   import gov .va.med.fw .mail.Mail Service;
  19   import gov .va.med.fw .service.A bstractCom ponent;
  20   import gov .va.med.fw .service.S erviceExce ption;
  21   import gov .va.med.fw .service.c onfig.Envi ronmentPar amService;
  22  
  23   /**
  24    * Initial  javadoc f or class P rocessStat isticsMail er. TODO -  Add conte nt here
  25    * 
  26    * Created  Feb 6, 20 06 9:43:08  AM
  27    * 
  28    * @author   DNS     DN S
  29    */
  30   public cla ss Process Statistics Mailer ext ends Abstr actCompone nt impleme nts Proces sStatistic sHandler {
  31           pu blic stati c String D EFAULT_SUB JECT_REPLA CEMENT_TOK EN = "@sub ject@";
  32           pu blic stati c String D EFAULT_APP _VERSION_R EPLACEMENT _TOKEN = " @appVersio n@";
  33           pu blic stati c String D EFAULT_APP _ENV_REPLA CEMENT_TOK EN = "@app Env@";
  34  
  35           pr ivate Mail Service ma ilService;
  36           pr ivate Simp leMailMess age messag eTemplate;
  37           pr ivate Simp leMailMess age failed MessageTem plate;
  38           pr ivate Stri ng subject Replacemen tToken = D EFAULT_SUB JECT_REPLA CEMENT_TOK EN;
  39           pr ivate bool ean ignore EmptyStati stics = fa lse;
  40           pr ivate Envi ronmentPar amService  environmen tParamServ ice = null ;
  41  
  42           pu blic void  processSta tistics(Pr ocessStati stics proc essStatist ics) {
  43                    proc essStatist ics(proces sStatistic s, process Statistics .getProces sName());
  44           }
  45  
  46           pu blic void  processSta tisticsWit hDynamicRe cipients(P rocessStat istics pro cessStatis tics,
  47                             List<S tring> ema ilRecipien ts) {
  48                    doPr ocessStati stics(proc essStatist ics, proce ssStatisti cs.getProc essName(),
  49                                      (String[ ]) emailRe cipients.t oArray(new  String[0] ));
  50           }
  51  
  52           pu blic void  processSta tistics(Pr ocessStati stics proc essStatist ics,
  53                             String  subjectRe placementV alue) {
  54                    doPr ocessStati stics(proc essStatist ics, subje ctReplacem entValue,  null);
  55           }
  56  
  57           pu blic void  processFai lure(Strin g processN ame, Strin g failureR eason, Lis t<String>  emailRecip ients)
  58           {
  59                    if ( emailRecip ients == n ull)
  60                             doProc essFailure Notificati on(process Name, fail ureReason,  null);
  61                    else
  62                             doProc essFailure Notificati on(process Name, 
  63                                      failureR eason, (St ring[]) em ailRecipie nts.toArra y(new Stri ng[0]));
  64           }
  65           
  66           /*
  67            *  (non-Java doc)
  68            *  
  69            *  @see
  70            *  gov.va.me d.fw.batch process.Pr ocessStati sticsHandl er#process Statistics
  71            *  (gov.va.m ed.fw.batc hprocess.P rocessStat istics)
  72            * /
  73           pr ivate void  doProcess Statistics (ProcessSt atistics p rocessStat istics,
  74                             String  subjectRe placementV alue, Stri ng[] dynam icEmailRec ipients) {
  75                    if ( ignoreEmpt yStatistic s && proce ssStatisti cs.getNumb erOfTotalR ecords() = = 0)
  76                             return ;
  77  
  78                    proc essStatist ics.setExe cutedOnSer ver(getSer verName()) ;
  79  
  80                    if ( messageTem plate.getT o() != nul l || dynam icEmailRec ipients !=  null) {
  81                             Simple MailMessag e template  = message Template;
  82                                              
  83                              //Fix  Fortify I ssues
  84                             ESAPIV alidator.v alidateStr ingInput(t emplate.ge tSubject() , ESAPIVal idationTyp e.EmailSub ject_White list);
  85                             
  86                             if (St ringUtils. isNotBlank (subjectRe placementT oken)
  87                                               && StringU tils.isNot Blank(mess ageTemplat e.getSubje ct())
  88                                               && message Template.g etSubject( ).indexOf( subjectRep lacementTo ken) != -1 ) {
  89                                      template  = new Sim pleMailMes sage(messa geTemplate );
  90                                      
  91                                      template .setSubjec t(template .getSubjec t().replac eFirst(sub jectReplac ementToken ,
  92                                                       su bjectRepla cementValu e));
  93                             }
  94  
  95                             if (th is.environ mentParamS ervice !=  null
  96                                               && StringU tils.isNot Blank(temp late.getSu bject()))  {
  97                                      if (temp late.getSu bject().in dexOf(DEFA ULT_APP_VE RSION_REPL ACEMENT_TO KEN) != -1 ) {
  98                                               String app Version =  getAppVers ion();
  99                                               if (String Utils.isNo tEmpty(app Version))
  100                                                       te mplate.set Subject(te mplate.get Subject(). replaceFir st(
  101                                                                         DEFAUL T_APP_VERS ION_REPLAC EMENT_TOKE N, appVers ion));
  102                                      }
  103  
  104                                      if (temp late.getSu bject().in dexOf(DEFA ULT_APP_EN V_REPLACEM ENT_TOKEN)  != -1) {
  105                                               String app Env = getD eployedEnv ironment() ;
  106                                               if (String Utils.isNo tEmpty(app Env))
  107                                                       te mplate.set Subject(te mplate.get Subject(). replaceFir st(
  108                                                                         DEFAUL T_APP_ENV_ REPLACEMEN T_TOKEN, a ppEnv));
  109                                      }
  110  
  111                             }
  112  
  113                             /**
  114                              * pro cess email ,addresses  injected  string nee ds to be s plit to
  115                              * ind ividual ad dresses
  116                              */
  117                             List<S tring> toA ddresses =  new Array List<Strin g>();
  118  
  119                             // use  passed-in  recipient s (if ther e)
  120                             if (dy namicEmail Recipients  != null & & dynamicE mailRecipi ents.lengt h > 0) {
  121                                      for (Str ing addres s : dynami cEmailReci pients)
  122                                               toAddresse s.add(addr ess);
  123                             }
  124                             // con vert injec ted string  of defaul t addresse s into a S tring[]
  125                             else i f (message Template.g etTo() !=  null && me ssageTempl ate.getTo( ).length >  0) {
  126                                      String[]  pList = S tringUtils .split(mes sageTempla te.getTo() [0], ",");
  127  
  128                                      for (Str ing addres s : pList)
  129                                               toAddresse s.add(addr ess);
  130                             }
  131                             // set  the addre sses
  132                             templa te.setTo(( String[])  toAddresse s.toArray( new String [] {}));
  133  
  134                             // don 't expose  exception  just becau se can not  send out  statistics
  135                             try {
  136                                      mailServ ice.send(p rocessStat istics.toF ormattedMa ilString() , template );
  137                             } catc h (MailExc eption e)  {
  138                                      logger
  139                                                       .e rror(
  140                                                                         "Unabl e to use m ailService  to send p rocess sta tistics... logging an d ignoring ",
  141                                                                         e);
  142                             }
  143                    } el se {
  144                             if (lo gger.isWar nEnabled() )
  145                                      logger
  146                                                       .w arn("Unabl e to email  ProcessSt atistics s ince there  is no rec ipients co nfigured/p assed-in") ;
  147                    }
  148           }
  149  
  150           
  151           pr ivate void  doProcess FailureNot ification( String sub jectReplac ementValue
  152                             String  failureRe ason, Stri ng[] dynam icEmailRec ipients) {
  153  
  154  
  155                    if ( failedMess ageTemplat e.getTo()  != null ||  dynamicEm ailRecipie nts != nul l) {
  156                             Simple MailMessag e template  = failedM essageTemp late;
  157                             
  158                       / /Fix Forti fy Issues
  159                             ESAPIV alidator.v alidateStr ingInput(t emplate.ge tSubject() , ESAPIVal idationTyp e.EmailSub ject_White list);
  160                             
  161                             if (St ringUtils. isNotBlank (subjectRe placementT oken)
  162                                               && StringU tils.isNot Blank(fail edMessageT emplate.ge tSubject() )
  163                                               && failedM essageTemp late.getSu bject().in dexOf(subj ectReplace mentToken)  != -1) {
  164                                      template  = new Sim pleMailMes sage(faile dMessageTe mplate);
  165                                      template .setSubjec t(template .getSubjec t().replac eFirst(sub jectReplac ementToken ,
  166                                                       su bjectRepla cementValu e));
  167                             }
  168  
  169                             if (th is.environ mentParamS ervice !=  null
  170                                               && StringU tils.isNot Blank(temp late.getSu bject()))  {
  171                                      if (temp late.getSu bject().in dexOf(DEFA ULT_APP_VE RSION_REPL ACEMENT_TO KEN) != -1 ) {
  172                                               String app Version =  getAppVers ion();
  173                                               if (String Utils.isNo tEmpty(app Version))
  174                                                       te mplate.set Subject(te mplate.get Subject(). replaceFir st(
  175                                                                         DEFAUL T_APP_VERS ION_REPLAC EMENT_TOKE N, appVers ion));
  176                                      }
  177  
  178                                      if (temp late.getSu bject().in dexOf(DEFA ULT_APP_EN V_REPLACEM ENT_TOKEN)  != -1) {
  179                                               String app Env = getD eployedEnv ironment() ;
  180                                               if (String Utils.isNo tEmpty(app Env))
  181                                                       te mplate.set Subject(te mplate.get Subject(). replaceFir st(
  182                                                                         DEFAUL T_APP_ENV_ REPLACEMEN T_TOKEN, a ppEnv));
  183                                      }
  184  
  185                             }
  186  
  187                             /**
  188                              * pro cess email ,addresses  injected  string nee ds to be s plit to
  189                              * ind ividual ad dresses
  190                              */
  191                             List<S tring> toA ddresses =  new Array List<Strin g>();
  192  
  193                             // use  passed-in  recipient s (if ther e)
  194                             if (dy namicEmail Recipients  != null & & dynamicE mailRecipi ents.lengt h > 0) {
  195                                      for (Str ing addres s : dynami cEmailReci pients)
  196                                               toAddresse s.add(addr ess);
  197                             }
  198                             // con vert injec ted string  of defaul t addresse s into a S tring[]
  199                             else i f (failedM essageTemp late.getTo () != null  && failed MessageTem plate.getT o().length  > 0) {
  200                                      String[]  pList = S tringUtils .split(fai ledMessage Template.g etTo()[0],  ",");
  201  
  202                                      for (Str ing addres s : pList)
  203                                               toAddresse s.add(addr ess);
  204                             }
  205                             // set  the addre sses
  206                             templa te.setTo(( String[])  toAddresse s.toArray( new String [] {}));
  207  
  208                             // don 't expose  exception  just becau se can not  send out  statistics
  209                             String  messageBo dy = 
  210                                      subjectR eplacement Value + "  execution  on server  " + 
  211                                      getServe rName() +  " failed.\ n" ;
  212                             if (St ringUtils. isNotEmpty (failureRe ason)) {
  213                                      messageB ody = mess ageBody +  "Reason: "  + message Body;
  214                             }
  215                             
  216                             
  217                             try {
  218                                      mailServ ice.send(m essageBody , template );
  219                             } catc h (MailExc eption e)  {
  220                                      logger
  221                                                       .e rror(
  222                                                                         "Unabl e to use m ailService  to send p rocess fai lure notif ication... logging an d ignoring ",
  223                                                                         e);
  224                             }
  225                    } el se {
  226                             if (lo gger.isWar nEnabled() )
  227                                      logger
  228                                                       .w arn("Unabl e to email  process f ailure not ification  since ther e is no re cipients c onfigured/ passed-in" );
  229                    }
  230           }        
  231           pr ivate Stri ng getAppV ersion() {
  232                    Stri ng appVers ion = Stri ngUtils.EM PTY;
  233                    if ( this.envir onmentPara mService ! = null) {
  234                             try {
  235                                      appVersi on = this. environmen tParamServ ice.getVer sion().get Version();
  236                             } catc h (Service Exception  e) {
  237                                      logger.e rror("Unab le to dete rmine Appl ication Ve rsion for  ProcessSta tisticsMai ler",
  238                                                       e) ;
  239                                      appVersi on = "";
  240                             }
  241                    }
  242                    retu rn appVers ion;
  243           }
  244  
  245           pr ivate Stri ng getDepl oyedEnviro nment() {
  246                    retu rn environ mentParamS ervice ==  null ? ""  : environm entParamSe rvice
  247                                      .getDepl oyedEnviro nment();
  248           }
  249  
  250           pr ivate Stri ng getServ erName() {
  251                    try  {
  252                             return  InetAddre ss.getLoca lHost().ge tHostName( );
  253                    } ca tch (Excep tion e) {
  254                             return  "Unknown" ;
  255                    }
  256           }
  257  
  258           pu blic void  afterPrope rtiesSet()  {
  259                    Vali date.notNu ll(mailSer vice, "A M ailService  is requir ed");
  260                    Vali date.notNu ll(message Template,  "A message Template i s required ");
  261           }
  262  
  263           /* *
  264            *  @return R eturns the  mailServi ce.
  265            * /
  266           pu blic MailS ervice get MailServic e() {
  267                    retu rn mailSer vice;
  268           }
  269  
  270           /* *
  271            *  @param ma ilService
  272            *              The mail Service to  set.
  273            * /
  274           pu blic void  setMailSer vice(MailS ervice mai lService)  {
  275                    this .mailServi ce = mailS ervice;
  276           }
  277  
  278           /* *
  279            *  @return R eturns the  messageTe mplate.
  280            * /
  281           pu blic Simpl eMailMessa ge getMess ageTemplat e() {
  282                    retu rn message Template;
  283           }
  284  
  285           /* *
  286            *  @param me ssageTempl ate
  287            *              The mess ageTemplat e to set.
  288            * /
  289           pu blic void  setMessage Template(S impleMailM essage mes sageTempla te) {
  290                    this .messageTe mplate = m essageTemp late;
  291           }
  292  
  293           pu blic Simpl eMailMessa ge getFail edMessageT emplate()  {
  294                    retu rn failedM essageTemp late;
  295           }
  296  
  297           pu blic void  setFailedM essageTemp late(Simpl eMailMessa ge failedM essageTemp late) {
  298                    this .failedMes sageTempla te = faile dMessageTe mplate;
  299           }
  300  
  301           /* *
  302            *  @return R eturns the  subjectRe placementT oken.
  303            * /
  304           pu blic Strin g getSubje ctReplacem entToken()  {
  305                    retu rn subject Replacemen tToken;
  306           }
  307  
  308           /* *
  309            *  @param su bjectRepla cementToke n
  310            *              The subj ectReplace mentToken  to set.
  311            * /
  312           pu blic void  setSubject Replacemen tToken(Str ing subjec tReplaceme ntToken) {
  313                    this .subjectRe placementT oken = sub jectReplac ementToken ;
  314           }
  315  
  316           /* *
  317            *  @return R eturns the  ignoreEmp tyStatisti cs.
  318            * /
  319           pu blic boole an isIgnor eEmptyStat istics() {
  320                    retu rn ignoreE mptyStatis tics;
  321           }
  322  
  323           /* *
  324            *  @param ig noreEmptyS tatistics
  325            *              The igno reEmptySta tistics to  set.
  326            * /
  327           pu blic void  setIgnoreE mptyStatis tics(boole an ignoreE mptyStatis tics) {
  328                    this .ignoreEmp tyStatisti cs = ignor eEmptyStat istics;
  329           }
  330  
  331           pu blic Envir onmentPara mService g etEnvironm entParamSe rvice() {
  332                    retu rn environ mentParamS ervice;
  333           }
  334  
  335           pu blic void  setEnviron mentParamS ervice(Env ironmentPa ramService  environme ntParamSer vice) {
  336                    this .environme ntParamSer vice = env ironmentPa ramService ;
  337           }
  338   }