23. EPMO Open Source Coordination Office Redaction File Detail Report

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

23.1 Files compared

# Location File Last Modified
1 CTT_Release_8_June_2018.zip\CTT_ISAAC\ISAAC\db-config-builder\src\main\java\gov\vha\isaac\ochre\pombuilder\upload SrcUploadCreator.java Tue Jul 17 16:28:38 2018 UTC
2 CTT_Release_8_June_2018.zip\CTT_ISAAC\ISAAC\db-config-builder\src\main\java\gov\vha\isaac\ochre\pombuilder\upload SrcUploadCreator.java Wed Jul 18 19:12:02 2018 UTC

23.2 Comparison summary

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

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

23.4 Active regular expressions

No regular expressions were active.

23.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.Arr ays;
  25   import jav a.util.Has hMap;
  26   import jav a.util.Lis t;
  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 d to utili ze to uplo ad the art ifact to t he artifac t 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.   Note tha t the task  is NOT ye t started,  when 
  71            *  it is ret urned.
  72            *  @throws T hrowable 
  73            * /
  74           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, 
  75                             String  gitReposi toryURL, S tring gitU sername, c har[] gitP assword,
  76                             String  artifactR epositoryU RL, String  repositor yUsername,  String re positoryPa ssword) th rows Throw able
  77           {
  78                    LOG. info("Buil ding the t ask to cre ate a sour ce upload  configurat ion for {} , version:  {}, exten sionName:  {}, to git : {} and a rtifact se rver: {}",  
  79                                      uploadTy pe, versio n, extensi onName, gi tRepositor yURL, arti factReposi toryURL);
  80                    if ( LOG.isDebu gEnabled()  && filesT oUpload !=  null)
  81                    {
  82                             LOG.de bug("Provi ded files  []", Array s.toString (filesToUp load.toArr ay(new Fil e[filesToU pload.size ()])));
  83                    }
  84  
  85                    if ( filesToUpl oad == nul l || files ToUpload.s ize() == 0 )
  86                    {
  87                             LOG.in fo("Throwi ng an exce ption beca use No con tent was f ound to up load");
  88                             throw  new Except ion("No co ntent was  found to u pload!");
  89                    }
  90                    
  91                    Task <String> u ploader =  new Task<S tring>()
  92                    {
  93                             @Overr ide
  94                             protec ted String  call() th rows Excep tion
  95                             {
  96                                      updateMe ssage("Pre paring");
  97                                      File bas eFolder =  null;
  98                                      try
  99                                      {
  100                                               baseFolder  = Files.c reateTempD irectory(" src-upload ").toFile( );
  101                                              
  102                                               //Otherwis e, move fo rward.  Cr eate our n ative-sour ce folder,  and move  everything  into it.
  103                                               File nativ eSource =  new File(b aseFolder,  "native-s ource");
  104                                               if (native Source.exi sts())
  105                                               {
  106                                                       LO G.info("Ta sk failing  due to un expected f ile in upl oad conten t '{}'", n ativeSourc e);
  107                                                       th row new Ru ntimeExcep tion("Unex pected fil e found in  upload co ntent!");
  108                                               }
  109                                               nativeSour ce.mkdir() ;
  110                                              
  111                                               for (File  f : filesT oUpload)
  112                                               {
  113                                                       // validate i t is a fil e, move it  into nati ve-source
  114                                                       if  (f.isFile ())
  115                                                       {
  116                                                                File s.move(f.t oPath(), n ativeSourc e.toPath() .resolve(f .toPath(). getFileNam e()));
  117                                                       }
  118                                                       el se
  119                                                       {
  120                                                                LOG. info("Task  failing d ue to unex pected dir ectory in  upload con tent: '{}' ", f.getAb solutePath ());
  121                                                                thro w new Exce ption("Une xpected di rectory fo und in upl oad conten t!  " + f. getAbsolut ePath());
  122                                                       }
  123                                               }
  124                                              
  125                                               StringBuff er noticeA ppend = ne w StringBu ffer();
  126                                               HashMap<St ring, Stri ng> pomSwa ps = new H ashMap<>() ;
  127                                              
  128                                               pomSwaps.p ut("#VERSI ON#", vers ion);
  129                                               pomSwaps.p ut("#SCM_U RL#", GitP ublish.con structChan gesetRepos itoryURL(g itReposito ryURL));
  130                                               if (upload Type.getAr tifactId() .contains( "*") && St ringUtils. isBlank(ex tensionNam e))
  131                                               {
  132                                                       th row new Ex ception("E xtensionNa me is requ ired when  the upload  type arti fact id co ntains a w ildcard");
  133                                               }
  134                                              
  135                                               pomSwaps.p ut("#GROUP ID#", uplo adType.get SourceUplo adGroupId( ));
  136                                              
  137                                               String tem p = upload Type.getAr tifactId() ;
  138                                               if (temp.c ontains("* "))
  139                                               {
  140                                                       te mp = temp. replace("* ", extensi onName.toL owerCase() );
  141                                               }
  142                                              
  143                                               pomSwaps.p ut("#ARTIF ACTID#", t emp);
  144                                               pomSwaps.p ut("#NAME# ", uploadT ype.getNic eName() +  " Source U pload");
  145                                               pomSwaps.p ut("#LICEN SE#", uplo adType.get LicenseInf ormation() [0]);  //w e only use  the first  license f or source  upload
  146                                               noticeAppe nd.append( uploadType .getNotice Informatio n()[0]);   //only use  the first  notice in fo
  147                                              
  148                                               String tag WithoutRev Number = p omSwaps.ge t("#GROUPI D#") + "/"  + pomSwap s.get("#AR TIFACTID#" ) + "/" +  pomSwaps.g et("#VERSI ON#");
  149                                               LOG.debug( "Desired t ag (withou tRevNumber ): {}", ta gWithoutRe vNumber);
  150                                              
  151                                               //Lock ove r the time  period wh ere we are  calculati ng the new  tag
  152                                               GitPublish .lock(gitR epositoryU RL);
  153                                               ArrayList< String> ex istingTags  = GitPubl ish.readTa gs(gitRepo sitoryURL,  gitUserna me, gitPas sword);
  154                                              
  155                                               if (LOG.is DebugEnabl ed())
  156                                               {
  157                                                       LO G.debug("C urrently E xisting ta gs in '{}' : {} ", gi tRepositor yURL, Arra ys.toStrin g(existing Tags.toArr ay(new Str ing[existi ngTags.siz e()])));
  158                                               }
  159                                              
  160                                               int highes tBuildRevi sion = Git Publish.re adHighestR evisionNum ber(existi ngTags, ta gWithoutRe vNumber);
  161                                              
  162                                               String tag ;
  163                                               //Fix vers ion number
  164                                               if (highes tBuildRevi sion == -1 )
  165                                               {
  166                                                       // No tag at  all - crea te without  rev numbe r, don't n eed to cha nge our po mSwaps
  167                                                       ta g = tagWit houtRevNum ber;
  168                                               }
  169                                               else
  170                                               {
  171                                                       // 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
  172                                                       if  (!pomSwap s.get("#VE RSION#").e ndsWith("S NAPSHOT"))
  173                                                       {
  174                                                                pomS waps.put(" #VERSION#" , pomSwaps .get("#VER SION#") +  "-" + (hig hestBuildR evision +  1));
  175                                                       }
  176                                                       ta g = tagWit houtRevNum ber + "-"  + (highest BuildRevis ion + 1);
  177                                               }
  178                                              
  179                                               LOG.info(" Final calc ulated tag : '{}'", t ag);
  180  
  181                                               pomSwaps.p ut("#SCM_T AG#", tag) ;
  182  
  183                                               FileUtil.w riteFile(" shared", " LICENSE.tx t", baseFo lder);
  184                                               FileUtil.w riteFile(" shared", " NOTICE.txt ", baseFol der, null,  noticeApp end.toStri ng());
  185                                               FileUtil.w riteFile(" srcUploadP rojectTemp late", "na tive-sourc e/DOTgitig nore", bas eFolder);
  186                                               FileUtil.w riteFile(" srcUploadP rojectTemp late", "as sembly.xml ", baseFol der);
  187                                               FileUtil.w riteFile(" srcUploadP rojectTemp late", "po m.xml", ba seFolder,  pomSwaps,  "");
  188                                              
  189                                               updateTitl e("Publish ing config uration to  Git");
  190                                               GitPublish .publish(b aseFolder,  gitReposi toryURL, g itUsername , gitPassw ord, tag);
  191                                               GitPublish .unlock(gi tRepositor yURL);
  192                                              
  193                                               updateTitl e("Zipping  content") ;
  194                                               LOG.debug( "Zipping c ontent");
  195                                              
  196                                               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);
  197                                              
  198                                               ArrayList< File> toZi p = new Ar rayList<>( );
  199                                               for (File  f : native Source.lis tFiles())
  200                                               {
  201                                                       if  (f.getNam e().equals (".gitigno re"))
  202                                                       {
  203                                                                //no op
  204                                                       }
  205                                                       el se
  206                                                       {
  207                                                                toZi p.add(f);
  208                                                       }
  209                                               }
  210                                              
  211                                               z.getStatu s().addLis tener(new  ChangeList ener<Strin g>()
  212                                               {
  213                                                       @O verride
  214                                                       pu blic void  changed(Ob servableVa lue<? exte nds String > observab le, String  oldValue,  String ne wValue)
  215                                                       {
  216                                                                upda teMessage( newValue);
  217                                                       }
  218                                               });
  219                                               z.getTotal Work().add (z.getWork Complete() ).addListe ner(new Ch angeListen er<Number> ()
  220                                               {
  221                                                       @O verride
  222                                                       pu blic void  changed(Ob servableVa lue<? exte nds Number > observab le, Number  oldValue,  Number ne wValue)
  223                                                       {
  224                                                                upda teProgress (z.getWork Complete() .get(), z. getTotalWo rk().get() );
  225                                                       }
  226                                               });
  227                                              
  228                                               //This blo cks till c omplete
  229                                               File zipFi le = z.add Files(toZi p);
  230                                              
  231                                               LOG.info(" Zip comple te, publis hing to ar tifact rep o {}", art ifactRepos itoryURL);
  232                                               updateTitl e("Publish ing files  to the Art ifact Repo sitory");
  233                                              
  234                                               MavenPubli sh pm = ne w MavenPub lish(pomSw aps.get("# GROUPID#") , pomSwaps .get("#ART IFACTID#") , pomSwaps .get("#VER SION#"), 
  235                                                                new  File(baseF older, "po m.xml"), n ew File[]  {zipFile},  artifactR epositoryU RL, reposi toryUserna me, reposi toryPasswo rd);
  236                                              
  237                                               pm.progres sProperty( ).addListe ner(new Ch angeListen er<Number> ()
  238                                               {
  239                                                       @O verride
  240                                                       pu blic void  changed(Ob servableVa lue<? exte nds Number > observab le, Number  oldValue,  Number ne wValue)
  241                                                       {
  242                                                                upda teProgress (pm.getWor kDone(), p m.getTotal Work());
  243                                                       }
  244                                               });
  245                                               pm.message Property() .addListen er(new Cha ngeListene r<String>( )
  246                                               {
  247                                                       @O verride
  248                                                       pu blic void  changed(Ob servableVa lue<? exte nds String > observab le, String  oldValue,  String ne wValue)
  249                                                       {
  250                                                                upda teMessage( newValue);
  251                                                       }
  252                                               });
  253                                              
  254                                               WorkExecut ors.get(). getExecuto r().execut e(pm);
  255                                              
  256                                               //block ti ll upload  complete
  257                                               pm.get();
  258                                              
  259                                               updateTitl e("Cleanin g Up");
  260                                               try
  261                                               {
  262                                                       Fi leUtil.rec ursiveDele te(baseFol der);
  263                                               }
  264                                               catch (Exc eption e)
  265                                               {
  266                                                       LO G.error("P roblem cle aning up t emp folder  {}", base Folder, e) ;
  267                                               }
  268                                              
  269                                               updateTitl e("Complet e");
  270                                               return tag ;
  271                                      }
  272                                      catch (T hrowable e )
  273                                      {
  274                                               LOG.error( "Unexpecte d error",  e);
  275                                               throw new  RuntimeExc eption(e);
  276                                      }
  277                                      finally
  278                                      {
  279                                               GitPublish .unlock(gi tRepositor yURL);
  280                                               try
  281                                               {
  282                                                       Fi leUtil.rec ursiveDele te(baseFol der);
  283                                               }
  284                                               catch (Exc eption e)
  285                                               {
  286                                                       LO G.error("P roblem cle aning up t emp folder  {}", base Folder, e) ;
  287                                               }
  288                                      }
  289                                      
  290                             }
  291                    };
  292                    
  293                    retu rn uploade r;
  294           }
  295   }