Produced by Araxis Merge on 4/23/2019 12:15:00 PM Central 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\AraxisMergeCompare\Pri_un\CCRS\CCRS-PMPM-Rcvr-v6.3.0\CCRS-PMPM-Rcvr-v6.3.0\src\main\java\gov\va\ccrs\receiver\service | DataStreamRequester.java | Wed Mar 20 20:42:30 2019 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\CCRS\CCRS-PMPM-Rcvr-v6.3.0\CCRS-PMPM-Rcvr-v6.3.0\src\main\java\gov\va\ccrs\receiver\service | DataStreamRequester.java | Wed Apr 17 02:59:44 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 252 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| 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 |
No regular expressions were active.
| 1 | package go v.va.ccrs. receiver.s ervice; | |
| 2 | ||
| 3 | import gov .va.ccrs.r eceiver.en tity.PMPMB atchLog; | |
| 4 | //import g ov.va.ccrs .receiver. utils.LogH elper; | |
| 5 | ||
| 6 | //import o rg.apache. log4j.Logg er; | |
| 7 | import org .apache.lo g4j.Level; | |
| 8 | ||
| 9 | import gov .va.ccrs.h elpers.Cle anPath; | |
| 10 | import gov .va.ccrs.h elpers.Log Helper; | |
| 11 | ||
| 12 | import org .springfra mework.htt p.Response Entity; | |
| 13 | import org .springfra mework.web .client.Re stTemplate ; | |
| 14 | import org .springfra mework.bea ns.factory .annotatio n.Value; | |
| 15 | import org .springfra mework.htt p.HttpEnti ty; | |
| 16 | import org .springfra mework.htt p.HttpHead ers; | |
| 17 | import org .springfra mework.htt p.HttpMeth od; | |
| 18 | ||
| 19 | ||
| 20 | import jav a.util.Lis t; | |
| 21 | import jav a.net.URI; | |
| 22 | ||
| 23 | public cla ss DataStr eamRequest er { | |
| 24 | ||
| 25 | // @Value("${ das.outbou nd.url}") | |
| 26 | pr ivate fina l String D AS_URL = " https://da s-test. DOMAIN . EXT "; | |
| 27 | ||
| 28 | pr ivate fina l String s enderIdHdr = "X-Rout ingSenderI D"; | |
| 29 | pr ivate fina l String r eceiverIdH dr = "X-Ro utingRecei verIDs"; | |
| 30 | pr ivate fina l String c onversatio nIdHdr = " X-Conversa tionID"; | |
| 31 | pr ivate fina l String t ransaction IdHdr = "X -Transacti onID"; | |
| 32 | ||
| 33 | // private st atic final Logger lo gger = Log ger.getLog ger(DataSt reamReques ter.class) ; | |
| 34 | ||
| 35 | pr ivate fina l String t ransIdPref ix = "CCRS -"; | |
| 36 | pu blic stati c int tran sIdSeqNbr = 1001; | |
| 37 | ||
| 38 | ||
| 39 | pu blic int s endGet2Das (PMPMBatch Log pmBatc h, List<St ring> hdrN ames, List <String> h drVals) th rows Excep tion { | |
| 40 | ||
| 41 | Rest Template r estTemplat e = new Re stTemplate (); | |
| 42 | Resp onseEntity <String> r esp = null ; | |
| 43 | Stri ng ccnUrl = pmBatch. getUrl(); | |
| 44 | Stri ng dasUrl; | |
| 45 | Stri ng sender = null; | |
| 46 | Stri ng receive r = null; | |
| 47 | Stri ng transId ; | |
| 48 | ||
| 49 | LogH elper.Log( Level.INFO , "Enter s endGet2Das method"); | |
| 50 | ||
| 51 | sync hronized ( this) { | |
| 52 | ++tran sIdSeqNbr; | |
| 53 | } | |
| 54 | tran sId = tran sIdPrefix + transIdS eqNbr; | |
| 55 | ||
| 56 | if ( ccnUrl.sta rtsWith("/ ")) | |
| 57 | dasUrl = DAS_URL + "/drs/v 1/Binary" + ccnUrl; | |
| 58 | else | |
| 59 | dasUrl = DAS_URL + "/drs/v 1/Binary/" + ccnUrl; | |
| 60 | ||
| 61 | LogH elper.Log( Level.INFO , "Sending callback to URL: " + dasUrl); | |
| 62 | LogH elper.Log( Level.INFO , "http he aders in G ET"); | |
| 63 | ||
| 64 | // l oad the he aders rece ived in cc rs/resourc e service for GET ca ll to DAS except swa p values o f sender a nd receive r | |
| 65 | Http Headers he aders = ne w HttpHead ers(); | |
| 66 | ||
| 67 | // C ontent-Typ e from CCN should be returned in Accept from CCRS | |
| 68 | head ers.set("A ccept", Cl eanPath.cl eanFilePat h(pmBatch. getContent Type())); | |
| 69 | ||
| 70 | LogH elper.Log( Level.INFO , "name: A ccept" + " value: " + pmBatc h.getConte ntType()); | |
| 71 | ||
| 72 | // f lip sender and recei ver values because c crs is now sender an d was rece iver upon ccrs/resou rce call a nd vice ve rsa for cc n | |
| 73 | for (int i=0; i<hdrNames .size(); i ++) { | |
| 74 | if (se nderIdHdr. equalsIgno reCase(hdr Names.get( i))) | |
| 75 | receiver = CleanPa th.cleanFi lePath(hdr Vals.get(i )); | |
| 76 | else i f (receive rIdHdr.equ alsIgnoreC ase(hdrNam es.get(i)) ) | |
| 77 | sender = CleanPath .cleanFile Path(hdrVa ls.get(i)) ; | |
| 78 | } | |
| 79 | ||
| 80 | // n ow that we have extr acted send and recei ver values , load the headers r eceived fr om DAS/CCN back with receiver and sender flipped | |
| 81 | // f or a GET, we need on ly sender, receiver, Conversat ionID and a new tran sactionID | |
| 82 | for (int i=0; i<hdrNames .size(); i ++) { | |
| 83 | if (se nderIdHdr. equalsIgno reCase(hdr Names.get( i))) { | |
| 84 | LogHelpe r.Log(Leve l.INFO, "n ame: " + h drNames.ge t(i) + " value: " + sender); | |
| 85 | headers. set(CleanP ath.cleanF ilePath(hd rNames.get (i)), send er); | |
| 86 | } | |
| 87 | else i f (receive rIdHdr.equ alsIgnoreC ase(hdrNam es.get(i)) ) { | |
| 88 | LogHelpe r.Log(Leve l.INFO, "n ame: " + h drNames.ge t(i) + " value: " + receiver ); | |
| 89 | headers. set(CleanP ath.cleanF ilePath(hd rNames.get (i)), rece iver); | |
| 90 | } | |
| 91 | else i f (transac tionIdHdr. equalsIgno reCase(hdr Names.get( i))) { | |
| 92 | LogHelpe r.Log(Leve l.INFO, "n ame: " + h drNames.ge t(i) + " value: " + transId) ; | |
| 93 | headers. set(CleanP ath.cleanF ilePath(hd rNames.get (i)), tran sId); | |
| 94 | } | |
| 95 | else i f (convers ationIdHdr .equalsIgn oreCase(hd rNames.get (i))) { | |
| 96 | LogHelpe r.Log(Leve l.INFO, "n ame: " + h drNames.ge t(i) + " value: " + hdrVals. get(i)); | |
| 97 | headers. set(CleanP ath.cleanF ilePath(hd rNames.get (i)), Clea nPath.clea nFilePath( hdrVals.ge t(i))); | |
| 98 | } | |
| 99 | // the se other h eaders sho uld not be in our GE T back to DAS | |
| 100 | /* | |
| 101 | else { | |
| 102 | LogHelpe r.Log(Leve l.INFO, "n ame: " + h drNames.ge t(i) + " value: " + hdrVals. get(i)); | |
| 103 | he aders.set( CleanPath. cleanFileP ath(hdrNam es.get(i)) , CleanPat h.cleanFil ePath(hdrV als.get(i) )); | |
| 104 | } | |
| 105 | */ | |
| 106 | } | |
| 107 | ||
| 108 | Http Entity ent ity = new HttpEntity (headers); | |
| 109 | ||
| 110 | ||
| 111 | try { | |
| 112 | //resp = r estTemplat e.getForEn tity(new U RI("http:/ /localhost :8090/jhoe ller/bookm arks/90"), String.cl ass); | |
| 113 | //resp = restTem plate.getF orEntity(n ew URI(das Url), Stri ng.class); | |
| 114 | //resp = restTem plate.exch ange(new U RI("http:/ /localhost :8090/jhoe ller/bookm arks/90"), HttpMetho d.GET, ent ity, Strin g.class); | |
| 115 | resp = restTempl ate.exchan ge(new URI (CleanPath .cleanFile Path(dasUr l)), HttpM ethod.GET, entity, S tring.clas s); | |
| 116 | } | |
| 117 | catc h (Excepti on ex) { | |
| 118 | LogHel per.Log(Le vel.ERROR, "Caught e xception c alling DAS : " + ex.t oString()) ; | |
| 119 | return -1; | |
| 120 | } | |
| 121 | ||
| 122 | LogH elper.Log( Level.INFO , "Status code recei ved:" + re sp.getStat usCode().t oString()) ; | |
| 123 | ||
| 124 | LogH elper.Log( Level.INFO , "Exit se ndGet2Das method"); | |
| 125 | retu rn resp.ge tStatusCod e().value( ); | |
| 126 | } | |
| 127 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.