1970. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/18/2019 5:56:03 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.

1970.1 Files compared

# Location File Last Modified
1 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_Vistalink\VAVistaLinkServer\src\main\java\gov\va\tas\nettyrest\netty ServerHandler.java Wed Apr 3 02:27:48 2019 UTC
2 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_Vistalink\VAVistaLinkServer\src\main\java\gov\va\tas\nettyrest\netty ServerHandler.java Wed Apr 17 17:32:17 2019 UTC

1970.2 Comparison summary

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

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

1970.4 Active regular expressions

No regular expressions were active.

1970.5 Comparison detail

  1   /********* ********** ********** ********** ********** ********** ********** *;
  2   * Project             : MCCF
  3   * Program  name       : ServerHa ndler.java
  4   * Author              : Tony L.  Howard
  5   * Date cre ated       : 20180601
  6   * Purpose             : Used to  setup a re quest and  process a  response 
  7   *                                             for the  requested  API 
  8   * Revision  History   :
  9   * Date         Author       Ref     Revisio n (Date in  YYYYMMDD  format) 
  10   * 20100601     howard tl    1       Intial  Creation 
  11   ********** ********** ********** ********** ********** ********** ********** /
  12  
  13   package go v.va.tas.n ettyrest.n etty;
  14  
  15   import sta tic io.net ty.handler .codec.htt p.HttpHead erNames.CO NNECTION;
  16   import sta tic io.net ty.handler .codec.htt p.HttpHead erNames.CO NTENT_TYPE ;
  17   import sta tic io.net ty.handler .codec.htt p.HttpHead erNames.TR ANSFER_ENC ODING;
  18   import sta tic io.net ty.handler .codec.htt p.HttpResp onseStatus .CONTINUE;
  19   import sta tic io.net ty.handler .codec.htt p.HttpVers ion.HTTP_1 _1;
  20  
  21   import jav a.net.Inet SocketAddr ess;
  22   import jav a.net.Sock etAddress;
  23   import jav a.util.Arr ays;
  24  
  25   import gov .va.tas.ne ttyrest.re sponse.Inf o;
  26   import gov .va.tas.ne ttyrest.re sponse.Res ult;
  27   import io. netty.hand ler.codec. http.*;
  28   import org .apache.co mmons.pool .impl.Gene ricKeyedOb jectPool;
  29   import gov .va.tas.ne ttyrest.Ap iHandler;
  30   import gov .va.tas.vi stalink.Vi staLinkRpc Connection ;
  31   import io. netty.buff er.Unpoole d;
  32   import io. netty.chan nel.Channe lFutureLis tener;
  33   import io. netty.chan nel.Channe lHandlerAd apter;
  34   import io. netty.chan nel.Channe lHandlerCo ntext;
  35   import io. netty.hand ler.codec. AsciiStrin g;
  36   import io. netty.util .internal. logging.In ternalLogg er;
  37   import io. netty.util .internal. logging.Lo g4JLoggerF actory;
  38   import org .json.JSON Object;
  39  
  40   public cla ss ServerH andler ext ends Chann elHandlerA dapter {
  41           pu blic stati c int port Number = 1 0009;
  42           pr ivate stat ic final I nternalLog ger LOGGER  = Log4JLo ggerFactor y.getInsta nce(Server Handler.cl ass);
  43           pr ivate Gene ricKeyedOb jectPool<S tring, Vis taLinkRpcC onnection>  oPool = n ull;
  44           pr ivate int  oPort = 0;
  45  
  46           pu blic Gener icKeyedObj ectPool<St ring, Vist aLinkRpcCo nnection>  getoPool()  {
  47                    retu rn oPool;
  48           }
  49  
  50           pu blic void  setoPool(G enericKeye dObjectPoo l<String,  VistaLinkR pcConnecti on> oPool2 ) {
  51                    this .oPool = o Pool2;
  52           }
  53           
  54           pu blic int g etoPort()  {
  55                    retu rn this.oP ort;
  56           }
  57  
  58           pu blic void  setoPort(i nt oPort)  {
  59                    this .oPort = o Port;
  60           }
  61  
  62           pu blic Serve rHandler(G enericKeye dObjectPoo l<String,  VistaLinkR pcConnecti on> oPool2 , int oPor t2) {
  63                    seto Pool(oPool 2);
  64                    seto Port(oPort 2);       
  65           }
  66  
  67  
  68           @O verride
  69       public  void chan nelReadCom plete(Chan nelHandler Context ct x) {
  70           ct x.flush();
  71       }
  72  
  73       @Overr ide
  74       public  void chan nelRead(Ch annelHandl erContext  ctx, Objec t msg) {
  75           LO GGER.debug (" Channel  Read");
  76  
  77           if  (msg inst anceof Htt pRequest)  {
  78  
  79                long sta rt = -1;
  80                if (LOGG ER.isDebug Enabled())  {
  81                    star t = System .currentTi meMillis() ;
  82                }
  83  
  84                HttpRequ est req =  (HttpReque st) msg;
  85  
  86                if (LOGG ER.isDebug Enabled())  {
  87                    LOGG ER.debug(" Message re ceived at  URI: " + r eq.uri());
  88                    LOGG ER.debug(" Message re ceived usi ng message : " + req. method());
  89                    LOGG ER.debug(" Protocol v ersion of  message: "  + req.pro tocolVersi on());
  90                    Http Headers h  = req.head ers();
  91                    h.fo rEach(e ->  LOGGER.de bug("Heade r entry ke y: " + e.g etKey() +  " Header e ntry value : " +  e.g etValue()) );
  92                }
  93  
  94                if (Http HeaderUtil .is100Cont inueExpect ed(req)) {
  95                    ctx. write(new  DefaultFul lHttpRespo nse(HTTP_1 _1, CONTIN UE));
  96                }
  97                            
  98                boolean  keepAlive  = HttpHead erUtil.isK eepAlive(r eq);
  99                
  100                // Socke tAddress i s for Test ing Only
  101                  int  PORT  =  P ;
  102                if (ctx. channel(). localAddre ss() insta nceof Sock etAddress)  {
  103                    try  {
  104                             port =  ((InetSoc ketAddress )ctx.chann el().local Address()) .getPort() ;
  105                    } ca tch (Excep tion e) {
  106                             LOGGER .error("%s  error: %s  \n\n%s",
  107                                 e. getClass() .getSimple Name(), e. getMessage (), Arrays .toString( e.getStack Trace()));
  108                    }
  109                    if ( port == 0)  {
  110                             port =  portNumbe r;
  111                             LOGGER .debug(Str ing.format ("Setting  Default So cket Addre ss Port: % s", port)) ;
  112                    }
  113                } else {
  114                    port  = ((InetS ocketAddre ss)ctx.cha nnel().loc alAddress( )).getPort ();
  115                }
  116                
  117                LOGGER.d ebug(Strin g.format(" Port: %s",  port));
  118  
  119                Result<I nfo> resul tObject =  ApiHandler .transfer( msg, this. oPool,port );
  120                HttpResp onseStatus  status =  HttpRespon seStatus.v alueOf(res ultObject. getInfo(). getCode()) ;
  121  
  122                byte[] r esultBytes  = encode( resultObje ct);
  123  
  124                FullHttp Response r esponse =
  125                         new Defaul tFullHttpR esponse(HT TP_1_1, st atus, Unpo oled.wrapp edBuffer(r esultBytes ));
  126                
  127                response .headers() .set(CONTE NT_TYPE,ne w AsciiStr ing("appli cation/jso n; charset =utf-8"));
  128                response .headers() .set(TRANS FER_ENCODI NG, HttpHe aderValues .CHUNKED);
  129  
  130                if (LOGG ER.isDebug Enabled()  && start >  0) {
  131                    long  end = Sys tem.curren tTimeMilli s();
  132                    LOGG ER.debug(" Full proce ssing time  for reque st: " + (e nd - start ));
  133                }
  134  
  135                if (!kee pAlive) {
  136                    ctx. write(resp onse).addL istener(Ch annelFutur eListener. CLOSE);
  137                } else {
  138                    resp onse.heade rs().set(C ONNECTION,  HttpHeade rValues.KE EP_ALIVE);
  139                    ctx. write(resp onse);
  140                }
  141           }
  142       }
  143  
  144       privat e static b yte[] enco de(Object  object) {
  145           St ring data  = new JSON Object(obj ect).toStr ing();
  146           re turn data. getBytes() ;
  147       }
  148  
  149       @Overr ide
  150       public  void exce ptionCaugh t(ChannelH andlerCont ext ctx, T hrowable c ause) {
  151           ca use.printS tackTrace( );
  152           ct x.close();
  153       }
  154  
  155   }