52. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/21/2017 6:15:14 PM Eastern 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.

52.1 Files compared

# Location File Last Modified
1 Genisis_2.0_v7_bld7.zip\TS\Service\testing\cli-test-scripts\src\main\java\gov\va\genisis2 CliScript.java Thu Dec 14 19:57:07 2017 UTC
2 Genisis_2.0_v7_bld7.zip\TS\Service\testing\cli-test-scripts\src\main\java\gov\va\genisis2 CliScript.java Thu Dec 21 22:17:41 2017 UTC

52.2 Comparison summary

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

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

52.4 Active regular expressions

No regular expressions were active.

52.5 Comparison detail

  1   package go v.va.genis is2;
  2  
  3   import jav a.io.Buffe redReader;
  4   import jav a.io.File;
  5   import jav a.io.IOExc eption;
  6   import jav a.io.Input StreamRead er;
  7   import jav a.util.Lis t;
  8   import jav a.util.reg ex.Pattern ;
  9  
  10   import org .apache.co mmons.cli. CommandLin e;
  11   import org .apache.co mmons.cli. CommandLin eParser;
  12   import org .apache.co mmons.cli. DefaultPar ser;
  13   import org .apache.co mmons.cli. HelpFormat ter;
  14   import org .apache.co mmons.cli. Option;
  15   import org .apache.co mmons.cli. OptionGrou p;
  16   import org .apache.co mmons.cli. Options;
  17   import org .apache.co mmons.cli. ParseExcep tion;
  18   import org .apache.lo g4j.Logger ;
  19  
  20   import com .fasterxml .jackson.c ore.type.T ypeReferen ce;
  21   import com .fasterxml .jackson.d atabind.Ob jectMapper ;
  22  
  23   import gov .va.genisi s2.ts.comm on.dto.Tri pleDTO;
  24  
  25   /**
  26    * @author   PII
  27    *
  28    */
  29   public cla ss CliScri pt {
  30  
  31           pr ivate stat ic final L ogger LOGG ER = Logge r.getLogge r(CliScrip t.class);
  32           
  33           pr ivate stat ic final P attern VAL ID_IP_ADDR ESS = Patt ern.compil e(
  34                    "^(( [01]?\\d\\ d?|2[0-4]\ \d|25[0-5] )\\.){3}([ 01]?\\d\\d ?|2[0-4]\\ d|25[0-5]) $");
  35           
  36           pu blic stati c void mai n(String[]  args) {
  37                    
  38                    Comm andClient  commandCli ent = new  CommandCli ent(
  39                                      new Prop ertyManage r(CliScrip tConstants .PROPERTY_ FILE_LOCAT ION));
  40                    
  41                    Comm andLinePar ser parser  = new Def aultParser ();
  42                    Comm andLine cm dLine = nu ll;
  43                    Opti ons option s = null;
  44                    try  {
  45                             option s = create CommandLin eOptions() ;
  46                             cmdLin e = parser .parse(opt ions, args );
  47                    } ca tch (Parse Exception  e) {
  48                             LOGGER .error("Co uldn't par se command  line argu ments "+e) ;
  49                             System .err.print ln("Error:  "+e);
  50                             HelpFo rmatter fo rmatter =  new HelpFo rmatter();
  51                             format ter.printH elp("java  -jar tscri pt-jar-wit h-dependen cies.jar",  options);
  52                             System .exit(0);
  53                    }
  54                    if(  cmdLine.ha sOption( C liScriptCo nstants.HE LP ) )  {
  55                             LOGGER .debug("he lp message ");
  56                             HelpFo rmatter fo rmatter =  new HelpFo rmatter();
  57                             format ter.printH elp("java  -jar ts-cl i-script-j ar-with-de pendencies .jar", opt ions);
  58                             System .exit(0);
  59                    }
  60                    
  61                    if(  cmdLine.ha sOption( C liScriptCo nstants.GE NERATE ))  {
  62                             LOGGER .debug("Ge nerate exi sting sets  of subjec ts, predic ates, and  objects");
  63                             String  endpoint  = cmdLine. getOptionV alue(CliSc riptConsta nts.GENERA TE);
  64                             
  65                             if( en dpoint ==  null ) {
  66                                      endpoint  = CliScri ptConstant s.DEFAULT_ SPARQL_END POINT;
  67                             }
  68                             comman dClient.ge nerateExis tingTriple Files(endp oint);
  69                    }
  70                    
  71                    if(  cmdLine.ha sOption( C liScriptCo nstants.CR EATE )) {
  72                             LOGGER .debug("Cr eate tripl es");
  73                             Intege r numberOf Triples =  1;
  74                             try {
  75                                      numberOf Triples =  Integer.pa rseInt( cm dLine.getO ptionValue (CliScript Constants. CREATE) );
  76                             }catch ( NumberFo rmatExcept ion ne ) {
  77                                      LOGGER.e rror("Cann ot parse t he number  of triples ...default ing to one ");
  78                             }final ly {
  79                                      commandC lient.crea teTriples(  numberOfT riples );
  80                             }
  81                    }
  82                    if(  cmdLine.ha sOption( C liScriptCo nstants.EX ISTS ) )   {
  83                             LOGGER .debug("Ch ecking if  triples ex ist");
  84                             
  85                             List<T ripleDTO>  triples =  null;
  86                             Object Mapper map per = new  ObjectMapp er();
  87  
  88                             String [] values  = cmdLine. getOptionV alues( Cli ScriptCons tants.EXIS TS );
  89                             
  90                             if( cm dLine.getO ptionValue (CliScript Constants. EXISTS) !=  null ) {
  91                                      //read j son values  from a fi le
  92                                      try {
  93                                               if( valida teIpAddres s(values[0 ]) ) {
  94                                                       // they have  entered in  an ip add ress and n o file nam e
  95                                                       Sy stem.err.p rintln(Cli ScriptCons tants.EXIS TS_HELP);
  96                                                       Sy stem.exit( -1);
  97                                               }
  98                                               //make a f ile from t he first a rgument
  99                                               triples =  mapper.rea dValue(new  File(valu es[0]), 
  100                                                                new  TypeRefere nce<List<T ripleDTO>> (){});
  101                                               String end point = Cl iScriptCon stants.DEF AULT_SPARQ L_ENDPOINT ;
  102                                               if( values [1] != nul l && valid ateIpAddre ss( values [1] )) {
  103                                                       en dpoint = c onstructSp qarqlEndpo int(values [1]);
  104                                               }
  105                                               commandCli ent.checkI fTriplesEx ists( trip les, false , endpoint  );
  106                                      } catch  (IOExcepti on e) {
  107                                               LOGGER.err or(e.getMe ssage());
  108                                      }
  109                             }
  110                             else {
  111                                      //read f rom stdin  which mean s the defa ult endpoi nt should  be used
  112                                      try {
  113                                               triples =  mapper.rea dValue(new  BufferedR eader(
  114                                                                new  InputStrea mReader(Sy stem.in)),  
  115                                                                new  TypeRefere nce<List<T ripleDTO>> (){});
  116                                               commandCli ent.checkI fTriplesEx ists( trip les, true,  CliScript Constants. DEFAULT_SP ARQL_ENDPO INT);
  117                                      } catch  (IOExcepti on e) {
  118                                               LOGGER.err or(e.getMe ssage());
  119                                      }
  120                             }
  121                    }
  122           }
  123           
  124  
  125           /* *
  126            *  Create th e option o bjects use d as comma nd line ar guments
  127            *  @return o rg.apache. commons.cl i.Options
  128            * /
  129           pr ivate stat ic Options  createCom mandLineOp tions() {
  130                    Opti ons option s = new Op tions();
  131  
  132                    Opti on helpOpt ion = Opti on.builder (CliScript Constants. HELP).
  133                                      required (false).
  134                                      desc("Di splays the  help mess age").
  135                                      build();
  136                    
  137                    //es tablish mu tually exc lusive gro up for req uired crea te, exists , generate
  138                    Opti onGroup mu tualExclus iveOptions  = new Opt ionGroup() ;
  139                    mutu alExclusiv eOptions.s etRequired (true);
  140  
  141                    Opti on createO ption = Op tion.build er(CliScri ptConstant s.CREATE).
  142                                      numberOf Args(1).
  143                                      type(Int eger.class ).
  144                                      desc("Ge nerate a J SON file o f triples" ).
  145                                      build();
  146                    
  147                    Opti on existsO ption = Op tion.build er(CliScri ptConstant s.EXISTS).
  148                                      numberOf Args(2).
  149                                      optional Arg(true).
  150                                      desc(Cli ScriptCons tants.EXIS TS_HELP).
  151                                      build();
  152                                      
  153                                      
  154                    Opti on generat eOption =  Option.bui lder(CliSc riptConsta nts.GENERA TE).
  155                                      numberOf Args(1).
  156                                      optional Arg(true).
  157                                      desc("Wi ll generat e 3 text f iles repre senting tr iples for  all existi ng subject s, predica tes, "
  158                                                       +  "and objec ts given a  fuseki ip  address l ocation. I f no IP gi ven will d efault to:  "
  159                                                       +  CliScriptC onstants.D EFAULT_SPA RQL_ENDPOI NT).
  160                                      build();
  161                    
  162                    opti ons.addOpt ion(helpOp tion);
  163                    
  164                    mutu alExclusiv eOptions.a ddOption(c reateOptio n);
  165                    mutu alExclusiv eOptions.a ddOption(e xistsOptio n);
  166                    mutu alExclusiv eOptions.a ddOption(g enerateOpt ion);
  167                    
  168                    opti ons.addOpt ionGroup(m utualExclu siveOption s);
  169  
  170                    retu rn options ;
  171                    
  172           }
  173           
  174           /* *
  175            *  Returns t rue if the  given str ing is val id ip addr ess
  176            *  @param ip
  177            *  @return
  178            * /
  179           pu blic stati c boolean  validateIp Address(St ring ip) {
  180                     ret urn VALID_ IP_ADDRESS .matcher(i p).matches ();
  181           }
  182           
  183           /* *
  184            *  Construct  a sparql  endpoint g iven an IP  address
  185            *  @param ip
  186            *  @return
  187            * /
  188           pu blic stati c String c onstructSp qarqlEndpo int(String  ip) {
  189                    Stri ngBuilder  builder =  new String Builder();
  190                    
  191                    retu rn builder .append("h ttp://")
  192                    .app end(ip)
  193                    .app end(":3030 /ds/sparql ").toStrin g();
  194                    
  195           }
  196   }