102. EPMO Open Source Coordination Office Redaction File Detail Report

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

102.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreRouter\main\src\java\gov\va\med\imaging\core CommandCreatorProvider.java Mon Dec 4 21:34:32 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreRouter\main\src\java\gov\va\med\imaging\core CommandCreatorProvider.java Mon Dec 4 21:58:22 2017 UTC

102.2 Comparison summary

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

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

102.4 Active regular expressions

No regular expressions were active.

102.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:          
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.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         
WERFEJ
  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().de bug("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().debu g("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  
  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                                               return sel ectedConst ructor;
  171                                      }
  172                             } 
  173                             catch  (ClassNotF oundExcept ion x)
  174                             {
  175                                      //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.");
  176                                      getLogge r().debug( "Unable to  construct  Command o f type '"  + commandC lassSemant ics.toStri ng() + "'  using Comm andCreator Provider ' " + this.g etClass(). getSimpleN ame() + "' .");
  177                             }
  178                    }
  179  
  180                    retu rn null;
  181           }
  182  
  183           /* *
  184            *  For error  and info  messages,  build a St ring repre sentation  of the
  185            *  construct or we are  looking fo r.
  186            *   
  187            *  @param co mmandClass Semantics
  188            *  @param pa rameterTyp es
  189            *  @return
  190            * /
  191           pr ivate Stri ng makeCon structorMe ssage(
  192                             Comman dClassSema ntics comm andClassSe mantics,
  193                             Class< ?>[] argTy pes)
  194           {
  195                    Stri ngBuilder  sb = new S tringBuild er();
  196  
  197                    sb.a ppend(comm andClassSe mantics.to String());
  198                    sb.a ppend("(") ;
  199                    bool ean firstA rg = true;
  200                    for( Class<?> a rgType : a rgTypes)
  201                    {
  202                             if(!fi rstArg)
  203                                      sb.appen d(", ");
  204                             sb.app end(argTyp e.getName( ));
  205                             firstA rg = false ;
  206                    }
  207  
  208                    sb.a ppend(")") ;
  209  
  210                    retu rn sb.toSt ring();
  211           }
  212  
  213           /* *
  214            *  @param st ringAsImpl ementation
  215            *  @return
  216            *  @throws C lassNotFou ndExceptio
  217            * /
  218           @S uppressWar nings("unc hecked")
  219           pr ivate Clas s<? extend s Command< ?>> findCo mmandClass (String st ringAsImpl ementation ,
  220                             String  commandPa ckage, boo lean initi alizeClass )
  221           th rows Class NotFoundEx ception
  222           {                 
  223                    Stri ng [] comm andPackage Names = ge tCommandPa ckageNames ();
  224                    if(c ommandPack age != nul l && comma ndPackage. length() >  0)
  225                    {
  226                             String  packageAn dCommandNa me = comma ndPackage  + "." + st ringAsImpl ementation ;
  227                             // if  the packag e is speci fied then  need to ch eck if the  package i s part of  the packag es managed  by
  228                             // the  current p rovider.   because al l the comm ands are i n the clas spath, any one can fi nd them
  229                             // but  we want t o be sure  the "corre ct" provid er finds i t so they  can assign  the corre ct Command Context
  230                             
  231                             for(St ring comma ndPackageN ame : comm andPackage Names)
  232                             {
  233                                      if(comma ndPackage. equals(com mandPackag eName))
  234                                      {                         
  235                                               // if the  command pa ckage was  found in t his provid er, try to  create th e command  (really sh ould work)
  236                                               try
  237                                               {                                  
  238                                                       ge tLogger(). debug("Sea rching for  command ' " + packag eAndComman dName + "'  using spe cified pac kage");
  239                                                       Cl ass<? exte nds Comman d<?>> comm andClass =  
  240                                                                (Cla ss<? exten ds Command <?>>)Class .forName(  packageAnd CommandNam e, 
  241                                                                                  initiali zeClass, t his.getCla ss().getCl assLoader( ) );
  242  
  243                                                       re turn comma ndClass;
  244                                              
  245                                               catch (Cla ssNotFound Exception  cnfX){}
  246                                               catch (Cla ssCastExce ption ccX) {}
  247                                      }
  248                             }
  249                             // may  not find  command if  this prov ider doesn 't support  that comm and
  250                             getLog ger().debu g("Did not  find comm and '" + p ackageAndC ommandName  + "' usin g specifie d package,  cannot cr eate comma nd - check  specified  .");
  251                    }
  252                    else
  253                    {
  254                             // if  package sp ecified, d on't brute  force it
  255                             for(St ring comma ndPackageN ame : comm andPackage Names)
  256                             {
  257                                      try
  258                                      {
  259                                               String pac kageAndCom mandName =  commandPa ckageName  + "." + st ringAsImpl ementation ;
  260                                               Class<? ex tends Comm and<?>> co mmandClass  = 
  261                                                       (C lass<? ext ends Comma nd<?>>)Cla ss.forName ( packageA ndCommandN ame, 
  262                                                                         initia lizeClass,  this.getC lass().get ClassLoade r() );
  263           
  264                                               return com mandClass;
  265                                      } 
  266                                      catch (C lassNotFou ndExceptio n cnfX){}
  267                                      catch (C lassCastEx ception cc X){}
  268                             }
  269                    }
  270  
  271                    thro w new Clas sNotFoundE xception(" No valid c ommand cla ss named ' " + string AsImplemen tation + " ' found in  any of th e command  packages") ;
  272           }
  273  
  274           /* *
  275            *  @param co nstructor
  276            *  @param pa rameterTyp es
  277            *  @return
  278            * /
  279           pr ivate bool ean evalua teConstruc torParamet ers(
  280                             Constr uctor<?> c onstructor ,
  281                             Class< ?>[] param eterTypes)
  282           {
  283                    Clas s<?>[] con structorPa rameterTyp es = const ructor.get ParameterT ypes();
  284  
  285                    // i f both par ameters li sts are nu ll or zero  length, r eturn true
  286                    if(  (parameter Types == n ull || par ameterType s.length = = 0) && 
  287                                      (constru ctorParame terTypes = = null ||  constructo rParameter Types.leng th == 0) )
  288                             return  true;
  289  
  290                    // 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
  291                    if(  (parameter Types == n ull || par ameterType s.length = = 0) && 
  292                                      (constru ctorParame terTypes ! = null &&  constructo rParameter Types.leng th > 0) )
  293                             return  false;
  294  
  295                    // 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
  296                    if(  (parameter Types != n ull && par ameterType s.length >  0) && 
  297                                      (constru ctorParame terTypes = = null ||  constructo rParameter Types.leng th == 0) )
  298                             return  false;
  299  
  300                    // i f the para meter type  lists are  different  length, r eturn null
  301                    if(  parameterT ypes.lengt h  != cons tructorPar ameterType s.length )
  302                             return  false;
  303  
  304                    // f inally com pare to se e if the p arameter l ists are c ompatible
  305                    for( int parame terIndex=0 ; paramete rIndex < c onstructor ParameterT ypes.lengt h; ++param eterIndex)
  306                    {
  307                             Class< ?> paramet erType = p arameterTy pes[parame terIndex];
  308                             Class< ?> constru ctorParame terType =  constructo rParameter Types[para meterIndex ];
  309  
  310                             // if  the parame terType is  assignabl e to the c onstructor  type then
  311                             // we  should not  get a Cla ssCastExce ption call ing the co nstructor
  312                             // oth erwise we  will and t he constru ctor is in compatible  with our  parameters
  313                             if( !  constructo rParameter Type.isAss ignableFro m(paramete rType) )
  314                                      return f alse;
  315                    }
  316  
  317                    retu rn true;
  318           }
  319  
  320           pu blic void  setBaseCom mandContex t(CommandC ontext bas eCommandCo ntext) 
  321           {
  322                    this .baseComma ndContext  = baseComm andContext ;
  323           }
  324  
  325           pu blic Comma ndContext  getBaseCom mandContex t() {
  326                    retu rn baseCom mandContex t;
  327           }
  328   }