public static void registerRootResource(Resource rootResource, ProductConfig cfg) { ModelNode model = rootResource.getModel(); model.get(ModelDescriptionConstants.MANAGEMENT_MAJOR_VERSION).set(Version.MANAGEMENT_MAJOR_VERSION); model.get(ModelDescriptionConstants.MANAGEMENT_MINOR_VERSION).set(Version.MANAGEMENT_MINOR_VERSION); model.get(ModelDescriptionConstants.MANAGEMENT_MICRO_VERSION).set(Version.MANAGEMENT_MICRO_VERSION); model.get(ModelDescriptionConstants.RELEASE_VERSION).set(Version.AS_VERSION); model.get(ModelDescriptionConstants.RELEASE_CODENAME).set(Version.AS_RELEASE_CODENAME); if (cfg != null) { if (cfg.getProductVersion() != null) { model.get(ModelDescriptionConstants.PRODUCT_VERSION).set(cfg.getProductVersion()); } if (cfg.getProductName() != null) { model.get(ModelDescriptionConstants.PRODUCT_NAME).set(cfg.getProductName()); } } } }
public String getProductName() { if (serverEnvironment.getProductConfig() != null && serverEnvironment.getProductConfig().getProductName() != null) { return serverEnvironment.getProductConfig().getProductName(); } return null; } };
public String getProductName() { if (serverEnvironment.getProductConfig() != null && serverEnvironment.getProductConfig().getProductName() != null) { return serverEnvironment.getProductConfig().getProductName(); } return null; } };
public static void registerRootResource(Resource rootResource, ProductConfig cfg) { ModelNode model = rootResource.getModel(); model.get(ModelDescriptionConstants.MANAGEMENT_MAJOR_VERSION).set(Version.MANAGEMENT_MAJOR_VERSION); model.get(ModelDescriptionConstants.MANAGEMENT_MINOR_VERSION).set(Version.MANAGEMENT_MINOR_VERSION); model.get(ModelDescriptionConstants.MANAGEMENT_MICRO_VERSION).set(Version.MANAGEMENT_MICRO_VERSION); model.get(ModelDescriptionConstants.RELEASE_VERSION).set(Version.AS_VERSION); model.get(ModelDescriptionConstants.RELEASE_CODENAME).set(Version.AS_RELEASE_CODENAME); if (cfg != null) { if (cfg.getProductVersion() != null) { model.get(ModelDescriptionConstants.PRODUCT_VERSION).set(cfg.getProductVersion()); } if (cfg.getProductName() != null) { model.get(ModelDescriptionConstants.PRODUCT_NAME).set(cfg.getProductName()); } } } }
public String getProductName() { if (serverEnvironment.getProductConfig() != null && serverEnvironment.getProductConfig().getProductName() != null) { return serverEnvironment.getProductConfig().getProductName(); } return null; } };
@Override public String getProductName() { if (environment.getProductConfig() != null && environment.getProductConfig().getProductName() != null) { return environment.getProductConfig().getProductName(); } return null; } };
public static void registerRootResource(Resource rootResource, ProductConfig cfg) { ModelNode model = rootResource.getModel(); model.get(ModelDescriptionConstants.MANAGEMENT_MAJOR_VERSION).set(Version.MANAGEMENT_MAJOR_VERSION); model.get(ModelDescriptionConstants.MANAGEMENT_MINOR_VERSION).set(Version.MANAGEMENT_MINOR_VERSION); model.get(ModelDescriptionConstants.MANAGEMENT_MICRO_VERSION).set(Version.MANAGEMENT_MICRO_VERSION); model.get(ModelDescriptionConstants.RELEASE_VERSION).set(Version.AS_VERSION); model.get(ModelDescriptionConstants.RELEASE_CODENAME).set(Version.AS_RELEASE_CODENAME); if (cfg != null) { if (cfg.getProductVersion() != null) { model.get(ModelDescriptionConstants.PRODUCT_VERSION).set(cfg.getProductVersion()); } if (cfg.getProductName() != null) { model.get(ModelDescriptionConstants.PRODUCT_NAME).set(cfg.getProductName()); } } } }
public static void registerRootResource(Resource rootResource, ProductConfig cfg) { ModelNode model = rootResource.getModel(); model.get(ModelDescriptionConstants.MANAGEMENT_MAJOR_VERSION).set(Version.MANAGEMENT_MAJOR_VERSION); model.get(ModelDescriptionConstants.MANAGEMENT_MINOR_VERSION).set(Version.MANAGEMENT_MINOR_VERSION); model.get(ModelDescriptionConstants.MANAGEMENT_MICRO_VERSION).set(Version.MANAGEMENT_MICRO_VERSION); model.get(ModelDescriptionConstants.RELEASE_VERSION).set(Version.AS_VERSION); model.get(ModelDescriptionConstants.RELEASE_CODENAME).set(Version.AS_RELEASE_CODENAME); if (cfg != null) { if (cfg.getProductVersion() != null) { model.get(ModelDescriptionConstants.PRODUCT_VERSION).set(cfg.getProductVersion()); } if (cfg.getProductName() != null) { model.get(ModelDescriptionConstants.PRODUCT_NAME).set(cfg.getProductName()); } } } }
@Override public String getProductName() { if (environment.getProductConfig() != null && environment.getProductConfig().getProductName() != null) { return environment.getProductConfig().getProductName(); } return null; } };
info.get(MANAGEMENT_MINOR_VERSION).set(Version.MANAGEMENT_MINOR_VERSION); info.get(MANAGEMENT_MICRO_VERSION).set(Version.MANAGEMENT_MICRO_VERSION); final String productName = productConfig.getProductName(); final String productVersion = productConfig.getProductVersion(); if(productName != null) {
info.get(MANAGEMENT_MINOR_VERSION).set(Version.MANAGEMENT_MINOR_VERSION); info.get(MANAGEMENT_MICRO_VERSION).set(Version.MANAGEMENT_MICRO_VERSION); final String productName = productConfig.getProductName(); final String productVersion = productConfig.getProductVersion(); if(productName != null) {
@Test public void testAddDirectory() throws Exception { final ContentItem item = new MiscContentItem("dir", new String[] { "test"}, NO_CONTENT, true, false); final ContentModification addDir = new ContentModification(item, NO_CONTENT, ModificationType.ADD); final String patchID = randomString(); final Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(addDir) .build(); // create the patch final File patchDir = mkdir(tempDir, patch.getPatchId()); createPatchXMLFile(patchDir, patch); final File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); // Apply PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); final File test = new File(env.getInstalledImage().getJbossHome(), "test"); assertTrue(test.exists()); assertTrue(test.isDirectory()); final File dir = new File(test, "dir"); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); rollback(patchID); }
@Test public void installedLayer() throws Exception { String layerName = randomString(); installLayers(layerName); TestUtils.tree(env.getInstalledImage().getJbossHome()); InstalledIdentity installedIdentity = loadInstalledIdentity(); Identity identity = installedIdentity.getIdentity(); assertEquals(productConfig.getProductName(), identity.getName()); assertEquals(productConfig.resolveVersion(), identity.getVersion()); List<Layer> layers = installedIdentity.getLayers(); assertEquals(2, layers.size()); Layer layer = layers.get(0); assertEquals(layerName, layer.getName()); assertEquals(BASE, layers.get(1).getName()); // base layer is always appended PatchableTarget.TargetInfo targetInfo = layer.loadTargetInfo(); assertEquals(BASE, targetInfo.getCumulativePatchID()); assertTrue(targetInfo.getPatchIDs().isEmpty()); DirectoryStructure directoryStructure = targetInfo.getDirectoryStructure(); assertEquals(newFile(env.getModuleRoot(), "system", "layers", layerName), directoryStructure.getModuleRoot()); assertNull(directoryStructure.getBundleRepositoryRoot()); }
@Before public void setUp() throws Exception{ // with a file in it File binDir = mkdir(env.getInstalledImage().getJbossHome(), "bin"); String fileName = "standalone.sh"; removedFile = touch(binDir, fileName); dump(removedFile, "modified script to run standalone AS"); expectedModifiedHash = hashFile(removedFile); // let's simulate that the file has been modified by the users by using a hash that is not the file checksum byte[] unmodifiedHash = randomString().getBytes(StandardCharsets.UTF_8); String patchID = randomString(); File patchDir = mkdir(tempDir, patchID); File updatedFile = touch(patchDir, "misc", "bin", fileName); dump(updatedFile, "updated script"); // build a one-off patch for the base installation // with 1 removed file fileRemoved = new ContentModification(new MiscContentItem(fileName, new String[] { "bin" }, NO_CONTENT), unmodifiedHash, REMOVE); patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileRemoved) .build(); // create the patch createPatchXMLFile(patchDir, patch); zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); runner = newPatchTool(); }
@Test public void testAddModule() throws Exception { // build a one-off patch for the base installation // with 1 added module String patchID = randomString(); File patchDir = mkdir(tempDir, patchID); String baseLayerPatchID = randomString(); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, baseLayerPatchID, moduleName); Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .oneOffPatchElement(baseLayerPatchID, BASE, false) .addContentModification(moduleAdded) .getParent() .build(); createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patchID); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity(); File modulePatchDirectory = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(baseLayerPatchID); assertDirExists(modulePatchDirectory); assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash()); }
@Test public void testApplyOneOffPatch() throws Exception { // build a one-off patch for the base installation // with 1 added module String oneOffPatchID = randomString(); String oneOffLayerPatchID = randomString(); File oneOffPatchDir = mkdir(tempDir, oneOffPatchID); String moduleName = randomString(); ContentModification moduleAdded = ContentModificationUtils.addModule(oneOffPatchDir, oneOffLayerPatchID, moduleName); Patch oneOffPatch = PatchBuilder.create() .setPatchId(oneOffPatchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .oneOffPatchElement(oneOffLayerPatchID, BASE, false) .addContentModification(moduleAdded) .getParent() .build(); createPatchXMLFile(oneOffPatchDir, oneOffPatch); File zippedPatch = createZippedPatchFile(oneOffPatchDir, oneOffPatchID); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, oneOffPatch); InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity(); File modulePatchDirectory = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(oneOffLayerPatchID); assertDirExists(modulePatchDirectory); assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash()); }
@Test public void testRemoveModule() throws Exception { String moduleName = randomString(); // create an empty module in the AS7 installation File baseModuleDir = newFile(env.getInstalledImage().getModulesDir(), SYSTEM, LAYERS, BASE); File moduleDir = createModule0(baseModuleDir, moduleName); // build a one-off patch for the installation base layer // with 1 module removed String baseLayerPatchID = randomString(); Patch patch = PatchBuilder.create() .setPatchId(randomString()) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .oneOffPatchElement(baseLayerPatchID, BASE, false) .addContentModification(ContentModificationUtils.removeModule(moduleDir)) .getParent() .build(); // create the patch File patchDir = mkdir(tempDir, patch.getPatchId()); createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); InstalledIdentity installedIdentity = loadInstalledIdentity(); File modulesPatchDir = installedIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(baseLayerPatchID); assertDirExists(modulesPatchDir); assertDefinedAbsentModule(modulesPatchDir, moduleName); }
@Test public void testAddFile() throws Exception { // build a one-off patch for the base installation // with 1 added file String patchID = randomString(); File patchDir = mkdir(tempDir, patchID); ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh"); Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileAdded) .build(); assertFileDoesNotExist(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); assertFileExists(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); }
@Test public void testRemoveFile() throws Exception { // start from a base installation // with a file in it String fileName = "standalone.sh"; File standaloneShellFile = touch(env.getInstalledImage().getJbossHome(), "bin", fileName ); dump(standaloneShellFile, "original script to run standalone AS7"); // build a one-off patch for the base installation // with 1 removed file ContentModification fileRemoved = ContentModificationUtils.removeMisc(standaloneShellFile, "bin", fileName); Patch patch = PatchBuilder.create() .setPatchId(randomString()) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileRemoved) .build(); // create the patch File patchDir = mkdir(tempDir, patch.getPatchId()); createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); /// file has been removed from the AS7 installation assertFileDoesNotExist(standaloneShellFile); // but it's been backed up assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "misc", "bin", fileName); }
.setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileModified)