/** * Create an offline local patch tool. * * @param jbossHome the distribution root * @param moduleRoots the module roots * @param bundleRoots the bundle roots * @return the patch tool * @throws IOException */ public static PatchTool createLocalTool(final File jbossHome, final List<File> moduleRoots, final List<File> bundleRoots) throws IOException { final File[] resolvedPath = resolveLayeredModulePath(moduleRoots); // Resolve the patched module root for the module loader final ModuleLoader loader = new LocalModuleLoader(resolvedPath); final ProductConfig config = ProductConfig.fromFilesystemSlot(loader, jbossHome.getAbsolutePath(), Collections.emptyMap()); final InstallationManager manager = InstallationManager.load(jbossHome, moduleRoots, bundleRoots, config); return create(manager); }
/** * Create a content verification policy from a dmr model * * @param operation the model node * @return the policy */ public static ContentVerificationPolicy create(final ModelNode operation) { final PatchTool.ContentPolicyBuilder builder = policyBuilder(); final boolean overrideModules = operation.get(Constants.OVERRIDE_MODULES).asBoolean(false); if(overrideModules) { builder.ignoreModuleChanges(); } final boolean overrideAll = operation.get(Constants.OVERRIDE_ALL).asBoolean(false); if(overrideAll) { builder.overrideAll(); } if(operation.hasDefined(Constants.OVERRIDE)) { final ModelNode overrides = operation.get(Constants.OVERRIDE); for(final ModelNode override : overrides.asList()) { builder.overrideItem(override.asString()); } } if(operation.hasDefined(Constants.PRESERVE)) { final ModelNode preserves = operation.get(Constants.PRESERVE); for(final ModelNode preserve : preserves.asList()) { builder.preserveItem(preserve.asString()); } } return builder.createPolicy(); }
LayersConfig layersConfig = getLayersConfig(file); break; loadOverlays(layer, layerFiles); for (File addOn : addOns) { if (addOn.isDirectory()) { loadOverlays(addOn, layeredPath);
final PatchTool patchTool = PatchTool.Factory.create(mgr); final PatchingResult result = patchTool.applyPatch(multiPatch, ContentVerificationPolicy.STRICT); result.commit();
LayersConfig layersConfig = getLayersConfig(file); break; loadOverlays(layer, layerFiles); for (File addOn : addOns) { if (addOn.isDirectory()) { loadOverlays(addOn, layeredPath);
final PatchTool patchTool = PatchTool.Factory.create(mgr); final PatchingResult result = patchTool.applyPatch(multiPatch, ContentVerificationPolicy.STRICT); result.rollback();
final PatchTool patchTool = PatchTool.Factory.create(mgr); final PatchingResult result = patchTool.applyPatch(multiPatch, ContentVerificationPolicy.STRICT); result.commit();
final PatchTool patchTool = PatchTool.Factory.create(mgr); try { patchTool.applyPatch(multiPatch, ContentVerificationPolicy.STRICT);
/** * Create a content verification policy from a dmr model * * @param operation the model node * @return the policy */ public static ContentVerificationPolicy create(final ModelNode operation) { final PatchTool.ContentPolicyBuilder builder = policyBuilder(); final boolean overrideModules = operation.get(Constants.OVERRIDE_MODULES).asBoolean(false); if(overrideModules) { builder.ignoreModuleChanges(); } final boolean overrideAll = operation.get(Constants.OVERRIDE_ALL).asBoolean(false); if(overrideAll) { builder.overrideAll(); } if(operation.hasDefined(Constants.OVERRIDE)) { final ModelNode overrides = operation.get(Constants.OVERRIDE); for(final ModelNode override : overrides.asList()) { builder.overrideItem(override.asString()); } } if(operation.hasDefined(Constants.PRESERVE)) { final ModelNode preserves = operation.get(Constants.PRESERVE); for(final ModelNode preserve : preserves.asList()) { builder.preserveItem(preserve.asString()); } } return builder.createPolicy(); }
protected PatchingResult apply(final PatchingTestStepBuilder builder, final ContentVerificationPolicy verificationPolicy, final PatchStepAssertions assertions) throws PatchingException { final Patch patch = builder.build(); final File installation = new File(tempDir, JBOSS_INSTALLATION); try { assertions.before(installation, patch, installationManager); } catch (IOException e) { throw new PatchingException(e); } // Write patch writePatch(builder.getPatchDir(), patch); // Create the patch tool and apply the patch final PatchTool patchTool = PatchTool.Factory.create(installationManager); final PatchingResult result = patchTool.applyPatch(builder.getPatchDir(), verificationPolicy); result.commit(); final InstalledIdentity identity = ((InstallationManagerImpl)installationManager).getInstalledIdentity(patch.getIdentity().getName(), null); Assert.assertTrue(identity.getAllInstalledPatches().contains(patch.getPatchId())); try { assertions.after(installation, patch, installationManager); } catch (IOException e) { throw new PatchingException(e); } return result; }
protected PatchingResult rollback(final PatchingTestStepBuilder builder, final ContentVerificationPolicy verificationPolicy, final PatchStepAssertions assertions, boolean rollbackTo) throws PatchingException { final Patch patch = builder.build(); final File installation = new File(tempDir, JBOSS_INSTALLATION); try { assertions.before(installation, patch, installationManager); } catch (IOException e) { throw new PatchingException(e); } final String patchId = patch.getPatchId(); final PatchTool patchTool = PatchTool.Factory.create(installationManager); final PatchingResult result = patchTool.rollback(patchId, verificationPolicy, rollbackTo, false); result.commit(); final InstalledIdentity identity = installationManager.getInstalledIdentity(patch.getIdentity().getName(), null); Assert.assertFalse(identity.getAllInstalledPatches().contains(patch.getPatchId())); try { assertions.after(installation, patch, installationManager); } catch (IOException e) { throw new PatchingException(e); } return result; }
/** * Create an offline local patch tool. * * @param jbossHome the distribution root * @param moduleRoots the module roots * @param bundleRoots the bundle roots * @return the patch tool * @throws IOException */ public static PatchTool createLocalTool(final File jbossHome, final List<File> moduleRoots, final List<File> bundleRoots) throws IOException { final File[] resolvedPath = resolveLayeredModulePath(moduleRoots); // Resolve the patched module root for the module loader final ModuleLoader loader = new LocalModuleLoader(resolvedPath); final ProductConfig config = ProductConfig.fromFilesystemSlot(loader, jbossHome.getAbsolutePath(), Collections.emptyMap()); final InstallationManager manager = InstallationManager.load(jbossHome, moduleRoots, bundleRoots, config); return create(manager); }
@Test public void testOverrideModules() throws Exception { testModuleConflicts(policyBuilder().ignoreModuleChanges().createPolicy()); }
/** * Create a local target. * * @param jbossHome the jboss home * @param moduleRoots the module roots * @param bundlesRoots the bundle roots * @return the local target * @throws IOException */ public static final PatchOperationTarget createLocal(final File jbossHome, List<File> moduleRoots, List<File> bundlesRoots) throws IOException { final PatchTool tool = PatchTool.Factory.createLocalTool(jbossHome, moduleRoots, bundlesRoots); return new LocalPatchOperationTarget(tool); }