public PatchHistoryIterator iterator() { final List<String> patches = new ArrayList<>(identity.getAllInstalledPatches()); Collections.reverse(patches); final int size = patches.size();
public PatchHistoryIterator iterator() { final List<String> patches = new ArrayList<>(identity.getAllInstalledPatches()); Collections.reverse(patches); final int size = patches.size();
final InstallationModificationImpl.InstallationState state = load(this); return new InstallationModificationImpl(identityInfo, identity.getName(), identity.getVersion(), this.getAllInstalledPatches(), state) {
final InstallationModificationImpl.InstallationState state = load(this); return new InstallationModificationImpl(identityInfo, identity.getName(), identity.getVersion(), this.getAllInstalledPatches(), state) {
if (identity.getAllInstalledPatches().contains(entry.getPatchId())) { alreadyApplied = true; break;
if (identity.getAllInstalledPatches().contains(entry.getPatchId())) { alreadyApplied = true; break;
private void assertNotPatched() throws Exception { assertFileExists(standaloneSh); assertFileContent(originalStandaloneHash, standaloneSh); assertFileDoesNotExist(addedByCP1); assertFileDoesNotExist(addedByCP1RemovedByCP3); assertFileDoesNotExist(addedByCP2); final InstalledIdentity installedIdentity = loadInstalledIdentity(); Assert.assertTrue(installedIdentity.getAllInstalledPatches().isEmpty()); }
@Override public PatchingResult rollback(final String streamName, final String patchId, final ContentVerificationPolicy contentPolicy, final boolean rollbackTo, final boolean resetConfiguration) throws PatchingException { InstalledIdentity targetIdentity = null; if (streamName == null) { for (InstalledIdentity identity : manager.getInstalledIdentities()) { if (identity.getAllInstalledPatches().contains(patchId)) { if (targetIdentity != null) { throw new PatchingException(PatchLogger.ROOT_LOGGER.patchIdFoundInMoreThanOneStream(patchId, targetIdentity.getIdentity().getName(), identity.getIdentity().getName())); } targetIdentity = identity; } } if(targetIdentity == null) { throw PatchLogger.ROOT_LOGGER.patchNotFoundInHistory(patchId); } } else { targetIdentity = manager.getInstalledIdentity(streamName, null); } // Rollback the patch final InstallationManager.InstallationModification modification = targetIdentity.modifyInstallation(runner); try { return runner.rollbackPatch(patchId, contentPolicy, rollbackTo, resetConfiguration, modification); } catch (Exception e) { modification.cancel(); throw rethrowException(e); } }
@Override public PatchingResult rollback(final String streamName, final String patchId, final ContentVerificationPolicy contentPolicy, final boolean rollbackTo, final boolean resetConfiguration) throws PatchingException { InstalledIdentity targetIdentity = null; if (streamName == null) { for (InstalledIdentity identity : manager.getInstalledIdentities()) { if (identity.getAllInstalledPatches().contains(patchId)) { if (targetIdentity != null) { throw new PatchingException(PatchLogger.ROOT_LOGGER.patchIdFoundInMoreThanOneStream(patchId, targetIdentity.getIdentity().getName(), identity.getIdentity().getName())); } targetIdentity = identity; } } if(targetIdentity == null) { throw PatchLogger.ROOT_LOGGER.patchNotFoundInHistory(patchId); } } else { targetIdentity = manager.getInstalledIdentity(streamName, null); } // Rollback the patch final InstallationManager.InstallationModification modification = targetIdentity.modifyInstallation(runner); try { return runner.rollbackPatch(patchId, contentPolicy, rollbackTo, resetConfiguration, modification); } catch (Exception e) { modification.cancel(); throw rethrowException(e); } }
protected static InstalledIdentity copy(InstalledIdentity original) throws IOException { final InstalledIdentityImpl copy = new InstalledIdentityImpl(original.getIdentity(), original.getAllInstalledPatches(), original.getInstalledImage()); for (final Layer layer : original.getLayers()) { copy.putLayer(layer.getName(), new LayerInfo(layer.getName(), layer.loadTargetInfo(), layer.getDirectoryStructure())); } for (final AddOn addOn : original.getAddOns()) { copy.putAddOn(addOn.getName(), new LayerInfo(addOn.getName(), addOn.loadTargetInfo(), addOn.getDirectoryStructure())); } return copy; }
protected static InstalledIdentity copy(InstalledIdentity original) throws IOException { final InstalledIdentityImpl copy = new InstalledIdentityImpl(original.getIdentity(), original.getAllInstalledPatches(), original.getInstalledImage()); for (final Layer layer : original.getLayers()) { copy.putLayer(layer.getName(), new LayerInfo(layer.getName(), layer.loadTargetInfo(), layer.getDirectoryStructure())); } for (final AddOn addOn : original.getAddOns()) { copy.putAddOn(addOn.getName(), new LayerInfo(addOn.getName(), addOn.loadTargetInfo(), addOn.getDirectoryStructure())); } return copy; }
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; }
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; }
Assert.assertEquals(Arrays.asList(new String[] {"CP1", "CP2", "CP3", "CP4", "CP5"}), installedIdentity.getAllInstalledPatches());