Search in sources :

Example 1 with InteractiveCredentialCreationRequest

use of com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveCredentialCreationRequest in project cloudbreak by hortonworks.

the class CredentialSender method createCredential.

@Override
public void createCredential(CloudContext cloudContext, ExtendedCloudCredential extendedCloudCredential) {
    InteractiveCredentialCreationRequest credentialCreationRequest = new InteractiveCredentialCreationRequest(cloudContext, extendedCloudCredential);
    LOGGER.info("Triggering event: {}", credentialCreationRequest);
    eventBus.notify(credentialCreationRequest.selector(), eventFactory.createEvent(credentialCreationRequest));
}
Also used : InteractiveCredentialCreationRequest(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveCredentialCreationRequest)

Example 2 with InteractiveCredentialCreationRequest

use of com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveCredentialCreationRequest in project cloudbreak by hortonworks.

the class InteractiveCredentialCreationHandler method accept.

@Override
public void accept(Event<InteractiveCredentialCreationRequest> interactiveCredentialCreationRequestEvent) {
    InteractiveCredentialCreationRequest interactiveCredentialCreationRequest = interactiveCredentialCreationRequestEvent.getData();
    ExtendedCloudCredential extendedCloudCredential = interactiveCredentialCreationRequest.getExtendedCloudCredential();
    Credential credential = extendedCloudCredentialToCredentialConverter.convert(extendedCloudCredential);
    try {
        credentialService.createWithRetry(extendedCloudCredential.getOwner(), extendedCloudCredential.getAccount(), credential);
    } catch (DuplicateKeyValueException e) {
        sendErrorNotification(extendedCloudCredential.getOwner(), extendedCloudCredential.getAccount(), extendedCloudCredential.getCloudPlatform(), DuplicatedKeyValueExceptionMapper.errorMessage(e));
    } catch (BadRequestException e) {
        sendErrorNotification(extendedCloudCredential.getOwner(), extendedCloudCredential.getAccount(), extendedCloudCredential.getCloudPlatform(), e.getMessage());
    }
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) Credential(com.sequenceiq.cloudbreak.domain.Credential) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) InteractiveCredentialCreationRequest(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveCredentialCreationRequest) DuplicateKeyValueException(com.sequenceiq.cloudbreak.service.DuplicateKeyValueException)

Aggregations

InteractiveCredentialCreationRequest (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveCredentialCreationRequest)2 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 Credential (com.sequenceiq.cloudbreak.domain.Credential)1 DuplicateKeyValueException (com.sequenceiq.cloudbreak.service.DuplicateKeyValueException)1