Produced by Araxis Merge on 6/9/2017 3:46:15 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 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\eHXE_Build3_2017-05-04.zip\NHIN_adapter\VistALinkSetup\src\main\java\gov\va\das\datamanager\vistalinksetup | VistALinkSetup.java | Wed Apr 5 01:13:58 2017 UTC |
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\eHXE_Build3_2017-05-04.zip\NHIN_adapter\VistALinkSetup\src\main\java\gov\va\das\datamanager\vistalinksetup | VistALinkSetup.java | Wed Jun 7 06:10:30 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 664 |
| 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 | /* | |
| 2 | * To chan ge this te mplate, ch oose Tools | Templat es | |
| 3 | * and ope n the temp late in th e editor. | |
| 4 | */ | |
| 5 | package go v.va.das.d atamanager .vistalink setup; | |
| 6 | ||
| 7 | import gov .va.med.nh in.adapter .utils.*; | |
| 8 | ||
| 9 | import jav a.io.*; | |
| 10 | import jav a.util.*; | |
| 11 | ||
| 12 | import jav ax.xml.par sers.*; | |
| 13 | import jav ax.xml.xpa th.*; | |
| 14 | ||
| 15 | import org .w3c.dom.* ; | |
| 16 | ||
| 17 | /** | |
| 18 | * | |
| 19 | * @author
|
|
| 20 | */ | |
| 21 | public cla ss VistALi nkSetup | |
| 22 | { | |
| 23 | // priv ate static DasEsapiV alidator d asEsapiVal idator = ( DasEsapiVa lidator) E SAPI.valid ator(); | |
| 24 | ||
| 25 | static class Con nectorInfo | |
| 26 | { | |
| 27 | pu blic Strin g jndiName ; | |
| 28 | pu blic Strin g stationN umber; | |
| 29 | } | |
| 30 | ||
| 31 | /** | |
| 32 | * @pa ram args t he command line argu ments | |
| 33 | */ | |
| 34 | static public vo id main(St ring[] arg s) | |
| 35 | { | |
| 36 | Fi leReader f ileReader = null; | |
| 37 | tr y { | |
| 38 | Properti es propert ies = new Properties (); | |
| 39 | String c onfigDir = System.ge tProperty( "gov.va.da s.datamana ger.vistal inksetup.c onfigDir", "./config "); | |
| 40 | /* | |
| 41 | try { | |
| 42 | conf igDir = da sEsapiVali dator.getV alidInput( | |
| 43 | "Validat e configDi r: " + con figDir, co nfigDir, " DirectoryN ame", fals e, false); | |
| 44 | } | |
| 45 | catc h (Validat ionExcepti on e) { | |
| 46 | String validatio nErrStr = "Failed in put valida tion of th e configDi r. " + e.g etMessage( ); | |
| 47 | throw new DataMa nagerExcep tion(valid ationErrSt r, e); | |
| 48 | } | |
| 49 | */ | |
| 50 | String p ropertyFil eName = co nfigDir + "/VistALin kSetup.pro perties"; | |
| 51 | System.o ut.println ("Reading properties file: "+p ropertyFil eName); | |
| 52 | fileRead er = new F ileReader( propertyFi leName); | |
| 53 | properti es.load(fi leReader); | |
| 54 | ||
| 55 | String v istALinkCo nnectorCon figFileNam e = proper ties.getPr operty("vi stALinkCon nectorConf igFileName "); | |
| 56 | System.o ut.println ("vistALin kConnector ConfigFile Name: "+vi stALinkCon nectorConf igFileName ); | |
| 57 | ||
| 58 | String r aTemplateD ir = prope rties.getP roperty("r aTemplateD ir"); | |
| 59 | System.o ut.println ("raTempla teDir: "+r aTemplateD ir); | |
| 60 | ||
| 61 | String r aStageDir = properti es.getProp erty("raSt ageDir"); | |
| 62 | System.o ut.println ("raStageD ir: "+raSt ageDir); | |
| 63 | ||
| 64 | String c onnections TemplateFi leName = p roperties. getPropert y("connect ionsTempla teFileName "); | |
| 65 | System.o ut.println ("connecti onsTemplat eFileName: "+connect ionsTempla teFileName ); | |
| 66 | ||
| 67 | String c onnections StageFileN ame = prop erties.get Property(" connection sStageFile Name"); | |
| 68 | System.o ut.println ("connecti onsStageFi leName: "+ connection sStageFile Name); | |
| 69 | ||
| 70 | String c onnectionK eyPrefix = propertie s.getPrope rty("conne ctionKeyPr efix"); | |
| 71 | System.o ut.println ("connecti onKeyPrefi x: "+conne ctionKeyPr efix); | |
| 72 | ||
| 73 | String c onnectionU serName = properties .getProper ty("connec tionUserNa me"); | |
| 74 | System.o ut.println ("connecti onUserName : "+connec tionUserNa me); | |
| 75 | ||
| 76 | Properti es connect ionPropert ies = load Connection Properties (connectio nsTemplate FileName); | |
| 77 | Connecto rInfo[] co nnectorInf os = getCo nnectorInf os(vistALi nkConnecto rConfigFil eName); | |
| 78 | ||
| 79 | for (Con nectorInfo connector Info : con nectorInfo s) { | |
| 80 | Stri ng connect orName = m akeConnect orName(con nectorInfo .jndiName) ; | |
| 81 | copy TemplateTo Stage(raTe mplateDir, raStageDi r, connect orName); | |
| 82 | fixC onfigurati on(raStage Dir, conne ctorName, connectorI nfo.jndiNa me); | |
| 83 | addC onnection( connection Properties , connecto rInfo, con nectionUse rName, con nectionKey Prefix); | |
| 84 | } | |
| 85 | ||
| 86 | storeCon nectionPro perties(co nnectionsS tageFileNa me, connec tionProper ties); | |
| 87 | } | |
| 88 | ca tch (Throw able t) { | |
| 89 | System.o ut.println ("Unrecove rable Erro r!"); | |
| 90 | t.printS tackTrace( ); | |
| 91 | } | |
| 92 | fi nally { | |
| 93 | safe Close(file Reader); | |
| 94 | } | |
| 95 | } | |
| 96 | ||
| 97 | static private C onnectorIn fo[] getCo nnectorInf os(String connectorC onfigFileN ame) | |
| 98 | th rows Excep tion | |
| 99 | { | |
| 100 | Li st<Connect orInfo> re t = new Ar rayList<Co nnectorInf o>(); | |
| 101 | ||
| 102 | Do cumentBuil derFactory dbf = Doc umentBuild erFactory. newInstanc e(); | |
| 103 | ||
| 104 | // g ify additi ons to add ress XXE i ssues | |
| 105 | //St ring FEATU RE = "http ://apache. org/xml/fe atures/dis allow-doct ype-decl"; | |
| 106 | //db f.setFeatu re(FEATURE , true); | |
| 107 | ||
| 108 | //FE ATURE = "h ttp://xml. org/sax/fe atures/ext ernal-para meter-enti ties"; | |
| 109 | //db f.setFeatu re(FEATURE , false); | |
| 110 | ||
| 111 | //FE ATURE = "h ttp://xml. org/sax/fe atures/ext ernal-gene ral-entiti es"; | |
| 112 | //db f.setFeatu re(FEATURE , false); | |
| 113 | ||
| 114 | //db f.setXIncl udeAware(f alse); | |
| 115 | //db f.setExpan dEntityRef erences(fa lse); | |
| 116 | //db f.setNames paceAware( true); | |
| 117 | ||
| 118 | Do cumentBuil der db = d bf.newDocu mentBuilde r(); | |
| 119 | Do cument doc = db.pars e(connecto rConfigFil eName); | |
| 120 | if (doc==nul l) { | |
| 121 | System.o ut.println ("Warning, connector ConfigFile Name: "+co nnectorCon figFileNam e + " was not parsed ."); | |
| 122 | } | |
| 123 | ||
| 124 | XP athFactory xpathFact ory = XPat hFactory.n ewInstance (); | |
| 125 | XP ath xpath = xpathFac tory.newXP ath(); | |
| 126 | No deList nod eList = (N odeList) x path.evalu ate("conne ctors/conn ector", do c, XPathCo nstants.NO DESET); | |
| 127 | ||
| 128 | fo r (int i = 0; i < no deList.get Length(); ++i) { | |
| 129 | Node nod e = nodeLi st.item(i) ; | |
| 130 | Connecto rInfo ci = new Conne ctorInfo() ; | |
| 131 | ci.jndiN ame = node .getAttrib utes().get NamedItem( "jndiName" ).getTextC ontent(); | |
| 132 | ci.stati onNumber = node.getA ttributes( ).getNamed Item("prim aryStation ").getText Content(); | |
| 133 | ||
| 134 | ret.add( ci); | |
| 135 | } | |
| 136 | ||
| 137 | re turn ret.t oArray(new Connector Info[ret.s ize()]); | |
| 138 | } | |
| 139 | ||
| 140 | static private S tring make ConnectorN ame(String connector JNDIName) | |
| 141 | { | |
| 142 | re turn conne ctorJNDINa me.replace ("/", ""); | |
| 143 | } | |
| 144 | ||
| 145 | static private v oid copyTe mplateToSt age(String templateD ir, String stageDir, String co nnectorNam e) | |
| 146 | th rows Excep tion | |
| 147 | { | |
| 148 | /* try { | |
| 149 | temp lateDir = dasEsapiVa lidator.ge tValidInpu t( | |
| 150 | "Validat e template Dir: " + t emplateDir , template Dir, "Dire ctoryName" , false, f alse); | |
| 151 | } | |
| 152 | ca tch (Valid ationExcep tion e) { | |
| 153 | String validatio nErrStr = "Failed in put valida tion of th e template Dir. " + e .getMessag e(); | |
| 154 | throw new DataMa nagerExcep tion(valid ationErrSt r, e); | |
| 155 | } | |
| 156 | */ | |
| 157 | Fi le source = new File (templateD ir); | |
| 158 | /* | |
| 159 | tr y { | |
| 160 | stag eDir = das EsapiValid ator.getVa lidInput( | |
| 161 | "Validat e stageDir : " + stag eDir, stag eDir, "Dir ectoryName ", false, false); | |
| 162 | } | |
| 163 | ca tch (Valid ationExcep tion e) { | |
| 164 | String validatio nErrStr = "Failed in put valida tion of th e stageDir . " + e.ge tMessage() ; | |
| 165 | throw new DataMa nagerExcep tion(valid ationErrSt r, e); | |
| 166 | } | |
| 167 | ||
| 168 | tr y { | |
| 169 | conn ectorName = dasEsapi Validator. getValidIn put( | |
| 170 | "Validat e connecto rName: " + connector Name, conn ectorName, "Director yName", fa lse, false ); | |
| 171 | } | |
| 172 | ca tch (Valid ationExcep tion e) { | |
| 173 | String validatio nErrStr = "Failed in put valida tion of th e connecto rName. " + e.getMess age(); | |
| 174 | throw new DataMa nagerExcep tion(valid ationErrSt r, e); | |
| 175 | } | |
| 176 | */ | |
| 177 | Fi le dest = new File(s tageDir + File.separ ator + con nectorName ); | |
| 178 | Fi le stage = new File( stageDir); | |
| 179 | ||
| 180 | if (!stage.e xists()) { | |
| 181 | System.o ut.println ("Making: "+stage.ge tAbsoluteP ath()); | |
| 182 | stage.mk dir(); | |
| 183 | } | |
| 184 | ||
| 185 | co pyDirector y(source, dest); | |
| 186 | } | |
| 187 | ||
| 188 | static private v oid copyDi rectory(Fi le sourceL ocation, F ile target Location) | |
| 189 | th rows IOExc eption | |
| 190 | { | |
| 191 | Sy stem.out.p rintln("Co pying from : "+source Location.g etAbsolute Path() + " to: "+tar getLocatio n); | |
| 192 | if (sourceLo cation.isD irectory() ) { | |
| 193 | if (!tar getLocatio n.exists() ) { | |
| 194 | Syst em.out.pri ntln("Maki ng: "+targ etLocation .getAbsolu tePath()); | |
| 195 | targ etLocation .mkdirs(); | |
| 196 | } | |
| 197 | ||
| 198 | String[] children = sourceLo cation.lis t(); | |
| 199 | for (int i = 0; i < children .length; i ++) { | |
| 200 | copy Directory( new File(s ourceLocat ion, child ren[i]), | |
| 201 | new File(t argetLocat ion, child ren[i])); | |
| 202 | } | |
| 203 | } | |
| 204 | el se { | |
| 205 | InputStr eam in = n ull; | |
| 206 | OutputSt ream out = null; | |
| 207 | ||
| 208 | try { | |
| 209 | in = new FileI nputStream (sourceLoc ation); | |
| 210 | out = new File OutputStre am(targetL ocation); | |
| 211 | ||
| 212 | // C opy the bi ts from in stream to outstream | |
| 213 | byte [] buf = n ew byte[10 24]; | |
| 214 | int len; | |
| 215 | whil e ((len = in.read(bu f)) > 0) { | |
| 216 | out.write( buf, 0, le n); | |
| 217 | } | |
| 218 | } | |
| 219 | finally { | |
| 220 | safe Close(in); | |
| 221 | safe Close(out) ; | |
| 222 | } | |
| 223 | } | |
| 224 | } | |
| 225 | ||
| 226 | static private v oid fixCon figuration (String st ageDir, St ring conne ctorName, String jnd iName) | |
| 227 | th rows Excep tion | |
| 228 | { | |
| 229 | /* try { | |
| 230 | stag eDir = das EsapiValid ator.getVa lidInput( | |
| 231 | "Validat e stageDir : " + stag eDir, stag eDir, "Dir ectoryName ", false, false); | |
| 232 | } | |
| 233 | ca tch (Valid ationExcep tion e) { | |
| 234 | String validatio nErrStr = "Failed in put valida tion of th e stageDir . " + e.ge tMessage() ; | |
| 235 | throw new DataMa nagerExcep tion(valid ationErrSt r, e); | |
| 236 | } | |
| 237 | ||
| 238 | try { | |
| 239 | connector Name = das EsapiValid ator.getVa lidInput( | |
| 240 | "Validat e connecto rName: " + connector Name, conn ectorName, "Director yName", fa lse, false ); | |
| 241 | } | |
| 242 | ca tch (Valid ationExcep tion e) { | |
| 243 | String validatio nErrStr = "Failed in put valida tion of th e connecto rName. " + e.getMess age(); | |
| 244 | throw new DataMa nagerExcep tion(valid ationErrSt r, e); | |
| 245 | } | |
| 246 | */ | |
| 247 | Fi le configD ir = new F ile(stageD ir + File. separator + connecto rName + Fi le.separat or + "META -INF"); | |
| 248 | Fi le configF ile = new File(confi gDir, "web logic-ra.x ml"); | |
| 249 | Fi le tempFil e = File.c reateTempF ile("out", ".xml", c onfigDir); | |
| 250 | ||
| 251 | Bu fferedRead er in = nu ll; | |
| 252 | Bu fferedWrit er out = n ull; | |
| 253 | ||
| 254 | tr y { | |
| 255 | in = new BufferedR eader(new FileReader (configFil e)); | |
| 256 | out = ne w Buffered Writer(new FileWrite r(tempFile )); | |
| 257 | ||
| 258 | while (i n.ready()) { | |
| 259 | Stri ng line = in.readLin e(); | |
| 260 | Stri ng replace ment = lin e.replaceA ll("\\$\\{ vlj\\.jndi \\.name\\} ", jndiNam e); | |
| 261 | out. write(repl acement); | |
| 262 | out. write("\n" ); | |
| 263 | } | |
| 264 | } | |
| 265 | fi nally { | |
| 266 | safe Close(in); | |
| 267 | safe Close(out) ; | |
| 268 | } | |
| 269 | ||
| 270 | co nfigFile.d elete(); | |
| 271 | te mpFile.ren ameTo(conf igFile); | |
| 272 | } | |
| 273 | ||
| 274 | static private P roperties loadConnec tionProper ties(Strin g filename ) | |
| 275 | { | |
| 276 | /* try { | |
| 277 | file name = das EsapiValid ator.getVa lidInput( | |
| 278 | "Validat e filename : " + file name, file name, "Dir ectoryName ", false, false); | |
| 279 | } | |
| 280 | ca tch (Valid ationExcep tion e) { | |
| 281 | String validatio nErrStr = "Failed in put valida tion of th e filename . " + e.ge tMessage() ; | |
| 282 | throw new DataMa nagerExcep tion(valid ationErrSt r, e); | |
| 283 | } | |
| 284 | */ | |
| 285 | Sy stem.out.p rintln("Lo oking for properties file: "+f ilename); | |
| 286 | Fi le file = new File(f ilename); | |
| 287 | ||
| 288 | if (!file.ex ists()) { | |
| 289 | System.o ut.println (filename+ " does not exist. W ill create file"); | |
| 290 | filename = (file.g etParent() != null ? file.getP arent() : "") + File .separator + System. getenv("HO STNAME") + "-" + fil e.getName( ); | |
| 291 | System.o ut.println ("Will try to use: " +filename) ; | |
| 292 | } | |
| 293 | ||
| 294 | Pr operties r et; | |
| 295 | tr y { | |
| 296 | ret = Pr opertiesCo llectionFa ctory.getP ropertiesC ollection( filename); | |
| 297 | } | |
| 298 | ca tch (Excep tion e) { | |
| 299 | System.o ut.println ("Did not find "+fil ename+". Returning empty prop erties."); | |
| 300 | ret = ne w Properti es(); | |
| 301 | } | |
| 302 | ||
| 303 | re turn ret; | |
| 304 | } | |
| 305 | ||
| 306 | static private v oid storeC onnectionP roperties( String fil ename, Pro perties co nnectionPr operties) | |
| 307 | th rows Excep tion | |
| 308 | { | |
| 309 | Fi le f = new File(file name); | |
| 310 | f. createNewF ile(); | |
| 311 | Pr opertiesCo llectionFa ctory.stor ePropertie s(filename , connecti onProperti es); | |
| 312 | } | |
| 313 | ||
| 314 | static private v oid addCon nection(Pr operties c onnectionP roperties, Connector Info conne ctorInfo, String con nectionUse rname, Str ing connec tionKeyPre fix) | |
| 315 | { | |
| 316 | Pr operties p roperties = new Prop erties(); | |
| 317 | pr operties.s etProperty ("JNDIName ", connect orInfo.jnd iName); | |
| 318 | pr operties.s etProperty ("username ", connect ionUsernam e); | |
| 319 | pr operties.s etProperty ("division ", connect orInfo.sta tionNumber ); | |
| 320 | co nnectionPr operties.p ut(connect ionKeyPref ix + conne ctorInfo.s tationNumb er, proper ties); | |
| 321 | } | |
| 322 | ||
| 323 | static void safe Close(Clos eable stre am) { | |
| 324 | try { | |
| 325 | if ( stream != null) { | |
| 326 | stream.c lose(); | |
| 327 | } | |
| 328 | } | |
| 329 | catch (I OException e) { | |
| 330 | Syst em.out.pri ntln("Vist ALinkSetup : Exceptio n closing stream"); | |
| 331 | } | |
| 332 | } | |
| 333 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.