Produced by Araxis Merge on 12/5/2017 12:06:36 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\CacheWeb\src\gov\va\med\cache | CacheManagementService.java | Mon Dec 4 21:34:10 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CacheWeb\src\gov\va\med\cache | CacheManagementService.java | Mon Dec 4 21:57:54 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1236 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | package go v.va.med.c ache; | |
| 2 | ||
| 3 | import jav a.io.Unsup portedEnco dingExcept ion; | |
| 4 | import jav a.net.URLE ncoder; | |
| 5 | import jav a.util.Arr ayList; | |
| 6 | import jav a.util.Col lection; | |
| 7 | import jav a.util.Col lections; | |
| 8 | import jav a.util.Ite rator; | |
| 9 | import jav a.util.Lis t; | |
| 10 | ||
| 11 | import gov .va.med.ca che.gui.se rver.Cache Semantics; | |
| 12 | import gov .va.med.ca che.gui.sh ared.Abstr actGroupPa rent; | |
| 13 | import gov .va.med.ca che.gui.sh ared.Abstr actNamedVO ; | |
| 14 | import gov .va.med.ca che.gui.sh ared.CACHE _POPULATIO N_DEPTH; | |
| 15 | import gov .va.med.ca che.gui.sh ared.Cache GroupMetad ata; | |
| 16 | import gov .va.med.ca che.gui.sh ared.Cache InstanceMe tadata; | |
| 17 | import gov .va.med.ca che.gui.sh ared.Cache ItemPath; | |
| 18 | import gov .va.med.ca che.gui.sh ared.Cache Metadata; | |
| 19 | import gov .va.med.ca che.gui.sh ared.Cache RegionMeta data; | |
| 20 | import gov .va.med.ca che.gui.sh ared.Cache VO; | |
| 21 | import gov .va.med.ca che.gui.sh ared.Group VO; | |
| 22 | import gov .va.med.ca che.gui.sh ared.Insta nceVO; | |
| 23 | import gov .va.med.ca che.gui.sh ared.Regio nVO; | |
| 24 | import gov .va.med.im aging.stor age.cache. Cache; | |
| 25 | import gov .va.med.im aging.stor age.cache. CacheManag er; | |
| 26 | import gov .va.med.im aging.stor age.cache. Group; | |
| 27 | import gov .va.med.im aging.stor age.cache. Instance; | |
| 28 | import gov .va.med.im aging.stor age.cache. Region; | |
| 29 | import gov .va.med.im aging.stor age.cache. exceptions .CacheExce ption; | |
| 30 | import gov .va.med.im aging.stor age.cache. impl.Cache ManagerImp l; | |
| 31 | ||
| 32 | import jav ax.managem ent.MBeanE xception; | |
| 33 | ||
| 34 | import org .apache.lo gging.log4 j.LogManag er; | |
| 35 | import org .apache.lo gging.log4 j.Logger; | |
| 36 | ||
| 37 | /** | |
| 38 | * | |
| 39 | * @author
|
|
| 40 | * | |
| 41 | */ | |
| 42 | public cla ss CacheMa nagementSe rvice | |
| 43 | { | |
| 44 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(Cach eManagemen tService.c lass); | |
| 45 | pr ivate stat ic CacheMa nager cach eManager; | |
| 46 | ||
| 47 | /* * | |
| 48 | * | |
| 49 | * / | |
| 50 | st atic | |
| 51 | { | |
| 52 | try | |
| 53 | { | |
| 54 | cacheM anager = C acheManage rImpl.getS ingleton() ; | |
| 55 | } | |
| 56 | catc h (MBeanEx ception e) | |
| 57 | { | |
| 58 | e.prin tStackTrac e(); | |
| 59 | } | |
| 60 | catc h (CacheEx ception e) | |
| 61 | { | |
| 62 | e.prin tStackTrac e(); | |
| 63 | } | |
| 64 | } | |
| 65 | ||
| 66 | /* * | |
| 67 | * Get the C acheManage r implemen tation. L og the has hCode of t he cache m anager so that we ca n assure t hat the | |
| 68 | * instance used by th is web app is the sa me instanc e as used by the app lications. | |
| 69 | * | |
| 70 | * @return | |
| 71 | * @throws C acheExcept ion | |
| 72 | * @throws M BeanExcept ion | |
| 73 | * / | |
| 74 | pu blic stati c CacheMan ager getCa cheManager () | |
| 75 | th rows MBean Exception, CacheExce ption | |
| 76 | { | |
| 77 | logg er.debug(" ENTERING g etCacheMan ager(), Ca cheManager instance is " | |
| 78 | + (cac heManager == null ? "<null>" : cacheMana ger.toStri ng()) | |
| 79 | ); | |
| 80 | ||
| 81 | retu rn cacheMa nager; | |
| 82 | } | |
| 83 | ||
| 84 | /* * | |
| 85 | * | |
| 86 | * @param ca chePath | |
| 87 | * @return | |
| 88 | * @throws I llegalArgu mentExcept ion | |
| 89 | * / | |
| 90 | pu blic stati c CacheMet adata getC acheMetada ta(CacheIt emPath cac hePath) | |
| 91 | th rows Illeg alArgument Exception | |
| 92 | { | |
| 93 | logg er.debug(" getCacheRe gionMetada ta(" + cac hePath.toS tring() + ")"); | |
| 94 | asse rt( cacheP ath.getCac heName() ! = null ); | |
| 95 | logg er.debug(" getCacheRe gionMetada ta(" + cac hePath.toS tring() + "), parame ters valid ated"); | |
| 96 | ||
| 97 | try | |
| 98 | { | |
| 99 | Cache cache = ge tCacheMana ger().getC ache(cache Path.getCa cheName()) ; | |
| 100 | return new Cache Metadata(c achePath, cache.getL ocationUri ().toStrin g(), cache .getLocati onPath(), cache.getL ocationPro tocol()); | |
| 101 | } | |
| 102 | catc h (Excepti on x) | |
| 103 | { | |
| 104 | x.prin tStackTrac e(); | |
| 105 | return null; | |
| 106 | } | |
| 107 | } | |
| 108 | ||
| 109 | /* * | |
| 110 | * | |
| 111 | * @param re gionPath | |
| 112 | * @return | |
| 113 | * @throws I llegalArgu mentExcept ion | |
| 114 | * / | |
| 115 | pu blic stati c CacheReg ionMetadat a getCache RegionMeta data(Cache ItemPath r egionPath) | |
| 116 | th rows Illeg alArgument Exception | |
| 117 | { | |
| 118 | logg er.debug(" ENTERING g etCacheReg ionMetadat a(" + regi onPath.toS tring() + ")"); | |
| 119 | asse rt( region Path.getCa cheName() != null ); | |
| 120 | asse rt( region Path.getRe gionName() != null ) ; | |
| 121 | logg er.debug(" getCacheRe gionMetada ta(" + reg ionPath.to String() + "), param eters vali dated"); | |
| 122 | ||
| 123 | try | |
| 124 | { | |
| 125 | Cache cache = ge tCacheMana ger().getC ache(regio nPath.getC acheName() ); | |
| 126 | Region region = cache.getR egion(regi onPath.get RegionName ()); | |
| 127 | CacheR egionMetad ata result = | |
| 128 | new Cach eRegionMet adata(regi onPath, re gion.getEv ictionStra tegyNames( ), region. getTotalSp ace(), reg ion.getUse dSpace()); | |
| 129 | logger .debug("EX ITING getC acheRegion Metadata(" + regionP ath.toStri ng() + ") SUCCESS -> " + resul t.toString ()); | |
| 130 | return result; | |
| 131 | } | |
| 132 | catc h (Excepti on x) | |
| 133 | { | |
| 134 | x.prin tStackTrac e(); | |
| 135 | logger .debug("EX ITING getC acheRegion Metadata(" + regionP ath.toStri ng() + ") EXCEPTION " + x.toSt ring()); | |
| 136 | return null; | |
| 137 | } | |
| 138 | } | |
| 139 | ||
| 140 | /* * | |
| 141 | * | |
| 142 | * @param gr oupPath | |
| 143 | * @return | |
| 144 | * @throws I llegalArgu mentExcept ion | |
| 145 | * / | |
| 146 | pu blic stati c CacheGro upMetadata getCacheG roupMetada ta(CacheIt emPath gro upPath) | |
| 147 | th rows Illeg alArgument Exception | |
| 148 | { | |
| 149 | logg er.debug(" getCacheIn stanceMeta data(" + g roupPath.t oString() + ")"); | |
| 150 | asse rt( groupP ath.getCac heName() ! = null ); | |
| 151 | asse rt( groupP ath.getReg ionName() != null ); | |
| 152 | asse rt( groupP ath.getGro upNames() != null && groupPath .getGroupN ames().len gth > 0); | |
| 153 | logg er.debug(" getCacheIn stanceMeta data(" + g roupPath.t oString() + "), para meters val idated"); | |
| 154 | ||
| 155 | try | |
| 156 | { | |
| 157 | Cache cache = ge tCacheMana ger().getC ache(group Path.getCa cheName()) ; | |
| 158 | Region region = cache.getR egion(grou pPath.getR egionName( )); | |
| 159 | Group group = re gion.getGr oup(groupP ath.getGro upNames()) ; | |
| 160 | ||
| 161 | return new Cache GroupMetad ata(groupP ath, group .getSize() , null, gr oup.getLas tAccessed( )); | |
| 162 | } | |
| 163 | catc h (Excepti on x) | |
| 164 | { | |
| 165 | x.prin tStackTrac e(); | |
| 166 | return null; | |
| 167 | } | |
| 168 | } | |
| 169 | ||
| 170 | /* * | |
| 171 | * | |
| 172 | * @param it emPath | |
| 173 | * @return | |
| 174 | * @throws I llegalArgu mentExcept ion | |
| 175 | * / | |
| 176 | pu blic stati c CacheIns tanceMetad ata getCac heInstance Metadata(C acheItemPa th itemPat h) | |
| 177 | th rows Illeg alArgument Exception | |
| 178 | { | |
| 179 | logg er.debug(" getCacheIn stanceMeta data(" + i temPath.to String() + ")"); | |
| 180 | asse rt( itemPa th.getCach eName() != null ); | |
| 181 | asse rt( itemPa th.getRegi onName() ! = null ); | |
| 182 | asse rt( itemPa th.getGrou pNames() ! = null && itemPath.g etGroupNam es().lengt h > 0); | |
| 183 | asse rt( itemPa th.getInst anceName() != null ) ; | |
| 184 | logg er.debug(" getCacheIn stanceMeta data(" + i temPath.to String() + "), param eters vali dated"); | |
| 185 | ||
| 186 | try | |
| 187 | { | |
| 188 | Cache cache = ge tCacheMana ger().getC ache(itemP ath.getCac heName()); | |
| 189 | cache. getLocatio nUri(); | |
| 190 | Region region = cache.getR egion(item Path.getRe gionName() ); | |
| 191 | Instan ce instanc e = region .getInstan ce(itemPat h.getGroup Names(), i temPath.ge tInstanceN ame()); | |
| 192 | ||
| 193 | return new Cache InstanceMe tadata(ite mPath, ins tance.getS ize(), ins tance.getL astAccesse d(), insta nce.getChe cksumValue ()); | |
| 194 | } | |
| 195 | catc h (Excepti on x) | |
| 196 | { | |
| 197 | x.prin tStackTrac e(); | |
| 198 | return null; | |
| 199 | } | |
| 200 | } | |
| 201 | ||
| 202 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 203 | // Private, helper, me thods that do the ma jority of the work. | |
| 204 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 205 | ||
| 206 | /* * | |
| 207 | * @param ca ches | |
| 208 | * @throws C acheExcept ion | |
| 209 | * @throws M BeanExcept ion | |
| 210 | * / | |
| 211 | pu blic stati c List<Cac he> getKno wnCaches() | |
| 212 | th rows MBean Exception, CacheExce ption | |
| 213 | { | |
| 214 | Iter able<Cache > caches = getCacheM anager().g etKnownCac hes(); | |
| 215 | ||
| 216 | List <Cache> ca cheList = new ArrayL ist<Cache> (); | |
| 217 | for( Iterator<C ache> cach eIter = ca ches.itera tor(); cac heIter.has Next(); ) | |
| 218 | { | |
| 219 | Cache cache = ca cheIter.ne xt(); | |
| 220 | ||
| 221 | cacheL ist.add(ca che); | |
| 222 | logger .debug(cac he.getName () + "-" + cache.get LocationPr otocol() + ":" + cac he.getLoca tionPath() ); | |
| 223 | } | |
| 224 | retu rn cacheLi st; | |
| 225 | } | |
| 226 | ||
| 227 | pu blic stati c List<Cac heVO> getC acheManage rCaches(CA CHE_POPULA TION_DEPTH depth, CA CHE_POPULA TION_DEPTH metadataP opulationD epth) | |
| 228 | th rows MBean Exception, CacheExce ption | |
| 229 | { | |
| 230 | List <CacheVO> caches = n ew ArrayLi st<CacheVO >(); | |
| 231 | ||
| 232 | for( Cache cach e : getKno wnCaches() ) | |
| 233 | { | |
| 234 | logger .info(cach e.getName( ) + "-" + cache.getL ocationPro tocol() + ":" + cach e.getLocat ionPath()) ; | |
| 235 | CacheI temPath ca cheItemPat h = new Ca cheItemPat h(cache.ge tName()); | |
| 236 | CacheV O cacheVO = new Cach eVO( | |
| 237 | cache.ge tName(), | |
| 238 | new Cach eMetadata( cacheItemP ath, cache .getLocati onUri().to String(), cache.getL ocationPat h(), cache .getLocati onProtocol ()) | |
| 239 | ); | |
| 240 | if(dep th.ordinal () >= CACH E_POPULATI ON_DEPTH.R EGION.ordi nal()) | |
| 241 | cacheVO. addAll(get CacheRegio ns(cache, depth, met adataPopul ationDepth )); | |
| 242 | caches .add(cache VO); | |
| 243 | } | |
| 244 | ||
| 245 | retu rn caches; | |
| 246 | } | |
| 247 | ||
| 248 | pu blic stati c Cache ge tCache(Str ing cacheN ame) | |
| 249 | th rows MBean Exception, CacheExce ption | |
| 250 | { | |
| 251 | for( Cache cach e : getKno wnCaches() ) | |
| 252 | if(cac heName.equ als(cache. getName()) ) | |
| 253 | return c ache; | |
| 254 | ||
| 255 | retu rn null; | |
| 256 | } | |
| 257 | /* * | |
| 258 | * @param re gions | |
| 259 | * @param ca che | |
| 260 | * @throws C acheExcept ion | |
| 261 | * / | |
| 262 | pu blic stati c List<Reg ionVO> get CacheRegio ns(Cache c ache, CACH E_POPULATI ON_DEPTH d epth, CACH E_POPULATI ON_DEPTH m etadataPop ulationDep th) | |
| 263 | th rows Cache Exception | |
| 264 | { | |
| 265 | List <RegionVO> regions = new Array List<Regio nVO>(); | |
| 266 | if(d epth.ordin al() >= CA CHE_POPULA TION_DEPTH .REGION.or dinal()) | |
| 267 | { | |
| 268 | for( I terator<? extends Re gion> regi onIterator = cache.g etRegions( ).iterator (); | |
| 269 | regionIt erator.has Next(); ) | |
| 270 | { | |
| 271 | Region r egion = re gionIterat or.next(); | |
| 272 | logger.d ebug(regio n.getName( )); | |
| 273 | ||
| 274 | CacheIte mPath regi onPath = n ew CacheIt emPath(cac he.getName (), region .getName() ); | |
| 275 | ||
| 276 | // getti ng region metadata i s a very e xpensive o peration, do so only if asked. | |
| 277 | CacheReg ionMetadat a metadata = metadat aPopulatio nDepth.com pareTo(CAC HE_POPULAT ION_DEPTH. REGION) >= 0 ? | |
| 278 | new CacheR egionMetad ata(region Path, regi on.getEvic tionStrate gyNames(), region.ge tTotalSpac e(), regio n.getFreeS pace()) : | |
| 279 | null; | |
| 280 | ||
| 281 | RegionVO vo = new RegionVO(r egion.getN ame(), met adata, reg ionPath); | |
| 282 | if(depth .ordinal() >= CACHE_ POPULATION _DEPTH.GRO UP0.ordina l()) | |
| 283 | vo.addAll( getRegionG roups(cach e, region, depth, me tadataPopu lationDept h)); | |
| 284 | regions. add(vo); | |
| 285 | } | |
| 286 | Collec tions.sort (regions); | |
| 287 | } | |
| 288 | ||
| 289 | retu rn regions ; | |
| 290 | } | |
| 291 | ||
| 292 | /* * | |
| 293 | * | |
| 294 | * @param ca che | |
| 295 | * @param re gion | |
| 296 | * @param de pth | |
| 297 | * @param me tadataPopu lationDept h | |
| 298 | * @return | |
| 299 | * @throws C acheExcept ion | |
| 300 | * / | |
| 301 | pu blic stati c Collecti on<GroupVO > getRegio nGroups(Ca che cache, Region re gion, CACH E_POPULATI ON_DEPTH d epth, CACH E_POPULATI ON_DEPTH m etadataPop ulationDep th) | |
| 302 | th rows Cache Exception | |
| 303 | { | |
| 304 | List <GroupVO> groups = n ew ArrayLi st<GroupVO >(); | |
| 305 | if(d epth.ordin al() >= CA CHE_POPULA TION_DEPTH .GROUP0.or dinal()) | |
| 306 | { | |
| 307 | for( I terator<? extends Gr oup> group Iterator = region.ge tGroups(); | |
| 308 | groupIte rator.hasN ext(); ) | |
| 309 | { | |
| 310 | Group gr oup = grou pIterator. next(); | |
| 311 | if(group == null) | |
| 312 | { | |
| 313 | logger.war n("NULL gr oup refere nce from r egion.getG roups() is being ign ored"); | |
| 314 | continue; | |
| 315 | } | |
| 316 | ||
| 317 | logger.d ebug(group .getName() ); | |
| 318 | CacheIte mPath grou pPath = ne w CacheIte mPath(cach e.getName( ), region. getName(), group.get Name()); | |
| 319 | ||
| 320 | // getti ng region metadata i s a very e xpensive o peration, do so only if asked. | |
| 321 | CacheGro upMetadata metadata = metadata Population Depth.comp areTo(CACH E_POPULATI ON_DEPTH.G ROUP0) >= 0 ? | |
| 322 | new CacheG roupMetada ta(groupPa th, group. getSize(), group.get LastAccess ed()) : | |
| 323 | null; | |
| 324 | ||
| 325 | GroupVO vo = new G roupVO( | |
| 326 | group.getN ame(), | |
| 327 | metadata, | |
| 328 | CACHE_POPU LATION_DEP TH.GROUP0, | |
| 329 | CacheSeman tics.getGr oupSemanti cType(cach e.getName( ), region. getName(), CACHE_POP ULATION_DE PTH.GROUP0 .getGroupI ndex()), | |
| 330 | groupPath | |
| 331 | ); | |
| 332 | ||
| 333 | if(depth .ordinal() > CACHE_P OPULATION_ DEPTH.GROU P0.ordinal ()) | |
| 334 | vo.addAll( getGroupG roups(grou pPath, gro up, depth, CACHE_POP ULATION_DE PTH.GROUP0 , metadata Population Depth)); | |
| 335 | if(depth .ordinal() >= CACHE_ POPULATION _DEPTH.INS TANCE.ordi nal()) | |
| 336 | vo.addAllI nstance(ge tGroupInst ances(grou pPath, gro up, metada taPopulati onDepth)); | |
| 337 | groups.a dd(vo); | |
| 338 | } | |
| 339 | Collec tions.sort (groups); | |
| 340 | } | |
| 341 | retu rn groups; | |
| 342 | } | |
| 343 | ||
| 344 | /* * | |
| 345 | * | |
| 346 | * @param gr oupPath | |
| 347 | * @param gr oup | |
| 348 | * @param cu rrentDepth | |
| 349 | * @param ta rgetDepth | |
| 350 | * @param me tadataPopu lationDept h | |
| 351 | * @return | |
| 352 | * @throws C acheExcept ion | |
| 353 | * / | |
| 354 | pu blic stati c Collecti on<GroupVO > getGroup Groups( | |
| 355 | Cach eItemPath groupPath, // the p ath to the current g roup | |
| 356 | Grou p group, | |
| 357 | CACH E_POPULATI ON_DEPTH c urrentDept h, | |
| 358 | CACH E_POPULATI ON_DEPTH t argetDepth , | |
| 359 | CACH E_POPULATI ON_DEPTH m etadataPop ulationDep th | |
| 360 | ) | |
| 361 | th rows Cache Exception | |
| 362 | { | |
| 363 | List <GroupVO> groups = n ew ArrayLi st<GroupVO >(); | |
| 364 | CACH E_POPULATI ON_DEPTH c hildrenDep th = CACHE _POPULATIO N_DEPTH.ne xt(current Depth); | |
| 365 | ||
| 366 | for( Iterator< ? extends Group> gro upIterator = group.g etGroups() ; | |
| 367 | groupI terator.ha sNext(); ) | |
| 368 | { | |
| 369 | Group childGroup = groupIt erator.nex t(); | |
| 370 | if(chi ldGroup == null) | |
| 371 | { | |
| 372 | logger.w arn("Ignor ing NULL i n group '" + group.g etName() + "' childr en."); | |
| 373 | continue ; | |
| 374 | } | |
| 375 | logger .debug(chi ldGroup.ge tName() + ", depth i s " + (chi ldrenDepth == null ? "null" : childrenDe pth.toStri ng()) ); | |
| 376 | CacheI temPath ch ildGroupPa th = group Path.creat eChildPath (childGrou p.getName( ), false); | |
| 377 | ||
| 378 | // get ting regio n metadata is a very expensive operation , do so on ly if aske d. | |
| 379 | CacheG roupMetada ta metadat a = metada taPopulati onDepth.co mpareTo(CA CHE_POPULA TION_DEPTH .GROUP0) > = 0 ? | |
| 380 | new Cach eGroupMeta data(child GroupPath, group.get Size(), gr oup.getLas tAccessed( )) : | |
| 381 | null; | |
| 382 | ||
| 383 | GroupV O vo = new GroupVO( | |
| 384 | childGro up.getName (), | |
| 385 | metadata , | |
| 386 | children Depth, | |
| 387 | children Depth == n ull ? null : | |
| 388 | CacheSem antics.get GroupSeman ticType( | |
| 389 | childGroup Path.getCa cheName(), | |
| 390 | childGroup Path.getRe gionName() , | |
| 391 | childrenDe pth.getGro upIndex()) , | |
| 392 | childGroup Path | |
| 393 | ); | |
| 394 | if(tar getDepth.o rdinal() > = CACHE_PO PULATION_D EPTH.GROUP 0.ordinal( )) | |
| 395 | vo.addAl l(getGroup Groups(chi ldGroupPat h, childGr oup, child renDepth, targetDept h, metadat aPopulatio nDepth)); | |
| 396 | ||
| 397 | //if(d epth.ordin al() >= CA CHE_POPULA TION_DEPTH .INSTANCE. ordinal()) | |
| 398 | // vo.addAl l(getGroup Instances( childGroup , depth)); | |
| 399 | groups .add(vo); | |
| 400 | } | |
| 401 | Coll ections.so rt(groups) ; | |
| 402 | retu rn groups; | |
| 403 | } | |
| 404 | ||
| 405 | /* * | |
| 406 | * | |
| 407 | * @param gr oupPath | |
| 408 | * @param gr oup | |
| 409 | * @param me tadataPopu lationDept h | |
| 410 | * @return | |
| 411 | * @throws C acheExcept ion | |
| 412 | * / | |
| 413 | pu blic stati c Collecti on<Instanc eVO> getGr oupInstanc es( | |
| 414 | Cach eItemPath groupPath, // the p ath to the current g roup | |
| 415 | Grou p group, | |
| 416 | CACH E_POPULATI ON_DEPTH m etadataPop ulationDep th) | |
| 417 | th rows Cache Exception | |
| 418 | { | |
| 419 | List <InstanceV O> instanc es = new A rrayList<I nstanceVO> (); | |
| 420 | for( Iterator< ? extends Instance> instanceIt erator = g roup.getIn stances(); | |
| 421 | instan ceIterator .hasNext() ; ) | |
| 422 | { | |
| 423 | Instan ce instanc e = instan ceIterator .next(); | |
| 424 | ||
| 425 | CacheI temPath in stancePath = groupPa th.createC hildInstan cePath(ins tance.getN ame()); | |
| 426 | ||
| 427 | // get ting regio n metadata is a very expensive operation , do so on ly if aske d. | |
| 428 | CacheI nstanceMet adata meta data = met adataPopul ationDepth .compareTo (CACHE_POP ULATION_DE PTH.INSTAN CE) >= 0 ? | |
| 429 | new Cach eInstanceM etadata(in stancePath , instance .getSize() , instance .getLastAc cessed(), instance.g etChecksum Value()) : | |
| 430 | null; | |
| 431 | ||
| 432 | Instan ceVO insta nceVO = ne w Instance VO( | |
| 433 | instance .getName() , | |
| 434 | metadata , | |
| 435 | CacheSem antics.get InstanceSe manticType (groupPath .getCacheN ame(), gro upPath.get RegionName ()), | |
| 436 | instance Path | |
| 437 | ); | |
| 438 | instan ces.add(in stanceVO); | |
| 439 | } | |
| 440 | Coll ections.so rt(instanc es); | |
| 441 | retu rn instanc es; | |
| 442 | } | |
| 443 | ||
| 444 | pu blic stati c String m akeTextSum mary(Cache VO cacheVo ) | |
| 445 | { | |
| 446 | retu rn makeTex tSummary(c acheVo, "" , "\t", "\ r\n"); | |
| 447 | } | |
| 448 | ||
| 449 | /* * | |
| 450 | * | |
| 451 | * @param ca cheVo | |
| 452 | * @return | |
| 453 | * / | |
| 454 | pu blic stati c String m akeTextSum mary(Cache VO cacheVo , String p refix, Str ing indent , String s uffix) | |
| 455 | { | |
| 456 | Stri ngBuilder sb = new S tringBuild er(); | |
| 457 | ||
| 458 | sb.a ppend(pref ix); | |
| 459 | sb.a ppend(cach eVo.getNam e()); | |
| 460 | sb.a ppend(suff ix); | |
| 461 | ||
| 462 | if(c acheVo.get RegionCoun t() > 0) | |
| 463 | for( R egionVO re gion : cac heVo.getRe gions() ) | |
| 464 | { | |
| 465 | sb.appen d(prefix); | |
| 466 | sb.appen d(indent); | |
| 467 | sb.appen d(region.g etName()); | |
| 468 | sb.appen d(suffix); | |
| 469 | if(regio n.getGroup Count() > 0) | |
| 470 | for(GroupV O group : region.get Groups()) | |
| 471 | sb .append(ma keTextSumm ary(group, prefix, i ndent + in dent, suff ix)); | |
| 472 | } | |
| 473 | ||
| 474 | retu rn sb.toSt ring(); | |
| 475 | } | |
| 476 | ||
| 477 | pu blic stati c String m akeTextSum mary(Group VO group, String pre fix, Strin g indent, String suf fix) | |
| 478 | { | |
| 479 | Stri ngBuilder sb = new S tringBuild er(); | |
| 480 | ||
| 481 | sb.a ppend(pref ix); | |
| 482 | sb.a ppend(inde nt); | |
| 483 | sb.a ppend(grou p.getName( )); | |
| 484 | sb.a ppend("[" + group.ge tSemanticT ypeName() + "]"); | |
| 485 | sb.a ppend(suff ix); | |
| 486 | ||
| 487 | if(g roup.getIn stanceCoun t() > 0) | |
| 488 | for(In stanceVO c hildInstan ce : group .getInstan ces()) | |
| 489 | sb.appen d(makeText Summary(ch ildInstanc e, prefix, indent + indent, su ffix)); | |
| 490 | ||
| 491 | if(g roup.getGr oupCount() > 0) | |
| 492 | for(Gr oupVO chil dGroup : g roup.getGr oups()) | |
| 493 | sb.appen d(makeText Summary(ch ildGroup, prefix, in dent + ind ent, suffi x)); | |
| 494 | ||
| 495 | retu rn sb.toSt ring(); | |
| 496 | } | |
| 497 | ||
| 498 | pr ivate stat ic String makeTextSu mmary(Inst anceVO chi ldInstance , String p refix, Str ing indent , String s uffix) | |
| 499 | { | |
| 500 | Stri ngBuilder sb = new S tringBuild er(); | |
| 501 | ||
| 502 | sb.a ppend(pref ix); | |
| 503 | sb.a ppend(inde nt); | |
| 504 | sb.a ppend(chil dInstance. getName()) ; | |
| 505 | sb.a ppend("[" + childIns tance.getS emanticTyp eName() + "]"); | |
| 506 | sb.a ppend(suff ix); | |
| 507 | ||
| 508 | retu rn sb.toSt ring(); | |
| 509 | } | |
| 510 | ||
| 511 | pu blic stati c List<Abs tractNamed VO> resolv eChildren( CacheItemP ath itemPa th) | |
| 512 | throws CacheExce ption, MBe anExceptio n { | |
| 513 | List <AbstractN amedVO> ch ildren = n ew ArrayLi st<Abstrac tNamedVO>( ); | |
| 514 | Stri ng type = itemPath.g etItemType (); | |
| 515 | if ( type == nu ll) | |
| 516 | childr en.addAll( getCacheMa nagerCache s(CACHE_PO PULATION_D EPTH.CACHE , | |
| 517 | CACHE_POPU LATION_DEP TH.CACHE)) ; | |
| 518 | else { | |
| 519 | gov.va .med.imagi ng.storage .cache.Cac he cache = getCache( itemPath | |
| 520 | .getCacheN ame()); | |
| 521 | if (ty pe.equals( "cache")) | |
| 522 | children .addAll(ge tCacheRegi ons(cache, | |
| 523 | CA CHE_POPULA TION_DEPTH .REGION, | |
| 524 | CA CHE_POPULA TION_DEPTH .CACHE)); | |
| 525 | else i f (type.eq uals("regi on")) { | |
| 526 | children .addAll(ge tRegionGro ups(cache, | |
| 527 | ca che.getReg ion(itemPa th.getRegi onName()), | |
| 528 | CA CHE_POPULA TION_DEPTH .GROUP0, | |
| 529 | CA CHE_POPULA TION_DEPTH .REGION)); | |
| 530 | } else if (type. equals("gr oup")) { | |
| 531 | gov.va.m ed.imaging .storage.c ache.Group group = c ache.getGr oup( | |
| 532 | it emPath.get RegionName (), itemPa th.getGrou pNames()); | |
| 533 | children .addAll(ge tGroupGrou ps(itemPat h, group, | |
| 534 | CA CHE_POPULA TION_DEPTH .GROUP0, | |
| 535 | CA CHE_POPULA TION_DEPTH .REGION, | |
| 536 | CA CHE_POPULA TION_DEPTH .REGION)); | |
| 537 | children .addAll(ge tGroupInst ances(item Path, grou p, | |
| 538 | CA CHE_POPULA TION_DEPTH .GROUP0)); | |
| 539 | } | |
| 540 | } | |
| 541 | retu rn childre n; | |
| 542 | } | |
| 543 | ||
| 544 | pu blic stati c Object r esolveMeta data(Cache ItemPath i temPath) | |
| 545 | throws CacheExce ption, MBe anExceptio n { | |
| 546 | Stri ng type = itemPath.g etItemType (); | |
| 547 | if ( type == nu ll) | |
| 548 | return null; | |
| 549 | if ( type.equal s("cache") ) | |
| 550 | return getCacheM etadata(it emPath); | |
| 551 | if ( type.equal s("region" )) | |
| 552 | return getCacheR egionMetad ata(itemPa th); | |
| 553 | if ( type.equal s("group") ) | |
| 554 | return getCacheG roupMetada ta(itemPat h); | |
| 555 | if ( type.equal s("instanc e")) | |
| 556 | return getCacheI nstanceMet adata(item Path); | |
| 557 | retu rn null; | |
| 558 | } | |
| 559 | ||
| 560 | pu blic stati c String b uildQueryS tring(Cach eItemPath itemPath) | |
| 561 | throws Unsupport edEncoding Exception { | |
| 562 | Stri ngBuilder qsb = new StringBuil der(); | |
| 563 | if ( itemPath.g etCacheNam e() != nul l | |
| 564 | && itemP ath.getCac heName().l ength() > 0) { | |
| 565 | qsb.ap pend("cach e="); | |
| 566 | qsb.ap pend(URLEn coder.enco de(itemPat h.getCache Name(), "U TF8")); | |
| 567 | if (it emPath.get RegionName () != null | |
| 568 | && itemPat h.getRegio nName().le ngth() > 0 ) { | |
| 569 | qsb.appe nd("®io n="); | |
| 570 | qsb.appe nd(URLEnco der.encode (itemPath. getRegionN ame(), "UT F8")); | |
| 571 | if (item Path.getGr oupNames() != null | |
| 572 | && itemPath. getGroupNa mes().leng th > 0) { | |
| 573 | for (int i = 0; i < itemPath.g etGroupNam es().lengt h; i++) { | |
| 574 | qs b.append(" &group="); | |
| 575 | qs b.append(U RLEncoder. encode( | |
| 576 | itemPa th.getGrou pNames()[i ], "UTF8") ); | |
| 577 | } | |
| 578 | } | |
| 579 | if (item Path.getIn stanceName () != null | |
| 580 | && itemPath. getInstanc eName().le ngth() > 0 ) { | |
| 581 | qsb.append ("&instanc e="); | |
| 582 | qsb.append (URLEncode r.encode(i temPath.ge tInstanceN ame(), | |
| 583 | "UTF 8")); | |
| 584 | } | |
| 585 | } | |
| 586 | } | |
| 587 | ||
| 588 | retu rn qsb.toS tring(); | |
| 589 | } | |
| 590 | ||
| 591 | /* * | |
| 592 | * | |
| 593 | * @param re gion | |
| 594 | * @return | |
| 595 | * / | |
| 596 | pu blic stati c GroupSum mary total Count(Abst ractGroupP arent regi on) | |
| 597 | { | |
| 598 | Grou pSummary t otals = ne w GroupSum mary(); | |
| 599 | if(r egion.getG roupCount( ) > 0) | |
| 600 | { | |
| 601 | totals .groupCoun t = region .getGroupC ount(); | |
| 602 | totals .instanceC ount = reg ion instan ceof Group VO ? ((Gro upVO)regio n).getInst anceCount( ) : 0; | |
| 603 | for(Gr oupVO grou p:region.g etGroups() ) | |
| 604 | { | |
| 605 | GroupSum mary child Totals = t otalCount( group); | |
| 606 | totals.g roupCount += childTo tals.group Count; | |
| 607 | totals.i nstanceCou nt += chil dTotals.in stanceCoun t; | |
| 608 | } | |
| 609 | } | |
| 610 | ||
| 611 | retu rn totals; | |
| 612 | } | |
| 613 | ||
| 614 | st atic class GroupSumm ary | |
| 615 | { | |
| 616 | int groupCount = 0; | |
| 617 | int instanceCo unt = 0; | |
| 618 | } | |
| 619 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.