Produced by Araxis Merge on 12/5/2017 12:06:45 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\ImagingExchangeCache\main\src\java\gov\va\med\imaging\exchange\storage\cache | AbstractCacheDecorator.java | Mon Dec 4 21:35:22 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingExchangeCache\main\src\java\gov\va\med\imaging\exchange\storage\cache | AbstractCacheDecorator.java | Mon Dec 4 22:03:20 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1024 |
| 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.i maging.exc hange.stor age.cache; | |
| 2 | ||
| 3 | import gov .va.med.Gl obalArtifa ctIdentifi er; | |
| 4 | import gov .va.med.Oc tetSequenc eEscaping; | |
| 5 | import gov .va.med.Pa tientArtif actIdentif ier; | |
| 6 | import gov .va.med.im aging.Abst ractImagin gURN; | |
| 7 | import gov .va.med.im aging.Bhie ImageURN; | |
| 8 | import gov .va.med.im aging.Imag eURN; | |
| 9 | import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume nt; | |
| 10 | import gov .va.med.im aging.exch ange.busin ess.vistar ad.ExamSit e; | |
| 11 | import gov .va.med.im aging.exch ange.busin ess.vistar ad.Patient Enterprise Exams; | |
| 12 | import gov .va.med.im aging.stor age.cache. Cache; | |
| 13 | import gov .va.med.im aging.stor age.cache. Instance; | |
| 14 | import gov .va.med.im aging.stor age.cache. exceptions .CacheExce ption; | |
| 15 | import jav a.io.IOExc eption; | |
| 16 | import jav a.io.Objec tInputStre am; | |
| 17 | import jav a.io.Objec tOutputStr eam; | |
| 18 | import jav a.io.Seria lizable; | |
| 19 | import jav a.nio.chan nels.Chann els; | |
| 20 | import jav a.nio.chan nels.Reada bleByteCha nnel; | |
| 21 | import jav a.nio.chan nels.Writa bleByteCha nnel; | |
| 22 | import org .apache.lo gging.log4 j.LogManag er; | |
| 23 | import org .apache.lo gging.log4 j.Logger; | |
| 24 | ||
| 25 | /** | |
| 26 | * This cl ass operat es in the semantics of the cac he (groups and insta nce keys) and busine ss | |
| 27 | * objects (Study). There mus t be no VA or DOD in terface sp ecific obj ects. | |
| 28 | * | |
| 29 | * Each co ncrete Cac he decorat or (derive d class) p rovides tw o regions, one for m etadata | |
| 30 | * and one for insta nces. In addition t he concret e class mu st provide access to a wrapped | |
| 31 | * Cache i nstance. | |
| 32 | * | |
| 33 | * @author
|
|
| 34 | * | |
| 35 | */ | |
| 36 | public abs tract clas s Abstract CacheDecor ator | |
| 37 | implements RealizedC ache | |
| 38 | { | |
| 39 | pr otected st atic Octet SequenceEs caping fil epathEscap ingEngine = | |
| 40 | Octe tSequenceE scaping.cr eateFilepa thLegalEsc apeEngine( ); | |
| 41 | ||
| 42 | /* * | |
| 43 | * A simple hash funct ion whose function i s just to produce | |
| 44 | * a String that can b e included in a file path and does not | |
| 45 | * include a ny special character s. | |
| 46 | * | |
| 47 | * @param va lue | |
| 48 | * @return | |
| 49 | * / | |
| 50 | pu blic stati c OctetSeq uenceEscap ing filena meOctetEsc aping = | |
| 51 | Octe tSequenceE scaping.cr eateFilena meLegalEsc apeEngine( ); | |
| 52 | ||
| 53 | /* * | |
| 54 | * If the GA ID is a PA ID (a subc lass of GA ID) then t he patient identifie r should b e accessib le, | |
| 55 | * otherwise use "Unkn ownPatient " as the p atient ide ntifier. | |
| 56 | * | |
| 57 | * If the do cumentIdIs Group flag is set th en the doc ument ID w ill be inc luded in t he groups, | |
| 58 | * otherwise it will n ot be. St udies, doc ument meta data and a other met adata incl ude the | |
| 59 | * document ID as a gr oup and th e instance key is us ually a co nstant ide ntifying t he type of data. | |
| 60 | * | |
| 61 | * @param ho meCommunit yId | |
| 62 | * @param re positoryId | |
| 63 | * @param do cumentId | |
| 64 | * @return | |
| 65 | * / | |
| 66 | pr otected st atic Strin g[] create ExternalIn stanceGrou pKeys(Glob alArtifact Identifier gaid, boo lean docum entIdIsGro up ) | |
| 67 | { | |
| 68 | if(g aid instan ceof Image URN) | |
| 69 | return documentI dIsGroup ? | |
| 70 | new Stri ng[] | |
| 71 | { | |
| 72 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getHomeCo mmunityId( )), | |
| 73 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getReposi toryUnique Id()), | |
| 74 | filenameOc tetEscapin g.escapeIl legalChara cters( ((I mageURN)ga id).getPat ientIdenti fier() ), | |
| 75 | filenameOc tetEscapin g.escapeIl legalChara cters( ((I mageURN)ga id).getStu dyId() ), | |
| 76 | filenameOc tetEscapin g.escapeIl legalChara cters( ((I mageURN)ga id).getIma geId() ), | |
| 77 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getDocume ntUniqueId ()) | |
| 78 | } : | |
| 79 | new Stri ng[] | |
| 80 | { | |
| 81 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getHomeCo mmunityId( )), | |
| 82 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getReposi toryUnique Id()), | |
| 83 | filenameOc tetEscapin g.escapeIl legalChara cters( ((I mageURN)ga id).getPat ientIdenti fier() ), | |
| 84 | filenameOc tetEscapin g.escapeIl legalChara cters( ((I mageURN)ga id).getStu dyId() ), | |
| 85 | filenameOc tetEscapin g.escapeIl legalChara cters( ((I mageURN)ga id).getIma geId() ) | |
| 86 | }; | |
| 87 | else | |
| 88 | return documentI dIsGroup ? | |
| 89 | new Stri ng[] | |
| 90 | { | |
| 91 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getHomeCo mmunityId( )), | |
| 92 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getReposi toryUnique Id()), | |
| 93 | gaid insta nceof Pati entArtifac tIdentifie r ? | |
| 94 | fi lenameOcte tEscaping. escapeIlle galCharact ers( ((Pat ientArtifa ctIdentifi er)gaid).g etPatientI dentifier( ) ) : | |
| 95 | "U nknownPati entIdentif ier", | |
| 96 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getDocume ntUniqueId ()) | |
| 97 | } : | |
| 98 | new Stri ng[] | |
| 99 | { | |
| 100 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getHomeCo mmunityId( )), | |
| 101 | filenameOc tetEscapin g.escapeIl legalChara cters(gaid .getReposi toryUnique Id()), | |
| 102 | gaid insta nceof Pati entArtifac tIdentifie r ? | |
| 103 | fi lenameOcte tEscaping. escapeIlle galCharact ers( ((Pat ientArtifa ctIdentifi er)gaid).g etPatientI dentifier( ) ) : | |
| 104 | "U nknownPati entIdentif ier" | |
| 105 | }; | |
| 106 | } | |
| 107 | ||
| 108 | pr otected st atic Strin g[] create InternalIn stanceGrou pKeys(Glob alArtifact Identifier gaid, boo lean docum entIdIsGro up ) | |
| 109 | { | |
| 110 | if(g aid instan ceof Image URN) | |
| 111 | { | |
| 112 | if(doc umentIdIsG roup) | |
| 113 | { | |
| 114 | return n ew String[ ] | |
| 115 | { | |
| 116 | file nameOctetE scaping.es capeIllega lCharacter s(gaid.get Repository UniqueId() ), | |
| 117 | file nameOctetE scaping.es capeIllega lCharacter s( ((Image URN)gaid). getThePati entIdentif ier().toSt ring() ), | |
| 118 | file nameOctetE scaping.es capeIllega lCharacter s( ((Image URN)gaid). getStudyId () ) | |
| 119 | }; | |
| 120 | } | |
| 121 | else | |
| 122 | { | |
| 123 | return n ew String[ ] | |
| 124 | { | |
| 125 | fi lenameOcte tEscaping. escapeIlle galCharact ers(gaid.g etReposito ryUniqueId ()), | |
| 126 | fi lenameOcte tEscaping. escapeIlle galCharact ers( ((Ima geURN)gaid ).getThePa tientIdent ifier().to String() ) , | |
| 127 | fi lenameOcte tEscaping. escapeIlle galCharact ers( ((Ima geURN)gaid ).getStudy Id() ), | |
| 128 | fi lenameOcte tEscaping. escapeIlle galCharact ers( ((Ima geURN)gaid ).getImage Id() ) | |
| 129 | }; | |
| 130 | ||
| 131 | } | |
| 132 | } | |
| 133 | else | |
| 134 | { | |
| 135 | String patientId entifier = "UnknownP atientIden tifier"; | |
| 136 | if(gai d instance of Abstrac tImagingUR N) | |
| 137 | { | |
| 138 | patientI dentifier = filename OctetEscap ing.escape IllegalCha racters( ( (AbstractI magingURN) gaid).getT hePatientI dentifier( ).toString ()); | |
| 139 | } | |
| 140 | else i f(gaid ins tanceof Pa tientArtif actIdentif ier) | |
| 141 | { | |
| 142 | patientI dentifier = filename OctetEscap ing.escape IllegalCha racters( ( (PatientAr tifactIden tifier)gai d).getPati entIdentif ier()); | |
| 143 | } | |
| 144 | if(doc umentIdIsG roup) | |
| 145 | { | |
| 146 | return n ew String[ ] | |
| 147 | { | |
| 148 | fi lenameOcte tEscaping. escapeIlle galCharact ers(gaid.g etReposito ryUniqueId ()), | |
| 149 | pa tientIdent ifier, | |
| 150 | fi lenameOcte tEscaping. escapeIlle galCharact ers(gaid.g etDocument UniqueId() ) | |
| 151 | }; | |
| 152 | ||
| 153 | } | |
| 154 | else | |
| 155 | { | |
| 156 | return n ew String[ ] | |
| 157 | { | |
| 158 | fi lenameOcte tEscaping. escapeIlle galCharact ers(gaid.g etReposito ryUniqueId ()), | |
| 159 | pa tientIdent ifier | |
| 160 | }; | |
| 161 | } | |
| 162 | } | |
| 163 | } | |
| 164 | ||
| 165 | /* * | |
| 166 | * | |
| 167 | * @param ga id | |
| 168 | * @return | |
| 169 | * / | |
| 170 | pr otected st atic Strin g[] create ExternalIn stanceGrou pKeys(Glob alArtifact Identifier gaid) | |
| 171 | { | |
| 172 | Stri ng[] group s = new St ring[]{ | |
| 173 | filena meOctetEsc aping.esca peIllegalC haracters( gaid.getHo meCommunit yId()), | |
| 174 | filena meOctetEsc aping.esca peIllegalC haracters( gaid.getRe positoryUn iqueId()), | |
| 175 | filena meOctetEsc aping.esca peIllegalC haracters( | |
| 176 | gaid ins tanceof Im ageURN ? ( (ImageURN) gaid).getS tudyId() : "UnknownS tudy" | |
| 177 | ) | |
| 178 | }; | |
| 179 | retu rn groups; | |
| 180 | } | |
| 181 | ||
| 182 | /* * | |
| 183 | * | |
| 184 | * @param ga id | |
| 185 | * @param qu ality TODO | |
| 186 | * @param me diaType TO DO | |
| 187 | * @return | |
| 188 | * / | |
| 189 | pr otected st atic Strin g createEx ternalImag eKey(Globa lArtifactI dentifier gaid, Stri ng quality , String m ediaType) | |
| 190 | { | |
| 191 | retu rn | |
| 192 | filena meOctetEsc aping.esca peIllegalC haracters( | |
| 193 | gaid ins tanceof Im ageURN ? ( (ImageURN) gaid).getI mageId() : gaid.getD ocumentUni queId() | |
| 194 | ) + "- " + | |
| 195 | (quali ty == null || qualit y.length() == 0 ? "" : filenam eOctetEsca ping.escap eIllegalCh aracters(q uality)) + "-" + | |
| 196 | (media Type == nu ll || medi aType.leng th() == 0 ? "" : fil enameOctet Escaping.e scapeIlleg alCharacte rs(mediaTy pe)); | |
| 197 | } | |
| 198 | ||
| 199 | pr otected st atic Strin g createDo cumentKey( GlobalArti factIdenti fier gaid) | |
| 200 | { | |
| 201 | retu rn filenam eOctetEsca ping.escap eIllegalCh aracters(g aid.getDoc umentUniqu eId()); | |
| 202 | } | |
| 203 | ||
| 204 | pr otected st atic Strin g createSt udyKey(Glo balArtifac tIdentifie r gaid){re turn "stud y.xml";} | |
| 205 | pr otected st atic Strin g createDo cumentMeta dataKey(Gl obalArtifa ctIdentifi er gaid){r eturn "doc umentMetad ata.xml";} | |
| 206 | ||
| 207 | pr otected st atic Strin g createIn ternalImag eKey(Globa lArtifactI dentifier gaid, Stri ng quality , String m ediaType) | |
| 208 | { | |
| 209 | if(g aid instan ceof BhieI mageURN) | |
| 210 | return createExt ernalImage Key(gaid, quality, m ediaType); | |
| 211 | if(g aid instan ceof Image URN) | |
| 212 | return | |
| 213 | filename OctetEscap ing.escape IllegalCha racters( ( (ImageURN) gaid).getI mageId() ) + "-" + | |
| 214 | filename OctetEscap ing.escape IllegalCha racters( q uality ) + "-" + | |
| 215 | filename OctetEscap ing.escape IllegalCha racters( m ediaType ) | |
| 216 | ; | |
| 217 | else | |
| 218 | return | |
| 219 | filename OctetEscap ing.escape IllegalCha racters( g aid.getDoc umentUniqu eId() ) + "-" + | |
| 220 | filename OctetEscap ing.escape IllegalCha racters( q uality ) + "-" + | |
| 221 | filename OctetEscap ing.escape IllegalCha racters( m ediaType ) | |
| 222 | ; | |
| 223 | } | |
| 224 | ||
| 225 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ==== | |
| 226 | // Instance Members | |
| 227 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ==== | |
| 228 | pr ivate Logg er logger = LogManag er.getLogg er(this.ge tClass()); | |
| 229 | pr otected ab stract Cac he getWrap pedCache() ; | |
| 230 | pr otected ab stract Str ing getIma geRegionNa me(); | |
| 231 | pr otected ab stract Str ing getMet adataRegio nName(); | |
| 232 | ||
| 233 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 234 | // Image Con tent Cachi ng | |
| 235 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 236 | pr otected In stance cre ateImage(S tring[] gr oups, Stri ng instanc eKey) | |
| 237 | th rows Cache Exception | |
| 238 | { | |
| 239 | retu rn getWrap pedCache() .getOrCrea teInstance ( | |
| 240 | getImage RegionName (), | |
| 241 | groups, | |
| 242 | instance Key ); | |
| 243 | } | |
| 244 | ||
| 245 | pr otected In stance get Image(Stri ng[] group s, String instanceKe y) | |
| 246 | th rows Cache Exception | |
| 247 | { | |
| 248 | retu rn getWrap pedCache() .getInstan ce( | |
| 249 | getImage RegionName (), | |
| 250 | groups, | |
| 251 | instance Key ); | |
| 252 | } | |
| 253 | ||
| 254 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 255 | // Study Met adata Cach ing | |
| 256 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 257 | ||
| 258 | pr otected vo id createS tudy( | |
| 259 | Stri ng[] group s, | |
| 260 | Stri ng groupKe y, | |
| 261 | gov. va.med.ima ging.excha nge.busine ss.Study s tudy) | |
| 262 | th rows Cache Exception | |
| 263 | { | |
| 264 | crea teMetadata (groups, g roupKey, s tudy); | |
| 265 | retu rn; | |
| 266 | } | |
| 267 | ||
| 268 | /* * | |
| 269 | * | |
| 270 | * @param gr oups | |
| 271 | * @param gr oupKey | |
| 272 | * @return | |
| 273 | * @throws C acheExcept ion | |
| 274 | * / | |
| 275 | pr otected go v.va.med.i maging.exc hange.busi ness.Study getStudy( String[] g roups, Str ing groupK ey) | |
| 276 | th rows Cache Exception | |
| 277 | { | |
| 278 | retu rn getMeta data(gov.v a.med.imag ing.exchan ge.busines s.Study.cl ass, group s, groupKe y); | |
| 279 | } | |
| 280 | ||
| 281 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 282 | // Enterpris e Exams Me tadata Cac hing | |
| 283 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 284 | ||
| 285 | pr otected vo id createP atientEnte rpriseExam s( | |
| 286 | String [] groups, | |
| 287 | String groupKey, | |
| 288 | Patien tEnterpris eExams pat ientEnterp riseExams) | |
| 289 | th rows Cache Exception | |
| 290 | { | |
| 291 | crea teMetadata (groups, g roupKey, p atientEnte rpriseExam s); | |
| 292 | retu rn; | |
| 293 | } | |
| 294 | ||
| 295 | pr otected vo id createE xamSite( | |
| 296 | String [] groups, | |
| 297 | String groupKey, | |
| 298 | ExamSi te examSit e) | |
| 299 | th rows Cache Exception | |
| 300 | { | |
| 301 | crea teMetadata (groups, g roupKey, e xamSite); | |
| 302 | retu rn; | |
| 303 | } | |
| 304 | ||
| 305 | /* * | |
| 306 | * | |
| 307 | * @param gr oups | |
| 308 | * @param gr oupKey | |
| 309 | * @return | |
| 310 | * @throws C acheExcept ion | |
| 311 | * / | |
| 312 | pr otected Pa tientEnter priseExams getPatien tEnterpris eExams(Str ing[] grou ps, String groupKey) | |
| 313 | th rows Cache Exception | |
| 314 | { | |
| 315 | retu rn getMeta data(Patie ntEnterpri seExams.cl ass, group s, groupKe y); | |
| 316 | } | |
| 317 | ||
| 318 | pr otected Ex amSite get ExamSite(S tring [] g roups, Str ing groupK ey) | |
| 319 | th rows Cache Exception | |
| 320 | { | |
| 321 | retu rn getMeta data(ExamS ite.class, groups, g roupKey); | |
| 322 | } | |
| 323 | ||
| 324 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 325 | // Document Metadata C aching | |
| 326 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 327 | @O verride | |
| 328 | pu blic void createDocu mentMetada ta(GlobalA rtifactIde ntifier ga id, Docume nt documen t) | |
| 329 | th rows Cache Exception | |
| 330 | { | |
| 331 | Stri ng[] group s = Abstra ctCacheDec orator.cre ateExterna lInstanceG roupKeys(g aid, true) ; | |
| 332 | Stri ng instanc eKey = Abs tractCache Decorator. createDocu mentMetada taKey(gaid ); | |
| 333 | ||
| 334 | crea teDocument Metadata(g roups, ins tanceKey, document); | |
| 335 | } | |
| 336 | ||
| 337 | @O verride | |
| 338 | pu blic Docum ent getDoc umentMetad ata(Global ArtifactId entifier g aid) | |
| 339 | th rows Cache Exception | |
| 340 | { | |
| 341 | Stri ng[] group s = Abstra ctCacheDec orator.cre ateExterna lInstanceG roupKeys(g aid, true) ; | |
| 342 | Stri ng instanc eKey = Abs tractCache Decorator. createDocu mentMetada taKey(gaid ); | |
| 343 | ||
| 344 | retu rn getDocu mentMetada ta(groups, instanceK ey); | |
| 345 | } | |
| 346 | ||
| 347 | // ========= ========== ========== ========== ========== ========== ========== ========== ======== | |
| 348 | // Document Caching | |
| 349 | // ========= ========== ========== ========== ========== ========== ========== ========== ======== | |
| 350 | @O verride | |
| 351 | pu blic Immut ableInstan ce createD ocumentCon tent(Globa lArtifactI dentifier gaid) | |
| 352 | th rows Cache Exception | |
| 353 | { | |
| 354 | Stri ng[] group s = Abstra ctCacheDec orator.cre ateExterna lInstanceG roupKeys(g aid, false ); | |
| 355 | Stri ng instanc eKey = Abs tractCache Decorator. createDocu mentKey(ga id); | |
| 356 | ||
| 357 | Inst ance insta nce = crea teImage(gr oups, inst anceKey); | |
| 358 | retu rn instanc e == null ? null : n ew Immutab leInstance ( instance ); | |
| 359 | } | |
| 360 | ||
| 361 | @O verride | |
| 362 | pu blic Immut ableInstan ce getDocu mentConten t(GlobalAr tifactIden tifier gai d) | |
| 363 | th rows Cache Exception | |
| 364 | { | |
| 365 | Stri ng[] group s = Abstra ctCacheDec orator.cre ateExterna lInstanceG roupKeys(g aid, false ); | |
| 366 | Stri ng instanc eKey = Abs tractCache Decorator. createDocu mentKey(ga id); | |
| 367 | ||
| 368 | Inst ance insta nce = getI mage(group s, instanc eKey); | |
| 369 | retu rn instanc e == null ? null : n ew Immutab leInstance ( instance ); | |
| 370 | } | |
| 371 | ||
| 372 | pr otected vo id createD ocumentMet adata( | |
| 373 | Stri ng[] group s, | |
| 374 | Stri ng groupKe y, | |
| 375 | gov. va.med.ima ging.excha nge.busine ss.documen ts.Documen t document ) | |
| 376 | th rows Cache Exception | |
| 377 | { | |
| 378 | crea teMetadata (groups, g roupKey, d ocument); | |
| 379 | retu rn; | |
| 380 | } | |
| 381 | ||
| 382 | /* * | |
| 383 | * @param gr oups | |
| 384 | * @param gr oupKey | |
| 385 | * @return | |
| 386 | * @throws C acheExcept ion | |
| 387 | * / | |
| 388 | pr otected go v.va.med.i maging.exc hange.busi ness.docum ents.Docum ent getDoc umentMetad ata(String [] groups, String gr oupKey) | |
| 389 | th rows Cache Exception | |
| 390 | { | |
| 391 | retu rn getMeta data(gov.v a.med.imag ing.exchan ge.busines s.document s.Document .class, gr oups, grou pKey); | |
| 392 | } | |
| 393 | ||
| 394 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 395 | // Genericiz ed Global Artifact I dentifier based meth ods | |
| 396 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 397 | @O verride | |
| 398 | pu blic <T ex tends Seri alizable> void creat e(GlobalAr tifactIden tifier gai , T object ) | |
| 399 | th rows Cache Exception | |
| 400 | { | |
| 401 | Stri ng[] group s = Abstra ctCacheDec orator.cre ateExterna lInstanceG roupKeys(g ai, false) ; | |
| 402 | Stri ng keyIden tifier = A bstractCac heDecorato r.createDo cumentKey( gai); | |
| 403 | crea teMetadata (groups, k eyIdentifi er, object ); | |
| 404 | } | |
| 405 | ||
| 406 | @O verride | |
| 407 | pu blic <T ex tends Seri alizable> T get(Clas s<T> expec tedClass, GlobalArti factIdenti fier gai) | |
| 408 | th rows Cache Exception | |
| 409 | { | |
| 410 | Stri ng[] group s = Abstra ctCacheDec orator.cre ateExterna lInstanceG roupKeys(g ai, false) ; | |
| 411 | Stri ng keyIden tifier = A bstractCac heDecorato r.createDo cumentKey( gai); | |
| 412 | ||
| 413 | retu rn getMeta data(expec tedClass, groups, ke yIdentifie r); | |
| 414 | } | |
| 415 | ||
| 416 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 417 | // Genericiz ed Metadat a Caching Methods | |
| 418 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ====== | |
| 419 | ||
| 420 | /* * | |
| 421 | * @param gr oups | |
| 422 | * @param gr oupKey | |
| 423 | * @return | |
| 424 | * @throws C acheExcept ion | |
| 425 | * / | |
| 426 | pr otected <T > T getMet adata(Clas s<T> expec tedResultC lass, Stri ng[] group s, String groupKey) | |
| 427 | th rows Cache Exception | |
| 428 | { | |
| 429 | T re sult = nul l; | |
| 430 | ||
| 431 | Read ableByteCh annel meta dataReadab le = null; | |
| 432 | Obje ctInputStr eam metada taInStream = null; | |
| 433 | try | |
| 434 | { | |
| 435 | Instan ce studyMe tadataInst ance = get WrappedCac he().getIn stance( | |
| 436 | getMetadat aRegionNam e(), | |
| 437 | groups, | |
| 438 | groupKey); | |
| 439 | ||
| 440 | if(stu dyMetadata Instance ! = null) | |
| 441 | { | |
| 442 | metadata Readable = studyMeta dataInstan ce.getRead ableChanne l(); | |
| 443 | ||
| 444 | metadata InStream = new Objec tInputStre am(Channel s.newInput Stream(met adataReada ble)); | |
| 445 | ||
| 446 | return e xpectedRes ultClass.c ast( metad ataInStrea m.readObje ct() ); | |
| 447 | } | |
| 448 | } | |
| 449 | catc h (IOExcep tion e) | |
| 450 | { | |
| 451 | e.prin tStackTrac e(); | |
| 452 | } | |
| 453 | catc h (ClassNo tFoundExce ption e) | |
| 454 | { | |
| 455 | e.prin tStackTrac e(); | |
| 456 | } | |
| 457 | fina lly | |
| 458 | { | |
| 459 | try{if (metadataI nStream != null)meta dataInStre am.close() ;} | |
| 460 | catch( Throwable t){} | |
| 461 | } | |
| 462 | ||
| 463 | retu rn result; | |
| 464 | } | |
| 465 | ||
| 466 | /* * | |
| 467 | * | |
| 468 | * @param <T > | |
| 469 | * @param gr oups | |
| 470 | * @param gr oupKey | |
| 471 | * @param do cument | |
| 472 | * @throws C acheExcept ion | |
| 473 | * / | |
| 474 | pr otected <T > void cre ateMetadat a( | |
| 475 | Stri ng[] group s, | |
| 476 | Stri ng groupKe y, | |
| 477 | T me tadata) | |
| 478 | th rows Cache Exception | |
| 479 | { | |
| 480 | Writ ableByteCh annel meta dataWritab le = null; | |
| 481 | Obje ctOutputSt ream metad ataOutStre am = null; | |
| 482 | try | |
| 483 | { | |
| 484 | if( ge tWrappedCa che().isEn abled().bo oleanValue () ) | |
| 485 | { | |
| 486 | Instance metadataI nstance = getWrapped Cache().ge tOrCreateI nstance( | |
| 487 | ge tMetadataR egionName( ), | |
| 488 | gr oups, | |
| 489 | gr oupKey); | |
| 490 | if(metad ataInstanc e != null) | |
| 491 | { | |
| 492 | metadataWr itable = m etadataIns tance.getW ritableCha nnel(); | |
| 493 | metadataOu tStream = new Object OutputStre am(Channel s.newOutpu tStream(me tadataWrit able)); | |
| 494 | ||
| 495 | metadataOu tStream.wr iteObject( metadata); | |
| 496 | } | |
| 497 | else | |
| 498 | logger.war n("Unable to write t o cache an d cache is enabled. Applicati on will co ntinue to operate wi th reduced performan ce."); | |
| 499 | } | |
| 500 | } | |
| 501 | catc h (IOExcep tion e) | |
| 502 | { | |
| 503 | e.prin tStackTrac e(); | |
| 504 | } | |
| 505 | fina lly | |
| 506 | { | |
| 507 | try{if (metadataO utStream ! = null) me tadataOutS tream.clos e();} | |
| 508 | catch( Throwable t){} | |
| 509 | } | |
| 510 | ||
| 511 | retu rn; | |
| 512 | } | |
| 513 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.