use of org.jboss.as.patching.tool.ContentVerificationPolicy in project wildfly-core by wildfly.
the class LocalPatchOperationStepHandler method executeRuntime.
private void executeRuntime(final OperationContext context, final ModelNode operation) throws OperationFailedException {
// Acquire the lock and check the write permissions for this operation
final ServiceRegistry registry = context.getServiceRegistry(true);
final InstallationManager installationManager = (InstallationManager) registry.getRequiredService(InstallationManagerService.NAME).getValue();
if (installationManager.requiresRestart()) {
throw PatchLogger.ROOT_LOGGER.serverRequiresRestart();
}
try {
final PatchTool runner = PatchTool.Factory.create(installationManager);
final ContentVerificationPolicy policy = PatchTool.Factory.create(operation);
final int index = operation.get(ModelDescriptionConstants.INPUT_STREAM_INDEX).asInt(0);
final InputStream is = context.getAttachmentStream(index);
installationManager.restartRequired();
final PatchingResult result = runner.applyPatch(is, policy);
context.restartRequired();
context.completeStep(new OperationContext.ResultHandler() {
@Override
public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) {
if (resultAction == OperationContext.ResultAction.KEEP) {
result.commit();
} else {
installationManager.clearRestartRequired();
context.revertRestartRequired();
result.rollback();
}
}
});
} catch (PatchingException e) {
final ModelNode failureDescription = context.getFailureDescription();
PatchOperationTarget.formatFailedResponse(e, failureDescription);
installationManager.clearRestartRequired();
}
}
use of org.jboss.as.patching.tool.ContentVerificationPolicy in project wildfly-core by wildfly.
the class LocalPatchRollbackHandler method execute.
@Override
protected void execute(final OperationContext context, final ModelNode operation, final InstallationManager installationManager, final String patchStream) throws OperationFailedException {
if (installationManager.requiresRestart()) {
throw PatchLogger.ROOT_LOGGER.serverRequiresRestart();
}
final String patchId = PatchResourceDefinition.PATCH_ID.resolveModelAttribute(context, operation).asString();
final boolean rollbackTo = PatchResourceDefinition.ROLLBACK_TO.resolveModelAttribute(context, operation).asBoolean();
final boolean restoreConfiguration = PatchResourceDefinition.RESET_CONFIGURATION.resolveModelAttribute(context, operation).asBoolean();
final PatchTool runner = PatchTool.Factory.create(installationManager);
final ContentVerificationPolicy policy = PatchTool.Factory.create(operation);
try {
// Rollback
final PatchingResult result = runner.rollback(patchStream, patchId, policy, rollbackTo, restoreConfiguration);
installationManager.restartRequired();
context.restartRequired();
context.completeStep(new OperationContext.ResultHandler() {
@Override
public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) {
if (resultAction == OperationContext.ResultAction.KEEP) {
result.commit();
} else {
installationManager.clearRestartRequired();
context.revertRestartRequired();
result.rollback();
}
}
});
} catch (PatchingException e) {
final ModelNode failureDescription = context.getFailureDescription();
PatchOperationTarget.formatFailedResponse(e, failureDescription);
installationManager.clearRestartRequired();
} finally {
//
}
}
use of org.jboss.as.patching.tool.ContentVerificationPolicy in project wildfly-core by wildfly.
the class LocalPatchRollbackLastHandler method execute.
@Override
protected void execute(final OperationContext context, final ModelNode operation, final InstallationManager installationManager, final String patchStream) throws OperationFailedException {
if (installationManager.requiresRestart()) {
throw PatchLogger.ROOT_LOGGER.serverRequiresRestart();
}
final boolean resetConfiguration = PatchResourceDefinition.RESET_CONFIGURATION.resolveModelAttribute(context, operation).asBoolean();
final PatchTool runner = PatchTool.Factory.create(installationManager);
final ContentVerificationPolicy policy = PatchTool.Factory.create(operation);
try {
// Rollback
final PatchingResult result = runner.rollbackLast(patchStream, policy, resetConfiguration);
installationManager.restartRequired();
context.restartRequired();
context.completeStep(new OperationContext.ResultHandler() {
@Override
public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) {
if (resultAction == OperationContext.ResultAction.KEEP) {
result.commit();
} else {
installationManager.clearRestartRequired();
context.revertRestartRequired();
result.rollback();
}
}
});
} catch (PatchingException e) {
final ModelNode failureDescription = context.getFailureDescription();
PatchOperationTarget.formatFailedResponse(e, failureDescription);
installationManager.clearRestartRequired();
} finally {
//
}
}
Aggregations