Search in sources :

Example 1 with PatchMetadataResolver

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);
    }
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) PatchingException(org.jboss.as.patching.PatchingException) PatchMetadataResolver(org.jboss.as.patching.metadata.PatchMetadataResolver) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) BundledPatch(org.jboss.as.patching.metadata.BundledPatch) File(java.io.File) Patch(org.jboss.as.patching.metadata.Patch) BundledPatch(org.jboss.as.patching.metadata.BundledPatch) FileInputStream(java.io.FileInputStream)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 PatchingException (org.jboss.as.patching.PatchingException)1 InstalledIdentity (org.jboss.as.patching.installation.InstalledIdentity)1 BundledPatch (org.jboss.as.patching.metadata.BundledPatch)1 Patch (org.jboss.as.patching.metadata.Patch)1 PatchMetadataResolver (org.jboss.as.patching.metadata.PatchMetadataResolver)1