Search in sources :

Example 6 with RollbackPatch

use of org.jboss.as.patching.metadata.RollbackPatch in project wildfly-core by wildfly.

the class IdentityPatchContext method createRollbackPatch.

/**
 * Create a rollback patch based on the recorded actions.
 *
 * @param patchId   the new patch id, depending on release or one-off
 * @param patchType the current patch identity
 * @return the rollback patch
 */
protected RollbackPatch createRollbackPatch(final String patchId, final Patch.PatchType patchType) {
    // Process elements
    final List<PatchElement> elements = new ArrayList<PatchElement>();
    // Process layers
    for (final PatchEntry entry : getLayers()) {
        final PatchElement element = createRollbackElement(entry);
        elements.add(element);
    }
    // Process add-ons
    for (final PatchEntry entry : getAddOns()) {
        final PatchElement element = createRollbackElement(entry);
        elements.add(element);
    }
    final InstalledIdentity installedIdentity = modification.getUnmodifiedInstallationState();
    final String name = installedIdentity.getIdentity().getName();
    final IdentityImpl identity = new IdentityImpl(name, modification.getVersion());
    if (patchType == Patch.PatchType.CUMULATIVE) {
        identity.setPatchType(Patch.PatchType.CUMULATIVE);
        identity.setResultingVersion(installedIdentity.getIdentity().getVersion());
    } else if (patchType == Patch.PatchType.ONE_OFF) {
        identity.setPatchType(Patch.PatchType.ONE_OFF);
    }
    final List<ContentModification> modifications = identityEntry.rollbackActions;
    final Patch delegate = new PatchImpl(patchId, "rollback patch", identity, elements, modifications);
    return new PatchImpl.RollbackPatchImpl(delegate, installedIdentity);
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) ArrayList(java.util.ArrayList) IdentityImpl(org.jboss.as.patching.metadata.impl.IdentityImpl) PatchElement(org.jboss.as.patching.metadata.PatchElement) PatchImpl(org.jboss.as.patching.metadata.PatchImpl) ContentModification(org.jboss.as.patching.metadata.ContentModification) Patch(org.jboss.as.patching.metadata.Patch) RollbackPatch(org.jboss.as.patching.metadata.RollbackPatch)

Aggregations

RollbackPatch (org.jboss.as.patching.metadata.RollbackPatch)6 Patch (org.jboss.as.patching.metadata.Patch)4 InstalledIdentity (org.jboss.as.patching.installation.InstalledIdentity)3 PatchElement (org.jboss.as.patching.metadata.PatchElement)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 PatchingException (org.jboss.as.patching.PatchingException)2 ContentModification (org.jboss.as.patching.metadata.ContentModification)2 PatchEntry (org.jboss.as.patching.runner.IdentityPatchContext.PatchEntry)2 HashMap (java.util.HashMap)1 List (java.util.List)1 PatchInfo (org.jboss.as.patching.PatchInfo)1 PatchableTarget (org.jboss.as.patching.installation.PatchableTarget)1 Identity (org.jboss.as.patching.metadata.Identity)1 LayerType (org.jboss.as.patching.metadata.LayerType)1 ModuleItem (org.jboss.as.patching.metadata.ModuleItem)1 PatchType (org.jboss.as.patching.metadata.Patch.PatchType)1