use of com.infiniteautomation.mango.io.serial.virtual.VirtualSerialPortConfig in project ma-modules-public by infiniteautomation.
the class VirtualSerialPortRestV2Controller method update.
@PreAuthorize("isAdmin()")
@ApiOperation(value = "Update virtual serial port", notes = "")
@RequestMapping(method = RequestMethod.PUT, consumes = { "application/json", "application/sero-json" }, produces = { "application/json", "text/csv", "application/sero-json" }, value = { "/{xid}" })
public ResponseEntity<VirtualSerialPortConfig> update(@ApiParam(value = "Valid virtual serial port id", required = true, allowMultiple = false) @PathVariable String xid, @ApiParam(value = "Virtual Serial Port", required = true) @RequestBody(required = true) VirtualSerialPortConfig model, @AuthenticationPrincipal User user, UriComponentsBuilder builder, HttpServletRequest request) {
// Check to see if it already exists
VirtualSerialPortConfig existing = VirtualSerialPortConfigDao.instance.getByXid(model.getXid());
if (existing == null)
throw new NotFoundRestException();
// Validate
model.ensureValid();
// Save it
VirtualSerialPortConfigDao.instance.save(model);
// Put a link to the updated data in the header
URI location = builder.path("/v2/virtual-serial-ports/{xid}").buildAndExpand(model.getXid()).toUri();
return getResourceUpdated(model, location);
}
Aggregations