Search in sources :

Example 1 with SoftwareType

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);
}
Also used : SDDCSoftwareConfig(com.vmware.flowgate.common.model.SDDCSoftwareConfig) ServerMapping(com.vmware.flowgate.common.model.ServerMapping) NoSuchElementException(java.util.NoSuchElementException) SoftwareType(com.vmware.flowgate.common.model.SDDCSoftwareConfig.SoftwareType) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SDDCSoftwareConfig (com.vmware.flowgate.common.model.SDDCSoftwareConfig)1 SoftwareType (com.vmware.flowgate.common.model.SDDCSoftwareConfig.SoftwareType)1 ServerMapping (com.vmware.flowgate.common.model.ServerMapping)1 NoSuchElementException (java.util.NoSuchElementException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1