182. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:40 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.

182.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ExchangeWebApp\main\src\java\gov\va\med\imaging\exchange\web ExchangeImageAccessServlet.java Mon Dec 4 21:34:56 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ExchangeWebApp\main\src\java\gov\va\med\imaging\exchange\web ExchangeImageAccessServlet.java Mon Dec 4 22:00:19 2017 UTC

182.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 724
Changed 1 2
Inserted 0 0
Removed 0 0

182.3 Comparison options

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

182.4 Active regular expressions

No regular expressions were active.

182.5 Comparison detail

  1   /**
  2    * 
  3     Package:  MAG - Vis tA Imaging
  4     WARNING:  Per VHA D irective 2 004-038, t his routin e should n ot be modi fied.
  5     Date Cre ated: Augu st 10, 200 6
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:          
TITTOC
  8     Descript ion: 
  9  
  10           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  11           ;;  Property  of the US  Government .
  12           ;;  No permis sion to co py or redi stribute t his softwa re is give n.
  13           ;;  Use of un released v ersions of  this soft ware requi res the us er
  14           ;;   to execu te a writt en test ag reement wi th the Vis tA Imaging
  15           ;;   Developm ent Office  of the De partment o f Veterans  Affairs,
  16           ;;   telephon e (301) 73 4-0100.
  17           ;;
  18           ;;  The Food  and Drug A dministrat ion classi fies this  software a s
  19           ;;  a Class I I medical  device.  A s such, it  may not b e changed
  20           ;;  in any wa y.  Modifi cations to  this soft ware may r esult in a n
  21           ;;  adulterat ed medical  device un der 21CFR8 20, the us e of which
  22           ;;  is consid ered to be  a violati on of US F ederal Sta tutes.
  23           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  24     */
  25  
  26   package go v.va.med.i maging.exc hange.web;
  27  
  28   import gov .va.med.ex ceptions.R outingToke nFormatExc eption;
  29   import gov .va.med.im aging.Imag eURN;
  30   import gov .va.med.im aging.core .interface s.exceptio ns.Securit yCredentia lsExpiredE xception;
  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.http .AcceptEle ment;
  35   import gov .va.med.im aging.http .AcceptEle mentList;
  36   import gov .va.med.im aging.http .exception s.HttpHead erParseExc eption;
  37   import gov .va.med.im aging.tran sactioncon text.Trans actionCont ext;
  38   import gov .va.med.im aging.tran sactioncon text.Trans actionCont extFactory ;
  39   import gov .va.med.im aging.wado .AbstractB aseImageSe rvlet;
  40   import gov .va.med.im aging.wado .query.Wad oQuery;
  41   import gov .va.med.im aging.wado .query.Wad oRequest;
  42   import gov .va.med.im aging.wado .query.exc eptions.Wa doQueryCom plianceExc eption;
  43  
  44   import jav a.io.IOExc eption;
  45   import jav a.util.Arr ayList;
  46   import jav a.util.Lis t;
  47  
  48   import jav ax.managem ent.Instan ceNotFound Exception;
  49   import jav ax.servlet .ServletEx ception;
  50   import jav ax.servlet .http.Http ServletReq uest;
  51   import jav ax.servlet .http.Http ServletRes ponse;
  52  
  53   import org .apache.lo gging.log4 j.LogManag er;
  54   import org .apache.lo gging.log4 j.Logger;
  55  
  56   /**
  57    * @author  Chris Bec key
  58    * @since  1.0
  59    *
  60    * ------- ---------- ---------- ---------- ---------- ---------- -----
  61    * @web.se rvlet 
  62    *   name= "ExchangeI mageAccess Servlet" 
  63    *   displ ay-name="E xchange Im age Access
  64    *   descr iption="Se rvlet impl ementing t he WAI spe cification  of VIX IC D."
  65    * 
  66    * @web.se rvlet-mapp ing 
  67    *   url-p attern="/i mage/*"
  68    * ------- ---------- ---------- ---------- ---------- ---------- -------
  69    */
  70   public cla ss Exchang eImageAcce ssServlet
  71   extends Ab stractBase ImageServl et
  72   {
  73           pr ivate stat ic final l ong serial VersionUID  = 1L;
  74           
  75           pu blic stati c final Li st<ImageFo rmat> acce ptableThum bnailRespo nseTypes;
  76           pu blic stati c final Li st<ImageFo rmat> acce ptableRefe renceRespo nseTypes;
  77           pu blic stati c final Li st<ImageFo rmat> acce ptableDiag nosticResp onseTypes;
  78           
  79           st atic
  80           {
  81                    acce ptableThum bnailRespo nseTypes =  new Array List<Image Format>();
  82                    acce ptableThum bnailRespo nseTypes.a dd(ImageFo rmat.JPEG) ;
  83                    
  84                    acce ptableRefe renceRespo nseTypes =  new Array List<Image Format>();
  85                    acce ptableRefe renceRespo nseTypes.a dd(ImageFo rmat.DICOM JPEG2000);
  86                    acce ptableRefe renceRespo nseTypes.a dd(ImageFo rmat.J2K);
  87                    acce ptableRefe renceRespo nseTypes.a dd(ImageFo rmat.JPEG) ;
  88   //               acce ptableRefe renceRespo nseTypes.a dd(ImageFo rmat.DICOM ); // DICO M must be  here becau se the req uest type  will be ap plication/ dicom whic h literall y converts  to this o ne
  89                    
  90                    acce ptableDiag nosticResp onseTypes  = new Arra yList<Imag eFormat>() ;
  91                    acce ptableDiag nosticResp onseTypes. add(ImageF ormat.DICO MJPEG2000) ;
  92                    acce ptableDiag nosticResp onseTypes. add(ImageF ormat.J2K) ;
  93                    acce ptableDiag nosticResp onseTypes. add(ImageF ormat.JPEG );
  94   //               acce ptableDiag nosticResp onseTypes. add(ImageF ormat.DICO M); // DIC OM must be  here beca use the re quest type  will be a pplication /dicom whi ch literal ly convert s to this  one
  95           }
  96           
  97           pr ivate Logg er logger  = LogManag er.getLogg er(this.ge tClass());   
  98           
  99           /* *
  100            *  
  101            * /
  102           pu blic Excha ngeImageAc cessServle t()
  103           {
  104                    supe r();
  105           }
  106           
  107           /* *
  108            *  Initializ ation of t he servlet . <br>
  109            *
  110            *  @throws S ervletExce ption if a n error oc cur
  111            * /
  112           pu blic void  init() 
  113           th rows Servl etExceptio n
  114           {
  115                    supe r.init();
  116           }
  117           
  118           
  119           
  120           /*  (non-Java doc)
  121            *  @see gov. va.med.ima ging.wado. AbstractBa seImageSer vlet#getUs erSiteNumb er()
  122            * /
  123           @O verride
  124           pu blic Strin g getUserS iteNumber(
  125           {
  126                    retu rn Exchang eUtil.getD odSiteNumb er();
  127           }
  128           
  129           pr otected St ring getWe bAppName()
  130           {
  131                    retu rn "Exchan ge WebApp" ;
  132           }
  133  
  134           /* *
  135            *  
  136            *  @see java x.servlet. http.HttpS ervlet#doG et(javax.s ervlet.htt p.HttpServ letRequest , javax.se rvlet.http .HttpServl etResponse )
  137            * /
  138           pr otected vo id doGet(H ttpServlet Request re q, HttpSer vletRespon se resp) 
  139           th rows Servl etExceptio n, IOExcep tion
  140           {
  141                    Wado Request wa doRequest= null;
  142                    long  bytesTran sferred =  0;
  143                    Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get();
  144                    
  145                    logg er.info("B eginning G ET handler : servlet  path=[" +  req.getSer vletPath()  + 
  146                                                           "],  path  info=[" +  req.getPa thInfo() +
  147                                                           "]\nquery  string: [ " + req.ge tQueryStri ng() + "]" );           
  148                    
  149                    try
  150                    {
  151                             wadoRe quest = Wa doRequest. createPars edXChangeC ompliantWa doRequest( req);
  152                             initTr ansactionC ontext(wad oRequest);
  153                             transa ctionConte xt.setRequ estType(ge tWebAppNam e() + " "  + transact ionContext .getReques tType());
  154                             logger .debug("XC HANGE w/ex tensions c ompliance  requested,  Request i s [" + wad oRequest.t oString()  + "]" );
  155                             bytesT ransferred  = doExcha ngeComplia ntGet(wado Request, r esp);
  156                             transa ctionConte xt.setEntr iesReturne d( bytesTr ansferred= =0 ? 0 : 1  );
  157                             transa ctionConte xt.setFaca deBytesSen t(bytesTra nsferred);
  158                             transa ctionConte xt.setResp onseCode(H ttpServlet Response.S C_OK + "") ;
  159                    }
  160                    catc h( WadoQue ryComplian ceExceptio n wadoX )
  161                    {
  162                             String  msg = "Re quest is n ot a valid  Exchange  (WAI) prot ocol reque st: " + wa doX.getMes sage();
  163                             logger .error(msg );
  164                             transa ctionConte xt.setErro rMessage(m sg);
  165                             transa ctionConte xt.setExce ptionClass Name(wadoX .getClass( ).getSimpl eName());
  166                             transa ctionConte xt.setResp onseCode(H ttpServlet Response.S C_NOT_ACCE PTABLE + " ");
  167                             resp.s endError(H ttpServlet Response.S C_NOT_ACCE PTABLE, ms g );                      
  168                    }
  169                    catc h( HttpHea derParseEx ception ht tpParseX )
  170                    {
  171                             String  msg = "Er ror parsin g HTTP hea der inform ation: " +  httpParse X.getMessa ge();
  172                             logger .error(msg );
  173                             transa ctionConte xt.setErro rMessage(m sg);
  174                             transa ctionConte xt.setExce ptionClass Name(httpP arseX.getC lass().get SimpleName ());
  175                             transa ctionConte xt.setResp onseCode(H ttpServlet Response.S C_INTERNAL _SERVER_ER ROR + "");
  176                             resp.s endError(H ttpServlet Response.S C_INTERNAL _SERVER_ER ROR, msg ) ;
  177                    }
  178                    catc h (IOExcep tion ioX) 
  179                    {
  180                             String  msg = "I/ O error wh en sending  image con tent: " +  ioX.getMes sage();
  181                             logger .error(msg );
  182                             transa ctionConte xt.setErro rMessage(m sg);
  183                             transa ctionConte xt.setExce ptionClass Name(ioX.g etClass(). getSimpleN ame());
  184                             transa ctionConte xt.setResp onseCode(H ttpServlet Response.S C_INTERNAL _SERVER_ER ROR + "");
  185                             resp.s endError(H ttpServlet Response.S C_INTERNAL _SERVER_ER ROR, msg ) ;
  186                    } 
  187                    catc h (ImageSe rvletExcep tion isX)
  188           {
  189                             String  msg = "Im age servle t exceptio n: " + isX .getMessag e();
  190                             logger .error(isX ); // want  stack tra ce to figu re out pro blem
  191                             transa ctionConte xt.setErro rMessage(m sg);
  192                             // don 't set the  transacti onContext. setExcepti onClassNam e() proper ty here
  193                             // it  gets set i n the Abst ractBaseIm ageServlet  because t hat is whe re the rea l
  194                             // exc eption is  caught
  195                             //tran sactionCon text.setEx ceptionCla ssName(isX .getClass( ).getName( ));
  196                             transa ctionConte xt.setResp onseCode(i sX.getResp onseCode()  + "");
  197                             resp.s endError(i sX.getResp onseCode() , msg );
  198           }
  199                    catc h(Security Credential sExpiredEx ception sc eX)
  200                    {
  201                             // for  DoD - can not return  an error  for securi ty excepti on, return  generic 5 00 error
  202                             String  msg = "Ex ception ac cessing im age: " + s ceX.getMes sage();
  203                             // log ging of er ror alread y done
  204                             // jus t need to  set approp riate erro r code
  205                             transa ctionConte xt.setResp onseCode(H ttpServlet Response.S C_INTERNAL _SERVER_ER ROR + "");
  206                             transa ctionConte xt.setErro rMessage(m sg);
  207                             resp.s endError(H ttpServlet Response.S C_INTERNAL _SERVER_ER ROR, msg);
  208                    }
  209                    catc h (Routing TokenForma tException  rtfX)
  210                    {
  211                             String  msg = "Im age servle t exceptio n: " + rtf X.getMessa ge();
  212                             logger .error(rtf X); // wan t stack tr ace to fig ure out pr oblem
  213                             transa ctionConte xt.setErro rMessage(m sg);
  214                             // don 't set the  transacti onContext. setExcepti onClassNam e() proper ty here
  215                             // it  gets set i n the Abst ractBaseIm ageServlet  because t hat is whe re the rea l
  216                             // exc eption is  caught
  217                             //tran sactionCon text.setEx ceptionCla ssName(isX .getClass( ).getName( ));
  218                             transa ctionConte xt.setResp onseCode(H ttpServlet Response.S C_INTERNAL _SERVER_ER ROR + "");
  219                             resp.s endError(H ttpServlet Response.S C_INTERNAL _SERVER_ER ROR, msg ) ;
  220                    }
  221  
  222                    logg er.info(
  223                             "GET h andler ret urned " + 
  224                             (bytes Transferre d) + 
  225                             " byte s for quer y string:  [" + req.g etQueryStr ing() + "]  ");
  226           }
  227  
  228           /* *
  229            *  
  230            *  @param wa doRequest
  231            *  @param re sp
  232            *  @throws W adoQueryCo mplianceEx ception
  233            *  @throws I OException
  234            *  @throws I mageServle tException  
  235            *  @throws I nstanceNot FoundExcep tion
  236            * /
  237           pr otected lo ng doExcha ngeComplia ntGet(Wado Request wa doRequest,  HttpServl etResponse  resp) 
  238           th rows WadoQ ueryCompli anceExcept ion, IOExc eption, Im ageServlet Exception,  SecurityC redentials ExpiredExc eption
  239           {
  240                    logg er.debug(" Doing Exch ange compl iant GET:   " + wadoR equest.toS tring());
  241                    Wado Query wado Query = wa doRequest. getWadoQue ry();
  242                    
  243                    Imag eURN image Urn = wado Query.getI nstanceUrn ();
  244                    Imag eQuality i mageQualit y = ImageQ uality.get ImageQuali ty( wadoRe quest.getW adoQuery() .getImageQ ualityValu e() );
  245                    Acce ptElementL ist conten tTypeList  = wadoQuer y.getConte ntTypeList ();
  246                    List <ImageForm at> accept ableRespon seContent  = validate ContentTyp e(imageQua lity, cont entTypeLis t);
  247                    
  248                    // D o sanity c heck for n on-Wado re quests
  249                    logg er.debug("    GET par ams:  imag eUrn=[" +  (imageUrn  == null ?  "NULL" : i mageUrn)
  250                                      + "]  Im ageQuality =[" + imag eQuality.n ame()                       // 1 6Sep2008 C TB name()  changed fr om toStrin g()
  251                                      + "]");
  252                                      
  253                    // i f the obje ct (instan ce) GUID i s supplied  then just  stream th e instance
  254                    // b ack, ignor ing any ot her parame ters
  255                    
  256                    Meta dataNotifi cation  me tadataNoti fication =  new Metad ataNotific ation(resp );
  257                    retu rn streamI mageInstan ceByUrn(im ageUrn, im ageQuality , acceptab leResponse Content, 
  258                                      resp.get OutputStre am(), meta dataNotifi cation, tr ue);
  259           }
  260  
  261           /* *
  262            *  chooseXch angeConten tType does  HTTP requ est conten tType chec k for non- WADO (XCHA NGE) 
  263            *  compliant  image req uests. Ret urns accep ted/select ed content Type.
  264            *  For THUMB NAILs, onl y "image/j peg" is ac cepted. Fo r REFERENC E and DIAG NOSTIC qua lity image s,
  265            *  "applicat ion/dicom"  (default) , and if a lternate l ogic appli es "image/ jp2" and " image/jpeg "
  266            *  are accep ted, if on e or more  are presen t the firs t is set.
  267            *  
  268            *  @param ac ceptElemen tList list  of reques ted conten tType entr ies (Accep tElementLi st type)
  269            *  @return I mageConten tType acce pted/selec ted conten tType
  270            *  @throws W adoQueryCo mplianceEx ception
  271            * /
  272           pr ivate List <ImageForm at> valida teContentT ype(
  273                    Imag eQuality i mageQualit y, 
  274                    Acce ptElementL ist accept ElementLis t)
  275           th rows WadoQ ueryCompli anceExcept ion
  276           {
  277                    
  278                    if(i mageQualit y == Image Quality.TH UMBNAIL)
  279                             return  validateC ontentType (acceptEle mentList,  acceptable ThumbnailR esponseTyp es);
  280                    else  if(imageQ uality ==  ImageQuali ty.REFEREN CE)
  281                             return  validateC ontentType (acceptEle mentList,  acceptable ReferenceR esponseTyp es);
  282                    else  if(imageQ uality ==  ImageQuali ty.DIAGNOS TIC)
  283                             return  validateC ontentType (acceptEle mentList,  acceptable Diagnostic ResponseTy pes);
  284                    else  if(imageQ uality ==  ImageQuali ty.DIAGNOS TICUNCOMPR ESSED)
  285                             return  validateC ontentType (acceptEle mentList,  acceptable Diagnostic ResponseTy pes);
  286  
  287                    thro w new 
  288                    Wado QueryCompl ianceExcep tion("Unkn own image  quality va lue for "
  289                             + (ima geQuality  == null ?  "null" : i mageQualit y.name())  +                         // 16S ep2008 CTB  name() ch anged from  toString(
  290                             " imag e: '" + ac ceptElemen tList.toSt ring() + " '" );
  291           }
  292                    
  293           /* *
  294            *  Validate  that eleme nts in the  acceptEle mentList a re in the  acceptable  response  types.
  295            *  Any eleme nts on the  accept li st that ar e not on t he accepta ble repons e types ar e ignored.
  296            *  If there  are no com mon elemen ts then it  is an err or because  the clien t asked fo r somethin g
  297            *  outside t he specifi cation def inition. 
  298            *  The resul ting list  of ImageFo rmat will  be in the  order of t he accepta ble respon se types l ist.
  299            * /
  300           pr ivate List <ImageForm at> valida teContentT ype(
  301                    Acce ptElementL ist accept ElementLis t, 
  302                    List <ImageForm at> accept ableRespon seTypes)
  303           th rows WadoQ ueryCompli anceExcept ion
  304           {
  305                    List <ImageForm at> select edContentT ype = new  ArrayList< ImageForma t>();
  306                    
  307                    //                iQ = THU MBNAILS -- > always J PEG (lossy ) -- needs  image/jpe g (default ) or */*!
  308                    //                iQ = REF ERENCE, DI AGNOSTIC - -> DICOM w rapped JPE G or J2K,
  309                    //                -- only  alternatel y plain J2 K or JPEG
  310                    //                                 --  needs app lication/d icom (defa ult), alte rnately im age/jp2, i mage/jpeg  or */*!
  311                    for( ImageForma t imageFor mat : acce ptableResp onseTypes)
  312                    {
  313                             for(in t i=0; i <  acceptEle mentList.s ize(); ++i  ) 
  314                             { 
  315                                      AcceptEl ement acce ptElement  = acceptEl ementList. get(i);
  316                                      String a cceptEleme ntType = a cceptEleme nt.getMedi aType();
  317                                      String a cceptEleme ntSubType  = acceptEl ement.getM ediaSubTyp e();
  318                                      String m ime = acce ptElementT ype + "/"  + acceptEl ementSubTy pe;
  319                                      if((imag eFormat.ge tMime().eq uals(mime) ) || (Imag eFormat.AN YTHING.get Mime().equ als(mime)) )
  320                                      {                                                                     
  321                                               selectedCo ntentType. add(imageF ormat);                                       
  322                                               // break h ere so tha t if there  are multi ple mime t ypes in th e request  that match  the
  323                                               // current  ImageForm at, only t ake the fi rst one (r emove dupl icates)
  324                                               break; 
  325                                      }
  326                                      /*
  327                                      ImageFor mat accept ElementIma geFormat =  ImageForm at.valueOf MimeType(a cceptEleme ntType + " /" + accep tElementSu bType);
  328                                      
  329                                      //if(acc eptElement ImageForma t == Image Format.ANY THING || a cceptEleme ntImageFor mat == ima geFormat)
  330                                      // JMW 4 /21/08 - c ompare mim e types so  that appl ication/di com for DI COM J2K wi ll equal a pplication /dicom (fo r uncompre ssed dicom )
  331                                      // then  we put in  the value  from the a cceptableR esponseTyp es list wh ich will l imit the r esponse to  J2K DICOM
  332                                      if(accep tElementIm ageFormat  == ImageFo rmat.ANYTH ING || 
  333                                                       ac ceptElemen tImageForm at.getMime ().equals( imageForma t.getMime( )))
  334                                               selectedCo ntentType. add(imageF ormat);
  335                                      */
  336                             }                         
  337                    }
  338                    
  339                    if ( selectedCo ntentType. size() ==  0) 
  340                    {
  341                             String  msg = "Il legal Exch ange accep t type[s],  values (" ;
  342                             
  343                             String  acceptEle mentsStrin g = null;
  344                             for( A cceptEleme nt acceptE lement : a cceptEleme ntList )
  345                                      acceptEl ementsStri ng += (acc eptElement sString==n ull ? "" :  ",") + ac ceptElemen t.toString ();
  346                             msg +=  acceptEle mentsStrin g;
  347  
  348                             msg +=  ") are no t of the a cceptable  types (";
  349                             
  350                             String  acceptabl eElementsS tring = nu ll;
  351                             for( I mageFormat  acceptabl eImageForm at : accep tableRespo nseTypes )
  352                                      acceptab leElements String +=  (acceptabl eElementsS tring==nul l ? "" : " ,") + acce ptableImag eFormat.to String();
  353                             msg +=  acceptabl eElementsS tring;
  354                             
  355                             msg +=  ").";
  356                             
  357                             throw  new 
  358                                      WadoQuer yComplianc eException ( msg );
  359                    }
  360  
  361                    retu rn selecte dContentTy pe;
  362           }
  363   }