final ContentModification mod) throws PatchingException { final ModificationType type = mod.getType(); if(type.equals(ModificationType.REMOVE)) { return;
final ContentModification mod) throws PatchingException { final ModificationType type = mod.getType(); if(type.equals(ModificationType.REMOVE)) { return;
if (cp1Type.equals(ModificationType.ADD)) { if (cp2Type.equals(ModificationType.ADD)) { throw new PatchingException("Patch " + cp2.getPatchId() + " adds " + cp1Mod.getItem().getRelativePath() + " already added by patch " + cp1.getPatchId()); if (cp2Type.equals(ModificationType.MODIFY)) { modType = ModificationType.ADD; } else { // remove cancels add } else if (cp1Type.equals(ModificationType.REMOVE)) { if (cp2Type.equals(ModificationType.REMOVE)) { throw new PatchingException("Patch " + cp2.getPatchId() + " removes " + cp1Mod.getItem().getRelativePath() + " already removed by patch " + cp1.getPatchId()); if (cp2Type.equals(ModificationType.ADD)) { throw new PatchingException("Patch " + cp2.getPatchId() + " adds " + cp1Mod.getItem().getRelativePath() + " modified by patch " + cp1.getPatchId()); if (cp2Type.equals(ModificationType.REMOVE)) { modType = ModificationType.REMOVE; } else { if (ModificationType.ADD.equals(modType)) { final ContentItem cp2Item = cp2Mod.getItem(); if (cp2Item.getContentType().equals(ContentType.MODULE)) { final ModuleItem module = (ModuleItem) cp2Item; if(cp2Type.equals(ModificationType.REMOVE)) { try { elementBuilder.addModule(module.getName(), module.getSlot(), PatchUtils.getAbsentModuleContentHash(module));
if (cp1Type.equals(ModificationType.ADD)) { if (cp2Type.equals(ModificationType.ADD)) { throw new PatchingException("Patch " + cp2.getPatchId() + " adds " + cp1Mod.getItem().getRelativePath() + " already added by patch " + cp1.getPatchId()); if (cp2Type.equals(ModificationType.MODIFY)) { modType = ModificationType.ADD; } else { // remove cancels add } else if (cp1Type.equals(ModificationType.REMOVE)) { if (cp2Type.equals(ModificationType.REMOVE)) { throw new PatchingException("Patch " + cp2.getPatchId() + " removes " + cp1Mod.getItem().getRelativePath() + " already removed by patch " + cp1.getPatchId()); if (cp2Type.equals(ModificationType.ADD)) { throw new PatchingException("Patch " + cp2.getPatchId() + " adds " + cp1Mod.getItem().getRelativePath() + " modified by patch " + cp1.getPatchId()); if (cp2Type.equals(ModificationType.REMOVE)) { modType = ModificationType.REMOVE; } else { if (ModificationType.ADD.equals(modType)) { final ContentItem cp2Item = cp2Mod.getItem(); if (cp2Item.getContentType().equals(ContentType.MODULE)) { final ModuleItem module = (ModuleItem) cp2Item; if(cp2Type.equals(ModificationType.REMOVE)) { try { elementBuilder.addModule(module.getName(), module.getSlot(), PatchUtils.getAbsentModuleContentHash(module));
protected Patch generateCP(final String currentCP, final String nextCP, ModificationType type) { final PatchBuilder patchBuilder = PatchBuilder.create().setPatchId(nextCP).setDescription(nextCP + " description"); patchBuilder.upgradeIdentity("identity", currentCP, nextCP); final PatchElementBuilder elementBuilder = patchBuilder.upgradeElement("base-" + nextCP, "base", false); if(ModificationType.ADD.equals(type)) { elementBuilder.addModule("org.jboss.test", "main", moduleHash(nextCP)) .addBundle("org.jboss.test", "main", bundleHash(nextCP)) .addFile("test.txt", Arrays.asList(new String[]{"org","jboss","test"}), miscHash(nextCP), false); } else if(ModificationType.MODIFY.equals(type)) { elementBuilder.modifyModule("org.jboss.test", "main", moduleHash(currentCP), moduleHash(nextCP)) .modifyBundle("org.jboss.test", "main", bundleHash(currentCP), bundleHash(nextCP)) .modifyFile("test.txt", Arrays.asList(new String[]{"org","jboss","test"}), miscHash(currentCP), miscHash(nextCP), false); } else { elementBuilder.removeModule("org.jboss.test", "main", moduleHash(currentCP)) .removeBundle("org.jboss.test", "main", bundleHash(currentCP)) .removeFile("test.txt", Arrays.asList(new String[] { "org", "jboss", "test" }), miscHash(currentCP), false); } return patchBuilder.build(); }