/** * PUT /queues : Updates an existing queue. * * @param queue the queue to update * @return the ResponseEntity with status 200 (OK) and with body the updated queue, or with status * 400 (Bad Request) if the queue is not valid, or with status 500 (Internal Server Error) if * the queue couldnt be updated * @throws URISyntaxException if the Location URI syntax is incorrect */ @RequestMapping( value = "/queues", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Queue> updateQueue(@RequestBody Queue queue) throws URISyntaxException { log.debug("REST request to update Queue : {}", queue); if (queue.getId() == null) { return createQueue(queue); } Queue result = queueRepository.save(queue); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("queue", queue.getId().toString())) .body(result); }
/** * POST /queues : Create a new queue. * * @param queue the queue to create * @return the ResponseEntity with status 201 (Created) and with body the new queue, or with * status 400 (Bad Request) if the queue has already an ID * @throws URISyntaxException if the Location URI syntax is incorrect */ @RequestMapping( value = "/queues", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Queue> createQueue(@RequestBody Queue queue) throws URISyntaxException { log.debug("REST request to save Queue : {}", queue); if (queue.getId() != null) { return ResponseEntity.badRequest() .headers( HeaderUtil.createFailureAlert( "queue", "idexists", "A new queue cannot already have an ID")) .body(null); } Queue result = queueRepository.save(queue); return ResponseEntity.created(new URI("/api/queues/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert("queue", result.getId().toString())) .body(result); }