Search in sources :

Example 1 with PatchingHistory

use of org.jboss.as.patching.tool.PatchingHistory in project wildfly-core by wildfly.

the class IdentityPatchRunner method portForward.

/**
 * Port forward missing module changes for each layer.
 *
 * @param patch   the current patch
 * @param context the patch context
 * @throws PatchingException
 * @throws IOException
 * @throws XMLStreamException
 */
void portForward(final Patch patch, IdentityPatchContext context) throws PatchingException, IOException, XMLStreamException {
    assert patch.getIdentity().getPatchType() == Patch.PatchType.CUMULATIVE;
    final PatchingHistory history = context.getHistory();
    for (final PatchElement element : patch.getElements()) {
        final PatchElementProvider provider = element.getProvider();
        final String name = provider.getName();
        final boolean addOn = provider.isAddOn();
        final IdentityPatchContext.PatchEntry target = context.resolveForElement(element);
        final String cumulativePatchID = target.getCumulativePatchID();
        if (Constants.BASE.equals(cumulativePatchID)) {
            reenableRolledBackInBase(target);
            continue;
        }
        boolean found = false;
        final PatchingHistory.Iterator iterator = history.iterator();
        while (iterator.hasNextCP()) {
            final PatchingHistory.Entry entry = iterator.nextCP();
            final String patchId = addOn ? entry.getAddOnPatches().get(name) : entry.getLayerPatches().get(name);
            if (patchId != null && patchId.equals(cumulativePatchID)) {
                final Patch original = loadPatchInformation(entry.getPatchId(), installedImage);
                for (final PatchElement originalElement : original.getElements()) {
                    if (name.equals(originalElement.getProvider().getName()) && addOn == originalElement.getProvider().isAddOn()) {
                        PatchingTasks.addMissingModifications(target, originalElement.getModifications(), ContentItemFilter.ALL_BUT_MISC);
                    }
                }
                // Record a loader to have access to the current modules
                final DirectoryStructure structure = target.getDirectoryStructure();
                final File modulesRoot = structure.getModulePatchDirectory(patchId);
                final File bundlesRoot = structure.getBundlesPatchDirectory(patchId);
                final PatchContentLoader loader = PatchContentLoader.create(null, bundlesRoot, modulesRoot);
                context.recordContentLoader(patchId, loader);
                found = true;
                break;
            }
        }
        if (!found) {
            throw PatchLogger.ROOT_LOGGER.patchNotFoundInHistory(cumulativePatchID);
        }
        reenableRolledBackInBase(target);
    }
}
Also used : PatchElementProvider(org.jboss.as.patching.metadata.PatchElementProvider) PatchElement(org.jboss.as.patching.metadata.PatchElement) Entry(org.jboss.as.patching.tool.PatchingHistory.Entry) Iterator(org.jboss.as.patching.tool.PatchingHistory.Iterator) PatchingHistory(org.jboss.as.patching.tool.PatchingHistory) Patch(org.jboss.as.patching.metadata.Patch) RollbackPatch(org.jboss.as.patching.metadata.RollbackPatch) File(java.io.File) PatchEntry(org.jboss.as.patching.runner.IdentityPatchContext.PatchEntry) DirectoryStructure(org.jboss.as.patching.DirectoryStructure)

Aggregations

File (java.io.File)1 DirectoryStructure (org.jboss.as.patching.DirectoryStructure)1 Patch (org.jboss.as.patching.metadata.Patch)1 PatchElement (org.jboss.as.patching.metadata.PatchElement)1 PatchElementProvider (org.jboss.as.patching.metadata.PatchElementProvider)1 RollbackPatch (org.jboss.as.patching.metadata.RollbackPatch)1 PatchEntry (org.jboss.as.patching.runner.IdentityPatchContext.PatchEntry)1 PatchingHistory (org.jboss.as.patching.tool.PatchingHistory)1 Entry (org.jboss.as.patching.tool.PatchingHistory.Entry)1 Iterator (org.jboss.as.patching.tool.PatchingHistory.Iterator)1