43. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/20/2018 12:56:42 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.

43.1 Files compared

# Location File Last Modified
1 CTT_Release_8_June_2018.zip\CTT_ISAAC\metacontent-store\ISAAC\db-config-builder\src\main\java\gov\vha\isaac\ochre\pombuilder\upload SrcUploadCreator.java Tue Jul 17 16:29:27 2018 UTC
2 CTT_Release_8_June_2018.zip\CTT_ISAAC\metacontent-store\ISAAC\db-config-builder\src\main\java\gov\vha\isaac\ochre\pombuilder\upload SrcUploadCreator.java Wed Jul 18 20:42:33 2018 UTC

43.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 672
Changed 1 2
Inserted 0 0
Removed 0 0

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

43.4 Active regular expressions

No regular expressions were active.

43.5 Comparison detail

  1   /**
  2    * Copyrig ht Notice
  3    *
  4    * This is  a work of  the U.S.  Government  and is no t subject  to copyrig ht
  5    * protect ion in the  United St ates. Fore ign copyri ghts may a pply.
  6    * 
  7    * License d under th e Apache L icense, Ve rsion 2.0  (the "Lice nse");
  8    * you may  not use t his file e xcept in c ompliance  with the L icense.
  9    * You may  obtain a  copy of th e License  at
  10    *
  11    * http:// www.apache .org/licen ses/LICENS E-2.0
  12    *
  13    * Unless  required b y applicab le law or  agreed to  in writing , software
  14    * distrib uted under  the Licen se is dist ributed on  an "AS IS " BASIS,
  15    * WITHOUT  WARRANTIE S OR CONDI TIONS OF A NY KIND, e ither expr ess or imp lied.
  16    * See the  License f or the spe cific lang uage gover ning permi ssions and
  17    * limitat ions under  the Licen se.
  18    */
  19   package go v.vha.isaa c.ochre.po mbuilder.u pload;
  20  
  21   import jav a.io.File;
  22   import jav a.nio.file .Files;
  23   import jav a.util.Arr ayList;
  24   import jav a.util.Has hMap;
  25   import jav a.util.Lis t;
  26   import jav a.util.con current.Ex ecutionExc eption;
  27  
  28   import org .apache.co mmons.lang 3.StringUt ils;
  29   import org .apache.lo gging.log4 j.LogManag er;
  30   import org .apache.lo gging.log4 j.Logger;
  31  
  32   import gov .vha.isaac .ochre.api .util.Mave nPublish;
  33   import gov .vha.isaac .ochre.api .util.Work Executors;
  34   import gov .vha.isaac .ochre.api .util.Zip;
  35   import gov .vha.isaac .ochre.pom builder.Fi leUtil;
  36   import gov .vha.isaac .ochre.pom builder.Gi tPublish;
  37   import gov .vha.isaac .ochre.pom builder.co nverter.Su pportedCon verterType s;
  38   import jav afx.beans. value.Chan geListener ;
  39   import jav afx.beans. value.Obse rvableValu e;
  40   import jav afx.concur rent.Task;
  41  
  42   /**
  43    * 
  44    * {@link  SrcUploadC reator}
  45    * Create  a new mave n pom proj ect which  when execu ted, will  upload a s et of SDO  input file s
  46    * @author  <a href=" mailto:dan iel.armbru st.list@gm ail.com">D an Armbrus t</a>
  47    */
  48   public cla ss SrcUplo adCreator
  49   {
  50           pr ivate stat ic final L ogger LOG  = LogManag er.getLogg er();
  51           
  52           
  53           /* *
  54            *  @param up loadType -  What type  of conten t is being  uploaded.
  55            *  @param ve rsion - Wh at version  number do es the pas sed in con tent repre sent
  56            *  @param ex tensionNam e - option al - If th e upload t ype is a t ype such a s {@link S upportedCo nverterTyp es#SCT_EXT ENSION} wh ich contai ns a 
  57            *  wildcard  '*' in its  {@link Su pportedCon verterType s#getArtif actId()} v alue, this  parameter  must be p rovided, a nd is the  string to  use to 
  58            *  replace t he wildcar d.  This w ould typic ally be a  value such  as "en" o r "fr", wh en used fo r snomed e xtension c ontent.
  59            *  @param fo lderContai ningConten t - The fo lder that  contains t he require d data fil es - these  files wil l be zippe d into an  artifact a nd uploade d
  60            *  to the ar tifactRepo sitoryURL.
  61            *  @param gi tRepositor yURL - The  URL to pu blish this  built pro ject to
  62            *  @param gi tUsername  - The user name to ut ilize to p ublish thi s project
  63            *  @param ge tPassword  - The pass word to ut ilize to p ublish thi s project
  64            *  @return t he tag cre ated in th e reposito ry that ca rries the  created pr oject
  65            *  @param ar tifactRepo sitoryURL  - The arti fact serve r (nexus)  path where  the creat ed artifac t should b e transfer red.  This  path shou ld go all  the way do wn to 
  66              * a specif ic reposit ory, such  as http:// DNS : PORT /nexus/con tent/repos itories/re leases/ or  http:// DNS : PORT /nexus/con tent/repos itories/te rmdata/
  67            *  This shou ld not poi nt to a UR L that rep resents a  'group' re pository v iew.
  68            *  @param re positoryUs ername - T he usernam e to utili ze to uplo ad the art ifact to t he artifac t server
  69            *  @param re positoryPa ssword - T he passwor dto utiliz e to uploa d the arti fact to th e artifact  server
  70            *  @return -  the task  handle - w hich will  return the  tag that  was create d in the g it reposit ory upon c ompletion.
  71            *  @throws T hrowable 
  72            * /
  73           pu blic stati c Task<Str ing> creat eSrcUpload Configurat ion(Suppor tedConvert erTypes up loadType,  String ver sion, Stri ng extensi onName, Li st<File> f ilesToUplo ad, 
  74                             String  gitReposi toryURL, S tring gitU sername, c har[] gitP assword,
  75                             String  artifactR epositoryU RL, String  repositor yUsername,  String re positoryPa ssword) th rows Throw able
  76           {
  77                    LOG. info("Buil ding the t ask to cre ate a sour ce upload  configurat ion...");
  78  
  79                    if ( filesToUpl oad == nul l || files ToUpload.s ize() == 0 )
  80                    {
  81                             throw  new Except ion("No co ntent was  found to u pload!");
  82                    }
  83                    
  84                    Task <String> u ploader =  new Task<S tring>()
  85                    {
  86                             @Overr ide
  87                             protec ted String  call() th rows Excep tion
  88                             {
  89                                      updateMe ssage("Pre paring");
  90                                      try
  91                                      {
  92                                               File baseF older = Fi les.create TempDirect ory("src-u pload").to File();
  93                                              
  94                                              
  95                                               //Otherwis e, move fo rward.  Cr eate our n ative-sour ce folder,  and move  everything  into it.
  96                                               File nativ eSource =  new File(b aseFolder,  "native-s ource");
  97                                               if (native Source.exi sts())
  98                                               {
  99                                                       th row new Ru ntimeExcep tion("Unex pected fil e found in  upload co ntent!");
  100                                               }
  101                                               nativeSour ce.mkdir() ;
  102                                              
  103                                               for (File  f : filesT oUpload)
  104                                               {
  105                                                       // validate i t is a fil e, move it  into nati ve-source
  106                                                       if  (f.isFile ())
  107                                                       {
  108                                                                File s.move(f.t oPath(), n ativeSourc e.toPath() .resolve(f .toPath(). getFileNam e()));
  109                                                       }
  110                                                       el se
  111                                                       {
  112                                                                thro w new Exce ption("Une xpected di rectory fo und in upl oad conten t!  " + f. getAbsolut ePath());
  113                                                       }
  114                                               }
  115                                              
  116                                               StringBuff er noticeA ppend = ne w StringBu ffer();
  117                                               HashMap<St ring, Stri ng> pomSwa ps = new H ashMap<>() ;
  118                                              
  119                                               pomSwaps.p ut("#VERSI ON#", vers ion);
  120                                               pomSwaps.p ut("#SCM_U RL#", gitR epositoryU RL);
  121                                               if (upload Type.getAr tifactId() .contains( "*") && St ringUtils. isBlank(ex tensionNam e))
  122                                               {
  123                                                       th row new Ex ception("E xtensionNa me is requ ired when  the upload  type arti fact id co ntains a w ildcard");
  124                                               }
  125                                              
  126                                               switch(upl oadType)
  127                                               {
  128                                                       ca se SCT:
  129                                                                noti ceAppend.a ppend(File Util.readF ile("share d/noticeAd ditions/rf 2-sct-NOTI CE-additio n.txt"));
  130                                                                pomS waps.put(" #LICENSE#" , FileUtil .readFile( "shared/li censes/sct .xml"));
  131                                                                pomS waps.put(" #GROUPID#" , "gov.vha .isaac.ter minology.s ource.rf2" );
  132                                                                pomS waps.put(" #ARTIFACTI D#", "rf2- src-data-s ct");
  133                                                                pomS waps.put(" #NAME#", " SnomedCT S ource Uplo ad");
  134                                                                brea k;
  135                                                       ca se SCT_EXT ENSION:
  136                                                                noti ceAppend.a ppend(File Util.readF ile("share d/noticeAd ditions/rf 2-sct-NOTI CE-additio n.txt"));
  137                                                                pomS waps.put(" #LICENSE#" , FileUtil .readFile( "shared/li censes/sct .xml"));
  138                                                                pomS waps.put(" #GROUPID#" , "gov.vha .isaac.ter minology.s ource.rf2" );
  139                                                                pomS waps.put(" #ARTIFACTI D#", "rf2- src-data-"  + extensi onName + " -extension ");
  140                                                                pomS waps.put(" #NAME#", " SnomedCT E xtension S ource Uplo ad");
  141                                                                brea k;
  142                                                       ca se LOINC:
  143                                                                noti ceAppend.a ppend(File Util.readF ile("share d/noticeAd ditions/lo inc-NOTICE -addition. txt"));
  144                                                                pomS waps.put(" #LICENSE#" , FileUtil .readFile( "shared/li censes/loi nc.xml"));
  145                                                                pomS waps.put(" #GROUPID#" , "gov.vha .isaac.ter minology.s ource.loin c");
  146                                                                pomS waps.put(" #ARTIFACTI D#", "loin c-src-data ");
  147                                                                pomS waps.put(" #NAME#", " LOINC Sour ce Upload" );
  148                                                                brea k;
  149                                                       ca se LOINC_T ECH_PREVIE W:
  150                                                                noti ceAppend.a ppend(File Util.readF ile("share d/noticeAd ditions/lo inc-tech-p review-NOT ICE-additi on.txt"));
  151                                                                pomS waps.put(" #LICENSE#" , FileUtil .readFile( "shared/li censes/loi nc.xml"));
  152                                                                pomS waps.put(" #GROUPID#" , "gov.vha .isaac.ter minology.s ource.loin c");
  153                                                                pomS waps.put(" #ARTIFACTI D#", "loin c-src-data -tech-prev iew");
  154                                                                pomS waps.put(" #NAME#", " LOINC Tech  Preview S ource Uplo ad");
  155                                                                brea k;
  156                                                       ca se VHAT:
  157                                                                pomS waps.put(" #LICENSE#" , "");
  158                                                                pomS waps.put(" #GROUPID#" , "gov.vha .isaac.ter minology.s ource.vhat ");
  159                                                                pomS waps.put(" #ARTIFACTI D#", "vhat -src-data" );
  160                                                                pomS waps.put(" #NAME#", " VHAT Sourc e Upload") ;
  161                                                                brea k;
  162                                                       ca se RXNORM:
  163                                                                noti ceAppend.a ppend(File Util.readF ile("share d/noticeAd ditions/rx norm-NOTIC E-addition .txt"));
  164                                                                pomS waps.put(" #LICENSE#" , FileUtil .readFile( "shared/li censes/rxn orm.xml")) ;
  165                                                                pomS waps.put(" #GROUPID#" , "gov.vha .isaac.ter minology.s ource.rxno rm");
  166                                                                pomS waps.put(" #ARTIFACTI D#", "rxno rm-src-dat a");
  167                                                                pomS waps.put(" #NAME#", " RxNorm Sou rce Upload ");
  168                                                                brea k;
  169                                                       // TODO RXNOR M_SOLOR su pport
  170                                                       de fault :
  171                                                                thro w new Runt imeExcepti on("oops") ;
  172                                               }
  173                                              
  174                                               String tag WithoutRev Number = p omSwaps.ge t("#GROUPI D#") + "/"  + pomSwap s.get("#AR TIFACTID#" ) + "/" +  pomSwaps.g et("#VERSI ON#");
  175                                              
  176                                               ArrayList< String> ex istingTags  = GitPubl ish.readTa gs(gitRepo sitoryURL,  gitUserna me, gitPas sword);
  177                                               int highes tBuildRevi sion = Git Publish.re adHighestR evisionNum ber(existi ngTags, ta gWithoutRe vNumber);
  178                                              
  179                                               String tag ;
  180                                               //Fix vers ion number
  181                                               if (highes tBuildRevi sion == -1 )
  182                                               {
  183                                                       // No tag at  all - crea te without  rev numbe r, don't n eed to cha nge our po mSwaps
  184                                                       ta g = tagWit houtRevNum ber;
  185                                               }
  186                                               else
  187                                               {
  188                                                       // If we are  a SNAPSHOT , don't em bed a buil d number,  because ne xus won't  allow the  upload, ot herwise, e mbed a rev  number
  189                                                       if  (!pomSwap s.get("#VE RSION#").e ndsWith("S NAPSHOT"))
  190                                                       {
  191                                                                pomS waps.put(" #VERSION#" , pomSwaps .get("#VER SION#") +  "-" + (hig hestBuildR evision +  1));
  192                                                       }
  193                                                       ta g = tagWit houtRevNum ber + "-"  + (highest BuildRevis ion + 1);
  194                                               }
  195  
  196                                               pomSwaps.p ut("#SCM_T AG#", tag) ;
  197  
  198                                               FileUtil.w riteFile(" shared", " LICENSE.tx t", baseFo lder);
  199                                               FileUtil.w riteFile(" shared", " NOTICE.txt ", baseFol der, null,  noticeApp end.toStri ng());
  200                                               FileUtil.w riteFile(" srcUploadP rojectTemp late", "na tive-sourc e/DOTgitig nore", bas eFolder);
  201                                               FileUtil.w riteFile(" srcUploadP rojectTemp late", "as sembly.xml ", baseFol der);
  202                                               FileUtil.w riteFile(" srcUploadP rojectTemp late", "po m.xml", ba seFolder,  pomSwaps,  "");
  203                                              
  204                                               updateTitl e("Publish ing config uration to  Git");
  205                                               GitPublish .publish(b aseFolder,  gitReposi toryURL, g itUsername , gitPassw ord, tag);
  206                                              
  207                                               updateTitl e("Zipping  content") ;
  208                                              
  209                                               Zip z = ne w Zip(pomS waps.get(" #ARTIFACTI D#"), pomS waps.get(" #VERSION#" ), null, n ull, new F ile(baseFo lder, "tar get"), nat iveSource,  false);
  210                                              
  211                                               ArrayList< File> toZi p = new Ar rayList<>( );
  212                                               for (File  f : native Source.lis tFiles())
  213                                               {
  214                                                       if  (f.getNam e().equals (".gitigno re"))
  215                                                       {
  216                                                                //no op
  217                                                       }
  218                                                       el se
  219                                                       {
  220                                                                toZi p.add(f);
  221                                                       }
  222                                               }
  223                                              
  224                                               z.getStatu s().addLis tener(new  ChangeList ener<Strin g>()
  225                                               {
  226                                                       @O verride
  227                                                       pu blic void  changed(Ob servableVa lue<? exte nds String > observab le, String  oldValue,  String ne wValue)
  228                                                       {
  229                                                                upda teMessage( newValue);
  230                                                       }
  231                                               });
  232                                               z.getTotal Work().add (z.getWork Complete() ).addListe ner(new Ch angeListen er<Number> ()
  233                                               {
  234                                                       @O verride
  235                                                       pu blic void  changed(Ob servableVa lue<? exte nds Number > observab le, Number  oldValue,  Number ne wValue)
  236                                                       {
  237                                                                upda teProgress (z.getWork Complete() .get(), z. getTotalWo rk().get() );
  238                                                       }
  239                                               });
  240                                              
  241                                               //This blo cks till c omplete
  242                                               File zipFi le = z.add Files(toZi p);
  243                                              
  244                                               updateTitl e("Publish ing files  to the Art ifact Repo sitory");
  245                                              
  246                                               MavenPubli sh pm = ne w MavenPub lish(pomSw aps.get("# GROUPID#") , pomSwaps .get("#ART IFACTID#") , pomSwaps .get("#VER SION#"), 
  247                                                                new  File(baseF older, "po m.xml"), n ew File[]  {zipFile},  artifactR epositoryU RL, reposi toryUserna me, reposi toryPasswo rd);
  248                                              
  249                                               pm.progres sProperty( ).addListe ner(new Ch angeListen er<Number> ()
  250                                               {
  251                                                       @O verride
  252                                                       pu blic void  changed(Ob servableVa lue<? exte nds Number > observab le, Number  oldValue,  Number ne wValue)
  253                                                       {
  254                                                                upda teProgress (pm.getWor kDone(), p m.getTotal Work());
  255                                                       }
  256                                               });
  257                                               pm.message Property() .addListen er(new Cha ngeListene r<String>( )
  258                                               {
  259                                                       @O verride
  260                                                       pu blic void  changed(Ob servableVa lue<? exte nds String > observab le, String  oldValue,  String ne wValue)
  261                                                       {
  262                                                                upda teMessage( newValue);
  263                                                       }
  264                                               });
  265                                              
  266                                               WorkExecut ors.get(). getExecuto r().execut e(pm);
  267                                              
  268                                               //block ti ll upload  complete
  269                                               pm.get();
  270                                              
  271                                               updateTitl e("Cleanin g Up");
  272                                               try
  273                                               {
  274                                                       Fi leUtil.rec ursiveDele te(baseFol der);
  275                                               }
  276                                               catch (Exc eption e)
  277                                               {
  278                                                       LO G.error("P roblem cle aning up t emp folder  " + baseF older, e);
  279                                               }
  280                                              
  281                                               updateTitl e("Complet e");
  282                                               return tag ;
  283                                      }
  284                                      catch (T hrowable e )
  285                                      {
  286                                               LOG.error( "Unexpecte d error",  e);
  287                                               throw new  RuntimeExc eption(e);
  288                                      }
  289                                      
  290                             }
  291                    };
  292                    
  293                    retu rn uploade r;
  294           }
  295           
  296           /* *
  297            *  A utility  method to  fetch a t asks resul t.  It ass umes the t ask has be en previou sly starte d.
  298            *  @param ta sk
  299            *  @return t he string  returned b y the task
  300            * /
  301           pu blic stati c String f etchResult (Task<Stri ng> task) 
  302           {
  303                    LOG. trace("In  fetchResul t");
  304                    
  305                    java fx.concurr ent.Worker .State s =  task.getS tate();
  306                    LOG. trace("Cur rent state  is " + s. toString() );
  307                    if(s  == javafx .concurren t.Worker.S tate.READY ) {
  308                             //thro w new Ille galStateEx ception("T he task ha s not been  started.   Please st art the ta sk.");
  309                    }
  310                    Stri ng result  = null;
  311                    try  {
  312                             LOG.tr ace("Calli ng task.ge t");
  313                             result  = task.ge t();
  314                             LOG.tr ace("task. get is don e, result=  " + resul t);
  315                    } ca tch (Excep tion e) {
  316                             result  = e.getMe ssage();
  317                             LOG.er ror("Excep tion throw n during t ask.get",  e);
  318                    } 
  319                    retu rn result;
  320           }
  321           
  322           /* *
  323            *  A utility  method to  execute a  task and  wait for i t to compl ete.
  324            *  @param ta sk
  325            *  @return t he string  returned b y the task
  326            *  @throws I nterrupted Exception
  327            *  @throws E xecutionEx ception
  328            * /
  329           pu blic stati c String e xecuteAndB lock(Task< String> ta sk) throws  Interrupt edExceptio n, Executi onExceptio n
  330           {
  331                    LOG. trace("exe cuteAndBlo ck with ta sk " + tas k);
  332                    Work Executors. get().getE xecutor(). execute(ta sk);
  333                    Stri ng result  = task.get ();
  334                    LOG. trace("res ult of tas k: " + res ult);
  335                    retu rn result;
  336           }
  337   }