public static void validateAdd(VnicProfile profile) { if (profile == null) { throw new ValidationException("Parameter 'profile' is mandatory but was not provided."); } if (profile.getName()==null) { throw new ValidationException("Parameter 'profile.name' is mandatory but was not provided."); } }
public static void validateAdd(VnicProfile profile) { if (profile == null) { throw new ValidationException("Parameter 'profile' is mandatory but was not provided."); } if (profile.getName()==null) { throw new ValidationException("Parameter 'profile.name' is mandatory but was not provided."); } if (profile.getNetwork()==null || profile.getNetwork().getId()==null) { throw new ValidationException("Parameter 'profile.network.id' is mandatory but was not provided."); } }
/** * <pre> * - Best effort conversion of the input user mapping REST API object into an internal representation. * - If there is no target 'to' then it is considered as 'no mapping specified' for this 'from'. therefore the * user entry is ignored and the bll logic will try to use the sources on the ovf nic as the target. * </pre> * @param regMapping - user input for mapping * @return internal object representing the input user mapping */ private static ExternalVnicProfileMapping createExternalVnicProfileMapping(RegistrationVnicProfileMapping regMapping) { ExternalVnicProfileMapping m = new ExternalVnicProfileMapping( regMapping.getFrom().getNetwork().getName(), regMapping.getFrom().getName()); if(isSetToId(regMapping)) { try { Guid targetId = asGuid(regMapping.getTo().getId()); m.setTargetProfileId(targetId); } catch (Exception e){ //bad id - ignore } } if (isSetToName(regMapping)) { m.setTargetProfileName(regMapping.getTo().getName()); } if (isSetToNetworkName(regMapping)) { m.setTargetNetworkName(regMapping.getTo().getNetwork().getName()); } return m; }
@Override protected void verify(VnicProfile model, VnicProfile transform) { assertNotNull(transform); assertEquals(model.getId(), transform.getId()); assertEquals(model.getName(), transform.getName()); assertEquals(model.getDescription(), transform.getDescription()); assertNotNull(transform.getNetwork()); assertEquals(model.getNetwork().getId(), transform.getNetwork().getId()); assertEquals(model.isPortMirroring(), transform.isPortMirroring()); assertNotNull(transform.getCustomProperties()); assertEquals(CustomPropertiesParser.parse(model.getCustomProperties().getCustomProperties()), CustomPropertiesParser.parse(transform.getCustomProperties().getCustomProperties())); } }
to.setName(from.getName());
entity.setName(model.getName());