Produced by Araxis Merge on 10/5/2018 9:05:31 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 | MHEDP3_VAOS_VATS_SM_Sept2018.zip\SM 2.4.0\scheduling-manager-resources-2.4.0.zip\SchedulingManagerMDWSLib\src\main\java\com\agilex\healthcare\schedulingmanager\mdws\connection | EmrConnection.java | Thu Jul 19 20:06:36 2018 UTC |
| 2 | MHEDP3_VAOS_VATS_SM_Sept2018.zip\SM 2.4.0\scheduling-manager-resources-2.4.0.zip\SchedulingManagerMDWSLib\src\main\java\com\agilex\healthcare\schedulingmanager\mdws\connection | EmrConnection.java | Fri Oct 5 16:53:36 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 450 |
| 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 co m.agilex.h ealthcare. scheduling manager.md ws.connect ion; | |
| 2 | ||
| 3 | import jav a.io.IOExc eption; | |
| 4 | import jav a.io.Seria lizable; | |
| 5 | import jav a.net.Http URLConnect ion; | |
| 6 | import jav a.net.URL; | |
| 7 | import jav a.util.Dat e; | |
| 8 | import jav a.util.UUI D; | |
| 9 | ||
| 10 | import jav ax.xml.nam espace.QNa me; | |
| 11 | import jav ax.xml.ws. BindingPro vider; | |
| 12 | ||
| 13 | import com .agilex.he althcare.s chedulingm anager.uti l.UriUtils ; | |
| 14 | import org .apache.cx f.endpoint .Client; | |
| 15 | import org .apache.cx f.frontend .ClientPro xy; | |
| 16 | import org .apache.cx f.transpor t.http.HTT PConduit; | |
| 17 | import org .apache.cx f.transpor ts.http.co nfiguratio n.HTTPClie ntPolicy; | |
| 18 | import org .springfra mework.sec urity.core .context.S ecurityCon text; | |
| 19 | import org .springfra mework.sec urity.core .context.S ecurityCon textHolder ; | |
| 20 | ||
| 21 | import com .agilex.he althcare.m obilehealt hplatform. domain.Mhp User; | |
| 22 | import com .agilex.he althcare.m obilehealt hplatform. security.A ppUser; | |
| 23 | import com .agilex.he althcare.s chedulingm anager.mdw s.MdwsResp onseExcept ion; | |
| 24 | import com .agilex.he althcare.s chedulingm anager.mdw s.generate dwsdl.emrs ervice.Dat aSourceArr ay; | |
| 25 | import com .agilex.he althcare.s chedulingm anager.mdw s.generate dwsdl.emrs ervice.Emr Svc; | |
| 26 | import com .agilex.he althcare.s chedulingm anager.mdw s.generate dwsdl.emrs ervice.Emr SvcSoap; | |
| 27 | ||
| 28 | public cla ss EmrConn ection imp lements Se rializable { | |
| 29 | pr ivate stat ic final o rg.apache. commons.lo gging.Log logger = o rg.apache. commons.lo gging.LogF actory.get Log(EmrCon nection.cl ass); | |
| 30 | pr ivate stat ic final l ong serial VersionUID = -767539 7237993685 048L; | |
| 31 | ||
| 32 | pr ivate Stri ng id; | |
| 33 | pr ivate Mdws Configurat ion config uration; | |
| 34 | pr ivate EmrS vcSoap por t; | |
| 35 | pr ivate Date refreshed Timestamp; | |
| 36 | ||
| 37 | pu blic EmrCo nnection() { | |
| 38 | this .id = UUID .randomUUI D().toStri ng(); | |
| 39 | } | |
| 40 | ||
| 41 | pu blic EmrCo nnection(E mrSvcSoap port) { | |
| 42 | this .id = UUID .randomUUI D().toStri ng(); | |
| 43 | this .port = po rt; | |
| 44 | } | |
| 45 | ||
| 46 | // this cons tructor wi ll be remo ved once c onnection pool is ad justed | |
| 47 | @D eprecated | |
| 48 | pu blic EmrCo nnection(M dwsConfigu ration con figuration ) { | |
| 49 | this .id = UUID .randomUUI D().toStri ng(); | |
| 50 | this .configura tion = con figuration ; | |
| 51 | //th is.authent icated = c onfigurati on.isAuthe nticated() ; | |
| 52 | //th is.port = establishC onnection( configurat ion, authe nticated); | |
| 53 | this .refreshed Timestamp = new Date (); | |
| 54 | } | |
| 55 | ||
| 56 | /* * | |
| 57 | * Calls the MDWS serv ice EmrSvc .connect i f the auth enticatedF lag is fal se - it wi ll usually be true | |
| 58 | * since mos t apps wil l login to a site wi th Authori zationServ ices and t hat connec tion is us ed from th at point o n. | |
| 59 | * / | |
| 60 | pu blic EmrCo nnection(M dwsConfigu ration con figuration , String s iteCode, b oolean aut henticateF lag) { | |
| 61 | this .id = UUID .randomUUI D().toStri ng(); | |
| 62 | this .configura tion = con figuration ; | |
| 63 | this .port = es tablishCon nection(co nfiguratio n, siteCod e, authent icateFlag) ; | |
| 64 | this .refreshed Timestamp = new Date (); | |
| 65 | } | |
| 66 | ||
| 67 | pu blic Date getRefresh edTimestam p() { | |
| 68 | retu rn refresh edTimestam p; | |
| 69 | } | |
| 70 | ||
| 71 | pu blic void refreshTim estamp() { | |
| 72 | this .refreshed Timestamp = new Date (); | |
| 73 | } | |
| 74 | ||
| 75 | pu blic Strin g getId() { | |
| 76 | retu rn id; | |
| 77 | } | |
| 78 | ||
| 79 | pu blic EmrSv cSoap getP ort() { | |
| 80 | retu rn port; | |
| 81 | } | |
| 82 | ||
| 83 | ||
| 84 | pu blic MdwsC onfigurati on getConf iguration( ) { | |
| 85 | retu rn this.co nfiguratio n; | |
| 86 | } | |
| 87 | ||
| 88 | /* * | |
| 89 | * Pings a H TTP URL an d returns true if it didn't ti me out. | |
| 90 | * / | |
| 91 | pr ivate stat ic boolean ping(Stri ng url, in t timeout) { | |
| 92 | url = url.repl aceFirst(" https", "h ttp"); // Otherwise an excepti on may be thrown on invalid SS L certific ates. | |
| 93 | ||
| 94 | Http URLConnect ion connec tion = nul l; | |
| 95 | try { | |
| 96 | connec tion = (Ht tpURLConne ction) new URL(url). openConnec tion(); | |
| 97 | connec tion.setCo nnectTimeo ut(timeout ); | |
| 98 | connec tion.setRe adTimeout( timeout); | |
| 99 | connec tion.setRe questMetho d("HEAD"); | |
| 100 | connec tion.getRe sponseCode (); //NOTE : We are g etting a 4 05 respons eCode from mdws - bu t that jus t proves t hat the se rver is up (which is what we c are about) | |
| 101 | return true; | |
| 102 | } ca tch (IOExc eption exc eption) { | |
| 103 | return false; | |
| 104 | } fi nally { | |
| 105 | if (co nnection ! = null) { | |
| 106 | try { co nnection.d isconnect( ); } catch (Exceptio n e) { log ger.info(" Problem di sconnectin g from pin g"); } | |
| 107 | } | |
| 108 | } | |
| 109 | } | |
| 110 | ||
| 111 | pu blic stati c EmrSvcSo ap establi shConnecti on(MdwsCon figuration configura tion, Stri ng siteCod e, boolean authentic ated) { | |
| 112 | Stri ng baseUrl = ""; | |
| 113 | MhpU ser mhpUse r = null; | |
| 114 | ||
| 115 | if ( authentica ted) { | |
| 116 | mhpUse r = getMhp User(); | |
| 117 | baseUr l = mhpUse r.getMdwsI nfo().getB aseUrl(); | |
| 118 | } el se { | |
| 119 | baseUr l = config uration.ge tEndPointB aseUrl(); | |
| 120 | } | |
| 121 | ||
| 122 | Stri ng url = U riUtils.ad dPath(base Url, confi guration.g etEndPoint Url()).toS tring(); | |
| 123 | ||
| 124 | if ( configurat ion.isPing WsdlBefore Connect() && ping(ur l, configu ration.get WsConnectT imeout()) == false) | |
| 125 | throw new MdwsRe sponseExce ption(Mdws ResponseEx ception.Us erMessages .CONNECTIO N_ERROR, " Unable to reach the server at " + url); | |
| 126 | ||
| 127 | URL wsdlLocati on = const ructWsdlUr l(url); | |
| 128 | EmrS vc emrServ ice = null ; | |
| 129 | try { | |
| 130 | emrService = new Emr Svc(wsdlLo cation, ne w QName("h ttp:// DNS /EmrSvc", "EmrSvc")) ; | |
| 131 | } ca tch (Throw able t) { | |
| 132 | throw new MdwsRe sponseExce ption(Mdws ResponseEx ception.Us erMessages .CONNECTIO N_ERROR, t .getMessag e()); | |
| 133 | } | |
| 134 | EmrS vcSoap por t = emrSer vice.getEm rSvcSoap() ; | |
| 135 | ||
| 136 | ((Bi ndingProvi der)port). getRequest Context(). put(Bindin gProvider. SESSION_MA INTAIN_PRO PERTY, tru e); | |
| 137 | ((Bi ndingProvi der)port). getRequest Context(). put(Bindin gProvider. ENDPOINT_A DDRESS_PRO PERTY, url ); | |
| 138 | ((Bi ndingProvi der)port). getRequest Context(). put("javax .xml.ws.cl ient.conne ctionTimeo ut", confi guration.g etWsConnec tTimeout() ); | |
| 139 | ((Bi ndingProvi der)port). getRequest Context(). put("javax .xml.ws.cl ient.recei veTimeout" , configur ation.getW sRequestTi meout()); | |
| 140 | ||
| 141 | if ( authentica ted){ | |
| 142 | setSes sionOnPort (port, mhp User.getMd wsInfo().g etSessionI d()); | |
| 143 | }els e{ | |
| 144 | DataS ourceArray dsa = nul l; | |
| 145 | ||
| 146 | try { | |
| 147 | dsa = port.conne ct(siteCod e); | |
| 148 | } ca tch (Throw able t) { | |
| 149 | throw ne w MdwsResp onseExcept ion(MdwsRe sponseExce ption.User Messages.C ONNECTION_ ERROR, t.g etMessage( )); | |
| 150 | } | |
| 151 | if ( dsa.getFau lt() != nu ll) | |
| 152 | throw ne w MdwsResp onseExcept ion(MdwsRe sponseExce ption.User Messages.C ONNECTION_ ERROR, dsa .getFault( )); | |
| 153 | } | |
| 154 | ||
| 155 | retu rn port; | |
| 156 | } | |
| 157 | ||
| 158 | pr ivate stat ic URL con structWsdl Url(String endPointU rl){ | |
| 159 | Stri ng wsdlLoc ation = en dPointUrl + "?WSDL"; | |
| 160 | URL wsdlLocati onURL = nu ll; | |
| 161 | try { | |
| 162 | wsdlLo cationURL = new URL( wsdlLocati on); | |
| 163 | } ca tch (Excep tion e) { | |
| 164 | throw new MdwsRe sponseExce ption(Mdws ResponseEx ception.Us erMessages .INVALID_W SDL, e.get Message()) ; | |
| 165 | } | |
| 166 | ||
| 167 | retu rn wsdlLoc ationURL; | |
| 168 | } | |
| 169 | ||
| 170 | ||
| 171 | @O verride | |
| 172 | pu blic int h ashCode() { | |
| 173 | fina l int prim e = 31; | |
| 174 | int result = 1 ; | |
| 175 | resu lt = prime * result + ((id == null) ? 0 : id.hashC ode()); | |
| 176 | retu rn result; | |
| 177 | } | |
| 178 | ||
| 179 | @O verride | |
| 180 | pu blic boole an equals( Object obj ) { | |
| 181 | if ( this == ob j) | |
| 182 | return true; | |
| 183 | if ( obj == nul l) | |
| 184 | return false; | |
| 185 | if ( getClass() != obj.ge tClass()) | |
| 186 | return false; | |
| 187 | EmrC onnection other = (E mrConnecti on) obj; | |
| 188 | if ( id == null ) { | |
| 189 | if (ot her.id != null) | |
| 190 | return f alse; | |
| 191 | } el se if (!id .equals(ot her.id)) | |
| 192 | return false; | |
| 193 | retu rn true; | |
| 194 | } | |
| 195 | ||
| 196 | pu blic stati c MhpUser getMhpUser (){ | |
| 197 | Se curityCont ext ctx = SecurityCo ntextHolde r.getConte xt(); | |
| 198 | if (ctx == n ull) | |
| 199 | thro w new Mdws ResponseEx ception(Md wsResponse Exception. UserMessag es.CONNECT ION_ERROR, "Unable t o get Spri ng Context "); | |
| 200 | if (ctx.getA uthenticat ion() == n ull) | |
| 201 | thro w new Mdws ResponseEx ception(Md wsResponse Exception. UserMessag es.CONNECT ION_ERROR, "Unable t o get Spri ng Authent ication"); | |
| 202 | if (ctx.getA uthenticat ion().getP rincipal() == null) | |
| 203 | thro w new Mdws ResponseEx ception(Md wsResponse Exception. UserMessag es.CONNECT ION_ERROR, "Unable t o get Spri ng Princip al"); | |
| 204 | if (((AppUse r)ctx.getA uthenticat ion().getP rincipal() ).getMhpUs er() == nu ll) | |
| 205 | thro w new Mdws ResponseEx ception(Md wsResponse Exception. UserMessag es.CONNECT ION_ERROR, "Unable t o get Spri ng MhpUser "); | |
| 206 | ||
| 207 | ||
| 208 | Ap pUser appU ser = (App User) ctx. getAuthent ication(). getPrincip al(); | |
| 209 | Mh pUser mhpU ser = appU ser.getMhp User(); | |
| 210 | mh pUser.setU serName(ap pUser.getU sername()) ; | |
| 211 | ||
| 212 | re turn mhpUs er; | |
| 213 | } | |
| 214 | ||
| 215 | pr ivate stat ic void se tSessionOn Port(EmrSv cSoap port , String s essionId) { | |
| 216 | Clie nt client = ClientPr oxy.getCli ent(port); | |
| 217 | ||
| 218 | HTTP ClientPoli cy policy = new HTTP ClientPoli cy(); | |
| 219 | HTTP Conduit ht tpConduit = (HTTPCon duit)clien t.getCondu it(); | |
| 220 | ||
| 221 | poli cy.setCook ie("ASP.NE T_SessionI d=" + sess ionId); | |
| 222 | poli cy.setAllo wChunking( false); | |
| 223 | ||
| 224 | http Conduit.se tClient(po licy); | |
| 225 | } | |
| 226 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.