List result = new ArrayList(targetFiles);
File manifestFile = new File(source, (String) sourceFiles.remove(0));
Manifest resultManifest = Utils.readManifest(manifestFile);
resultManifest.getMainAttributes().remove(new Name(Constants.DEPLOYMENTPACKAGE_FIXPACK));
for (Iterator i = result.iterator(); i.hasNext();) {
String targetFile = (String) i.next();
if (!"META-INF/MANIFEST.MF".equals(targetFile) && !resultManifest.getEntries().containsKey(targetFile)) {
i.remove();
}
}
for (Iterator iter = sourceFiles.iterator(); iter.hasNext();) {
String path = (String) iter.next();
File from = new File(source, path);
File to = new File(target, path);
if (targetFiles.contains(path)) {
if (!to.delete()) {
throw new IOException("Could not delete " + to);
}
}
else {
result.add(path);
}
if (!rename(from, to)) {
throw new IOException("Could not rename " + from + " to " + to);
}
}
targetFiles.removeAll(sourceFiles);
for (Iterator iter = resultManifest.getEntries().keySet().iterator(); iter.hasNext();) {
String path = (String) iter.next();
Attributes sourceAttribute = (Attributes) resultManifest.getEntries().get(path);
if ("true".equals(sourceAttribute.remove(new Name(Constants.DEPLOYMENTPACKAGE_MISSING)))) {
targetFiles.remove(path);
}
}
for (Iterator iter = targetFiles.iterator(); iter.hasNext();) {