public ImportService getImportService ( File file , RepositoryCollection source ) { final Map < String , ImportService > importServicesMappedToExtensions = Maps . newHashMap ( ) ; importServices . stream ( ) . filter ( importService -> importService . canImport ( file , source ) ) . forEach ( importService -> { for ( String extension : importService . getSupportedFileExtensions ( ) ) { importServicesMappedToExtensions . put ( extension . toLowerCase ( ) , importService ) ; } } ) ; String extension = FileExtensionUtils . findExtensionFromPossibilities ( file . getName ( ) , importServicesMappedToExtensions . keySet ( ) ) ; final ImportService importService = importServicesMappedToExtensions . get ( extension ) ; if ( importService == null ) throw new MolgenisDataException ( "Can not import file. No suitable importer found" ) ; return importService ; }
Finds a suitable ImportService for a FileRepositoryCollection .