Changeset 6804


Ignore:
Timestamp:
11/13/15 15:19:58 (9 years ago)
Author:
davor.ostojic@oeaw.ac.at
Message:

trying to read maps from files within given path and in case of error from classpath

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.3-oeaw/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/PostProcessorsWithVocabularyMap.java

    r6793 r6804  
    6161               
    6262
    63                         _logger.info("Reading vocabulary file from: {}", mapUrl);
    64                         // load records from file
    65                         // in the future this should be loaded from CLAVAS directly and the
    66                         // file only used as fallback
     63                InputStream is = null;
     64                File mapUrlFile = new File(mapUrl);
     65                _logger.info("Reading vocabulary file from: {}", mapUrl);
     66                // load records from file
     67                // in the future this should be loaded from CLAVAS directly and the
     68                // file only used as fallback
     69               
     70               
     71                //try from file and if not exists fetch it from classpath (root of the vlo-vocabularies project)
     72                Path p = Paths.get(mapUrl);
     73               
     74                try {
     75                        is = new FileInputStream(mapUrlFile);
     76                } catch (Exception e) {
     77                        _logger.warn("File {} not found, trying to fetch it from classpath ...", mapUrl);
    6778                       
    68                         InputStream is = PostProcessorsWithVocabularyMap.class.getClassLoader().getResourceAsStream(mapUrl);
     79                        is = PostProcessorsWithVocabularyMap.class.getClassLoader().getResourceAsStream(mapUrlFile.getName());
    6980                        if(is == null)
    7081                                throw new RuntimeException("Cannot instantiate postProcessor, " + mapUrl + " is not on the classpath");
    71                        
    72                         try{
    73                                 return VariantsMapMarshaller.unmarshal(is);
    74                         } catch (Exception e) {
    75                                 throw new RuntimeException("Cannot instantiate postProcessor: ", e);
    76                         }
     82                }
     83               
     84                try{
     85                        return VariantsMapMarshaller.unmarshal(is);
     86                } catch (Exception e) {
     87                        throw new RuntimeException("Cannot instantiate postProcessor: ", e);
     88                }
    7789                       
    7890               
Note: See TracChangeset for help on using the changeset viewer.