757. EPMO Open Source Coordination Office Redaction File Detail Report

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

757.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\CoreRouter\main\src\java\gov\va\med\imaging\core CommandCreatorProvider.java Thu Oct 11 13:30:20 2018 UTC
2 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\CoreRouter\main\src\java\gov\va\med\imaging\core CommandCreatorProvider.java Wed Oct 17 18:46:35 2018 UTC

757.2 Comparison summary

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

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

757.4 Active regular expressions

No regular expressions were active.

757.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: May  4, 2011
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:     PI I
  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.cor e;
  27  
  28   import gov .va.med.im aging.core .interface s.router.C ommand;
  29   import gov .va.med.im aging.core .interface s.router.C ommandCont ext;
  30  
  31   import jav a.lang.ref lect.Const ructor;
  32   import jav a.lang.ref lect.Modif ier;
  33  
  34   import org .apache.lo gging.log4 j.LogManag er;
  35   import org .apache.lo gging.log4 j.Logger;
  36  
  37   /**
  38    * Command CreatorPro vider is a n abstract  base for  creating c ommands as  a provide r.  This h andles the  actual se arching fo r and crea ting
  39    * of the  command. I mplementat ions of th is provide r are resp onsible fo r specifyi ng the pac kages thei r commands  exist in  and for as signing
  40    * the com mand conte xt (creati ng an exte nsion if d esired)
  41    * 
  42    * @author   PI I
  43    *
  44    */
  45   public abs tract clas s CommandC reatorProv ider 
  46   {
  47           pr ivate Comm andContext  baseComma ndContext;
  48  
  49           pu blic Comma ndCreatorP rovider()
  50           {
  51  
  52           }
  53  
  54           /* *
  55            *  Return an  array of  the packag e names su pported by  this prov ider. Idea lly this l ist of pac kages is u nique in a  VISA depl oyment
  56            *  @return
  57            * /
  58           pr otected ab stract Str ing [] get CommandPac kageNames( );
  59           
  60           /* *
  61            *  Return th e command  context to  assign to  any comma nds owned  by this co mmand crea tor provid er. The as signed Com mandContex t should b
  62            *  based on  the baseCo mmandConte xt paramet er. If no  special ch anges need  to be mad e to the C ommandCont ext, this  method can  simply
  63            *  return ba seCommandC ontext
  64            *   
  65            *  @param ba seCommandC ontext
  66            *  @return
  67            * /
  68           pr otected ab stract Com mandContex t getComma ndContext( CommandCon text baseC ommandCont ext);
  69  
  70           pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(Comm andCreator Provider.c lass);
  71           pr otected Lo gger getLo gger()
  72           {
  73                    retu rn logger;
  74           }
  75           
  76           /* *
  77            *  Determine s if the c ommand is  supported  by this pr ovider
  78            *  @param co mmandClass Semantics
  79            *  @param pa rameterTyp es
  80            *  @param in itArgs
  81            *  @return
  82            * /
  83           pr otected bo olean isCo mmandSuppo rted(Comma ndClassSem antics com mandClassS emantics,
  84                             Class< ?>[] param eterTypes,  
  85                             Object [] initArg s)
  86           {
  87                    Cons tructor<?>  construct or = findC onstructor (commandCl assSemanti cs, 
  88                                      paramete rTypes, in itArgs, fa lse);
  89                    retu rn constru ctor != nu ll ? true  : false;
  90           }
  91  
  92           @S uppressWar nings("unc hecked")
  93           pr otected <R  extends O bject> Com mand<R> cr eateComman d(
  94                             Comman dClassSema ntics comm andClassSe mantics,
  95                             Class< ?>[] param eterTypes,  
  96                             Object [] initArg s)
  97           {
  98                    getL ogger().tr ace("Attem pting to c reate comm and '" + c ommandClas sSemantics .toString( true) + 
  99                                      "' with  CommandCre atorProvid er '" + th is.getClas s().getSim pleName()) ;
  100                    Cons tructor<?>  selectedC onstructor  = 
  101                             findCo nstructor( commandCla ssSemantic s, paramet erTypes, i nitArgs, t rue);
  102                    if(s electedCon structor = = null)
  103                    {
  104                             getLog ger().trac e("Cannot  find Comma nd using C ommandCrea torProvide r '" + thi s.getClass ().getSimp leName() +  
  105                                               "' of type  '" + comm andClassSe mantics.to String(tru e) + 
  106                                               "' failed  because th ere were n o construc tors like  '" + makeC onstructor Message(co mmandClass Semantics,  parameter Types) + 
  107                             "'.");
  108                    }
  109                    else
  110                    {
  111                             try
  112                             {
  113                                      Command< R> command  = (Comman d<R>)selec tedConstru ctor.newIn stance(ini tArgs);
  114                                      command. setCommand Context(ge tCommandCo ntext(getB aseCommand Context()) );
  115                                      getLogge r().debug( "Successfu lly create d command  ["+command .getClass( ).getName( )+"]");
  116                                      return c ommand;
  117                             } 
  118                             catch  (Exception  x)
  119                             {
  120                                      getLogge r().warn(" Request to  construct  Command o f type '"  + commandC lassSemant ics.toStri ng(true) +  
  121                                                       "'  in Comman dCreatorPr ovider '"  + this.get Class().ge tSimpleNam e() + "' f ailed in t he constru ctor.", x) ;
  122                             } 
  123                    }        
  124  
  125                    retu rn null;
  126           }
  127           
  128           pr ivate Cons tructor<?>  findConst ructor(Com mandClassS emantics c ommandClas sSemantics ,
  129                             Class< ?>[] param eterTypes,  
  130                             Object [] initArg s, boolean  initializ eClass)
  131           {
  132                    if(c ommandClas sSemantics  != null)
  133                    {
  134                             try
  135                             {
  136                                      Class<?  extends Co mmand<?>>  commandCla ss = 
  137                                               findComman dClass( co mmandClass Semantics. toStringAs Implementa tion(), 
  138                                                                comm andClassSe mantics.ge tCommandPa ckage(), i nitializeC lass);
  139  
  140                                      Construc tor<?> sel ectedConst ructor = n ull;                                 
  141                                      Construc tor<?>[] c ommandCons tructors =  commandCl ass.getCon structors( );
  142                                      for(Cons tructor<?>  construct or : comma ndConstruc tors)
  143                                      {
  144                                               if( Modifi er.isPubli c( constru ctor.getMo difiers()  ) )
  145                                               {
  146                                                       if (evaluateC onstructor Parameters (construct or, parame terTypes))
  147                                                       {
  148                                                                if(s electedCon structor ! = null)
  149                                                                {
  150                                                                         getLog ger().erro r(
  151                                                                                           "Request t o construc t Command  of type '"  + command ClassSeman tics.toStr ing(true) 
  152                                                                                           "' failed  multiple c onstructor s like '"  + makeCons tructorMes sage(comma ndClassSem antics, pa rameterTyp es) + 
  153                                                                         "' cou ld not be  differenti ated.");
  154                                                                         return  null;
  155                                                                }
  156                                                                sele ctedConstr uctor = co nstructor;
  157                                                       }
  158                                               }
  159                                      }
  160  
  161                                      if(selec tedConstru ctor == nu ll)
  162                                      {
  163                                               getLogger( ).error(
  164                                                                "Req uest to co nstruct Co mmand of t ype '" + c ommandClas sSemantics .toString( true) + 
  165                                                                "' f ailed beca use there  were no co nstructors  like '" +  makeConst ructorMess age(comman dClassSema ntics, par ameterType s) + 
  166                                               "'.");
  167                                      }
  168                                      else
  169                                      {
  170                                               getLogger( ).debug("S uccessfull y selected  Construct or ["+sele ctedConstr uctor.getC lass().get Name()+"]" );
  171                                               return sel ectedConst ructor;
  172                                      }
  173                             } 
  174                             catch  (ClassNotF oundExcept ion x)
  175                             {
  176                                      //getLog ger().erro r("Request  to constr uct Comman d of type  '" + comma ndClassSem antics.toS tring() +  "' failed  because th e class wa s not foun d.");
  177                                      getLogge r().trace( "Unable to  construct  Command o f type '"  + commandC lassSemant ics.toStri ng() + "'  using Comm andCreator Provider ' " + this.g etClass(). getSimpleN ame() + "' .");
  178                             }
  179                    }
  180  
  181                    retu rn null;
  182           }
  183  
  184           /* *
  185            *  For error  and info  messages,  build a St ring repre sentation  of the
  186            *  construct or we are  looking fo r.
  187            *   
  188            *  @param co mmandClass Semantics
  189            *  @param pa rameterTyp es
  190            *  @return
  191            * /
  192           pr ivate Stri ng makeCon structorMe ssage(
  193                             Comman dClassSema ntics comm andClassSe mantics,
  194                             Class< ?>[] argTy pes)
  195           {
  196                    Stri ngBuilder  sb = new S tringBuild er();
  197  
  198                    sb.a ppend(comm andClassSe mantics.to String());
  199                    sb.a ppend("(") ;
  200                    bool ean firstA rg = true;
  201                    for( Class<?> a rgType : a rgTypes)
  202                    {
  203                             if(!fi rstArg)
  204                                      sb.appen d(", ");
  205                             sb.app end(argTyp e.getName( ));
  206                             firstA rg = false ;
  207                    }
  208  
  209                    sb.a ppend(")") ;
  210  
  211                    retu rn sb.toSt ring();
  212           }
  213  
  214           /* *
  215            *  @param st ringAsImpl ementation
  216            *  @return
  217            *  @throws C lassNotFou ndExceptio
  218            * /
  219           @S uppressWar nings("unc hecked")
  220           pr ivate Clas s<? extend s Command< ?>> findCo mmandClass (String st ringAsImpl ementation ,
  221                             String  commandPa ckage, boo lean initi alizeClass )
  222           th rows Class NotFoundEx ception
  223           {                 
  224                    Stri ng [] comm andPackage Names = ge tCommandPa ckageNames ();
  225                    if(c ommandPack age != nul l && comma ndPackage. length() >  0)
  226                    {
  227                             String  packageAn dCommandNa me = comma ndPackage  + "." + st ringAsImpl ementation ;
  228                             // if  the packag e is speci fied then  need to ch eck if the  package i s part of  the packag es managed  by
  229                             // the  current p rovider.   because al l the comm ands are i n the clas spath, any one can fi nd them
  230                             // but  we want t o be sure  the "corre ct" provid er finds i t so they  can assign  the corre ct Command Context
  231                             
  232                             for(St ring comma ndPackageN ame : comm andPackage Names)
  233                             {
  234                                      if(comma ndPackage. equals(com mandPackag eName))
  235                                      {                         
  236                                               // if the  command pa ckage was  found in t his provid er, try to  create th e command  (really sh ould work)
  237                                               try
  238                                               {                                  
  239                                                       ge tLogger(). trace("Sea rching for  command ' " + packag eAndComman dName + "'  using spe cified pac kage");
  240                                                       Cl ass<? exte nds Comman d<?>> comm andClass =  
  241                                                                (Cla ss<? exten ds Command <?>>)Class .forName(  packageAnd CommandNam e, 
  242                                                                                  initiali zeClass, t his.getCla ss().getCl assLoader( ) );
  243  
  244                                                       ge tLogger(). debug("Suc cessfully  created co mmand pack age class  ["+ comman dClass.get Class().ge tName()+"] ");
  245                                                       re turn comma ndClass;
  246                                              
  247                                               catch (Cla ssNotFound Exception  cnfX){}
  248                                               catch (Cla ssCastExce ption ccX) {}
  249                                      }
  250                             }
  251                             // may  not find  command if  this prov ider doesn 't support  that comm and
  252                             getLog ger().trac e("Did not  find comm and '" + p ackageAndC ommandName  + "' usin g specifie d package,  cannot cr eate comma nd - check  specified  .");
  253                    }
  254                    else
  255                    {
  256                             logger .trace("Re quest did  not pass i n a Comman d Package  for " + st ringAsImpl ementation );
  257                             // if  package sp ecified, d on't brute  force it
  258                             for(St ring comma ndPackageN ame : comm andPackage Names)
  259                             {
  260                                      try
  261                                      {
  262                                               String pac kageAndCom mandName =  commandPa ckageName  + "." + st ringAsImpl ementation ;
  263                                               Class<? ex tends Comm and<?>> co mmandClass  = 
  264                                                       (C lass<? ext ends Comma nd<?>>)Cla ss.forName ( packageA ndCommandN ame, 
  265                                                                         initia lizeClass,  this.getC lass().get ClassLoade r() );
  266                                               getLogger( ).debug("S uccessfull y created  command cl ass ["+ co mmandClass .getClass( ).getName( )+"]");        
  267                                               return com mandClass;
  268                                      } 
  269                                      catch (C lassNotFou ndExceptio n cnfX){}
  270                                      catch (C lassCastEx ception cc X){}
  271                             }
  272                    }
  273  
  274                    thro w new Clas sNotFoundE xception(" No valid c ommand cla ss named ' " + string AsImplemen tation + " ' found in  any of th e command  packages") ;
  275           }
  276  
  277           /* *
  278            *  @param co nstructor
  279            *  @param pa rameterTyp es
  280            *  @return
  281            * /
  282           pr ivate bool ean evalua teConstruc torParamet ers(
  283                             Constr uctor<?> c onstructor ,
  284                             Class< ?>[] param eterTypes)
  285           {
  286                    Clas s<?>[] con structorPa rameterTyp es = const ructor.get ParameterT ypes();
  287  
  288                    // i f both par ameters li sts are nu ll or zero  length, r eturn true
  289                    if(  (parameter Types == n ull || par ameterType s.length = = 0) && 
  290                                      (constru ctorParame terTypes = = null ||  constructo rParameter Types.leng th == 0) )
  291                             return  true;
  292  
  293                    // i f the para meters lis t are null  or zero l ength and  the constr uctor para meter list s are not  then retur n false
  294                    if(  (parameter Types == n ull || par ameterType s.length = = 0) && 
  295                                      (constru ctorParame terTypes ! = null &&  constructo rParameter Types.leng th > 0) )
  296                             return  false;
  297  
  298                    // i f the para meters lis t are not  null or ze ro length  and the co nstructor  parameter  lists are  then retur n false
  299                    if(  (parameter Types != n ull && par ameterType s.length >  0) && 
  300                                      (constru ctorParame terTypes = = null ||  constructo rParameter Types.leng th == 0) )
  301                             return  false;
  302  
  303                    // i f the para meter type  lists are  different  length, r eturn null
  304                    if(  parameterT ypes.lengt h  != cons tructorPar ameterType s.length )
  305                             return  false;
  306  
  307                    // f inally com pare to se e if the p arameter l ists are c ompatible
  308                    for( int parame terIndex=0 ; paramete rIndex < c onstructor ParameterT ypes.lengt h; ++param eterIndex)
  309                    {
  310                             Class< ?> paramet erType = p arameterTy pes[parame terIndex];
  311                             Class< ?> constru ctorParame terType =  constructo rParameter Types[para meterIndex ];
  312  
  313                             // if  the parame terType is  assignabl e to the c onstructor  type then
  314                             // we  should not  get a Cla ssCastExce ption call ing the co nstructor
  315                             // oth erwise we  will and t he constru ctor is in compatible  with our  parameters
  316                             if( !  constructo rParameter Type.isAss ignableFro m(paramete rType) )
  317                                      return f alse;
  318                    }
  319  
  320                    retu rn true;
  321           }
  322  
  323           pu blic void  setBaseCom mandContex t(CommandC ontext bas eCommandCo ntext) 
  324           {
  325                    this .baseComma ndContext  = baseComm andContext ;
  326           }
  327  
  328           pu blic Comma ndContext  getBaseCom mandContex t() {
  329                    retu rn baseCom mandContex t;
  330           }
  331   }