@Override public InputStream getDumpFileStream() throws IOException { prepareDumpFile(); String fileName = WmfDumpFile.getDumpFileName(this.dumpContentType, this.projectName, this.dateStamp); DirectoryManager thisDumpDirectoryManager = this.dumpfileDirectoryManager .getSubdirectoryManager(WmfDumpFile.getDumpFileDirectoryName( this.dumpContentType, this.dateStamp)); return thisDumpDirectoryManager.getInputStreamForFile(fileName, WmfDumpFile.getDumpFileCompressionType(fileName)); }
@Override protected boolean fetchIsDone() { return this.localDumpfileDirectoryManager.hasFile(WmfDumpFile .getDumpFileName(this.dumpContentType, this.projectName, this.dateStamp)); }
if (!dumpfileDirectoryManager.hasSubdirectory(subdirectoryName)) { throw new IllegalArgumentException( "There is no local dump file directory at the specified location."); .getSubdirectoryManager(subdirectoryName); } catch (IOException e) { throw new IllegalArgumentException(
@Override public void prepareDumpFile() throws IOException { if (this.isPrepared) { return; } String fileName = WmfDumpFile.getDumpFileName(DumpContentType.JSON, this.projectName, this.dateStamp); String urlString = getBaseUrl() + fileName; logger.info("Downloading JSON dump file " + fileName + " from " + urlString + " ..."); if (!isAvailable()) { throw new IOException( "Dump file not available (yet). Aborting dump retrieval."); } DirectoryManager dailyDirectoryManager = this.dumpfileDirectoryManager .getSubdirectoryManager(WmfDumpFile.getDumpFileDirectoryName( DumpContentType.JSON, this.dateStamp)); try (InputStream inputStream = webResourceFetcher .getInputStreamForUrl(urlString)) { dailyDirectoryManager.createFileAtomic(fileName, inputStream); } this.isPrepared = true; logger.info("... completed download of JSON dump file " + fileName + " from " + urlString); }
@Override public InputStream getDumpFileStream() throws IOException { if (!isAvailable()) { throw new IOException("Local dump file \"" + this.dumpFilePath.toString() + "\" is not available for reading."); } return this.directoryManager.getInputStreamForFile(this.dumpFileName, MwLocalDumpFile.COMPRESSION_TYPE.get(this.dumpContentType)); }
OutputStream out = dm.getOutputStreamForFile(Paths .get(this.clientConfiguration.getReportFileName()) .getFileName().toString());
/** * Constructor. * * @param projectName * name of the project to obtain dumps for as used in the folder * structure of the dump site, e.g., "wikidatawiki" * @param downloadDirectoryManager * the directory manager for the directory where the download * directory for dump files should be; it will be created if * needed * @param webResourceFetcher * the web resource fetcher to access web resources or null if no * web access should happen * @throws IOException * if it was not possible to access the directory for managing * dumpfiles */ public WmfDumpFileManager(String projectName, DirectoryManager downloadDirectoryManager, WebResourceFetcher webResourceFetcher) throws IOException { this.projectName = projectName; this.dumpfileDirectoryManager = downloadDirectoryManager .getSubdirectoryManager( WmfDumpFileManager.DOWNLOAD_DIRECTORY_NAME) .getSubdirectoryManager(projectName); this.webResourceFetcher = webResourceFetcher; WmfDumpFileManager.logger.info("Using download directory " + this.dumpfileDirectoryManager.toString()); }
try { dumpFileDirectories = this.dumpfileDirectoryManager .getSubdirectories(directoryPattern); } catch (IOException e) { logger.error("Unable to access dump directory: " + e.toString());
@Override public void prepareDumpFile() throws IOException { if (this.isPrepared) { return; } String fileName = WmfDumpFile.getDumpFileName(DumpContentType.DAILY, this.projectName, this.dateStamp); String urlString = getBaseUrl() + fileName; logger.info("Downloading daily dump file " + fileName + " from " + urlString + " ..."); if (!isAvailable()) { throw new IOException( "Dump file not available (yet). Aborting dump retrieval."); } DirectoryManager dailyDirectoryManager = this.dumpfileDirectoryManager .getSubdirectoryManager(WmfDumpFile.getDumpFileDirectoryName( DumpContentType.DAILY, this.dateStamp)); long size; try (InputStream inputStream = webResourceFetcher .getInputStreamForUrl(urlString)) { size = dailyDirectoryManager .createFileAtomic(fileName, inputStream); } this.isPrepared = true; logger.info("... completed download of daily dump file " + fileName + " from " + urlString + " (" + size + " bytes)"); }
@Override public InputStream getDumpFileStream() throws IOException { String dumpFileName = WmfDumpFile.getDumpFileName(this.dumpContentType, this.projectName, this.dateStamp); return this.localDumpfileDirectoryManager.getInputStreamForFile( dumpFileName, WmfDumpFile.getDumpFileCompressionType(dumpFileName)); }
OutputStream out = dm.getOutputStreamForFile(Paths.get(filePath) .getFileName().toString());
@Override public InputStream getDumpFileStream() throws IOException { prepareDumpFile(); String fileName = WmfDumpFile.getDumpFileName(DumpContentType.DAILY, this.projectName, this.dateStamp); DirectoryManager dailyDirectoryManager = this.dumpfileDirectoryManager .getSubdirectoryManager(WmfDumpFile.getDumpFileDirectoryName( DumpContentType.DAILY, this.dateStamp)); return dailyDirectoryManager.getInputStreamForFile(fileName, WmfDumpFile.getDumpFileCompressionType(fileName)); }
@Override public void prepareDumpFile() throws IOException { if (this.isPrepared) { return; } String fileName = WmfDumpFile.getDumpFileName(this.dumpContentType, this.projectName, this.dateStamp); String urlString = getBaseUrl() + fileName; logger.info("Downloading " + this.dumpContentType.toString().toLowerCase() + " dump file " + fileName + " from " + urlString + " ..."); if (!isAvailable()) { throw new IOException( "Dump file not available (yet). Aborting dump retrieval."); } DirectoryManager thisDumpDirectoryManager = this.dumpfileDirectoryManager .getSubdirectoryManager(WmfDumpFile.getDumpFileDirectoryName( this.dumpContentType, this.dateStamp)); long size; try (InputStream inputStream = webResourceFetcher .getInputStreamForUrl(urlString)) { size = thisDumpDirectoryManager.createFileAtomic(fileName, inputStream); } this.isPrepared = true; logger.info("... completed download of " + this.dumpContentType.toString().toLowerCase() + " dump file " + fileName + " from " + urlString + " (" + size + " bytes)"); }
&& this.directoryManager.hasFile(this.dumpFileName);
@Override public InputStream getDumpFileStream() throws IOException { prepareDumpFile(); String fileName = WmfDumpFile.getDumpFileName(DumpContentType.JSON, this.projectName, this.dateStamp); DirectoryManager dailyDirectoryManager = this.dumpfileDirectoryManager .getSubdirectoryManager(WmfDumpFile.getDumpFileDirectoryName( DumpContentType.JSON, this.dateStamp)); return dailyDirectoryManager.getInputStreamForFile(fileName, WmfDumpFile.getDumpFileCompressionType(fileName)); }