Produced by Araxis Merge on 12/5/2017 12:06:52 PM Central Standard 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 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\XCAInitiatingGatewayDataSourceProvider\main\src\java\gov\va\med\imaging\ihe\xca\proxy | XCADataSourceProxy.java | Mon Dec 4 21:35:22 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\XCAInitiatingGatewayDataSourceProvider\main\src\java\gov\va\med\imaging\ihe\xca\proxy | XCADataSourceProxy.java | Tue Dec 5 15:38:27 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1476 |
| Changed | 1 | 4 |
| 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 | /** | |
| 2 | * | |
| 3 | Package: MAG - Vis tA Imaging | |
| 4 | WARNING: Per VHA D irective 2 004-038, t his routin e should n ot be modi fied. | |
| 5 | Date Cre ated: Jun 23, 2009 | |
| 6 | Site Nam e: Washin gton OI Fi eld Office , Silver S pring, MD | |
| 7 | Develope r: vhaisw werfej | |
| 8 | Descript ion: | |
| 9 | ||
| 10 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
| 11 | ;; Property of the US Government . | |
| 12 | ;; No permis sion to co py or redi stribute t his softwa re is give n. | |
| 13 | ;; Use of un released v ersions of this soft ware requi res the us er | |
| 14 | ;; to execu te a writt en test ag reement wi th the Vis tA Imaging | |
| 15 | ;; Developm ent Office of the De partment o f Veterans Affairs, | |
| 16 | ;; telephon e (301) 73 4-0100. | |
| 17 | ;; | |
| 18 | ;; The Food and Drug A dministrat ion classi fies this software a s | |
| 19 | ;; a Class I I medical device. A s such, it may not b e changed | |
| 20 | ;; in any wa y. Modifi cations to this soft ware may r esult in a n | |
| 21 | ;; adulterat ed medical device un der 21CFR8 20, the us e of which | |
| 22 | ;; is consid ered to be a violati on of US F ederal Sta tutes. | |
| 23 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
| 24 | ||
| 25 | */ | |
| 26 | package go v.va.med.i maging.ihe .xca.proxy ; | |
| 27 | ||
| 28 | import gov .va.med.im aging.arti factsource .ResolvedA rtifactSou rce; | |
| 29 | import gov .va.med.im aging.core .interface s.exceptio ns.Connect ionExcepti on; | |
| 30 | import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception; | |
| 31 | import gov .va.med.im aging.exch ange.busin ess.Docume ntFilter; | |
| 32 | import gov .va.med.im aging.exch ange.busin ess.ImageS treamRespo nse; | |
| 33 | import gov .va.med.im aging.exch ange.busin ess.Reques tor; | |
| 34 | import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume ntSetResul t; | |
| 35 | import gov .va.med.im aging.ihe. XCATransla torAdb; | |
| 36 | import gov .va.med.im aging.ihe. XCATransla torXmlBean s; | |
| 37 | import gov .va.med.im aging.ihe. exceptions .Translati onExceptio n; | |
| 38 | import gov .va.med.im aging.ihe. xca.dataso urce.XCADo cumentData SourceServ ice; | |
| 39 | import gov .va.med.im aging.ihe. xca.dataso urce.confi guration.X CADataSour ceConfigur ation; | |
| 40 | import gov .va.med.im aging.prox y.ssl.Auth SSLProtoco lSocketFac tory; | |
| 41 | import gov .va.med.im aging.tran sactioncon text.Trans actionCont ext; | |
| 42 | import gov .va.med.im aging.tran sactioncon text.Trans actionCont extFactory ; | |
| 43 | import gov .va.med.im aging.tran sactioncon text.Trans actionCont extHttpHea ders; | |
| 44 | ||
| 45 | import jav a.io.File; | |
| 46 | import jav a.io.IOExc eption; | |
| 47 | import jav a.io.Unsup portedEnco dingExcept ion; | |
| 48 | import jav a.net.Malf ormedURLEx ception; | |
| 49 | import jav a.net.URL; | |
| 50 | import jav a.net.URLD ecoder; | |
| 51 | import jav a.rmi.Remo teExceptio n; | |
| 52 | import jav a.util.Arr ayList; | |
| 53 | import jav a.util.Lis t; | |
| 54 | import jav a.util.Map ; | |
| 55 | import org .apache.ax is2.AxisFa ult; | |
| 56 | import org .apache.ax is2.addres sing.Endpo intReferen ce; | |
| 57 | import org .apache.ax is2.client .Options; | |
| 58 | import org .apache.ax is2.client .ServiceCl ient; | |
| 59 | import org .apache.ax is2.contex t.Configur ationConte xt; | |
| 60 | import org .apache.ax is2.contex t.Configur ationConte xtFactory; | |
| 61 | import org .apache.ax is2.contex t.MessageC ontext; | |
| 62 | import org .apache.ax is2.transp ort.http.H TTPConstan ts; | |
| 63 | import org .apache.ax is2.transp ort.http.H ttpTranspo rtProperti es; | |
| 64 | import org .apache.co mmons.http client.pro tocol.Defa ultProtoco lSocketFac tory; | |
| 65 | import org .apache.co mmons.http client.pro tocol.Prot ocol; | |
| 66 | import org .apache.co mmons.http client.pro tocol.Prot ocolSocket Factory; | |
| 67 | import org .apache.lo gging.log4 j.LogManag er; | |
| 68 | import org .apache.lo gging.log4 j.Logger; | |
| 69 | ||
| 70 | /** | |
| 71 | * @author vhaiswwer fej | |
| 72 | * | |
| 73 | */ | |
| 74 | public cla ss XCAData SourceProx y | |
| 75 | { | |
| 76 | // The "prot ocol" to u se for sec ure connec tions set up using t he trustst ore | |
| 77 | // and keyst ore specif ied in the configura tion | |
| 78 | pu blic stati c final St ring SECUR E_XCA_VIRT UAL_PROTOC OL = "xcas "; | |
| 79 | pu blic stati c final St ring XCA_V IRTUAL_PRO TOCOL = "x ca"; | |
| 80 | ||
| 81 | /* * | |
| 82 | * | |
| 83 | * / | |
| 84 | // private st atic final String DE FAULT_HOME _COMMUNITY _OID = "ur n:oid:2.16 .840.1.113 883.3.166" ; | |
| 85 | pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(XCAD ataSourceP roxy.class ); | |
| 86 | pr ivate stat ic Configu rationCont ext config Context; | |
| 87 | ||
| 88 | st atic | |
| 89 | { | |
| 90 | St ring home = System.g etenv("CAT ALINA_HOME "); | |
| 91 | ho me = home == null ? System.get Property(" catalina.h ome") : ho me; | |
| 92 | ||
| 93 | // create th is folder at your ho me. This f older coul d be anyth ing | |
| 94 | // then creat e the "mod ules" fold er | |
| 95 | ||
| 96 | Fi le reposit ory = new File(home + File.sep arator + " axis2-repo sitory"); | |
| 97 | if (!reposit ory.exists ()) | |
| 98 | LogManag er.getLogg er(XCAData SourceProx y.class).e rror("AXIS 2 reposito ry '" + re pository.g etAbsolute Path() + " ' does not exist"); | |
| 99 | ||
| 100 | // copy the L oggingModu le.mar to "modules" folder. | |
| 101 | // then modif y the axis 2.xml that is genera ting there according to | |
| 102 | // phases tha t being in cluded in the "modul e.xml" | |
| 103 | tr y | |
| 104 | { | |
| 105 | config Context = Configurat ionContext Factory. | |
| 106 | createCo nfiguratio nContextFr omFileSyst em(reposit ory.getAbs olutePath( ), reposit ory.getAbs olutePath( ) + "/conf /client-ax is2.xml"); | |
| 107 | Servic eClient se rviceClien t = new Se rviceClien t(configCo ntext, nul l); | |
| 108 | servic eClient.en gageModule ("addressi ng"); | |
| 109 | } | |
| 110 | catc h (AxisFau lt x) | |
| 111 | { | |
| 112 | x.prin tStackTrac e(); | |
| 113 | } | |
| 114 | } | |
| 115 | ||
| 116 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 117 | // | |
| 118 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 119 | ||
| 120 | pr ivate fina l XCATrans latorXmlBe ans xmlBea nsTranslat or; | |
| 121 | pr ivate fina l XCATrans latorAdb a dbTranslat or; | |
| 122 | pr ivate fina l gov.va.m ed.imaging .ihe.xca.x mlbeans.Re spondingGa teway_Serv iceStub qu eryStub; | |
| 123 | pr ivate fina l gov.va.m ed.imaging .ihe.xca.a db.Respond ingGateway Retrieve_S erviceStub retrieveS tub; | |
| 124 | pr ivate fina l Resolved ArtifactSo urce resol vedArtifac tSource; | |
| 125 | pr ivate fina l URL quer yUrl; | |
| 126 | pr ivate fina l URL retr ieveUrl; | |
| 127 | pr ivate fina l XCADataS ourceConfi guration c onfigurati on; | |
| 128 | ||
| 129 | /* * | |
| 130 | * The Resol vedArtifac tSource pa ssed to th is constru ctor must have only one | |
| 131 | * URL for t he query a nd one for the retri eve. Any URL fixup in protoco l | |
| 132 | * or path m ust be com pleted bef ore this c onstructor . This in stance wil l use | |
| 133 | * the first URL in ea ch list wi thout modi fication. | |
| 134 | * | |
| 135 | * @param si teConfigur ation | |
| 136 | * @param si te | |
| 137 | * @param ho meCommunit yOid | |
| 138 | * @throws C onnectionE xception | |
| 139 | * / | |
| 140 | pu blic XCADa taSourcePr oxy( | |
| 141 | Reso lvedArtifa ctSource r esolvedArt ifactSourc e, | |
| 142 | XCAD ataSourceC onfigurati on configu ration) | |
| 143 | th rows Conne ctionExcep tion | |
| 144 | { | |
| 145 | this .configura tion = con figuration ; | |
| 146 | this .xmlBeansT ranslator = new XCAT ranslatorX mlBeans(); | |
| 147 | this .adbTransl ator = new XCATransl atorAdb(); | |
| 148 | ||
| 149 | this .resolvedA rtifactSou rce = reso lvedArtifa ctSource; | |
| 150 | ||
| 151 | List <String> q ueryAuthSc hemeList = new Array List<Strin g>(); | |
| 152 | quer yAuthSchem eList.add( HttpTransp ortPropert ies.Authen ticator.BA SIC); | |
| 153 | //qu eryAuthSch emeList.ad d(HttpTran sportPrope rties.Auth enticator. DIGEST); | |
| 154 | //qu eryAuthSch emeList.ad d(HttpTran sportPrope rties.Auth enticator. NTLM); | |
| 155 | ||
| 156 | List <String> r etrieveAut hSchemeLis t = new Ar rayList<St ring>(); | |
| 157 | retr ieveAuthSc hemeList.a dd(HttpTra nsportProp erties.Aut henticator .BASIC); | |
| 158 | //re trieveAuth SchemeList .add(HttpT ransportPr operties.A uthenticat or.DIGEST) ; | |
| 159 | //re trieveAuth SchemeList .add(HttpT ransportPr operties.A uthenticat or.NTLM); | |
| 160 | ||
| 161 | if(r esolvedArt ifactSourc e.getMetad ataUrls(). size() < 1 ) | |
| 162 | throw new Connec tionExcept ion("The r esolved ar tifact sou rce '" + r esolvedArt ifactSourc e.toString () +"' doe s not supp ort the re quired pro tocol '" + XCADocume ntDataSour ceService. SUPPORTED_ PROTOCOL + "' for me tadata."); | |
| 163 | if(r esolvedArt ifactSourc e.getArtif actUrls(). size() < 1 ) | |
| 164 | throw new Connec tionExcept ion("The r esolved ar tifact sou rce '" + r esolvedArt ifactSourc e.toString () +"' doe s not supp ort the re quired pro tocol '" + XCADocume ntDataSour ceService. SUPPORTED_ PROTOCOL + "' for ar tifacts.") ; | |
| 165 | ||
| 166 | // s et this be fore creat ing the st ubs, we us e getters that depen d | |
| 167 | // o n these va lues in th e stub cre ation | |
| 168 | this .queryUrl = resolved ArtifactSo urce.getMe tadataUrls ().get(0); | |
| 169 | this .retrieveU rl = resol vedArtifac tSource.ge tArtifactU rls().get( 0); | |
| 170 | ||
| 171 | // r equires th at the que ry and ret rieve URL fields be set | |
| 172 | vali dateProtoc olRegistra tion(); | |
| 173 | ||
| 174 | try | |
| 175 | { | |
| 176 | //queryUrl = new URL ("http:// IP /DocSearch XcaService /Respondin gGateway_S ervice"); | |
| 177 | //queryUrl = new URL ("http://l ocalhost: PORT /DocSearch XcaService /Respondin gGateway_S ervice"); | |
| 178 | this.q ueryStub = new gov.v a.med.imag ing.ihe.xc a.xmlbeans .Respondin gGateway_S erviceStub (configCon text, this .getQueryU rlWithoutU serInfo()) ; | |
| 179 | if(get QueryUrlUs erID() != null) | |
| 180 | { | |
| 181 | HttpTran sportPrope rties.Auth enticator queryAutho rization = new HttpT ransportPr operties.A uthenticat or(); | |
| 182 | queryAut horization .setUserna me(getQuer yUrlUserID ()); | |
| 183 | if(getQu eryUrlPass word() != null) | |
| 184 | queryAutho rization.s etPassword (getQueryU rlPassword ()); | |
| 185 | queryAut horization .setAuthSc hemes(quer yAuthSchem eList); | |
| 186 | queryAut horization .setPreemp tiveAuthen tication(t rue); | |
| 187 | Options queryOptio ns = | |
| 188 | queryStub. _getServic eClient(). getOptions () != null ? | |
| 189 | qu eryStub._g etServiceC lient().ge tOptions() : | |
| 190 | ne w Options( ); | |
| 191 | queryOpt ions.setPr operty(HTT PConstants .AUTHENTIC ATE, query Authorizat ion); | |
| 192 | queryStu b._getServ iceClient( ).setOptio ns(queryOp tions); | |
| 193 | } | |
| 194 | Servic eClient qu eryService Client = t his.queryS tub._getSe rviceClien t(); | |
| 195 | System .out.print ln( "Query service c lient is o f type '" + querySer viceClient .getClass( ).getCanon icalName() + "'." ); | |
| 196 | ||
| 197 | this.r etrieveStu b = new go v.va.med.i maging.ihe .xca.adb.R espondingG atewayRetr ieve_Servi ceStub(con figContext , this.get RetrieveUr lWithoutUs erInfo()); | |
| 198 | Option s retrieve Options = | |
| 199 | retrieve Stub._getS erviceClie nt().getOp tions() != null ? | |
| 200 | retrieveSt ub._getSer viceClient ().getOpti ons() : | |
| 201 | new Option s(); | |
| 202 | if(get RetrieveUr lUserID() != null) | |
| 203 | { | |
| 204 | HttpTran sportPrope rties.Auth enticator retrieveAu thorizatio n = new Ht tpTranspor tPropertie s.Authenti cator(); | |
| 205 | retrieve Authorizat ion.setUse rname(getR etrieveUrl UserID()); | |
| 206 | if(getRe trieveUrlP assword() != null) | |
| 207 | retrieveAu thorizatio n.setPassw ord(getRet rieveUrlPa ssword()); | |
| 208 | retrieve Authorizat ion.setAut hSchemes(r etrieveAut hSchemeLis t); | |
| 209 | retrieve Options.se tProperty( HTTPConsta nts.AUTHEN TICATE, re trieveAuth orization) ; | |
| 210 | } | |
| 211 | //retr ieveOption s.setPrope rty(Messag eContextCo nstants.TR ANSPORT_UR L,"**https ://myservi ces.test.c om/testhar ness/myapp licationap i.asmx");* | |
| 212 | // put the real protocol i nto the WS -Addressin g "to" ele ment | |
| 213 | URL ht tpRetrieve Url = getR etrieveUrl (); | |
| 214 | if("xc a".equals( getRetriev eUrl().get Protocol() ) ) | |
| 215 | httpRetr ieveUrl = new URL("h ttp", getR etrieveUrl ().getHost (), getRet rieveUrl() .getPort() , getRetri eveUrl().g etFile()); | |
| 216 | else i f("xcas".e quals(getR etrieveUrl ().getProt ocol()) ) | |
| 217 | httpRetr ieveUrl = new URL("h ttps", get RetrieveUr l().getHos t(), getRe trieveUrl( ).getPort( ), getRetr ieveUrl(). getFile()) ; | |
| 218 | logger .info("Set ting WS-Ad dressing ' to' to end point refe rence '" + httpRetri eveUrl.toS tring() + "'."); | |
| 219 | retrie veOptions. setTo(new EndpointRe ference(ht tpRetrieve Url.toStri ng())); | |
| 220 | retrie veOptions. setTimeOut InMilliSec onds(getRe trieveTime out()); | |
| 221 | ||
| 222 | retrie veStub._ge tServiceCl ient().set Options(re trieveOpti ons); | |
| 223 | ||
| 224 | //Serv iceClient retrieveSe rviceClien t = this.r etrieveStu b._getServ iceClient( ); | |
| 225 | //Syst em.out.pri ntln( "Ret rieve serv ice client is of typ e '" + ret rieveServi ceClient.g etClass(). getCanonic alName() + "'." ); | |
| 226 | } | |
| 227 | catc h(AxisFaul t afX) | |
| 228 | { | |
| 229 | logger .error("Er ror creati ng XCA pro xy", afX); | |
| 230 | throw new Connec tionExcept ion(afX); | |
| 231 | } | |
| 232 | catc h (Malform edURLExcep tion murlX ) | |
| 233 | { | |
| 234 | logger .error("Er ror creati ng XCA pro xy", murlX ); | |
| 235 | throw new Connec tionExcept ion(murlX) ; | |
| 236 | } | |
| 237 | } | |
| 238 | ||
| 239 | pr ivate int getQueryTi meout() | |
| 240 | { | |
| 241 | if(c onfigurati on.getQuer yTimeout() == null) | |
| 242 | return XCADataSo urceConfig uration.de faultQuery Timeout; | |
| 243 | retu rn configu ration.get QueryTimeo ut(); | |
| 244 | } | |
| 245 | ||
| 246 | pr ivate int getRetriev eTimeout() | |
| 247 | { | |
| 248 | if(c onfigurati on.getRetr ieveTimeou t() == nul l) | |
| 249 | return XCADataSo urceConfig uration.de faultRetri eveTimeout ; | |
| 250 | retu rn configu ration.get RetrieveTi meout(); | |
| 251 | } | |
| 252 | ||
| 253 | /* * | |
| 254 | * @param qu eryUrl2 | |
| 255 | * @param re trieveUrl2 | |
| 256 | * / | |
| 257 | pr ivate void validateP rotocolReg istration( ) | |
| 258 | { | |
| 259 | // t his is syn chronized with the c lass insta nce so tha t multiple instances | |
| 260 | // d o not try to registe r the prot ocol socke t factory | |
| 261 | sync hronized(X CADataSour ceProxy.cl ass) | |
| 262 | { | |
| 263 | if(! i sProtocolH andlerRegi stered(get QueryUrl() .getProtoc ol())) | |
| 264 | register ProtocolHa ndler(getQ ueryUrl(). getProtoco l()); | |
| 265 | if(! i sProtocolH andlerRegi stered(get RetrieveUr l().getPro tocol())) | |
| 266 | register ProtocolHa ndler(getR etrieveUrl ().getProt ocol()); | |
| 267 | } | |
| 268 | } | |
| 269 | ||
| 270 | /* * | |
| 271 | * @param pr otocol | |
| 272 | * / | |
| 273 | pr ivate void registerP rotocolHan dler(Strin g protocol ) | |
| 274 | { | |
| 275 | if( XCA_VIRTUA L_PROTOCOL .equalsIgn oreCase(pr otocol) ) | |
| 276 | { | |
| 277 | Protoc ol httpPro tocol = Pr otocol.get Protocol(" http"); | |
| 278 | if(htt pProtocol == null) | |
| 279 | { | |
| 280 | logger.e rror("Fail ed to regi ster proto col '" + p rotocol + "' because mapped ht tp protoco l is not r egistered, attemptin g to creat e a defaul t socket f actory."); | |
| 281 | Protocol .registerP rotocol( X CA_VIRTUAL _PROTOCOL, new Proto col(protoc ol, new De faultProto colSocketF actory(), 80) ); | |
| 282 | logger.i nfo("Proto col '" + p rotocol + "' registe red to a n ew default socket fa ctory."); | |
| 283 | } | |
| 284 | else | |
| 285 | Protocol .registerP rotocol(XC A_VIRTUAL_ PROTOCOL, httpProtoc ol ); | |
| 286 | } | |
| 287 | else if( SECUR E_XCA_VIRT UAL_PROTOC OL.equalsI gnoreCase( protocol) ) | |
| 288 | { | |
| 289 | try | |
| 290 | { | |
| 291 | // Eithe r keystore or trusts tore may b e null but not both | |
| 292 | // or Au thSSLProto colSocketF actory wil l fail to construct. | |
| 293 | URL keys toreUrl = new URL(co nfiguratio n.getKeyst oreUrl()); // t he keystor e containi ng the key to send a s the clie nt | |
| 294 | URL trus tstoreUrl = new URL( configurat ion.getTru ststoreUrl ()); // t he keystor e containi ng the tru sted certi ficates, t o validate the serve r cert aga inst | |
| 295 | ||
| 296 | Protocol SocketFact ory socket Factory = | |
| 297 | new AuthSSLPro tocolSocke tFactory( | |
| 298 | keystoreUr l, configu ration.get KeystorePa ssword(), | |
| 299 | truststore Url, confi guration.g etTruststo rePassword ()); | |
| 300 | Protocol httpsProt ocol = new Protocol( protocol, socketFact ory, confi guration.g etTLSPort( )); | |
| 301 | ||
| 302 | // regis ter our so cket facto ry using t he 'virtua l' scheme "xcas". | |
| 303 | // When creating a socket co nnection u se "xcas" in the URI e.g. | |
| 304 | // HttpC lient http client = n ew HttpCli ent(); | |
| 305 | // GetMe thod httpg et = new G etMethod(" xcas://www .whatever. com/"); | |
| 306 | Protocol .registerP rotocol(SE CURE_XCA_V IRTUAL_PRO TOCOL, htt psProtocol ); | |
| 307 | } | |
| 308 | catch (Malformed URLExcepti on x) | |
| 309 | { | |
| 310 | x.printS tackTrace( ); | |
| 311 | logger.e rror("Fail ed to regi ster proto col '" + p rotocol + "' unable to form va lid trust or key sto re URL [" + x.getMes sage() + " ]."); | |
| 312 | } | |
| 313 | } | |
| 314 | else | |
| 315 | logger .error("Pr otocol '" + protocol + "' is n ot registe red with a socket fa ctory."); | |
| 316 | ||
| 317 | if(i sProtocolH andlerRegi stered(pro tocol)) | |
| 318 | logger .info("Pro tocol '" + protocol + "' regis tered succ essfully." ); | |
| 319 | else | |
| 320 | logger .info("Pro tocol '" + protocol + "' faile d to regis ter."); | |
| 321 | } | |
| 322 | ||
| 323 | /* * | |
| 324 | * @param pr otocol | |
| 325 | * @return | |
| 326 | * / | |
| 327 | pr ivate bool ean isProt ocolHandle rRegistere d(String p rotocol) | |
| 328 | { | |
| 329 | try | |
| 330 | { | |
| 331 | return Protocol. getProtoco l(protocol ) != null; | |
| 332 | } | |
| 333 | catc h (Illegal StateExcep tion x) | |
| 334 | { | |
| 335 | return false; | |
| 336 | } | |
| 337 | } | |
| 338 | ||
| 339 | /* * | |
| 340 | * @return t he queryUr l as passe d to the c onstructor for this class | |
| 341 | * / | |
| 342 | pu blic URL g etQueryUrl () | |
| 343 | { | |
| 344 | retu rn this.qu eryUrl; | |
| 345 | } | |
| 346 | ||
| 347 | /* * | |
| 348 | * @return t he retriev eUrl as pa ssed to th e construc tor for th is class | |
| 349 | * / | |
| 350 | pu blic URL g etRetrieve Url() | |
| 351 | { | |
| 352 | retu rn this.re trieveUrl; | |
| 353 | } | |
| 354 | ||
| 355 | pr ivate Stri ng getQuer yUrlWithou tUserInfo( ) | |
| 356 | { | |
| 357 | retu rn getUrlW ithoutUser Info(getQu eryUrl()); | |
| 358 | } | |
| 359 | ||
| 360 | pr ivate Stri ng getRetr ieveUrlWit houtUserIn fo() | |
| 361 | { | |
| 362 | retu rn getUrlW ithoutUser Info(getRe trieveUrl( )); | |
| 363 | } | |
| 364 | ||
| 365 | pr ivate Stri ng getUrlW ithoutUser Info(URL u rl) | |
| 366 | { | |
| 367 | retu rn url.get Protocol() + | |
| 368 | "://" + | |
| 369 | url.ge tHost() + | |
| 370 | (url.g etPort() > 0 ? ":" + url.getPo rt() : "") + | |
| 371 | url.ge tFile(); | |
| 372 | } | |
| 373 | ||
| 374 | pr ivate Stri ng getQuer yUrlUserID () | |
| 375 | { | |
| 376 | retu rn parseUs erID(getQu eryUrl().g etUserInfo ()); | |
| 377 | } | |
| 378 | pr ivate Stri ng getQuer yUrlPasswo rd() | |
| 379 | { | |
| 380 | retu rn parsePa ssword(get QueryUrl() .getUserIn fo()); | |
| 381 | } | |
| 382 | ||
| 383 | pr ivate Stri ng getRetr ieveUrlUse rID() | |
| 384 | { | |
| 385 | retu rn parseUs erID(getRe trieveUrl( ).getUserI nfo()); | |
| 386 | } | |
| 387 | pr ivate Stri ng getRetr ieveUrlPas sword() | |
| 388 | { | |
| 389 | retu rn parsePa ssword(get RetrieveUr l().getUse rInfo()); | |
| 390 | } | |
| 391 | ||
| 392 | pr ivate fina l static S tring utf8 = "UTF-8" ; | |
| 393 | pr ivate Stri ng parseUs erID(Strin g userInfo ) | |
| 394 | { | |
| 395 | if(u serInfo != null) | |
| 396 | { | |
| 397 | String [] userInf oComponent s = userIn fo.split(" :"); | |
| 398 | if(use rInfoCompo nents[0] ! = null) | |
| 399 | { | |
| 400 | try | |
| 401 | { | |
| 402 | return URL Decoder.de code(userI nfoCompone nts[0], ut f8); | |
| 403 | } | |
| 404 | catch (U nsupported EncodingEx ception e) | |
| 405 | { | |
| 406 | //e.printS tackTrace( ); | |
| 407 | logger.war n("Error U RL decodin g username '" + user InfoCompon ents[0] + "'."); | |
| 408 | return use rInfoCompo nents[0]; | |
| 409 | } | |
| 410 | } | |
| 411 | } | |
| 412 | retu rn null; | |
| 413 | } | |
| 414 | pr ivate Stri ng parsePa ssword(Str ing userIn fo) | |
| 415 | { | |
| 416 | if(u serInfo != null) | |
| 417 | { | |
| 418 | String [] userInf oComponent s = userIn fo.split(" :"); | |
| 419 | if(use rInfoCompo nents.leng th > 1) | |
| 420 | { | |
| 421 | String p wd = userI nfoCompone nts[1]; | |
| 422 | if(pwd ! = null) | |
| 423 | { | |
| 424 | try | |
| 425 | { | |
| 426 | re turn URLDe coder.deco de(pwd, ut f8); | |
| 427 | } | |
| 428 | catch (Uns upportedEn codingExce ption e) | |
| 429 | { | |
| 430 | // e.printSta ckTrace(); | |
| 431 | lo gger.warn( "Error URL decoding password ' " + pwd + "'."); | |
| 432 | re turn pwd; | |
| 433 | } | |
| 434 | } | |
| 435 | } | |
| 436 | } | |
| 437 | retu rn null; | |
| 438 | } | |
| 439 | ||
| 440 | /* * | |
| 441 | * @return t he configu ration | |
| 442 | * / | |
| 443 | pu blic XCADa taSourceCo nfiguratio n getConfi guration() | |
| 444 | { | |
| 445 | retu rn this.co nfiguratio n; | |
| 446 | } | |
| 447 | ||
| 448 | pu blic XCATr anslatorXm lBeans get XmlBeansTr anslator() | |
| 449 | { | |
| 450 | retu rn this.xm lBeansTran slator; | |
| 451 | } | |
| 452 | ||
| 453 | pu blic XCATr anslatorAd b getAdbTr anslator() | |
| 454 | { | |
| 455 | retu rn this.ad bTranslato r; | |
| 456 | } | |
| 457 | ||
| 458 | /* * | |
| 459 | * | |
| 460 | * @param pa tientIcn | |
| 461 | * @param fi lter | |
| 462 | * @return | |
| 463 | * @throws M ethodExcep tion | |
| 464 | * @throws C onnectionE xception | |
| 465 | * / | |
| 466 | pu blic Docum entSetResu lt getPati entDocumen tSets( | |
| 467 | Docu mentFilter filter) | |
| 468 | th rows Metho dException , Connecti onExceptio n | |
| 469 | { | |
| 470 | //St oredQueryP arameterSe t requestP arameters = new Stor edQueryPar ameterSet( ); | |
| 471 | //Cr ossGateway QueryReque st request = new Cro ssGatewayQ ueryReques t( | |
| 472 | // getHom eCommunity Oid(), | |
| 473 | // -1L, | |
| 474 | // true, | |
| 475 | // reques tParameter s | |
| 476 | //); | |
| 477 | ||
| 478 | vali dateUrl(ge tQueryUrl( )); | |
| 479 | ||
| 480 | org. oasis.ebxm l.regrep.q uery.xmlbe ans.AdhocQ ueryReques tDocument request; | |
| 481 | try | |
| 482 | { | |
| 483 | getXml BeansTrans lator(); | |
| 484 | reques t = XCATra nslatorXml Beans.tran slate(filt er); | |
| 485 | } | |
| 486 | catc h (Malform edURLExcep tion x) | |
| 487 | { | |
| 488 | logger .error("Er ror creati ng a query instance" , x); | |
| 489 | throw new Connec tionExcept ion(x); | |
| 490 | } | |
| 491 | ||
| 492 | try | |
| 493 | { | |
| 494 | Transa ctionConte xt transac tionContex t = Transa ctionConte xtFactory. get(); | |
| 495 | transa ctionConte xt.addDebu gInformati on("Execut ing CrossG atewayQuer y to url ' " + getQue ryUrlWitho utUserInfo () + "'"); | |
| 496 | logger .info("Exe cuting Cro ssGatewayQ uery to ur l '" + get QueryUrlWi thoutUserI nfo() + "' "); | |
| 497 | ||
| 498 | // for ce SOAP 1. 1 | |
| 499 | //quer yStub._get ServiceCli ent().getO ptions().s etSoapVers ionURI(org .apache.ax iom.soap.S OAP11Const ants.SOAP_ ENVELOPE_N AMESPACE_U RI); | |
| 500 | // for ce SOAP 1. 2 | |
| 501 | queryS tub._getSe rviceClien t().getOpt ions().set SoapVersio nURI(org.a pache.axio m.soap.SOA P12Constan ts.SOAP_EN VELOPE_NAM ESPACE_URI ); | |
| 502 | // set SOAP acti on | |
| 503 | queryS tub._getSe rviceClien t().getOpt ions().set Property(o rg.apache. axis2.tran sport.http .HTTPConst ants.HEADE R_SOAP_ACT ION, "urn: ihe:iti:20 07:CrossGa tewayQuery "); | |
| 504 | queryS tub._getSe rviceClien t().getOpt ions().set Property(o rg.apache. axis2.tran sport.http .HTTPConst ants.HEADE R_ACCEPT_A PPL_SOAP, "urn:ihe:i ti:2007:Cr ossGateway Query"); | |
| 505 | // tur n chunking off | |
| 506 | queryS tub._getSe rviceClien t().getOpt ions().set Property(o rg.apache. axis2.tran sport.http .HTTPConst ants.CHUNK ED, Boolea n.FALSE); | |
| 507 | queryS tub._getSe rviceClien t().getOpt ions().set TimeOutInM illiSecond s(getQuery Timeout()) ; | |
| 508 | ||
| 509 | ArrayL ist<org.ap ache.commo ns.httpcli ent.Header > customHt tpHeaders = addTrans actionCont extFieldsT oHeaders() ; | |
| 510 | // the HTTP head er MUST be quoted be cause it c ontains sp ecial char acters as defined in IETF RFC 822 | |
| 511 | custom HttpHeader s.add(new org.apache .commons.h ttpclient. Header("SO APAction", "\"urn:ih e:iti:2007 :CrossGate wayQuery\" ")); | |
| 512 | ||
| 513 | String patientId = filter. getPatient Id(); | |
| 514 | if(p atientId ! = null && patientId. length() > 0) | |
| 515 | custom HttpHeader s.add(new org.apache .commons.h ttpclient. Header(Tra nsactionCo ntextHttpH eaders.htt pHeaderPat ientId, | |
| 516 | patientId) ); | |
| 517 | ||
| 518 | queryS tub._getSe rviceClien t().getOpt ions().set Property( | |
| 519 | org.apache .axis2.tra nsport.htt p.HTTPCons tants.HTTP _HEADERS, customHttp Headers); | |
| 520 | ||
| 521 | //quer yStub._get ServiceCli ent().enga geModule(" addressing "); | |
| 522 | ||
| 523 | //quer yStub._get ServiceCli ent().addS tringHeade r( new QNa me("http:/ /www.w3.or g/2005/08/ addressing ", "Action "), "urn:i he:iti:200 7:CrossGat ewayQuery" ); | |
| 524 | // try | |
| 525 | // { | |
| 526 | // OMNamesp ace omName space = OM AbstractFa ctory.getO MFactory() .createOMN amespace(" http://wso 2.com", "w s"); | |
| 527 | // SOAPHead erBlock se condHeader = OMAbstr actFactory .getSOAP12 Factory(). createSOAP HeaderBloc k("Action" , omNamesp ace); | |
| 528 | // secondHe ader.addCh ild(AXIOMU til.string ToOM("urn: ihe:iti:20 07:CrossGa tewayQuery ")); | |
| 529 | // //second Header.set MustUnders tand(true) ; | |
| 530 | // queryStu b._getServ iceClient( ).addHeade r(secondHe ader); | |
| 531 | // } | |
| 532 | // catch (XMLStream Exception x) | |
| 533 | // { | |
| 534 | // x.printS tackTrace( ); | |
| 535 | // } | |
| 536 | ||
| 537 | org.oa sis.ebxml. regrep.que ry.xmlbean s.AdhocQue ryResponse Document r esponse = | |
| 538 | queryStu b.respondi ngGateway_ CrossGatew ayQuery(re quest); | |
| 539 | logger .info("Cro ssGatewayQ uery compl eted execu tion, tran slating re sults"); | |
| 540 | ||
| 541 | //dump MessageCon textProper ties(); | |
| 542 | ||
| 543 | Docume ntSetResul t result = | |
| 544 | XCATrans latorXmlBe ans.transl ate( | |
| 545 | re sponse, | |
| 546 | fi lter.getPa tientId(), | |
| 547 | re solvedArti factSource , | |
| 548 | ge tConfigura tion().get ProxyConfi guration() .isAllowPa rtialSucce ss().boole anValue() | |
| 549 | ); | |
| 550 | transa ctionConte xt.addDebu gInformati on("Docume ntSetResul t: " + (re sult == nu ll ? "null " : result .toString( true))); | |
| 551 | return result; | |
| 552 | } | |
| 553 | catc h(RemoteEx ception rX ) | |
| 554 | { | |
| 555 | String msg = | |
| 556 | "Error m aking XCA Query Requ est \n" + | |
| 557 | "Binding name is " + querySt ub._getSer viceClient ().getAxis Service(). getBinding Name() + " '."; | |
| 558 | System .err.print ln(msg); | |
| 559 | logger .error( ms g, rX); | |
| 560 | dumpMe ssageConte xtProperti es(); | |
| 561 | throw new Method Exception( rX); | |
| 562 | } | |
| 563 | catc h (Transla tionExcept ion tX) | |
| 564 | { | |
| 565 | logger .error("Er ror transl ating XCA Query resp onse", tX) ; | |
| 566 | throw new Method Exception( tX); | |
| 567 | } | |
| 568 | ||
| 569 | } | |
| 570 | ||
| 571 | /* * | |
| 572 | * Verifies the provid ed URL con tains a va lid host a nd port to use | |
| 573 | * @param ur l | |
| 574 | * @throws M ethodExcep tion | |
| 575 | * / | |
| 576 | pr ivate void validateU rl(URL url ) | |
| 577 | th rows Metho dException | |
| 578 | { | |
| 579 | if(u rl.getHost () == null || url.ge tHost().le ngth() == 0) | |
| 580 | throw new Method Exception( "Cannot co nnect to u rl '" + ur l.toString () + "', m issing hos t."); | |
| 581 | if(u rl.getPort () <= 0) | |
| 582 | throw new Method Exception( "Cannot co nnect to u rl '" + ur l.toString () + "', p ort is inv alid."); | |
| 583 | } | |
| 584 | ||
| 585 | pr ivate void dumpMessa geContextP roperties( ) | |
| 586 | { | |
| 587 | try | |
| 588 | { | |
| 589 | Map<St ring, Mess ageContext > msgConte xts = | |
| 590 | queryStu b._getServ iceClient( ).getLastO perationCo ntext().ge tMessageCo ntexts(); | |
| 591 | for(Ma p.Entry<St ring, Mess ageContext > msgConte xtEntry : msgContext s.entrySet ()) | |
| 592 | { | |
| 593 | MessageC ontext msg Context = msgContext Entry.getV alue(); | |
| 594 | logger.i nfo("Dumpi ng propert ies for " + flowText (msgContex t.FLOW) + " message context '" + msgCont ext.toStri ng() + "'. "); | |
| 595 | for( Map .Entry<Str ing, Objec t> propert yEntry : m sgContext. getPropert ies().entr ySet() ) | |
| 596 | logger.inf o("\t'" + propertyEn try.getKey () + "' => '" + prop ertyEntry. getValue() .toString( ) + "'."); | |
| 597 | } | |
| 598 | } | |
| 599 | catc h(Exceptio n x) | |
| 600 | { | |
| 601 | logger .error( "U nable to p rovide mes sage detai ls" ); | |
| 602 | } | |
| 603 | } | |
| 604 | pr ivate Stri ng flowTex t(int flow ) | |
| 605 | { | |
| 606 | swit ch(flow) | |
| 607 | { | |
| 608 | case MessageCo ntext.IN_F LOW: retur n "in-flow "; | |
| 609 | case MessageCo ntext.OUT_ FLOW: retu rn "out-fl ow"; | |
| 610 | case MessageCo ntext.IN_F AULT_FLOW: return "i n--fault-f low"; | |
| 611 | case MessageCo ntext.OUT_ FAULT_FLOW : return " out-fault- flow"; | |
| 612 | defa ult: retur n "unknown flow dire ction"; | |
| 613 | } | |
| 614 | ||
| 615 | } | |
| 616 | ||
| 617 | pr ivate Arra yList<org. apache.com mons.httpc lient.Head er> addTra nsactionCo ntextField sToHeaders () | |
| 618 | { | |
| 619 | Arra yList<org. apache.com mons.httpc lient.Head er> custom HttpHeader s = | |
| 620 | new Ar rayList<or g.apache.c ommons.htt pclient.He ader>(); | |
| 621 | ||
| 622 | // B HIE requir es this he ader to kn ow the req uest came from the V A | |
| 623 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 624 | Stri ng sitenam e = transa ctionConte xt.getSite Name(); | |
| 625 | if (sitename != null && sitename. length() > 0) | |
| 626 | cust omHttpHead ers.add(ne w org.apac he.commons .httpclien t.Header(T ransaction ContextHtt pHeaders.h ttpHeaderS iteName, | |
| 627 | "VA_" + sitename)) ; | |
| 628 | ||
| 629 | St ring fulln ame = tran sactionCon text.getFu llName(); | |
| 630 | if (fullname != null && fullname. length() > 0) | |
| 631 | cust omHttpHead ers.add(ne w org.apac he.commons .httpclien t.Header(T ransaction ContextHtt pHeaders.h ttpHeaderF ullName, | |
| 632 | fullname )); | |
| 633 | ||
| 634 | St ring siten umber = tr ansactionC ontext.get SiteNumber (); | |
| 635 | if (sitenumbe r != null && sitenum ber.length () > 0) | |
| 636 | cust omHttpHead ers.add(ne w org.apac he.commons .httpclien t.Header(T ransaction ContextHtt pHeaders.h ttpHeaderS iteNumber, | |
| 637 | sitenumb er)); | |
| 638 | ||
| 639 | // for the u ser identi fier, use the SSN or the user division a nd name or the trans action ID | |
| 640 | St ring userI dentifier = | |
| 641 | tran sactionCon text.getSs n() != nul l && trans actionCont ext.getSsn ().length( ) > 0 ? | |
| 642 | transa ctionConte xt.getSsn( ) : | |
| 643 | transa ctionConte xt.getLogg erUserDivi sion() != null && | |
| 644 | transa ctionConte xt.getLogg erUserDivi sion().len gth() > 0 && | |
| 645 | transa ctionConte xt.getLogg erFullName () != null && | |
| 646 | transa ctionConte xt.getLogg erFullName ().length( ) > 0 ? | |
| 647 | transact ionContext .getLogger UserDivisi on() + ":" + transac tionContex t.getLogge rFullName( ) : | |
| 648 | transact ionContext .getTransa ctionId() != null && transacti onContext. getTransac tionId().l ength() > 0 ? | |
| 649 | transactio nContext.g etTransact ionId() : null; | |
| 650 | if (userIdent ifier != n ull && use rIdentifie r.length() > 0) | |
| 651 | cust omHttpHead ers.add( | |
| 652 | new or g.apache.c ommons.htt pclient.He ader(Trans actionCont extHttpHea ders.httpH eaderSSN, userIdenti fier) | |
| 653 | ); | |
| 654 | ||
| 655 | cu stomHttpHe aders.add( new org.ap ache.commo ns.httpcli ent.Header (Transacti onContextH ttpHeaders .httpHeade rPurposeOf Use, | |
| 656 | Requesto r.PurposeO fUse.routi neMedicalC are.getDes cription() )); | |
| 657 | ||
| 658 | St ring trans actionId = transacti onContext. getTransac tionId(); | |
| 659 | if (transacti onId != nu ll && tran sactionId. length() > 0) | |
| 660 | cust omHttpHead ers.add(ne w org.apac he.commons .httpclien t.Header(T ransaction ContextHtt pHeaders.h ttpHeaderT ransaction Id, | |
| 661 | transact ionId)); | |
| 662 | ||
| 663 | re turn custo mHttpHeade rs; | |
| 664 | } | |
| 665 | ||
| 666 | /* * | |
| 667 | * | |
| 668 | * @param do cumentUrn | |
| 669 | * @return | |
| 670 | * @throws M ethodExcep tion | |
| 671 | * @throws C onnectionE xception | |
| 672 | * / | |
| 673 | /* | |
| 674 | pu blic Image StreamResp onse getPa tientDocum ent(Docume ntURN docu mentUrn) | |
| 675 | th rows Metho dException , Connecti onExceptio n | |
| 676 | { | |
| 677 | org. ihe.iti.xd sb.adb.Ret rieveDocum entSetRequ est reques t = null; | |
| 678 | ||
| 679 | logg er.info("C reating XC A Retrieve document request fo r document '" + docu mentUrn.to String() + "'."); | |
| 680 | requ est = this .adbTransl ator.creat eRetrieveD ocumentSet Request(do cumentUrn) ; | |
| 681 | ||
| 682 | try | |
| 683 | { | |
| 684 | logger .info("Exe cuting Cro ssGatewayR etrieve to url '" + retrieveUr l + "'"); | |
| 685 | org.ih e.iti.xdsb .adb.Retri eveDocumen tSetRespon se respons e = | |
| 686 | retrieve Stub.respo ndingGatew ay_CrossGa tewayRetri eve(reques t); | |
| 687 | logger .info("Cro ssGatewayR equest com pleted exe cution, tr anslating results"); | |
| 688 | ||
| 689 | return this.adbT ranslator. translateD ocumentRet rieveRespo nse(respon se); | |
| 690 | ||
| 691 | } | |
| 692 | catc h(IOExcept ion ioe) | |
| 693 | { | |
| 694 | logger .error("Er ror making XCA Retri eve", ioe) ; | |
| 695 | throw new Method Exception( ioe); | |
| 696 | } | |
| 697 | }* / | |
| 698 | ||
| 699 | /* * | |
| 700 | * @param ho meCommunit yUid | |
| 701 | * @param re positoryUn iqueId | |
| 702 | * @param do cumentId | |
| 703 | * @return | |
| 704 | * @throws M ethodExcep tion | |
| 705 | * / | |
| 706 | pu blic Image StreamResp onse getPa tientDocum ent(String homeCommu nityUid, S tring repo sitoryUniq ueId, Stri ng documen tId) | |
| 707 | th rows Metho dException | |
| 708 | { | |
| 709 | org. ihe.iti.xd sb.adb.Ret rieveDocum entSetRequ est reques t = null; | |
| 710 | vali dateUrl(ge tRetrieveU rl()); | |
| 711 | ||
| 712 | logg er.info("C reating XC A Retrieve document request fo r document '" + home CommunityU id + ":" + repositor yUniqueId + ":" + do cumentId + "'."); | |
| 713 | requ est = this .adbTransl ator.creat eRetrieveD ocumentSet Request(ho meCommunit yUid, repo sitoryUniq ueId, docu mentId); | |
| 714 | ||
| 715 | // a dd transac tion conte xt fields necessary to make | |
| 716 | Arra yList<org. apache.com mons.httpc lient.Head er> custom HttpHeader s = addTra nsactionCo ntextField sToHeaders (); | |
| 717 | Opti ons client Options = retrieveSt ub._getSer viceClient ().getOpti ons(); | |
| 718 | clie ntOptions. setPropert y( org.apa che.axis2. transport. http.HTTPC onstants.H TTP_HEADER S, customH ttpHeaders ); | |
| 719 | //cl ientOption s.setPrope rty(Consta nts.Config uration.EN ABLE_MTOM, Constants .VALUE_TRU E); | |
| 720 | ||
| 721 | try | |
| 722 | { | |
| 723 | logger .info("Exe cuting Cro ssGatewayR etrieve to url '" + retrieveUr l + "'"); | |
| 724 | Transa ctionConte xt transac tionContex t = Transa ctionConte xtFactory. get(); | |
| 725 | transa ctionConte xt.addDebu gInformati on("Execut ing CrossG atewayRetr ieve to ur l '" + ret rieveUrl + "'"); | |
| 726 | org.ih e.iti.xdsb .adb.Retri eveDocumen tSetRespon se respons e = | |
| 727 | retrieve Stub.respo ndingGatew ay_CrossGa tewayRetri eve(reques t); | |
| 728 | logger .info("Cro ssGatewayR equest com pleted exe cution, tr anslating results"); | |
| 729 | ||
| 730 | return this.adbT ranslator. translate( response); | |
| 731 | ||
| 732 | } | |
| 733 | catc h(IOExcept ion ioe) | |
| 734 | { | |
| 735 | logger .error("Er ror making XCA Retri eve", ioe) ; | |
| 736 | throw new Method Exception( ioe); | |
| 737 | } | |
| 738 | } | |
| 739 | ||
| 740 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.