use of com.vmware.flowgate.common.model.SDDCSoftwareConfig.SoftwareType in project flowgate by vmware.
the class SDDCSoftwareController method delete.
// Delete
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void delete(@PathVariable String id) {
Optional<SDDCSoftwareConfig> sddcOptional = sddcRepository.findById(id);
SDDCSoftwareConfig server = new SDDCSoftwareConfig();
try {
server = sddcOptional.get();
} catch (NoSuchElementException e) {
throw WormholeRequestException.NotFound("sddc", "id", id);
}
SoftwareType type = server.getType();
switch(type) {
case VCENTER:
List<ServerMapping> vcenterMappings = serverMappingRepository.findAllByVCID(id);
if (vcenterMappings != null && !vcenterMappings.isEmpty()) {
for (ServerMapping mapping : vcenterMappings) {
serverMappingRepository.deleteById(mapping.getId());
}
}
break;
case VRO:
case VROPSMP:
List<ServerMapping> mappings = serverMappingRepository.findAllByVroID(id);
if (mappings != null && !mappings.isEmpty()) {
for (ServerMapping mapping : mappings) {
serverMappingRepository.deleteById(mapping.getId());
}
}
break;
default:
logger.info(String.format("Integration Type: %s No Found.", server.getType()));
break;
}
sddcRepository.deleteById(id);
}
Aggregations