protected CreatePhysicalPortCommand(UniPort port) { setNmsPortId(port.getNmsPortId()); setNocLabel(port.getNocLabel()); setBodPortId(port.getBodPortId()); setManagerLabel(port.hasManagerLabel() ? port.getManagerLabel() : ""); setPhysicalResourceGroup(port.getPhysicalResourceGroup()); setTopologyName(port.getTopologyName()); }
private UniPort createUniPort(CreatePhysicalPortCommand command, NbiPort nbiPort) { UniPort uniPort = new UniPort(nbiPort); uniPort.setNocLabel(command.getNocLabel()); uniPort.setBodPortId(command.getBodPortId()); if (Strings.isNullOrEmpty(command.getManagerLabel())) { uniPort.setManagerLabel(null); } else { uniPort.setManagerLabel(command.getManagerLabel()); } uniPort.setPhysicalResourceGroup(command.getPhysicalResourceGroup()); uniPort.setTopologyName(bodEnvironment.getBodTopologyName()); return uniPort; }
@RequestMapping(value = DELETE, params = ID_KEY, method = RequestMethod.DELETE) public String delete( Long id, @RequestParam(value = PAGE_KEY, required = false) Integer page, Model uiModel) { return physicalPortService .find(id) .map( port -> { if (port instanceof UniPort) { virtualServiceService .findEntriesForUniPort((UniPort) port) .forEach( service -> virtualServiceService.delete(service, Security.getUserDetails())); } physicalPortService.delete(id); uiModel.asMap().clear(); uiModel.addAttribute(PAGE_KEY, page == null ? "1" : page.toString()); return redirectPortListPage(port); }) .orElse("redirect:"); }
public UpdatePhysicalPortCommand(UniPort uniPort) { super(uniPort); this.version = uniPort.getVersion(); this.id = uniPort.getId(); }
@RequestMapping(method = RequestMethod.POST) public String create( @Valid CreatePhysicalPortCommand command, BindingResult result, RedirectAttributes redirectAttributes, Model model) { PhysicalPort physicalPort = physicalPortService.findByBodPortId(command.getBodPortId()); if (physicalPort != null) { result.rejectValue("bodPortId", "validation.not.unique"); } Optional<NbiPort> maybeNbiPort = physicalPortService.findNbiPort(command.getNmsPortId()); if (!maybeNbiPort.isPresent()) { return "redirect:"; } NbiPort nbiPort = maybeNbiPort.get(); command.validate(nbiPort, bodEnvironment.getBodTopologyName(), result); if (result.hasErrors()) { model.addAttribute("interfaceTypes", availableInterfaceTypes(nbiPort)); model.addAttribute("availableTopologies", physicalPortService.findTopologyNames()); model.addAttribute("vlanRequired", nbiPort.isVlanRequired()); model.addAttribute("createPhysicalPortCommand", command); return PAGE_URL + CREATE; } PhysicalPort port; switch (command.getInterfaceType()) { case E_NNI: port = createEnniPort(command, nbiPort); messageManager.addInfoFlashMessage( redirectAttributes, "info_physicalport_enni_created", port.getNocLabel()); break; case UNI: UniPort uniPort = createUniPort(command, nbiPort); messageManager.addInfoFlashMessage( redirectAttributes, "info_physicalport_uni_created", uniPort.getNocLabel(), uniPort.getPhysicalResourceGroup().getName()); port = uniPort; break; default: throw new IllegalArgumentException("unknown interface type " + command.getInterfaceType()); } try { physicalPortService.save(port); } catch (OverlappingSubportAllocationException e) { result.reject(e.getMessage()); model.addAttribute("interfaceTypes", availableInterfaceTypes(nbiPort)); model.addAttribute("availableTopologies", physicalPortService.findTopologyNames()); model.addAttribute("vlanRequired", nbiPort.isVlanRequired()); model.addAttribute("createPhysicalPortCommand", command); return PAGE_URL + CREATE; } return redirectPortListPage(port); }