187. EPMO Open Source Coordination Office Redaction File Detail Report

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

187.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\FederationDataSourceProvider\main\src\java\gov\va\med\imaging\federation\storage FederationStorageUtility.java Mon Dec 4 21:35:06 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\FederationDataSourceProvider\main\src\java\gov\va\med\imaging\federation\storage FederationStorageUtility.java Mon Dec 4 22:00:28 2017 UTC

187.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 460
Changed 2 4
Inserted 0 0
Removed 0 0

187.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

187.4 Active regular expressions

No regular expressions were active.

187.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: Sep  23, 2008
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:          
WERFEJ
  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.fed eration.st orage;
  27  
  28   import jav a.io.IOExc eption;
  29   import jav a.util.zip .ZipEntry;
  30   import jav a.util.zip .ZipInputS tream;
  31  
  32   import org .apache.lo gging.log4 j.LogManag er;
  33   import org .apache.lo gging.log4 j.Logger;
  34  
  35   import gov .va.med.im aging.Size dInputStre am;
  36   import gov .va.med.im aging.core .interface s.StorageC redentials ;
  37   import gov .va.med.im aging.core .interface s.exceptio ns.Connect ionExcepti on;
  38   import gov .va.med.im aging.core .interface s.exceptio ns.ImageCo nversionEx ception;
  39   import gov .va.med.im aging.core .interface s.exceptio ns.ImageNe arLineExce ption;
  40   import gov .va.med.im aging.core .interface s.exceptio ns.ImageNo tFoundExce ption;
  41   import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception;
  42   import gov .va.med.im aging.exch ange.busin ess.ImageF ormatQuali ty;
  43   import gov .va.med.im aging.exch ange.busin ess.ImageF ormatQuali tyList;
  44   import gov .va.med.im aging.exch ange.busin ess.Site;
  45   import gov .va.med.im aging.exch ange.enums .ImageForm at;
  46   import gov .va.med.im aging.exch ange.enums .ImageQual ity;
  47   import gov .va.med.im aging.exch ange.enums .StoragePr oximity;
  48   import gov .va.med.im aging.exch ange.stora ge.Abstrac tBufferedI mageStorag eFacade;
  49   import gov .va.med.im aging.exch ange.stora ge.ByteBuf ferBackedI mageStream Response;
  50   import gov .va.med.im aging.exch ange.stora ge.ByteBuf ferBackedI nputStream ;
  51   import gov .va.med.im aging.fede ration.pro xy.IFedera tionProxy;
  52   import gov .va.med.im aging.tran sactioncon text.Trans actionCont extFactory ;
  53  
  54   /**
  55    * @author         
WERFEJ
  56    *
  57    */
  58   public cla ss Federat ionStorage Utility 
  59   extends Ab stractBuff eredImageS torageFaca de
  60   {
  61           pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(Fede rationStor ageUtility .class);
  62           
  63           pr ivate fina l IFederat ionProxy i magingProx y;
  64           pr ivate fina l Site sit e;
  65           
  66           pu blic Feder ationStora geUtility( IFederatio nProxy ima gingProxy,  Site site )
  67           {
  68                    this .imagingPr oxy = imag ingProxy;
  69                    this .site = si te;
  70           }
  71  
  72           /*  (non-Java doc)
  73            *  @see gov. va.med.ima ging.excha nge.storag e.Abstract ImageStora geFacade#o penImageSt ream(java. lang.Strin g, gov.va. med.imagin g.core.int erfaces.St orageCrede ntials, go v.va.med.i maging.exc hange.enum s.StorageP roximity,  gov.va.med .imaging.e xchange.bu siness.Ima geFormatQu alityList)
  74            * /
  75           /* *
  76            *  Override  this funct ion for Fe deration b ecause whe n Federati on request s an image , it comes  
  77            *  back with  the image  and the T XT file in  a ZIP Str eam. Previ ously Fede ration was  buffering
  78            *  both the  image and  the TXT st ream and o pening an  InputStrea m to both  files, now  want to p ut
  79            *  the conte nts of the  ZIP strea m into the  buffer po ol without  first buf fering it  (more effi cient
  80            *  memory us e). 
  81            *  
  82            *  This impl ementation  also igno res the us eBuffer pa rameter be cause the  input come s from a z ip
  83            *  stream wh ich means  we have to  buffer al l data fro m Federati on, so no  benefit to  try to no
  84            *  use the b uffer pool  system.
  85            *  
  86            * /
  87           @O verride
  88           pu blic ByteB ufferBacke dImageStre amResponse  openImage Stream(Str ing imageI dentifier,
  89                    Stor ageCredent ials image Credential s,
  90                    Stor ageProximi ty imagePr oximity,
  91                    Imag eFormatQua lityList r equestForm atQualityL ist)
  92           th rows Image NearLineEx ception, I mageNotFou ndExceptio n,
  93                    Conn ectionExce ption, Ima geConversi onExceptio n, MethodE xception
  94           {
  95                    if(i mageBuffer  == null)
  96                    {                         
  97                             try 
  98                             {
  99                                      String i mageId = i mageIdenti fier;
  100                                      logger.i nfo("Retri eving imag e [" + ima geId + "]  from site  [" + site. getSiteNum ber() + "] ");
  101                                      SizedInp utStream i nputStream  = imaging Proxy.getI nstance(im ageId, req uestFormat QualityLis t, true);
  102                                      ZipInput Stream zip Stream = n ew ZipInpu tStream(in putStream. getInStrea m());
  103                                      
  104                                      int file Size = ima gingProxy. getFileLen gth();
  105                                      int txtS ize = imag ingProxy.g etTxtLengt h();
  106                                      
  107                                      int data SourceByte sReceived  = 0;
  108                                      
  109                                      ZipEntry  entry = z ipStream.g etNextEntr y();
  110                                      while(en try != nul l)
  111                                      {
  112                                               if(entry.g etName().e quals("ima ge"))
  113                                               {       
  114                                                       lo gger.info( "Reading i mage from  site [" +  site.getSi teNumber()  + "] into  buffer... ");
  115                                                       //  size of f ile will b e ignored  since it i s read int o a buffer
  116                                                       //  Reading i nto the bu ffer calls  close on  the input  stream - I  hope this  is ok...
  117                                                       im ageBuffer  = new Fede rationZipB yteBufferB ackedImage InputStrea m(zipStrea m, 
  118                                                                         fileSi ze, true,  imagingPro xy.getImag eChecksum( ));
  119                                                       da taSourceBy tesReceive d = imageB uffer.getS ize();
  120                                                       im ageQuality  = imaging Proxy.getR equestedQu ality();
  121                                               }
  122                                               else if("t xt".equals (entry.get Name()))
  123                                               {
  124                                                       lo gger.info( "Reading T XT file fr om site ["  + site.ge tSiteNumbe r() + "] i nto buffer ...");
  125                                                       //  JMW 3/24/ 09 - if th e TXT file  doesn't a ctually ex ist in the  stream bu t there is  an entry  for it
  126                                                       //  need to c atch when  reading th e TXT file  - keep wo rking sinc e image ok
  127                                                       tr y
  128                                                       {
  129                                                                txtB uffer = ne w Federati onZipByteB ufferBacke dInputStre am(zipStre am, 
  130                                                                                  txtSize,  true, ima gingProxy. getTxtChec ksum());
  131                                                                // i f only get ting text  file then  want to pu t the size  in
  132                                                                if(d ataSourceB ytesReceiv ed <= 0)
  133                                                                         dataSo urceBytesR eceived =  txtBuffer. getSize();
  134                                                       }
  135                                                       ca tch(IOExce ption ioX)
  136                                                       {
  137                                                                logg er.error(" Error read ing TXT fi le from si te [" + si te.getSite Number() +  "] into b uffer, thi s may be c aused by t he TXT fil e not exis ting in th e source",  ioX);
  138                                                                txtB uffer = nu ll;
  139                                                       }                                                                      
  140                                               }
  141                                               try
  142                                               {
  143                                                       en try = zipS tream.getN extEntry() ;
  144                                               }
  145                                               catch(IOEx ception io X)
  146                                               {
  147                                                       lo gger.error ("Error re ading next  entry fro m site ["  + site.get SiteNumber () + "], t his may be  caused by  the TXT f ile not ex isting in  the source ", ioX);
  148                                                       en try = null ;
  149                                               }
  150                                      }
  151                                      zipStrea m.close();
  152                                      Transact ionContext Factory.ge t().setDat aSourceByt esReceived ((long)dat aSourceByt esReceived );
  153                             }
  154                             catch( IOExceptio n ioX)
  155                             {
  156                                      logger.e rror("Erro r reading  zip respon se", ioX);
  157                                      throw ne w Connecti onExceptio n(ioX);
  158                             }
  159                    }
  160                    Byte BufferBack edImageStr eamRespons e response  = new Byt eBufferBac kedImageSt reamRespon se(imageBu ffer);
  161                    resp onse.setIm ageQuality (imageQual ity);
  162                    
  163                    if(t xtBuffer ! = null)
  164                    {
  165                             respon se.setTxtS tream(txtB uffer);
  166                    }
  167                    retu rn respons e;
  168           }
  169  
  170           /*  (non-Java doc)
  171            *  @see gov. va.med.ima ging.excha nge.storag e.Abstract ImageStora geFacade#o penImageSt reamIntern al(java.la ng.String,  gov.va.me d.imaging. core.inter faces.Stor ageCredent ials, gov. va.med.ima ging.excha nge.enums. StoragePro ximity, go v.va.med.i maging.exc hange.busi ness.Image FormatQual ityList)
  172            * /
  173           @O verride
  174           pr otected By teBufferBa ckedImageS treamRespo nse openIm ageStreamI nternal(St ring image Identifier ,
  175                    Stor ageCredent ials image Credential s,
  176                    Stor ageProximi ty imagePr oximity,
  177                    Imag eFormatQua lityList r equestForm atQualityL ist)
  178           th rows Image NearLineEx ception, I mageNotFou ndExceptio n,
  179                    Conn ectionExce ption 
  180           {
  181                    logg er.fatal(" Federation StorageUti lity.openI mageStream Internal -  this func tion shoul d NEVER be  called...  extreme e rror!");
  182                    retu rn null;
  183           }
  184  
  185           /*  (non-Java doc)
  186            *  @see gov. va.med.ima ging.excha nge.storag e.Abstract ImageStora geFacade#o penTXTStre amInternal (java.lang .String, g ov.va.med. imaging.co re.interfa ces.Storag eCredentia ls, gov.va .med.imagi ng.exchang e.enums.St orageProxi mity)
  187            * /
  188           @O verride
  189           pr otected By teBufferBa ckedInputS tream open TXTStreamI nternal(St ring image Identifier ,
  190                    Stor ageCredent ials image Credential s, Storage Proximity  imageProxi mity)
  191           th rows Image NearLineEx ception, I mageNotFou ndExceptio n,
  192                    Conn ectionExce ption, Met hodExcepti on
  193           {
  194                    try
  195                    {
  196                             String  imageId =  imageIden tifier;
  197                             logger .info("Ret rieving TX T file ["  + imageId  + "] from  site [" +  site.getSi teNumber()  + "]");
  198                             ImageF ormatQuali tyList req uestFormat QualityLis t = new Im ageFormatQ ualityList ();
  199                             ImageF ormatQuali ty txtQual ity = new  ImageForma tQuality(I mageFormat .TEXT_DICO M, ImageQu ality.REFE RENCE);
  200                             reques tFormatQua lityList.a dd(txtQual ity);
  201                             SizedI nputStream  inputStre am = imagi ngProxy.ge tInstance( imageId, r equestForm atQualityL ist, true) ;
  202                             //TODO : get the  txt file c hecksum, n eed to ret urn in som ething...
  203                             logger .info("Got  [" + (inp utStream = = null ? " null" : in putStream. getByteSiz e()) + " b ytes from  TXT file f or URN ["  + imageId  + "]");
  204                             if(inp utStream = = null)
  205                                      return n ull;
  206                             return  new ByteB ufferBacke dInputStre am(inputSt ream.getIn Stream(),  inputStrea m.getByteS ize());
  207                    }
  208                    catc h(ImageCon versionExc eption icX )
  209                    {
  210                             // thi s really s hould not  happen, bu t in case  it does, c onvert it  to a image  not found  exception
  211                             logger .error("Im ageConvers ion except ion when g etting TXT  file, sho uld never  happen!",  icX);
  212                             throw  new ImageN otFoundExc eption(icX );
  213                    }
  214           }
  215  
  216           /*  (non-Java doc)
  217            *  @see gov. va.med.ima ging.core. interfaces .ImageStor ageFacade# openPhotoI d(java.lan g.String,  gov.va.med .imaging.c ore.interf aces.Stora geCredenti als)
  218            * /
  219           @O verride
  220           pu blic ByteB ufferBacke dInputStre am openPho toId(Strin g imageIde ntifier,
  221                             Storag eCredentia ls imageCr edentials)  
  222           th rows Image NotFoundEx ception, C onnectionE xception,  MethodExce ption
  223           {                 
  224                    logg er.info("R etrieving  Patient ["  + imageId entifier +  "] Photo  Id from si te [" + si te.getSite Number() +  "]");
  225                    Size dInputStre am inputSt ream = 
  226                             imagin gProxy.get PatientIde ntifierIma ge(imageId entifier,  site.getSi teNumber() );
  227                    logg er.info("G ot [" + (i nputStream  == null ?  "null" :  inputStrea m.getByteS ize()) + "  bytes fro m Photo Id  for patie nt [" + im ageIdentif ier + "]") ;
  228                    if(i nputStream  == null)
  229                             return  null;
  230                    retu rn new Byt eBufferBac kedInputSt ream(input Stream.get InStream() , inputStr eam.getByt eSize());            
  231           }        
  232   }