Produced by Araxis Merge on 12/5/2017 12:06:49 PM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\SiteServiceDataSourceProvider\main\src\java\gov\va\med\siteservice | SiteResolver.java | Mon Dec 4 21:34:18 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\SiteServiceDataSourceProvider\main\src\java\gov\va\med\siteservice | SiteResolver.java | Mon Dec 4 22:05:38 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 1276 |
| Changed | 2 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /** | |
| 2 | * Package : MAG - Vi stA Imagin g | |
| 3 | * WARNING : Per VHA Directive 2004-038, this routi ne should not be mod ified. | |
| 4 | * Date Cr eated: Jan 15, 2008 | |
| 5 | * Site Na me: Washi ngton OI F ield Offic e, Silver Spring, MD | |
| 6 | * @author
|
|
| 7 | * @versio n 1.0 | |
| 8 | * | |
| 9 | * ------- ---------- ---------- ---------- ---------- ---------- ------- | |
| 10 | * Propert y of the U S Governme nt. | |
| 11 | * No perm ission to copy or re distribute this soft ware is gi ven. | |
| 12 | * Use of unreleased versions of this so ftware req uires the user | |
| 13 | * to exec ute a writ ten test a greement w ith the Vi stA Imagin g | |
| 14 | * Develop ment Offic e of the D epartment of Veteran s Affairs, | |
| 15 | * telepho ne (301) 7 34-0100. | |
| 16 | * | |
| 17 | * The Foo d and Drug Administr ation clas sifies thi s software as | |
| 18 | * a Class II medica l device. As such, it may not be change d | |
| 19 | * in any way. Modi fications to this so ftware may result in an | |
| 20 | * adulter ated medic al device under 21CF R820, the use of whi ch | |
| 21 | * is cons idered to be a viola tion of US Federal S tatutes. | |
| 22 | * ------- ---------- ---------- ---------- ---------- ---------- ------- | |
| 23 | */ | |
| 24 | package go v.va.med.s iteservice ; | |
| 25 | ||
| 26 | import gov .va.med.OI D; | |
| 27 | import gov .va.med.Ro utingToken ; | |
| 28 | import gov .va.med.Ro utingToken Impl; | |
| 29 | import gov .va.med.We llKnownOID ; | |
| 30 | import gov .va.med.ex ceptions.R outingToke nFormatExc eption; | |
| 31 | import gov .va.med.im aging.Imag ingMBean; | |
| 32 | import gov .va.med.im aging.arti factsource .ArtifactS ource; | |
| 33 | import gov .va.med.im aging.arti factsource .ResolvedA rtifactSou rce; | |
| 34 | import gov .va.med.im aging.core .interface s.exceptio ns.Configu rationErro r; | |
| 35 | import gov .va.med.im aging.core .interface s.exceptio ns.Connect ionExcepti on; | |
| 36 | import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception; | |
| 37 | import gov .va.med.im aging.core .interface s.exceptio ns.Protoco lConfigura tionError; | |
| 38 | import gov .va.med.im aging.data source.Abs tractLocal DataSource ; | |
| 39 | import gov .va.med.im aging.data source.Pro viderConfi guration; | |
| 40 | import gov .va.med.im aging.data source.Sit eResolutio nDataSourc eSpi; | |
| 41 | import gov .va.med.im aging.exch ange.busin ess.Region ; | |
| 42 | import gov .va.med.im aging.exch ange.busin ess.Resolv edSite; | |
| 43 | import gov .va.med.im aging.exch ange.busin ess.Resolv edSiteImpl ; | |
| 44 | import gov .va.med.im aging.exch ange.busin ess.Site; | |
| 45 | import jav a.io.IOExc eption; | |
| 46 | import jav a.lang.man agement.Ma nagementFa ctory; | |
| 47 | import jav a.lang.ref lect.Const ructor; | |
| 48 | import jav a.lang.ref lect.Invoc ationTarge tException ; | |
| 49 | import jav a.net.Malf ormedURLEx ception; | |
| 50 | import jav a.net.URL; | |
| 51 | import jav a.util.*; | |
| 52 | import jav ax.managem ent.MBeanS erver; | |
| 53 | import jav ax.managem ent.Object Name; | |
| 54 | import org .apache.lo gging.log4 j.LogManag er; | |
| 55 | import org .apache.lo gging.log4 j.Logger; | |
| 56 | ||
| 57 | /** | |
| 58 | * @author
|
|
| 59 | * | |
| 60 | * The Sit eResolutio nDataSourc e service implementa tion. | |
| 61 | * This cl ass is pre dominantly a wrapper around th e SiteServ ice | |
| 62 | * proxy w ith additi onal funct ionality t o build UR Ls based o n | |
| 63 | * the Sit e informat ion. | |
| 64 | * | |
| 65 | */ | |
| 66 | public cla ss SiteRes olver | |
| 67 | extends Ab stractLoca lDataSourc e | |
| 68 | implements SiteResol utionDataS ourceSpi | |
| 69 | { | |
| 70 | pr ivate stat ic Logger logger = L ogManager. getLogger( SiteResolv er.class); | |
| 71 | ||
| 72 | /* * | |
| 73 | * | |
| 74 | * @param si teServiceU rl | |
| 75 | * @return | |
| 76 | * @throws I llegalArgu mentExcept ion | |
| 77 | * @throws S ecurityExc eption | |
| 78 | * @throws I nstantiati onExceptio n | |
| 79 | * @throws I llegalAcce ssExceptio n | |
| 80 | * @throws I nvocationT argetExcep tion | |
| 81 | * @throws N oSuchMetho dException | |
| 82 | * / | |
| 83 | pu blic stati c SiteReso lver creat e(SiteReso lutionProv iderConfig uration co nfiguratio n) | |
| 84 | th rows Illeg alArgument Exception, SecurityE xception, Instantiat ionExcepti on, Illega lAccessExc eption, In vocationTa rgetExcept ion, NoSuc hMethodExc eption | |
| 85 | { | |
| 86 | retu rn new Sit eResolver( configurat ion); | |
| 87 | } | |
| 88 | ||
| 89 | /* * | |
| 90 | * From a Si te instanc e, create set of URL S to conta ct that si te | |
| 91 | * in the pr eferred or der of con tact. | |
| 92 | * | |
| 93 | * @param si te | |
| 94 | * @return | |
| 95 | * @throws P rotocolCon figuration Error | |
| 96 | * / | |
| 97 | pr ivate stat ic SourceU RLs buildS iteUrlSet( | |
| 98 | Site ProtocolPr eferenceFa ctory prot ocolPrefer enceFactor y, | |
| 99 | Map< String, Pr otocolServ erConfigur ation> pro tocolConfi guration, | |
| 100 | Site site) | |
| 101 | { | |
| 102 | asse rt protoco lPreferenc eFactory ! = null : " protocolPr eferenceFa ctory is n ull"; | |
| 103 | asse rt protoco lConfigura tion != nu ll : "prot ocolConfig uration is null"; | |
| 104 | asse rt site != null : "s ite is nul l"; | |
| 105 | ||
| 106 | List <URL> meta dataUrls = new Array List<URL>( ); | |
| 107 | List <URL> arti factUrls = new Array List<URL>( ); | |
| 108 | ||
| 109 | if(s ite == nul l) | |
| 110 | return new Sourc eURLs(meta dataUrls, artifactUr ls); | |
| 111 | ||
| 112 | // i f we get e rrors buil ding the U RLs then s ave them u p and, per haps, thro w an error at the en d | |
| 113 | Map< String, Ma lformedURL Exception> urlExcept ions = new HashMap<S tring, Mal formedURLE xception>( ); | |
| 114 | Stri ng[] proto colPrefere nces = pro tocolPrefe renceFacto ry.getPref erredProto cols(site. getSiteNum ber()); | |
| 115 | ||
| 116 | // f or each of the proto cols for t he site, i n preferre d order, a ttempt to create a U RL | |
| 117 | for( String pro tocol : pr otocolPref erences) | |
| 118 | { | |
| 119 | // Fin d the conf igured pro tocol from the site protocol t hen | |
| 120 | // get the site' s constitu ent server configura tion for t he protoco l | |
| 121 | Protoc olServerCo nfiguratio n psc = pr otocolConf iguration. get(protoc ol); | |
| 122 | if(psc != null) | |
| 123 | { | |
| 124 | // find the server and port available at the sit e for the specified protocol | |
| 125 | // this was previo usly a sim ple differ entiation between vi sta and an y | |
| 126 | // other protocol | |
| 127 | URL meta dataUrl = site.getAv ailableMet adataServe r(protocol ); | |
| 128 | URL arti factUrl = site.getAv ailableArt ifactServe r(protocol ); | |
| 129 | logger.d ebug("Site '" + site .getSiteNu mber() + " ', protoco l '" + pro tocol + "' => " + | |
| 130 | (artifactU rl == null ? "null" : artifact Url.toStri ng()) | |
| 131 | ); | |
| 132 | if(artif actUrl != null) | |
| 133 | { | |
| 134 | String art ifactServe r = artifa ctUrl.getH ost(); | |
| 135 | int artifa ctPort = a rtifactUrl .getPort() ; | |
| 136 | String met adataServe r = metada taUrl.getH ost(); | |
| 137 | int metada taPort = m etadataUrl .getPort() ; | |
| 138 | String art ifactFile = psc.getA bsoluteIma gePath(); | |
| 139 | String met adataFile = psc.getA bsoluteMet adataPath( ); | |
| 140 | ||
| 141 | try | |
| 142 | { | |
| 143 | me tadataUrls .add( new URL( proto col, metad ataServer, metadataP ort, metad ataFile ) ); | |
| 144 | ar tifactUrls .add( new URL( proto col, artif actServer, artifactP ort, artif actFile ) ); | |
| 145 | } | |
| 146 | catch (Mal formedURLE xception e ) | |
| 147 | { | |
| 148 | St ring msg = "An error occurred creating a URL for s ite '" + s ite.getSit eName() + | |
| 149 | "'. A URLStre amHandler for the pr otocol '" + protocol + | |
| 150 | "' m ay not be available. Please c heck that the requir ed stream handlers a re deploye d correctl y."; | |
| 151 | lo gger.error (msg); | |
| 152 | // create a new Malfor medURLExce ption with our messa ge | |
| 153 | ur lException s.put(prot ocol, new MalformedU RLExceptio n(msg)); | |
| 154 | } | |
| 155 | } | |
| 156 | } | |
| 157 | else | |
| 158 | { | |
| 159 | // the p rotocol is not confi gured, | |
| 160 | // eithe r the site is config ured incor rectly or the protoc ol | |
| 161 | // is no t installe d | |
| 162 | String m sg = | |
| 163 | "The proto col '" + p rotocol + | |
| 164 | "', specif ied by art ifact sour ce '" + si te.getIden tifier() + | |
| 165 | "' is not a configur ed protoco l in the s ite config uration."; | |
| 166 | ||
| 167 | logger.e rror(msg); | |
| 168 | urlExcep tions.put( protocol, new Malfo rmedURLExc eption(msg ) ); | |
| 169 | } | |
| 170 | } | |
| 171 | ||
| 172 | // i f any Malf ormedURLEx ceptions o ccurred th row an Err or | |
| 173 | if(u rlExceptio ns != null && urlExc eptions.si ze() > 0) | |
| 174 | throw new Protoc olConfigur ationError (urlExcept ions); | |
| 175 | ||
| 176 | retu rn new Sou rceURLs(me tadataUrls , artifact Urls); | |
| 177 | } | |
| 178 | ||
| 179 | // ========= ========== ========== ========== ========== ========== ========== ========== ======== | |
| 180 | // | |
| 181 | // ========= ========== ========== ========== ========== ========== ========== ========== ======== | |
| 182 | pr ivate Site Resolution ProviderCo nfiguratio n configur ation; | |
| 183 | pr ivate Site Service si teService; | |
| 184 | pr ivate Exte rnalArtifa ctSourceRe solver ext ernalArtif actSourceR esolver; | |
| 185 | ||
| 186 | // lists the protocols by prefer ence order | |
| 187 | pr ivate Site ProtocolPr eferenceFa ctory prot ocolPrefer enceFactor y; | |
| 188 | ||
| 189 | // maps the applicatio n to the m etadata an d image pa ths | |
| 190 | pr ivate Map< String, Pr otocolServ erConfigur ation> pro tocolConfi guration; | |
| 191 | ||
| 192 | pu blic SiteR esolver() | |
| 193 | { | |
| 194 | this ((SiteReso lutionProv iderConfig uration)nu ll); | |
| 195 | } | |
| 196 | ||
| 197 | /* * | |
| 198 | * @throws N oSuchMetho dException | |
| 199 | * @throws I nvocationT argetExcep tion | |
| 200 | * @throws I llegalAcce ssExceptio n | |
| 201 | * @throws I nstantiati onExceptio n | |
| 202 | * @throws S ecurityExc eption | |
| 203 | * @throws I llegalArgu mentExcept ion | |
| 204 | * | |
| 205 | * / | |
| 206 | pu blic SiteR esolver(Si teResoluti onProvider Configurat ion mement o) | |
| 207 | { | |
| 208 | supe r(); | |
| 209 | ||
| 210 | if(m emento != null) | |
| 211 | { | |
| 212 | logger .info("Usi ng provide d configur ation of t ype '" + m emento.get Class().ge tSimpleNam e() + "'." ); | |
| 213 | assert memento.g etExternal ArtifactSo urces() != null : "M emento ext ernal arti fact sourc e is null and must n ot be."; | |
| 214 | assert memento.g etProtocol Configurat ion() != n ull : "Mem ento proto col config uration is null and must not b e."; | |
| 215 | assert memento.g etSiteProt ocolPrefer enceFactor y() != nul l : "Memen to site pr otocol pre ference fa ctory is n ull and mu st not be. "; | |
| 216 | assert memento.g etSiteServ iceConfigu ration() ! = null : " Memento si te service configura tion is nu ll and mus t not be." ; | |
| 217 | this.c onfigurati on = memen to; | |
| 218 | } | |
| 219 | else | |
| 220 | { | |
| 221 | Provid erConfigur ation<Site Resolution ProviderCo nfiguratio n> provide rConfigura tion = | |
| 222 | SiteReso lutionProv ider.getPr oviderConf iguration( ); | |
| 223 | assert providerC onfigurati on != null ; | |
| 224 | try | |
| 225 | { | |
| 226 | logger.i nfo("Loadi ng configu ration fro m '" + pro viderConfi guration.g etConfigur ationFileN ame() + "' ." ); | |
| 227 | this.con figuration = provide rConfigura tion.loadC onfigurati on(); | |
| 228 | assert t his.config uration != null : "C onfigurati on is null after loa ding and n o exceptio n thrown." ; | |
| 229 | logger.i nfo("Confi guration o f type '" + this.con figuration .getClass( ).getSimpl eName() + "'." ); | |
| 230 | } | |
| 231 | catch (IOExcepti on x) | |
| 232 | { | |
| 233 | throw new Config urationErr or( | |
| 234 | this.get Class().ge tName(), | |
| 235 | "Excepti on occurre d loading configurat ion mement o.", | |
| 236 | x); | |
| 237 | } | |
| 238 | } | |
| 239 | ||
| 240 | crea teSubSyste ms(); | |
| 241 | } | |
| 242 | ||
| 243 | /* * | |
| 244 | * Create th e child co mponents o f the Site Resolver f rom the co nfiguratio n. | |
| 245 | * | |
| 246 | * @throws C onfigurati onError | |
| 247 | * / | |
| 248 | pr ivate void createSub Systems() | |
| 249 | th rows Confi gurationEr ror | |
| 250 | { | |
| 251 | asse rt this.co nfiguratio n != null : "Configu ration sho uld logica lly be ava ilable her e regardle ss of how it was loa ded."; | |
| 252 | ||
| 253 | asse rt this.co nfiguratio n.getSiteS erviceConf iguration( ) != null; | |
| 254 | try | |
| 255 | { | |
| 256 | site Service = new SiteSe rvice(this .configura tion.getSi teServiceC onfigurati on()); | |
| 257 | } | |
| 258 | catc h (Excepti on e) | |
| 259 | { | |
| 260 | String siteServi ceLocation = "<unkno wn>"; | |
| 261 | try | |
| 262 | { | |
| 263 | siteServ iceLocatio n = this.c onfigurati on.getSite ServiceCon figuration ().getSite ServiceUri ().toStrin g(); | |
| 264 | } | |
| 265 | catch (NullPoint erExceptio n x){} | |
| 266 | e.pr intStackTr ace(); | |
| 267 | thro w new Conf igurationE rror( | |
| 268 | this.g etClass(). getName(), | |
| 269 | "Excep tion occur red instan tiating Si teService, please ch eck:\n" + | |
| 270 | "1.) s ite servic e URL '" + siteServi ceLocation + "' is c orrect.", | |
| 271 | e); | |
| 272 | } | |
| 273 | ||
| 274 | asse rt this.co nfiguratio n.getProto colConfigu ration() ! = null; | |
| 275 | prot ocolConfig uration = this.confi guration.g etProtocol Configurat ion(); | |
| 276 | ||
| 277 | asse rt this.co nfiguratio n.getSiteP rotocolPre ferenceFac tory() != null; | |
| 278 | prot ocolPrefer enceFactor y = this.c onfigurati on.getSite ProtocolPr eferenceFa ctory(); | |
| 279 | ||
| 280 | asse rt this.co nfiguratio n.getExter nalArtifac tSources() != null; | |
| 281 | Exte rnalArtifa ctSources externalAr tifactSour ces = this .configura tion.getEx ternalArti factSource s(); | |
| 282 | exte rnalArtifa ctSourceRe solver = n ew Externa lArtifactS ourceResol verImpl( | |
| 283 | extern alArtifact Sources, | |
| 284 | protoc olPreferen ceFactory ); | |
| 285 | regi sterMBeanS erver(site Service); | |
| 286 | } | |
| 287 | ||
| 288 | pr ivate stat ic ObjectN ame siteSe rviceManag erMBeanNam e = null; | |
| 289 | ||
| 290 | pr ivate stat ic synchro nized void registerM BeanServer (SiteServi ce siteSer vice) | |
| 291 | { | |
| 292 | if(s iteService ManagerMBe anName == null) | |
| 293 | { | |
| 294 | logger .info("Reg istering S ite Servic e With JMX "); | |
| 295 | try | |
| 296 | { | |
| 297 | // add sta tistics | |
| 298 | SiteServ iceStatist ics siteSe rviceMbean = new Sit eServiceSt atistics(s iteService ); | |
| 299 | MBeanSer ver mBeanS erver = Ma nagementFa ctory.getP latformMBe anServer() ; | |
| 300 | Hashtabl e<String, String> mB eanPropert ies = new Hashtable< String, St ring>(); | |
| 301 | mBeanPro perties.pu t( "type", "SiteServ ice" ); | |
| 302 | //mBeanP roperties. put( "name ", "Manage r-" + Inte ger.toHexS tring(buff erManager. hashCode() ) ); | |
| 303 | mBeanPro perties.pu t( "name", "Configur ation"); | |
| 304 | siteServ iceManager MBeanName = new Obje ctName(Ima gingMBean. VIX_MBEAN_ DOMAIN_NAM E, mBeanPr operties); | |
| 305 | mBeanSer ver.regist erMBean(si teServiceM bean, site ServiceMan agerMBeanN ame); | |
| 306 | } | |
| 307 | catch( Exception ex) | |
| 308 | { | |
| 309 | logger.e rror("Erro r register ing Site S ervice wit h JMX", ex ); | |
| 310 | } | |
| 311 | } | |
| 312 | } | |
| 313 | ||
| 314 | /* * | |
| 315 | * | |
| 316 | * @param ex ternalRout ingMemento | |
| 317 | * @return | |
| 318 | * / | |
| 319 | pr ivate Exte rnalArtifa ctSources createExte rnalArtifa ctSourceMa pping(Rout ingToArtif actSourceM apMemento externalRo utingMemen to) | |
| 320 | { | |
| 321 | asse rt externa lRoutingMe mento != n ull; | |
| 322 | ||
| 323 | Exte rnalArtifa ctSources eas = null ; | |
| 324 | Stri ng externa lArtifactS ourceMappi ngClassNam e = extern alRoutingM emento.get RoutingToA rtifactSou rceMapClas sName(); | |
| 325 | logg er.info("E xternal ar tifact sou rce mappin g class ty pe '" + ex ternalArti factSource MappingCla ssName + " '."); | |
| 326 | ||
| 327 | if(e xternalArt ifactSourc eMappingCl assName == null) | |
| 328 | { | |
| 329 | extern alArtifact SourceMapp ingClassNa me = Stati cExternalA rtifactSou rces.class .getName() ; | |
| 330 | logger .info("Ext ernal arti fact sourc e mapping class type not speci fied, defa ulting to '" + exter nalArtifac tSourceMap pingClassN ame + "'." ); | |
| 331 | } | |
| 332 | ||
| 333 | try | |
| 334 | { | |
| 335 | Class< ?> externa lArtifactS ourceMappi ngClass = Class.forN ame(extern alArtifact SourceMapp ingClassNa me); | |
| 336 | Constr uctor<?> c tor = exte rnalArtifa ctSourceMa ppingClass .getConstr uctor(Rout ingToArtif actSourceM apMemento. class); | |
| 337 | ||
| 338 | eas = (ExternalA rtifactSou rces)ctor. newInstanc e(external RoutingMem ento); | |
| 339 | ||
| 340 | extern alArtifact SourceReso lver = new ExternalA rtifactSou rceResolve rImpl(eas, protocolP referenceF actory); | |
| 341 | } | |
| 342 | catc h (Excepti on x) | |
| 343 | { | |
| 344 | logger .error("Un able to in stantiate external a rtifact so urce mappi ng class ' " + extern alArtifact SourceMapp ingClassNa me + "'.", x); | |
| 345 | } | |
| 346 | ||
| 347 | retu rn eas; | |
| 348 | } | |
| 349 | ||
| 350 | /* * | |
| 351 | * If a wild card routi ng exists for the gi ven home c ommunity I D then tha t is a gat eway, | |
| 352 | * return tr ue. other wise retur n false. | |
| 353 | * | |
| 354 | * @see gov. va.med.ima ging.datas ource.Site Resolution DataSource #isReposit oryGateway Extant(gov .va.med.OI D) | |
| 355 | * / | |
| 356 | @O verride | |
| 357 | pu blic boole an isRepos itoryGatew ayExtant(O ID homeCom munityId) | |
| 358 | th rows Metho dException , Connecti onExceptio n | |
| 359 | { | |
| 360 | try | |
| 361 | { | |
| 362 | Routin gToken wil dcardRouti ngToken = RoutingTok enImpl.cre ate(homeCo mmunityId, RoutingTo ken.ROUTIN G_WILDCARD ); | |
| 363 | try | |
| 364 | { | |
| 365 | return r esolveArti factSource (wildcardR outingToke n) != null ; | |
| 366 | } | |
| 367 | catch (Exception x) | |
| 368 | { | |
| 369 | return f alse; | |
| 370 | } | |
| 371 | } | |
| 372 | catc h (Routing TokenForma tException x) | |
| 373 | { | |
| 374 | throw new Method Exception( x); | |
| 375 | } | |
| 376 | } | |
| 377 | ||
| 378 | /* * | |
| 379 | * | |
| 380 | * @param ar tifactSour ce | |
| 381 | * @return | |
| 382 | * / | |
| 383 | @O verride | |
| 384 | pu blic Resol vedArtifac tSource re solveArtif actSource( RoutingTok en routing Token) | |
| 385 | th rows Unsup portedOper ationExcep tion, Meth odExceptio n, Connect ionExcepti on | |
| 386 | { | |
| 387 | // l ook in the external artifact s ources fir st, if the artifact source can | |
| 388 | // b e found th ere then r eturn that . | |
| 389 | Reso lutionResu lt externa lResolutio nResult = externalAr tifactSour ceResolver .resolve(r outingToke n); | |
| 390 | ||
| 391 | // i f the exte rnal artif act source is an ind irection t hrough a r outing tok en | |
| 392 | // t hen recurs ively call ourselves to resolv e the new routing to ken. | |
| 393 | if(e xternalRes olutionRes ult != nul l && exter nalResolut ionResult. isIndirect ed()) | |
| 394 | { | |
| 395 | logger .info(rout ingToken.t oRoutingTo kenString( ) + "=> in directed t o =>" + ex ternalReso lutionResu lt.getRout ingToken() .toRouting TokenStrin g()); | |
| 396 | return resolveAr tifactSour ce(externa lResolutio nResult.ge tRoutingTo ken()); | |
| 397 | } | |
| 398 | else | |
| 399 | { | |
| 400 | Resolv edArtifact Source res olvedArtif actSource = | |
| 401 | external Resolution Result == null ? nul l : extern alResoluti onResult.g etResolved ArtifactSo urce(); | |
| 402 | ||
| 403 | if(res olvedArtif actSource != null) | |
| 404 | logger.i nfo(routin gToken.toS tring() + "=> resolv ed as exte rnal artif act source to =>" + resolvedAr tifactSour ce.toStrin g()); | |
| 405 | ||
| 406 | // if the extern al artifac t source d id not lis t the arti fact sourc e and it i s a | |
| 407 | // VA artifact s ource, use the repos itory ID a s a site n umber and attempt to | |
| 408 | // res olve it us ing site s ervice. | |
| 409 | if( re solvedArti factSource == null & & | |
| 410 | WellKnow nOID.VA_DO CUMENT.isA pplicable( routingTok en.getHome CommunityI d()) || | |
| 411 | WellKnow nOID.VA_RA DIOLOGY_IM AGE.isAppl icable(rou tingToken. getHomeCom munityId() ) ) | |
| 412 | { | |
| 413 | logger.d ebug("reso lvesite: " + routing Token.getR epositoryU niqueId()) ; | |
| 414 | for (Sit e site: si teService) | |
| 415 | { | |
| 416 | logger.deb ug("sitese rvice " + site.getSi teAbbr() + " - " + s ite.getSit eName() + " - " + si te.getSite Number() ) ; | |
| 417 | } | |
| 418 | resolved ArtifactSo urce = res olveSite(r outingToke n.getRepos itoryUniqu eId()); | |
| 419 | logger.d ebug(routi ngToken.to String() + "=> resol ved as sit e to =>" + (resolved ArtifactSo urce == nu ll ? "null " : resolv edArtifact Source.toS tring()) ) ; | |
| 420 | } | |
| 421 | ||
| 422 | return resolvedA rtifactSou rce; | |
| 423 | } | |
| 424 | } | |
| 425 | ||
| 426 | /* * | |
| 427 | * @see gov. va.med.ima ging.datas ource.Site Resolution DataSource Spi#resolv eSite(java .lang.Stri ng) | |
| 428 | * / | |
| 429 | @O verride | |
| 430 | pu blic Resol vedSite re solveSite( String sit eNumber) | |
| 431 | th rows Unsup portedOper ationExcep tion | |
| 432 | { | |
| 433 | Site site = si teService. getSiteByN umber(site Number); | |
| 434 | ||
| 435 | retu rn site == null ? nu ll : resol veSite(sit e); | |
| 436 | } | |
| 437 | ||
| 438 | @O verride | |
| 439 | pu blic Resol vedSite re solveSite( Site site) | |
| 440 | th rows Unsup portedOper ationExcep tion | |
| 441 | { | |
| 442 | if(s ite == nul l) | |
| 443 | return null; | |
| 444 | ||
| 445 | if(p rotocolPre ferenceFac tory.isSit eEnabled(s ite.getSit eNumber()) ) | |
| 446 | { | |
| 447 | Source URLs siteU rls = Site Resolver.b uildSiteUr lSet( | |
| 448 | protocol Preference Factory, | |
| 449 | protocol Configurat ion, | |
| 450 | site); | |
| 451 | ||
| 452 | return Res olvedSiteI mpl.create ( | |
| 453 | site, | |
| 454 | protoc olPreferen ceFactory. isSiteLoca l(site.get SiteNumber ()), | |
| 455 | protoc olPreferen ceFactory. isSiteAlie n(site.get SiteNumber ()), | |
| 456 | protoc olPreferen ceFactory. isSiteEnab led(site.g etSiteNumb er()), | |
| 457 | siteUr ls.getMeta dataUrls() , siteUrls .getArtifa ctUrls() | |
| 458 | ); | |
| 459 | } | |
| 460 | else | |
| 461 | { | |
| 462 | logger .info("Sit e '" + sit e.getSiteN umber() + "' is disa bled, cann ot resolve site"); | |
| 463 | return ResolvedS iteImpl.cr eate( | |
| 464 | site, | |
| 465 | protocolPr eferenceFa ctory.isSi teLocal(si te.getSite Number()), | |
| 466 | protocol Preference Factory.is SiteAlien( site.getSi teNumber() ), | |
| 467 | protocol Preference Factory.is SiteEnable d(site.get SiteNumber ()), | |
| 468 | new Arra yList<URL> (), new Ar rayList<UR L>()); | |
| 469 | } | |
| 470 | } | |
| 471 | ||
| 472 | /* * | |
| 473 | * This vers ion of res olveSite() is really only for testing be cause it | |
| 474 | * lets dire ct request s explicit ly, which is somethi ng we shou ld not | |
| 475 | * do in pro duction. | |
| 476 | * | |
| 477 | * @see gov. va.med.ima ging.datas ource.Site Resolution DataSource Spi#resolv eSite(java .lang.Stri ng) | |
| 478 | * / | |
| 479 | @O verride | |
| 480 | pu blic Resol vedSite re solveSite( String sit eNumber, S tring[] pr otocolOver ride) | |
| 481 | th rows Unsup portedOper ationExcep tion | |
| 482 | { | |
| 483 | retu rn resolve Site(siteS ervice.get SiteByNumb er(siteNum ber), prot ocolOverri de); | |
| 484 | } | |
| 485 | ||
| 486 | /* * | |
| 487 | * | |
| 488 | * / | |
| 489 | @O verride | |
| 490 | pu blic Resol vedSite re solveSite( Site site, String[] protocolOv erride) | |
| 491 | th rows Unsup portedOper ationExcep tion | |
| 492 | { | |
| 493 | if(s ite == nul l) | |
| 494 | return null; | |
| 495 | ||
| 496 | Stri ngBuilder sb = new S tringBuild er(); | |
| 497 | for( String pro tocol : pr otocolOver ride) | |
| 498 | sb.app end((sb.le ngth() > 0 ? "," : " ") + proto col); | |
| 499 | logg er.warn("O verriding the prefer red protoc ols with : " + sb.toS tring()); | |
| 500 | ||
| 501 | Site ProtocolPr eferenceFa ctory ppf = | |
| 502 | new Co nstantProt ocolPrefer enceFactor y(protocol Override); | |
| 503 | ||
| 504 | Sour ceURLs sou rceUrls = SiteResolv er.buildSi teUrlSet(p pf, protoc olConfigur ation, sit e); | |
| 505 | // R esolvedSit e will try to build the URLs o f the host based on the Site | |
| 506 | // i nformation . | |
| 507 | return R esolvedSit eImpl.crea te( | |
| 508 | site , | |
| 509 | ppf. isSiteLoca l(site.get SiteNumber ()), | |
| 510 | ppf. isSiteAlie n(site.get SiteNumber ()), | |
| 511 | ppf. isSiteEnab led(site.g etSiteNumb er()), | |
| 512 | sour ceUrls.get MetadataUr ls(), | |
| 513 | sour ceUrls.get ArtifactUr ls() | |
| 514 | ); | |
| 515 | } | |
| 516 | ||
| 517 | /* * | |
| 518 | * | |
| 519 | * @return | |
| 520 | * / | |
| 521 | public Iterator< ResolvedSi te> iterat or() | |
| 522 | { | |
| 523 | return n ew Iterato r<Resolved Site>() | |
| 524 | { | |
| 525 | priv ate Iterat or<Site> s iteIterato r = siteSe rvice.iter ator(); | |
| 526 | ||
| 527 | @Overr ide | |
| 528 | public b oolean has Next() | |
| 529 | { | |
| 530 | return sit eIterator. hasNext(); | |
| 531 | } | |
| 532 | ||
| 533 | @Overr ide | |
| 534 | public R esolvedSit e next() | |
| 535 | { | |
| 536 | return res olveSite(s iteIterato r.next().g etSiteNumb er()); | |
| 537 | } | |
| 538 | ||
| 539 | @Overr ide | |
| 540 | public v oid remove () | |
| 541 | { | |
| 542 | throw ne w Unsuppor tedOperati onExceptio n("remove( ) is not s upported b y the Site Service it erator."); | |
| 543 | } | |
| 544 | }; | |
| 545 | } | |
| 546 | ||
| 547 | /* (non-Java doc) | |
| 548 | * @see gov. va.med.ima ging.datas ource.Site Resolution DataSource #getAllReg ions() | |
| 549 | * / | |
| 550 | @O verride | |
| 551 | pu blic List< Region> ge tAllRegion s() | |
| 552 | th rows Metho dException , Connecti onExceptio n | |
| 553 | { | |
| 554 | retu rn siteSer vice.getAl lRegions() ; | |
| 555 | } | |
| 556 | ||
| 557 | /* (non-Java doc) | |
| 558 | * @see gov. va.med.ima ging.datas ource.Site Resolution DataSource #resolveRe gion(java. lang.Strin g) | |
| 559 | * / | |
| 560 | @O verride | |
| 561 | pu blic Regio n resolveR egion(Stri ng regionI d) | |
| 562 | th rows Metho dException , Connecti onExceptio n | |
| 563 | { | |
| 564 | retu rn siteSer vice.getRe gionByNumb er(regionI d); | |
| 565 | } | |
| 566 | ||
| 567 | /* * | |
| 568 | * This gets all of th e artifact sources, | |
| 569 | * it does n ot include the indir ected rout ing tokens . | |
| 570 | * / | |
| 571 | @O verride | |
| 572 | pu blic List< ArtifactSo urce> getA llArtifact Sources() | |
| 573 | th rows Metho dException , Connecti onExceptio n | |
| 574 | { | |
| 575 | List <ArtifactS ource> art ifactSourc es = new A rrayList<A rtifactSou rce>(); | |
| 576 | ||
| 577 | for( Site site : this.sit eService) | |
| 578 | artifa ctSources. add(site); | |
| 579 | ||
| 580 | for( Iterator<R esolutionR esult> ite r = this.e xternalArt ifactSourc eResolver. iterator() ; iter.has Next(); ) | |
| 581 | { | |
| 582 | Resolu tionResult resolutio nResult = iter.next( ); | |
| 583 | if(res olutionRes ult.isReso lved()) | |
| 584 | artifact Sources.ad d(resoluti onResult.g etResolved ArtifactSo urce().get ArtifactSo urce()); | |
| 585 | } | |
| 586 | retu rn artifac tSources; | |
| 587 | } | |
| 588 | ||
| 589 | @O verride | |
| 590 | pu blic List< ResolvedAr tifactSour ce> getAll ResolvedAr tifactSour ces() | |
| 591 | th rows Metho dException , Connecti onExceptio n | |
| 592 | { | |
| 593 | List <ResolvedA rtifactSou rce> resol vedArtifac tSources = new Array List<Resol vedArtifac tSource>() ; | |
| 594 | ||
| 595 | for( Site site : this.sit eService) | |
| 596 | resolv edArtifact Sources.ad d( resolve Site(site) ); | |
| 597 | ||
| 598 | for( Iterator<R esolutionR esult> ite r = this.e xternalArt ifactSourc eResolver. iterator() ; iter.has Next(); ) | |
| 599 | { | |
| 600 | Resolu tionResult resolutio nResult = iter.next( ); | |
| 601 | if(res olutionRes ult.isReso lved()) | |
| 602 | resolved ArtifactSo urces.add( resolution Result.get ResolvedAr tifactSour ce()); | |
| 603 | } | |
| 604 | retu rn resolve dArtifactS ources; | |
| 605 | } | |
| 606 | ||
| 607 | @O verride | |
| 608 | pu blic void refreshSit eResolutio nData() | |
| 609 | th rows Metho dException , Connecti onExceptio n | |
| 610 | { | |
| 611 | site Service.re freshCache (); | |
| 612 | } | |
| 613 | ||
| 614 | @O verride | |
| 615 | pu blic Site getSite(St ring siteI d) | |
| 616 | th rows Metho dException , Connecti onExceptio n | |
| 617 | { | |
| 618 | retu rn siteSer vice.getSi teByNumber (siteId); | |
| 619 | } | |
| 620 | ||
| 621 | /* * | |
| 622 | * A simple little val ue object to pass th e collecti ons of met adata | |
| 623 | * and artif act URLs t ogether. | |
| 624 | * / | |
| 625 | st atic class SourceURL s | |
| 626 | { | |
| 627 | priv ate final List<URL> metadataUr ls; | |
| 628 | priv ate final List<URL> artifactUr ls; | |
| 629 | ||
| 630 | Sour ceURLs(Lis t<URL> met adataUrls, List<URL> artifactU rls) | |
| 631 | { | |
| 632 | super( ); | |
| 633 | this.m etadataUrl s = metada taUrls; | |
| 634 | this.a rtifactUrl s = artifa ctUrls; | |
| 635 | } | |
| 636 | ||
| 637 | publ ic List<UR L> getMeta dataUrls() {return th is.metadat aUrls;} | |
| 638 | publ ic List<UR L> getArti factUrls() {return th is.artifac tUrls;} | |
| 639 | } | |
| 640 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.