188. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/9/2017 11:01:33 PM 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.

188.1 Files compared

# Location File Last Modified
1 PPS_N_3.0_Iter2_Build_360.zip\Unredacted\PS_PPS_srv\src\main\java\gov\va\med\pharmacy\peps\service\common\capability\impl RxNormUpdateCapabilityImpl.java Fri Jun 30 19:12:26 2017 UTC
2 PPS_N_3.0_Iter2_Build_360.zip\Unredacted\PS_PPS_srv\src\main\java\gov\va\med\pharmacy\peps\service\common\capability\impl RxNormUpdateCapabilityImpl.java Fri Jul 7 20:04:44 2017 UTC

188.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 5 728
Changed 4 8
Inserted 0 0
Removed 0 0

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

188.4 Active regular expressions

No regular expressions were active.

188.5 Comparison detail

  1   package go v.va.med.p harmacy.pe ps.service .common.ca pability.i mpl;
  2  
  3   import sta tic gov.va .med.pharm acy.peps.c ommon.util ity.securi ty.ESAPIVa lidationTy pe.LOG_FOR GING;
  4   import sta tic gov.va .med.pharm acy.peps.c ommon.util ity.securi ty.ESAPIVa lidator.va lidateStri ngInput;
  5  
  6   import gov .va.med.ph armacy.pep s.common.e mail.Email ;
  7   import gov .va.med.ph armacy.pep s.common.e mail.Email Service;
  8   import gov .va.med.ph armacy.pep s.common.v o.National Setting;
  9   import gov .va.med.ph armacy.pep s.common.v o.National SettingVo;
  10   import gov .va.med.ph armacy.pep s.common.v o.UserVo;
  11   import gov .va.med.ph armacy.pep s.domain.c ommon.capa bility.Nat ionalSetti ngDomainCa pability;
  12   import gov .va.med.ph armacy.pep s.domain.c ommon.mode l.EplProdu ctDo;
  13   import gov .va.med.ph armacy.pep s.domain.c ommon.util ity.RxNorm Capability ;
  14   import gov .va.med.ph armacy.pep s.service. common.cap ability.Rx NormUpdate Capability ;
  15   import gov .va.med.ph armacy.pep s.service. common.sch eduler.Pro cessStatus ;
  16  
  17   import jav a.security .cert.Cert ificateExc eption;
  18   import jav a.security .cert.X509 Certificat e;
  19   import jav a.util.Dat e;
  20   import jav a.util.Lis t;
  21   import jav a.util.con current.Ti meUnit;
  22  
  23   import jav ax.net.ssl .SSLContex t;
  24   import jav ax.net.ssl .TrustMana ger;
  25   import jav ax.net.ssl .X509Trust Manager;
  26  
  27   import org .apache.lo gging.log4 j.LogManag er;
  28   import org .apache.lo gging.log4 j.Logger;
  29   import org .springfra mework.bea ns.factory .annotatio n.Autowire d;
  30   import org .springfra mework.tra nsaction.P latformTra nsactionMa nager;
  31   import org .springfra mework.tra nsaction.T ransaction Definition ;
  32   import org .springfra mework.tra nsaction.T ransaction Status;
  33   import org .springfra mework.tra nsaction.a nnotation. Transactio nal;
  34   import org .springfra mework.tra nsaction.s upport.Def aultTransa ctionDefin ition;
  35  
  36   /**
  37    * This cl ass is the  main impl ementation  that mana ges the Rx Norm updat e process
  38    * 
  39    * @author   DNS    DN S
  40    *
  41    */
  42   public cla ss RxNormU pdateCapab ilityImpl  implements  RxNormUpd ateCapabil ity {
  43       
  44       privat e static f inal Logge r LOG = Lo gManager.g etLogger(R xNormUpdat eCapabilit yImpl.clas s);
  45       privat e National SettingDom ainCapabil ity nation alSettingD omainCapab ility;
  46       privat e RxNormCa pability r xNormCapab ility;
  47       privat e static f inal int T IMEOUT = 2 00;
  48       privat e static f inal int L ONG_TIMEOU T = 1200;
  49       
  50       @Autow ired
  51       privat e Platform Transactio nManager t ransaction Manager;     
  52       
  53       @Autow ired
  54       privat e EmailSer vice email Service;
  55  
  56  
  57       /* (no n-Javadoc)
  58        * @se e gov.va.m ed.pharmac y.peps.ser vice.commo n.capabili ty.RxNormU pdateCapab ility#proc ess(gov.va .med.pharm acy.peps.c ommon.vo.U serVo)
  59        */
  60       public  void proc ess(UserVo  user) {
  61          
  62           tr y {
  63                updateJo bStatusToR unning(use r);
  64                
  65                List<Epl ProductDo>  products  = fetchRxN ormUpdateP roducts();
  66                
  67                processP roducts(us er, produc ts);
  68                
  69                updateJo bStatusToC ompleted(u ser);
  70                
  71           }  catch (Exc eption e)  {
  72                    e.pr intStackTr ace();
  73                    LOG. error("Exc eption in  RxNormUpda teCapabili tyImpl.pro cess()  "  + validate StringInpu t(e.getMes sage(), LO G_FORGING) , e);
  74                    if ( e.getCause () != null ) {
  75                         LOG.error( "The Under lying caus e is " + e .getCause( ).getMessa ge(), e);
  76                    }
  77                updateJo bStatusToE rror(user) ;
  78           }
  79       }
  80  
  81       
  82           /* *
  83            *  Calls the  RxNorm do main capab ility to f etch and r eturn a li st of EPL  Product ob jects that  are enabl ed
  84            *  for rxNor m updates
  85            *  
  86            *  @return t he list of  EPL Produ ct objects  to proces s
  87            * /
  88       @Trans actional(n oRollbackF orClassNam e="java.la ng.Excepti on")   
  89           pr ivate List <EplProduc tDo> fetch RxNormUpda teProducts () {
  90                    Defa ultTransac tionDefini tion def;
  91                    Tran sactionSta tus status ;
  92                    def  = new Defa ultTransac tionDefini tion(Trans actionDefi nition.PRO PAGATION_R EQUIRES_NE W);
  93                    def. setTimeout (LONG_TIME OUT);
  94                    stat us = trans actionMana ger.getTra nsaction(d ef);
  95                    
  96                    List <EplProduc tDo> produ cts = rxNo rmCapabili ty.fetchRx NormUpdate Products() ;
  97                    tran sactionMan ager.commi t(status);
  98                    
  99                    retu rn product s;
  100           }
  101  
  102           /* *
  103            *  Updates t he RxNorm  job status  to Error
  104            *  
  105            *  @param us er
  106            *  @param e
  107            * /
  108       @Trans actional(n oRollbackF orClassNam e="java.la ng.Excepti on")   
  109           pr ivate void  updateJob StatusToEr ror(UserVo  user) {
  110                    Defa ultTransac tionDefini tion def;
  111                    Tran sactionSta tus status ;
  112                    def  = new Defa ultTransac tionDefini tion(Trans actionDefi nition.PRO PAGATION_R EQUIRES_NE W);
  113                    def. setTimeout (TIMEOUT);
  114                    stat us = trans actionMana ger.getTra nsaction(d ef);
  115                    
  116                    upda teStatus(P rocessStat us.ERROR,  user);
  117                    
  118                    tran sactionMan ager.commi t(status);
  119           }
  120  
  121           /* *
  122            *  This meth od iterate s thru a l ist of pro ducts, cre ates a new  transacti on for eac h product,  and passe s processi ng 
  123            *  down into  the popul ate and pe rsist meth od of the  RxNorm dom ain capabi lity objec t.
  124            *  @param us er
  125            *  @param pr oducts the  list of p roducts to  send to r xnorm
  126            * /    
  127           pr ivate void  processPr oducts(Use rVo user,  List<EplPr oductDo> p roducts) {                  
  128                    trus tSelfSigne dSSL();
  129                    Date  runDate =  new Date( );
  130                    for  (EplProduc tDo produc t : produc ts) {
  131             
  132                             proces sEachProdu ct(user, p roduct, ru nDate);
  133                // Delay  for 100 m illisecond s so that  we never s end more t han 10 per  second
  134                try {
  135                    Time Unit.MILLI SECONDS.sl eep(100);
  136                } catch( Interrupte dException  ie) {
  137                    //ig nore
  138                }
  139           }
  140           }
  141  
  142       /**
  143        * Pro cesses eac h product
  144        * @pa ram user
  145        * @pa ram produc tDo
  146        * @pa ram runDat e
  147        */
  148                @Transac tional           
  149       privat e void pro cessEachPr oduct(User Vo user, E plProductD o productD o, Date ru nDate){
  150                  
  151                  Defaul tTransacti onDefiniti on def = n ew Default Transactio nDefinitio n(Transact ionDefinit ion.PROPAG ATION_REQU IRED);
  152                  Transa ctionStatu s status =  transacti onManager. getTransac tion(def);                
  153              def.setTim eout(TIMEO UT);
  154              rxNormCapa bility.pop ulateAndPe rsist(user , productD o, runDate );
  155              // Job com pletes nor mally
  156              transactio nManager.c ommit(stat us);
  157       }
  158       
  159           /* *
  160            *  Updates t he RxNorm  job status  to Comple ted
  161            *  
  162            *  @param us er
  163            * /
  164       @Trans actional(n oRollbackF orClassNam e="java.la ng.Excepti on")   
  165           pr ivate void  updateJob StatusToCo mpleted(Us erVo user)  {
  166                    Defa ultTransac tionDefini tion def;
  167                    Tran sactionSta tus status ;
  168                    def  = new Defa ultTransac tionDefini tion(Trans actionDefi nition.PRO PAGATION_R EQUIRES_NE W);
  169                    def. setTimeout (TIMEOUT);
  170                    stat us = trans actionMana ger.getTra nsaction(d ef);
  171                        
  172                    upda teStatus(P rocessStat us.COMPLET ED, user);
  173                    upda teRuntime( user);
  174      
  175                    tran sactionMan ager.commi t(status);
  176           }
  177  
  178           /* *
  179            *  Updates t he RxNorm  job status  to Runnin g
  180            *  
  181            *  @param us er
  182            * /
  183       @Trans actional(n oRollbackF orClassNam e="java.la ng.Excepti on")   
  184           pr ivate void  updateJob StatusToRu nning(User Vo user) {
  185                    Defa ultTransac tionDefini tion def;
  186                    Tran sactionSta tus status ;
  187                    def  = new Defa ultTransac tionDefini tion(Trans actionDefi nition.PRO PAGATION_R EQUIRES_NE W);
  188                    def. setTimeout (TIMEOUT);
  189                    stat us = trans actionMana ger.getTra nsaction(d ef);
  190  
  191                    LOG. info("---- ---------- -processin g RXNORM U pdate----- ---------- ----");
  192                    
  193                    upda teStatus(P rocessStat us.RUNNING , user);
  194                    
  195                    tran sactionMan ager.commi t(status);
  196           }
  197    
  198       /**
  199        * The  updateRun time metho d will upd ate the Rx Norm Updat e run stat us. 
  200        * @pa ram proces sStatus Pr ocessStatu s
  201        */
  202       privat e void upd ateStatus( ProcessSta tus proces sStatus, U serVo user ) {
  203  
  204           //  This code  can be re placed wit h ProcessS tatusUpdat er.
  205           Na tionalSett ingVo retu rnedSettin g = nation alSettingD omainCapab ility.retr ieve(Natio nalSetting .RXNORM_UP DATE_RUN_S TATE.toStr ing());
  206  
  207           re turnedSett ing.setStr ingValue(p rocessStat us.toStrin g());
  208           na tionalSett ingDomainC apability. update(ret urnedSetti ng, user);
  209       }
  210  
  211       /**
  212        * The  updateRun time metho d will upd ate the Rx Norm Updat e runtime  date. 
  213        */
  214       privat e void upd ateRuntime (UserVo us er) {
  215  
  216           //  This code  can be re placed wit h ProcessS tatusUpdat er.
  217           Na tionalSett ingVo retu rnedSettin g = nation alSettingD omainCapab ility.retr ieve(Natio nalSetting .RXNORM_UP DATE_LAST_ RUN.toStri ng());
  218  
  219           re turnedSett ing.setDat eValue(new  Date());
  220           na tionalSett ingDomainC apability. update(ret urnedSetti ng, user);
  221       }
  222       
  223       
  224       /**
  225        * get s the Tran sactionMan ager for R xNormUpdat eCapabilit yImpl.
  226        * @re turn the t ransaction Manager
  227        */
  228       public  PlatformT ransaction Manager ge tTransacti onManager( ) {
  229           re turn trans actionMana ger;
  230       }
  231  
  232       /**
  233        * set s the Tran sactionMan ager for R xNormUpdat eCapabilit yImpl.
  234        * @pa ram transa ctionManag er the tra nsactionMa nager to s et
  235        */
  236       public  void setT ransaction Manager(Pl atformTran sactionMan ager trans actionMana ger) {
  237           th is.transac tionManage r = transa ctionManag er;
  238       }
  239       
  240       /**
  241        * set NationalSe ttingDomai nCapabilit y in Propo sedInactiv ateCapabil ityImpl.
  242        * @pa ram nation alSettingD omainCapab ility the  nationalSe ttingDomai nCapabilit y to set
  243        */
  244       public  void setN ationalSet tingDomain Capability (NationalS ettingDoma inCapabili ty
  245                                                           nationalS ettingDoma inCapabili ty) {
  246           th is.nationa lSettingDo mainCapabi lity = nat ionalSetti ngDomainCa pability;
  247       }
  248       
  249       /**
  250        * Get s the rx n orm capabi lity.
  251        * @re turn the r x norm cap ability
  252        */
  253       public  RxNormCap ability ge tRxNormCap ability()  {
  254           re turn rxNor mCapabilit y;
  255       }
  256       /**
  257        * Set s the rx n orm capabi lity.
  258        * @pa ram rxNorm Capability  the new r x norm cap ability
  259        */
  260       public  void setR xNormCapab ility(RxNo rmCapabili ty rxNormC apability)  {
  261           th is.rxNormC apability  = rxNormCa pability;
  262       }
  263       
  264       
  265       /**
  266        * @re turn the e mailServic e
  267        */
  268       public  EmailServ ice getEma ilService( ) {
  269           re turn email Service;
  270       }
  271  
  272       
  273       /**
  274        * @pa ram emailS ervice the  emailServ ice to set
  275        */
  276       public  void setE mailServic e(EmailSer vice email Service) {
  277           th is.emailSe rvice = em ailService ;
  278       }
  279       
  280       
  281       /**
  282        * Sen ds text em ail notifi cation.
  283        * 
  284        * @pa ram toEmai lIds
  285        * @pa ram emailS ubject
  286        * @pa ram emailM essage
  287        */
  288       privat e void sen dEmailNoti fication(L ong status , String f ilename) {
  289           St ring toEma ilIds = nu ll;  
  290           St ring email Subject =  null;
  291           St ring email Message =  null;
  292           
  293           if (status ==  3  ){                        
  294                // For S QA
  295                toEmailI ds =" PII                                                                                             "; 
  296                emailSub ject="Upda te File Tr ansmitted  to Test FT P - " + fi lename;
  297                emailMes sage="\n\n  Transmiss ion of the  Created f ile " + fi lename + "  to the te st FTP loc ation has  been compl eted.";
  298                
  299            }         
  300           el se if(stat us == 8){
  301                toEmailI ds =" PII                                 " ;
  302                emailSub ject="Upda te File Tr ansmitted  to Product ion FTP -  " + filena me;
  303                emailMes sage="\n\n  Transmiss ion of the  approved  file " + f ilename +  " to the p roduction  FTP locati on has bee n complete d.";
  304           }
  305           
  306           tr y {
  307                           
  308                Email em ailBean =  new Email( );
  309                
  310                /*
  311                   * Need to  set to in  another wa   by convert ing to an  array as s etting add resses lik PII                PII                
  312                 * Gives  error by  javax mail  Address P arser.
  313                 */
  314                String[]  toEmailId  = new Str ing[]{""};
  315                
  316                // if to EmailIdStr  string is  a comma s eparated s tring then  split it.  
  317                if(null! =toEmailId s && toEma ilIds.leng th()>0)
  318                {
  319                    toEm ailId = to EmailIds.s plit(",");
  320                }                
  321                                      
  322                emailBea n.setTo(to EmailId);         
  323                emailBea n.setSubje ct(emailSu bject);         
  324                emailBea n.setEmail Message(em ailMessage );
  325                
  326                emailSer vice.sendE mail(email Bean);
  327                   
  328           }  catch (Exc eption e)  {
  329                LOG.erro r("Error i n sendEmai lNotificat ion ", e);
  330           }
  331       }    
  332      
  333       /*
  334        * Thi s method i s used to  bypass the  SSL certi ficate che cking. 
  335        * TOD O: We need  to work w ith the IS AAC group  to get the  correct c ertificate s
  336        */
  337       public  static vo id trustSe lfSignedSS L() {
  338         try  {
  339              //SSLConte xt ctx = S SLContext. getInstanc e("TLS");
  340              SSLContext  ctx = SSL Context.ge tInstance( "TLS");
  341              X509TrustM anager tm  = new X509 TrustManag er() {
  342  
  343           @O verride
  344           pu blic void  checkClien tTrusted(X 509Certifi cate[] cha in, String  authType)  throws Ce rtificateE xception {
  345              // TODO Au to-generat ed method  stub
  346             
  347           }
  348  
  349           @O verride
  350           pu blic void  checkServe rTrusted(X 509Certifi cate[] cha in, String  authType)  throws Ce rtificateE xception {
  351              // TODO Au to-generat ed method  stub
  352             
  353           }
  354  
  355           @O verride
  356           pu blic X509C ertificate [] getAcce ptedIssuer s() {
  357              // TODO Au to-generat ed method  stub
  358              return nul l;
  359           }
  360              };
  361              ctx.init(n ull, new T rustManage r[]{(Trust Manager) t m}, null);
  362              SSLContext .setDefaul t(ctx);
  363         } ca tch (Excep tion ex) {
  364              ex.printSt ackTrace() ;
  365         }
  366     }
  367       
  368   }