use of org.jboss.as.patching.metadata.PatchMetadataResolver in project wildfly-core by wildfly.
the class PatchToolImpl method execute.
protected PatchingResult execute(final File workDir, final ContentVerificationPolicy contentPolicy) throws PatchingException, IOException, XMLStreamException {
final File patchBundleXml = new File(workDir, PatchBundleXml.MULTI_PATCH_XML);
if (patchBundleXml.exists()) {
final InputStream patchIs = new FileInputStream(patchBundleXml);
try {
// Handle multi patch installs
final BundledPatch bundledPatch = PatchBundleXml.parse(patchIs);
return applyPatchBundle(workDir, bundledPatch, contentPolicy);
} finally {
safeClose(patchIs);
}
} else {
// Parse the xml
File patchXml = new File(workDir, PatchXml.PATCH_XML);
PatchMetadataResolver patchResolver = parsePatchXml(patchXml);
Patch patch = patchResolver.resolvePatch(null, null);
final InstalledIdentity installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), null);
final String currentVersion = installedIdentity.getIdentity().getVersion();
if (!Constants.UNKNOWN.equals(currentVersion) && !patch.getIdentity().getVersion().equals(currentVersion)) {
patchXml = new File(workDir, currentVersion + PatchMerger.PATCH_XML_SUFFIX);
if (!patchXml.exists()) {
throw new PatchingException("The patch does not contain metadata for currently installed " + patch.getIdentity().getName() + " version " + currentVersion);
}
patchResolver = parsePatchXml(patchXml);
patch = patchResolver.resolvePatch(null, null);
}
return apply(patchResolver, PatchContentProvider.DefaultContentProvider.create(workDir), contentPolicy);
}
}
Aggregations