Changeset 6773


Ignore:
Timestamp:
11/09/15 16:05:52 (9 years ago)
Author:
davor.ostojic@oeaw.ac.at
Message:

postprocessor will try first to obtain normalisation map from file system and then from class path

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

    r6731 r6773  
    5959
    6060        protected VariantsMap getMappingFromFile(String mapUrl) {
    61                 try {
     61               
    6262
    6363                        _logger.info("Reading vocabulary file from: {}", mapUrl);
     
    6565                        // in the future this should be loaded from CLAVAS directly and the
    6666                        // file only used as fallback
    67 
    68                         // InputStream is =
    69                         // PostProcessorsWithVocabularyMap.class.getClassLoader().getResourceAsStream(mapUrl);
    70                         InputStream is = new FileInputStream(new File(mapUrl));
    71 
    72                         return VariantsMapMarshaller.unmarshal(is);
    73                 } catch (Exception e) {
    74                         throw new RuntimeException("Cannot instantiate postProcessor:", e);
    75                 }
     67                       
     68                       
     69                        //try from file first
     70                        try {
     71                                InputStream is = new FileInputStream(new File(mapUrl));
     72                        } catch (Exception e) {
     73                                _logger.warn("File {} not found, trying to fetch it from classpath ...", mapUrl);
     74                               
     75                               
     76                        }
     77                       
     78                        //try from classpath
     79                       
     80                        InputStream is = PostProcessorsWithVocabularyMap.class.getClassLoader().getResourceAsStream(mapUrl);
     81                        if(is == null)
     82                                throw new RuntimeException("Cannot instantiate postProcessor, " + mapUrl + " is not on the classpath");
     83                       
     84                        try{
     85                                return VariantsMapMarshaller.unmarshal(is);
     86                        } catch (Exception e) {
     87                                throw new RuntimeException("Cannot instantiate postProcessor: ", e);
     88                        }
     89                       
     90               
    7691        }
    7792
Note: See TracChangeset for help on using the changeset viewer.