40. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:35 PM Central Standard 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.

40.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\BaseWebFacade\main\src\java\gov\va\med\imaging TimerFilter.java Mon Dec 4 21:34:28 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\BaseWebFacade\main\src\java\gov\va\med\imaging TimerFilter.java Mon Dec 4 21:57:09 2017 UTC

40.2 Comparison summary

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

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

40.4 Active regular expressions

No regular expressions were active.

40.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging;
  5  
  6   import jav a.io.*;
  7   import jav a.text.Dat eFormat;
  8   import jav a.text.Sim pleDateFor mat;
  9   import jav a.util.con current.Ex ecutorServ ice;
  10   import jav a.util.con current.Ex ecutors;
  11   import jav a.util.con current.Th readFactor y;
  12   import jav a.util.con current.Ti meUnit;
  13  
  14   import jav ax.servlet .*;
  15   import jav ax.servlet .http.Http ServletReq uest;
  16  
  17   import org .apache.lo gging.log4 j.Logger;
  18   import org .apache.lo gging.log4 j.LogManag er;
  19  
  20   /**
  21    * @author         
BECKEC
  22    *
  23    */
  24   public cla ss TimerFi lter
  25   implements  Filter
  26   {
  27           pr ivate Logg er logger  = LogManag er.getLogg er(this.ge tClass());  
  28           pu blic final  static St ring outpu tFilename  = "TimerFi lter.csv";
  29           pu blic final  static St ring heade rLine = "r equest-ide ntifier,re quest-time ,response- time,durat ion";
  30           pr ivate Writ er writer;
  31           pr ivate Exec utorServic e executor ;
  32           pr ivate Stri ng dateFor mat = "yyy y-MM-dd:hh :mm:ss:SSS S";
  33  
  34           pr ivate Writ er getWrit er()
  35           {
  36                    File  outFile;
  37                    bool ean writeH eaderLine  = false;
  38                    
  39                    File  dir = new  File(Syst em.getenv( "vixconfig "));
  40                    dir. mkdirs();
  41                    outF ile = new  File(dir,  outputFile name);
  42                    logg er.debug(" writing to  '" + outF ile.getAbs olutePath( ) + "'.");
  43                    
  44                    if(!  outFile.e xists())
  45                             writeH eaderLine  = true;
  46                    
  47                    Outp utStreamWr iter write r = null;
  48                    
  49                    try
  50                    {
  51                             writer  = new Out putStreamW riter( new  FileOutpu tStream(ou tFile, tru e) );
  52                    } 
  53                    catc h (FileNot FoundExcep tion x)
  54                    {
  55                             writer  = new Out putStreamW riter( Sys tem.out );
  56                    }
  57                    
  58                    if(w riteHeader Line)
  59                             try
  60                             {
  61                                      writer.w rite(heade rLine + "\ n");
  62                                      writer.f lush();
  63                             } 
  64                             catch  (IOExcepti on x)
  65                             {
  66                                      logger.e rror("Erro r writing  header lin e to timer  file", x) ;
  67                             }
  68                    
  69                    retu rn writer;
  70           }
  71           
  72           /*  (non-Java doc)
  73            *  @see java x.servlet. Filter#ini t(javax.se rvlet.Filt erConfig)
  74            * /
  75           pu blic void  init(Filte rConfig co nfig) thro ws Servlet Exception
  76           {
  77                    writ er = getWr iter();
  78                    exec utor = Exe cutors.new SingleThre adExecutor (new Threa dFactory()
  79                    {
  80                             public  Thread ne wThread(Ru nnable r)
  81                             {
  82                                      Thread t hread = ne w Thread(r );
  83                                      thread.s etName("ti mer-filter -log-write r");
  84                                      //thread .setPriori ty(Thread. NORM_PRIOR ITY-1);
  85                                      
  86                                      return t hread;
  87                             }
  88                             
  89                    });
  90           }
  91           
  92           /*  (non-Java doc)
  93            *  @see java x.servlet. Filter#doF ilter(java x.servlet. ServletReq uest, java x.servlet. ServletRes ponse, jav ax.servlet .FilterCha in)
  94            * /
  95           pu blic void  doFilter(S ervletRequ est reques t, Servlet Response r esponse, F ilterChain  chain) 
  96           th rows IOExc eption, Se rvletExcep tion
  97           {
  98                    Thre adLocal<Lo ng> reques tTime = ne w ThreadLo cal<Long>( );
  99                    requ estTime.se t( new Lon g(System.c urrentTime Millis())  );
  100                    
  101                    chai n.doFilter (request,  response);
  102                    
  103                    Stri ng request Identifier  = null;
  104                    
  105                    if(r equest ins tanceof Ht tpServletR equest)
  106                    {
  107                             HttpSe rvletReque st httpReq uest = (Ht tpServletR equest)req uest;
  108                             String  imageUrn  = httpRequ est.getPar ameter("im ageURN");  // was ima geUrn - DK B
  109                             if (im ageUrn !=  null) // i mage reque st
  110                             {
  111                                      boolean  vaImage =  imageUrn.i ndexOf("va image") >=  0;
  112                                      boolean  dodImage =  imageUrn. indexOf("d odimage")  >= 0;
  113                                      
  114                                      requestI dentifier  = httpRequ est.getReq uestURI() 
  115                                               (vaImage ?  "-vaimage " : null)  +
  116                                               (dodImage  ? "-dodima ge" : null );
  117                             }
  118                             else / / web serv ice reques t
  119                             {
  120                                      requestI dentifier  = request. getRemoteH ost() + ": " + reques t.getRemot ePort();                               
  121                             }
  122                    }
  123                    else  // TODO:  When is th is ever be ing execut ed? DKB
  124                    {
  125                             reques tIdentifie r = reques t.getRemot eHost() +  ":" + requ est.getRem otePort();
  126                    }
  127                    writ eTimerLog( ((Long)req uestTime.g et()).long Value(), S ystem.curr entTimeMil lis(), req uestIdenti fier);
  128                    
  129                    requ estTime.re move();
  130           }
  131  
  132           /*  (non-Java doc)
  133            *  @see java x.servlet. Filter#des troy()
  134            * /
  135           pu blic void  destroy()
  136           {
  137                    try
  138                    {
  139                             try
  140                             {
  141                                      executor .shutdown( );
  142                                      executor .awaitTerm ination(10 , TimeUnit .SECONDS);
  143                             } 
  144                             catch  (Interrupt edExceptio n x)
  145                             {
  146                                      x.printS tackTrace( );
  147                             }
  148                             writer .flush();
  149                             writer .close();
  150                    } 
  151                    catc h (IOExcep tion x)
  152                    {
  153                             x.prin tStackTrac e();
  154                    }
  155           }
  156  
  157           pr ivate void  writeTime rLog(long  requestTim e, long re sponseTime , String r equestIden tifier)
  158           {
  159                    logg er.debug(" writeTimer Log(" + re questTime  + "," + re sponseTime  + "," + r equestIden tifier + " )");
  160                    
  161                    Time rLogEntry  logEntry =  new Timer LogEntry(r equestTime , response Time, requ estIdentif ier);
  162                    
  163                    Time rLogEntryT ask task =  new Timer LogEntryTa sk(logEntr y);
  164                    exec utor.submi t(task);
  165           }
  166           
  167           cl ass TimerL ogEntry
  168           {
  169                    priv ate long r equestTime ;
  170                    priv ate long r esponseTim e;
  171                    priv ate String  requestId entifier;
  172                    
  173                    Time rLogEntry( long reque stTime, lo ng respons eTime, Str ing reques tIdentifie r)
  174                    {
  175                             this.r equestTime  = request Time;
  176                             this.r esponseTim e = respon seTime;
  177                             this.r equestIden tifier = r equestIden tifier;
  178                    }
  179  
  180                    publ ic long ge tRequestTi me()
  181                    {
  182                             return  this.requ estTime;
  183                    }
  184  
  185                    publ ic long ge tResponseT ime()
  186                    {
  187                             return  this.resp onseTime;
  188                    }
  189  
  190                    publ ic String  getRequest Identifier ()
  191                    {
  192                             return  this.requ estIdentif ier;
  193                    }
  194           }
  195           
  196           cl ass TimerL ogEntryTas k
  197           im plements R unnable
  198           {
  199                    priv ate TimerL ogEntry en try;
  200                    Time rLogEntryT ask(TimerL ogEntry en try)
  201                    {
  202                             this.e ntry = ent ry;
  203                    }
  204                    
  205                    publ ic void ru n()
  206                    {
  207                             DateFo rmat df =  new Simple DateFormat (dateForma t);
  208                             String Buffer sb  = new Stri ngBuffer() ;
  209                             sb.app end(entry. getRequest Identifier ());
  210                             sb.app end(',');
  211                             sb.app end( df.fo rmat(entry .getReques tTime()) ) ;
  212                             sb.app end(',');
  213                             sb.app end( df.fo rmat(entry .getRespon seTime())  );
  214                             sb.app end(',');
  215                             sb.app end( entry .getRespon seTime() -  entry.get RequestTim e() );
  216                             
  217                             System .out.print ln("Writin g TimerLog Entry(" +  sb.toStrin g() + ")") ;
  218                             
  219                             try
  220                             {
  221                                      writer.w rite(sb.to String());
  222                                      writer.w rite("\n") ;
  223                                      writer.f lush();
  224                             } 
  225                             catch  (IOExcepti on x)
  226                             {
  227                                      x.printS tackTrace( );
  228                             }
  229                    }
  230           }
  231   }