private void importDataArchive ( final Resource resource , final ArchiveInputStream resourceStream , BatchImportOptions options ) { final File tempDir = Files . createTempDir ( ) ; try { ArchiveEntry archiveEntry ; while ( ( archiveEntry = resourceStream . getNextEntry ( ) ) != null ) { final File entryFile = new File ( tempDir , archiveEntry . getName ( ) ) ; if ( ! archiveEntry . isDirectory ( ) ) { entryFile . getParentFile ( ) . mkdirs ( ) ; IOUtils . copy ( new CloseShieldInputStream ( resourceStream ) , new FileOutputStream ( entryFile ) ) ; } } importDataDirectory ( tempDir , null , options ) ; } catch ( IOException e ) { throw new RuntimeException ( "Failed to extract data from '" + resource + "' to '" + tempDir + "' for batch import." , e ) ; } finally { FileUtils . deleteQuietly ( tempDir ) ; } }
Extracts the archive resource and then runs the batch - import process on it .