Produced by Araxis Merge on 6/9/2017 3:51:27 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:27 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\report | AdapterDateRangeReport.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 | 261 |
| 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.report ; | |||||
| 2 | ||||||
| 3 | import gov .va.nvap.a udit.BulkD ownloadDoc s; | |||||
| 4 | import gov .va.nvap.w eb.app.Res ponseDispa tcherHttpS ervlet; | |||||
| 5 | import gov .va.nvap.w eb.helper. privacy.Co nsentManag ementHelpe r; | |||||
| 6 | import gov .va.nvap.w eb.helper. report.Rep ortHelper; | |||||
| 7 | ||||||
| 8 | import jav a.io.Buffe redOutputS tream; | |||||
| 9 | import jav a.io.File; | |||||
| 10 | import jav a.io.FileI nputStream ; | |||||
| 11 | import jav a.io.IOExc eption; | |||||
| 12 | import jav a.io.Input Stream; | |||||
| 13 | import jav a.text.Par seExceptio n; | |||||
| 14 | import jav a.text.Sim pleDateFor mat; | |||||
| 15 | import jav a.util.Dat e; | |||||
| 16 | import jav a.util.Pro perties; | |||||
| 17 | import jav ax.servlet .ServletEx ception; | |||||
| 18 | import jav ax.servlet .http.Http Servlet; | |||||
| 19 | import jav ax.servlet .http.Http ServletReq uest; | |||||
| 20 | import jav ax.servlet .http.Http ServletRes ponse; | |||||
| 21 | import jav ax.servlet .http.Http Session; | |||||
| 22 | import org .apache.co mmons.io.I OUtils; | |||||
| 23 | import web logic.secu rity.inter nal.Serial izedSystem Ini; | |||||
| 24 | import web logic.secu rity.inter nal.encryp tion.Clear OrEncrypte dService; | |||||
| 25 | import web logic.secu rity.inter nal.encryp tion.Encry ptionServi ce; | |||||
| 26 | ||||||
| 27 | /** | |||||
| 28 | * Servlet implement ation clas s AdapterD ateRangeRe port | |||||
| 29 | * | |||||
| 30 | * @author Sricharan Reddy | |||||
| 31 | */ | |||||
| 32 | public cla ss Adapter DateRangeR eport exte nds Respon seDispatch erHttpServ let { | |||||
| 33 | ||||||
| 34 | // Begin Cons tant Decla rations fo r Class | |||||
| 35 | pr ivate stat ic final l ong seri alVersionU ID = 1L; | |||||
| 36 | ||||||
| 37 | pr ivate stat ic final i nt BYTE S_DOWNLOAD = 1024; | |||||
| 38 | ||||||
| 39 | pr ivate stat ic final S tring MOCK _FLAG = "m ock.bulk.d ownload"; | |||||
| 40 | ||||||
| 41 | pr ivate stat ic final S tring REPO RT_HELPER_ CLASS= "re portHelper "; | |||||
| 42 | ||||||
| 43 | pr ivate stat ic final S tring CMS_ HELPER_CLA SS = "cmsH elper"; | |||||
| 44 | ||||||
| 45 | pr ivate stat ic final S tring INPU T_DATE_FOR MAT = "MM/ dd/yyyy"; | |||||
| 46 | ||||||
| 47 | pr ivate stat ic final S tring OUTP UT_DATE_FO RMAT = "yy yy-MM-dd"; | |||||
| 48 | ||||||
| 49 | pr ivate stat ic final S tring STAR T_DATE_PAR AM = "star tDate"; | |||||
| 50 | ||||||
| 51 | pr ivate stat ic final S tring END_ DATE_PARAM ="endDate "; | |||||
| 52 | ||||||
| 53 | pr ivate stat ic final S tring PART NER_PARAM = "item"; | |||||
| 54 | ||||||
| 55 | pr ivate stat ic final S tring PATI ENT_IDENTI FIER_PARAM = "patien tIdentifie r"; | |||||
| 56 | ||||||
| 57 | pr ivate stat ic final S tring CONT ENT_TYPE = "applicat ion/zip"; | |||||
| 58 | ||||||
| 59 | pr ivate stat ic final S tring RESP ONSE_HEADE R = "atta chment; fi lename=aud itedDocsEx port.zip"; | |||||
| 60 | privat e static f inal Strin g PROP_FIL E_LOC_SYSP ROP = "va p.bulkDown load.confi g"; | |||||
| 61 | privat e static f inal Strin g PROP_FIL E_LOC_DFTL _VAL = "co nfig/vap/b ulkDownloa d.properti es"; | |||||
| 62 | privat e static f inal Strin g VAP_ID_P ROP = "vap .identifie r"; | |||||
| 63 | ||||||
| 64 | // End of Co nstants De claration | |||||
| 65 | ||||||
| 66 | //*** | |||||
| 67 | // Set by init() | |||||
| 68 | //*** | |||||
| 69 | privat e String v apId; | |||||
| 70 | privat e ClearOrE ncryptedSe rvice encS vc; | |||||
| 71 | ||||||
| 72 | /** | |||||
| 73 | * Def ault const ructor. | |||||
| 74 | */ | |||||
| 75 | public AdapterDa teRangeRep ort() | |||||
| 76 | { | |||||
| 77 | ||||||
| 78 | } | |||||
| 79 | ||||||
| 80 | @Overr ide | |||||
| 81 | public void init () throws ServletExc eption | |||||
| 82 | { | |||||
| 83 | su per.init() ; | |||||
| 84 | tr y | |||||
| 85 | { | |||||
| 86 | vapId = loadVAPId( ); | |||||
| 87 | } | |||||
| 88 | ca tch(IOExce ption ex) | |||||
| 89 | { | |||||
| 90 | throw ne w ServletE xception( | |||||
| 91 | "Una ble to loa d configur ation for bulk downl oad.", ex) ; | |||||
| 92 | } | |||||
| 93 | ||||||
| 94 | // works off conventio n that the current w orking dir ectory is the domain home | |||||
| 95 | St ring domai nHome = ne w File("du mmy").getA bsoluteFil e().getPar ent(); | |||||
| 96 | En cryptionSe rvice encr yptSrv = S erializedS ystemIni.g etEncrypti onService( domainHome ); | |||||
| 97 | en cSvc = new ClearOrEn cryptedSer vice(encry ptSrv); | |||||
| 98 | } | |||||
| 99 | ||||||
| 100 | /** | |||||
| 101 | * Hel per method to get th e CmsHelpe r instance | |||||
| 102 | * @re turn insta nce of Con sentManage mentHelper | |||||
| 103 | */ | |||||
| 104 | public ConsentMa nagementHe lper getCm sHelper() | |||||
| 105 | { | |||||
| 106 | fi nal Consen tManagemen tHelper cm sHelper = this.getBe an(CMS_HEL PER_CLASS, ConsentMan agementHel per.class) ; | |||||
| 107 | re turn cmsHe lper; | |||||
| 108 | } | |||||
| 109 | ||||||
| 110 | /** | |||||
| 111 | * Me thod to ge t an insta nce of bul k download docs | |||||
| 112 | * @re turn insta nce of Bul kDownloadD ocs | |||||
| 113 | */ | |||||
| 114 | public BulkDownl oadDocs ge tbulkDownl oadDocs() | |||||
| 115 | { | |||||
| 116 | St ring useMo ck =""; | |||||
| 117 | us eMock = Sy stem.getPr operty(MOC K_FLAG)!=n ull?System .getProper ty(MOCK_FL AG):""; | |||||
| 118 | St ring mockC lass=""; | |||||
| 119 | i f(useMock. equalsIgno reCase("tr ue")) | |||||
| 120 | { | |||||
| 121 | mockCl ass = "bul kDownloadD ocs-mock"; | |||||
| 122 | } | |||||
| 123 | e lse | |||||
| 124 | { | |||||
| 125 | mockCl ass = "bul kDownloadD ocs"; | |||||
| 126 | } | |||||
| 127 | fina l BulkDown loadDocs b ulkDownloa dBean = ge tBean(mock Class, Bul kDownloadD ocs.class) ; | |||||
| 128 | re turn bulkD ownloadBea n; | |||||
| 129 | } | |||||
| 130 | ||||||
| 131 | /** | |||||
| 132 | * Met hod for t he Report Helper cla ss | |||||
| 133 | * @re turn insta nce of Rep ortHelper | |||||
| 134 | */ | |||||
| 135 | privat e ReportHe lper getRe portHelper () | |||||
| 136 | { | |||||
| 137 | re turn this. getBean(RE PORT_HELPE R_CLASS, R eportHelpe r.class); | |||||
| 138 | } | |||||
| 139 | ||||||
| 140 | /* * | |||||
| 141 | * Servlet l ogic for g etting the dates and generatin g the outp ut file | |||||
| 142 | * / | |||||
| 143 | pr otected vo id doGet(H ttpServlet Request re quest, Htt pServletRe sponse res ponse) thr ows Servle tException , IOExcept ion | |||||
| 144 | { | |||||
| 145 | // G et relevan t session variables | |||||
| 146 | Stri ng startDa te= reques t.getParam eter(START _DATE_PARA M)!=null?r equest.get Parameter( START_DATE _PARAM):"" ; | |||||
| 147 | Stri ng endDate = request .getParame ter(END_DA TE_PARAM)! =null?requ est.getPar ameter(END _DATE_PARA M):""; | |||||
| 148 | Stri ng organiz ationName= request.g etParamete r(PARTNER_ PARAM)!=nu ll?request .getParame ter(PARTNE R_PARAM):" "; | |||||
| 149 | Stri ng patient Identifier = request. getParamet er(PATIENT _IDENTIFIE R_PARAM)!= null?reque st.getPara meter(PATI ENT_IDENTI FIER_PARAM ):""; | |||||
| 150 | ||||||
| 151 | //In itialize p age with D efault val ues | |||||
| 152 | if( startDate. equalsIgno reCase("") || endDat e.equalsIg noreCase(" ")) | |||||
| 153 | { | |||||
| 154 | unspe cified(req uest, resp onse); | |||||
| 155 | retur n; | |||||
| 156 | } | |||||
| 157 | ||||||
| 158 | if( !startDate .equalsIgn oreCase("" ) && !endD ate.equals IgnoreCase ("")) | |||||
| 159 | { | |||||
| 160 | String s tartAudit = for matDateFor Adapter(st artDate); | |||||
| 161 | String e ndAudit = for matDateFor Adapter(en dDate); | |||||
| 162 | String d ocGenPartn erId = for matStringf orPartner( organizati onName); | |||||
| 163 | InputStr eam is; | |||||
| 164 | try | |||||
| 165 | { | |||||
| 166 | Stri ng vapIdCl ear = encS vc.decrypt (vapId); | |||||
| 167 | is = getbulkDo wnloadDocs ().downloa dRetrieved Docs(vapId Clear, sta rtAudit, e ndAudit, d ocGenPartn erId, pati entIdentif ier); // G et input s tream from BulkDownl oad Class | |||||
| 168 | }catch(E xception e ) | |||||
| 169 | { | |||||
| 170 | thro w new Serv letExcepti on( | |||||
| 171 | "An except ion occurr ed while a ttempting to communi cate with Adapter Bu lk Documen t Download .", e); | |||||
| 172 | } | |||||
| 173 | ||||||
| 174 | Buffered OutputStre am bos = n ull; | |||||
| 175 | try | |||||
| 176 | { | |||||
| 177 | resp onse.setCo ntentType( CONTENT_TY PE); | |||||
| 178 | resp onse.setHe ader("Cont ent-Dispos ition",RES PONSE_HEAD ER); | |||||
| 179 | int read=0; | |||||
| 180 | byte [] bytes = new byte[ BYTES_DOWN LOAD]; | |||||
| 181 | bos = new Buff eredOutput Stream(res ponse.getO utputStrea m()); | |||||
| 182 | whil e((read = is.read(by tes))!= -1 ) | |||||
| 183 | { | |||||
| 184 | bos.write( bytes, 0, read); | |||||
| 185 | } | |||||
| 186 | bos. flush(); | |||||
| 187 | } | |||||
| 188 | finally | |||||
| 189 | { | |||||
| 190 | IOUt ils.closeQ uietly(bos ); | |||||
| 191 | IOUt ils.closeQ uietly(is) ; | |||||
| 192 | } | |||||
| 193 | } | |||||
| 194 | } | |||||
| 195 | ||||||
| 196 | // Method to Format th e partner string for input to client fun ction | |||||
| 197 | pr ivate Stri ng formatS tringforPa rtner(Stri ng organiz ationName) | |||||
| 198 | { | |||||
| 199 | St ring partn erId= orga nizationNa me.replace ('%', ' ') ; // Remov e % signs from Partn er ID | |||||
| 200 | pa rtnerId = partnerId. replaceAll ("\\s+", " "); // Rep lace empty character s | |||||
| 201 | retu rn partner Id!=null?p artnerId:o rganizatio nName; | |||||
| 202 | } | |||||
| 203 | ||||||
| 204 | // Method to format dat es for Web service cl ient | |||||
| 205 | pr ivate Stri ng formatD ateForAdap ter(String inputDate ) | |||||
| 206 | { | |||||
| 207 | Simp leDateForm at sdf= ne w SimpleDa teFormat(I NPUT_DATE_ FORMAT); | |||||
| 208 | Simp leDateForm at dt = ne w SimpleDa teFormat(O UTPUT_DATE _FORMAT); | |||||
| 209 | Date date = nu ll; | |||||
| 210 | try { | |||||
| 211 | date = sdf.parse (inputDate ); | |||||
| 212 | } ca tch (Parse Exception e) { | |||||
| 213 | throw ne w RuntimeE xception(" Exception in date fo rmat.", e) ; | |||||
| 214 | } | |||||
| 215 | Stri ng returnD ate=dt.for mat(date); | |||||
| 216 | retu rn returnD ate!=null? returnDate :inputDate ; | |||||
| 217 | } | |||||
| 218 | ||||||
| 219 | /* * | |||||
| 220 | * @see Http Servlet #d oPost(Http ServletReq uest reque st, HttpSe rvletRespo nse respon se) | |||||
| 221 | * / | |||||
| 222 | pr otected vo id doPost( HttpServle tRequest r equest, Ht tpServletR esponse re sponse) th rows Servl etExceptio n, IOExcep tion { | |||||
| 223 | doGe t(request, response) ; | |||||
| 224 | } | |||||
| 225 | ||||||
| 226 | @O verride | |||||
| 227 | pr otected vo id unspeci fied(HttpS ervletRequ est reques t, HttpSer vletRespon se respons e) | |||||
| 228 | throws ServletEx ception, I OException | |||||
| 229 | { | |||||
| 230 | fina l HttpSess ion sessio n = reques t.getSessi on(false); | |||||
| 231 | Repo rtHelper.s etDefaultS earchDates (session); | |||||
| 232 | this .getReport Helper().g etOrgLists (request,t his.getCms Helper()); | |||||
| 233 | this.for ward(reque st, respon se, "show" ); | |||||
| 234 | } | |||||
| 235 | ||||||
| 236 | privat e String l oadVAPId() throws IO Exception | |||||
| 237 | { | |||||
| 238 | Fi le file; | |||||
| 239 | if (System.g etProperty (PROP_FILE _LOC_SYSPR OP) != nul l) | |||||
| 240 | { | |||||
| 241 | file = n ew File(Sy stem.getPr operty(PRO P_FILE_LOC _SYSPROP)) ; | |||||
| 242 | } | |||||
| 243 | el se | |||||
| 244 | { | |||||
| 245 | file = n ew File(PR OP_FILE_LO C_DFTL_VAL ); | |||||
| 246 | } | |||||
| 247 | ||||||
| 248 | In putStream stream = n ull; | |||||
| 249 | Pr operties p rops = new Propertie s(); | |||||
| 250 | tr y | |||||
| 251 | { | |||||
| 252 | stream = new FileI nputStream (file); | |||||
| 253 | props.lo ad(stream) ; | |||||
| 254 | } | |||||
| 255 | fi nally | |||||
| 256 | { | |||||
| 257 | IOUtils. closeQuiet ly(stream) ; | |||||
| 258 | } | |||||
| 259 | re turn props .getProper ty(VAP_ID_ PROP); | |||||
| 260 | } | |||||
| 261 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.