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\document | DocumentHelper.java | Fri Apr 21 20:03:30 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 250 |
| 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 .document; | |||||
| 2 | ||||||
| 3 | import gov .va.nvap.c ommon.tran sformer.Tr ansformer; | |||||
| 4 | import gov .va.nvap.c ommon.tran sformer.Tr ansformerE xception; | |||||
| 5 | import gov .va.nvap.c ommon.tran sformer.xm l.StringTo XML; | |||||
| 6 | import gov .va.nvap.c ommon.uuid .UUIDUtil; | |||||
| 7 | import gov .va.nvap.c ommon.vali dation.Ass ert; | |||||
| 8 | import gov .va.nvap.c ommon.vali dation.Nul lChecker; | |||||
| 9 | import gov .va.nvap.c ommon.xpat h.XPathExc eption; | |||||
| 10 | import gov .va.nvap.c ommon.xpat h.XPathUti l; | |||||
| 11 | import gov .va.nvap.s ervice.ada pter.doc.A dapterDocQ ueryRetrie ve; | |||||
| 12 | import gov .va.nvap.s ervice.ada pter.doc.A dapterExce ption; | |||||
| 13 | ||||||
| 14 | import jav a.io.IOExc eption; | |||||
| 15 | import jav a.io.Outpu tStream; | |||||
| 16 | import jav a.util.Dat e; | |||||
| 17 | import jav a.util.Has hMap; | |||||
| 18 | ||||||
| 19 | import jav ax.servlet .http.Http ServletRes ponse; | |||||
| 20 | ||||||
| 21 | import org .apache.xe rces.impl. dv.util.Ba se64; | |||||
| 22 | import org .springfra mework.bea ns.factory .annotatio n.Required ; | |||||
| 23 | import org .w3c.dom.D ocument; | |||||
| 24 | import org .w3c.dom.N ode; | |||||
| 25 | ||||||
| 26 | /** | |||||
| 27 | * Helper class to h elp query and retrie ve of docu ments. | |||||
| 28 | * | |||||
| 29 | * @author Asha Amri traj | |||||
| 30 | * | |||||
| 31 | */ | |||||
| 32 | public cla ss Documen tHelper { | |||||
| 33 | /* * | |||||
| 34 | * The adapt er documen t query be an. | |||||
| 35 | * / | |||||
| 36 | pr ivate Adap terDocQuer yRetrieve adapterDoc QueryRetri eve; | |||||
| 37 | /* * | |||||
| 38 | * The defau lt stylesh eet the wo uld be dis played to the user. | |||||
| 39 | * / | |||||
| 40 | pr ivate Stri ng default Stylesheet ; | |||||
| 41 | /* * | |||||
| 42 | * Flag for showing XM L view. | |||||
| 43 | * / | |||||
| 44 | pr ivate bool ean isXmlV iewEnabled ; | |||||
| 45 | /* * | |||||
| 46 | * A default document repository id to get the data from. Adap ter hard c odes | |||||
| 47 | * a default id to dec ide whethe r the adap ter doc re trieve wou ld go to t he | |||||
| 48 | * NwHIN or local. | |||||
| 49 | * / | |||||
| 50 | pr ivate Stri ng localDo cumentRepo sitoryId; | |||||
| 51 | /* * | |||||
| 52 | * The maxim um size fo r a file u pload. | |||||
| 53 | * / | |||||
| 54 | pr ivate long maxUpload FileSize; | |||||
| 55 | ||||||
| 56 | /* * | |||||
| 57 | * For trans forming St ring to XM L; | |||||
| 58 | * / | |||||
| 59 | pr ivate Stri ngToXML st ringToXML; | |||||
| 60 | ||||||
| 61 | /* * | |||||
| 62 | * A bunch o f style sh eet transf ormer map, to show d ifferent v iews on th e | |||||
| 63 | * GUI. | |||||
| 64 | * / | |||||
| 65 | pr ivate Hash Map<String , Transfor mer<Docume nt, String >> stylesh eetTransfo rmers; | |||||
| 66 | ||||||
| 67 | /* * | |||||
| 68 | * Get the C 32 documen t by calli ng Adapter DocQueryRe trieve on the NHIN | |||||
| 69 | * adapter. | |||||
| 70 | * / | |||||
| 71 | pu blic Strin g getC32Do cument(fin al String icn, final String us erName) | |||||
| 72 | throws AdapterEx ception { | |||||
| 73 | // U se current dates to get the VA C32 | |||||
| 74 | fina l String d ocument = this.adapt erDocQuery Retrieve.g etDocument (icn, | |||||
| 75 | new Date (), new Da te(), user Name); | |||||
| 76 | retu rn documen t; | |||||
| 77 | } | |||||
| 78 | ||||||
| 79 | pu blic Strin g getC62At tachment(f inal Strin g document ) | |||||
| 80 | throws Transform erExceptio n, XPathEx ception { | |||||
| 81 | fina l Document xmlDoc = this.strin gToXML.tra nsform(doc ument); | |||||
| 82 | // T ODO: Move to Spring | |||||
| 83 | fina l Node nod e = XPathU til.getNod eByPath(xm lDoc, | |||||
| 84 | "//*[loc al-name()= 'nonXMLBod y']/*[loca l-name()=' text']/tex t()"); | |||||
| 85 | ||||||
| 86 | Stri ng textCon tent = nul l; | |||||
| 87 | if ( NullChecke r.isNotEmp ty(node)) { | |||||
| 88 | // Get the text | |||||
| 89 | textCo ntent = no de.getNode Value().tr im(); | |||||
| 90 | if (Nu llChecker. isNotEmpty (textConte nt)) { | |||||
| 91 | textCont ent = text Content.re placeAll(" \\s+", "") ; | |||||
| 92 | } | |||||
| 93 | } | |||||
| 94 | ||||||
| 95 | retu rn textCon tent; | |||||
| 96 | ||||||
| 97 | } | |||||
| 98 | ||||||
| 99 | /* * | |||||
| 100 | * Get the d ocument by calling N HIN Adapte rDocQueryR etrieve on the NHIN | |||||
| 101 | * adapter. | |||||
| 102 | * / | |||||
| 103 | pu blic Strin g getDocum ent(final String icn , final St ring docum entUniqueI d, | |||||
| 104 | final String use rName, fin al String homeCommun ityId) | |||||
| 105 | throws AdapterEx ception { | |||||
| 106 | // P ass the lo cal docume nt reposit ory ID whi ch is hard coded in t he | |||||
| 107 | // s pring prop erties | |||||
| 108 | fina l String d ocument = this.adapt erDocQuery Retrieve.g etDocument (icn, | |||||
| 109 | document UniqueId, this.local DocumentRe positoryId , | |||||
| 110 | homeComm unityId, u serName); | |||||
| 111 | retu rn documen t; | |||||
| 112 | ||||||
| 113 | } | |||||
| 114 | ||||||
| 115 | /* * | |||||
| 116 | * Convert X ML to Html by using the approp riate styl e sheet. | |||||
| 117 | * / | |||||
| 118 | pu blic Strin g getHtml( final Stri ng cdaDocu ment, fina l String s tyleSheetT ype) { | |||||
| 119 | try { | |||||
| 120 | // Con vert to XM L | |||||
| 121 | final Document d oc = new S tringToXML ().transfo rm(cdaDocu ment); | |||||
| 122 | // Che ck if it i s a known style shee t | |||||
| 123 | if (Nu llChecker. isNotEmpty (styleShee tType) | |||||
| 124 | && this.st ylesheetTr ansformers .containsK ey(styleSh eetType)) { | |||||
| 125 | // Apply the trans former | |||||
| 126 | final Tr ansformer< Document, String> tr ansformer = this.sty lesheetTra nsformers | |||||
| 127 | .g et(styleSh eetType); | |||||
| 128 | final St ring html = transfor mer.transf orm(doc); | |||||
| 129 | return h tml; | |||||
| 130 | } else { | |||||
| 131 | Assert.a ssertTrue( this.style sheetTrans formers | |||||
| 132 | .c ontainsKey (this.defa ultStylesh eet), | |||||
| 133 | "D efault sty lesheet fo r view mus t be set") ; | |||||
| 134 | // Use a default s tyle sheet defined i n the spri ng propert ies | |||||
| 135 | final Tr ansformer< Document, String> de faultTrans former = t his.styles heetTransf ormers | |||||
| 136 | .g et(this.de faultStyle sheet); | |||||
| 137 | final St ring html = defaultT ransformer .transform (doc); | |||||
| 138 | return h tml; | |||||
| 139 | } | |||||
| 140 | } ca tch (final Transform erExceptio n ex) { | |||||
| 141 | throw new Runtim eException (ex); | |||||
| 142 | } | |||||
| 143 | } | |||||
| 144 | ||||||
| 145 | pu blic long getMaxUplo adFileSize () { | |||||
| 146 | retu rn this.ma xUploadFil eSize; | |||||
| 147 | } | |||||
| 148 | ||||||
| 149 | pu blic Strin g getPriva cyConsentD irectiveAt tachment(f inal Strin g document ) | |||||
| 150 | throws Transform erExceptio n, XPathEx ception { | |||||
| 151 | ||||||
| 152 | fina l Document xmlDoc = this.strin gToXML.tra nsform(doc ument); | |||||
| 153 | // T ODO: Move to Spring | |||||
| 154 | fina l Node nod e = XPathU til | |||||
| 155 | .getNode ByPath(xml Doc, | |||||
| 156 | "/ /*[local-n ame()='obs ervationMe dia']/*[lo cal-name() ='value']/ text()"); | |||||
| 157 | Stri ng textCon tent = nul l; | |||||
| 158 | if ( NullChecke r.isNotEmp ty(node)) { | |||||
| 159 | // Get the text | |||||
| 160 | textCo ntent = no de.getNode Value().tr im(); | |||||
| 161 | if (Nu llChecker. isNotEmpty (textConte nt)) { | |||||
| 162 | textCont ent = text Content.re placeAll(" \\s+", "") ; | |||||
| 163 | } | |||||
| 164 | } | |||||
| 165 | retu rn textCon tent; | |||||
| 166 | } | |||||
| 167 | ||||||
| 168 | pu blic Strin g getPriva cyConsentD irectiveMe diaType(fi nal String document) | |||||
| 169 | throws Transform erExceptio n, XPathEx ception { | |||||
| 170 | ||||||
| 171 | fina l Document xmlDoc = this.strin gToXML.tra nsform(doc ument); | |||||
| 172 | // T ODO: Move to Spring | |||||
| 173 | fina l Node nod e = XPathU til | |||||
| 174 | .getNode ByPath(xml Doc, | |||||
| 175 | "/ /*[local-n ame()='obs ervationMe dia']/*[lo cal-name() ='value']/ @mediaType "); | |||||
| 176 | Stri ng mediaTy pe = null; | |||||
| 177 | if ( NullChecke r.isNotEmp ty(node)) { | |||||
| 178 | // Get the text | |||||
| 179 | mediaT ype = node .getNodeVa lue().trim (); | |||||
| 180 | if (Nu llChecker. isNotEmpty (mediaType )) { | |||||
| 181 | mediaTyp e = mediaT ype.replac eAll("\\s+ ", ""); | |||||
| 182 | } | |||||
| 183 | } | |||||
| 184 | retu rn mediaTy pe; | |||||
| 185 | } | |||||
| 186 | ||||||
| 187 | pu blic boole an isXmlVi ewEnabled( ) { | |||||
| 188 | retu rn this.is XmlViewEna bled; | |||||
| 189 | } | |||||
| 190 | ||||||
| 191 | @R equired | |||||
| 192 | pu blic void setAdapter DocQueryRe trieve( | |||||
| 193 | final AdapterDoc QueryRetri eve adapte rDocQueryR etrieve) { | |||||
| 194 | this .adapterDo cQueryRetr ieve = ada pterDocQue ryRetrieve ; | |||||
| 195 | } | |||||
| 196 | ||||||
| 197 | @R equired | |||||
| 198 | pu blic void setDefault Stylesheet (final Str ing defaul tStyleshee t) { | |||||
| 199 | this .defaultSt ylesheet = defaultSt ylesheet; | |||||
| 200 | } | |||||
| 201 | ||||||
| 202 | @R equired | |||||
| 203 | pu blic void setLocalDo cumentRepo sitoryId( | |||||
| 204 | final String loc alDocument Repository Id) { | |||||
| 205 | this .localDocu mentReposi toryId = l ocalDocume ntReposito ryId; | |||||
| 206 | } | |||||
| 207 | ||||||
| 208 | @R equired | |||||
| 209 | pu blic void setMaxUplo adFileSize (final lon g maxUploa dFileSize) { | |||||
| 210 | // M ultiply to convert f rom MB to bytes | |||||
| 211 | this .maxUpload FileSize = maxUpload FileSize; | |||||
| 212 | } | |||||
| 213 | ||||||
| 214 | @R equired | |||||
| 215 | pu blic void setStringT oXML(final StringToX ML stringT oXML) { | |||||
| 216 | this .stringToX ML = strin gToXML; | |||||
| 217 | } | |||||
| 218 | ||||||
| 219 | @R equired | |||||
| 220 | pu blic void setStylesh eetTransfo rmers( | |||||
| 221 | final HashMap<St ring, Tran sformer<Do cument, St ring>> sty lesheetTra nsformers) { | |||||
| 222 | this .styleshee tTransform ers = styl esheetTran sformers; | |||||
| 223 | } | |||||
| 224 | ||||||
| 225 | @R equired | |||||
| 226 | pu blic void setXmlView Enabled(fi nal boolea n isXmlVie wEnabled) { | |||||
| 227 | this .isXmlView Enabled = isXmlViewE nabled; | |||||
| 228 | } | |||||
| 229 | ||||||
| 230 | pu blic void writeAttac hmentToStr eam(final HttpServle tResponse response, | |||||
| 231 | final String con tent, fina l MediaTyp e mediaTyp e, | |||||
| 232 | final Representa tionType r epresentat ion) throw s IOExcept ion { | |||||
| 233 | Asse rt.assertN otEmpty(co ntent, "Co ntent cann ot be empt y!"); | |||||
| 234 | ||||||
| 235 | // D ecode if e ncoded wit h Base 64 | |||||
| 236 | fina l byte dec oded[] = R epresentat ionType.B6 4.equals(r epresentat ion) ? Bas e64 | |||||
| 237 | .decode( content) : content.g etBytes(); | |||||
| 238 | ||||||
| 239 | // S et the app ropriate h eader in t he respons e | |||||
| 240 | resp onse.setCo ntentType( mediaType. mediaType( )); | |||||
| 241 | resp onse.setHe ader("Cont ent-Dispos ition", "a ttachment; filename= \"" | |||||
| 242 | + UUIDUt il.generat eMessageId () + "." + mediaType .extension () | |||||
| 243 | + "\""); | |||||
| 244 | resp onse.setHe ader("Cach e-Control" , "must-re validate") ; | |||||
| 245 | // F ill up the response and send i t back | |||||
| 246 | fina l OutputSt ream outSt ream = res ponse.getO utputStrea m(); | |||||
| 247 | outS tream.writ e(decoded, 0, decode d.length); | |||||
| 248 | outS tream.clos e(); | |||||
| 249 | } | |||||
| 250 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.