781. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/18/2018 2:02:19 PM Central Daylight 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.

781.1 Files compared

# Location File Last Modified
1 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\ImagingDicomRouter\main\src\java\gov\va\med\imaging\core\router\commands PostDicomInstanceSetCommandImpl.java Thu Oct 11 13:30:17 2018 UTC
2 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\ImagingDicomRouter\main\src\java\gov\va\med\imaging\core\router\commands PostDicomInstanceSetCommandImpl.java Wed Oct 17 18:55:01 2018 UTC

781.2 Comparison summary

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

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

781.4 Active regular expressions

No regular expressions were active.

781.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: 
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:     PII
  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  
  27   package go v.va.med.i maging.cor e.router.c ommands;
  28  
  29   import gov .va.med.im aging.busi ness.excep tions.Post DicomInsta nceSetExce ption;
  30   import gov .va.med.im aging.core .annotatio ns.routerf acade.Rout erCommandE xecution;
  31   import gov .va.med.im aging.core .interface s.exceptio ns.Connect ionExcepti on;
  32   import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception;
  33   import gov .va.med.im aging.dico m.DicomCon text;
  34   import gov .va.med.im aging.dico m.DicomRou ter;
  35   import gov .va.med.im aging.dico m.common.i nterfaces. IDicomData Set;
  36   import gov .va.med.im aging.dico m.common.s pring.Spri ngContext;
  37   import gov .va.med.im aging.dico m.common.s tats.Dicom ServiceSta ts;
  38   import gov .va.med.im aging.dico m.common.u tils.Publi sher;
  39   import gov .va.med.im aging.dico m.dcftoolk it.common. observer.S ubOperatio nsStatus;
  40   import gov .va.med.im aging.dico m.router.f acade.Inte rnalDicomC ontext;
  41   import gov .va.med.im aging.dico m.router.f acade.Inte rnalDicomR outer;
  42   import gov .va.med.im aging.dico m.scu.exce ptions.Ass ociationAb ortExcepti on;
  43   import gov .va.med.im aging.dico m.scu.exce ptions.Ass ociationIn itializati onExceptio n;
  44   import gov .va.med.im aging.dico m.scu.exce ptions.Ass ociationRe jectExcept ion;
  45   import gov .va.med.im aging.dico m.scu.stor agescu.int erfaces.IS toreSCUCon trol;
  46   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomAE;
  47   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomInsta nceSet;
  48   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomServe rConfigura tion;
  49   import gov .va.med.im aging.exch ange.busin ess.dicom. InstanceSt orageInfo;
  50   import gov .va.med.im aging.exch ange.busin ess.dicom. MoveComman dObserver;
  51  
  52   import jav a.util.Has hSet;
  53   import jav a.util.Ite rator;
  54   import jav a.util.Obs erver;
  55   import jav a.util.con current.Li nkedBlocki ngQueue;
  56  
  57   import org .apache.lo gging.log4 j.LogManag er;
  58   import org .apache.lo gging.log4 j.Logger;
  59  
  60   /**
  61    * This Ro uter comma nd establi shes a DIC OM Associa tion and c ontrols th e flow of  retrieving
  62    * reconst ituting, a nd sending  DICOM Ins tances to  the DICOM  device.
  63    *  
  64    * @author   PII
  65    *
  66    */
  67   @RouterCom mandExecut ion(asynch ronous = t rue, distr ibutable =  false)
  68   public cla ss PostDic omInstance SetCommand Impl 
  69   extends Ab stractDico mCommandIm pl<Void>
  70   {
  71           pr ivate stat ic final l ong serial VersionUID  = 1308887 1877824212 85L;
  72       privat e static L ogger logg er = LogMa nager.getL ogger(Post DicomInsta nceSetComm andImpl.cl ass);
  73       privat e static L ogger summ aryLogger  = LogManag er.getLogg er("Summar y");
  74       privat e static f inal Dicom Router rou ter = Dico mContext.g etRouter() ;
  75       privat e static f inal Inter nalDicomRo uter inter nalrouter  = Internal DicomConte xt.getRout er();
  76  
  77           pr ivate IDic omDataSet  LASTBAG =  null;
  78       privat e Publishe r subOpera tionsPubli sher = nul l;
  79       privat e SubOpera tionsStatu s subOpera tionsStatu s = null;
  80           pr ivate Stri ng storeAE Title = nu ll;
  81           pr ivate Dico mInstanceS et instanc es = null;
  82           pr ivate Obse rver scpLi stener = n ull;
  83           pr ivate Move CommandObs erver move Command =  null;
  84           pr ivate Link edBlocking Queue<IDic omDataSet>  queue;
  85           
  86           pu blic PostD icomInstan ceSetComma ndImpl(Str ing storeA ETitle, Di comInstanc eSet insta nces, 
  87                             Observ er scpList ener, Move CommandObs erver move Command)
  88           {
  89                    this .storeAETi tle = stor eAETitle;
  90                    this .instances  = instanc es;
  91                    this .scpListen er = scpLi stener;
  92                    this .moveComma nd = moveC ommand;
  93                    this .queue = n ew LinkedB lockingQue ue<IDicomD ataSet>(Di comServerC onfigurati on.getConf iguration( ).getMoveQ ueueCapaci ty());
  94                    
  95                    this .LASTBAG =  (IDicomDa taSet)Spri ngContext. getContext ().getBean ("DicomDat aSet");
  96                    this .LASTBAG.s etName("LA STBAG");
  97           }
  98  
  99           @O verride
  100           pu blic Void  callSynchr onouslyInT ransaction Context()  throws Met hodExcepti on, Connec tionExcept ion
  101           {
  102                    logg er.debug(T hread.curr entThread( ).getId()+ ": Executi ng Router  Command "+ this.getCl ass().getN ame());
  103  
  104           su bOperation sStatus =  new SubOpe rationsSta tus();
  105           // Add object  Total to  SubOperati onsStatus  object.
  106           su bOperation sStatus.se tRemaining SubOperati ons(this.i nstances.s ize());
  107           if (!DicomSer verConfigu ration.get Configurat ion().isMo veSubOpera tionsEnabl ed()){
  108                    subO perationsS tatus.setS ubOperatio nsActive(f alse);
  109           }
  110                    if(t his.scpLis tener != n ull){
  111                             //Init ialize Sub Operations  Activity
  112                             subOpe rationsPub lisher = n ew Publish er();                         
  113                    //Ad d Subscrib er to Publ isher.
  114                    subO perationsP ublisher.a ddObserver (scpListen er);
  115                    }
  116                    noti fySubscrib ers();
  117  
  118                    ISto reSCUContr ol scu = ( IStoreSCUC ontrol)Spr ingContext .getContex t().getBea n("StoreSC UControl") ;
  119                    //Ge t the SOP  Class UIDs  needed fo r the asso ciation.
  120                    Hash Set<String > sopClass UIDs = thi s.createSO PClassUIDL ist();
  121                    //Ge t the Conn ection inf o for the  CStore SCU .
  122                    Dico mAE remote AE = route r.getRemot eAE(DicomA E.searchMo de.REMOTE_ AE, storeA ETitle,
  123                                      DicomSer verConfigu ration.get Configurat ion().getS iteId());
  124                    
  125                    //Op en DICOM A ssociation  to the CS tore SCU.
  126                    try  {
  127                             if(rem oteAE.getR esultCode( ) < 0){
  128                                      logger.e rror("C-St ore AETitl e Error: " +remoteAE. getResultC ode()+", " +remoteAE. getResultM essage());
  129                             summar yLogger.er ror("AETit le, "+remo teAE.getRe moteAETitl e()
  130                                               +", does n ot have pe rmission t o initiate  a C-Store  Dimse Ser vice to th e C-Storag e SCP.\n"
  131                                               +"This per mission is  configura ble using  DICOM AE S ecurity Ma trix.");
  132                                      throw ne w Associat ionInitial izationExc eption(rem oteAE.getR esultCode( )+", "+rem oteAE.getR esultMessa ge());
  133                             }
  134                             scu.op enStoreAss ociation(r emoteAE, r emoteAE.ge tLocalAETi tle(), sop ClassUIDs) ;
  135                             DicomS erviceStat s.getInsta nce().incr ementOutbo undAssocia tionAccept Count(stor eAETitle);
  136  
  137                             //Star t PostDico mDataSet r outer comm and.  This  is an asy nc command  that watc hes the
  138                             //       queue an d sends an ything in  that queue  to the SC U.  Once s tarted, yo u can then
  139                             //       start bu ilding DIC OM objects  and add t hem to the  queue.
  140                             try{
  141                                      internal router.pos tDicomData Set(scu, q ueue, subO perationsP ublisher,  subOperati onsStatus,  
  142                                                       mo veCommand) ;
  143                             }
  144                             catch( MethodExce ption mX){
  145                                      throw ne w PostDico mInstanceS etExceptio n(mX);
  146                             }
  147                             catch( Connection Exception  cX){
  148                                      //WFP-Ta ke out all  object pu t into the  queue.  C ollect the ir SOP Ins tance UIDs .
  149                                      throw ne w PostDico mInstanceS etExceptio n(cX);
  150                             }
  151                             
  152                             //Now  it's time  to populat e the queu e.
  153                             
  154                             //LOOP : Cycle th ru DicomIn stanceSet  collection .  Collect ion return
  155                             //       Instance StorageInf o object.
  156                             Iterat or<Instanc eStorageIn fo> iter =  this.inst ances.iter ator();
  157                             while( iter.hasNe xt()){
  158                                      //Pass t he Instanc eStorageIn fo object  to the Get DicomDataS et router  command.
  159                                      //       This will  return a I DicomDataS et object.
  160                                      Instance StorageInf o info = ( InstanceSt orageInfo) iter.next( );
  161                                      IDicomDa taSet dds  = null;
  162                                      try{
  163                                               dds = rout er.getDico mDataSet(i nfo);
  164                                               //Add IDic omDataSet  object to  queue.
  165                                               if(dds ==  null){
  166                                                       lo gger.error ("Failed t o create D icomDataSe t for "+
  167                                                                         info.g etObjectId entifier() +"\n");
  168                                                       su mmaryLogge r.error("F ailed to c reate a DI COM object  for "+inf o.getObjec tIdentifie r()+" to s end to C-S torage SCP .\n" +
  169                                                                         "The r esult is a  DICOM Obj ect was no t transmit ted to the  C-Storage  SCP.  Ref er to othe r logs for  more deta il.");
  170                                                       th is.subOper ationsStat us.setFail edSubOpera tions();
  171                                                       no tifySubscr ibers();
  172                                               }
  173                                               else{
  174                                                       if (!this.mov eCommand.i sSendDicom DataSetsAb ort()){
  175                                                                logg er.debug(" Putting Di comDataSet  into the  Send Queue .");
  176                                                                this .queue.put (dds);
  177                                                       }
  178                                                       el se{
  179                                                                this .subOperat ionsStatus .addFailed SOPInstanc eUID(dds.g etSOPInsta nceUID());
  180                                                                noti fySubscrib ers();
  181                                                       }
  182                                               }
  183                                      } 
  184                                      catch (I nterrupted Exception  iX) {
  185                                               logger.err or(iX.getM essage());
  186                                               if(dds !=  null){
  187                                                       th is.subOper ationsStat us.addFail edSOPInsta nceUID(dds .getSOPIns tanceUID() );
  188                                               }
  189                                               else{
  190                                                       th is.subOper ationsStat us.setFail edSubOpera tions();
  191                                               }
  192                                               notifySubs cribers();
  193                                      }
  194                                      catch (M ethodExcep tion mX) {
  195                                               logger.err or(mX.getM essage());
  196                                               if(dds !=  null){
  197                                                       th is.subOper ationsStat us.addFail edSOPInsta nceUID(dds .getSOPIns tanceUID() );
  198                                               }
  199                                               else{
  200                                                       th is.subOper ationsStat us.setFail edSubOpera tions();
  201                                               }
  202                                               notifySubs cribers();
  203                                      }
  204                                      catch (C onnectionE xception c X) {
  205                                               logger.err or(cX.getM essage());
  206                                               if(dds !=  null){
  207                                                       th is.subOper ationsStat us.addFail edSOPInsta nceUID(dds .getSOPIns tanceUID() );
  208                                               }
  209                                               else{
  210                                                       th is.subOper ationsStat us.setFail edSubOpera tions();
  211                                               }
  212                                               notifySubs cribers();
  213                                      }
  214                                      //Check  if CMove w as cancell ed.  If re ceived, st op sending  images an d send
  215                                      //       final CMov e operatio ns message  to the CM ove subscr iber.  Exi t Loop.
  216                                      if(this. moveComman d.isCancel MoveOperat ion()){
  217                                               subOperati onsStatus. setComplet eStatus(Su bOperation sStatus.CA NCEL);
  218                                               break;
  219                                      }
  220                             }
  221                             
  222                             try {
  223                                      if(!this .moveComma nd.isSendD icomDataSe tsAbort()) {
  224                                               this.queue .put(this. LASTBAG);                                       
  225                                      }
  226                             } 
  227                             catch  (Interrupt edExceptio n iX) {
  228                         logger.err or(iX.getM essage());
  229                         logger.err or("Failed  to queue  LAST BAG." );
  230                                      this.mov eCommand.s etGetDicom DataSetsDo ne(true);
  231                             }
  232                             
  233                             while( !this.move Command.is SendDicomD ataSetsDon e() && !th is.moveCom mand.isSen dDicomData SetsAbort( )){
  234                                      try {
  235                                               Thread.sle ep(2000);
  236                                      } 
  237                                      catch (I nterrupted Exception  e) {
  238                                               //ignore.
  239                                      }
  240                             }
  241                             
  242                             if(thi s.moveComm and.isSend DicomDataS etsAbort()  && !this. queue.isEm pty()){
  243                                      Iterator <IDicomDat aSet> queu eIter = th is.queue.i terator();
  244                                      while (q ueueIter.h asNext()){
  245                                               IDicomData Set tempdd s = queueI ter.next() ;
  246                                               this.subOp erationsSt atus.addFa iledSOPIns tanceUID(t empdds.get SOPInstanc eUID());
  247                                      }
  248                             }
  249                                          
  250                    //Cl ose the DI COM Associ ation to t he CStore  SCU.                                   
  251                    if(! this.moveC ommand.isS endDicomDa taSetsAbor t()){
  252                             try{
  253                                      logger.d ebug("Clos ing C-Stor e Associat ion.");
  254                                      scu.clos eStoreAsso ciation();
  255                             }
  256                             catch  (Associati onAbortExc eption aaX ) {
  257                         logger.err or(aaX.get Message()) ;
  258                         logger.err or("C-Stor e SCP Abor ted the DI COM C-Stor e Associat ion while  closing.") ;
  259                             }
  260                    } 
  261                    
  262                    if(t his.moveCo mmand.isSe ndDicomDat aSetsAbort ()){
  263                             subOpe rationsSta tus.setErr orComment( "C-Store S CU Associa tion abort ed.");
  264                             subOpe rationsSta tus.setCom pleteStatu s(SubOpera tionsStatu s.FAILURE_ COMMENT);
  265                    }
  266                    else {
  267                             subOpe rationsSta tus.setCom pleteStatu s(SubOpera tionsStatu s.SUCCESS) ;
  268                    }
  269                    
  270                    } 
  271                    catc h (Associa tionReject Exception  arX) {
  272                logger.e rror(arX.g etMessage( ));
  273                logger.e rror("C-St ore SCP re jecting DI COM C-Stor e Associat ion.");
  274                             summar yLogger.er ror("The C -Store Dim se message  was rejec ted by the  C-Storage  SCP.  Ref er to othe r logs for  more deta il.");
  275                subOpera tionsStatu s.setError Comment(re moteAE.get RemoteAETi tle()+" re jected Ass ociation R equested.\ n "+arX.ge tMessage() );
  276                subOpera tionsStatu s.setCompl eteStatus( SubOperati onsStatus. FAILURE_CO MMENT);
  277                             DicomS erviceStat s.getInsta nce().incr ementOutbo undAssocia tionReject Count(stor eAETitle);
  278                    } 
  279                    catc h (Associa tionInitia lizationEx ception ai X) {
  280                logger.e rror(aiX.g etMessage( ));
  281                logger.e rror("Exce ption thro wn opening  DICOM C-S tore Assoc iation.");
  282                             summar yLogger.er ror("The C -Storage S CU Dimse S ervice fai led to ini tialize.   " +
  283                                               "\nLikely  problem is  the DICOM  AE Securi ty Matrix  entry for  this " +
  284                                               "AETitle,  " +remoteA E.getRemot eAETitle() +", is con figured wi th the wro ng IP Addr ess and/or  Port#."+
  285                                               "\nRefer t o other lo gs for mor e detail." );
  286                subOpera tionsStatu s.setError Comment("A ssociation  Initializ ation exce ption.\n " +aiX.getMe ssage());
  287                subOpera tionsStatu s.setCompl eteStatus( SubOperati onsStatus. FAILURE_CO MMENT);
  288                    }
  289                    catc h(PostDico mInstanceS etExceptio n pdisX){
  290                logger.e rror(pdisX .getMessag e());
  291                logger.e rror("Exce ption thro wn opening  DICOM C-S tore Assoc iation.");
  292                             summar yLogger.er ror("The C -Storage S CU Dimse S ervice fai led to ini tialize.   Refer to o ther logs  for more d etail.");
  293                subOpera tionsStatu s.setError Comment("P osting Dic om Instanc e Set exce ption.\n " );
  294                subOpera tionsStatu s.setCompl eteStatus( SubOperati onsStatus. FAILURE_CO MMENT);
  295                    }
  296                    
  297  
  298                    //No tify Obser ver with t he final C Move Subop erations R esponse wi th list of  failed
  299                    //       SOP In stance UID s.
  300           lo gger.debug ("Dicom To olkit Laye r: " +
  301                             "Sendi ng final C -Move Resp onse to C- Move SCU." );
  302           no tifySubscr ibers();
  303       
  304           // Remove sub scribers f rom Observ able.
  305           su bOperation sPublisher .deleteObs ervers();
  306                    retu rn null;
  307           }
  308  
  309           pu blic int h ashCode()
  310           {
  311                    fina l int prim e = 31;
  312                    int  result = 1 ;
  313                    resu lt = prime  * result  + ((this.i nstances = = null) ?  0 : this.i nstances.h ashCode()) ;
  314                    resu lt = prime  * result  + ((this.s toreAETitl e== null)  ? 0 : this .storeAETi tle.hashCo de());
  315                    resu lt = prime  * result  + ((this.s cpListener  == null)  ? 0 : this .scpListen er.hashCod e());
  316                    resu lt = prime  * result  + ((this.m oveCommand  == null)  ? 0 : this .moveComma nd.hashCod e());
  317  
  318                    retu rn result;
  319           }
  320  
  321           
  322           @O verride
  323           pu blic boole an equals( Object obj )
  324           {
  325                    // T ODO Auto-g enerated m ethod stub
  326                    retu rn false;
  327           }
  328  
  329           
  330           /* *
  331            *  @return t he Instanc es
  332            * /
  333           pu blic Dicom InstanceSe t getInsta nces() {
  334                    retu rn this.in stances;
  335           }
  336  
  337           
  338           @O verride
  339           pr otected St ring param eterToStri ng()
  340           {
  341                    // T ODO Auto-g enerated m ethod stub
  342                    retu rn null;
  343           }
  344  
  345           @O verride
  346           pr otected bo olean areC lassSpecif icFieldsEq ual(Object  obj) {
  347                    // T ODO Auto-g enerated m ethod stub
  348                    retu rn false;
  349           }
  350           
  351           pr ivate Hash Set<String > createSO PClassUIDL ist(){
  352                    Hash Set<String > sopClass es = new H ashSet<Str ing>();
  353                    
  354                    Iter ator<Insta nceStorage Info> iter  = this.in stances.it erator();
  355                    
  356                    whil e(iter.has Next()){
  357                             Instan ceStorageI nfo info =  (Instance StorageInf o)iter.nex t();
  358                             String  sopClass  = info.get SopClassUI D();
  359                             if(sop Class != n ull){
  360                                      if(!sopC lasses.con tains(sopC lass)){
  361                                               sopClasses .add(sopCl ass);
  362                                      }
  363                             }
  364                    }
  365                    if(s opClasses. isEmpty()) {
  366                             logger .debug("No  SOP Class es from HI S. Will ha ve to use  SOP Classe s from DCF  configura tion file. ");
  367                    }
  368                    else {
  369                             logger .debug("SO P Class UI D List bas ed on info rmation re trieved fr om HIS: "+ sopClasses .toString( ));
  370                    }
  371                    retu rn sopClas ses;
  372           }
  373           
  374           pr ivate void  notifySub scribers() {
  375                if(subOp erationsPu blisher !=  null){
  376                    //No tify the P ublisher t o send the  status ob ject to th e subscrib ers.
  377                    subO perationsP ublisher.p ublish(sub Operations Status);
  378                }
  379           }
  380   }