@Override void handle(ModelNode result, Identity info) throws IOException { result.set(info.loadTargetInfo().getCumulativePatchID()); } });
@Override void handle(ModelNode result, Identity info) throws IOException { result.set(info.loadTargetInfo().getCumulativePatchID()); } });
@Override void handle(ModelNode result, Identity info) throws IOException { result.setEmptyList(); for (final String id : info.loadTargetInfo().getPatchIDs()) { result.add(id); } } });
@Override void handle(ModelNode result, Identity info) throws IOException { result.setEmptyList(); for (final String id : info.loadTargetInfo().getPatchIDs()) { result.add(id); } } });
@Override public boolean isValid(PatchingArtifactValidationContext context) { try { // Check the target state we are rolling back to final PatchableTarget.TargetInfo target = rollbackIdentity.getIdentity().loadTargetInfo(); final List<String> patches = target.getPatchIDs(); final String rollbackTo; if (patches.isEmpty()) { rollbackTo = target.getCumulativePatchID(); } else { rollbackTo = patches.get(0); } final String ref = reference.getNextPatchID(); if (rollbackTo.equals(ref)) { return true; } else if (ref == null && Constants.BASE.equals(rollbackTo)) { return true; } else { context.getErrorHandler().addInconsistent(PatchingArtifacts.ROLLBACK_TARGET, this); } } catch (IOException e) { context.getErrorHandler().addError(PatchingArtifacts.ROLLBACK_TARGET, this); } return false; }
@Override public boolean isValid(PatchingArtifactValidationContext context) { try { // Check the target state we are rolling back to final PatchableTarget.TargetInfo target = rollbackIdentity.getIdentity().loadTargetInfo(); final List<String> patches = target.getPatchIDs(); final String rollbackTo; if (patches.isEmpty()) { rollbackTo = target.getCumulativePatchID(); } else { rollbackTo = patches.get(0); } final String ref = reference.getNextPatchID(); if (rollbackTo.equals(ref)) { return true; } else if (ref == null && Constants.BASE.equals(rollbackTo)) { return true; } else { context.getErrorHandler().addInconsistent(PatchingArtifacts.ROLLBACK_TARGET, this); } } catch (IOException e) { context.getErrorHandler().addError(PatchingArtifacts.ROLLBACK_TARGET, this); } return false; }
@Override protected void execute(final OperationContext context, final ModelNode operation, final InstalledIdentity installedIdentity) throws OperationFailedException { final boolean excludeAgedOut = PatchResourceDefinition.EXCLUDE_AGEDOUT.resolveModelAttribute(context, operation).asBoolean(); try { final PatchableTarget.TargetInfo info = installedIdentity.getIdentity().loadTargetInfo(); final ModelNode result = PatchingHistory.Factory.getHistory(installedIdentity, info, excludeAgedOut); context.getResult().set(result); } catch (Throwable t) { PatchLogger.ROOT_LOGGER.debugf(t, "failed to get history"); throw PatchLogger.ROOT_LOGGER.failedToShowHistory(t); } } }
@Override protected void execute(final OperationContext context, final ModelNode operation, final InstalledIdentity installedIdentity) throws OperationFailedException { final boolean excludeAgedOut = PatchResourceDefinition.EXCLUDE_AGEDOUT.resolveModelAttribute(context, operation).asBoolean(); try { final PatchableTarget.TargetInfo info = installedIdentity.getIdentity().loadTargetInfo(); final ModelNode result = PatchingHistory.Factory.getHistory(installedIdentity, info, excludeAgedOut); context.getResult().set(result); } catch (Throwable t) { PatchLogger.ROOT_LOGGER.debugf(t, "failed to get history"); throw PatchLogger.ROOT_LOGGER.failedToShowHistory(t); } } }
@Override public ModelNode getHistory(boolean excludeAgedOut) throws PatchingException { try { return getHistory(installedIdentity.getIdentity().loadTargetInfo(), excludeAgedOut); } catch (IOException e) { throw new PatchingException(PatchLogger.ROOT_LOGGER.failedToLoadInfo(installedIdentity.getIdentity().getName()), e); } }
@Override public Iterator iterator(boolean excludeAgedOut) throws PatchingException { try { return iterator(installedIdentity.getIdentity().loadTargetInfo(), excludeAgedOut); } catch (IOException e) { throw new PatchingException(PatchLogger.ROOT_LOGGER.failedToLoadInfo(installedIdentity.getIdentity().getName()), e); } }
@Override public ModelNode getHistory(boolean excludeAgedOut) throws PatchingException { try { return getHistory(installedIdentity.getIdentity().loadTargetInfo(), excludeAgedOut); } catch (IOException e) { throw new PatchingException(PatchLogger.ROOT_LOGGER.failedToLoadInfo(installedIdentity.getIdentity().getName()), e); } }
@Override public Iterator iterator(boolean excludeAgedOut) throws PatchingException { try { return iterator(installedIdentity.getIdentity().loadTargetInfo(), excludeAgedOut); } catch (IOException e) { throw new PatchingException(PatchLogger.ROOT_LOGGER.failedToLoadInfo(installedIdentity.getIdentity().getName()), e); } }
@Override protected void execute(final OperationContext context, final ModelNode operation, final InstalledIdentity installedIdentity) throws OperationFailedException { String patchId = PatchResourceDefinition.PATCH_ID_OPTIONAL.resolveModelAttribute(context, operation).asStringOrNull(); assert patchId != null; // the overridden execute(OperationContext context, ModelNode operation) ensures not final boolean verbose = PatchResourceDefinition.VERBOSE.resolveModelAttribute(context, operation).asBoolean(); final PatchableTarget.TargetInfo info; try { info = installedIdentity.getIdentity().loadTargetInfo(); } catch (Exception e) { throw new OperationFailedException(PatchLogger.ROOT_LOGGER.failedToLoadInfo(installedIdentity.getIdentity().getName()), e); } final PatchingHistory.Iterator i = PatchingHistory.Factory.iterator(installedIdentity, info); final ModelNode result = patchIdInfo(context, patchId, verbose, i); if (result == null) { context.getFailureDescription().set(PatchLogger.ROOT_LOGGER.patchNotFoundInHistory(patchId).getLocalizedMessage()); } else { context.getResult().set(result); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); }
@Override protected void execute(final OperationContext context, final ModelNode operation, final InstalledIdentity installedIdentity) throws OperationFailedException { String patchId = PatchResourceDefinition.PATCH_ID_OPTIONAL.resolveModelAttribute(context, operation).asStringOrNull(); assert patchId != null; // the overridden execute(OperationContext context, ModelNode operation) ensures not final boolean verbose = PatchResourceDefinition.VERBOSE.resolveModelAttribute(context, operation).asBoolean(); final PatchableTarget.TargetInfo info; try { info = installedIdentity.getIdentity().loadTargetInfo(); } catch (Exception e) { throw new OperationFailedException(PatchLogger.ROOT_LOGGER.failedToLoadInfo(installedIdentity.getIdentity().getName()), e); } final PatchingHistory.Iterator i = PatchingHistory.Factory.iterator(installedIdentity, info); final ModelNode result = patchIdInfo(context, patchId, verbose, i); if (result == null) { context.getFailureDescription().set(PatchLogger.ROOT_LOGGER.patchNotFoundInHistory(patchId).getLocalizedMessage()); } else { context.getResult().set(result); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); }
public static void assertPatchHasBeenRolledBack(PatchingResult result, Identity expectedIdentity) throws IOException { assertEquals(expectedIdentity.getVersion(), result.getPatchInfo().getVersion()); assertEquals(expectedIdentity.loadTargetInfo().getCumulativePatchID(), result.getPatchInfo().getCumulativePatchID()); assertEquals(expectedIdentity.loadTargetInfo().getPatchIDs(), result.getPatchInfo().getPatchIDs()); }
@Override public PatchInfo getPatchInfo(String streamName) throws PatchingException { try { final InstalledIdentity installedIdentity = streamName == null ? manager.getDefaultIdentity() : manager.getInstalledIdentity(streamName, null); final PatchableTarget.TargetInfo info = installedIdentity.getIdentity().loadTargetInfo(); final VerbosePatchInfo.Builder infoBuilder = VerbosePatchInfo.builder() .setVersion(installedIdentity.getIdentity().getVersion()) .setCumulativePatchId(info.getCumulativePatchID()) .setPatchIds(info.getPatchIDs()); for(Layer layer : installedIdentity.getLayers()) { infoBuilder.addLayerInfo(layer.getName(), layer.loadTargetInfo()); } for(AddOn addon : installedIdentity.getAddOns()) { infoBuilder.addAddOnInfo(addon.getName(), addon.loadTargetInfo()); } return infoBuilder.build(); } catch (IOException e) { // why throw a rethrowException(e) ? throw new RuntimeException(e); } }
@Override public PatchInfo getPatchInfo(String streamName) throws PatchingException { try { final InstalledIdentity installedIdentity = streamName == null ? manager.getDefaultIdentity() : manager.getInstalledIdentity(streamName, null); final PatchableTarget.TargetInfo info = installedIdentity.getIdentity().loadTargetInfo(); final VerbosePatchInfo.Builder infoBuilder = VerbosePatchInfo.builder() .setVersion(installedIdentity.getIdentity().getVersion()) .setCumulativePatchId(info.getCumulativePatchID()) .setPatchIds(info.getPatchIDs()); for(Layer layer : installedIdentity.getLayers()) { infoBuilder.addLayerInfo(layer.getName(), layer.loadTargetInfo()); } for(AddOn addon : installedIdentity.getAddOns()) { infoBuilder.addAddOnInfo(addon.getName(), addon.loadTargetInfo()); } return infoBuilder.build(); } catch (IOException e) { // why throw a rethrowException(e) ? throw new RuntimeException(e); } }
PatchableTarget.TargetInfo identityInfo = installedIdentity.getIdentity().loadTargetInfo(); assertEquals(BASE, identityInfo.getCumulativePatchID()); assertTrue(identityInfo.getPatchIDs().isEmpty());
static void assertNotApplied(final Patch patch, InstallationManager manager) throws IOException { InstalledIdentity installedIdentity = null; try { installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), patch.getIdentity().getVersion()); } catch (PatchingException e) { Assert.fail(e.getLocalizedMessage()); } final PatchableTarget.TargetInfo identity = installedIdentity.getIdentity().loadTargetInfo(); assertNotApplied(patch.getIdentity().getPatchType(), patch.getPatchId(), identity); assertDoesNotExists(identity.getDirectoryStructure().getInstalledImage().getPatchHistoryDir(patch.getPatchId())); for (final PatchElement element : patch.getElements()) { final PatchElementProvider provider = element.getProvider(); final PatchableTarget target = provider.isAddOn() ? installedIdentity.getAddOn(provider.getName()) : installedIdentity.getLayer(provider.getName()); Assert.assertNotNull(target); assertNotApplied(provider.getPatchType(), element.getId(), target.loadTargetInfo()); } }
assertPatchHasBeenApplied(result, patch); InstalledIdentity patchedInstalledIdentity = InstalledIdentity.load(env.getInstalledImage().getJbossHome(), productConfig, env.getInstalledImage().getModulesDir()); assertInstallationIsPatched(patch, patchedInstalledIdentity.getIdentity().loadTargetInfo()); assertFileExists(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName());