@Override PatchElementBuilder modifyLayer(String name, boolean addOn) { final PatchElementConfigBuilder config = PatchConfigBuilder.this.elements.get(name); if (config == null) { return null; //throw processingError("missing patch-config for layer %s", name); } final PatchElementBuilder builder; if (config.getPatchType() == null) { config.setPatchType(patchType); } if (patchType == Patch.PatchType.CUMULATIVE) { builder = upgradeElement(config.getPatchId(), name, addOn); } else { builder = oneOffPatchElement(config.getPatchId(), name, addOn); } if (config.getDescription() != null) { builder.setDescription(config.getDescription()); } builder.setContentItemFilter(config); return builder; } };
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(); }
public PatchElementBuilder upgradeElement(final String patchId, final String layerName, final boolean addOn) { if (!Patch.PATCH_NAME_PATTERN.matcher(patchId).matches()) { throw PatchLogger.ROOT_LOGGER.illegalPatchName(patchId); } final PatchElementBuilder builder = new PatchElementBuilder(patchId, layerName, addOn, this); builder.upgrade(); addElement(patchId, builder); return builder; }
public PatchElementBuilder oneOffPatchElement(final String patchId, final String layerName, final boolean addOn) { if (!Patch.PATCH_NAME_PATTERN.matcher(patchId).matches()) { throw PatchLogger.ROOT_LOGGER.illegalPatchName(patchId); } final PatchElementBuilder builder = new PatchElementBuilder(patchId, layerName, addOn, this); builder.oneOffPatch(); addElement(patchId, builder); return builder; }
elementBuilder.removeBundle(o.getName(), o.getSlot(), o.getMetadataHash()); } else { elementBuilder.removeModule(o.getName(), o.getSlot(), o.getMetadataHash()); elementBuilder.modifyBundle(n.getName(), n.getSlot(), o.getMetadataHash(), n.getMetadataHash()); } else { elementBuilder.modifyModule(n.getName(), n.getSlot(), o.getMetadataHash(), n.getMetadataHash()); throw processingError("missing patch-config for layer/add-on %s", layer); elementBuilder.modifyModule(n.getName(), n.getSlot(), o.getMetadataHash(), n.getMetadataHash()); elementBuilder.addBundle(item.getName(), item.getSlot(), item.getMetadataHash()); } else { elementBuilder.addModule(item.getName(), item.getSlot(), item.getMetadataHash());
.getParent() .upgradeElement(baseCP1ID, BASE, false) .addContentModification(cp1BaseModuleAdded) .addContentModification(cp1BaseModule2Added) .getParent() .upgradeElement(layer1CP1ID, "layer1", false) .addContentModification(cp1Layer1ModuleAdded) .getParent() .upgradeElement(layer2CP1ID, "layer2", false) .addContentModification(cp1Layer2ModuleAdded) .addContentModification(cp1Layer2Module2Added) .getParent() .addContentModification(cp1StandaloneModified) .addContentModification(cp1AddedByCP1Added)
.addContentModification(fileModified) .oneOffPatchElement(patchElementId, "base", false) .setDescription(oneOffElementDescr) .addContentModification(moduleModified) .getParent() .build(); .addContentModification(fileModified2) .upgradeElement(patchElementId2, "base", false) .setDescription(cpElementDescr) .addContentModification(moduleModified2) .getParent() .build();
} else { final PatchElementBuilder elementBuilder = builder.upgradeElement(cp2El.getId(), provider.getName(), provider.isAddOn()).setDescription(cp2El.getDescription());
@Override protected PatchElementTestStepBuilder internalAddModification(ContentModification modification) { builder.addContentModification(modification); return returnThis(); }
public PatchElementBuilder addElement(final String patchId, final String layerName, final boolean addOn) { if (!Patch.PATCH_NAME_PATTERN.matcher(patchId).matches()) { throw PatchLogger.ROOT_LOGGER.illegalPatchName(patchId); } final PatchElementBuilder builder = new PatchElementBuilder(patchId, layerName, addOn, this); //builder.cumulativePatch(); addElement(patchId, builder); return builder; }
.getParent() .upgradeElement(baseCP2ID, BASE, false) .addContentModification(cp2BaseModuleModified) .addContentModification(cp2BaseModule2Removed) .getParent() .upgradeElement(layer2CP2ID, "layer2", false) .addContentModification(cp2Layer2ModuleRemoved) .addContentModification(cp2Layer2Module3Added) .getParent() .addContentModification(cp2StandaloneModified) .addContentModification(cp2AddedByCp2Added)
.addContentModification(fileModified) .oneOffPatchElement(patchElementId, "base", false) .setDescription(oneOffElementDescr) .addContentModification(moduleModified) .getParent() .build(); .addContentModification(fileModified2) .upgradeElement(patchElementId2, "base", false) .setDescription(cpElementDescr) .addContentModification(moduleModified2) .getParent() .build();
} else { final PatchElementBuilder elementBuilder = builder.upgradeElement(cp2El.getId(), provider.getName(), provider.isAddOn()).setDescription(cp2El.getDescription());
public PatchElementBuilder oneOffPatchElement(final String patchId, final String layerName, final boolean addOn) { if (!Patch.PATCH_NAME_PATTERN.matcher(patchId).matches()) { throw PatchLogger.ROOT_LOGGER.illegalPatchName(patchId); } final PatchElementBuilder builder = new PatchElementBuilder(patchId, layerName, addOn, this); builder.oneOffPatch(); addElement(patchId, builder); return builder; }
@Test public void testOneOffPatch() throws Exception { // build a one-off patch for the base installation // with 1 added module String patchID = randomString(); String layerPatchID = randomString(); File patchDir = mkdir(tempDir, patchID); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchID, moduleName); InstalledIdentity installedIdentity = loadInstalledIdentity(); final PatchBuilder builder = PatchBuilder.create(); builder .setPatchId(patchID) .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion()) .getParent() .oneOffPatchElement(layerPatchID, BASE, false) .addContentModification(moduleAdded); Patch patch = builder.build(); checkApplyPatchAndRollbackRestoresBackupConfiguration(patchDir, patch); }
public PatchElementBuilder addElement(final String patchId, final String layerName, final boolean addOn) { if (!Patch.PATCH_NAME_PATTERN.matcher(patchId).matches()) { throw PatchLogger.ROOT_LOGGER.illegalPatchName(patchId); } final PatchElementBuilder builder = new PatchElementBuilder(patchId, layerName, addOn, this); //builder.cumulativePatch(); addElement(patchId, builder); return builder; }
private void prepareCP3(final InstalledIdentity installedIdentity) throws IOException, Exception { final String cp3ID = "CP3"; final File cp3Dir = mkdir(tempDir, cp3ID); cp3StandaloneModified = ContentModificationUtils.modifyMisc(cp3Dir, cp3ID, "updated by cp3", standaloneSh, "bin", standaloneSh.getName()); cp3BaseModuleModified = ContentModificationUtils.modifyModule(cp3Dir, baseCP3ID, moduleName, cp2BaseModuleModified.getItem().getContentHash(), "cp3 content"); // cp3BaseModule2Added = ContentModificationUtils.addModule(cp3Dir, baseCP3ID, moduleName + "2"); the patchgen tool // would generate an update instead final File absentModuleXml = IoUtils.newFile(installedIdentity.getLayer("base").loadTargetInfo() .getDirectoryStructure().getModulePatchDirectory(baseCP2ID), "org", "jboss", "test2", "main", "module.xml"); cp3BaseModule2Added = ContentModificationUtils.modifyModule(cp3Dir, baseCP3ID, moduleName + "2", HashUtils.hashFile(absentModuleXml), "cp3 content"); final ContentModification cp3AddedByCP1RemovedByCP3Removed = ContentModificationUtils.removeMisc(addedByCP1RemovedByCP3, "bin", addedByCP1RemovedByCP3.getName()); cp3 = PatchBuilder.create() .setPatchId(cp3ID) .setDescription(randomString()) .upgradeIdentity(installedIdentity.getIdentity().getName(), productConfig.getProductVersion() + "_CP2", productConfig.getProductVersion() + "_CP3") .getParent() .upgradeElement(baseCP3ID, BASE, false) .addContentModification(cp3BaseModuleModified) .addContentModification(cp3BaseModule2Added) .getParent() .addContentModification(cp3StandaloneModified) .addContentModification(cp3AddedByCP1RemovedByCP3Removed) .build(); createPatchXMLFile(cp3Dir, cp3); cp3Zip = createZippedPatchFile(cp3Dir, cp3ID); }
public PatchElementBuilder upgradeElement(final String patchId, final String layerName, final boolean addOn) { if (!Patch.PATCH_NAME_PATTERN.matcher(patchId).matches()) { throw PatchLogger.ROOT_LOGGER.illegalPatchName(patchId); } final PatchElementBuilder builder = new PatchElementBuilder(patchId, layerName, addOn, this); builder.upgrade(); addElement(patchId, builder); return builder; }
@Test public void testCumulativePatch() throws Exception { // build a cumulative patch for the base installation // with 1 added module String patchID = randomString(); String layerPatchID = randomString(); File patchDir = mkdir(tempDir, patchID); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchID, moduleName); InstalledIdentity installedIdentity = loadInstalledIdentity(); final PatchBuilder builder = PatchBuilder.create(); builder .setPatchId(patchID) .setDescription(randomString()) .upgradeIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion(), productConfig.getProductVersion() + "-CP1") .getParent() .upgradeElement(layerPatchID, BASE, false) .addContentModification(moduleAdded); Patch patch = builder.build(); checkApplyPatchAndRollbackRestoresBackupConfiguration(patchDir, patch); }
.getParent() .oneOffPatchElement(layerPatchId, layerName, false) .addContentModification(moduleAdded) .getParent(); try { patchBuilder.oneOffPatchElement(layerPatchId, layer2Name, false);