Show
Ignore:
Timestamp:
02.11.2016 11:37:07 (3 years ago)
Author:
davidb
Message:

Support for Java properties file

Location:
other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/ProcessForSolrIngest.java

    r31013 r31024  
    11package org.hathitrust.extractedfeatures; 
    22 
     3import java.io.BufferedInputStream; 
     4import java.io.FileInputStream; 
     5import java.io.FileNotFoundException; 
     6import java.io.IOException; 
    37import java.io.Serializable; 
    48import org.apache.commons.cli.*; 
     
    178182        options.addOption(verbosity_opt); 
    179183         
     184        Option properties_opt = new Option("p", "properties", false,  
     185                "Read in the specified Java properties file."); 
     186        properties_opt.setRequired(false); 
     187        options.addOption(properties_opt); 
     188         
    180189        Option output_dir_opt = new Option("o", "output-dir", true,  
    181190                "If specified, save BZipped Solr JSON files to this directory"); 
     
    213222        int verbosity = Integer.parseInt(verbosity_str); 
    214223 
     224        String property_filename = cmd.getOptionValue("properties",null); 
     225     
    215226        String output_dir = cmd.getOptionValue("output-dir",null); 
    216227        String solr_url   = cmd.getOptionValue("solr-url",null); 
     
    222233            print_usage(formatter,options); 
    223234            System.exit(1); 
     235        } 
     236     
     237        if (property_filename != null) { 
     238            try { 
     239                FileInputStream fis = new FileInputStream(property_filename); 
     240                BufferedInputStream bis = new BufferedInputStream(fis); 
     241                 
     242                System.getProperties().load(bis); 
     243            }  
     244            catch (FileNotFoundException e) { 
     245                // TODO Auto-generated catch block 
     246                e.printStackTrace(); 
     247                System.err.println("File not found: '" + property_filename + "'. Skipping property file read"); 
     248            } 
     249            catch (IOException e) { 
     250                System.err.println("IO Exception for: '" + property_filename + "'. Malformed syntax? Skipping property file read"); 
     251            } 
    224252        } 
    225253