Produced by Araxis Merge on 12/5/2017 12:06:42 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\ImagingBaseWebFacade\main\src\java\gov\va\med\imaging\wado | AbstractBaseImageServlet.java | Mon Dec 4 21:34:44 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingBaseWebFacade\main\src\java\gov\va\med\imaging\wado | AbstractBaseImageServlet.java | Mon Dec 4 22:01:20 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 4 | 2074 |
| Changed | 3 | 6 |
| 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.wad o; | |
| 2 | ||
| 3 | import gov .va.med.Gl obalArtifa ctIdentifi er; | |
| 4 | import gov .va.med.Pa tientArtif actIdentif ierImpl; | |
| 5 | import gov .va.med.Pa tientIdent ifier; | |
| 6 | import gov .va.med.Ro utingToken ; | |
| 7 | import gov .va.med.Ro utingToken Impl; | |
| 8 | import gov .va.med.SE RIALIZATIO N_FORMAT; | |
| 9 | import gov .va.med.ex ceptions.R outingToke nFormatExc eption; | |
| 10 | import gov .va.med.im aging.Imag eURN; | |
| 11 | import gov .va.med.im aging.Imag ingBaseWeb FacadeRout er; | |
| 12 | import gov .va.med.im aging.Inst anceChecks umNotifica tion; | |
| 13 | import gov .va.med.im aging.chan nels.Abstr actBytePum p.TRANSFER _TYPE; | |
| 14 | import gov .va.med.im aging.chan nels.ByteS treamPump; | |
| 15 | import gov .va.med.im aging.core .FacadeRou terUtility ; | |
| 16 | import gov .va.med.im aging.core .interface s.ImageMet adataNotif ication; | |
| 17 | import gov .va.med.im aging.core .interface s.PhotoIDI nformation Notificati on; | |
| 18 | import gov .va.med.im aging.core .interface s.exceptio ns.Connect ionExcepti on; | |
| 19 | import gov .va.med.im aging.core .interface s.exceptio ns.ImageCo nversionEx ception; | |
| 20 | import gov .va.med.im aging.core .interface s.exceptio ns.ImageNe arLineExce ption; | |
| 21 | import gov .va.med.im aging.core .interface s.exceptio ns.ImageNo tCachedExc eption; | |
| 22 | import gov .va.med.im aging.core .interface s.exceptio ns.ImageNo tFoundExce ption; | |
| 23 | import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception; | |
| 24 | import gov .va.med.im aging.core .interface s.exceptio ns.Securit yCredentia lsExpiredE xception; | |
| 25 | import gov .va.med.im aging.exch ange.Image AccessLogE vent; | |
| 26 | import gov .va.med.im aging.exch ange.Image AccessLogE vent.Image AccessLogE ventType; | |
| 27 | import gov .va.med.im aging.exch ange.busin ess.Abstra ctBaseServ let; | |
| 28 | import gov .va.med.im aging.exch ange.busin ess.ImageF ormatQuali tyList; | |
| 29 | import gov .va.med.im aging.exch ange.busin ess.ImageM etadata; | |
| 30 | import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume ntRetrieve Result; | |
| 31 | import gov .va.med.im aging.exch ange.busin ess.util.E xchangeUti l; | |
| 32 | import gov .va.med.im aging.exch ange.enums .ImageForm at; | |
| 33 | import gov .va.med.im aging.exch ange.enums .ImageQual ity; | |
| 34 | import gov .va.med.im aging.tran sactioncon text.Trans actionCont ext; | |
| 35 | import gov .va.med.im aging.tran sactioncon text.Trans actionCont extFactory ; | |
| 36 | import gov .va.med.im aging.tran sactioncon text.Trans actionCont extHttpHea ders; | |
| 37 | import gov .va.med.im aging.wado .query.Wad oRequest; | |
| 38 | import gov .va.med.im aging.webs ervices.co mmon.Webse rvicesComm on; | |
| 39 | ||
| 40 | import jav a.io.IOExc eption; | |
| 41 | import jav a.io.Input Stream; | |
| 42 | import jav a.io.Outpu tStream; | |
| 43 | import jav a.util.Lis t; | |
| 44 | ||
| 45 | import jav ax.servlet .ServletEx ception; | |
| 46 | import jav ax.servlet .http.Http ServletReq uest; | |
| 47 | import jav ax.servlet .http.Http ServletRes ponse; | |
| 48 | ||
| 49 | import org .apache.lo gging.log4 j.LogManag er; | |
| 50 | import org .apache.lo gging.log4 j.Logger; | |
| 51 | ||
| 52 | /** | |
| 53 | * The abs tract root of Image providing servlets i n the VIX architectu re. | |
| 54 | * | |
| 55 | * @author
|
|
| 56 | */ | |
| 57 | public abs tract clas s Abstract BaseImageS ervlet | |
| 58 | extends Ab stractBase Servlet | |
| 59 | { | |
| 60 | pr ivate stat ic final l ong serial VersionUID = 1L; | |
| 61 | pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(Abst ractBaseIm ageServlet .class); | |
| 62 | ||
| 63 | pr otected Lo gger getLo gger() | |
| 64 | { | |
| 65 | retu rn logger; | |
| 66 | } | |
| 67 | ||
| 68 | /* * | |
| 69 | * Construct or of the object. | |
| 70 | * / | |
| 71 | pu blic Abstr actBaseIma geServlet( ) | |
| 72 | { | |
| 73 | supe r(); | |
| 74 | } | |
| 75 | ||
| 76 | /* * | |
| 77 | * Method to get the u sers site number, mu st be impl emented by extending class | |
| 78 | * @return | |
| 79 | * / | |
| 80 | pu blic abstr act String getUserSi teNumber() ; | |
| 81 | ||
| 82 | /* * | |
| 83 | * Returns i nformation about the servlet, such as | |
| 84 | * author, v ersion, an d copyrigh t. | |
| 85 | * | |
| 86 | * @return S tring info rmation ab out this s ervlet | |
| 87 | * / | |
| 88 | pu blic Strin g getServl etInfo() | |
| 89 | { | |
| 90 | retu rn "The ab stract roo t of Image providing servlets in the VIX architect ure."; | |
| 91 | } | |
| 92 | ||
| 93 | /* * | |
| 94 | * Derived s ervlets mu st impleme nt a doGet method | |
| 95 | * @see java x.servlet. http.HttpS ervlet#doG et(javax.s ervlet.htt p.HttpServ letRequest , javax.se rvlet.http .HttpServl etResponse ) | |
| 96 | * / | |
| 97 | @O verride | |
| 98 | protec ted abstra ct void do Get(HttpSe rvletReque st req, Ht tpServletR esponse re sp) | |
| 99 | th rows Servl etExceptio n, IOExcep tion; | |
| 100 | ||
| 101 | /* * | |
| 102 | * | |
| 103 | * @param re sp | |
| 104 | * @param im ageUrn | |
| 105 | * @param co ntentType | |
| 106 | * @return | |
| 107 | * @throws I OException | |
| 108 | * / | |
| 109 | pr otected lo ng streamI mageInstan ceByUrn( | |
| 110 | ImageU RN imageUr n, | |
| 111 | ImageQ uality req uestedImag eQuality, | |
| 112 | List<I mageFormat > acceptab leResponse Content, | |
| 113 | Output Stream out Stream, | |
| 114 | ImageM etadataNot ification checksumNo tification ) | |
| 115 | th rows IOExc eption, Se curityCred entialsExp iredExcept ion, Image ServletExc eption | |
| 116 | { | |
| 117 | retu rn streamI mageInstan ceByUrn(im ageUrn, re questedIma geQuality, | |
| 118 | accept ableRespon seContent, outStream , checksum Notificati on, true); | |
| 119 | } | |
| 120 | ||
| 121 | /* * | |
| 122 | * | |
| 123 | * @param im ageUrn | |
| 124 | * @param re questedIma geQuality | |
| 125 | * @param ac ceptableRe sponseCont ent | |
| 126 | * @param ou tStream | |
| 127 | * @param ch ecksumNoti fication | |
| 128 | * @param lo gImageAcce ss | |
| 129 | * @return | |
| 130 | * @throws I OException | |
| 131 | * @throws I mageServle tException | |
| 132 | * / | |
| 133 | pr otected lo ng streamI mageInstan ceByUrn( | |
| 134 | ImageU RN imageUr n, | |
| 135 | ImageQ uality req uestedImag eQuality, | |
| 136 | List<I mageFormat > acceptab leResponse Content, | |
| 137 | Output Stream out Stream, | |
| 138 | ImageM etadataNot ification checksumNo tification , | |
| 139 | boolea n logImage Access) | |
| 140 | th rows IOExc eption, Se curityCred entialsExp iredExcept ion, Image ServletExc eption | |
| 141 | { | |
| 142 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 143 | Imag eFormatQua lityList q ualityList = new Ima geFormatQu alityList( ); | |
| 144 | qual ityList.ad dAll(accep tableRespo nseContent , requeste dImageQual ity); | |
| 145 | ||
| 146 | getL ogger().in fo("Gettin g image in stance by URN [" + i mageUrn.to String() + "] with r equest for mat: " + q ualityList .getAccept String(tru e, true)); | |
| 147 | long bytesTran sferred = 0; | |
| 148 | try | |
| 149 | { | |
| 150 | bytesT ransferred = (Long)g etRouter() .getInstan ceByImageU RN( | |
| 151 | im ageUrn, | |
| 152 | qu alityList, | |
| 153 | ou tStream, | |
| 154 | ch ecksumNoti fication); | |
| 155 | getLog ger().debu g("Wrote [ " + bytesT ransferred + "] byte s to outpu t stream f or image [ " + imageU rn.toStrin g() + "]") ; | |
| 156 | ||
| 157 | ||
| 158 | if(log ImageAcces s) | |
| 159 | { | |
| 160 | if(reque stedImageQ uality != ImageQuali ty.THUMBNA IL) | |
| 161 | { | |
| 162 | ||
| 163 | try | |
| 164 | { | |
| 165 | Im ageAccessL ogEvent lo gEvent = c reateImage AccessLogE vent(image Urn); | |
| 166 | ge tLogger(). info("Got image, log ging image access (" + logEven t.getEvent Type().toS tring() + ") for " + | |
| 167 | "image [" + imag eUrn.toStr ing() + "] by [" | |
| 168 | //+ Tr ansactionC ontextFact ory.get(). getTransac tionId() + "]."); | |
| 169 | //+ th is.transac tionId + " ]."); | |
| 170 | + tran sactionCon text.getTr ansactionI d() + "]." ); | |
| 171 | ge tRouter(). logImageAc cessEventR etryable(l ogEvent); | |
| 172 | } | |
| 173 | catch(Serv letExcepti on sX) | |
| 174 | { | |
| 175 | ge tLogger(). error("Err or logging image acc ess event, " + sX.ge tMessage() , sX); | |
| 176 | } | |
| 177 | } | |
| 178 | } | |
| 179 | } | |
| 180 | catc h (ImageNe arLineExce ption inle ) | |
| 181 | { | |
| 182 | String message = "Image [" + imageUr n.toString () + "] fo und only i n off-line storage.\ n" + | |
| 183 | "Please resubmit i mage acces s request later, ope rator has been notif ied to loa d media."; | |
| 184 | getLog ger().debu g(message) ; | |
| 185 | transa ctionConte xt.setExce ptionClass Name(inle. getClass() .getSimple Name()); | |
| 186 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_C ONFLICT, m essage); | |
| 187 | } | |
| 188 | catc h (ImageCo nversionEx ception ic e) | |
| 189 | { | |
| 190 | String message = | |
| 191 | "Image [ " + imageU rn.toStrin g() + | |
| 192 | "] found in a diff erent form at and con version to the reque sted type failed.\n" + | |
| 193 | ice.getM essage(); | |
| 194 | getLog ger().debu g(message) ; | |
| 195 | transa ctionConte xt.setExce ptionClass Name(ice.g etClass(). getSimpleN ame()); | |
| 196 | // JMW 6/23/08 - if there is an imag e conversi on error, it will co me out as an interna l server e rror (500) | |
| 197 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 198 | } | |
| 199 | catc h(ImageNot FoundExcep tion infX) | |
| 200 | { | |
| 201 | String message = "Image [" + imageUr n.toString () + "] no t found.\n " + infX.g etMessage( ); | |
| 202 | //Tran sactionCon textFactor y.get().se tErrorMess age(messag e); // not needed he re | |
| 203 | getLog ger().debu g(message) ; | |
| 204 | transa ctionConte xt.setExce ptionClass Name(infX. getClass() .getSimple Name()); | |
| 205 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_N OT_FOUND, message); | |
| 206 | } | |
| 207 | catc h(MethodEx ception mX ) | |
| 208 | { | |
| 209 | String message = | |
| 210 | "Interna l server e rror in ac cessing im age [" + i mageUrn.to String() + "] \n" + | |
| 211 | mX.getMe ssage(); | |
| 212 | getLog ger().erro r(message, mX); | |
| 213 | handle MethodExce ption(mX); | |
| 214 | // the MethodExc eption is not a Secu rityCreden tialsExpir edExceptio n and must still be handled. | |
| 215 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 216 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 217 | } | |
| 218 | catc h(Exceptio n x) | |
| 219 | { | |
| 220 | String message = | |
| 221 | "Interna l server e rror in ac cessing im age [" + i mageUrn.to String() + "] \n" + | |
| 222 | x.getMes sage(); | |
| 223 | getLog ger().erro r(message, x); | |
| 224 | transa ctionConte xt.setExce ptionClass Name(x.get Class().ge tSimpleNam e()); | |
| 225 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 226 | } | |
| 227 | retu rn bytesTr ansferred; | |
| 228 | } | |
| 229 | ||
| 230 | /* * | |
| 231 | * This meth od will at tempt to c onvert the MethodExc eption int o a Securi tyCredenti alsExcepti on | |
| 232 | * and then throw the appropriat e ImageSer vletExcept ion which contains a n appropri ate error code | |
| 233 | * indicatin g the cred entials ex ception. | |
| 234 | * | |
| 235 | * If the Me thodExcept ion cannot be conver ted into a SecurityC redentials Exception then this method | |
| 236 | * does noth ing and th e MethodEx ception mu st be hand led. | |
| 237 | * | |
| 238 | * @param mX | |
| 239 | * @throws I mageServle tException | |
| 240 | * / | |
| 241 | pr otected vo id handleM ethodExcep tion(Metho dException mX) | |
| 242 | th rows Secur ityCredent ialsExpire dException | |
| 243 | { | |
| 244 | Webs ervicesCom mon.throwS ecurityCre dentialsEx ceptionFro mMethodExc eption(mX) ; | |
| 245 | /* | |
| 246 | try | |
| 247 | { | |
| 248 | Webser vicesCommo n.throwSec urityCrede ntialsExce ptionFromM ethodExcep tion(mX); | |
| 249 | } | |
| 250 | catc h(Security Credential sExpiredEx ception sc eX) | |
| 251 | { | |
| 252 | Transa ctionConte xtFactory. get().setE xceptionCl assName(sc eX.getClas s().getSim pleName()) ; | |
| 253 | // pre condition failed (41 2) error | |
| 254 | throw new Securi tyCredenti alsExpired Exception( HttpServle tResponse. SC_PRECOND ITION_FAIL ED, sceX.g etMessage( )); | |
| 255 | }*/ | |
| 256 | } | |
| 257 | ||
| 258 | pr otected Se curityCred entialsExp iredExcept ion findSe curityCred entialsExc eption(Met hodExcepti on mX) | |
| 259 | { | |
| 260 | try | |
| 261 | { | |
| 262 | Webser vicesCommo n.throwSec urityCrede ntialsExce ptionFromM ethodExcep tion(mX); | |
| 263 | } | |
| 264 | catc h(Security Credential sExpiredEx ception sc eX) | |
| 265 | { | |
| 266 | return sceX; | |
| 267 | } | |
| 268 | retu rn null; | |
| 269 | } | |
| 270 | ||
| 271 | pr ivate Imag eAccessLog Event crea teImageAcc essLogEven t(ImageURN imageUrn) | |
| 272 | { | |
| 273 | getL ogger().in fo("Router Impl.logIm ageAccess( " + imageU rn.toStrin g() + ") b y [" + Tra nsactionCo ntextFacto ry.get().g etTransact ionId() + "]."); | |
| 274 | Stri ng imageId = imageUr n.getImage Id(); | |
| 275 | Stri ng siteNum ber = imag eUrn.getOr iginatingS iteId(); | |
| 276 | ||
| 277 | bool ean dodIma ge = false ; | |
| 278 | if(E xchangeUti l.isSiteDO D(siteNumb er)) | |
| 279 | dodIma ge = true; | |
| 280 | ||
| 281 | Stri ng userSit eNumber = getUserSit eNumber(); | |
| 282 | ||
| 283 | // J MW 12/27/2 012 - this is only u sed for Ex change/XCA requests, not for i nternal VA (Clin Dis p, VRad, e tc) reques ts. As a r esult the patient ID should al ways be an ICN | |
| 284 | Imag eAccessLog Event logE vent = new ImageAcce ssLogEvent (imageId, "", | |
| 285 | imageUrn .getPatien tId(), ima geUrn.getO riginating SiteId(), System.cur rentTimeMi llis(), | |
| 286 | "", "", ImageAcces sLogEventT ype.IMAGE_ ACCESS, do dImage, us erSiteNumb er); | |
| 287 | retu rn logEven t; | |
| 288 | } | |
| 289 | ||
| 290 | pr otected in t streamTx tFileInsta nceByUrn( | |
| 291 | ImageU RN imageUr n, | |
| 292 | Output Stream out Stream, | |
| 293 | ImageM etadataNot ification metadataNo tification ) | |
| 294 | th rows IOExc eption, Im ageServlet Exception, SecurityC redentials ExpiredExc eption | |
| 295 | { | |
| 296 | getL ogger().de bug("Getti ng TXT fil e instance by URN [" + imageUr n.toString () + "]"); | |
| 297 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 298 | try | |
| 299 | { | |
| 300 | int by tesReturne d = | |
| 301 | getRoute r().getTxt FileByImag eURN(image Urn, | |
| 302 | outStream, metadataN otificatio n); | |
| 303 | getLog ger().debu g("Pushing TXT file instance b y URN [" + imageUrn. toString() + "].."); | |
| 304 | return bytesRetu rned; | |
| 305 | } | |
| 306 | catc h(ImageNot FoundExcep tion infX) | |
| 307 | { | |
| 308 | getLog ger().erro r("Error g etting TXT file for URN [" + i mageUrn.to String() + "]", infX ); | |
| 309 | String message = "Error ge tting TXT file for U RN [" + im ageUrn.toS tring() + "].\n" + i nfX.getMes sage(); | |
| 310 | transa ctionConte xt.setErro rMessage(m essage); | |
| 311 | transa ctionConte xt.setExce ptionClass Name(infX. getClass() .getSimple Name()); | |
| 312 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_N OT_FOUND, message); | |
| 313 | } | |
| 314 | catc h (ImageNe arLineExce ption inle ) | |
| 315 | { | |
| 316 | String message = "TXT file [" + imag eUrn.toStr ing() + "] found onl y in off-l ine storag e.\n" + | |
| 317 | "Please resubmit i mage acces s request later, ope rator has been notif ied to loa d media."; | |
| 318 | getLog ger().debu g(message) ; | |
| 319 | transa ctionConte xt.setExce ptionClass Name(inle. getClass() .getSimple Name()); | |
| 320 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_C ONFLICT, m essage); | |
| 321 | } | |
| 322 | catc h(MethodEx ception mX ) | |
| 323 | { | |
| 324 | String message = | |
| 325 | "Interna l server e rror in ac cessing TX T file [" + imageUrn .toString( ) + "] \n" + | |
| 326 | mX.getMe ssage(); | |
| 327 | getLog ger().debu g(message) ; | |
| 328 | handle MethodExce ption(mX); | |
| 329 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 330 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 331 | } | |
| 332 | catc h(Connecti onExceptio n mX) | |
| 333 | { | |
| 334 | String message = | |
| 335 | "Interna l server e rror in ac cessing TX T file [" + imageUrn .toString( ) + "] \n" + | |
| 336 | mX.getMe ssage(); | |
| 337 | getLog ger().debu g(message) ; | |
| 338 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 339 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 340 | } | |
| 341 | catc h(ServletE xception s X) | |
| 342 | { | |
| 343 | String message = | |
| 344 | "Interna l server e rror in ac cessing TX T file [" + imageUrn .toString( ) + "] \n" + | |
| 345 | sX.getMe ssage(); | |
| 346 | getLog ger().debu g(message) ; | |
| 347 | transa ctionConte xt.setExce ptionClass Name(sX.ge tClass().g etSimpleNa me()); | |
| 348 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 349 | } | |
| 350 | catc h(Exceptio n x) | |
| 351 | { | |
| 352 | String message = | |
| 353 | "Interna l server e rror in ac cessing TX T file [" + imageUrn .toString( ) + "] \n" + | |
| 354 | x.getMes sage(); | |
| 355 | getLog ger().erro r(message, x); | |
| 356 | transa ctionConte xt.setExce ptionClass Name(x.get Class().ge tSimpleNam e()); | |
| 357 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 358 | } | |
| 359 | } | |
| 360 | ||
| 361 | /* * | |
| 362 | * This meth od actuall y streams the image to the res ult | |
| 363 | * @param do cumentIden tifier | |
| 364 | * @return | |
| 365 | * @throws I OException | |
| 366 | * @throws I mageServle tException | |
| 367 | * / | |
| 368 | pr otected lo ng streamD ocument(Gl obalArtifa ctIdentifi er documen tIdentifie r, OutputS tream outS tream, | |
| 369 | ImageM etadataNot ification checksumNo tification ) | |
| 370 | th rows IOExc eption, Im ageServlet Exception | |
| 371 | { | |
| 372 | Docu mentRetrie veResult d ocumentRet rieveResul t = retrie veDocument (documentI dentifier, | |
| 373 | checksum Notificati on); | |
| 374 | Byte StreamPump pump = By teStreamPu mp.getByte StreamPump (); | |
| 375 | Inpu tStream in put = docu mentRetrie veResult.g etDocument Stream(); | |
| 376 | long bytes = 0 L; | |
| 377 | ||
| 378 | try | |
| 379 | { | |
| 380 | bytes = pump.xfe r(input, o utStream); | |
| 381 | } | |
| 382 | fina lly | |
| 383 | { | |
| 384 | // mus t close in put stream or causes problems in the cac he | |
| 385 | try | |
| 386 | { | |
| 387 | if(input != null) | |
| 388 | input.clos e(); | |
| 389 | } | |
| 390 | catch( IOExceptio n ioX) | |
| 391 | { | |
| 392 | getLogge r().warn(" IOExceptio n caught w hen closin g document stream '" + documen tIdentifie r.toString () + ", " + ioX.getM essage()); | |
| 393 | } | |
| 394 | } | |
| 395 | //TO DO: use ch ecksumNoti fication - need to a dd to use in command | |
| 396 | retu rn bytes; | |
| 397 | } | |
| 398 | ||
| 399 | /* * | |
| 400 | * | |
| 401 | * @deprecat ed Prefer to use ret rieveDocum ent(Global ArtifactId entifier d ocumentIde ntifier, | |
| 402 | ImageM etadataNot ification checksumNo tification ) | |
| 403 | * @param do cumentIden tifier | |
| 404 | * @return | |
| 405 | * @throws I OException | |
| 406 | * @throws I mageServle tException | |
| 407 | * / | |
| 408 | @D eprecated | |
| 409 | pr otected Do cumentRetr ieveResult retrieveD ocument(Gl obalArtifa ctIdentifi er documen tIdentifie r) | |
| 410 | th rows IOExc eption, Im ageServlet Exception | |
| 411 | { | |
| 412 | retu rn retriev eDocument( documentId entifier, null); | |
| 413 | } | |
| 414 | ||
| 415 | /* * | |
| 416 | * | |
| 417 | * @param do cumentIden tifier | |
| 418 | * @return | |
| 419 | * @throws I OException | |
| 420 | * @throws I mageServle tException | |
| 421 | * / | |
| 422 | pr otected Do cumentRetr ieveResult retrieveD ocument(Gl obalArtifa ctIdentifi er documen tIdentifie r, | |
| 423 | ImageM etadataNot ification checksumNo tification ) | |
| 424 | th rows IOExc eption, Im ageServlet Exception | |
| 425 | { | |
| 426 | getL ogger().de bug("Getti ng Documen t instance by identi fier [" + documentId entifier.t oString() + "]"); | |
| 427 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 428 | try | |
| 429 | { | |
| 430 | if(che cksumNotif ication == null) | |
| 431 | return g etRouter() .getDocume nt(documen tIdentifie r); | |
| 432 | else | |
| 433 | return g etRouter() .getDocume nt(documen tIdentifie r, checksu mNotificat ion); | |
| 434 | } | |
| 435 | catc h(ImageNot FoundExcep tion infX) | |
| 436 | { | |
| 437 | getLog ger().erro r("Error g etting Doc ument inst ance for U RN [" + do cumentIden tifier.toS tring() + "]", infX) ; | |
| 438 | String message = "Error ge tting Docu ment insta nce for UR N [" + doc umentIdent ifier.toSt ring() + " ].\n" + in fX.getMess age(); | |
| 439 | transa ctionConte xt.setErro rMessage(m essage); | |
| 440 | transa ctionConte xt.setExce ptionClass Name(infX. getClass() .getSimple Name()); | |
| 441 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_N OT_FOUND, message); | |
| 442 | } | |
| 443 | catc h(MethodEx ception mX ) | |
| 444 | { | |
| 445 | String message = | |
| 446 | "Interna l server e rror in ac cessing Do cument ins tance [" + documentI dentifier. toString() + "] \n" + | |
| 447 | mX.getMe ssage(); | |
| 448 | getLog ger().debu g(message) ; | |
| 449 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 450 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 451 | } | |
| 452 | catc h(Connecti onExceptio n mX) | |
| 453 | { | |
| 454 | String message = | |
| 455 | "Interna l server e rror in ac cessing Do cument ins tance [" + documentI dentifier. toString() + "] \n" + | |
| 456 | mX.getMe ssage(); | |
| 457 | getLog ger().debu g(message) ; | |
| 458 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 459 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 460 | } | |
| 461 | catc h(ServletE xception s X) | |
| 462 | { | |
| 463 | String message = | |
| 464 | "Interna l server e rror in ac cessing Do cument ins tance [" + documentI dentifier. toString() + "] \n" + | |
| 465 | sX.getMe ssage(); | |
| 466 | getLog ger().debu g(message) ; | |
| 467 | transa ctionConte xt.setExce ptionClass Name(sX.ge tClass().g etSimpleNa me()); | |
| 468 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 469 | } | |
| 470 | } | |
| 471 | ||
| 472 | /* * | |
| 473 | * Given a s ite number and a pat ient ICN, get a phot o ID of th e patient and | |
| 474 | * stream it to the gi ven output stream. | |
| 475 | * | |
| 476 | * @param si teNumber | |
| 477 | * @param pa tientIcn | |
| 478 | * @param ou tStream | |
| 479 | * @throws I OException | |
| 480 | * @throws I mageServle tException | |
| 481 | * / | |
| 482 | pr otected lo ng streamP atientIdIm ageByPatie ntIcn( | |
| 483 | String siteNumbe r, | |
| 484 | Patien tIdentifie r patientI dentifier, | |
| 485 | PhotoI DInformati onNotifica tion photo IdInformat ionNotific ation, | |
| 486 | Output Stream out Stream) | |
| 487 | th rows IOExc eption, Se curityCred entialsExp iredExcept ion, Image ServletExc eption | |
| 488 | { | |
| 489 | getL ogger().de bug("Getti ng patient ID file i nstance by patient I CN [" + pa tientIdent ifier + "] "); | |
| 490 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 491 | long bytesTran sferred = 0; | |
| 492 | try | |
| 493 | { | |
| 494 | InputS tream pati entIdInStr eam = null ; | |
| 495 | if(pho toIdInform ationNotif ication == null) | |
| 496 | { | |
| 497 | patientI dInStream = getRoute r().getPat ientIdenti ficationIm age(patien tIdentifie r, | |
| 498 | RoutingTok enImpl.cre ateVADocum entSite(si teNumber)) ; | |
| 499 | } | |
| 500 | else | |
| 501 | { | |
| 502 | patientI dInStream = getRoute r().getPat ientIdenti ficationIm age(patien tIdentifie r, | |
| 503 | RoutingTok enImpl.cre ateVADocum entSite(si teNumber), | |
| 504 | photoIdInf ormationNo tification ); | |
| 505 | } | |
| 506 | ||
| 507 | if (pa tientIdInS tream == n ull) | |
| 508 | { | |
| 509 | String m essage = " No patient photo ID available for [" + p atientIden tifier + " ]."; | |
| 510 | Transact ionContext Factory.ge t().setErr orMessage( message); | |
| 511 | getLogge r().debug( message); | |
| 512 | throw ne w ImageSer vletExcept ion(HttpSe rvletRespo nse.SC_NOT _FOUND, me ssage); | |
| 513 | } | |
| 514 | else // SUCCE SS (SC_OK) -- 200 | |
| 515 | { | |
| 516 | String m essage = " Pushing pa tient phot o ID for [ " + patien tIdentifie r + "]."; | |
| 517 | getLogge r().debug( message); | |
| 518 | ||
| 519 | ByteStre amPump pum p = ByteSt reamPump.g etByteStre amPump(TRA NSFER_TYPE .FileToNet work); | |
| 520 | ||
| 521 | bytesTra nsferred = pump.xfer (patientId InStream, outStream) ; | |
| 522 | patientI dInStream. close(); | |
| 523 | } | |
| 524 | } | |
| 525 | catc h (ImageNe arLineExce ption inle ) | |
| 526 | { | |
| 527 | String message = "Patient ID photo f or [" + pa tientIdent ifier + "] found onl y in off-l ine storag e.\n" + | |
| 528 | "Please resubmit i mage acces s request later, ope rator has been notif ied to loa d media."; | |
| 529 | getLog ger().debu g(message) ; | |
| 530 | transa ctionConte xt.setExce ptionClass Name(inle. getClass() .getSimple Name()); | |
| 531 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_C ONFLICT, m essage); | |
| 532 | } | |
| 533 | catc h (ImageNo tFoundExce ption inle ) | |
| 534 | { | |
| 535 | String message = "Patient ID photo f or [" + pa tientIdent ifier + "] from site [" + site Number + " ] not foun d."; | |
| 536 | getLog ger().debu g(message) ; | |
| 537 | transa ctionConte xt.setExce ptionClass Name(inle. getClass() .getSimple Name()); | |
| 538 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_N OT_FOUND, message); | |
| 539 | } | |
| 540 | catc h(MethodEx ception mX ) | |
| 541 | { | |
| 542 | String message = | |
| 543 | "Interna l server e rror in ge tting pati ent ID pho to [" + pa tientIdent ifier + "] \n" + | |
| 544 | mX.getMe ssage(); | |
| 545 | getLog ger().debu g(message) ; | |
| 546 | handle MethodExce ption(mX); | |
| 547 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 548 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 549 | } | |
| 550 | catc h(Connecti onExceptio n mX) | |
| 551 | { | |
| 552 | String message = | |
| 553 | "Interna l server e rror in ge tting pati ent ID pho to [" + pa tientIdent ifier + "] \n" + | |
| 554 | mX.getMe ssage(); | |
| 555 | getLog ger().debu g(message) ; | |
| 556 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 557 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_B AD_GATEWAY , message) ; | |
| 558 | } | |
| 559 | catc h(ServletE xception s X) | |
| 560 | { | |
| 561 | String message = | |
| 562 | "Interna l server e rror in ge tting pati ent ID pho to [" + pa tientIdent ifier + "] \n" + | |
| 563 | sX.getMe ssage(); | |
| 564 | getLog ger().debu g(message) ; | |
| 565 | transa ctionConte xt.setExce ptionClass Name(sX.ge tClass().g etSimpleNa me()); | |
| 566 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 567 | } | |
| 568 | catc h (Routing TokenForma tException rtfX) | |
| 569 | { | |
| 570 | String message = | |
| 571 | "Interna l server e rror in ge tting pati ent ID pho to [" + pa tientIdent ifier + "] \n" + | |
| 572 | rtfX.get Message(); | |
| 573 | getLog ger().debu g(message) ; | |
| 574 | transa ctionConte xt.setExce ptionClass Name(rtfX. getClass() .getSimple Name()); | |
| 575 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 576 | } | |
| 577 | retu rn bytesTr ansferred; | |
| 578 | } | |
| 579 | ||
| 580 | pr otected lo ng streamP atientIdIm ageByPatie ntIcn( | |
| 581 | Stri ng siteNum ber, | |
| 582 | Pati entIdentif ier patien tIdentifie r, | |
| 583 | Outp utStream o utStream) | |
| 584 | th rows IOExc eption, Se curityCred entialsExp iredExcept ion, Image ServletExc eption | |
| 585 | { | |
| 586 | retu rn streamP atientIdIm ageByPatie ntIcn(site Number, pa tientIdent ifier, nul l, outStre am); | |
| 587 | } | |
| 588 | ||
| 589 | /* * | |
| 590 | * Initializ e the thre ad local t ransaction context f rom the Wa doRequest | |
| 591 | * @param wa doRequest | |
| 592 | * @throws R outingToke nFormatExc eption | |
| 593 | * / | |
| 594 | pr otected vo id initTra nsactionCo ntext(Wado Request wa doRequest) | |
| 595 | th rows Routi ngTokenFor matExcepti on | |
| 596 | { | |
| 597 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 598 | tran sactionCon text.setQu eryFilter( "n/a"); | |
| 599 | Imag eQuality i mageQualit y = ImageQ uality.get ImageQuali ty( wadoRe quest.getW adoQuery() .getImageQ ualityValu e() ); | |
| 600 | Imag eURN image URN = wado Request == null ? nu ll : wadoR equest.get WadoQuery( ).getInsta nceUrn(); | |
| 601 | Glob alArtifact Identifier gai = wad oRequest = = null ? n ull : wado Request.ge tWadoQuery ().getGlob alArtifact Identifier (); | |
| 602 | tran sactionCon text.setQu ality(imag eQuality = = null ? I mageQualit y.THUMBNAI L.toString () : image Quality.na me()); | |
| 603 | tran sactionCon text.setQu eryFilter( "n/a"); | |
| 604 | ||
| 605 | // i f the prot ocolOverri de and tar getSite we re passed in the que ry string then | |
| 606 | // s tuff them onto the t ransaction context. | |
| 607 | // T hese are f or testing , NOT prod uction. | |
| 608 | Stri ng targetS ite = wado Request.ge tParsedHtt pHeader(). getMiscReq uestHeader ("targetSi te"); | |
| 609 | Stri ng protoco lOverride = wadoRequ est.getPar sedHttpHea der().getM iscRequest Header("pr otocolOver ride"); | |
| 610 | if(t argetSite != null && targetSit e.length() > 0 && pr otocolOver ride != nu ll && prot ocolOverri de.length( ) > 0) | |
| 611 | { | |
| 612 | Routin gToken rou tingToken = RoutingT okenImpl.c reateVARad iologySite (targetSit e); | |
| 613 | transa ctionConte xt.setOver rideProtoc ol(protoco lOverride) ; | |
| 614 | transa ctionConte xt.setOver rideRoutin gToken(rou tingToken) ; | |
| 615 | getLog ger().warn ("Protocol override and target server ar e specifie d in the q uery strin g. This a ctivates t est code a nd should never be s een in pro duction.") ; | |
| 616 | } | |
| 617 | ||
| 618 | if ( imageURN ! = null) | |
| 619 | { | |
| 620 | String patientIc n = ""; | |
| 621 | String imageUrnA sString = ""; | |
| 622 | // ori ginating s ite id mea ns locatio n where th e image is coming fr om | |
| 623 | //TODO : look at this logic more clos ely to mak e more gen eric for c ommon prov iders | |
| 624 | patien tIcn = ima geURN.getP atientId() ; // no lo nger encod e the pati ent ICN | |
| 625 | imageU rnAsString = Transac tionContex tFactory.d ecodeUrnFo rLogging(i mageURN);/ / decodeD odUrnForLo gging(imag eURN.toStr ing()); | |
| 626 | ||
| 627 | ||
| 628 | transa ctionConte xt.setPati entID(pati entIcn); | |
| 629 | transa ctionConte xt.setUrn( imageUrnAs String); | |
| 630 | transa ctionConte xt.setModa lity(image URN.getIma geModality ()); | |
| 631 | } | |
| 632 | else if(gai != null) | |
| 633 | { | |
| 634 | transa ctionConte xt.setUrn( gai.toStri ng(SERIALI ZATION_FOR MAT.RAW)); | |
| 635 | if(gai instanceo f PatientA rtifactIde ntifierImp l) | |
| 636 | { | |
| 637 | PatientA rtifactIde ntifierImp l pai = (P atientArti factIdenti fierImpl)g ai; | |
| 638 | transact ionContext .setPatien tID(pai.ge tPatientId entifier() ); | |
| 639 | } | |
| 640 | } | |
| 641 | tran sactionCon text.setRe questType( "image tra nsfer"); | |
| 642 | } | |
| 643 | ||
| 644 | /* * | |
| 645 | * Destructi on of the servlet. < br> | |
| 646 | * / | |
| 647 | pu blic void destroy() | |
| 648 | { | |
| 649 | supe r.destroy( ); | |
| 650 | } | |
| 651 | ||
| 652 | /* * | |
| 653 | * An except ion class that is us ed by this class and its deriv ations | |
| 654 | * to notify of error conditions . | |
| 655 | * | |
| 656 | * @author
|
|
| 657 | * | |
| 658 | * / | |
| 659 | pu blic class ImageServ letExcepti on | |
| 660 | ex tends Exce ption | |
| 661 | { | |
| 662 | priv ate static final lon g serialVe rsionUID = 1L; | |
| 663 | priv ate final int respon seCode; | |
| 664 | ||
| 665 | Imag eServletEx ception(in t response Code, Stri ng message ) | |
| 666 | { | |
| 667 | supe r(message) ; | |
| 668 | this .responseC ode = resp onseCode; | |
| 669 | } | |
| 670 | ||
| 671 | publ ic int get ResponseCo de() | |
| 672 | { | |
| 673 | retu rn respons eCode; | |
| 674 | } | |
| 675 | } | |
| 676 | ||
| 677 | pr otected lo ng streamE xamImageIn stanceFrom CacheByUrn (ImageURN imageUrn, | |
| 678 | Imag eQuality r equestedIm ageQuality , | |
| 679 | List <ImageForm at> accept ableRespon seContent, | |
| 680 | Outp utStream o utStream, | |
| 681 | Imag eMetadataN otificatio n checksum Notificati on) | |
| 682 | th rows IOExc eption, Se curityCred entialsExp iredExcept ion, Image ServletExc eption | |
| 683 | { | |
| 684 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 685 | Imag eFormatQua lityList q ualityList = new Ima geFormatQu alityList( ); | |
| 686 | qual ityList.ad dAll(accep tableRespo nseContent , requeste dImageQual ity); | |
| 687 | ||
| 688 | getL ogger().in fo("Gettin g exam ima ge instanc e from cac he by URN [" + image Urn.toStri ng() + "] with reque st format: " + quali tyList.get AcceptStri ng(true, t rue)); | |
| 689 | long bytesTran sferred = 0; | |
| 690 | try | |
| 691 | { | |
| 692 | bytesT ransferred = (Long)g etRouter() .getExamIn stanceFrom CacheByIma geUrn( | |
| 693 | im ageUrn, | |
| 694 | ch ecksumNoti fication, | |
| 695 | ou tStream, | |
| 696 | qu alityList) ; | |
| 697 | getLog ger().debu g("Wrote [ " + bytesT ransferred + "] byte s to outpu t stream f or exam im age [" + i mageUrn.to String() + "]"); | |
| 698 | } | |
| 699 | // n ot doing i mage conve rsion for this call, only poss ible excep tion is im age not ca ched or me thod excep tion | |
| 700 | catc h(ImageNot CachedExce ption incX ) | |
| 701 | { | |
| 702 | String message = "Image [" + imageUr n.toString () + "] no t found in cache.\n" + incX.ge tMessage() ; | |
| 703 | getLog ger().debu g(message) ; | |
| 704 | transa ctionConte xt.setExce ptionClass Name(incX. getClass() .getSimple Name()); | |
| 705 | // sen ding a 404 error whe n image no t in the c ache | |
| 706 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_N OT_FOUND, message); | |
| 707 | } | |
| 708 | catc h(MethodEx ception mX ) | |
| 709 | { | |
| 710 | String message = | |
| 711 | "Interna l server e rror in ac cessing im age [" + i mageUrn.to String() + "] \n" + | |
| 712 | mX.getMe ssage(); | |
| 713 | getLog ger().erro r(message, mX); | |
| 714 | handle MethodExce ption(mX); | |
| 715 | // the MethodExc eption is not a Secu rityCreden tialsExpir edExceptio n and must still be handled. | |
| 716 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 717 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 718 | } | |
| 719 | catc h(Exceptio n x) | |
| 720 | { | |
| 721 | String message = | |
| 722 | "Interna l server e rror in ac cessing im age [" + i mageUrn.to String() + "] \n" + | |
| 723 | x.getMes sage(); | |
| 724 | getLog ger().debu g(message) ; | |
| 725 | transa ctionConte xt.setExce ptionClass Name(x.get Class().ge tSimpleNam e()); | |
| 726 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 727 | } | |
| 728 | retu rn bytesTr ansferred; | |
| 729 | } | |
| 730 | ||
| 731 | /* * | |
| 732 | * | |
| 733 | * @param im ageUrn | |
| 734 | * @param re questedIma geQuality | |
| 735 | * @param ac ceptableRe sponseCont ent | |
| 736 | * @param ou tStream | |
| 737 | * @param ch ecksumNoti fication | |
| 738 | * @param al lowedFromC ache | |
| 739 | * @return | |
| 740 | * @throws I OException | |
| 741 | * @throws S ecurityCre dentialsEx piredExcep tion | |
| 742 | * @throws I mageServle tException | |
| 743 | * / | |
| 744 | pr otected lo ng streamE xamImageIn stanceByUr n( | |
| 745 | Imag eURN image Urn, | |
| 746 | Imag eQuality r equestedIm ageQuality , | |
| 747 | List <ImageForm at> accept ableRespon seContent, | |
| 748 | Outp utStream o utStream, | |
| 749 | Imag eMetadataN otificatio n checksum Notificati on, | |
| 750 | bool ean allowe dFromCache ) | |
| 751 | th rows IOExc eption, Se curityCred entialsExp iredExcept ion, Image ServletExc eption | |
| 752 | { | |
| 753 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 754 | Imag eFormatQua lityList q ualityList = new Ima geFormatQu alityList( ); | |
| 755 | qual ityList.ad dAll(accep tableRespo nseContent , requeste dImageQual ity); | |
| 756 | ||
| 757 | getL ogger().in fo("Gettin g exam ima ge instanc e by URN [ " + imageU rn.toStrin g() + "] w ith reques t format: " + qualit yList.getA cceptStrin g(true, tr ue)); | |
| 758 | long bytesTran sferred = 0; | |
| 759 | try | |
| 760 | { | |
| 761 | if(all owedFromCa che) | |
| 762 | { | |
| 763 | bytesTra nsferred = (Long)get Router().g etExamInst anceByImag eUrn( | |
| 764 | imag eUrn, | |
| 765 | chec ksumNotifi cation, | |
| 766 | outS tream, | |
| 767 | qual ityList); | |
| 768 | } | |
| 769 | else | |
| 770 | { | |
| 771 | bytesTra nsferred = (Long)get Router().g etExamInst anceByImag eUrnNotFro mCache( | |
| 772 | im ageUrn, | |
| 773 | ch ecksumNoti fication, | |
| 774 | ou tStream, | |
| 775 | qu alityList) ; | |
| 776 | } | |
| 777 | getLog ger().debu g("Wrote [ " + bytesT ransferred + "] byte s to outpu t stream f or exam im age [" + i mageUrn.to String() + "]"); | |
| 778 | } | |
| 779 | catc h (ImageNe arLineExce ption inle ) | |
| 780 | { | |
| 781 | String message = "Image [" + imageUr n.toString () + "] fo und only i n off-line storage.\ n" + | |
| 782 | "Please resubmit i mage acces s request later, ope rator has been notif ied to loa d media."; | |
| 783 | getLog ger().debu g(message) ; | |
| 784 | transa ctionConte xt.setExce ptionClass Name(inle. getClass() .getSimple Name()); | |
| 785 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_C ONFLICT, m essage); | |
| 786 | } | |
| 787 | catc h (ImageCo nversionEx ception ic e) | |
| 788 | { | |
| 789 | String message = | |
| 790 | "Image [ " + imageU rn.toStrin g() + | |
| 791 | "] found in a diff erent form at and con version to the reque sted type failed.\n" + | |
| 792 | ice.getM essage(); | |
| 793 | getLog ger().debu g(message) ; | |
| 794 | transa ctionConte xt.setExce ptionClass Name(ice.g etClass(). getSimpleN ame()); | |
| 795 | // JMW 6/23/08 - if there is an imag e conversi on error, it will co me out as an interna l server e rror (500) | |
| 796 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 797 | } | |
| 798 | catc h(ImageNot FoundExcep tion infX) | |
| 799 | { | |
| 800 | String message = "Image [" + imageUr n.toString () + "] no t found.\n " + infX.g etMessage( ); | |
| 801 | //Tran sactionCon textFactor y.get().se tErrorMess age(messag e); // not needed he re | |
| 802 | getLog ger().debu g(message) ; | |
| 803 | transa ctionConte xt.setExce ptionClass Name(infX. getClass() .getSimple Name()); | |
| 804 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_N OT_FOUND, message); | |
| 805 | } | |
| 806 | catc h(MethodEx ception mX ) | |
| 807 | { | |
| 808 | String message = | |
| 809 | "Interna l server e rror in ac cessing im age [" + i mageUrn.to String() + "] \n" + | |
| 810 | mX.getMe ssage(); | |
| 811 | getLog ger().erro r(message, mX); | |
| 812 | handle MethodExce ption(mX); | |
| 813 | // the MethodExc eption is not a Secu rityCreden tialsExpir edExceptio n and must still be handled. | |
| 814 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 815 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 816 | } | |
| 817 | catc h(Exceptio n x) | |
| 818 | { | |
| 819 | String message = | |
| 820 | "Interna l server e rror in ac cessing im age [" + i mageUrn.to String() + "] \n" + | |
| 821 | x.getMes sage(); | |
| 822 | getLog ger().debu g(message) ; | |
| 823 | transa ctionConte xt.setExce ptionClass Name(x.get Class().ge tSimpleNam e()); | |
| 824 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 825 | } | |
| 826 | retu rn bytesTr ansferred; | |
| 827 | } | |
| 828 | ||
| 829 | /* * | |
| 830 | * Get the i mage metad ata (to sa tisfy an H TTP HEAD r equest). | |
| 831 | * | |
| 832 | * @param im ageUrn | |
| 833 | * @param re questedIma geQuality | |
| 834 | * @param ac ceptableRe sponseCont ent | |
| 835 | * @param al lowedFromC ache | |
| 836 | * @return | |
| 837 | * / | |
| 838 | pr otected Im ageMetadat a getImage MetadataBy URN( | |
| 839 | Imag eURN image Urn, | |
| 840 | Imag eQuality r equestedIm ageQuality , | |
| 841 | List <ImageForm at> accept ableRespon seContent, | |
| 842 | bool ean requir eFromCache , | |
| 843 | bool ean allowe dFromCache ) | |
| 844 | th rows IOExc eption, Se curityCred entialsExp iredExcept ion, Image ServletExc eption | |
| 845 | { | |
| 846 | Imag eMetadata result = n ull; | |
| 847 | Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get(); | |
| 848 | Imag eFormatQua lityList r equestedFo rmatQualit y = new Im ageFormatQ ualityList (); | |
| 849 | requ estedForma tQuality.a ddAll(acce ptableResp onseConten t, request edImageQua lity); | |
| 850 | ||
| 851 | getL ogger().in fo("Gettin g exam ima ge instanc e by URN [ " + imageU rn.toStrin g() + "] w ith reques t format: " + reques tedFormatQ uality.get AcceptStri ng(true, t rue)); | |
| 852 | ||
| 853 | try { | |
| 854 | result = getRout er().headI nstanceByI mageUrnVer bose(image Urn, reque stedFormat Quality, n ull, false , false, t rue); | |
| 855 | } | |
| 856 | catc h (ImageNe arLineExce ption inle ) | |
| 857 | { | |
| 858 | String message = "Image [" + imageUr n.toString () + "] fo und only i n off-line storage.\ n" + | |
| 859 | "Please resubmit i mage acces s request later, ope rator has been notif ied to loa d media."; | |
| 860 | getLog ger().debu g(message) ; | |
| 861 | transa ctionConte xt.setExce ptionClass Name(inle. getClass() .getSimple Name()); | |
| 862 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_C ONFLICT, m essage); | |
| 863 | } | |
| 864 | catc h (ImageCo nversionEx ception ic e) | |
| 865 | { | |
| 866 | String message = | |
| 867 | "Image [ " + imageU rn.toStrin g() + | |
| 868 | "] found in a diff erent form at and con version to the reque sted type failed.\n" + | |
| 869 | ice.getM essage(); | |
| 870 | getLog ger().debu g(message) ; | |
| 871 | transa ctionConte xt.setExce ptionClass Name(ice.g etClass(). getSimpleN ame()); | |
| 872 | // JMW 6/23/08 - if there is an imag e conversi on error, it will co me out as an interna l server e rror (500) | |
| 873 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 874 | } | |
| 875 | catc h(ImageNot FoundExcep tion infX) | |
| 876 | { | |
| 877 | String message = "Image [" + imageUr n.toString () + "] no t found.\n " + infX.g etMessage( ); | |
| 878 | //Tran sactionCon textFactor y.get().se tErrorMess age(messag e); // not needed he re | |
| 879 | getLog ger().debu g(message) ; | |
| 880 | transa ctionConte xt.setExce ptionClass Name(infX. getClass() .getSimple Name()); | |
| 881 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_N OT_FOUND, message); | |
| 882 | } | |
| 883 | catc h(MethodEx ception mX ) | |
| 884 | { | |
| 885 | String message = | |
| 886 | "Interna l server e rror in ac cessing im age [" + i mageUrn.to String() + "] \n" + | |
| 887 | mX.getMe ssage(); | |
| 888 | getLog ger().erro r(message, mX); | |
| 889 | handle MethodExce ption(mX); | |
| 890 | // the MethodExc eption is not a Secu rityCreden tialsExpir edExceptio n and must still be handled. | |
| 891 | transa ctionConte xt.setExce ptionClass Name(mX.ge tClass().g etSimpleNa me()); | |
| 892 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 893 | } | |
| 894 | catc h(Exceptio n x) | |
| 895 | { | |
| 896 | String message = | |
| 897 | "Interna l server e rror in ac cessing im age [" + i mageUrn.to String() + "] \n" + | |
| 898 | x.getMes sage(); | |
| 899 | getLog ger().debu g(message) ; | |
| 900 | transa ctionConte xt.setExce ptionClass Name(x.get Class().ge tSimpleNam e()); | |
| 901 | throw new ImageS ervletExce ption(Http ServletRes ponse.SC_I NTERNAL_SE RVER_ERROR , message) ; | |
| 902 | } | |
| 903 | ||
| 904 | retu rn result; | |
| 905 | } | |
| 906 | ||
| 907 | pr otected sy nchronized ImagingBa seWebFacad eRouter ge tRouter() | |
| 908 | th rows Servl etExceptio n | |
| 909 | { | |
| 910 | Imag ingBaseWeb FacadeRout er router; | |
| 911 | try | |
| 912 | { | |
| 913 | router = FacadeR outerUtili ty.getFaca deRouter(I magingBase WebFacadeR outer.clas s); | |
| 914 | } | |
| 915 | catc h (Excepti on x) | |
| 916 | { | |
| 917 | logger .error("Ex ception ge tting the facade rou ter implem entation." , x); | |
| 918 | return null; | |
| 919 | } | |
| 920 | ||
| 921 | retu rn router; | |
| 922 | } | |
| 923 | ||
| 924 | /* * | |
| 925 | * @deprecat ed This is no longer used, use MetadataN otificatio n instead | |
| 926 | * / | |
| 927 | @D eprecated | |
| 928 | pu blic class ChecksumN otificatio n | |
| 929 | im plements I nstanceChe cksumNotif ication | |
| 930 | { | |
| 931 | priv ate HttpSe rvletRespo nse resp; | |
| 932 | ||
| 933 | publ ic Checksu mNotificat ion(HttpSe rvletRespo nse resp) | |
| 934 | { | |
| 935 | this.r esp = resp ; | |
| 936 | } | |
| 937 | ||
| 938 | publ ic void in stanceChec ksum(Strin g checksum Value) | |
| 939 | { | |
| 940 | if(che cksumValue != null) | |
| 941 | resp.add Header(Tra nsactionCo ntextHttpH eaders.htt pHeaderChe cksum, che cksumValue ); | |
| 942 | } | |
| 943 | ||
| 944 | } | |
| 945 | ||
| 946 | /* * | |
| 947 | * Metadata notificati on to set properties of the HT TP respons e that ind icate | |
| 948 | * key field s of the r esponded i mage. This includes setting th e checksum , | |
| 949 | * image con tent type, content l ength and optionally the image quality a nd the ful l type | |
| 950 | * of the im age (appli cable if D ICOM to in clude the sub type) | |
| 951 | * @author
|
|
| 952 | * | |
| 953 | * / | |
| 954 | pu blic class MetadataN otificatio n | |
| 955 | im plements I mageMetada taNotifica tion | |
| 956 | { | |
| 957 | priv ate final HttpServle tResponse resp; | |
| 958 | priv ate final boolean in cludeCusto mHeaders; | |
| 959 | ||
| 960 | publ ic Metadat aNotificat ion(HttpSe rvletRespo nse resp, boolean in cludeCusto mHeaders) | |
| 961 | { | |
| 962 | this.r esp = resp ; | |
| 963 | this.i ncludeCust omHeaders = includeC ustomHeade rs; | |
| 964 | } | |
| 965 | ||
| 966 | /** | |
| 967 | * C onstructor that does not inclu de custom headers in the respo nse | |
| 968 | * @ param resp | |
| 969 | */ | |
| 970 | publ ic Metadat aNotificat ion(HttpSe rvletRespo nse resp) | |
| 971 | { | |
| 972 | this.r esp = resp ; | |
| 973 | this.i ncludeCust omHeaders = false; | |
| 974 | } | |
| 975 | ||
| 976 | @Ove rride | |
| 977 | publ ic void im ageMetadat a(String c hecksumVal ue, | |
| 978 | ImageFor mat imageF ormat, int fileSize, ImageQual ity imageQ uality) | |
| 979 | { | |
| 980 | Transa ctionConte xt transac tionContex t = Transa ctionConte xtFactory. get(); | |
| 981 | if(che cksumValue != null) | |
| 982 | { | |
| 983 | // in so me cases t his was ge tting call ed twice o n a single image res ponse, che ck for an existing | |
| 984 | // check sum value and update it if it exists | |
| 985 | if(resp. containsHe ader(Trans actionCont extHttpHea ders.httpH eaderCheck sum)) | |
| 986 | { | |
| 987 | logger.war n("Header '" + Trans actionCont extHttpHea ders.httpH eaderCheck sum + "' a lready has value, up dating to new value '" + check sumValue + "'."); | |
| 988 | resp.setHe ader(Trans actionCont extHttpHea ders.httpH eaderCheck sum, check sumValue); | |
| 989 | } | |
| 990 | else | |
| 991 | { | |
| 992 | resp.addHe ader(Trans actionCont extHttpHea ders.httpH eaderCheck sum, check sumValue); | |
| 993 | } | |
| 994 | } | |
| 995 | if(ima geFormat ! = null) | |
| 996 | { | |
| 997 | resp.set ContentTyp e(imageFor mat.getMim e()); | |
| 998 | if(inclu deCustomHe aders) | |
| 999 | { | |
| 1000 | resp.addHe ader(Trans actionCont extHttpHea ders.httpH eaderVista ImageForma t, | |
| 1001 | im ageFormat. getMimeWit hEnclosedM ime()); | |
| 1002 | } | |
| 1003 | transact ionContext .setFacade ImageForma tSent(imag eFormat.to String()); | |
| 1004 | } | |
| 1005 | if(ima geQuality != null) | |
| 1006 | { | |
| 1007 | if(inclu deCustomHe aders) | |
| 1008 | { | |
| 1009 | resp.addHe ader(Trans actionCont extHttpHea ders.httpH eaderImage Quality, | |
| 1010 | im ageQuality .getCanoni cal() + "" ); | |
| 1011 | } | |
| 1012 | transact ionContext .setFacade ImageQuali tySent(ima geQuality. toString() ); | |
| 1013 | } | |
| 1014 | if(inc ludeCustom Headers) | |
| 1015 | { | |
| 1016 | String m achineName = transac tionContex t.getMachi neName(); | |
| 1017 | if(machi neName == null) | |
| 1018 | machineNam e = "<unkn own>"; | |
| 1019 | resp.add Header(Tra nsactionCo ntextHttpH eaders.htt pHeaderMac hineName, machineNam e); | |
| 1020 | ||
| 1021 | String c acheFilena me = trans actionCont ext.getCac heFilename (); | |
| 1022 | if (cach eFilename != null) | |
| 1023 | resp.addHe ader(Trans actionCont extHttpHea ders.httpH eaderCache Filename, cacheFilen ame); | |
| 1024 | ||
| 1025 | // String s torageSite Number = t ransaction Context.ge tStorageSi teNumber() ; | |
| 1026 | // if (stor ageSiteNum ber != nul l) | |
| 1027 | // resp.addHe ader(Trans actionCont extHttpHea ders.httpH eaderStora geSiteNumb er, storag eSiteNumbe r); | |
| 1028 | // | |
| 1029 | // String s torageUser name = tra nsactionCo ntext.getS torageUser name(); | |
| 1030 | // if (stor ageUsernam e != null) | |
| 1031 | // resp.addHe ader(Trans actionCont extHttpHea ders.httpH eaderStora geUsername , storageU sername); | |
| 1032 | // | |
| 1033 | // String s toragePass word = tra nsactionCo ntext.getS toragePass word(); | |
| 1034 | // if (stor agePasswor d != null) | |
| 1035 | // resp.addHe ader(Trans actionCont extHttpHea ders.httpH eaderStora gePassword , storageP assword); | |
| 1036 | ||
| 1037 | } | |
| 1038 | } | |
| 1039 | } | |
| 1040 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.