use of net.sourceforge.processdash.tool.export.mgr.ExternalResourceManager in project processdash by dtuma.
the class FileBackupManager method createExternalizedBackupFile.
private File createExternalizedBackupFile(URL backup) throws IOException {
// open the existing backup file as a ZIP stream
ZipInputStream zipIn = new ZipInputStream(new BufferedInputStream(backup.openStream()));
// create a temporary file for externalizing purposes
File result = TempFileFactory.get().createTempFile("pdash-backup", ".zip");
result.deleteOnExit();
ZipOutputStream zipOut = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(result)));
zipOut.setLevel(9);
ExternalResourceManager extMgr = ExternalResourceManager.getInstance();
// copy all the files from the existing backup into the externalized
// backup (but skip any files that appear to be externalized)
ZipEntry e;
while ((e = zipIn.getNextEntry()) != null) {
String filename = e.getName();
if (extMgr.isArchivedItem(filename))
continue;
ZipEntry eOut = new ZipEntry(filename);
eOut.setTime(e.getTime());
zipOut.putNextEntry(eOut);
FileUtils.copyFile(zipIn, zipOut);
zipOut.closeEntry();
}
zipIn.close();
// now, ask the external resource manager to augment the ZIP.
extMgr.addExternalResourcesToBackup(zipOut);
zipOut.finish();
zipOut.close();
return result;
}
Aggregations