use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.users.RemoveUsersResponse in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method removeRolesAction.
@Bean(name = "REMOVE_ROLES_STATE")
public Action<?, ?> removeRolesAction() {
return new AbstractFreeIpaCleanupAction<>(RemoveUsersResponse.class) {
@Override
protected void doExecute(FreeIpaContext context, RemoveUsersResponse payload, Map<Object, Object> variables) {
if (shouldSkipState(payload, variables) || payload.getRoles() == null || payload.getRoles().isEmpty()) {
LOGGER.info("Roles is empty, skipping removing roles");
RemoveRolesResponse response = new RemoveRolesResponse(payload, Collections.emptySet(), Collections.emptyMap());
sendEvent(context, response);
} else {
RemoveRolesRequest request = new RemoveRolesRequest(payload, context.getStack());
sendEvent(context, request);
}
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.users.RemoveUsersResponse in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method removeUsersAction.
@Bean(name = "REMOVE_USERS_STATE")
public Action<?, ?> removeUsersAction() {
return new AbstractFreeIpaCleanupAction<>(RemoveVaultEntriesResponse.class) {
@Override
protected void doExecute(FreeIpaContext context, RemoveVaultEntriesResponse payload, Map<Object, Object> variables) {
if (shouldSkipState(payload, variables) || payload.getUsers() == null || payload.getUsers().isEmpty()) {
LOGGER.info("User is empty, skipping removing users");
RemoveUsersResponse response = new RemoveUsersResponse(payload, Collections.emptySet(), Collections.emptyMap());
sendEvent(context, response);
} else {
RemoveUsersRequest request = new RemoveUsersRequest(payload, context.getStack());
sendEvent(context, request);
}
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.users.RemoveUsersResponse in project cloudbreak by hortonworks.
the class RemoveUsersResponseToCleanupFailureEventConverter method convert.
@Override
public CleanupFailureEvent convert(Object payload) {
RemoveUsersResponse removeUsersResponse = (RemoveUsersResponse) payload;
CleanupFailureEvent event = new CleanupFailureEvent(removeUsersResponse, "Users removal", removeUsersResponse.getUserCleanupFailed(), removeUsersResponse.getUserCleanupSuccess());
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.users.RemoveUsersResponse in project cloudbreak by hortonworks.
the class UserRemoveHandler method accept.
@Override
public void accept(Event<RemoveUsersRequest> event) {
RemoveUsersRequest request = event.getData();
try {
Pair<Set<String>, Map<String, String>> removeUsersResult = cleanupService.removeUsers(request.getResourceId(), request.getUsers(), request.getClusterName(), request.getEnvironmentCrn());
RemoveUsersResponse response = new RemoveUsersResponse(request, removeUsersResult.getFirst(), removeUsersResult.getSecond());
eventBus.notify(response.getUserCleanupFailed().isEmpty() ? EventSelectorUtil.selector(RemoveUsersResponse.class) : EventSelectorUtil.failureSelector(RemoveUsersResponse.class), new Event<>(event.getHeaders(), response));
} catch (Exception e) {
LOGGER.error("Removing users failed: [{}]", request.getUsers(), e);
Map<String, String> failureResult = request.getUsers().stream().collect(Collectors.toMap(h -> h, h -> e.getMessage()));
RemoveUsersResponse response = new RemoveUsersResponse(request, Collections.emptySet(), failureResult);
eventBus.notify(EventSelectorUtil.failureSelector(RemoveUsersResponse.class), new Event<>(event.getHeaders(), response));
}
}
Aggregations