ZipArchiveInputStream existingInputStream = new ZipArchiveInputStream(new FileInputStream(existingArchiveFile));
/*
* Create a zip archive output stream for the temp file
*/
ZipArchiveOutputStream tempOutputStream = new ZipArchiveOutputStream(tempArchiveFile);
/*
* Iterate through all existing entries adding them to the new archive
*/
ZipArchiveEntry curArchiveEntry;
Set<String> existingArchiveEntryNames = new HashSet<String>();
while ((curArchiveEntry = existingInputStream.getNextZipEntry()) != null) {
existingArchiveEntryNames.add(curArchiveEntry.getName().toLowerCase());
getLog().debug("Current File Name: " + curArchiveEntry.getName());
tempOutputStream.putArchiveEntry(curArchiveEntry);
IOUtils.copy(existingInputStream, tempOutputStream);
tempOutputStream.closeArchiveEntry();
}
/*
* Create content.xml within temp archive
*/
ContentUtil.buildContentFromClassList(classList, tempOutputStream, existingArchiveEntryNames, buildDirectory,
componentPathBase, defaultComponentPathSuffix, defaultComponentGroup, transformer);
/*
* Create Dialogs within temp archive
*/
DialogUtil.buildDialogsFromClassList(transformer, classList, tempOutputStream, existingArchiveEntryNames,
widgetRegistry, classLoader, classPool, buildDirectory, componentPathBase, defaultComponentPathSuffix);
/*
* Create edit config within temp archive
*/
EditConfigUtil.buildEditConfigFromClassList(classList, tempOutputStream, existingArchiveEntryNames,
buildDirectory, componentPathBase, defaultComponentPathSuffix, transformer);
/*
* Copy temp archive to the original archive position
*/
tempOutputStream.finish();
existingInputStream.close();
tempOutputStream.close();
existingArchiveFile.delete();
tempArchiveFile.renameTo(existingArchiveFile);
}