use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.CleanupFailureEvent in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method cleanupFailureAction.
@Bean(name = "CLEANUP_FAILED_STATE")
public Action<?, ?> cleanupFailureAction() {
return new AbstractFreeIpaCleanupAction<>(CleanupFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(FreeIpaContext context, CleanupFailureEvent payload, Map<Object, Object> variables) {
LOGGER.error("Cleanup failed with payload: " + payload);
String environmentCrn = payload.getEnvironmentCrn();
SuccessDetails successDetails = new SuccessDetails(environmentCrn);
successDetails.getAdditionalDetails().put(payload.getFailedPhase(), payload.getSuccess() == null ? List.of() : new ArrayList<>(payload.getSuccess()));
String message = "Cleanup failed during " + payload.getFailedPhase();
FailureDetails failureDetails = new FailureDetails(environmentCrn, message);
if (payload.getFailureDetails() != null) {
failureDetails.getAdditionalDetails().putAll(payload.getFailureDetails());
}
operationService.failOperation(payload.getAccountId(), payload.getOperationId(), message, List.of(successDetails), List.of(failureDetails));
sendEvent(context, FreeIpaCleanupEvent.CLEANUP_FAILURE_HANDLED_EVENT.event(), payload);
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<CleanupFailureEvent>> payloadConverters) {
payloadConverters.add(new RemoveDnsResponseToCleanupFailureEventConverter());
payloadConverters.add(new RemoveHostsResponseToCleanupFailureEventConverter());
payloadConverters.add(new RemoveRolesResponseToCleanupFailureEventConverter());
payloadConverters.add(new RemoveUsersResponseToCleanupFailureEventConverter());
payloadConverters.add(new RevokeCertsResponseToCleanupFailureEventConverter());
payloadConverters.add(new RemoveVaultEntriesResponseToCleanupFailureEventConverter());
}
};
}
Aggregations