25. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/5/2018 10:24:09 AM 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.

25.1 Files compared

# Location File Last Modified
1 patch_205_build_9.zip\Java\ImagingCommon\main\src\java\gov\va\med\imaging\facade\configuration AbstractBaseFacadeConfiguration.java Wed May 30 14:35:27 2018 UTC
2 patch_205_build_9.zip\Java\ImagingCommon\main\src\java\gov\va\med\imaging\facade\configuration AbstractBaseFacadeConfiguration.java Fri Jun 1 20:45:43 2018 UTC

25.2 Comparison summary

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

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

25.4 Active regular expressions

No regular expressions were active.

25.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: Jan  7, 2009
  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   package go v.va.med.i maging.fac ade.config uration;
  27  
  28   import jav a.beans.XM LDecoder;
  29   import jav a.io.File;
  30   import jav a.io.FileI nputStream ;
  31   import jav a.io.FileN otFoundExc eption;
  32   import jav a.io.FileO utputStrea m;
  33   import jav a.io.IOExc eption;
  34   import jav a.lang.ref lect.Field ;
  35   import jav a.util.Arr ayList;
  36   import jav a.util.Lis t;
  37  
  38   import org .apache.lo gging.log4 j.LogManag er;
  39   import org .apache.lo gging.log4 j.Logger;
  40  
  41   import com .thoughtwo rks.xstrea m.XStream;
  42  
  43   /**
  44    * @author   PII
  45    *
  46    */
  47   public abs tract clas s Abstract BaseFacade Configurat ion 
  48   {
  49           pr otected fi nal static  Logger lo gger = 
  50                    LogM anager.get Logger(Abs tractBaseF acadeConfi guration.c lass);
  51           
  52           pr ivate bool ean dirty;
  53           
  54           /* *
  55            *  Indicates  if the co nfiguratio n has been  updated o n disk and  this in m emory conf iguration  object may  be
  56            *  considere d dirty. T his doesn' t mean the  configura tion has t o be refre shed, that  is up to  the develo per/usage
  57            *  
  58            *  @return
  59            * /
  60           pr otected bo olean isDi rty() {
  61                    retu rn dirty;
  62           }
  63  
  64           pu blic void  setDirty(b oolean dir ty) {
  65                    this .dirty = d irty;
  66           }
  67  
  68           pr otected Lo gger getLo gger()
  69           {
  70                    retu rn logger;
  71           }
  72           
  73           // private fi nal String  configura tionFilena me;
  74           
  75           pu blic Abstr actBaseFac adeConfigu ration()
  76           {                 
  77                    //th is.configu rationFile name = fil ename;
  78           }
  79           
  80           pu blic Abstr actBaseFac adeConfigu ration loa dConfigura tion()
  81           {
  82                    Abst ractBaseFa cadeConfig uration co nfig = loa dConfigura tionFromFi le();
  83                    if(c onfig == n ull)
  84                    {
  85                             config  = loadDef aultConfig uration();
  86                             config .storeConf iguration( );
  87                    }
  88                    retu rn config;
  89           }                 
  90           
  91           
  92           pr ivate Abst ractBaseFa cadeConfig uration lo adConfigur ationFromF ile()
  93           {
  94                    File InputStrea m inputStr eam = null ;
  95                    try
  96                    {
  97                             File f ile = new  File(getCo nfiguratio nFileName( ));
  98                             if(fil e.exists() )
  99                             {                         
  100                                      try
  101                                      {
  102                                               inputStrea m = new Fi leInputStr eam(file);
  103                                               XStream xs tream = ge tXtream();
  104  
  105                                               AbstractBa seFacadeCo nfiguratio n configur ation = 
  106                                                       (A bstractBas eFacadeCon figuration )xstream.f romXML(inp utStream);
  107                                               return con figuration ;
  108                                      }
  109                                      catch(co m.thoughtw orks.xstre am.convert ers.Conver sionExcept ion cX)
  110                                      {
  111                                               logger.deb ug(cX.getM essage());
  112                                               try 
  113                                               {
  114                                                       in putStream. close();
  115                                                       in putStream  = null;
  116                                               }
  117                                               catch(Exce ption ex)  {}
  118                                               inputStrea m = new Fi leInputStr eam(file);
  119                                               XMLDecoder  decoder =  null;
  120                                               try
  121                                               {
  122                                                       de coder = ne w XMLDecod er(new Fil eInputStre am(file.ge tAbsoluteP ath()));
  123                                                       Ab stractBase FacadeConf iguration  configurat ion = (Abs tractBaseF acadeConfi guration)d ecoder.rea dObject();
  124                                                       lo gger.info( "Loaded co nfiguratio n file ["  + file.get AbsolutePa th() + "]" );
  125                                                       re turn confi guration;
  126                                               }
  127                                               finally
  128                                               {
  129                                                       if (decoder ! = null)
  130                                                                deco der.close( );
  131                                               }
  132                                      }
  133                             }
  134                             else
  135                             {
  136                                      logger.e rror("File  [" + file .getAbsolu tePath() +  "] does n ot exist") ;
  137                                      return n ull;
  138                             }
  139                    }
  140                    catc h(FileNotF oundExcept ion fnfX)
  141                    {
  142                             logger .error("Er ror readin g configur ation, " +  fnfX.getM essage(),  fnfX);
  143                             return  null;
  144                    }
  145                    fina lly
  146                    {
  147                             if(inp utStream ! = null)
  148                             {
  149                                      try {inp utStream.c lose();}
  150                                      catch(Ex ception ex ) {}
  151                             }
  152                    }
  153           }
  154           
  155           pu blic abstr act Abstra ctBaseFaca deConfigur ation load DefaultCon figuration ();
  156           
  157           
  158           pu blic synch ronized vo id storeCo nfiguratio n()
  159           {
  160                    File OutputStre am output  = null;
  161                    try
  162                    {
  163                             String  filename  = getConfi gurationFi leName();
  164                             output  = new Fil eOutputStr eam(filena me, false) ;
  165                             XStrea m xstream  = getXtrea m();
  166                             xstrea m.toXML(th is, output );
  167                             logger .info("Sto red config uration fi le [" + fi lename + " ]");
  168                    }
  169                    catc h(IOExcept ion ioX)
  170                    {
  171                             logger .error("Er ror storin g configur ation, " +  ioX.getMe ssage(), i oX);
  172                    }
  173                    fina lly
  174                    {
  175                             if(out put != nul l)
  176                             {
  177                                      try {out put.close( );}
  178                                      catch(Ex ception ex ) {}
  179                             }
  180                    }                 
  181           }
  182           
  183           pr ivate XStr eam getXtr eam()
  184           {
  185                    XStr eam xstrea m = new XS tream();
  186                    Stri ng [] omit tedFields  = getOmitt edFields() ;
  187                    if(o mittedFiel ds != null  && omitte dFields.le ngth > 0)
  188                    {
  189                             for(St ring omitt edField :  omittedFie lds)
  190                             {
  191                                      xstream. omitField( getClass() , omittedF ield);             
  192                             }
  193                    }
  194                    
  195                    xstr eam.regist erConverte r(new Encr yptedConfi gurationPr opertyStri ngSingleVa lueConvert er());
  196                    retu rn xstream ;
  197           }
  198           
  199           /* *
  200            *  Deletes t he configu ration fil e from dis k (does no t affect c onfigurati ons in mem ory). 
  201            *  This meth od is prim arily used  for testi ng purpose s, there a re not any  real reas ons in pro duction wh y a config  file
  202            *  should be  deleted. 
  203            * /
  204           pu blic synch ronized bo olean dele teConfigur ation()
  205           {
  206                    Stri ng filenam e = getCon figuration FileName() ;
  207                    logg er.info("D eleting co nfiguratio n file '"  + filename  + "'.");
  208                    File  file = ne w File(fil ename);
  209                    if(f ile.exists ())
  210                    {
  211                             if(!fi le.delete( ))
  212                             {
  213                                      logger.e rror("Cann ot delete  file.");
  214                                      return f alse;                              
  215                             }
  216                    }
  217                    retu rn true;
  218           }
  219           
  220           /* *
  221            *  Get the c onfigurati on directo ry.
  222            *  Usually,  derived cl asses do n ot need to  access th e director y
  223            *  and just  rely on th e storeCon figuration )( and loa dConfigura tion()
  224            *  methods.   This meth od is prov ided for e xceptional  cases.
  225            * /
  226           pr ivate File  getConfig urationDir ectory()
  227           {
  228                    Stri ng configu rationDire ctoryName  = System.g etenv("vix config");
  229                    if(c onfigurati onDirector yName == n ull)
  230                             config urationDir ectoryName  = System. getPropert y("user.ho me");
  231                    if(c onfigurati onDirector yName == n ull)
  232                             config urationDir ectoryName  = "/";
  233                    
  234                    File  configura tionDirect ory = new  File(confi gurationDi rectoryNam e);
  235                    if(!  configura tionDirect ory.exists ())
  236                             config urationDir ectory.mkd irs();                  // make  the direct ories if t hey don't  exist
  237                    
  238                    retu rn configu rationDire ctory;
  239           }
  240           
  241           /* *
  242            *  Get a ref erence to  the config uration fi le.
  243            *  This meth od will cr eate the c onfigurati on and par ent direct ories if t hey do not  exist.
  244            *  If the Pr ovider doe s not have  a configu ration fil e then thi s method r eturns nul l.
  245            *  @return
  246            *  @throws I OException  
  247            * /
  248           /*
  249           pr ivate File  getConfig urationFil e() 
  250           th rows IOExc eption
  251           {
  252                    Stri ng configu rationFile Name = get Configurat ionFileNam e();
  253                    if(  configurat ionFileNam e == null)
  254                             return  null;
  255                    File  configura tionFile =  new File( configurat ionFileNam e);
  256                    if(!  configura tionFile.e xists())
  257                             config urationFil e.createNe wFile();
  258                    
  259                    retu rn configu rationFile ;
  260           }* /
  261           
  262           /* *
  263            *  Build a f ilename in  the stand ardized fo rmat from  the
  264            *  provider  name and v ersion.  A  Provider  that does  not
  265            *  have any  persistent  configura tion must  override t his 
  266            *  method to  return nu ll.
  267            *  This meth od will as sure that  the parent  directory  exists
  268            *  before re turning.   It will NO T create t he configu ration
  269            *  file if i t does not  exist.
  270            *  
  271            *  The prefe rred store  locations  are (in o rder):
  272            *  1.) The d irectory o f the VIX  configurat ion
  273            *  2.) The u ser home d irectory
  274            *  3.) The r oot direct ory
  275            *  
  276            *  @return
  277            * /
  278           pr ivate Stri ng getConf igurationF ileName()
  279           {
  280                    File  configura tionDirect ory = getC onfigurati onDirector y();      
  281                    retu rn configu rationDire ctory.getA bsolutePat h() + "/"  + this.get Class().ge tSimpleNam e() + ".co nfig"; 
  282           }
  283           
  284           /* *
  285            *  Override  this metho d if you w ould like  to have fi elds omitt ed from th e XML outp ut. Any fi eld name l isted here  will not  be include
  286            *  when this  configura tion objec t is writt en to disk  but it st ill can be  read from  disk if i t exists i n the XML
  287            *  @return
  288            * /
  289           pr ivate Stri ng [] getO mittedFiel ds()
  290           {
  291                    List <String> o mittedFiel ds = new A rrayList<S tring>();
  292                    Clas s<?> clazz  = this.ge tClass();
  293                    
  294                    Fiel d [] field s = clazz. getDeclare dFields();
  295                    
  296                    //Fi eld [] fie lds = claz z.getField s();
  297                    for( Field fiel d : fields )
  298                    {
  299                             if(fie ld.isAnnot ationPrese nt(HiddenC onfigurati onField.cl ass))
  300                             {
  301                                      omittedF ields.add( field.getN ame());
  302                             }
  303                             else i f(field.is Annotation Present(Hi ddenString Configurat ionField.c lass))
  304                             {
  305                                      if(isStr ingFieldDe faultValue (field))
  306                                      {
  307                                               omittedFie lds.add(fi eld.getNam e());
  308                                      }                                  
  309                             }
  310                             else i f(field.is Annotation Present(Hi ddenBoolea nConfigura tionField. class))
  311                             {
  312                                      if(isBoo leanFieldD efaultValu e(field))
  313                                               omittedFie lds.add(fi eld.getNam e());
  314                             }
  315                             else i f(field.is Annotation Present(Hi ddenIntCon figuration Field.clas s))
  316                             {
  317                                      if(isInt FieldDefau ltValue(fi eld))
  318                                               omittedFie lds.add(fi eld.getNam e());
  319                             }
  320                    }
  321                    retu rn omitted Fields.toA rray(new S tring[omit tedFields. size()]);
  322           }
  323           
  324           pr ivate bool ean isIntF ieldDefaul tValue(Fie ld field)
  325           {
  326                    try
  327                    {
  328                             field. setAccessi ble(true);
  329                             int va lue = fiel d.getInt(t his);
  330                             return  value ==  0;
  331                    }
  332                    catc h (Illegal ArgumentEx ception e)
  333                    {
  334                             logger .error("Il legalArgum entExcepti on reading  property  value, " +  e.getMess age());
  335                    } 
  336                    catc h (Illegal AccessExce ption e)
  337                    {
  338                             logger .error("Il legalAcces sException  reading p roperty va lue, " + e .getMessag e());
  339                    } 
  340                    retu rn false;
  341           }
  342           
  343           pr ivate bool ean isBool eanFieldDe faultValue (Field fie ld)
  344           {
  345                    try
  346                    {
  347                             field. setAccessi ble(true);
  348                             boolea n value =  field.getB oolean(thi s);
  349                             return  value ==  false;
  350                    }
  351                    catc h (Illegal ArgumentEx ception e)
  352                    {
  353                             logger .error("Il legalArgum entExcepti on reading  property  value, " +  e.getMess age());
  354                    } 
  355                    catc h (Illegal AccessExce ption e)
  356                    {
  357                             logger .error("Il legalAcces sException  reading p roperty va lue, " + e .getMessag e());
  358                    } 
  359                    retu rn false;
  360           }
  361           
  362           pr ivate bool ean isStri ngFieldDef aultValue( Field fiel d)
  363           {
  364                    try
  365                    {
  366                             field. setAccessi ble(true);
  367                             Object  value = f ield.get(t his);
  368                             return  value ==  null;
  369                    }
  370                    catc h (Illegal ArgumentEx ception e)
  371                    {
  372                             logger .error("Il legalArgum entExcepti on reading  property  value, " +  e.getMess age());
  373                    } 
  374                    catc h (Illegal AccessExce ption e)
  375                    {
  376                             logger .error("Il legalAcces sException  reading p roperty va lue, " + e .getMessag e());
  377                    } 
  378                    retu rn false;
  379           }
  380   }