Produced by Araxis Merge on 6/9/2017 3:51:26 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Jun 9 19:51:26 2017 UTC | ||
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-web\src\main\java\gov\va\nvap\web\helper\report | BulkDownloadDocsClient.java | Tue May 2 14:49:40 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 181 |
| 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.nvap. web.helper .report; | |||||
| 2 | ||||||
| 3 | import gov .va.nvap.a udit.BulkD ownloadDoc s; | |||||
| 4 | import jav a.io.Close able; | |||||
| 5 | import jav a.io.Filte rInputStre am; | |||||
| 6 | import jav a.io.IOExc eption; | |||||
| 7 | import jav a.io.Input Stream; | |||||
| 8 | import jav a.net.URI; | |||||
| 9 | import jav a.net.URIS yntaxExcep tion; | |||||
| 10 | import jav a.text.Mes sageFormat ; | |||||
| 11 | import org .apache.ht tp.HttpSta tus; | |||||
| 12 | ||||||
| 13 | ||||||
| 14 | import org .apache.ht tp.client. config.Req uestConfig ; | |||||
| 15 | import org .apache.ht tp.client. methods.Cl oseableHtt pResponse; | |||||
| 16 | import org .apache.ht tp.client. methods.Ht tpGet; | |||||
| 17 | import org .apache.ht tp.client. utils.URIB uilder; | |||||
| 18 | import org .apache.ht tp.impl.cl ient.Close ableHttpCl ient; | |||||
| 19 | import org .apache.ht tp.impl.cl ient.HttpC lientBuild er; | |||||
| 20 | import org .slf4j.Log gerFactory ; | |||||
| 21 | ||||||
| 22 | /** | |||||
| 23 | * Connect s to the R eST servic e provided by NHIN A dapter for bulk down load of | |||||
| 24 | * (audite d) retriev ed documen ts. This s ervice pro vides a bi nary | |||||
| 25 | * zip str eam of all retrieved (disclosu re or rece ipt) docum ents meeti ng the | |||||
| 26 | * given f ilter crit eria. | |||||
| 27 | * @author cbarber | |||||
| 28 | */ | |||||
| 29 | public cla ss BulkDow nloadDocsC lient impl ements Bul kDownloadD ocs | |||||
| 30 | { | |||||
| 31 | public static fi nal int MS _PER_SEC = 1000; | |||||
| 32 | privat e static f inal Strin g RQST_HDR _VAP_ID = "VAP_ID"; | |||||
| 33 | ||||||
| 34 | privat e static f inal org.s lf4j.Logge r LOGGER = | |||||
| 35 | Lo ggerFactor y.getLogge r(BulkDown loadDocsCl ient.class ); | |||||
| 36 | ||||||
| 37 | //**** | |||||
| 38 | // Pro perties se t by Sprin g configur ation. | |||||
| 39 | //**** | |||||
| 40 | privat e String d ownloadUrl ; | |||||
| 41 | privat e int conn ectionTime outSec; | |||||
| 42 | privat e int read TimeoutSec ; | |||||
| 43 | ||||||
| 44 | @Overr ide | |||||
| 45 | public InputStre am downloa dRetrieved Docs(Strin g vapId, S tring star tAudit, St ring endAu dit, Strin g docGenPa rtnerId, S tring pati entIdentif ier) throw s IOExcept ion | |||||
| 46 | { | |||||
| 47 | // Define URI to hit Ad apter Bulk DownloadDo cs | |||||
| 48 | UR I uri; | |||||
| 49 | tr y { | |||||
| 50 | // Valid ate patien tIdentifie r | |||||
| 51 | if (pati entIdentif ier != nul l && patie ntIdentifi er.isEmpty () == fals e) | |||||
| 52 | { | |||||
| 53 | uri = new URIB uilder(dow nloadUrl) | |||||
| 54 | .setParame ter("patie ntIdentifi er", patie ntIdentifi er) | |||||
| 55 | .setParame ter("start ", startAu dit) | |||||
| 56 | .setParame ter("end", endAudit) | |||||
| 57 | .setParame ter("creat or", docGe nPartnerId ) | |||||
| 58 | .build(); | |||||
| 59 | } | |||||
| 60 | else | |||||
| 61 | { | |||||
| 62 | uri = new URIB uilder(dow nloadUrl) | |||||
| 63 | .setParame ter("start ", startAu dit) | |||||
| 64 | .setParame ter("end", endAudit) | |||||
| 65 | .setParame ter("creat or", docGe nPartnerId ) | |||||
| 66 | .build(); | |||||
| 67 | } | |||||
| 68 | } catch (URI SyntaxExce ption ex) { | |||||
| 69 | throw ne w IOExcept ion("Excep tion throw n while cr eating The URI.", ex ); | |||||
| 70 | } | |||||
| 71 | ||||||
| 72 | Ht tpGet http Get = new HttpGet(ur i); | |||||
| 73 | ||||||
| 74 | // Define and Set Conne ction Time outs | |||||
| 75 | Re questConfi g.Builder requestBui lder = Req uestConfig .custom(); | |||||
| 76 | re questBuild er = reque stBuilder. setConnect Timeout(co nnectionTi meoutSec * MS_PER_SE C); | |||||
| 77 | re questBuild er = reque stBuilder. setConnect ionRequest Timeout(co nnectionTi meoutSec * MS_PER_SE C); | |||||
| 78 | re questBuild er = reque stBuilder. setSocketT imeout(rea dTimeoutSe c * MS_PER _SEC); | |||||
| 79 | ||||||
| 80 | // Create Htt pClient | |||||
| 81 | Ht tpClientBu ilder buil der = Http ClientBuil der.create (); | |||||
| 82 | bu ilder.setD efaultRequ estConfig( requestBui lder.build ()); | |||||
| 83 | ||||||
| 84 | Cl oseableHtt pClient ht tpClient = null; | |||||
| 85 | Cl oseableHtt pResponse response = null; | |||||
| 86 | In putStream contentStr eam = null ; | |||||
| 87 | tr y | |||||
| 88 | { | |||||
| 89 | // httpC lient actu ally maint ains an HT TP conn po ol, and wo uld be | |||||
| 90 | // reusa ble if thi s bulk dow nload feat ure ever s ees heavie r usage. | |||||
| 91 | httpClie nt = build er.build() ; | |||||
| 92 | ||||||
| 93 | // Execu te the get request a nd set the response. | |||||
| 94 | httpGet. addHeader( RQST_HDR_V AP_ID, vap Id); | |||||
| 95 | response = httpCli ent.execut e(httpGet) ; | |||||
| 96 | int stat usCode = r esponse.ge tStatusLin e().getSta tusCode(); | |||||
| 97 | if (stat usCode != HttpStatus .SC_OK) | |||||
| 98 | { | |||||
| 99 | Stri ng msg = M essageForm at.format( | |||||
| 100 | "Adapter B ulk Downlo ad failed with HTTP error code : {0}", | |||||
| 101 | statusCode ); | |||||
| 102 | thro w new IOEx ception(ms g); | |||||
| 103 | } | |||||
| 104 | else | |||||
| 105 | { | |||||
| 106 | LOGG ER.debug(" Adapter Bu lk Downloa d response Status Co de: " + | |||||
| 107 | statusCode ); | |||||
| 108 | } | |||||
| 109 | ||||||
| 110 | contentS tream = re sponse.get Entity().g etContent( ); | |||||
| 111 | ||||||
| 112 | //*** | |||||
| 113 | // Speci al close m ethod to c lose the u nderlying socket con nection | |||||
| 114 | // and H TTPClient instance, too. Note need for s eparate fi nal | |||||
| 115 | // copie s of the t wo vars be low, since they must be initia lized to | |||||
| 116 | // null outside th e try bloc k for the finally bl ock to wor k. | |||||
| 117 | //*** | |||||
| 118 | final Cl oseableHtt pClient ht tpClientF = httpClie nt; | |||||
| 119 | final Cl oseableHtt pResponse responseF = response ; | |||||
| 120 | return n ew FilterI nputStream (contentSt ream) | |||||
| 121 | { | |||||
| 122 | @Ove rride | |||||
| 123 | publ ic void cl ose() thro ws IOExcep tion | |||||
| 124 | { | |||||
| 125 | closeQuiet ly(respons eF); | |||||
| 126 | closeQuiet ly(httpCli entF); | |||||
| 127 | super.clos e(); | |||||
| 128 | } | |||||
| 129 | }; | |||||
| 130 | } | |||||
| 131 | fi nally | |||||
| 132 | { | |||||
| 133 | if(conte ntStream = = null) | |||||
| 134 | { | |||||
| 135 | // o therwise, caller mus t close th e returned InputStre am | |||||
| 136 | // s ubclass, w hich will close thes e | |||||
| 137 | clos eQuietly(r esponse); | |||||
| 138 | clos eQuietly(h ttpClient) ; | |||||
| 139 | } | |||||
| 140 | } | |||||
| 141 | } | |||||
| 142 | ||||||
| 143 | public void setD ownloadUrl (String s) | |||||
| 144 | { | |||||
| 145 | do wnloadUrl = s; | |||||
| 146 | } | |||||
| 147 | ||||||
| 148 | public void setC onnectionT imeoutSec( int connec tionTimeou tSec) | |||||
| 149 | { | |||||
| 150 | th is.connect ionTimeout Sec = conn ectionTime outSec; | |||||
| 151 | } | |||||
| 152 | ||||||
| 153 | public void setR eadTimeout Sec(int re adTimeoutS ec) | |||||
| 154 | { | |||||
| 155 | thi s.readTime outSec = r eadTimeout Sec; | |||||
| 156 | } | |||||
| 157 | ||||||
| 158 | /** | |||||
| 159 | * Unc onditional ly close a <code>Clo seable</co de>. | |||||
| 160 | * Thi s is from commons-io ....WebLog ic seems t o be packi ng an old version | |||||
| 161 | * som ewhere tha t is givin g NoSuchMe thodError. | |||||
| 162 | * <p> | |||||
| 163 | * Equ ivalent to {@link Cl oseable#cl ose()}, ex cept any e xceptions will be ig nored. | |||||
| 164 | * Thi s is typic ally used in finally blocks. | |||||
| 165 | ||||||
| 166 | * @pa ram closea ble the ob ject to cl ose, may b e null or already cl osed | |||||
| 167 | */ | |||||
| 168 | public static vo id closeQu ietly(Clos eable clos eable) | |||||
| 169 | { | |||||
| 170 | tr y | |||||
| 171 | { | |||||
| 172 | if (clos eable != n ull) { | |||||
| 173 | clos eable.clos e(); | |||||
| 174 | } | |||||
| 175 | } | |||||
| 176 | ca tch (IOExc eption ioe ) | |||||
| 177 | { | |||||
| 178 | // ignor e | |||||
| 179 | } | |||||
| 180 | } | |||||
| 181 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.