Search in sources :

Example 16 with PatchElement

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

the class PatchHandler method displayPatchXml.

private void displayPatchXml(CommandContext ctx, Patch patch) throws CommandLineException {
    final Identity identity = patch.getIdentity();
    SimpleTable table = new SimpleTable(2, ctx.getTerminalWidth());
    table.addLine(new String[] { "Patch ID:", patch.getPatchId() });
    table.addLine(new String[] { "Type:", identity.getPatchType().getName() });
    table.addLine(new String[] { "Identity name:", identity.getName() });
    table.addLine(new String[] { "Identity version:", identity.getVersion() });
    table.addLine(new String[] { "Description:", patch.getDescription() == null ? "n/a" : patch.getDescription() });
    if (patch.getLink() != null) {
        table.addLine(new String[] { "Link:", patch.getLink() });
    }
    ctx.printLine(table.toString(false));
    if (verbose.isPresent(ctx.getParsedCommandLine())) {
        ctx.printLine("");
        ctx.printLine("ELEMENTS");
        for (PatchElement e : patch.getElements()) {
            table = new SimpleTable(2, ctx.getTerminalWidth());
            table.addLine(new String[] { "Patch ID:", e.getId() });
            table.addLine(new String[] { "Name:", e.getProvider().getName() });
            table.addLine(new String[] { "Type:", e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER });
            table.addLine(new String[] { "Description:", e.getDescription() });
            ctx.printLine("");
            ctx.printLine(table.toString(false));
        }
    }
}
Also used : SimpleTable(org.jboss.as.cli.util.SimpleTable) PatchElement(org.jboss.as.patching.metadata.PatchElement) Identity(org.jboss.as.patching.metadata.Identity)

Example 17 with PatchElement

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

the class IdentityApplyCallback method operationCancelled.

@Override
public void operationCancelled(IdentityPatchContext context) {
    // Cleanup history, bundles and module patch directories
    final InstalledImage image = structure.getInstalledImage();
    IoUtils.recursiveDelete(image.getPatchHistoryDir(patchId));
    IoUtils.recursiveDelete(structure.getBundlesPatchDirectory(patchId));
    IoUtils.recursiveDelete(structure.getModulePatchDirectory(patchId));
    for (final PatchElement element : original.getElements()) {
        boolean addOn = element.getProvider().isAddOn();
        final IdentityPatchContext.PatchEntry entry = context.getEntry(element.getProvider().getName(), addOn);
        final DirectoryStructure structure = entry.getDirectoryStructure();
        IoUtils.recursiveDelete(structure.getBundlesPatchDirectory(element.getId()));
        IoUtils.recursiveDelete(structure.getModulePatchDirectory(element.getId()));
    }
}
Also used : PatchElement(org.jboss.as.patching.metadata.PatchElement) InstalledImage(org.jboss.as.patching.installation.InstalledImage) DirectoryStructure(org.jboss.as.patching.DirectoryStructure)

Example 18 with PatchElement

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

the class PatchStepAssertions method assertNotApplied.

static void assertNotApplied(final Patch patch, InstallationManager manager) throws IOException {
    InstalledIdentity installedIdentity = null;
    try {
        installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), patch.getIdentity().getVersion());
    } catch (PatchingException e) {
        Assert.fail(e.getLocalizedMessage());
    }
    final PatchableTarget.TargetInfo identity = installedIdentity.getIdentity().loadTargetInfo();
    assertNotApplied(patch.getIdentity().getPatchType(), patch.getPatchId(), identity);
    assertDoesNotExists(identity.getDirectoryStructure().getInstalledImage().getPatchHistoryDir(patch.getPatchId()));
    for (final PatchElement element : patch.getElements()) {
        final PatchElementProvider provider = element.getProvider();
        final PatchableTarget target = provider.isAddOn() ? installedIdentity.getAddOn(provider.getName()) : installedIdentity.getLayer(provider.getName());
        Assert.assertNotNull(target);
        assertNotApplied(provider.getPatchType(), element.getId(), target.loadTargetInfo());
    }
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) PatchableTarget(org.jboss.as.patching.installation.PatchableTarget) PatchingException(org.jboss.as.patching.PatchingException) PatchElementProvider(org.jboss.as.patching.metadata.PatchElementProvider) PatchElement(org.jboss.as.patching.metadata.PatchElement)

Example 19 with PatchElement

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

the class MergingPatchMetadataTestCase method testAddRemove.

@Test
public void testAddRemove() throws Exception {
    final Patch cp1 = generateCP("base", "cp1", ModificationType.ADD);
    final Patch cp2 = generateCP("cp1", "cp2", ModificationType.REMOVE);
    final Patch merged = PatchMerger.merge(cp1, cp2);
    assertEquals("cp2", merged.getPatchId());
    assertEquals("cp2" + " description", merged.getDescription());
    final IdentityUpgrade identity = merged.getIdentity().forType(PatchType.CUMULATIVE, Identity.IdentityUpgrade.class);
    assertEquals("base", identity.getVersion());
    assertEquals("cp2", identity.getResultingVersion());
    assertEquals(PatchType.CUMULATIVE, identity.getPatchType());
    final List<PatchElement> elements = merged.getElements();
    assertEquals(1, elements.size());
    final PatchElement e = elements.get(0);
    assertEquals("base-" + "cp2", e.getId());
    final PatchElementProvider provider = e.getProvider();
    assertEquals("base", provider.getName());
    assertEquals(PatchType.CUMULATIVE, provider.getPatchType());
    assertEquals(LayerType.Layer, provider.getLayerType());
    // assertEquals(0, e.getModifications().size());
    // for modules remove is effectively a modify which changes the module xml to indicate an absent module
    // so, it will remain an add of an absent module
    assertEquals(1, e.getModifications().size());
    final ContentModification mod = e.getModifications().iterator().next();
    assertEquals(ModificationType.ADD, mod.getType());
    Assert.assertArrayEquals(PatchUtils.getAbsentModuleContentHash((ModuleItem) mod.getItem()), mod.getItem().getContentHash());
}
Also used : ModuleItem(org.jboss.as.patching.metadata.ModuleItem) IdentityUpgrade(org.jboss.as.patching.metadata.Identity.IdentityUpgrade) PatchElementProvider(org.jboss.as.patching.metadata.PatchElementProvider) PatchElement(org.jboss.as.patching.metadata.PatchElement) Identity(org.jboss.as.patching.metadata.Identity) Patch(org.jboss.as.patching.metadata.Patch) ContentModification(org.jboss.as.patching.metadata.ContentModification) Test(org.junit.Test)

Example 20 with PatchElement

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

the class MergingPatchMetadataTestCase method testAddModify.

@Test
public void testAddModify() throws Exception {
    final Patch cp1 = generateCP("base", "cp1", ModificationType.ADD);
    final Patch cp2 = generateCP("cp1", "cp2", ModificationType.MODIFY);
    final Patch merged = PatchMerger.merge(cp1, cp2);
    assertEquals("cp2", merged.getPatchId());
    assertEquals("cp2" + " description", merged.getDescription());
    final IdentityUpgrade identity = merged.getIdentity().forType(PatchType.CUMULATIVE, Identity.IdentityUpgrade.class);
    assertEquals("base", identity.getVersion());
    assertEquals("cp2", identity.getResultingVersion());
    assertEquals(PatchType.CUMULATIVE, identity.getPatchType());
    final List<PatchElement> elements = merged.getElements();
    assertEquals(1, elements.size());
    final PatchElement e = elements.get(0);
    assertEquals("base-" + "cp2", e.getId());
    final PatchElementProvider provider = e.getProvider();
    assertEquals("base", provider.getName());
    assertEquals(PatchType.CUMULATIVE, provider.getPatchType());
    assertEquals(LayerType.Layer, provider.getLayerType());
    assertEquals(3, e.getModifications().size());
    for (ContentModification mod : e.getModifications()) {
        assertEquals(ModificationType.ADD, mod.getType());
        final ContentItem item = mod.getItem();
        assertEquals(0, mod.getTargetHash().length);
        if (ContentType.MODULE.equals(item.getContentType())) {
            Assert.assertArrayEquals(moduleHash("cp2"), item.getContentHash());
        } else if (ContentType.MISC.equals(item.getContentType())) {
            Assert.assertArrayEquals(miscHash("cp2"), item.getContentHash());
        } else {
            Assert.assertArrayEquals(bundleHash("cp2"), item.getContentHash());
        }
    }
}
Also used : IdentityUpgrade(org.jboss.as.patching.metadata.Identity.IdentityUpgrade) PatchElementProvider(org.jboss.as.patching.metadata.PatchElementProvider) PatchElement(org.jboss.as.patching.metadata.PatchElement) Identity(org.jboss.as.patching.metadata.Identity) Patch(org.jboss.as.patching.metadata.Patch) ContentModification(org.jboss.as.patching.metadata.ContentModification) ContentItem(org.jboss.as.patching.metadata.ContentItem) Test(org.junit.Test)

Aggregations

PatchElement (org.jboss.as.patching.metadata.PatchElement)20 Patch (org.jboss.as.patching.metadata.Patch)13 PatchElementProvider (org.jboss.as.patching.metadata.PatchElementProvider)11 Identity (org.jboss.as.patching.metadata.Identity)10 ContentModification (org.jboss.as.patching.metadata.ContentModification)8 InstalledIdentity (org.jboss.as.patching.installation.InstalledIdentity)7 RollbackPatch (org.jboss.as.patching.metadata.RollbackPatch)6 IdentityUpgrade (org.jboss.as.patching.metadata.Identity.IdentityUpgrade)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 PatchingException (org.jboss.as.patching.PatchingException)4 PatchableTarget (org.jboss.as.patching.installation.PatchableTarget)4 ContentItem (org.jboss.as.patching.metadata.ContentItem)4 PatchEntry (org.jboss.as.patching.runner.IdentityPatchContext.PatchEntry)4 Entry (org.jboss.as.patching.tool.PatchingHistory.Entry)3 File (java.io.File)2 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 SimpleTable (org.jboss.as.cli.util.SimpleTable)2