public IdentityApplyCallback(final Patch original, final DirectoryStructure structure) { this.patchId = original.getPatchId(); this.original = original; this.structure = structure; }
@Override public String getPatchId() { return original.getPatchId(); }
@Override public String getPatchId() { return patch.getPatchId(); }
@Override public String getPatchId() { return original.getPatchId(); }
public IdentityApplyCallback(final Patch original, final DirectoryStructure structure) { this.patchId = original.getPatchId(); this.original = original; this.structure = structure; }
@Override public String getPatchId() { return patch.getPatchId(); }
public static void assertInstallationIsPatched(Patch patch, PatchableTarget.TargetInfo targetInfo) { if (CUMULATIVE == patch.getIdentity().getPatchType()) { assertEquals(patch.getPatchId(), targetInfo.getCumulativePatchID()); } else { Assert.assertTrue(targetInfo.getPatchIDs().contains(patch.getPatchId())); // applied one-off patch is at the top of the patchIDs assertEquals(patch.getPatchId(), targetInfo.getPatchIDs().get(0)); } } }
static void assertNoResourcesForPatch(DirectoryStructure structure, Patch patch) { assertDirDoesNotExist(structure.getModulePatchDirectory(patch.getPatchId())); assertDirDoesNotExist(structure.getBundlesPatchDirectory(patch.getPatchId())); assertDirDoesNotExist(structure.getInstalledImage().getPatchHistoryDir(patch.getPatchId())); }
/** * Create a patch representing what we actually processed. This may contain some fixed content hashes for removed * modules. * * @param original the original * @return the processed patch */ protected Patch createProcessedPatch(final Patch original) { // Process elements final List<PatchElement> elements = new ArrayList<PatchElement>(); // Process layers for (final PatchEntry entry : getLayers()) { final PatchElement element = createPatchElement(entry, entry.element.getId(), entry.modifications); elements.add(element); } // Process add-ons for (final PatchEntry entry : getAddOns()) { final PatchElement element = createPatchElement(entry, entry.element.getId(), entry.modifications); elements.add(element); } // Swap the patch element modifications, keep the identity ones since we don't need to fix the misc modifications return new PatchImpl(original.getPatchId(), original.getDescription(), original.getLink(), original.getIdentity(), elements, identityEntry.modifications); }
@Override public void completed(IdentityPatchContext context) { final InstalledImage installedImage = directoryStructure.getInstalledImage(); final File history = installedImage.getPatchHistoryDir(patch.getPatchId()); if (!recursiveDelete(history)) { context.failedToCleanupDir(history); } // Cleanup all the recorded rollbacks cleanupEntry(context.getLayers()); cleanupEntry(context.getAddOns()); cleanupEntry(Collections.singleton(context.getIdentityEntry())); }
@Override public void completed(IdentityPatchContext context) { final InstalledImage installedImage = directoryStructure.getInstalledImage(); final File history = installedImage.getPatchHistoryDir(patch.getPatchId()); if (!recursiveDelete(history)) { context.failedToCleanupDir(history); } // Cleanup all the recorded rollbacks cleanupEntry(context.getLayers()); cleanupEntry(context.getAddOns()); cleanupEntry(Collections.singleton(context.getIdentityEntry())); }
static ContentTaskDefinitions process(final RollbackInfo... rollbackInfos) { final ContentTaskDefinitions foo = new ContentTaskDefinitions(); for(final RollbackInfo info : rollbackInfos) { PatchingTasks.rollback(info.original.getPatchId(), info.original.getModifications(), info.rollback.getModifications(), foo, ContentItemFilter.MISC_ONLY, PatchingTaskContext.Mode.APPLY); } return foo; }
static void assertPatchHasNotBeenApplied(ContentConflictsException result, Patch patch, ContentItem problematicItem, DirectoryStructure structure) { assertFalse("patch should have failed", result.getConflicts().isEmpty()); assertTrue(problematicItem + " is not reported in the problems " + result.getConflicts(), result.getConflicts().contains(problematicItem)); assertDirDoesNotExist(structure.getInstalledImage().getPatchHistoryDir(patch.getPatchId())); }
public static void assertPatchHasBeenApplied(PatchingResult result, Patch patch) { if (CUMULATIVE == patch.getIdentity().getPatchType()) { assertEquals(patch.getPatchId(), result.getPatchInfo().getCumulativePatchID()); assertTrue(result.getPatchInfo().getPatchIDs().isEmpty()); assertEquals(patch.getIdentity().forType(CUMULATIVE, org.jboss.as.patching.metadata.Identity.IdentityUpgrade.class).getResultingVersion(), result.getPatchInfo().getVersion()); } else { assertTrue(result.getPatchInfo().getPatchIDs().contains(patch.getPatchId())); // applied one-off patch is at the top of the patchIDs assertEquals(patch.getPatchId(), result.getPatchInfo().getPatchIDs().get(0)); } }
@Test public void testRemovedModifiedFileWithOVERRIDE_ALL() throws Exception { PatchingResult result = runner.applyPatch(zippedPatch, ContentVerificationPolicy.OVERRIDE_ALL); assertPatchHasBeenApplied(result, patch); /// file has been removed from the AS7 installation // and it's the new one assertFileDoesNotExist(removedFile); // the existing file has been backed up File backupFile = assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "misc", "bin", removedFile.getName()); assertArrayEquals(expectedModifiedHash, hashFile(backupFile)); }
@Test public void testUpdateModifiedFileWithOVERRIDE_ALL() throws Exception { PatchingResult result = runner.applyPatch(zippedPatch, ContentVerificationPolicy.OVERRIDE_ALL); assertPatchHasBeenApplied(result, patch); /// file has been updated in the AS7 installation // and it's the new one assertFileExists(modifiedFile); assertArrayEquals(updatedHash, hashFile(modifiedFile)); // the existing file has been backed up File backupFile = assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "misc", "bin", modifiedFile.getName()); assertArrayEquals(expectedModifiedHash, hashFile(backupFile)); }
@Test public void testParseOneOff() throws Exception { final InputStream is = getResource("patch-02-ONE-OFF.xml"); final Patch patch = PatchXml.parse(is).resolvePatch(null, null); // One-off Patch assertNotNull(patch); assertNotNull(patch.getPatchId()); assertNotNull(patch.getDescription()); final Identity identity = patch.getIdentity(); assertNotNull(identity); assertNotNull(patch.getIdentity().getVersion()); }
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()); } }
@Test public void testParseCP() throws Exception { final InputStream is = getResource("patch-01-CP.xml"); final Patch patch = PatchXml.parse(is).resolvePatch(null, null); // Cumulative Patch assertNotNull(patch); assertNotNull(patch.getPatchId()); assertNotNull(patch.getDescription()); final Identity identity = patch.getIdentity(); assertNotNull(identity); assertEquals(Patch.PatchType.CUMULATIVE, identity.getPatchType()); assertNotNull(identity.forType(Patch.PatchType.CUMULATIVE, Identity.IdentityUpgrade.class).getResultingVersion()); assertNotNull(identity.getVersion()); }
static void assertApplied(final Patch patch, InstallationManager manager) throws IOException { final String patchID = patch.getPatchId(); InstalledIdentity installedIdentity = null; try { installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), null); } catch (PatchingException e) { Assert.fail(e.getLocalizedMessage()); } final PatchableTarget target = installedIdentity.getIdentity(); final PatchableTarget.TargetInfo identity = target.loadTargetInfo(); assertIsApplied(patch.getIdentity().getPatchType(), patchID, identity); assertExists(identity.getDirectoryStructure().getInstalledImage().getPatchHistoryDir(patchID)); assertContentItems(patchID, target, patch.getModifications()); for (final PatchElement element : patch.getElements()) { final PatchElementProvider provider = element.getProvider(); final PatchableTarget targetElement = provider.isAddOn() ? installedIdentity.getAddOn(provider.getName()) : installedIdentity.getLayer(provider.getName()); assertIsApplied(provider.getPatchType(), element.getId(), targetElement.loadTargetInfo()); assertContentItems(element.getId(), targetElement, element.getModifications()); } }