Produced by Araxis Merge on 7/10/2017 1:01:48 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 | C:\AraxisMergeCompare\Pri_un\IV-ehmp_cif\VixInstallerSolution2013.root\VixInstallerSolution2013\VixInstallerBusiness | VixFacade.cs | Thu Jun 29 17:22:28 2017 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\IV-ehmp_cif\VixInstallerSolution2013.root\VixInstallerSolution2013\VixInstallerBusiness | VixFacade.cs | Thu Jul 6 15:07:22 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 8 | 4216 |
| Changed | 7 | 16 |
| 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 | using Syst em; | |
| 2 | using Syst em.Collect ions.Gener ic; | |
| 3 | using Syst em.Text; | |
| 4 | using Syst em.IO; | |
| 5 | using log4 net; | |
| 6 | using Syst em.Diagnos tics; | |
| 7 | using Syst em.Threadi ng; | |
| 8 | using Micr osoft.Win3 2; | |
| 9 | using Micr osoft.Visu alBasic.Fi leIO; | |
| 10 | using Syst em.Xml; | |
| 11 | ||
| 12 | namespace gov.va.med .imaging.e xchange.Vi xInstaller .business | |
| 13 | { | |
| 14 | public static cl ass VixFac ade | |
| 15 | { | |
| 16 | pr ivate stat ic readonl y String V IX_CONFIG_ FILENAME = "ViXConfi g.xml"; | |
| 17 | pr ivate stat ic readonl y String S ITE_SERVIC E_SITE_RES OLUTION_FI LENAME = " SiteServic eSiteResol ution-1.0. config"; | |
| 18 | pr ivate stat ic readonl y String E XCHANGE_DA TA_SOURCE_ FILENAME = "Exchange DataSource -1.0.confi g"; | |
| 19 | pr ivate stat ic readonl y String E XCHANGE_CA CHE_CONFIG _REL_FILES PEC = @"ca che-config \ImagingEx changeCach e-cache.xm l"; | |
| 20 | pr ivate stat ic readonl y String E XCHANGE_CA CHE_DOD_IM AGE_REGION = @"dod-i mage-regio n"; | |
| 21 | pr ivate stat ic readonl y String F EDERATION_ KEYSTORE_F ILENAME = "federatio n.keystore "; | |
| 22 | pr ivate stat ic readonl y String F EDERATION_ TRUSTSTORE _FILENAME = "federat ion.trusts tore"; | |
| 23 | pu blic stati c readonly String VI X_CACHE_DI RECTORY = @"VixCache "; | |
| 24 | pu blic stati c readonly String VI X_CONFIG_D IRECTORY = @"VixConf ig"; | |
| 25 | pu blic stati c readonly String VI X_CERTSTOR E_DIRECTOR Y = @"VixC ertStore"; | |
| 26 | pu blic stati c readonly int MINIM UM_VIX_CAC HE_SIZE_GB = 20; | |
| 27 | pr ivate stat ic readonl y long ONE _GIGBYTE = (1024 * 1 024 * 1024 ); | |
| 28 | pu blic stati c readonly String HD IG_DICOM_D IRECTORY = @"DICOM"; | |
| 29 | // private st atic reado nly String XCA_KEYST ORE_FILENA ME = "xca. keystore"; | |
| 30 | // private st atic reado nly String XCA_TRUST STORE_FILE NAME = "xc a.truststo re"; | |
| 31 | pr ivate stat ic readonl y String X CA_CERTIFI CATE_FILEN AME = "CVI X_XCA_Cert ificate.pe m"; | |
| 32 | pr ivate stat ic readonl y String X CA_PRIVATE _KEY_FILEN AME = "CVI X_XCA_Priv ateKey.pem "; | |
| 33 | pr ivate stat ic readonl y String M ODALITY_BL ACKLIST_FI LENAME = " ExchangeMo dalityBlac kList.txt" ; | |
| 34 | pr ivate stat ic readonl y String J AVALOG_KEY STORE_FILE NAME = "Lo calAdmin.j ks"; | |
| 35 | pr ivate stat ic readonl y String R OI_DISCLOS URE_DIRECT ORY = @"RO I\disclosu re"; | |
| 36 | ||
| 37 | #r egion prop erties | |
| 38 | pr ivate stat ic InfoDel egate info Delegate = null; // used to di splay a li ne of text to any Wi zardPage t hat has re gistered | |
| 39 | pu blic stati c InfoDele gate InfoD elegate | |
| 40 | { | |
| 41 | get { re turn VixFa cade.infoD elegate; } | |
| 42 | set { Vi xFacade.in foDelegate = value; } | |
| 43 | } | |
| 44 | ||
| 45 | pr ivate stat ic AppEven tsDelegate appEvents Delegate = null; // used to ke ep the UI responsive | |
| 46 | pu blic stati c AppEvent sDelegate AppEventsD elegate | |
| 47 | { | |
| 48 | get { re turn VixFa cade.appEv entsDelega te; } | |
| 49 | set { Vi xFacade.ap pEventsDel egate = va lue; } | |
| 50 | } | |
| 51 | ||
| 52 | pr ivate stat ic VixMani fest manif est = null ; // the i nstallatio n manifest | |
| 53 | pu blic stati c VixManif est Manife st | |
| 54 | { | |
| 55 | get { re turn VixFa cade.manif est; } | |
| 56 | set { Vi xFacade.ma nifest = v alue; } | |
| 57 | } | |
| 58 | ||
| 59 | pu blic stati c string V ixConfigFi lespec | |
| 60 | { | |
| 61 | get { re turn Path. Combine(Ge tVixConfig urationDir ectory(), VIX_CONFIG _FILENAME) ; } | |
| 62 | } | |
| 63 | ||
| 64 | pu blic stati c string S iteService SiteResolu tionConfig Filespec | |
| 65 | { | |
| 66 | get { re turn Path. Combine(Ge tVixConfig urationDir ectory(), SITE_SERVI CE_SITE_RE SOLUTION_F ILENAME); } | |
| 67 | } | |
| 68 | ||
| 69 | pu blic stati c string E xchangeDat aSourceCon figFilespe c | |
| 70 | { | |
| 71 | get { re turn Path. Combine(Ge tVixConfig urationDir ectory(), EXCHANGE_D ATA_SOURCE _FILENAME) ; } | |
| 72 | } | |
| 73 | ||
| 74 | pu blic stati c string E xchangeCac heConfigFi lespec | |
| 75 | { | |
| 76 | get { re turn Path. Combine(Ge tVixConfig urationDir ectory(), EXCHANGE_C ACHE_CONFI G_REL_FILE SPEC); } | |
| 77 | } | |
| 78 | ||
| 79 | #e ndregion | |
| 80 | ||
| 81 | #r egion publ ic methods | |
| 82 | // / <summary > | |
| 83 | // / Checks t o see if a VIX is in stalled wi th all the required prerequisi tes. | |
| 84 | // / </summar y> | |
| 85 | // / <returns >true if t he VIX is installed, false oth erwise</re turns> | |
| 86 | pu blic stati c bool IsV ixInstalle d() | |
| 87 | { | |
| 88 | bool isI nstalled = false; | |
| 89 | ||
| 90 | //if (To mcatFacade .IsTomcatI nstalled() == true & & JavaFaca de.IsJavaI nstalled(i sDeveloper Mode) == t rue) | |
| 91 | if (Tomc atFacade.I sTomcatIns talled() = = true) | |
| 92 | { | |
| 93 | Stri ng vixPath = Path.Co mbine(Tomc atFacade.T omcatWebAp plicationF older, @"V ixServerHe althWebApp "); | |
| 94 | if ( Directory. Exists(vix Path) && I sVixConfig ured()) | |
| 95 | { | |
| 96 | isInstalle d = true; | |
| 97 | } | |
| 98 | } | |
| 99 | return i sInstalled ; | |
| 100 | } | |
| 101 | ||
| 102 | // / <summary > | |
| 103 | // / | |
| 104 | // / </summar y> | |
| 105 | // / <returns ></returns > | |
| 106 | pu blic stati c bool IsV ixConfigur ed() | |
| 107 | { | |
| 108 | bool isC onfigured = false; | |
| 109 | ||
| 110 | String v ixConfigDi r = Enviro nment.GetE nvironment Variable(" vixconfig" , Environm entVariabl eTarget.Ma chine); | |
| 111 | if (vixC onfigDir ! = null) | |
| 112 | { | |
| 113 | Stri ng vixConf igFilepath = Path.Co mbine(vixC onfigDir, VIX_CONFIG _FILENAME) ; | |
| 114 | if ( File.Exist s(vixConfi gFilepath) ) | |
| 115 | { | |
| 116 | isConfigur ed = true; | |
| 117 | } | |
| 118 | } | |
| 119 | ||
| 120 | return i sConfigure d; | |
| 121 | } | |
| 122 | ||
| 123 | // / <summary > | |
| 124 | // / | |
| 125 | // / </summar y> | |
| 126 | // / <returns ></returns > | |
| 127 | pu blic stati c bool IsF ederationC ertificate InstalledO rNotRequir ed(IVixCon figuration Parameters config) | |
| 128 | { | |
| 129 | bool isV ixCertific ateInstall edOrNotReq uired = fa lse; | |
| 130 | string c ertStoreDi r = VixFac ade.GetVix Certificat eStoreDir( ); | |
| 131 | string v ixKeystore Filepath = Path.Comb ine(certSt oreDir, FE DERATION_K EYSTORE_FI LENAME); | |
| 132 | string v ixTruststo reFilepath = Path.Co mbine(cert StoreDir, FEDERATION _TRUSTSTOR E_FILENAME ); | |
| 133 | ||
| 134 | //if (Vi xFacade.Ma nifest.Maj orPatchNum ber == 34) | |
| 135 | if (conf ig.VixRole == VixRol eType.Dico mGateway) | |
| 136 | { | |
| 137 | isVi xCertifica teInstalle dOrNotRequ ired = tru e; | |
| 138 | Logg er().Info( "VIX Certi ficate not required. "); | |
| 139 | } | |
| 140 | else if (File.Exis ts(vixKeys toreFilepa th) && Fil e.Exists(v ixTruststo reFilepath )) | |
| 141 | { | |
| 142 | isVi xCertifica teInstalle dOrNotRequ ired = tru e; | |
| 143 | Logg er().Info( "VIX Certi ficate is installed. "); | |
| 144 | } | |
| 145 | return i sVixCertif icateInsta lledOrNotR equired; | |
| 146 | } | |
| 147 | ||
| 148 | // / <summary > | |
| 149 | // / | |
| 150 | // / </summar y> | |
| 151 | // / <returns ></returns > | |
| 152 | pu blic stati c bool IsX caCertific ateInstall ed() | |
| 153 | { | |
| 154 | bool isX caCertific ateInstall ed = false ; | |
| 155 | string c ertStoreDi r = VixFac ade.GetVix Certificat eStoreDir( ); | |
| 156 | //string xcaKeysto reFilepath = Path.Co mbine(cert StoreDir, XCA_KEYSTO RE_FILENAM E); | |
| 157 | //string xcaTrusts toreFilepa th = Path. Combine(ce rtStoreDir , XCA_TRUS TSTORE_FIL ENAME); | |
| 158 | string x caCertific ateFilepat h = Path.C ombine(cer tStoreDir, XCA_CERTI FICATE_FIL ENAME); | |
| 159 | string x caPrivateK eyFilepath = Path.Co mbine(cert StoreDir, XCA_PRIVAT E_KEY_FILE NAME); | |
| 160 | ||
| 161 | //if (Fi le.Exists( xcaKeystor eFilepath) && File.E xists(xcaT ruststoreF ilepath) & & File.Exi sts(xcaCer tificateFi lepath) && File.Exis ts(xcaPriv ateKeyFile path)) | |
| 162 | if (File .Exists(xc aCertifica teFilepath ) && File. Exists(xca PrivateKey Filepath)) | |
| 163 | { | |
| 164 | isXc aCertifica teInstalle d = true; | |
| 165 | } | |
| 166 | ||
| 167 | return i sXcaCertif icateInsta lled; | |
| 168 | } | |
| 169 | ||
| 170 | // / <summary > | |
| 171 | // / Install the VIX se rvice. Thi s is the m ethod that acutally installs a VIX. It's what the wizard exi sts to sup port. | |
| 172 | // / </summar y> | |
| 173 | // / <param n ame="isDev eloperMode "></param> | |
| 174 | pu blic stati c void Ins tallVix(IV ixConfigur ationParam eters conf ig) //, bo ol isDevel operMode) | |
| 175 | { | |
| 176 | // HDIG servers no w have a c ertificate - needed for viewin g encrypte d log entr ies | |
| 177 | if (conf ig.VixRole == VixRol eType.Dico mGateway) | |
| 178 | { | |
| 179 | stri ng certSto reDir = Vi xFacade.Ge tVixCertif icateStore Dir(); | |
| 180 | if ( !Directory .Exists(ce rtStoreDir )) | |
| 181 | { | |
| 182 | Directory. CreateDire ctory(cert StoreDir); // this m ust be don e before A CLs are ap plied | |
| 183 | } | |
| 184 | } | |
| 185 | ||
| 186 | // Apply DAC for t he ViX ser vice accou nt to the file syste m | |
| 187 | ApplyAcc essControl (config); | |
| 188 | ||
| 189 | // set t he ViX env ironment v ariables | |
| 190 | CreateEn vironmentV ariables(c onfig); | |
| 191 | ||
| 192 | // delet e any depr ecated fil es from a previous r elease | |
| 193 | DeleteDe precatedDi stribution Files(conf ig, true); | |
| 194 | ||
| 195 | // delet e any depr ecated dir ectories f rom a prev ious relea se | |
| 196 | DeleteDe precatedDi stribution Directorie s(config, true); | |
| 197 | ||
| 198 | // re-cr eate tomca t-users.xm l | |
| 199 | TomcatFa cade.Confi gureTomcat Users(conf ig); | |
| 200 | ||
| 201 | if (conf ig.VixRole == VixRol eType.Site Vix) | |
| 202 | { | |
| 203 | // U nregister any OCX de pendencies | |
| 204 | Unre gisterImag eGearDepen dencyFiles (config); | |
| 205 | ||
| 206 | // C opy distri bution fil es to targ et locatio ns | |
| 207 | Depl oyImageGea rDependenc yFiles(con fig, true) ; | |
| 208 | ||
| 209 | // R egister an y OCX depe ndencies | |
| 210 | Regi sterImageG earDepende ncyFiles(c onfig); | |
| 211 | } | |
| 212 | ||
| 213 | // Copy distributi on files t o target l ocations | |
| 214 | DeployDe pendencyFi les(config , true); | |
| 215 | ||
| 216 | // deplo y the web applicatio ns as dict ated by th e manifest and confi guration p arameters | |
| 217 | DeployVi xWebApplic ations(con fig); | |
| 218 | ||
| 219 | // Copy distributi on file th at update the deploy ed web app s | |
| 220 | DeployWe bAppDepend encyFiles( config, tr ue); | |
| 221 | ||
| 222 | // write ViX confi guration f iles | |
| 223 | // this must come after mani fest files are copie d | |
| 224 | WriteViX Configurat ionFiles(c onfig); // , isDevelo perMode); | |
| 225 | ||
| 226 | // add t he java pr operties n eeded to b y the ViX to the Pro crun envir onment | |
| 227 | ApplyVix JavaProper tiesFromMa nifest(con fig, true) ; // commi t result | |
| 228 | ||
| 229 | // fixup Tomcat to point to the JVM sp ecified in the manif est | |
| 230 | TomcatFa cade.Fixup TomcatServ iceJvm(); | |
| 231 | ||
| 232 | // preve nt Tomcat Monitor fr om running at log in | |
| 233 | TomcatFa cade.Disab leTomcatMo nitor(); | |
| 234 | ||
| 235 | // for C VIX instal ls, deploy the vhasi tes.xml fi le that dr ives the s ite servic e to the | |
| 236 | // VIX c onfig dire ctory. | |
| 237 | if (conf ig.VixRole == VixRol eType.Ente rpriseGate way && con fig.SitesF ile != nul l) | |
| 238 | { | |
| 239 | Depl oySitesFil e(config); | |
| 240 | } | |
| 241 | ||
| 242 | // turn off Tomcat logging t o Stdout | |
| 243 | TomcatFa cade.Disab leStdOutLo gging(); | |
| 244 | ||
| 245 | // fixup Tomcat JV M memory u sage to co rrect case where mor e than 1G was being allocated for 32 bit process | |
| 246 | TomcatFa cade.Confi gureTomcat JvmMemory( config); | |
| 247 | ||
| 248 | //set TC P Timeout | |
| 249 | TCPTimeo utInRegist ry(); | |
| 250 | ||
| 251 | //Run a Netsh comm and | |
| 252 | RunNetwo rkConfigur ationComma nd(); | |
| 253 | ||
| 254 | // save the VIX in staller co nfiguratio n paramete rs for lat er use | |
| 255 | // this must go he re because the Write Configurat ionFiles s tep change s the conf iguration. | |
| 256 | config.T oXml(); | |
| 257 | ||
| 258 | if (mani fest.Clear Cache || m anifest.Cl earCacheIf PreviousVe rsion(conf ig.Previou sProductVe rsionProp) ) | |
| 259 | { | |
| 260 | Dele teAllLocal CacheRegio ns(config) ; | |
| 261 | } | |
| 262 | ||
| 263 | // start the ViX i f not runn ing on a c luster | |
| 264 | switch ( config.Vix Deployment Option) | |
| 265 | { | |
| 266 | case VixDeploy mentType.F ocClusterN ode: | |
| 267 | return; | |
| 268 | } | |
| 269 | ||
| 270 | Info("St arting the " + Tomca tFacade.To mcatServic eName + " service.") ; | |
| 271 | ServiceU tilities.S tartLocalS ervice(Tom catFacade. TomcatServ iceName); | |
| 272 | System.S erviceProc ess.Servic eControlle rStatus st atus; | |
| 273 | // wait for the Vi X to start | |
| 274 | do | |
| 275 | { | |
| 276 | DoEv ents(); | |
| 277 | Thre ad.Sleep(5 00); | |
| 278 | stat us = Servi ceUtilitie s.GetLocal ServiceSta tus(Tomcat Facade.Tom catService Name); | |
| 279 | } | |
| 280 | while (s tatus == S ystem.Serv iceProcess .ServiceCo ntrollerSt atus.Start Pending); | |
| 281 | ||
| 282 | if (stat us == Syst em.Service Process.Se rviceContr ollerStatu s.Running) | |
| 283 | { | |
| 284 | Info ("The " + TomcatFaca de.TomcatS erviceName + " servi ce has bee n started. "); | |
| 285 | //no w start th e Viewer a nd Render services. | |
| 286 | bool viewerSta tus = ZFVi ewerFacade .StartZFVi ewerServic es(); | |
| 287 | if ( viewerStat us == fals e) | |
| 288 | { | |
| 289 | Info("The " + ZFView erFacade.V iewerServi ceAccountN ame + " co uld not be started." ); | |
| 290 | } | |
| 291 | } | |
| 292 | else | |
| 293 | { | |
| 294 | Info ("The " + TomcatFaca de.TomcatS erviceName + " could not be st arted. The current s tatus is " + status. ToString() ); | |
| 295 | } | |
| 296 | } | |
| 297 | ||
| 298 | // / <summary > | |
| 299 | // / Unregist ers Image Gear depen dency file s. | |
| 300 | // / </summar y> | |
| 301 | // / <remarks >At this t ime used t o unregist er Image G ear compon ents</rema rks> | |
| 302 | pu blic stati c void Unr egisterIma geGearDepe ndencyFile s(IVixConf igurationP arameters config) | |
| 303 | { | |
| 304 | VixDepen dencyFile[ ] igFiles = Manifest .GetImageG earDepende ncyFiles(c onfig); | |
| 305 | if (igFi les.Length > 0) | |
| 306 | { | |
| 307 | Info ("Unregist ering Imag eGear file s"); | |
| 308 | fore ach (VixDe pendencyFi le igFile in igFiles ) | |
| 309 | { | |
| 310 | if (igFile .Register) | |
| 311 | { | |
| 312 | string igFilespe c = igFile .GetAppFil espec(); | |
| 313 | if (Fi le.Exists( igFilespec )) | |
| 314 | { | |
| 315 | in t exitCode = Registe rOrUnregis terOcx(igF ilespec, f alse); | |
| 316 | In fo("Unregi ster file " + igFile spec + " : " + (exit Code == 0 ? "Success " : "Failu re")); | |
| 317 | } | |
| 318 | } | |
| 319 | } | |
| 320 | } | |
| 321 | else | |
| 322 | { | |
| 323 | Info ("ImageGea r not inst alled - no files to unregister "); | |
| 324 | } | |
| 325 | } | |
| 326 | ||
| 327 | // / <summary > | |
| 328 | // / Register s Image Ge ar depende ncy files. | |
| 329 | // / </summar y> | |
| 330 | // / <remarks >At this t ime used t o register Image Gea r componen ts</remark s> | |
| 331 | pu blic stati c void Reg isterImage GearDepend encyFiles( IVixConfig urationPar ameters co nfig) | |
| 332 | { | |
| 333 | VixDepen dencyFile[ ] igFiles = Manifest .GetImageG earDepende ncyFiles(c onfig); | |
| 334 | if (igFi les.Length > 0) | |
| 335 | { | |
| 336 | Info ("Register ing ImageG ear files" ); | |
| 337 | fore ach (VixDe pendencyFi le igFile in igFiles ) | |
| 338 | { | |
| 339 | if (igFile .Register) | |
| 340 | { | |
| 341 | string igFilespe c = igFile .GetAppFil espec(); | |
| 342 | if (!F ile.Exists (igFilespe c)) | |
| 343 | { | |
| 344 | th row new Ex ception("T rying to r egister fi le which d oes not ex ist: " + i gFilespec) ; | |
| 345 | } | |
| 346 | int ex itCode = R egisterOrU nregisterO cx(igFiles pec, true) ; | |
| 347 | Info(" Register f ile " + ig Filespec + " : " + ( exitCode = = 0 ? "Suc cess" : "F ailure")); | |
| 348 | } | |
| 349 | } | |
| 350 | } | |
| 351 | } | |
| 352 | ||
| 353 | // / <summary > | |
| 354 | // / Remove t he web app lication t races asso ciated wit h the web applicatio ns specifi ed in the manifest. Note that | |
| 355 | // / it is no t necessar y to delet e applicat ion contex ts from se rver.xml b ecause the contexts will be ge nerated | |
| 356 | // / from scr atch in th e server.x ml shell t hat is dis tributed w ith each V iX payload . | |
| 357 | // / </summar y> | |
| 358 | // / <param n ame="confi g"></param > | |
| 359 | pu blic stati c void Und eployVixWe bApplicati ons(IVixCo nfiguratio nParameter s config) | |
| 360 | { | |
| 361 | if (Tomc atFacade.I sTomcatIns talled() = = false) / / sanity c heck - cou ld happen in JDK man ual uninst all/reinst all scener io | |
| 362 | { | |
| 363 | retu rn; | |
| 364 | } | |
| 365 | ||
| 366 | VixWebAp plication[ ] vixWebAp plications = Manifes t.VixWebAp plications ; | |
| 367 | ||
| 368 | foreach (VixWebApp lication v ixWebAppli cation in vixWebAppl ications) | |
| 369 | { | |
| 370 | if ( vixWebAppl ication.Is Axis2WebAp plication( )) | |
| 371 | { | |
| 372 | continue; | |
| 373 | } | |
| 374 | Info ("Uninstal ling Web A pplication " + vixWe bApplicati on.Path); | |
| 375 | Unin stallWebAp plication( config, vi xWebApplic ation, tru e); | |
| 376 | } | |
| 377 | Info("Al l web appl ications h ave been u ninstalled ."); | |
| 378 | } | |
| 379 | // / <summary > | |
| 380 | // / | |
| 381 | // / </summar y> | |
| 382 | // / <param n ame="confi g"></param > | |
| 383 | pu blic stati c void Dep loyVixWebA pplication s(IVixConf igurationP arameters config) | |
| 384 | { | |
| 385 | VixWebAp plication[ ] vixWebAp plications = Manifes t.VixWebAp plications ; | |
| 386 | ||
| 387 | foreach (VixWebApp lication v ixWebAppli cation in vixWebAppl ications) | |
| 388 | { | |
| 389 | if ( vixWebAppl ication.Op tion == Vi xWebApplic ationOptio n.Remove) | |
| 390 | { | |
| 391 | continue; // dont de ploy web a pplication s marked a s remove | |
| 392 | } | |
| 393 | ||
| 394 | if ( vixWebAppl ication.Is Axis2WebAp plication( )) | |
| 395 | { | |
| 396 | Info("Inst alling Axi s2 Web App lication " + vixWebA pplication .War); | |
| 397 | string sou rceJarFile Spec = Pat h.Combine( TomcatFaca de.TomcatW ebApplicat ionFolder, vixWebApp lication.W ar); | |
| 398 | string tar getJarFile Spec = Pat h.Combine( TomcatFaca de.TomcatA xis2WebApp licationFo lder, vixW ebApplicat ion.War); | |
| 399 | File.Copy( sourceJarF ileSpec, t argetJarFi leSpec); | |
| 400 | File.Delet e(sourceJa rFileSpec) ; | |
| 401 | } | |
| 402 | else | |
| 403 | { | |
| 404 | Info("Inst alling Web Applicati on " + vix WebApplica tion.Path) ; | |
| 405 | string war FileSpec = Path.Comb ine(Tomcat Facade.Tom catWebAppl icationFol der, vixWe bApplicati on.War); | |
| 406 | Debug.Asse rt(File.Ex ists(warFi leSpec)); | |
| 407 | ||
| 408 | string pat hFolder = vixWebAppl ication.Pa th.StartsW ith("/") ? vixWebApp lication.P ath.Substr ing(1) : v ixWebAppli cation.Pat h; | |
| 409 | string web AppPathFol der = Path .Combine(T omcatFacad e.TomcatWe bApplicati onFolder, pathFolder ); | |
| 410 | if (Direct ory.Exists (webAppPat hFolder)) // safety net - shou ld not hap pen | |
| 411 | { | |
| 412 | Uninst allWebAppl ication(co nfig, vixW ebApplicat ion, false ); | |
| 413 | } | |
| 414 | Directory. CreateDire ctory(webA ppPathFold er); | |
| 415 | ZipUtiliti es.UnZip(w arFileSpec , webAppPa thFolder); // unzip the war to the speci fied path | |
| 416 | File.Delet e(warFileS pec); // d elete the war so tha t it does not auto d eploy | |
| 417 | } | |
| 418 | } | |
| 419 | ||
| 420 | AddWebAp pContextEl ements(Pat h.Combine( TomcatFaca de.TomcatC onfigurati onFolder, "server.xm l"), confi g); | |
| 421 | } | |
| 422 | ||
| 423 | // / <summary > | |
| 424 | // / | |
| 425 | // / </summar y> | |
| 426 | // / <param n ame="serve rXmlFilesp ec"></para m> | |
| 427 | pu blic stati c void Add WebAppCont extElement s(string s erverXmlFi lespec, IV ixConfigur ationParam eters conf ig) | |
| 428 | { | |
| 429 | Debug.As sert(File. Exists(ser verXmlFile spec)); | |
| 430 | XmlDocum ent xmlSer verDom = n ew XmlDocu ment(); | |
| 431 | xmlServe rDom.Load( serverXmlF ilespec); | |
| 432 | ||
| 433 | if (conf ig.VixRole == VixRol eType.Ente rpriseGate way) | |
| 434 | { | |
| 435 | XmlN ode xmlHtt pConnector = xmlServ erDom.Sele ctSingleNo de("Server /Service/C onnector[@ port='xxx' ]"); // Ge t port fro m config | |
| 436 | Debu g.Assert(x mlHttpConn ector != n ull); | |
| 437 | Upda teHttpConn ector(conf ig, xmlHtt pConnector ); | |
| 438 | ||
| 439 | XmlN ode xmlXca Connector = null; | |
| 440 | if ( config.Use OpenSslFor XCAConnect or) | |
| 441 | { | |
| 442 | // delete the connec tor that w ould be us ed with js ee | |
| 443 | xmlXcaConn ector = xm lServerDom .SelectSin gleNode("S erver/Serv ice/Connec tor[@port= 'yyy']"); // Get por t from con fig | |
| 444 | Debug.Asse rt(xmlXcaC onnector ! = null); | |
| 445 | xmlXcaConn ector.Pare ntNode.Rem oveChild(x mlXcaConne ctor); | |
| 446 | xmlXcaConn ector = xm lServerDom .SelectSin gleNode("S erver/Serv ice/Connec tor[@port= 'zzz']"); // Get por t from con fig | |
| 447 | Debug.Asse rt(xmlXcaC onnector ! = null); | |
| 448 | UpdateOpen SslXcaConn ector(conf ig, xmlXca Connector) ; | |
| 449 | } | |
| 450 | else | |
| 451 | { | |
| 452 | // delete the connec tor that w ould be us ed with Op enSSL | |
| 453 | xmlXcaConn ector = xm lServerDom .SelectSin gleNode("S erver/Serv ice/Connec tor[@port= 'zzz']"); // Get por t from con fig | |
| 454 | Debug.Asse rt(xmlXcaC onnector ! = null); | |
| 455 | xmlXcaConn ector.Pare ntNode.Rem oveChild(x mlXcaConne ctor); | |
| 456 | xmlXcaConn ector = xm lServerDom .SelectSin gleNode("S erver/Serv ice/Connec tor[@port= 'yyy']"); // Get por t from con fig | |
| 457 | Debug.Asse rt(xmlXcaC onnector ! = null); | |
| 458 | UpdateXcaC onnector(c onfig, xml XcaConnect or); | |
| 459 | } | |
| 460 | } | |
| 461 | else if (config.Vi xRole == V ixRoleType .SiteVix | | config.V ixRole == VixRoleTyp e.DicomGat eway || co nfig.VixRo le == VixR oleType.Mi niVix) // configure a SSL conn ector to b e used jav a logs | |
| 462 | { | |
| 463 | XmlN ode xmlHtt psConnecto r = xmlSer verDom.Sel ectSingleN ode("Serve r/Service/ Connector[ @port='443 ']"); | |
| 464 | if ( xmlHttpsCo nnector != null) | |
| 465 | { | |
| 466 | UpdateVixH digHttpsCo nnector(co nfig, xmlH ttpsConnec tor); | |
| 467 | } | |
| 468 | } | |
| 469 | ////else if (confi g.VixRole == VixRole Type.Dicom Gateway) | |
| 470 | ////{ | |
| 471 | //// XmlNode xm lHttpsConn ector = xm lServerDom .SelectSin gleNode("S erver/Serv ice/Connec tor[@port= '443']"); | |
| 472 | //// if (xmlHtt psConnecto r != null) | |
| 473 | //// { | |
| 474 | //// Update HdigHttpsC onnector(c onfig, xml HttpsConne ctor); | |
| 475 | //// } | |
| 476 | ////} | |
| 477 | ||
| 478 | XmlNode xmlConnect or = xmlSe rverDom.Se lectSingle Node("Serv er/Service /Connector [@port='84 43']"); | |
| 479 | if (xmlC onnector ! = null) // patch 34 doesnt hav e a federa tion inter face | |
| 480 | { | |
| 481 | Upda teFederati onConnecto r(config, xmlConnect or); | |
| 482 | } | |
| 483 | ||
| 484 | // updat e Engine e lement wit h default host name | |
| 485 | XmlNode xmlEngine = xmlServe rDom.Selec tSingleNod e("Server/ Service[@n ame='Catal ina']/Engi ne"); | |
| 486 | UpdateEn gine(confi g, xmlEngi ne); | |
| 487 | ||
| 488 | // updat e Host ele ment name attribute | |
| 489 | XmlNode xmlHost = xmlEngine. SelectSing leNode("./ Host"); | |
| 490 | UpdateHo st(config, xmlHost); | |
| 491 | ||
| 492 | // updat e Realm el ement site informati on | |
| 493 | XmlNode xmlRealm = xmlHost.S electSingl eNode("./R ealm"); | |
| 494 | UpdateRe alm(config , xmlRealm ); | |
| 495 | ||
| 496 | // write context e lements fo r each web applicati on | |
| 497 | VixWebAp plication[ ] vixWebAp plications = Manifes t.VixWebAp plications ; | |
| 498 | foreach (VixWebApp lication v ixWebAppli cation in vixWebAppl ications) | |
| 499 | { | |
| 500 | if ( vixWebAppl ication.Op tion == Vi xWebApplic ationOptio n.Remove) | |
| 501 | { | |
| 502 | continue; | |
| 503 | } | |
| 504 | ||
| 505 | if ( vixWebAppl ication.Us eContextFo lder == tr ue) | |
| 506 | { | |
| 507 | continue; // web app provides its own ME TA-INF\con text.xml - no contex t tag need ed in serv er.xml | |
| 508 | } | |
| 509 | ||
| 510 | XmlE lement xml Context = CreateCont ext(config , xmlServe rDom, vixW ebApplicat ion); | |
| 511 | xmlH ost.Insert After(xmlC ontext, xm lRealm); | |
| 512 | } | |
| 513 | ||
| 514 | // confi gure the D icomSCPSer vice servi ce child e lements if present | |
| 515 | xmlEngin e = xmlSer verDom.Sel ectSingleN ode("Serve r/Service[ @name='Dic omSCPServi ce']/Engin e"); | |
| 516 | if (xmlE ngine != n ull) | |
| 517 | { | |
| 518 | // u pdate Engi ne element with defa ult host n ame | |
| 519 | Upda teEngine(c onfig, xml Engine); | |
| 520 | // u pdate Real m element site infor mation | |
| 521 | xmlR ealm = xml Engine.Sel ectSingleN ode("./Rea lm"); | |
| 522 | Upda teRealm(co nfig, xmlR ealm); | |
| 523 | // u pdate Host element n ame attrib ute | |
| 524 | xmlH ost = xmlE ngine.Sele ctSingleNo de("./Host "); | |
| 525 | Upda teHost(con fig, xmlHo st); | |
| 526 | } | |
| 527 | ||
| 528 | // confi gure the P eriodicCom mandServic e service child elem ents if pr esent | |
| 529 | xmlEngin e = xmlSer verDom.Sel ectSingleN ode("Serve r/Service[ @name='Per iodicComma ndService' ]/Engine") ; | |
| 530 | if (xmlE ngine != n ull) | |
| 531 | { | |
| 532 | // u pdate Engi ne element with defa ult host n ame | |
| 533 | Upda teEngine(c onfig, xml Engine); | |
| 534 | // u pdate Real m element site infor mation | |
| 535 | xmlR ealm = xml Engine.Sel ectSingleN ode("./Rea lm"); | |
| 536 | Upda teRealm(co nfig, xmlR ealm); | |
| 537 | // u pdate Host element n ame attrib ute | |
| 538 | xmlH ost = xmlE ngine.Sele ctSingleNo de("./Host "); | |
| 539 | Upda teHost(con fig, xmlHo st); | |
| 540 | } | |
| 541 | ||
| 542 | // confi gure the P eriodicCom mandServic e service child elem ents if pr esent | |
| 543 | xmlEngin e = xmlSer verDom.Sel ectSingleN ode("Serve r/Service[ @name='Per iodicROICo mmandServi ce']/Engin e"); | |
| 544 | if (xmlE ngine != n ull) | |
| 545 | { | |
| 546 | // u pdate Engi ne element with defa ult host n ame | |
| 547 | Upda teEngine(c onfig, xml Engine); | |
| 548 | // u pdate Real m element site infor mation | |
| 549 | xmlR ealm = xml Engine.Sel ectSingleN ode("./Rea lm"); | |
| 550 | Upda teRealm(co nfig, xmlR ealm); | |
| 551 | // u pdate Host element n ame attrib ute | |
| 552 | xmlH ost = xmlE ngine.Sele ctSingleNo de("./Host "); | |
| 553 | Upda teHost(con fig, xmlHo st); | |
| 554 | } | |
| 555 | ||
| 556 | xmlServe rDom.Save( serverXmlF ilespec); | |
| 557 | } | |
| 558 | // ---------- ---------- ---------- ---------- ---------- ------ | |
| 559 | ||
| 560 | pr ivate stat ic void Up dateFedera tionConnec tor(IVixCo nfiguratio nParameter s config, XmlNode xm lConnector ) | |
| 561 | { | |
| 562 | String s = Path.Co mbine(VixF acade.GetV ixCertific ateStoreDi r(), FEDER ATION_KEYS TORE_FILEN AME); | |
| 563 | String f ederationK eystorePat h = s.Repl ace(@"\", "/"); | |
| 564 | s = Path .Combine(V ixFacade.G etVixCerti ficateStor eDir(), FE DERATION_T RUSTSTORE_ FILENAME); | |
| 565 | String f ederationT ruststoreP ath = s.Re place(@"\" , "/"); | |
| 566 | ||
| 567 | xmlConne ctor.Attri butes["key storeFile" ].Value = federation KeystorePa th; | |
| 568 | xmlConne ctor.Attri butes["key storePass" ].Value = config.Fed erationKey storePassw ord; | |
| 569 | xmlConne ctor.Attri butes["tru ststoreFil e"].Value = federati onTruststo rePath; | |
| 570 | xmlConne ctor.Attri butes["tru ststorePas s"].Value = config.F ederationT ruststoreP assword; | |
| 571 | } | |
| 572 | ||
| 573 | pr ivate stat ic void Up dateVixHdi gHttpsConn ector(IVix Configurat ionParamet ers config , XmlNode xmlConnect or) | |
| 574 | { | |
| 575 | String s = Path.Co mbine(VixF acade.GetV ixCertific ateStoreDi r(), JAVAL OG_KEYSTOR E_FILENAME ); | |
| 576 | String k eystorePat h = s.Repl ace(@"\", "/"); | |
| 577 | ||
| 578 | xmlConne ctor.Attri butes["key storeFile" ].Value = keystorePa th; | |
| 579 | xmlConne ctor.Attri butes["key storePass" ].Value = config.Fed erationTru ststorePas sword; // JavaLog ce rt and Fed eration tr uststore u se the sam e password | |
| 580 | } | |
| 581 | ||
| 582 | // //private static voi d UpdateVi xHttpsConn ector(IVix Configurat ionParamet ers config , XmlNode xmlConnect or) | |
| 583 | // //{ | |
| 584 | // // Stri ng s = Pat h.Combine( VixFacade. GetVixCert ificateSto reDir(), F EDERATION_ KEYSTORE_F ILENAME); | |
| 585 | // // Stri ng federat ionKeystor ePath = s. Replace(@" \", "/"); | |
| 586 | ||
| 587 | // // xmlC onnector.A ttributes[ "keystoreF ile"].Valu e = federa tionKeysto rePath; | |
| 588 | // // xmlC onnector.A ttributes[ "keystoreP ass"].Valu e = config .Federatio nKeystoreP assword; | |
| 589 | // //} | |
| 590 | ||
| 591 | pr ivate stat ic void Up dateXcaCon nector(IVi xConfigura tionParame ters confi g, XmlNode xmlConnec tor) | |
| 592 | { | |
| 593 | String s = Path.Co mbine(VixF acade.GetV ixCertific ateStoreDi r(), FEDER ATION_KEYS TORE_FILEN AME); //XC A_KEYSTORE _FILENAME) ; | |
| 594 | String x caKeystore Path = s.R eplace(@"\ ", "/"); | |
| 595 | s = Path .Combine(V ixFacade.G etVixCerti ficateStor eDir(), FE DERATION_T RUSTSTORE_ FILENAME); //XCA_TRU STSTORE_FI LENAME); | |
| 596 | String x caTruststo rePath = s .Replace(@ "\", "/"); | |
| 597 | ||
| 598 | xmlConne ctor.Attri butes["por t"].Value = config.X caConnecto rPort.ToSt ring(); | |
| 599 | xmlConne ctor.Attri butes["key storeFile" ].Value = xcaKeystor ePath; | |
| 600 | xmlConne ctor.Attri butes["key storePass" ].Value = config.Fed erationKey storePassw ord; // re using fede ration cre dentials? Dont think it matter s... | |
| 601 | xmlConne ctor.Attri butes["tru ststoreFil e"].Value = xcaTrust storePath; | |
| 602 | xmlConne ctor.Attri butes["tru ststorePas s"].Value = config.F ederationT ruststoreP assword; // reusing federatio n credenti als? Dont think it m atters... | |
| 603 | } | |
| 604 | ||
| 605 | pr ivate stat ic void Up dateOpenSs lXcaConnec tor(IVixCo nfiguratio nParameter s config, XmlNode xm lConnector ) | |
| 606 | { | |
| 607 | String s = Path.Co mbine(VixF acade.GetV ixCertific ateStoreDi r(), XCA_C ERTIFICATE _FILENAME) ; | |
| 608 | String x caKeystore Path = s.R eplace(@"\ ", "/"); | |
| 609 | s = Path .Combine(V ixFacade.G etVixCerti ficateStor eDir(), XC A_PRIVATE_ KEY_FILENA ME); | |
| 610 | String x caPrivateK eyPath = s .Replace(@ "\", "/"); | |
| 611 | ||
| 612 | xmlConne ctor.Attri butes["por t"].Value = config.X caConnecto rPort.ToSt ring(); | |
| 613 | xmlConne ctor.Attri butes["SSL Certificat eFile"].Va lue = xcaK eystorePat h; | |
| 614 | xmlConne ctor.Attri butes["SSL Certificat eKeyFile"] .Value = x caPrivateK eyPath; | |
| 615 | //xmlCon nector.Att ributes["S SLPassword "].Value = config.Fe derationKe ystorePass word; // r eusing fed eration cr edentials? Dont thin k it matte rs... | |
| 616 | } | |
| 617 | ||
| 618 | pr ivate stat ic void Up dateHttpCo nnector(IV ixConfigur ationParam eters conf ig, XmlNod e xmlConne ctor) | |
| 619 | { | |
| 620 | xmlConne ctor.Attri butes["por t"].Value = config.H ttpConnect orPort.ToS tring(); | |
| 621 | } | |
| 622 | ||
| 623 | pr ivate stat ic void Up dateEngine (IVixConfi gurationPa rameters c onfig, Xml Node xmlEn gine) | |
| 624 | { | |
| 625 | string hos tName = co nfig.SiteN umber + ". URL "; | |
| 626 | xmlEngin e.Attribut es["defaul tHost"].Va lue = host Name; | |
| 627 | } | |
| 628 | ||
| 629 | pr ivate stat ic void Up dateHost(I VixConfigu rationPara meters con fig, XmlNo de xmlHost ) | |
| 630 | { | |
| 631 | string hos tName = co nfig.SiteN umber + ". URL "; | |
| 632 | xmlHost. Attributes ["name"].V alue = hos tName; | |
| 633 | } | |
| 634 | ||
| 635 | // / <summary > | |
| 636 | // / Checks t o see if t he current server is a develop ment CVIX. Very frag ile!!! | |
| 637 | // / </summar y> | |
| 638 | // / <param n ame="confi g"></param > | |
| 639 | // / <returns ><c>true</ c> if the current se rver is a developmen t CVIX; <c >false</c> otherwise </returns> | |
| 640 | pr ivate stat ic bool Is Developmen tCvix(IVix Configurat ionParamet ers config ) | |
| 641 | { | |
| 642 | bool isD evCvix = f alse; | |
| 643 | if (conf ig.VixRole == VixRol eType.Ente rpriseGate way) | |
| 644 | { | |
| 645 | // f ragile - m ust be upd ated as th e test env ironment i s updated - last upd ate 9/25/2 012 | |
| 646 | if (config .VixServer NameProp.T oUpper() = = " IMMIXCVIX" || config .VixServer NameProp.T oUpper() = = " IMMIXVIX2" || config .VixServer NameProp.T oUpper() = = "PRIV-DE VCVIX" || | |
| 647 | config.Vix ServerName Prop.ToUpp er() == "P RIV-DICVIX " || confi g.VixServe rNameProp. ToUpper() == "PRIV-R TCVIX" || config.Vix ServerName Prop.ToUpp er() == " SQACVIX" | | | |
| 648 | /* Silver Spring Int eragency C VIX server s */ | |
| 649 | config.Vix ServerName Prop.ToUpp er() == " IMGX64VIX" || config .VixServer NameProp.T oUpper() = = " IMMIXVIX9" || | |
| 650 | /* Martins burg Inter agency CVI X servers */ | |
| 651 | config.Vix ServerName Prop.ToUpp er() == " DNS BNODCVIX5" || config .VixServer NameProp.T oUpper() = = " DNS BNODCVIX6" ) | |
| 652 | { | |
| 653 | isDevCvix = true; | |
| 654 | } | |
| 655 | } | |
| 656 | return i sDevCvix; | |
| 657 | } | |
| 658 | ||
| 659 | // / <summary > | |
| 660 | // / Checks t o see if t he current server is a develop ment inter agency CVI X. Very fr agile!!! | |
| 661 | // / </summar y> | |
| 662 | // / <param n ame="confi g"></param > | |
| 663 | // / <returns ><c>true</ c> if the current se rver is a developeme nt interag ency CVIX; <c>false< /c> otherw ise</retur ns> | |
| 664 | pr ivate stat ic bool Is Developmen tInteragen cyCvix(IVi xConfigura tionParame ters confi g) | |
| 665 | { | |
| 666 | bool isI nteragency Cvix = fal se; | |
| 667 | if (conf ig.VixRole == VixRol eType.Ente rpriseGate way) | |
| 668 | { | |
| 669 | // f ragile - m ust be upd ated as th e test env ironment i s updated - last upd ate 9/25/2 012 | |
| 670 | if ( /* Silver Spring Int eragency C VIX server s */ | |
| 671 | config.Vix ServerName Prop.ToUpp er() == " IMGX64VIX" || config .VixServer NameProp.T oUpper() = = " IMMIXVIX9" || | |
| 672 | /* Martins burg Inter agency CVI X servers */ | |
| 673 | config.Vix ServerName Prop.ToUpp er() == " DNS BNODCVIX5" || config .VixServer NameProp.T oUpper() = = " DNS BNODCVIX6" ) | |
| 674 | { | |
| 675 | isInterage ncyCvix = true; | |
| 676 | } | |
| 677 | } | |
| 678 | return i sInteragen cyCvix; | |
| 679 | } | |
| 680 | ||
| 681 | pr ivate stat ic void Up dateRealm( IVixConfig urationPar ameters co nfig, XmlN ode xmlRea lm) | |
| 682 | { | |
| 683 | xmlRealm .Attribute s["siteNum ber"].Valu e = config .SiteNumbe r; | |
| 684 | xmlRealm .Attribute s["siteAbb reviation" ].Value = config.Sit eAbbreviat ion; | |
| 685 | xmlRealm .Attribute s["siteNam e"].Value = config.S iteName; | |
| 686 | xmlRealm .Attribute s["vistaSe rver"].Val ue = confi g.VistaSer verName; | |
| 687 | xmlRealm .Attribute s["vistaPo rt"].Value = config. VistaServe rPort; | |
| 688 | if (conf ig.VixRole == VixRol eType.Ente rpriseGate way && xml Realm.Attr ibutes["ad ditionalUs erRoles"] != null) | |
| 689 | { | |
| 690 | xmlR ealm.Attri butes["add itionalUse rRoles"].V alue = con fig.Statio n200UserNa me + ":xca ,vista-use r"; | |
| 691 | // s et CPRS co ntext to f alse in th e test env ironment f or now | |
| 692 | if ( config.Sta tion200Use rName.ToLo wer() == " testing_1" || config .Station20 0UserName. ToLower() == "boatin g1") | |
| 693 | { | |
| 694 | if (xmlRea lm.Attribu tes["setCp rsContext" ] != null) | |
| 695 | { | |
| 696 | xmlRea lm.Attribu tes["setCp rsContext" ].Value = "false"; / / Perfrom local conn ection to VistA Imag ing in Rea lm - true would mean perform a local Vis tA connect ion | |
| 697 | } | |
| 698 | } | |
| 699 | if ( IsDevelopm entCvix(co nfig) == t rue && IsD evelopment Interagenc yCvix(conf ig) == tru e) | |
| 700 | { | |
| 701 | if (xmlRea lm.Attribu tes["gener ateBseToke n"] != nul l) | |
| 702 | { | |
| 703 | // Don t generate a BSE tok en because Station 2 00 token w ill not wo rk with ou r test env ironment - CAPRI wil l be used instead. | |
| 704 | xmlRea lm.Attribu tes["gener ateBseToke n"].Value = "false"; | |
| 705 | } | |
| 706 | } | |
| 707 | } | |
| 708 | } | |
| 709 | ||
| 710 | pr ivate stat ic XmlElem ent Create Context(IV ixConfigur ationParam eters conf ig, XmlDoc ument xmlS erverDom, VixWebAppl ication vi xWebApplic ation) | |
| 711 | { | |
| 712 | XmlEleme nt xmlCont ext = xmlS erverDom.C reateEleme nt("Contex t"); | |
| 713 | xmlConte xt.SetAttr ibute("coo kies", "fa lse"); | |
| 714 | xmlConte xt.SetAttr ibute("cro ssContext" , "false") ; | |
| 715 | xmlConte xt.SetAttr ibute("doc Base", vix WebApplica tion.DocBa se); | |
| 716 | xmlConte xt.SetAttr ibute("pat h", vixWeb Applicatio n.Path); | |
| 717 | xmlConte xt.SetAttr ibute("pri vileged", "false"); | |
| 718 | xmlConte xt.SetAttr ibute("rel oadable", "false"); | |
| 719 | xmlConte xt.SetAttr ibute("use Naming", " true"); | |
| 720 | return x mlContext; | |
| 721 | } | |
| 722 | ||
| 723 | // ---------- ---------- ---------- ------- | |
| 724 | ||
| 725 | // / <summary > | |
| 726 | // / Add or r emoves the java prop erties req uired by t he ViX to the Tomcat Java envi ronment. | |
| 727 | // / The only reason th is method is public is for tes ting purpo ses. | |
| 728 | // / </summar y> | |
| 729 | // / <returns >The set o f Procrun Java prope rties that were adde d as part of the cur rent insta llation.</ returns> | |
| 730 | pu blic stati c void App lyVixJavaP ropertiesF romManifes t(IVixConf igurationP arameters config, bo ol commit) | |
| 731 | { | |
| 732 | List<Str ing> modif iedOptions InfoList = new List< String>(); | |
| 733 | string p arametersK ey = null; | |
| 734 | Registry View regVi ew = Regis tryView.Re gistry64; | |
| 735 | if (Busi nessFacade .Is64BitOp eratingSys tem()) | |
| 736 | { | |
| 737 | para metersKey = @"SOFTWA RE\Wow6432 Node\Apach e Software Foundatio n\Procrun 2.0\" + To mcatFacade .TomcatSer viceName + @"\Parame ters\Java" ; | |
| 738 | } | |
| 739 | else | |
| 740 | { | |
| 741 | para metersKey = @"SOFTWA RE\Apache Software F oundation\ Procrun 2. 0\" + Tomc atFacade.T omcatServi ceName + @ "\Paramete rs\Java"; | |
| 742 | } | |
| 743 | ||
| 744 | using (R egistryKey regKey = RegistryKe y.OpenBase Key(Regist ryHive.Loc alMachine, regView)) | |
| 745 | { | |
| 746 | usin g (Registr yKey java = regKey.O penSubKey( parameters Key, true) ) | |
| 747 | { | |
| 748 | Debug.Asse rt(java.Ge tValueKind ("Options" ) == Regis tryValueKi nd.MultiSt ring); | |
| 749 | VixJavaPro perty[] ma nifestVixJ avaPropert ies = Mani fest.GetMa nifestVixJ avaPropert ies(config .ConfigDir ); | |
| 750 | Dictionary <String, V ixJavaProp erty> inst alledVixJa vaProperti es = GetIn stalledViX JavaProper ties((Stri ng[])java. GetValue(" Options")) ; | |
| 751 | ||
| 752 | foreach (V ixJavaProp erty manif estViXJava Property i n manifest VixJavaPro perties) | |
| 753 | { | |
| 754 | // klu dge - must fix up jc ifs proper ty file lo cation wit h the sele ction ViX configurat ion folder | |
| 755 | //if ( manifestVi XJavaPrope rty.Name = = "jcifs.p roperties" && Manife st.VixIter ation > 6) | |
| 756 | //{ | |
| 757 | // manifestVi XJavaPrope rty.Value = Path.Com bine(confi g.ConfigDi r, manifes tViXJavaPr operty.Val ue); | |
| 758 | //} | |
| 759 | ||
| 760 | if (ma nifestViXJ avaPropert y.Option = = VixJavaP ropertyOpt ion.AddUpd ate) | |
| 761 | { | |
| 762 | if (installe dVixJavaPr operties.C ontainsKey (manifestV iXJavaProp erty.Name) ) | |
| 763 | { | |
| 764 | VixJavaP roperty in stalledViX JavaProper ty = insta lledVixJav aPropertie s[manifest ViXJavaPro perty.Name ]; | |
| 765 | if (inst alledViXJa vaProperty .Value != manifestVi XJavaPrope rty.Value) | |
| 766 | { | |
| 767 | modi fiedOption sInfoList. Add(instal ledViXJava Property.N ame + " ch anged from " + | |
| 768 | installedV iXJavaProp erty.Value + " to " + manifest ViXJavaPro perty.Valu e); | |
| 769 | inst alledViXJa vaProperty .Value = m anifestViX JavaProper ty.Value; | |
| 770 | } | |
| 771 | } | |
| 772 | el se | |
| 773 | { | |
| 774 | modified OptionsInf oList.Add( manifestVi XJavaPrope rty.Name + "=" + man ifestViXJa vaProperty .Value | |
| 775 | + " has been a dded"); | |
| 776 | installe dVixJavaPr operties.A dd(manifes tViXJavaPr operty.Nam e, manifes tViXJavaPr operty); | |
| 777 | } | |
| 778 | } | |
| 779 | else i f (manifes tViXJavaPr operty.Opt ion == Vix JavaProper tyOption.R emove) | |
| 780 | { | |
| 781 | if (installe dVixJavaPr operties.C ontainsKey (manifestV iXJavaProp erty.Name) ) | |
| 782 | { | |
| 783 | modified OptionsInf oList.Add( manifestVi XJavaPrope rty.Name + "=" + man ifestViXJa vaProperty .Value | |
| 784 | + " has been r emoved"); | |
| 785 | installe dVixJavaPr operties.R emove(mani festViXJav aProperty. Name); | |
| 786 | } | |
| 787 | } | |
| 788 | } | |
| 789 | ||
| 790 | if (modifi edOptionsI nfoList.Co unt > 0) | |
| 791 | { | |
| 792 | Info(" Procrun JV M environm ent option s have bee n changed" ); | |
| 793 | if (co mmit == tr ue) | |
| 794 | { | |
| 795 | mo difiedOpti onsInfoLis t.Add("Upd ated Procr un JVM opt ions are a s follows: "); | |
| 796 | } | |
| 797 | else | |
| 798 | { | |
| 799 | mo difiedOpti onsInfoLis t.Add("Pro crun JVM o ptions tha t would be written ( commit = f alse):"); | |
| 800 | } | |
| 801 | List<S tring> opt ionsList = new List< String>(); | |
| 802 | foreac h (String key in ins talledVixJ avaPropert ies.Keys) | |
| 803 | { | |
| 804 | op tionsList. Add(instal ledVixJava Properties [key].ToSt ring()); | |
| 805 | } | |
| 806 | modifi edOptionsI nfoList.Ad dRange(opt ionsList); | |
| 807 | if (co mmit == tr ue) | |
| 808 | { | |
| 809 | ja va.SetValu e("Options ", options List.ToArr ay()); | |
| 810 | } | |
| 811 | foreac h (String option in modifiedOp tionsInfoL ist) | |
| 812 | { | |
| 813 | In fo(option) ; | |
| 814 | } | |
| 815 | } | |
| 816 | } | |
| 817 | } | |
| 818 | } | |
| 819 | ||
| 820 | / // <summar y> | |
| 821 | // / Reformat s a passed array of java prope rty string s as used by Procrun to establ ish Tomcat Java envi ronment | |
| 822 | // / as a Dic tionary of VixJavaPr operty obj ects. | |
| 823 | // / The only reason th is method is public is for tes ting purpo ses. | |
| 824 | // / </summar y> | |
| 825 | // / <param n ame="prope rtyList">T he array o f Java pro perties ex pressed as command l ine parama ters (i.e. -Dparamet er=value)< /param> | |
| 826 | // / <returns >Returns a Dictionar y of Java properties as VixJav aProperty objects ke yed by nam e</returns > | |
| 827 | pu blic stati c Dictiona ry<String, VixJavaPr operty> Ge tInstalled ViXJavaPro perties(St ring[] pro pertyList) | |
| 828 | { | |
| 829 | Dictiona ry<String, VixJavaPr operty> vi xJavaPrope rties = ne w Dictiona ry<String, VixJavaPr operty>(); | |
| 830 | string p refix = nu ll; | |
| 831 | ||
| 832 | foreach (String pr operty in propertyLi st) | |
| 833 | { | |
| 834 | if ( property = = "") | |
| 835 | { | |
| 836 | continue; | |
| 837 | } | |
| 838 | //De bug.Assert (property. StartsWith ("-D") || property.S tartsWith( "-X")); | |
| 839 | if ( property.S tartsWith( "-D")) | |
| 840 | { | |
| 841 | prefix = " -D"; | |
| 842 | } | |
| 843 | else if (prope rty.Starts With("-X") ) | |
| 844 | { | |
| 845 | prefix = " -X"; | |
| 846 | } | |
| 847 | else | |
| 848 | { | |
| 849 | throw new Exception( "Unexpecte d prefix i n Java pro perty - wa s expectin g -D or -X : " + prop erty); | |
| 850 | } | |
| 851 | ||
| 852 | Stri ng s = pro perty.Subs tring(2); | |
| 853 | Stri ng[] split s = s.Spli t('='); | |
| 854 | stri ng name = splits[0]. Trim(); | |
| 855 | stri ng value = null; | |
| 856 | if ( splits.Len gth >= 2) | |
| 857 | { | |
| 858 | value = sp lits[1].Tr im(); | |
| 859 | if (splits .Length > 2) | |
| 860 | { | |
| 861 | for (i nt i = 2; i < splits .Length; i ++) | |
| 862 | { | |
| 863 | va lue += "=" + splits[ i]; | |
| 864 | } | |
| 865 | value = value.Tr im(); | |
| 866 | } | |
| 867 | } | |
| 868 | ||
| 869 | VixJ avaPropert y installe dVixJavaPr operty = n ew VixJava Property(V ixJavaProp ertyOption .Installed , prefix, name, valu e, null); | |
| 870 | vixJ avaPropert ies.Add(in stalledVix JavaProper ty.Name, i nstalledVi xJavaPrope rty); | |
| 871 | } | |
| 872 | ||
| 873 | return v ixJavaProp erties; | |
| 874 | } | |
| 875 | ||
| 876 | // / <summary > | |
| 877 | // / | |
| 878 | // / </summar y> | |
| 879 | // / <returns ></returns > | |
| 880 | pu blic stati c string G etVixConfi gurationDi rectory() | |
| 881 | { | |
| 882 | String v ixConfigDi r = null; | |
| 883 | String v ixconfig = Environme nt.GetEnvi ronmentVar iable("vix config", E nvironment VariableTa rget.Machi ne); | |
| 884 | if (vixc onfig != n ull) | |
| 885 | { | |
| 886 | vixC onfigDir = vixconfig .Replace(" /", @"\"); // transl ate file s ystem deli miter back from Java forward s lash | |
| 887 | } | |
| 888 | return v ixConfigDi r; | |
| 889 | } | |
| 890 | ||
| 891 | // / <summary > | |
| 892 | // / | |
| 893 | // / </summar y> | |
| 894 | // / <returns ></returns > | |
| 895 | pu blic stati c String G etLocalVix CacheDirec tory() | |
| 896 | { | |
| 897 | String v ixCacheDir = null; | |
| 898 | String v ixcache = Environmen t.GetEnvir onmentVari able("vixc ache", Env ironmentVa riableTarg et.Machine ); | |
| 899 | if (vixc ache != nu ll) | |
| 900 | { | |
| 901 | vixC acheDir = vixcache.R eplace("/" , @"\"); / / translat e file sys tem delimi ter back f rom Java f orward sla sh | |
| 902 | } | |
| 903 | return v ixCacheDir ; | |
| 904 | } | |
| 905 | ||
| 906 | // / <summary > | |
| 907 | // / This met hod search es for an existing V IX configu ration fil e in a clu stered ins tall and r eturns the directory where the configura tion resid es | |
| 908 | // / </summar y> | |
| 909 | // / <returns >The direc tory where the confi guration r esides if found, nul l otherwis e</returns > | |
| 910 | pu blic stati c string G etExisting FocVixConf igurationD ir() | |
| 911 | { | |
| 912 | Debug.As sert(Clust erFacade.I sServerClu sterNode() ); | |
| 913 | DriveInf o[] drives = GetConf igDrives() ; | |
| 914 | ||
| 915 | foreach (DriveInfo drive in drives) | |
| 916 | { | |
| 917 | stri ng configD ir = Path. Combine(dr ive.Name, VixFacade. VIX_CONFIG _DIRECTORY ); | |
| 918 | stri ng filespe c = Path.C ombine(con figDir, VI X_CONFIG_F ILENAME); | |
| 919 | if ( File.Exist s(filespec )) | |
| 920 | { | |
| 921 | return con figDir; | |
| 922 | } | |
| 923 | } | |
| 924 | ||
| 925 | return n ull; | |
| 926 | } | |
| 927 | ||
| 928 | // / <summary > | |
| 929 | // / Returns a list of local driv es that ca n be used for a loca l VIX cach e or confi guration b ased on De ploymentTy pe | |
| 930 | // / </summar y> | |
| 931 | // / <param n ame="deplo ymentType" ></param> | |
| 932 | // / <returns ></returns > | |
| 933 | pu blic stati c DriveInf o[] GetCon figDrives( ) | |
| 934 | { | |
| 935 | List<Dri veInfo> dr ives = new List<Driv eInfo>(); | |
| 936 | ||
| 937 | foreach (DriveInfo drive in FileSystem .Drives) | |
| 938 | { | |
| 939 | if ( drive.IsRe ady && dri ve.DriveTy pe == Driv eType.Fixe d) | |
| 940 | { | |
| 941 | if (IsDriv eOkForDepl oyment(dri ve)) | |
| 942 | { | |
| 943 | drives .Add(drive ); | |
| 944 | } | |
| 945 | } | |
| 946 | } | |
| 947 | Debug.As sert(drive s.Count > 0); | |
| 948 | return d rives.ToAr ray(); | |
| 949 | } | |
| 950 | ||
| 951 | // / <summary > | |
| 952 | // / Returns a list of local driv es that ca n be used for a loca l VIX cach e or confi guration b ased on De ploymentTy pe | |
| 953 | // / </summar y> | |
| 954 | // / <param n ame="deplo ymentType" ></param> | |
| 955 | // / <returns ></returns > | |
| 956 | pu blic stati c DriveInf o[] GetCac heDrives(V ixDeployme ntType dep loymentTyp e, VixCach eType cach eType, int cacheSize InGB) | |
| 957 | { | |
| 958 | List<Dri veInfo> dr ives = new List<Driv eInfo>(); | |
| 959 | ||
| 960 | foreach (DriveInfo drive in FileSystem .Drives) | |
| 961 | { | |
| 962 | if ( drive.IsRe ady && dri ve.DriveTy pe == Driv eType.Fixe d) | |
| 963 | { | |
| 964 | if (cacheT ype == Vix CacheType. ExchangeTi meStorageE victionLoc alFilesyst em && driv e.Availabl eFreeSpace < (cacheS izeInGB * ONE_GIGBYT E)) | |
| 965 | { | |
| 966 | contin ue; | |
| 967 | } | |
| 968 | ||
| 969 | if (IsDriv eOkForDepl oyment(dri ve)) | |
| 970 | { | |
| 971 | drives .Add(drive ); | |
| 972 | } | |
| 973 | } | |
| 974 | } | |
| 975 | Debug.As sert(drive s.Count > 0); | |
| 976 | return d rives.ToAr ray(); | |
| 977 | } | |
| 978 | ||
| 979 | // / <summary > | |
| 980 | // / | |
| 981 | // / </summar y> | |
| 982 | // / <returns ></returns > | |
| 983 | pu blic stati c String G etDefaultL ocalVixCac heDrive(Vi xDeploymen tType depl oymentType , VixCache Type cache Type, int cacheSizeI nGB) | |
| 984 | { | |
| 985 | String v ixCacheDri ve = null; | |
| 986 | DriveInf o mostFree Space = nu ll; | |
| 987 | Info("Ge tDefaultLo calVixCach eDrive:"); | |
| 988 | ||
| 989 | foreach (DriveInfo drive in FileSystem .Drives) | |
| 990 | { | |
| 991 | if ( drive.IsRe ady && dri ve.DriveTy pe == Driv eType.Fixe d) | |
| 992 | { | |
| 993 | if (IsDriv eOkForDepl oyment(dri ve)) | |
| 994 | { | |
| 995 | // don t recommen d the quor um drive a s the defa ult (but a llow it) | |
| 996 | if (Cl usterFacad e.IsCluste rQuorumDri ve(drive)) | |
| 997 | { | |
| 998 | In fo("Drive " + drive. Name + " i s quorum d rive - ski pping"); | |
| 999 | co ntinue; | |
| 1000 | } | |
| 1001 | ||
| 1002 | if (ca cheType == VixCacheT ype.Exchan geTimeStor ageEvictio nLocalFile system && drive.Avai lableFreeS pace < (ca cheSizeInG B * ONE_GI GBYTE)) | |
| 1003 | { | |
| 1004 | In fo("Drive " + drive. Name + " h as less th an " + cac heSizeInGB .ToString( ) + " free space - s kipping"); | |
| 1005 | co ntinue; | |
| 1006 | } | |
| 1007 | ||
| 1008 | if (mo stFreeSpac e == null || drive.T otalFreeSp ace > most FreeSpace. TotalFreeS pace) | |
| 1009 | { | |
| 1010 | mo stFreeSpac e = drive; | |
| 1011 | In fo("Drive " + drive. Name + " i s a candid ate"); | |
| 1012 | } | |
| 1013 | } | |
| 1014 | } | |
| 1015 | } | |
| 1016 | ||
| 1017 | Debug.As sert(mostF reeSpace ! = null); | |
| 1018 | vixCache Drive = mo stFreeSpac e.Name.ToU pper(); | |
| 1019 | return v ixCacheDri ve; | |
| 1020 | } | |
| 1021 | ||
| 1022 | // / <summary > | |
| 1023 | // / | |
| 1024 | // / </summar y> | |
| 1025 | // / <returns ></returns > | |
| 1026 | pu blic stati c String G etFullyQua ifiedHdigD icomDirect ory() | |
| 1027 | { | |
| 1028 | Info("Ge tFullyQuai fiedHdigDi comDirecto ry: "); | |
| 1029 | ||
| 1030 | foreach (DriveInfo drive in FileSystem .Drives) | |
| 1031 | { | |
| 1032 | if ( drive.IsRe ady && dri ve.DriveTy pe == Driv eType.Fixe d) | |
| 1033 | { | |
| 1034 | string dic omDirector y = drive. Name + Vix Facade.HDI G_DICOM_DI RECTORY; | |
| 1035 | if (Direct ory.Exists (dicomDire ctory)) | |
| 1036 | { | |
| 1037 | Info(" \tFound " + dicomDir ectory); | |
| 1038 | return dicomDire ctory; | |
| 1039 | } | |
| 1040 | } | |
| 1041 | } | |
| 1042 | ||
| 1043 | Info("\t Found null "); | |
| 1044 | return n ull; | |
| 1045 | } | |
| 1046 | ||
| 1047 | // / <summary > | |
| 1048 | // / | |
| 1049 | // / </summar y> | |
| 1050 | // / <param n ame="deplo ymentType" ></param> | |
| 1051 | // / <param n ame="cache Type"></pa ram> | |
| 1052 | // / <param n ame="cache SizeInGB"> </param> | |
| 1053 | // / <returns ></returns > | |
| 1054 | pu blic stati c String G etDefaultV ixConfigDr ive(VixDep loymentTyp e deployme ntType, Vi xCacheType cacheType , int cach eSizeInGB) | |
| 1055 | { | |
| 1056 | if (depl oymentType == VixDep loymentTyp e.SingleSe rver) | |
| 1057 | { | |
| 1058 | Stri ng systemD rive = Env ironment.G etEnvironm entVariabl e("SystemD rive", Env ironmentVa riableTarg et.Process ).ToUpper( ) + @"\"; | |
| 1059 | retu rn systemD rive; | |
| 1060 | } | |
| 1061 | else | |
| 1062 | { | |
| 1063 | retu rn GetDefa ultLocalVi xCacheDriv e(deployme ntType, ca cheType, c acheSizeIn GB); | |
| 1064 | } | |
| 1065 | } | |
| 1066 | ||
| 1067 | // / <summary > | |
| 1068 | // / Returns the direc tory where the VIX k eystore an d truststo re files w ill go. | |
| 1069 | // / </summar y> | |
| 1070 | // / <returns ></returns > | |
| 1071 | pu blic stati c String G etVixCerti ficateStor eDir() | |
| 1072 | { | |
| 1073 | String s ystemDrive = Environ ment.GetEn vironmentV ariable("S ystemDrive ", Environ mentVariab leTarget.P rocess).To Upper() + @"\"; | |
| 1074 | return P ath.Combin e(systemDr ive, VIX_C ERTSTORE_D IRECTORY); | |
| 1075 | } | |
| 1076 | ||
| 1077 | #e ndregion | |
| 1078 | ||
| 1079 | #r egion priv ate utilit y methods | |
| 1080 | ||
| 1081 | // / <summary > | |
| 1082 | // / Recursiv ely remove read only attribute s from all files in the specif ied folder and its s ubfolders. | |
| 1083 | // / </summar y> | |
| 1084 | // / <param n ame="paren tFolder">T he parent folder.</p aram> | |
| 1085 | // / <remarks ></remarks > | |
| 1086 | st atic priva te void Re moveReadOn lyAttribut es(String parentFold er) | |
| 1087 | { | |
| 1088 | String[] folders = Directory .GetDirect ories(pare ntFolder); | |
| 1089 | long fol derCount = folders.L ength; | |
| 1090 | ||
| 1091 | Director yInfo pare ntFolderIn fo = new D irectoryIn fo(parentF older); | |
| 1092 | foreach (FileInfo fileInfo i n parentFo lderInfo.G etFiles()) | |
| 1093 | { | |
| 1094 | File .SetAttrib utes(fileI nfo.FullNa me, FileAt tributes.N ormal); | |
| 1095 | } | |
| 1096 | ||
| 1097 | foreach (String fo lder in fo lders) | |
| 1098 | { | |
| 1099 | Remo veReadOnly Attributes (folder); | |
| 1100 | } | |
| 1101 | } | |
| 1102 | ||
| 1103 | // / <summary > | |
| 1104 | // / Register s the or u nregisters an ocx fi le | |
| 1105 | // / </summar y> | |
| 1106 | // / <param n ame="ocxFi lespec">Th e ocx file spec to re gister or unregusrer .</param> | |
| 1107 | // / <param n ame="regis ter">if se t to <c>tr ue</c> [re gister]; < c>false</c > [unregis ter].</par am> | |
| 1108 | // / <returns >command p rocessor e xit code w here 0 is success</r eturns> | |
| 1109 | // / <remarks ></remarks > | |
| 1110 | pr ivate stat ic int Reg isterOrUnr egisterOcx (string oc xFilespec, bool regi ster) | |
| 1111 | { | |
| 1112 | int exit Code = 0; // externa l process executed o k - comman d shell co nvention | |
| 1113 | ||
| 1114 | using (P rocess ext ernalProce ss = new P rocess()) | |
| 1115 | { | |
| 1116 | exte rnalProces s.StartInf o.FileName = "regsvr 32"; | |
| 1117 | exte rnalProces s.StartInf o.Argument s = (regis ter ? "/s" : "/s /u" ) + " " + ocxFilespe c; | |
| 1118 | exte rnalProces s.StartInf o.WorkingD irectory = Path.GetD irectoryNa me(ocxFile spec); ; | |
| 1119 | exte rnalProces s.StartInf o.UseShell Execute = false; | |
| 1120 | exte rnalProces s.StartInf o.CreateNo Window = t rue; | |
| 1121 | exte rnalProces s.Start(); | |
| 1122 | ||
| 1123 | try | |
| 1124 | { | |
| 1125 | do | |
| 1126 | { | |
| 1127 | DoEven ts(); | |
| 1128 | Thread .Sleep(500 ); | |
| 1129 | extern alProcess. Refresh(); | |
| 1130 | } while (! externalPr ocess.HasE xited); | |
| 1131 | exitCode = externalP rocess.Exi tCode; | |
| 1132 | } | |
| 1133 | fina lly | |
| 1134 | { | |
| 1135 | externalPr ocess.Clos e(); | |
| 1136 | } | |
| 1137 | } | |
| 1138 | ||
| 1139 | return e xitCode; | |
| 1140 | } | |
| 1141 | ||
| 1142 | // / <summary > | |
| 1143 | // / | |
| 1144 | // / </summar y> | |
| 1145 | // / <param n ame="deplo ymentType" ></param> | |
| 1146 | // / <returns ></returns > | |
| 1147 | pr ivate stat ic bool Is DriveOkFor Deployment (DriveInfo drive) | |
| 1148 | { | |
| 1149 | bool isD riveOk = t rue; | |
| 1150 | String s ystemDrive = Environ ment.GetEn vironmentV ariable("S ystemDrive ", Environ mentVariab leTarget.P rocess).To Upper() + @"\"; | |
| 1151 | ||
| 1152 | try | |
| 1153 | { | |
| 1154 | if ( drive.Driv eType == D riveType.F ixed && dr ive.IsRead y == true) | |
| 1155 | { | |
| 1156 | if (drive. Name.ToUpp er() == sy stemDrive) // for FO C clusters , system d rive is no t shared | |
| 1157 | { | |
| 1158 | if (Cl usterFacad e.IsServer ClusterNod e()) | |
| 1159 | { | |
| 1160 | is DriveOk = false; | |
| 1161 | } | |
| 1162 | } | |
| 1163 | } | |
| 1164 | else | |
| 1165 | { | |
| 1166 | isDriveOk = false; | |
| 1167 | } | |
| 1168 | } | |
| 1169 | catch (E xception e x) | |
| 1170 | { | |
| 1171 | Info (ex.Messag e); | |
| 1172 | isDr iveOk = fa lse; | |
| 1173 | } | |
| 1174 | //finall y | |
| 1175 | //{ | |
| 1176 | // In fo(drive.N ame + (isD riveOk ? " is OK for cache or config fil es" : "is not OK for cache or config fil es")); | |
| 1177 | //} | |
| 1178 | ||
| 1179 | return i sDriveOk; | |
| 1180 | } | |
| 1181 | ||
| 1182 | // / <summary > | |
| 1183 | // / A helper method to wrap the infoDelega te member, which if non null p rovide a w ay to repo rt status to the | |
| 1184 | // / user int erface. | |
| 1185 | // / </summar y> | |
| 1186 | // / <param n ame="infoM essage">me ssage to d isplay in the user i nterface.< /param> | |
| 1187 | // / <returns >the messa ge string passed in the infoMe ssage para meter to s upport cha ining.</re turns> | |
| 1188 | pr ivate stat ic String Info(Strin g infoMess age) | |
| 1189 | { | |
| 1190 | if (info Delegate ! = null) | |
| 1191 | { | |
| 1192 | info Delegate(i nfoMessage ); | |
| 1193 | } | |
| 1194 | Logger() .Info(info Message); // any inf o provided to the pr esentation layer wil l be logge d. | |
| 1195 | return i nfoMessage ; | |
| 1196 | } | |
| 1197 | ||
| 1198 | // / <summary > | |
| 1199 | // / | |
| 1200 | // / </summar y> | |
| 1201 | pr ivate stat ic void Do Events() | |
| 1202 | { | |
| 1203 | if (appE ventsDeleg ate != nul l) | |
| 1204 | { | |
| 1205 | appE ventsDeleg ate(); | |
| 1206 | } | |
| 1207 | } | |
| 1208 | ||
| 1209 | // / <summary > | |
| 1210 | // / Retrieve a logger for this c lass. | |
| 1211 | // / </summar y> | |
| 1212 | // / <returns >A logger as a ILog interface. </returns> | |
| 1213 | pr ivate stat ic ILog Lo gger() | |
| 1214 | { | |
| 1215 | return L ogManager. GetLogger( typeof(Vix Facade).Na me); | |
| 1216 | } | |
| 1217 | ||
| 1218 | // / <summary > | |
| 1219 | // / | |
| 1220 | // / </summar y> | |
| 1221 | // / <param n ame="filen ame"></par am> | |
| 1222 | // / <param n ame="targe tDir"></pa ram> | |
| 1223 | pr ivate stat ic void De leteHelper (String fi lename, St ring targe tDir) | |
| 1224 | { | |
| 1225 | String t argetPath = Path.Com bine(targe tDir, file name); | |
| 1226 | if (File .Exists(ta rgetPath)) | |
| 1227 | { | |
| 1228 | Info ("Deleting deprecate d file " + targetPat h); | |
| 1229 | File .Delete(ta rgetPath); | |
| 1230 | } | |
| 1231 | } | |
| 1232 | ||
| 1233 | // / <summary > | |
| 1234 | // / | |
| 1235 | // / </summar y> | |
| 1236 | // / <param n ame="comma ndParamete rs"></para m> | |
| 1237 | // / <param n ame="paylo adPath"></ param> | |
| 1238 | // / <param n ame="confi g"></param > | |
| 1239 | pr ivate stat ic void Ru nJavaUtili ty(String commandPar ameters, I VixConfigu rationPara meters con fig) | |
| 1240 | { | |
| 1241 | String p ayloadJar = Path.Com bine(VixFa cade.Manif est.Payloa dPath, @"s erver\jars "); | |
| 1242 | String j avaExeFile spec = Pat h.Combine( JavaFacade .GetActive JavaPath(J avaFacade. IsActiveJr eInstalled ()), @"bin \java.exe" ); | |
| 1243 | ||
| 1244 | using (P rocess ext ernalProce ss = new P rocess()) | |
| 1245 | { | |
| 1246 | exte rnalProces s.StartInf o.FileName = javaExe Filespec; | |
| 1247 | exte rnalProces s.StartInf o.Argument s = comman dParameter s; | |
| 1248 | exte rnalProces s.StartInf o.WorkingD irectory = payloadJa r; | |
| 1249 | exte rnalProces s.StartInf o.UseShell Execute = false; | |
| 1250 | exte rnalProces s.StartInf o.CreateNo Window = t rue; // DK B - 5/25/1 0 | |
| 1251 | if ( externalPr ocess.Star tInfo.Envi ronmentVar iables.Con tainsKey(" vixconfig" )) | |
| 1252 | { | |
| 1253 | externalPr ocess.Star tInfo.Envi ronmentVar iables.Rem ove("vixco nfig"); | |
| 1254 | } | |
| 1255 | exte rnalProces s.StartInf o.Environm entVariabl es.Add("vi xconfig", config.Con figDir); | |
| 1256 | if ( externalPr ocess.Star tInfo.Envi ronmentVar iables.Con tainsKey(" vixcache") ) | |
| 1257 | { | |
| 1258 | externalPr ocess.Star tInfo.Envi ronmentVar iables.Rem ove("vixca che"); | |
| 1259 | } | |
| 1260 | exte rnalProces s.StartInf o.Environm entVariabl es.Add("vi xcache", c onfig.Loca lCacheDir) ; | |
| 1261 | exte rnalProces s.Start(); | |
| 1262 | ||
| 1263 | try | |
| 1264 | { | |
| 1265 | do | |
| 1266 | { | |
| 1267 | DoEven ts(); | |
| 1268 | Thread .Sleep(500 ); | |
| 1269 | extern alProcess. Refresh(); | |
| 1270 | } while (! externalPr ocess.HasE xited); | |
| 1271 | //exitCode = externa lProcess.E xitCode; | |
| 1272 | } | |
| 1273 | fina lly | |
| 1274 | { | |
| 1275 | externalPr ocess.Clos e(); | |
| 1276 | } | |
| 1277 | } | |
| 1278 | } | |
| 1279 | ||
| 1280 | // / <summary > | |
| 1281 | // / | |
| 1282 | // / </summar y> | |
| 1283 | // / <param n ame="confi g"></param > | |
| 1284 | // / <param n ame="paylo adPath"></ param> | |
| 1285 | pu blic stati c void Dep loyDepende ncyFiles(I VixConfigu rationPara meters con fig, bool commit) | |
| 1286 | { | |
| 1287 | VixDepen dencyFile[ ] vixDepen dencyFiles = Manifes t.GetDepen dencyFiles (config); | |
| 1288 | NativeTy pe native = manifest .CurrentNa tiveInstal lation; | |
| 1289 | ||
| 1290 | if (vixD ependencyF iles.Lengt h > 0) | |
| 1291 | { | |
| 1292 | Info ("Copying distributi on files.. ."); | |
| 1293 | } | |
| 1294 | foreach (VixDepend encyFile v ixDependen cyFile in vixDepende ncyFiles) | |
| 1295 | { | |
| 1296 | if ( commit == true) | |
| 1297 | { | |
| 1298 | if (vixDep endencyFil e.Dependen cyType == VixDepende ncyType.Zi pConfigFil e) | |
| 1299 | { | |
| 1300 | Info(" Unzipping " + vixDep endencyFil e.GetPaylo adFilespec () + " to " + vixDep endencyFil e.GetAppFo lder()); | |
| 1301 | ZipUti lities.UnZ ip(vixDepe ndencyFile .GetPayloa dFilespec( ), vixDepe ndencyFile .GetAppFol der()); | |
| 1302 | } | |
| 1303 | else if (v ixDependen cyFile.Nat ive == Nat iveType.al l || vixDe pendencyFi le.Native == native) | |
| 1304 | { | |
| 1305 | Info(" Copying " + vixDepen dencyFile. GetPayload Filespec() + " to " + vixDepen dencyFile. GetAppFile spec()); | |
| 1306 | if (Fi le.Exists( vixDepende ncyFile.Ge tAppFilesp ec())) | |
| 1307 | { | |
| 1308 | Fi le.SetAttr ibutes(vix Dependency File.GetAp pFilespec( ), FileAtt ributes.No rmal); | |
| 1309 | } | |
| 1310 | File.D elete(vixD ependencyF ile.GetApp Filespec() ); | |
| 1311 | File.C opy(vixDep endencyFil e.GetPaylo adFilespec (), vixDep endencyFil e.GetAppFi lespec()); | |
| 1312 | } | |
| 1313 | else | |
| 1314 | { | |
| 1315 | Info(" Skipping " + vixDepe ndencyFile .Native + " dependen cy " + vix Dependency File.GetPa yloadFiles pec()); | |
| 1316 | } | |
| 1317 | } | |
| 1318 | } | |
| 1319 | ||
| 1320 | if (!con fig.IsPatc h) | |
| 1321 | { | |
| 1322 | Stri ng payload Properties = Path.Co mbine(VixF acade.Mani fest.Paylo adPath, @" server/pro perties"); | |
| 1323 | if ( commit == true) | |
| 1324 | { | |
| 1325 | RewriteLog gingProper tiesFile(p ayloadProp erties, "l og4j.prope rties", Vi xFacade.Ge tVixConfig urationDir ectory(), config); | |
| 1326 | } | |
| 1327 | } | |
| 1328 | } | |
| 1329 | ||
| 1330 | ||
| 1331 | pu blic stati c void Dep loyWebAppD ependencyF iles(IVixC onfigurati onParamete rs config, bool comm it) | |
| 1332 | { | |
| 1333 | VixDepen dencyFile[ ] vixDepen dencyFiles = Manifes t.GetWebAp pDependenc yFiles(con fig); | |
| 1334 | NativeTy pe native = manifest .CurrentNa tiveInstal lation; | |
| 1335 | ||
| 1336 | if (vixD ependencyF iles.Lengt h > 0) | |
| 1337 | { | |
| 1338 | Info ("Copying web applic ation dist ribution f iles..."); | |
| 1339 | } | |
| 1340 | foreach (VixDepend encyFile v ixDependen cyFile in vixDepende ncyFiles) | |
| 1341 | { | |
| 1342 | if ( commit == true) | |
| 1343 | { | |
| 1344 | if (vixDep endencyFil e.Dependen cyType == VixDepende ncyType.Zi pConfigFil e) | |
| 1345 | { | |
| 1346 | Info(" Unzipping " + vixDep endencyFil e.GetPaylo adFilespec () + " to " + vixDep endencyFil e.GetAppFo lder()); | |
| 1347 | ZipUti lities.UnZ ip(vixDepe ndencyFile .GetPayloa dFilespec( ), vixDepe ndencyFile .GetAppFol der()); | |
| 1348 | } | |
| 1349 | else if (v ixDependen cyFile.Nat ive == Nat iveType.al l || vixDe pendencyFi le.Native == native) | |
| 1350 | { | |
| 1351 | Info(" Copying " + vixDepen dencyFile. GetPayload Filespec() + " to " + vixDepen dencyFile. GetAppFile spec()); | |
| 1352 | if (Fi le.Exists( vixDepende ncyFile.Ge tAppFilesp ec())) | |
| 1353 | { | |
| 1354 | Fi le.SetAttr ibutes(vix Dependency File.GetAp pFilespec( ), FileAtt ributes.No rmal); | |
| 1355 | } | |
| 1356 | File.D elete(vixD ependencyF ile.GetApp Filespec() ); // hand les read o nly file | |
| 1357 | File.C opy(vixDep endencyFil e.GetPaylo adFilespec (), vixDep endencyFil e.GetAppFi lespec()); | |
| 1358 | } | |
| 1359 | else | |
| 1360 | { | |
| 1361 | Info(" Skipping " + vixDepe ndencyFile .Native + " dependen cy " + vix Dependency File.GetPa yloadFiles pec()); | |
| 1362 | } | |
| 1363 | } | |
| 1364 | } | |
| 1365 | } | |
| 1366 | ||
| 1367 | pu blic stati c void Dep loyImageGe arDependen cyFiles(IV ixConfigur ationParam eters conf ig, bool c ommit) | |
| 1368 | { | |
| 1369 | VixDepen dencyFile[ ] vixDepen dencyFiles = Manifes t.GetImage GearDepend encyFiles( config); | |
| 1370 | ||
| 1371 | if (vixD ependencyF iles.Lengt h > 0) | |
| 1372 | { | |
| 1373 | Info ("Copying web applic ation dist ribution f iles..."); | |
| 1374 | } | |
| 1375 | foreach (VixDepend encyFile v ixDependen cyFile in vixDepende ncyFiles) | |
| 1376 | { | |
| 1377 | if ( commit == true) | |
| 1378 | { | |
| 1379 | if (vixDep endencyFil e.Dependen cyType == VixDepende ncyType.Zi pConfigFil e) | |
| 1380 | { | |
| 1381 | Info(" Unzipping " + vixDep endencyFil e.GetPaylo adFilespec () + " to " + vixDep endencyFil e.GetAppFo lder()); | |
| 1382 | ZipUti lities.UnZ ip(vixDepe ndencyFile .GetPayloa dFilespec( ), vixDepe ndencyFile .GetAppFol der()); | |
| 1383 | } | |
| 1384 | else | |
| 1385 | { | |
| 1386 | Info(" Copying " + vixDepen dencyFile. GetPayload Filespec() + " to " + vixDepen dencyFile. GetAppFile spec()); / / side eff ect - crea tes folder if necess ary | |
| 1387 | if (Fi le.Exists( vixDepende ncyFile.Ge tAppFilesp ec())) | |
| 1388 | { | |
| 1389 | Fi le.SetAttr ibutes(vix Dependency File.GetAp pFilespec( ), FileAtt ributes.No rmal); | |
| 1390 | } | |
| 1391 | File.D elete(vixD ependencyF ile.GetApp Filespec() ); // hand les read o nly file | |
| 1392 | File.C opy(vixDep endencyFil e.GetPaylo adFilespec (), vixDep endencyFil e.GetAppFi lespec()); | |
| 1393 | } | |
| 1394 | } | |
| 1395 | } | |
| 1396 | } | |
| 1397 | ||
| 1398 | pu blic stati c void Del eteDepreca tedDistrib utionFiles (IVixConfi gurationPa rameters c onfig, boo l commit) | |
| 1399 | { | |
| 1400 | VixDepre catedFile[ ] vixDepre catedFiles = Manifes t.GetDepre catedFiles (config); | |
| 1401 | ||
| 1402 | Info("De leting dep recated fi les..."); | |
| 1403 | foreach (VixDeprec atedFile v ixDeprecat edFile in vixDepreca tedFiles) | |
| 1404 | { | |
| 1405 | if ( File.Exist s(vixDepre catedFile. GetAppFile spec())) | |
| 1406 | { | |
| 1407 | Info("Dele ting " + v ixDeprecat edFile.Get AppFilespe c()); | |
| 1408 | if (commit == true) | |
| 1409 | { | |
| 1410 | File.D elete(vixD eprecatedF ile.GetApp Filespec() ); | |
| 1411 | } | |
| 1412 | } | |
| 1413 | } | |
| 1414 | } | |
| 1415 | ||
| 1416 | pu blic stati c VixDepen dencyFile[ ] FilterFi lesByType( VixDepende ncyFile[] vixDepende ncyFiles, IVixConfig urationPar ameters co nfig, VixD ependencyT ype vixDep endencyTyp e) | |
| 1417 | { | |
| 1418 | List<Vix Dependency File> filt eredFiles = new List <VixDepend encyFile>( ); | |
| 1419 | ||
| 1420 | foreach (VixDepend encyFile v ixDependen cyFile in vixDepende ncyFiles) | |
| 1421 | { | |
| 1422 | if ( vixDepende ncyFile.De pendencyTy pe == vixD ependencyT ype) | |
| 1423 | { | |
| 1424 | filteredFi les.Add(vi xDependenc yFile); | |
| 1425 | } | |
| 1426 | } | |
| 1427 | return f ilteredFil es.ToArray (); | |
| 1428 | } | |
| 1429 | ||
| 1430 | pu blic stati c void Del eteDepreca tedDistrib utionDirec tories(IVi xConfigura tionParame ters confi g, bool co mmit) | |
| 1431 | { | |
| 1432 | VixDepre catedDirec tory[] vix Deprecated Directorie s = Manife st.GetDepr ecatedDire ctories(co nfig); | |
| 1433 | ||
| 1434 | Info("De leting dep recated di rectories. .."); | |
| 1435 | foreach (VixDeprec atedDirect ory vixDep recatedDir ectory in vixDepreca tedDirecto ries) | |
| 1436 | { | |
| 1437 | if ( Directory. Exists(vix Deprecated Directory. GetDirecto ryPath())) | |
| 1438 | { | |
| 1439 | Info("Dele ting " + v ixDeprecat edDirector y.GetDirec toryPath() ); | |
| 1440 | if (commit == true) | |
| 1441 | { | |
| 1442 | Direct ory.Delete (vixDeprec atedDirect ory.GetDir ectoryPath (), true); // recurs ive delete | |
| 1443 | } | |
| 1444 | } | |
| 1445 | } | |
| 1446 | ||
| 1447 | } | |
| 1448 | ||
| 1449 | // / <summary > | |
| 1450 | // / | |
| 1451 | // / </summar y> | |
| 1452 | // / <param n ame="confi g"></param > | |
| 1453 | // / <param n ame="paylo adPath"></ param> | |
| 1454 | // / <param n ame="isDev eloperMode "></param> | |
| 1455 | pu blic stati c void Wri teViXConfi gurationFi les(IVixCo nfiguratio nParameter s config) //, bool i sDeveloper Mode) | |
| 1456 | { | |
| 1457 | VixJavaC onfigurati onUtility[ ] vixConfi gUtilites = Manifest .JavaConfi gurationUt ilityPrope rties; | |
| 1458 | ||
| 1459 | foreach (VixJavaCo nfiguratio nUtility c onfigUtili ty in vixC onfigUtili tes) | |
| 1460 | { | |
| 1461 | Exec uteConfigu rationUtil ity(config Utility, c onfig); | |
| 1462 | } | |
| 1463 | } | |
| 1464 | ||
| 1465 | // / <summary > | |
| 1466 | // / Check to see that a zip file contains a keystore and trust store maki ng it a "v alid" cert ificate. | |
| 1467 | // / </summar y> | |
| 1468 | // / <param n ame="certi ficateFile spec">The zip file w hich shoul d contain a keystore and trust store</par am> | |
| 1469 | // / <returns >true if t he zip fil e contains a keystor e and trus tstore</re turns> | |
| 1470 | pu blic stati c bool IsF ederationC ertificate Valid(stri ng certifi cateFilesp ec) | |
| 1471 | { | |
| 1472 | bool isV ixCertific ateValid = false; | |
| 1473 | List<str ing> allow edCertific ateFiles = new List< string>(); | |
| 1474 | allowedC ertificate Files.Add( FEDERATION _KEYSTORE_ FILENAME); | |
| 1475 | allowedC ertificate Files.Add( FEDERATION _TRUSTSTOR E_FILENAME ); | |
| 1476 | //TODO: add host n ame check | |
| 1477 | if (ZipU tilities.F ileCount(c ertificate Filespec) == 2 && Zi pUtilities .CheckZipC ontents(ce rtificateF ilespec, a llowedCert ificateFil es.ToArray ())) | |
| 1478 | { | |
| 1479 | isVi xCertifica teValid = true; | |
| 1480 | } | |
| 1481 | return i sVixCertif icateValid ; | |
| 1482 | } | |
| 1483 | ||
| 1484 | // / <summary > | |
| 1485 | // / Check to see that a zip file contains a keystore and trust store maki ng it a "v alid" cert ificate. | |
| 1486 | // / </summar y> | |
| 1487 | // / <param n ame="certi ficateFile spec">The zip file w hich shoul d contain a keystore and trust store</par am> | |
| 1488 | // / <returns >true if t he zip fil e contains a keystor e and trus tstore</re turns> | |
| 1489 | pu blic stati c bool IsX caCertific ateValid(s tring cert ificateFil espec) | |
| 1490 | { | |
| 1491 | bool isX caCertific ateValid = false; | |
| 1492 | List<str ing> allow edCertific ateFiles = new List< string>(); | |
| 1493 | //allowe dCertifica teFiles.Ad d(XCA_KEYS TORE_FILEN AME); | |
| 1494 | //allowe dCertifica teFiles.Ad d(XCA_TRUS TSTORE_FIL ENAME); | |
| 1495 | allowedC ertificate Files.Add( XCA_CERTIF ICATE_FILE NAME); | |
| 1496 | allowedC ertificate Files.Add( XCA_PRIVAT E_KEY_FILE NAME); | |
| 1497 | //TODO: add host n ame check | |
| 1498 | if (ZipU tilities.F ileCount(c ertificate Filespec) >= allowed Certificat eFiles.Cou nt && ZipU tilities.C heckZipCon tents(cert ificateFil espec, all owedCertif icateFiles .ToArray() )) | |
| 1499 | { | |
| 1500 | isXc aCertifica teValid = true; | |
| 1501 | } | |
| 1502 | return i sXcaCertif icateValid ; | |
| 1503 | } | |
| 1504 | #e ndregion | |
| 1505 | ||
| 1506 | #r egion priv ate instal lation met hods | |
| 1507 | ||
| 1508 | ||
| 1509 | // / <summary > | |
| 1510 | // / Uninstal ls the web applicati on. | |
| 1511 | // / </summar y> | |
| 1512 | // / <param n ame="vixWe bApplicati on">The vi x web appl ication ob ject.</par am> | |
| 1513 | // / <param n ame="delet eWar">if s et to <c>t rue</c> [d elete the war the we b applicat ion came f rom].</par am> | |
| 1514 | // / <remarks ></remarks > | |
| 1515 | pr ivate stat ic void Un installWeb Applicatio n(IVixConf igurationP arameters config, Vi xWebApplic ation vixW ebApplicat ion, bool deleteWar) | |
| 1516 | { | |
| 1517 | if (dele teWar) | |
| 1518 | { | |
| 1519 | stri ng warFile Spec = Pat h.Combine( TomcatFaca de.TomcatW ebApplicat ionFolder, vixWebApp lication.W ar); | |
| 1520 | if ( File.Exist s(warFileS pec)) | |
| 1521 | { | |
| 1522 | File.Delet e(warFileS pec); | |
| 1523 | Info(" Deleted " + warFileS pec); | |
| 1524 | } | |
| 1525 | } | |
| 1526 | ||
| 1527 | string p athFolder = vixWebAp plication. Path.Start sWith("/") ? vixWebA pplication .Path.Subs tring(1) : vixWebApp lication.P ath; | |
| 1528 | string w ebAppPathF older = Pa th.Combine (TomcatFac ade.Tomcat WebApplica tionFolder , pathFold er); | |
| 1529 | if (Dire ctory.Exis ts(webAppP athFolder) ) | |
| 1530 | { | |
| 1531 | Remo veReadOnly Attributes (webAppPat hFolder); // recurse | |
| 1532 | Dire ctory.Dele te(webAppP athFolder, true); // recurse | |
| 1533 | Info (" Dele ted " + we bAppPathFo lder); | |
| 1534 | } | |
| 1535 | string w ebAppPathW orkFolder = Path.Com bine(Tomca tFacade.Ge tTomcatWor kFolder(co nfig.SiteN umber), pa thFolder); | |
| 1536 | if (Dire ctory.Exis ts(webAppP athWorkFol der)) | |
| 1537 | { | |
| 1538 | Remo veReadOnly Attributes (webAppPat hWorkFolde r); // rec urse | |
| 1539 | Dire ctory.Dele te(webAppP athWorkFol der, true) ; // recur se | |
| 1540 | Info (" Dele ted " + we bAppPathWo rkFolder); | |
| 1541 | } | |
| 1542 | } | |
| 1543 | ||
| 1544 | // / <summary > | |
| 1545 | // / | |
| 1546 | // / </summar y> | |
| 1547 | // / <param n ame="sourc eDir"></pa ram> | |
| 1548 | // / <param n ame="sourc eFilename" ></param> | |
| 1549 | // / <param n ame="targe tDir"></pa ram> | |
| 1550 | // / <param n ame="confi g"></param > | |
| 1551 | pr ivate stat ic void Re writeLoggi ngProperti esFile(Str ing source Dir, Strin g sourceFi lename, St ring targe tDir, | |
| 1552 | IVixConf igurationP arameters config) | |
| 1553 | { | |
| 1554 | String s ourcePath = Path.Com bine(sourc eDir, sour ceFilename ); | |
| 1555 | String t argetPath = Path.Com bine(targe tDir, sour ceFilename ); | |
| 1556 | String v ixConfigDi r = config .ConfigDir .Replace(@ "\", "/"); // transl ate file s ystem deli miter so J ava doesnt barf | |
| 1557 | Info("Re writing " + sourceFi lename + " to " + ta rgetDir); | |
| 1558 | ||
| 1559 | using (S treamReade r sr = new StreamRea der(source Path)) | |
| 1560 | { | |
| 1561 | usin g (StreamW riter sw = File.Crea teText(tar getPath)) // file wi ll be over written | |
| 1562 | { | |
| 1563 | String lin e; | |
| 1564 | while ((li ne = sr.Re adLine()) != null) | |
| 1565 | { | |
| 1566 | if (li ne.Contain s("vixconf ig=")) | |
| 1567 | { | |
| 1568 | sw .WriteLine ("vixconfi g=" + vixC onfigDir); | |
| 1569 | } | |
| 1570 | else | |
| 1571 | { | |
| 1572 | sw .WriteLine (line); | |
| 1573 | } | |
| 1574 | } | |
| 1575 | sw.Close() ; | |
| 1576 | } | |
| 1577 | sr.C lose(); | |
| 1578 | } | |
| 1579 | } | |
| 1580 | ||
| 1581 | // / <summary > | |
| 1582 | // / | |
| 1583 | // / </summar y> | |
| 1584 | // / <param n ame="confi gUtility"> </param> | |
| 1585 | // / <param n ame="confi g"></param > | |
| 1586 | // / <param n ame="paylo adPath"></ param> | |
| 1587 | pr ivate stat ic void Ex ecuteConfi gurationUt ility(VixJ avaConfigu rationUtil ity config Utility, I VixConfigu rationPara meters con fig) | |
| 1588 | { | |
| 1589 | StringBu ilder sb = new Strin gBuilder() ; | |
| 1590 | ||
| 1591 | // Trans action Imp ort Log ut ility requ ires this to operate | |
| 1592 | string l ogProperti esFilespec = Path.Co mbine(conf ig.ConfigD ir, "log4j .propertie s"); | |
| 1593 | sb.Appen dFormat(" -Dlog4j.co nfiguratio n=file:/{0 } -cp ./*; {1} {2} ", logProper tiesFilesp ec.Replace (@"\", "/" ), | |
| 1594 | conf igUtility. Jar, confi gUtility.P ackage); | |
| 1595 | ||
| 1596 | switch ( configUtil ity.Config UtilityTyp e) | |
| 1597 | { | |
| 1598 | case ViXConfig urationUti lityType.V iX: | |
| 1599 | sb.AppendF ormat("\"L ocalSiteNu mber={0}\" \"SmtpSer verUri={1} \" \"VixSo ftwareVers ion={2}\"" , | |
| 1600 | config .SiteNumbe r, Busines sFacade.Ge tSmtpServe rUri(), co nfig.Produ ctVersionP rop); | |
| 1601 | break; | |
| 1602 | case ViXConfig urationUti lityType.C ache: | |
| 1603 | BuildCache Configurat ionParamet ers(config , sb); // sb gets po pulated | |
| 1604 | break; | |
| 1605 | case ViXConfig urationUti lityType.S iteResolut ionProvide r: | |
| 1606 | //} | |
| 1607 | if (config .VixRole = = VixRoleT ype.Enterp riseGatewa y) | |
| 1608 | { | |
| 1609 | string commandFi lespec = P ath.Combin e(config.C onfigDir, "configure SiteResolu tionProvid er.command s"); | |
| 1610 | sb.App endFormat( "-f \"file :/{0}\" \" {1}\"", co mmandFiles pec.Replac e(@"\", "/ "), config .SiteServi ceUri); | |
| 1611 | } | |
| 1612 | else if (c onfig.VixR ole == Vix RoleType.S iteVix) | |
| 1613 | { | |
| 1614 | if (co nfig.HasLo calDodConf iguration( )) // worm hole | |
| 1615 | { | |
| 1616 | st ring comma ndFilespec = Path.Co mbine(conf ig.ConfigD ir, "confi gureSiteRe solutionPr ovider3.co mmands"); | |
| 1617 | st ring pacsi ExchangeMe tadataUrl = "exchang e://" + co nfig.Local DodServer + ":" + co nfig.Local DodServerP ort + "/Va ImagingExc hange/Imag eMetadataS ervice.asm x"; | |
| 1618 | st ring pacsi ExchangeIm ageUrl = " exchange:/ /" + confi g.LocalDod Server + " :" + confi g.LocalDod ServerPort + "/VaIma gingExchan ge/Retriev eImage.ash x"; | |
| 1619 | sb .AppendFor mat("-f \" file:/{0}\ " \"{1}\" \"{2}\" \" {3}\" \"{4 }\" \"{5}\ "", comman dFilespec. Replace(@" \", "/"), | |
| 1620 | config.S iteService Uri, confi g.SiteNumb er, config .LocalDodS iteNumber, pacsiExch angeMetada taUrl, pac siExchange ImageUrl); | |
| 1621 | } | |
| 1622 | else | |
| 1623 | { | |
| 1624 | // param 3 - exchange | |
| 1625 | st ring comma ndFilespec = Path.Co mbine(conf ig.ConfigD ir, "confi gureSiteRe solutionPr ovider.com mands"); | |
| 1626 | sb .AppendFor mat("-f \" file:/{0}\ " \"{1}\" \"{2}\"", commandFil espec.Repl ace(@"\", "/"), conf ig.SiteSer viceUri, c onfig.Site Number); | |
| 1627 | } | |
| 1628 | } | |
| 1629 | else if (c onfig.VixR ole == Vix RoleType.D icomGatewa y) | |
| 1630 | { | |
| 1631 | string commandFi lespec = P ath.Combin e(config.C onfigDir, "configure SiteResolu tionProvid er.command s"); | |
| 1632 | sb.App endFormat( "-f \"file :/{0}\" \" {1}\" \"{2 }\"", comm andFilespe c.Replace( @"\", "/") , config.S iteService Uri, confi g.SiteNumb er); | |
| 1633 | } | |
| 1634 | else if (c onfig.VixR ole == Vix RoleType.M iniVix) | |
| 1635 | { | |
| 1636 | // par am 3 - exc hange | |
| 1637 | string commandFi lespec = P ath.Combin e(config.C onfigDir, "configure SiteResolu tionProvid er2.comman ds"); | |
| 1638 | sb.App endFormat( "-f \"file :/{0}\" \" {1}\" \"{2 }\"", comm andFilespe c.Replace( @"\", "/") , config.S iteService Uri, confi g.SiteNumb er); | |
| 1639 | } | |
| 1640 | else // sh ould never happen | |
| 1641 | { | |
| 1642 | thro w new Exce ption(conf ig.VixRole .ToString( ) + " Sit e Resoluti on Configu ration not currently supported "); | |
| 1643 | } | |
| 1644 | break; | |
| 1645 | case ViXConfig urationUti lityType.C linicalDis playProvid er: | |
| 1646 | break; // no paramet ers yet | |
| 1647 | case ViXConfig urationUti lityType.E xchangeDat aSourcePro vider: | |
| 1648 | sb.AppendF ormat("\"- biaUsernam e\" \"{0}\ " \"-biaPa ssword\" \ "{1}\"", c onfig.BiaU sername, c onfig.BiaP assword); | |
| 1649 | if (config .VixRole = = VixRoleT ype.Enterp riseGatewa y) | |
| 1650 | { | |
| 1651 | sb.App end(Blackl istModalit yArguments (config)); | |
| 1652 | } | |
| 1653 | else if (c onfig.HasL ocalDodCon figuration ()) | |
| 1654 | { | |
| 1655 | sb.App endFormat( " \"-alien Site\" \"{ 0}\" \"{1} \" \"{2}\" \"{3}\" \ "{4}\"", | |
| 1656 | co nfig.Local DodSiteNum ber, confi g.LocalDod Server, co nfig.Local DodServerP ort, confi g.LocalDod Username, config.Loc alDodPassw ord); | |
| 1657 | } | |
| 1658 | break; | |
| 1659 | case ViXConfig urationUti lityType.E xchangePro cedureFilt erTermsCon figuration : | |
| 1660 | break; // no paramet ers yet | |
| 1661 | case ViXConfig urationUti lityType.I mageConver sion: | |
| 1662 | break; // no paramet ers yet | |
| 1663 | case ViXConfig urationUti lityType.V istaDataSo urceProvid er: | |
| 1664 | break; // no paramet ers yet | |
| 1665 | case ViXConfig urationUti lityType.V istaOnlyDa taSourcePr ovider: | |
| 1666 | // used to be CVIX o nly - not any more a s of P119 - DKB | |
| 1667 | if (config .Station20 0UserName == null) / / VIX or M ini-VIX | |
| 1668 | { | |
| 1669 | sb.App end("false "); // pro duction - use CPRS T reating Fa cility Lis t RPC | |
| 1670 | } | |
| 1671 | else if (c onfig.Stat ion200User Name.ToLow er() == "t esting_1" || config. Station200 UserName.T oLower() = = "boating 1") // CVI X | |
| 1672 | { | |
| 1673 | sb.App end("true" ); // inte rnal test environmen t - use Vi stA Imagin g Treating Facility List RPC | |
| 1674 | } | |
| 1675 | else | |
| 1676 | { | |
| 1677 | sb.App end("false "); // pro duction - use CPRS T reating Fa cility Lis t RPC - CV IX | |
| 1678 | } | |
| 1679 | break; | |
| 1680 | case ViXConfig urationUti lityType.T ransaction LoggerData SourceProv ider: | |
| 1681 | break; // no paramet ers yet - will need for cluste red CVIX | |
| 1682 | case ViXConfig urationUti lityType.V ixLogConfi guration: | |
| 1683 | break; // no paramet ers yet | |
| 1684 | case ViXConfig urationUti lityType.B yteBufferP oolConfigu ration: | |
| 1685 | if (config .VixRole = = VixRoleT ype.MiniVi x) | |
| 1686 | { | |
| 1687 | sb.App end("-m"); | |
| 1688 | } | |
| 1689 | break; | |
| 1690 | case ViXConfig urationUti lityType.V istaRadCom mandConfig uration: | |
| 1691 | if (config .VixRole = = VixRoleT ype.MiniVi x) | |
| 1692 | { | |
| 1693 | sb.App end("-m"); | |
| 1694 | } | |
| 1695 | break; | |
| 1696 | case ViXConfig urationUti lityType.I dsProxyCon figuration : | |
| 1697 | break; // no paramet ers yet | |
| 1698 | case ViXConfig urationUti lityType.F ederationD ataSourceP rovider: | |
| 1699 | String s = Path.Comb ine(VixFac ade.GetVix Certificat eStoreDir( ), FEDERAT ION_KEYSTO RE_FILENAM E); | |
| 1700 | String fed erationKey storePath = s.Replac e(@"\", "/ "); | |
| 1701 | s = Path.C ombine(Vix Facade.Get VixCertifi cateStoreD ir(), FEDE RATION_TRU STSTORE_FI LENAME); | |
| 1702 | String fed erationTru ststorePat h = s.Repl ace(@"\", "/"); | |
| 1703 | sb.AppendF ormat("\"- truststore Password\" \"{0}\" \ "-keystore Password\" \"{1}\" \ "-keystore Url\" \"fi le:///{2}\ " \"-trust storeUrl\" \"file:// /{3}\" -fe derationSs lProtocol \"https\"" , | |
| 1704 | config .Federatio nTruststor ePassword, config.Fe derationKe ystorePass word, fede rationKeys torePath, federation Truststore Path); | |
| 1705 | break; | |
| 1706 | case ViXConfig urationUti lityType.V ixHealthCo nfiguratio n: | |
| 1707 | if (config .VixRole = = VixRoleT ype.Enterp riseGatewa y) | |
| 1708 | { | |
| 1709 | sb.App endFormat( "\"{0}\" t rue true t rue false" , config.S iteNumber) ; | |
| 1710 | } | |
| 1711 | else if (c onfig.VixR ole == Vix RoleType.S iteVix || config.Vix Role == Vi xRoleType. MiniVix) | |
| 1712 | { | |
| 1713 | sb.App endFormat( "\"{0}\" t rue true f alse false ", config. SiteNumber ); | |
| 1714 | } | |
| 1715 | else if (c onfig.VixR ole == Vix RoleType.D icomGatewa y) | |
| 1716 | { | |
| 1717 | sb.App endFormat( "\"{0}\" t rue true f alse true" , config.S iteNumber) ; | |
| 1718 | } | |
| 1719 | else // sh ould never happen | |
| 1720 | { | |
| 1721 | throw new Except ion(config .VixRole.T oString() + " Healt h Configur ation not currently supported" ); | |
| 1722 | } | |
| 1723 | break; | |
| 1724 | case ViXConfig urationUti lityType.N otificatio nConfigura tion: | |
| 1725 | if (config .VixRole = = VixRoleT ype.DicomG ateway) | |
| 1726 | { | |
| 1727 | sb.App endFormat( "\"{0}\" f alse", con fig.SiteNu mber); // DICOM VIXe n do not e nable noti fications for now | |
| 1728 | } | |
| 1729 | else | |
| 1730 | { | |
| 1731 | sb.App endFormat( "\"{0}\" t rue", conf ig.SiteNum ber); | |
| 1732 | } | |
| 1733 | break; | |
| 1734 | case ViXConfig urationUti lityType.N otificatio nEmailConf iguration: | |
| 1735 | if (config .Notificat ionEmailAd dresses != null) | |
| 1736 | { | |
| 1737 | sb.App endFormat( " \"{0}\"" , config.N otificatio nEmailAddr esses); | |
| 1738 | } | |
| 1739 | break; | |
| 1740 | case ViXConfig urationUti lityType.X CAInitiati ngGatewayD ataSourceP rovider: | |
| 1741 | //"file:/C :/VixCertS tore/xca.k eystore" " R00tbeer" "file:/C:/ VixCertSto re/xca.tru ststore" " R00tbeer" "7443" "nu ll" "null" "null" "x cas" "null " "null" " xcas" "nca tusername" "ncatpass word" | |
| 1742 | ||
| 1743 | s = Path.C ombine(Vix Facade.Get VixConfigu rationDire ctory(), " configureC VIX_XCA.co mmands"); | |
| 1744 | String xca Commands = s.Replace (@"\", "/" ); | |
| 1745 | sb.AppendF ormat("-f \"file:/{0 }\" ", xca Commands); | |
| 1746 | ||
| 1747 | s = Path.C ombine(Vix Facade.Get VixCertifi cateStoreD ir(), FEDE RATION_KEY STORE_FILE NAME); // XCA_KEYSTO RE_FILENAM E); | |
| 1748 | String xca KeystorePa th = s.Rep lace(@"\", "/"); | |
| 1749 | s = Path.C ombine(Vix Facade.Get VixCertifi cateStoreD ir(), FEDE RATION_TRU STSTORE_FI LENAME);// XCA_TRUST STORE_FILE NAME); | |
| 1750 | String xca Truststore Path = s.R eplace(@"\ ", "/"); | |
| 1751 | sb.AppendF ormat("\"f ile:/{0}\" \"{1}\" \ "file:/{2} \" \"{3}\" \"{4}\" \ "{5}\" \"{ 6}\" \"{7} \" \"{8}\" \"{9}\" \ "{10}\" \" {11}\" \"{ 12}\" \"{1 3}\"", | |
| 1752 | xcaKey storePath, config.Fe derationKe ystorePass word, xcaT ruststoreP ath, confi g.Federati onTruststo rePassword , config.X caConnecto rPort.ToSt ring(), | |
| 1753 | config .BhieProto col, (conf ig.BhieUse rName == n ull ? "nul l" : confi g.BhieUser Name), (co nfig.BhieP assword == null ? "n ull" : con fig.BhiePa ssword), | |
| 1754 | config .HaimsProt ocol, (con fig.HaimsU serName == null ? "n ull" : con fig.HaimsU serName), (config.Ha imsPasswor d == null ? "null" : config.Ha imsPasswor d), | |
| 1755 | config .NcatProto col, (conf ig.NcatUse rName == n ull ? "nul l" : confi g.NcatUser Name), (co nfig.NcatP assword == null ? "n ull" : con fig.NcatPa ssword)); | |
| 1756 | break; | |
| 1757 | case ViXConfig urationUti lityType.D icomGatewa yConfigura tion: | |
| 1758 | string dco rrectDir = Path.Comb ine(config .LocalCach eDir, "DCo rrect").Re place(@"\" , "/"); | |
| 1759 | string dde bugDir = P ath.Combin e(config.L ocalCacheD ir, "DDebu g").Replac e(@"\", "/ "); | |
| 1760 | sb.AppendF ormat("\"{ 0}\" \"{1} \" \"{2}\" \"{3}\" \ "{4}\" \"D LE={5}\" \ "AE={6}\" \"IPE={7}\ "", config .SiteNumbe r, config. DicomImage GatewaySer ver, | |
| 1761 | config .DicomImag eGatewayPo rt, config .VdigAcces sor, confi g.VdigVeri fier, conf ig.DicomLi stenerEnab led.ToStri ng().ToLow er(), conf ig.Archive Enabled.To String().T oLower(), | |
| 1762 | config .IconGener ationEnabl ed.ToStrin g().ToLowe r()); | |
| 1763 | break; | |
| 1764 | case ViXConfig urationUti lityType.S torageServ erConfigur ation: | |
| 1765 | break; // no parame ters yet | |
| 1766 | case ViXConfig urationUti lityType.P eriodicCom mandConfig uration: / / HDIG onl y for now so no need to check VIX role | |
| 1767 | sb.AppendF ormat("\"{ 0}\" \"{1} \" \"{2}\" \"{3}\" \ "{4}\" \"{ 5}\" \"{6} \" \"{7}\" \"{8}\" \ "{9}\"", " ProcessAsy ncStorageQ ueueSendEm ailCommand ", "60000" , "Process DicomCorre ctCommand" , "60000", | |
| 1768 | "Proce ssIconImag eCreationQ ueueComman d", "60000 ", "Proces sEmailQueu eCommand", "30000"," ProcessPor tListening CheckComma nd", "6000 0"); | |
| 1769 | // this wa s previous ly a P79 o nly featur e... | |
| 1770 | sb.AppendF ormat(" \" {0}\" \"{1 }\"", "Pro cessStoreC ommitWorkI temCommand ", "60000" ); | |
| 1771 | break; | |
| 1772 | case ViXConfig urationUti lityType.R oiConfigur ation: // P130, P138 VIX | |
| 1773 | sb.AppendF ormat("\"{ 0}\" \"{1} \"", confi g.RoiAcces sor, confi g.RoiVerif ier); | |
| 1774 | break; | |
| 1775 | case ViXConfig urationUti lityType.I mageGearDa taSourcePr ovider: // P130, P13 8 VIX | |
| 1776 | VixDepende ncyFile[] roiAnnotat e = Filter FilesByTyp e(manifest .GetDepend encyFiles( config), c onfig, Vix Dependency Type.RoiAn notationEx e); | |
| 1777 | if (roiAnn otate.Leng th != 1) t hrow new E xception(" Cannot con figure Ima geGearData SourceProv ider - mis sing ROI a nnotation exe"); | |
| 1778 | VixDepende ncyFile[] roiPdf = F ilterFiles ByType(man ifest.GetD ependencyF iles(confi g), config , VixDepen dencyType. RoiPdfExe) ; | |
| 1779 | if (roiAnn otate.Leng th != 1) t hrow new E xception(" Cannot con figure Ima geGearData SourceProv ider - mis sing ROI P DF exe"); | |
| 1780 | string roi Disclosure Dirspec = Path.Combi ne(config. ConfigDir, ROI_DISCL OSURE_DIRE CTORY); | |
| 1781 | if (!Direc tory.Exist s(roiDiscl osureDirsp ec)) | |
| 1782 | { | |
| 1783 | Direct ory.Create Directory( roiDisclos ureDirspec ); | |
| 1784 | } | |
| 1785 | sb.AppendF ormat("\"{ 0}\" \"{1} \" \"{2}\" \"{3}\"", roiDisclo sureDirspe c, config. SiteName, roiPdf[0]. GetAppFile spec(), ro iAnnotate[ 0].GetAppF ilespec()) ; | |
| 1786 | break; | |
| 1787 | case ViXConfig urationUti lityType.V istaConnec tionConfig uration: | |
| 1788 | if (config .VixRole = = VixRoleT ype.Enterp riseGatewa y) | |
| 1789 | { | |
| 1790 | if (Is Developmen tCvix(conf ig) == fal se) | |
| 1791 | { | |
| 1792 | sb .Append("- new true") ; // use n ew style b roker | |
| 1793 | } | |
| 1794 | } | |
| 1795 | break; | |
| 1796 | case ViXConfig urationUti lityType.C ommandConf iguration: | |
| 1797 | if (config .VixRole = = VixRoleT ype.Enterp riseGatewa y) | |
| 1798 | { | |
| 1799 | if (co nfig.Stati on200UserN ame.ToLowe r() == "te sting_1" | | config.S tation200U serName.To Lower() == "boating1 ") | |
| 1800 | { | |
| 1801 | sb .Append("t rue false false"); / / dont not use CPRS context | |
| 1802 | } | |
| 1803 | else | |
| 1804 | { | |
| 1805 | sb .Append("t rue true f alse"); | |
| 1806 | } | |
| 1807 | } | |
| 1808 | else // VI X and Mini -VIX, HDIG does not have this configured | |
| 1809 | { | |
| 1810 | sb.App end("true false true "); | |
| 1811 | } | |
| 1812 | break; | |
| 1813 | case ViXConfig urationUti lityType.I magingFaca deConfigur ation: | |
| 1814 | if (config .VixRole = = VixRoleT ype.Enterp riseGatewa y) | |
| 1815 | { | |
| 1816 | sb.App end("false true"); | |
| 1817 | } | |
| 1818 | else if (c onfig.VixR ole == Vix RoleType.S iteVix || config.Vix Role == Vi xRoleType. MiniVix) | |
| 1819 | { | |
| 1820 | sb.App end("true false"); | |
| 1821 | } | |
| 1822 | else // sh ould never happen | |
| 1823 | { | |
| 1824 | throw new Except ion(config .VixRole.T oString() + " Imagi ng Facade Configurat ion not cu rrently su pported"); | |
| 1825 | } | |
| 1826 | break; | |
| 1827 | } | |
| 1828 | ||
| 1829 | String p arameters = sb.ToStr ing(); | |
| 1830 | //Logger ().Info("j ava " + pa rameters); | |
| 1831 | Info("Co nfiguring " + config Utility.Co nfigUtilit yType.ToSt ring()); | |
| 1832 | RunJavaU tility(par ameters, c onfig); | |
| 1833 | Info("Do ne."); | |
| 1834 | } | |
| 1835 | ||
| 1836 | // / <summary > | |
| 1837 | // / | |
| 1838 | // / </summar y> | |
| 1839 | // / <param n ame="confi g"></param > | |
| 1840 | // / <returns ></returns > | |
| 1841 | pr ivate stat ic string BlacklistM odalityArg uments(IVi xConfigura tionParame ters confi g) | |
| 1842 | { | |
| 1843 | string b lacklistFi lespec = P ath.Combin e(config.C onfigDir, MODALITY_B LACKLIST_F ILENAME); | |
| 1844 | StringBu ilder sb = new Strin gBuilder() ; | |
| 1845 | ||
| 1846 | if (File .Exists(bl acklistFil espec)) | |
| 1847 | { | |
| 1848 | stri ng line; | |
| 1849 | ||
| 1850 | usin g (StreamR eader sr = new Strea mReader(bl acklistFil espec)) | |
| 1851 | { | |
| 1852 | while ((li ne = sr.Re adLine()) != null) | |
| 1853 | { | |
| 1854 | if (li ne.Length == 0) | |
| 1855 | { | |
| 1856 | co ntinue; | |
| 1857 | } | |
| 1858 | sb.App end(" -emp tyModality " + "\"" + line + " \""); | |
| 1859 | } | |
| 1860 | sr.Close() ; | |
| 1861 | } | |
| 1862 | } | |
| 1863 | ||
| 1864 | return s b.ToString (); | |
| 1865 | } | |
| 1866 | ||
| 1867 | // / <summary > | |
| 1868 | // / Populate the passe d StringBu ilder with the param eters need ed to init ialize the VIX cache | |
| 1869 | // / </summar y> | |
| 1870 | // / <param n ame="confi g"></param > | |
| 1871 | // / <param n ame="sb">< /param> | |
| 1872 | pr ivate stat ic void Bu ildCacheCo nfiguratio nParameter s(IVixConf igurationP arameters config, St ringBuilde r sb) | |
| 1873 | { | |
| 1874 | string l ocalCacheD ir = confi g.LocalCac heDir.Repl ace(@"\", "/"); // t ranslate f ile system delimiter so Java d oesnt barf | |
| 1875 | switch ( config.Vix CacheOptio n) | |
| 1876 | { | |
| 1877 | case VixCacheT ype.Exchan geTimeEvic tionLocalF ilesystem: | |
| 1878 | sb.AppendF ormat("cre ate \"<Ima gingExchan geCache>\" \"<file:/ /{0}>\" \" <VixProtot ype>\" ini tialize en able store exit", | |
| 1879 | localC acheDir); | |
| 1880 | break; | |
| 1881 | case VixCacheT ype.Exchan geTimeStor ageEvictio nLocalFile system: | |
| 1882 | sb.AppendF ormat("cre ate \"<Ima gingExchan geCache>\" \"<file:/ /{0}>\" \" <LimitedSp aceVixProt otype>\" i nitialize enable ", | |
| 1883 | localC acheDir); | |
| 1884 | // image s torage evi ction modi fication b ased on ca che size | |
| 1885 | // default combined metadata r egion size is 1GB wh ich should be all we need | |
| 1886 | long image RegionSize = (config .VixCacheS ize - 1) * ONE_GIGBY TE; | |
| 1887 | Debug.Asse rt(imageRe gionSize > 0); | |
| 1888 | long image RegionFree SpaceThres hold = (lo ng)(imageR egionSize * 0.05); / / start ev icting at 95% full | |
| 1889 | long image RegionTarg etFreeSpac eThreshold = (long)( imageRegio nSize * 0. 1); // sto p evicting at 90% fu ll | |
| 1890 | sb.AppendF ormat("mod ify-evicti on \"<imag e-storage- threshold> \" \"<maxU sedSpaceTh reshold>\" \"<{0}>\" ", | |
| 1891 | imageR egionSize) ; // maxUs edSpaceThr eshold is MAX cache size (may be exceede d) | |
| 1892 | sb.AppendF ormat("mod ify-evicti on \"<imag e-storage- threshold> \" \"<minF reeSpaceTh reshold>\" \"<{0}>\" ", | |
| 1893 | imageR egionFreeS paceThresh old); // M AX - minFr eeSpaceThr eshold is where evic tion start s to occur | |
| 1894 | sb.AppendF ormat("mod ify-evicti on \"<imag e-storage- threshold> \" \"<targ etFreeSpac eThreshold >\" \"<{0} >\" ", | |
| 1895 | imageR egionTarge tFreeSpace Threshold) ; // MAX - targetFre eSpaceThre shold is w here evict ion stops | |
| 1896 | // save an d exit | |
| 1897 | sb.Append( "store exi t"); | |
| 1898 | break; | |
| 1899 | defa ult: | |
| 1900 | string mes sage = "Bu ildCacheCo nfiguratio nParameter s: unsuppo rted cache option " + config.V ixCacheOpt ion.ToStri ng(); | |
| 1901 | throw new Exception( message); | |
| 1902 | } | |
| 1903 | } | |
| 1904 | ||
| 1905 | // / <summary > | |
| 1906 | // / Set acce ss control on all di rectories needed by the Apache Tomcat se rvice acco unt | |
| 1907 | // / </summar y> | |
| 1908 | // / <param n ame="confi g"></param > | |
| 1909 | pr ivate stat ic void Ap plyAccessC ontrol(IVi xConfigura tionParame ters confi g) | |
| 1910 | { | |
| 1911 | String s ystemDrive = Environ ment.GetEn vironmentV ariable("S ystemDrive ", Environ mentVariab leTarget.P rocess).To Upper() + @"\"; | |
| 1912 | String j avaPath = JavaFacade .GetActive JavaPath(J avaFacade. IsActiveJr eInstalled ()); | |
| 1913 | String t omcatPath = TomcatFa cade.Tomca tInstallat ionFolder; | |
| 1914 | String l aurelBridg ePath = La urelBridge Facade.Get ActiveDcfR ootFromMan ifest(); | |
| 1915 | String s erviceAcco untUsernam e = Tomcat Facade.Ser viceAccoun tUsername; | |
| 1916 | ||
| 1917 | Info("Se tting file system ac cess rules ."); | |
| 1918 | try | |
| 1919 | { | |
| 1920 | Info ("Applying access co ntrol for the " + se rviceAccou ntUsername + " accou nt to " + systemDriv e); | |
| 1921 | Acce ssContolUt ilities.Se tRootDirec toryAccess Control(se rviceAccou ntUsername , systemDr ive); | |
| 1922 | } | |
| 1923 | catch (E xception e x) | |
| 1924 | { | |
| 1925 | Info ("Non fata l error de nying acce ss to " + serviceAcc ountUserna me + " acc ount to " + systemDr ive); | |
| 1926 | Logg er().Warn( "Non fatal error den ying acces s to " + s erviceAcco untUsernam e + " acco unt to " + systemDri ve); | |
| 1927 | Logg er().Warn( ex.Message ); | |
| 1928 | } | |
| 1929 | Info("Ap plying acc ess contro l for the " + servic eAccountUs ername + " account t o " + java Path); | |
| 1930 | AccessCo ntolUtilit ies.SetJav aDirectory AccessCont rol(servic eAccountUs ername, ja vaPath); | |
| 1931 | Info("Ap plying acc ess contro l for the " + servic eAccountUs ername + " account t o " + tomc atPath); | |
| 1932 | AccessCo ntolUtilit ies.SetTom catAccessC ontrol(ser viceAccoun tUsername, tomcatPat h); | |
| 1933 | if (Laur elBridgeFa cade.IsLau relBridgeR equired(co nfig)) | |
| 1934 | { | |
| 1935 | Info ("Applying access co ntrol for the " + se rviceAccou ntUsername + " accou nt to " + laurelBrid gePath); | |
| 1936 | Acce ssContolUt ilities.Se tDcfDirect oryAccessC ontrol(ser viceAccoun tUsername, laurelBri dgePath); | |
| 1937 | } | |
| 1938 | Info("Ap plying acc ess contro l for the " + servic eAccountUs ername + " account t o " + conf ig.ConfigD ir); | |
| 1939 | AccessCo ntolUtilit ies.SetFul lDirectory AccessCont rol(servic eAccountUs ername, co nfig.Confi gDir); | |
| 1940 | ||
| 1941 | Info("Ap plying acc ess contro l for the " + servic eAccountUs ername + " account t o " + VixF acade.GetV ixCertific ateStoreDi r()); | |
| 1942 | AccessCo ntolUtilit ies.SetFul lDirectory AccessCont rol(servic eAccountUs ername, Vi xFacade.Ge tVixCertif icateStore Dir()); | |
| 1943 | ||
| 1944 | // if th e cache is in a loca l dir, the n apply ac cess contr ol | |
| 1945 | if (conf ig.LocalCa cheDir != null) | |
| 1946 | { | |
| 1947 | Info ("Applying access co ntrol for the " + se rviceAccou ntUsername + " accou nt to " + config.Loc alCacheDir ); | |
| 1948 | Acce ssContolUt ilities.Se tFullDirec toryAccess Control(se rviceAccou ntUsername , config.L ocalCacheD ir); | |
| 1949 | } | |
| 1950 | ||
| 1951 | if (conf ig.VixRole == VixRol eType.Dico mGateway) | |
| 1952 | { | |
| 1953 | stri ng dicomDi r = GetFul lyQuaified HdigDicomD irectory() ; | |
| 1954 | if ( dicomDir ! = null) | |
| 1955 | { | |
| 1956 | Info("Appl ying acces s control for the " + serviceA ccountUser name + " a ccount to " + dicomD ir); | |
| 1957 | AccessCont olUtilitie s.SetFullD irectoryAc cessContro l(serviceA ccountUser name, dico mDir); | |
| 1958 | } | |
| 1959 | } | |
| 1960 | } | |
| 1961 | ||
| 1962 | // / <summary > | |
| 1963 | // / | |
| 1964 | // / </summar y> | |
| 1965 | // / <param n ame="confi g"></param > | |
| 1966 | pr ivate stat ic void Cr eateEnviro nmentVaria bles(IVixC onfigurati onParamete rs config) | |
| 1967 | { | |
| 1968 | Info("Se tting Wind ows enviro nment vari ables."); | |
| 1969 | // set t he vixconf ig environ ment varia ble to the local con figuration dir | |
| 1970 | String v ixConfigDi r = config .ConfigDir .Replace(@ "\", "/"); // transl ate file s ystem deli miter so J ava doesnt barf | |
| 1971 | Info("Se tting Wind ows enviro nment vari able vixco nfig=" + v ixConfigDi r); | |
| 1972 | Environm ent.SetEnv ironmentVa riable("vi xconfig", vixConfigD ir, Enviro nmentVaria bleTarget. Machine); | |
| 1973 | ||
| 1974 | if (conf ig.LocalCa cheDir != null) | |
| 1975 | { | |
| 1976 | Stri ng vixCach eDir = con fig.LocalC acheDir.Re place(@"\" , "/"); // translate file syst em delimit er so Java doesnt ba rf | |
| 1977 | // s et the vix cache envi ronment va riable to the local cache dir | |
| 1978 | Info ("Setting Windows en vironment variable v ixcache=" + vixCache Dir); | |
| 1979 | Envi ronment.Se tEnvironme ntVariable ("vixcache ", vixCach eDir, Envi ronmentVar iableTarge t.Machine) ; | |
| 1980 | } | |
| 1981 | else | |
| 1982 | { | |
| 1983 | // s et the vix cache envi ronment va riable to the cache network sh are | |
| 1984 | Info ("Setting Windows en vironment variable v ixcache=" + config.N etworkFile Share); | |
| 1985 | Envi ronment.Se tEnvironme ntVariable ("vixcache ", config. NetworkFil eShare, En vironmentV ariableTar get.Machin e); | |
| 1986 | } | |
| 1987 | ||
| 1988 | Info("Se tting Wind ows enviro nment vari able CATAL INA_HOME=" + TomcatF acade.Tomc atInstalla tionFolder ); | |
| 1989 | Environm ent.SetEnv ironmentVa riable("CA TALINA_HOM E", Tomcat Facade.Tom catInstall ationFolde r, Environ mentVariab leTarget.M achine); | |
| 1990 | } | |
| 1991 | ||
| 1992 | pr ivate stat ic bool Is LocalCache Configured (IVixConfi gurationPa rameters c onfig) | |
| 1993 | { | |
| 1994 | bool isC onfigured = true; | |
| 1995 | Debug.As sert(confi g.LocalCac heDir != n ull); | |
| 1996 | Debug.As sert(confi g.ConfigDi r != null) ; | |
| 1997 | ||
| 1998 | if (File .Exists(Vi xFacade.Vi xConfigFil espec) == false) | |
| 1999 | { | |
| 2000 | isCo nfigured = false; | |
| 2001 | } | |
| 2002 | ||
| 2003 | string c acheRegion Dirspec = Path.Combi ne(config. LocalCache Dir, EXCHA NGE_CACHE_ DOD_IMAGE_ REGION); | |
| 2004 | if (Dire ctory.Exis ts(cacheRe gionDirspe c) == fals e) | |
| 2005 | { | |
| 2006 | isCo nfigured = false; | |
| 2007 | } | |
| 2008 | ||
| 2009 | return i sConfigure d; | |
| 2010 | } | |
| 2011 | ||
| 2012 | pr ivate stat ic readonl y String D OD_METADAT A_REGION = @"dod-met adata-regi on"; | |
| 2013 | pr ivate stat ic readonl y String D OD_IMAGE_R EGION = @" dod-image- region"; | |
| 2014 | pr ivate stat ic readonl y String V A_METADATA _REGION = @"va-metad ata-region "; | |
| 2015 | pr ivate stat ic readonl y String V A_IMAGE_RE GION = @"v a-image-re gion"; | |
| 2016 | ||
| 2017 | pr ivate stat ic void De leteAllLoc alCacheReg ions(IVixC onfigurati onParamete rs config) | |
| 2018 | { | |
| 2019 | if (IsLo calCacheCo nfigured(c onfig)) | |
| 2020 | { | |
| 2021 | Logg er().Info( Info("Dele ting files from the local VIX cache.")); | |
| 2022 | Info ("This may take seve ral minute s - please be patien t."); | |
| 2023 | stri ng baseCac heDir = co nfig.Local CacheDir.R eplace("/" , @"\"); | |
| 2024 | Dele teCacheReg ion(baseCa cheDir, DO D_METADATA _REGION); | |
| 2025 | Dele teCacheReg ion(baseCa cheDir, DO D_IMAGE_RE GION); | |
| 2026 | Dele teCacheReg ion(baseCa cheDir, VA _METADATA_ REGION); | |
| 2027 | Dele teCacheReg ion(baseCa cheDir, VA _IMAGE_REG ION); | |
| 2028 | Info ("The VIX cache has been clear ed."); | |
| 2029 | } | |
| 2030 | } | |
| 2031 | ||
| 2032 | pr ivate stat ic void De leteCacheR egion(stri ng baseCac heDir, str ing region Dir) | |
| 2033 | { | |
| 2034 | string r egionPath = Path.Com bine(baseC acheDir, r egionDir); | |
| 2035 | string f ooDir = Pa th.Combine (baseCache Dir, "foo" ); | |
| 2036 | if (Dire ctory.Exis ts(regionP ath)) | |
| 2037 | { | |
| 2038 | Logg er().Info( Info("Dele ting conte nts of " + regionPat h)); | |
| 2039 | stri ng[] dirs = Director y.GetDirec tories(reg ionPath); | |
| 2040 | fore ach (strin g subDir i n dirs) | |
| 2041 | { | |
| 2042 | try | |
| 2043 | { | |
| 2044 | Direct ory.Move(s ubDir, foo Dir); | |
| 2045 | Direct ory.Delete (fooDir, t rue); | |
| 2046 | } | |
| 2047 | catch (Exc eption) { } | |
| 2048 | finally | |
| 2049 | { | |
| 2050 | if (Di rectory.Ex ists(subDi r)) | |
| 2051 | { | |
| 2052 | Lo gger().Err or("Could not delete directory " + subDi r); | |
| 2053 | } | |
| 2054 | } | |
| 2055 | } | |
| 2056 | } | |
| 2057 | } | |
| 2058 | ||
| 2059 | // / <summary > | |
| 2060 | // / Copy the sites fil e (usualy vhasites.x ml) to the VIX confi g director y and rena me to vhas ites.xml. | |
| 2061 | // / </summar y> | |
| 2062 | // / <param n ame="confi g"></param > | |
| 2063 | pr ivate stat ic void De ploySitesF ile(IVixCo nfiguratio nParameter s config) | |
| 2064 | { | |
| 2065 | string t argetFiles pec = Path .Combine(G etVixConfi gurationDi rectory(), "VhaSites .xml"); | |
| 2066 | Debug.As sert(File. Exists(con fig.SitesF ile)); | |
| 2067 | File.Cop y(config.S itesFile, targetFile spec, true ); // over write | |
| 2068 | } | |
| 2069 | ||
| 2070 | pr ivate stat ic void TC PTimeoutIn Registry() { | |
| 2071 | ||
| 2072 | Registry View regVi ew = Regis tryView.Re gistry64; | |
| 2073 | string k ey = @"SYS TEM\Curren tControlSe t\Services \Tcpip\Par ameters"; | |
| 2074 | using (R egistryKey regKey = RegistryKe y.OpenBase Key(Regist ryHive.Loc alMachine, regView)) | |
| 2075 | { | |
| 2076 | usin g (Registr yKey tcpKe y = regKey .OpenSubKe y(key, tru e)) | |
| 2077 | { | |
| 2078 | tcpKey.Set Value("Tcp TimedWaitD elay", 30, RegistryV alueKind.D Word); | |
| 2079 | } | |
| 2080 | } | |
| 2081 | } | |
| 2082 | ||
| 2083 | pr ivate stat ic void Ru nNetworkCo nfiguratio nCommand() { | |
| 2084 | int exit Code = 0; | |
| 2085 | using (P rocess ext ernalProce ss = new P rocess()) | |
| 2086 | { | |
| 2087 | exte rnalProces s.StartInf o.FileName = "NetSh" ; | |
| 2088 | exte rnalProces s.StartInf o.Argument s = "INT I PV4 SET Dy namicPort TCP Start= 1025 num=6 4511"; | |
| 2089 | //ex ternalProc ess.StartI nfo.Workin gDirectory ; | |
| 2090 | exte rnalProces s.StartInf o.UseShell Execute = false; | |
| 2091 | exte rnalProces s.StartInf o.CreateNo Window = t rue; | |
| 2092 | exte rnalProces s.Start(); | |
| 2093 | ||
| 2094 | try | |
| 2095 | { | |
| 2096 | do | |
| 2097 | { | |
| 2098 | DoEven ts(); | |
| 2099 | Thread .Sleep(500 ); | |
| 2100 | extern alProcess. Refresh(); | |
| 2101 | } while (! externalPr ocess.HasE xited); | |
| 2102 | exitCode = externalP rocess.Exi tCode; | |
| 2103 | } | |
| 2104 | fina lly | |
| 2105 | { | |
| 2106 | externalPr ocess.Clos e(); | |
| 2107 | } | |
| 2108 | } | |
| 2109 | ||
| 2110 | } | |
| 2111 | ||
| 2112 | #e ndregion | |
| 2113 | } | |
| 2114 | } | |
| 2115 | ||
| 2116 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.