use of com.sequenceiq.environment.network.dao.domain.RegistrationType in project cloudbreak by hortonworks.
the class NetworkDeleteHandler method accept.
@Override
public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) {
EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData();
EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto();
EnvDeleteEvent envDeleteEvent = EnvDeleteEvent.builder().withResourceId(environmentDto.getResourceId()).withResourceName(environmentDto.getName()).withResourceCrn(environmentDto.getResourceCrn()).withForceDelete(environmentDeletionDto.isForceDelete()).withSelector(START_IDBROKER_MAPPINGS_DELETE_EVENT.selector()).build();
try {
environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(environment -> {
BaseNetwork network = environment.getNetwork();
if (network != null) {
RegistrationType registrationType = network.getRegistrationType();
if (RegistrationType.CREATE_NEW == registrationType) {
environmentNetworkService.deleteNetwork(environmentDtoConverter.environmentToDto(environment));
}
network.setName(environment.getResourceCrn() + "_network_DELETED_@_" + System.currentTimeMillis());
environmentService.save(environment);
}
});
eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders());
} catch (Exception e) {
exceptionProcessor.handle(new HandlerFailureConjoiner(e, environmentDtoEvent, envDeleteEvent), LOGGER, eventSender(), selector());
}
}
use of com.sequenceiq.environment.network.dao.domain.RegistrationType in project cloudbreak by hortonworks.
the class AzureRegistrationTypeResolverTest method testNetworkDtoGetRegistrationTypeExisting.
@Test
void testNetworkDtoGetRegistrationTypeExisting() {
NetworkDto networkDto = NetworkDto.builder().withAzure(AzureParams.builder().withNetworkId("NetworkId").withResourceGroupName("ResourceGroupName").build()).build();
RegistrationType registrationType = azureRegistrationTypeResolver.getRegistrationType(networkDto);
Assertions.assertEquals(RegistrationType.EXISTING, registrationType);
}
Aggregations