if (channelType == null) {
LOG.warn("Invalid ChannelType (" + channelName + ") submitted.");
result = MappingCreateResult.BAD_CHANNEL_TYPE;
} else {
ChannelVulnerability channelVulnerability =
channelVulnerabilityDao.retrieveByCode(channelType, channelVulnerabilityCode);
if (channelVulnerability == null) {
LOG.info("Channel Vulnerability lookup by code failed, trying by name.");
channelVulnerability =
channelVulnerabilityDao.retrieveByName(channelType, channelVulnerabilityCode);
}
if (channelVulnerability == null) {
LOG.warn("Invalid ChannelVulnerability code (" + channelVulnerabilityCode + ") submitted.");
result = MappingCreateResult.BAD_CHANNEL_VULNERABILITY;
} else {
GenericVulnerability genericVulnerability =
genericVulnerabilityDao.retrieveByDisplayId(integerId);
if (genericVulnerability == null) {
LOG.warn("Unable to find GenericVulnerability with code " + genericVulnerabilityId);
result = MappingCreateResult.BAD_GENERIC_VULNERABILITY_ID;
} else {
VulnerabilityMap newMap = new VulnerabilityMap();
newMap.setChannelVulnerability(channelVulnerability);
newMap.setGenericVulnerability(genericVulnerability);
channelVulnerability.setVulnerabilityMaps(Arrays.asList(newMap));
channelVulnerability.setUserCreated(true);
channelVulnerabilityDao.saveOrUpdate(channelVulnerability);
result = MappingCreateResult.SUCCESS;
}