Changeset 6322


Ignore:
Timestamp:
06/24/15 12:21:17 (9 years ago)
Author:
davor.ostojic@oeaw.ac.at
Message:

#768

in case of non existing data root WARN msg instead of ERROR is printed
public static String CL_DATAROOTS_LIST changed to private String
more understandable var names
comments

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

    r6321 r6322  
    9393     */
    9494    public MetadataImporter() {}
     95   
     96    public MetadataImporter(String clDatarootsList) {
     97        this.clDatarootsList = clDatarootsList;
     98    }
    9599
    96100    /**
     
    207211        for (DataRoot dataRoot : dataRoots) {
    208212            if (!dataRoot.getRootFile().exists()) {
    209                 LOG.error("Root file " + dataRoot.getRootFile() + " does not exist. It could be configuration error! Proceeding with next ...");
     213                LOG.warn("Root file " + dataRoot.getRootFile() + " does not exist. It could be configuration error! Proceeding with next ...");
    210214            } else{
    211215                existingDataRoots.add(dataRoot);
     
    223227     */
    224228    protected List<DataRoot> filterDataRootsWithCLArgs(List<DataRoot> dataRoots){
    225         if(CL_DATAROOTS_LIST == null)
     229        if(clDatarootsList == null)
    226230                return dataRoots;
    227231       
    228         //filter data
    229232       
    230         LOG.info("Filtering configured data root files with command line arguments: " + CL_DATAROOTS_LIST) ;
     233        LOG.info("Filtering configured data root files with command line arguments: \"" + clDatarootsList + "\"" ) ;
    231234       
    232         LinkedList<File> cl_dataroots = new LinkedList<File>();
     235        LinkedList<File> fsDataRoots = new LinkedList<File>();
    233236       
    234         List<String> paths = Arrays.asList((CL_DATAROOTS_LIST.split("\\s+")));
     237        List<String> paths = Arrays.asList((clDatarootsList.split("\\s+")));
    235238       
     239        //Convert String paths to File objects for comparison
    236240        for(String path: paths)
    237                 cl_dataroots.add(new File(path));
     241                fsDataRoots.add(new File(path));
    238242       
    239243        List<DataRoot> filteredDataRoots = new LinkedList<DataRoot>();
    240244        try{
     245                //filter data
    241246        dr: for(DataRoot dataRoot: dataRoots){
    242                         for(File cldr: cl_dataroots){
    243                         if(cldr.getCanonicalPath().equals(dataRoot.getRootFile().getCanonicalPath())){
     247                        for(File fsDataRoot: fsDataRoots){
     248                        if(fsDataRoot.getCanonicalPath().equals(dataRoot.getRootFile().getCanonicalPath())){
    244249                                filteredDataRoots.add(dataRoot);
    245                                 cl_dataroots.remove(cldr);
     250                                fsDataRoots.remove(fsDataRoot);
    246251                                continue dr;
    247252                        }
     
    566571   
    567572    //data roots passed from command line   
    568     public static String CL_DATAROOTS_LIST = null;
     573    private String clDatarootsList = null;
    569574   
    570575    /**
     
    580585        // use the Apache cli framework for getting command line parameters
    581586        Options options = new Options();
     587       
     588        // Data root list passed from command line with -l option
     589        String cldrList = null;
    582590
    583591        /**
    584592         * Add a "c" option, the option indicating the specification of an XML
    585593         * configuration file
     594         *
     595         * "l" option - to specify which data roots (from config file) to import
     596         * imports all by default
    586597         */
    587598        options.addOption("c", true, "-c <file> : use parameters specified in <file>");
     
    602613           
    603614            if(cmd.hasOption("l")){
    604                 CL_DATAROOTS_LIST = cmd.getOptionValue("l");
     615                cldrList = cmd.getOptionValue("l");
    605616            }
    606617           
     
    651662            // optionally, modify the configuration here
    652663            // create and start the importer
    653             MetadataImporter importer = new MetadataImporter();
     664            MetadataImporter importer = new MetadataImporter(cldrList);
    654665            importer.startImport();
    655666
Note: See TracChangeset for help on using the changeset viewer.