}
}
if (patchFiles.isEmpty()) {
LOG.warn("No valid patches to apply");
throw new FabricException("No valid patches to apply");
}
if (targetId == null || targetId.equals("")) {
Version latestVersion = getLatestVersion();
VersionSequence sequence = new VersionSequence(latestVersion.getId());
targetId = sequence.next().getName();
}
Version targetVersion = profileService.createVersionFrom(sourceId, targetId, null);
File currentPatchFile = null;
try {
for (File file : patchFiles) {
currentPatchFile = file;
if (!file.isFile()) {
LOG.info("File is a directory, skipping: {}", file);
continue;
}
LOG.info("Applying patch file {}", file);
fabricService.getPatchService().applyPatch(targetVersion, file.toURI().toURL(), proxyUser, proxyPassword);
LOG.info("Successfully applied {}", file);
}
} catch (Throwable t) {
LOG.warn("Failed to apply patch file {}", currentPatchFile, t);
profileService.deleteVersion(targetId);
throw new FabricException("Failed to apply patch file " + currentPatchFile, t);
}
for (File file : patchFiles) {
try {
LOG.info("Deleting patch file {}", file);