final ContentModifications cp2Mods = new ContentModifications(e2.getModifications()); for (ContentModification cp1Mod : e1.getModifications()) { final ContentModification cp2Mod = cp2Mods.remove(cp1Mod.getItem()); if (cp2Mod == null) {
final ContentModifications cp2Mods = new ContentModifications(e2.getModifications()); for (ContentModification cp1Mod : e1.getModifications()) { final ContentModification cp2Mod = cp2Mods.remove(cp1Mod.getItem()); if (cp2Mod == null) {
elementWriter.copyItems(element.getModifications());
if (name.equals(originalElement.getProvider().getName()) && addOn == originalElement.getProvider().isAddOn()) { PatchingTasks.addMissingModifications(target, originalElement.getModifications(), ContentItemFilter.ALL_BUT_MISC);
PatchingTasks.rollback(elementPatchId, original.getModifications(), patchElement.getModifications(), entry, ContentItemFilter.ALL_BUT_MISC, mode); entry.rollback(original.getId());
if (name.equals(originalElement.getProvider().getName()) && addOn == originalElement.getProvider().isAddOn()) { PatchingTasks.addMissingModifications(target, originalElement.getModifications(), ContentItemFilter.ALL_BUT_MISC);
provider.isAddOn()).setDescription(cp2El.getDescription()); mergeModifications(elementBuilder, cp1El.getModifications(), cp2El.getModifications(), cp1, cp2);
provider.isAddOn()).setDescription(cp2El.getDescription()); mergeModifications(elementBuilder, cp1El.getModifications(), cp2El.getModifications(), cp1, cp2);
boolean modules = false; boolean bundles = false; for (final ContentModification modification : element.getModifications()) { if (modules && bundles) { break;
boolean modules = false; boolean bundles = false; for (final ContentModification modification : element.getModifications()) { if (modules && bundles) { break;
apply(elementPatchId, element.getModifications(), target); target.apply(elementPatchId, elementPatchType);
apply(elementPatchId, element.getModifications(), target); target.apply(elementPatchId, elementPatchType);
@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()); }
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(LayerType.Layer, provider.getLayerType()); assertEquals(3, e.getModifications().size()); for(ContentModification mod : e.getModifications()) { assertEquals(ModificationType.REMOVE, mod.getType()); final ContentItem item = mod.getItem();
assertEquals(LayerType.Layer, provider.getLayerType()); assertEquals(3, e.getModifications().size()); for(ContentModification mod : e.getModifications()) { assertEquals(ModificationType.MODIFY, mod.getType()); final ContentItem item = mod.getItem();
assertEquals(LayerType.Layer, provider.getLayerType()); assertEquals(3, e.getModifications().size()); for(ContentModification mod : e.getModifications()) { assertEquals(ModificationType.MODIFY, mod.getType()); final ContentItem item = mod.getItem();
writeContentModifications(writer, element.getModifications());
writeContentModifications(writer, element.getModifications());
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()); } }