Changeset 6321
- Timestamp:
- 06/23/15 14:36:16 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.3-oeaw/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java
r6317 r6321 1 1 package eu.clarin.cmdi.vlo.importer; 2 3 import eu.clarin.cmdi.vlo.LanguageCodeUtils;4 import eu.clarin.cmdi.vlo.CommonUtils;5 import eu.clarin.cmdi.vlo.FacetConstants;6 import eu.clarin.cmdi.vlo.config.DataRoot;7 import eu.clarin.cmdi.vlo.config.VloConfig;8 import eu.clarin.cmdi.vlo.config.XmlVloConfigFactory;9 2 10 3 import java.io.File; … … 38 31 import org.slf4j.LoggerFactory; 39 32 33 import eu.clarin.cmdi.vlo.CommonUtils; 34 import eu.clarin.cmdi.vlo.FacetConstants; 35 import eu.clarin.cmdi.vlo.LanguageCodeUtils; 36 import eu.clarin.cmdi.vlo.config.DataRoot; 37 import eu.clarin.cmdi.vlo.config.VloConfig; 38 import eu.clarin.cmdi.vlo.config.XmlVloConfigFactory; 39 40 40 /** 41 41 * The main metadataImporter class. Also contains the main function. … … 121 121 initSolrServer(); 122 122 List<DataRoot> dataRoots = checkDataRoots(); 123 124 dataRoots = filterDataRootsWithCLArgs(dataRoots); 125 123 126 long start = System.currentTimeMillis(); 124 127 try { … … 204 207 for (DataRoot dataRoot : dataRoots) { 205 208 if (!dataRoot.getRootFile().exists()) { 206 LOG.error("Root file " + dataRoot.getRootFile() + " does not exist. Could be configuration error (see VLOConfig.xml)! Proceeding with next ..."); 207 // LOG.error("Root file " + dataRoot.getRootFile() + " does not exist. Probable configuration error so stopping import."); 208 // System.exit(1); 209 LOG.error("Root file " + dataRoot.getRootFile() + " does not exist. It could be configuration error! Proceeding with next ..."); 209 210 } else{ 210 211 existingDataRoots.add(dataRoot); 211 212 } 213 212 214 } 213 215 return existingDataRoots; 216 } 217 218 /** 219 * if user specified which data roots should be imported, 220 * list of existing data roots will be filtered with the list from user 221 * 222 * @return 223 */ 224 protected List<DataRoot> filterDataRootsWithCLArgs(List<DataRoot> dataRoots){ 225 if(CL_DATAROOTS_LIST == null) 226 return dataRoots; 227 228 //filter data 229 230 LOG.info("Filtering configured data root files with command line arguments: " + CL_DATAROOTS_LIST) ; 231 232 LinkedList<File> cl_dataroots = new LinkedList<File>(); 233 234 List<String> paths = Arrays.asList((CL_DATAROOTS_LIST.split("\\s+"))); 235 236 for(String path: paths) 237 cl_dataroots.add(new File(path)); 238 239 List<DataRoot> filteredDataRoots = new LinkedList<DataRoot>(); 240 try{ 241 dr: for(DataRoot dataRoot: dataRoots){ 242 for(File cldr: cl_dataroots){ 243 if(cldr.getCanonicalPath().equals(dataRoot.getRootFile().getCanonicalPath())){ 244 filteredDataRoots.add(dataRoot); 245 cl_dataroots.remove(cldr); 246 continue dr; 247 } 248 } 249 LOG.info("Root file " + dataRoot.getRootFile() + " will be omitted from processing"); 250 } 251 }catch (IOException e){ 252 filteredDataRoots = dataRoots; 253 } 254 255 256 return filteredDataRoots; 214 257 } 215 258 … … 522 565 public static LanguageCodeUtils languageCodeUtils; 523 566 567 //data roots passed from command line 568 public static String CL_DATAROOTS_LIST = null; 569 524 570 /** 525 571 * @param args … … 540 586 */ 541 587 options.addOption("c", true, "-c <file> : use parameters specified in <file>"); 588 options.addOption("l", true, "-l <dataroot> [ ' ' <dataroot> ]* : space separated list of dataroots to be processed.\n" 589 + "If dataroot is not specified in config file it will be ignored."); 590 options.getOption("l").setOptionalArg(true); 542 591 543 592 CommandLineParser parser = new PosixParser(); … … 550 599 // the "c" option was specified, now get its value 551 600 configFile = cmd.getOptionValue("c"); 601 } 602 603 if(cmd.hasOption("l")){ 604 CL_DATAROOTS_LIST = cmd.getOptionValue("l"); 552 605 } 553 606
Note: See TracChangeset
for help on using the changeset viewer.