List of usage examples for org.springframework.http HttpStatus NOT_FOUND
HttpStatus NOT_FOUND
To view the source code for org.springframework.http HttpStatus NOT_FOUND.
Click Source Link
From source file:ca.qhrtech.controllers.ResultController.java
@ApiMethod(description = "Updates the Game Result at the specified location") @RequestMapping(value = "/result/{id}", method = RequestMethod.PUT) public ResponseEntity<GameResult> updateResult(@PathVariable("id") long id, @RequestBody GameResult result) { GameResult currentResult = resultService.findResultById(id); if (currentResult == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/* w ww . j ava2 s . c o m*/ currentResult.setComments(result.getComments()); currentResult.setTeam(result.getTeam()); currentResult.setWinner(result.isWinner()); resultService.updateResult(currentResult); return new ResponseEntity<>(currentResult, HttpStatus.OK); }
From source file:com.bill99.yn.webmgmt.functional.rest.TaskRestFT.java
/** * //.//from www . jav a 2s. c o m */ @Test @Category(Smoke.class) public void createUpdateAndDeleteTask() { // create Task task = TaskData.randomTask(); URI taskUri = restTemplate.postForLocation(resoureUrl, task); System.out.println(taskUri.toString()); Task createdTask = restTemplate.getForObject(taskUri, Task.class); assertThat(createdTask.getTitle()).isEqualTo(task.getTitle()); // update String id = StringUtils.substringAfterLast(taskUri.toString(), "/"); task.setId(new Long(id)); task.setTitle(TaskData.randomTitle()); restTemplate.put(taskUri, task); Task updatedTask = restTemplate.getForObject(taskUri, Task.class); assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle()); // delete restTemplate.delete(taskUri); try { restTemplate.getForObject(taskUri, Task.class); fail("Get should fail while feth a deleted task"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); } }
From source file:org.mitre.openid.connect.web.ApprovedSiteAPI.java
/** * Delete an approved site/* w w w.j a v a 2 s .c om*/ * */ @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public String deleteApprovedSite(@PathVariable("id") Long id, ModelMap m, Principal p) { ApprovedSite approvedSite = approvedSiteService.getById(id); if (approvedSite == null) { logger.error("deleteApprovedSite failed; no approved site found for id: " + id); m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND); m.put(JsonErrorView.ERROR_MESSAGE, "Could not delete approved site. The requested approved site with id: " + id + " could not be found."); return JsonErrorView.VIEWNAME; } else if (!approvedSite.getUserId().equals(p.getName())) { logger.error( "deleteApprovedSite failed; principal " + p.getName() + " does not own approved site" + id); m.put(HttpCodeView.CODE, HttpStatus.FORBIDDEN); m.put(JsonErrorView.ERROR_MESSAGE, "You do not have permission to delete this approved site. The approved site decision will not be deleted."); return JsonErrorView.VIEWNAME; } else { m.put(HttpCodeView.CODE, HttpStatus.OK); approvedSiteService.remove(approvedSite); } return HttpCodeView.VIEWNAME; }
From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java
@Test public void get_notFound() { controller.register(new Application("http://localhost", "FOO")); ResponseEntity<?> response = controller.get("unknown"); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); }
From source file:com.walmart.gatling.AbstractRestIntTest.java
protected HttpStatus delete(String url) { ResponseEntity<Void> response = template.exchange(url, HttpMethod.DELETE, null, Void.class); HttpStatus code = response.getStatusCode(); if (code == HttpStatus.OK || code == HttpStatus.NO_CONTENT || code == HttpStatus.NOT_FOUND) return response.getStatusCode(); else {//w ww .ja v a2 s. c o m fail("Expected the delete response to be 200 or 404, but was " + code.value() + "(" + code.getReasonPhrase() + ")."); return null; //for compiler } }
From source file:ca.qhrtech.controllers.CategoryController.java
@ApiMethod(description = "Deletes the Category at the specified location") @RequestMapping(value = "/category/{id}", method = RequestMethod.DELETE) public ResponseEntity<Category> deleteCategory(@PathVariable("id") long id) { if (categoryService.findCategoryById(id) == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/*from ww w .j a va 2 s . c om*/ categoryService.deleteCategory(id); return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
From source file:org.ow2.proactive.procci.rest.SwarmRest.java
@RequestMapping(value = "{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<ResourceRendering> getSwarm(@PathVariable("id") String id) { logger.debug("Get Swarm " + id); try {/*from w ww . j ava2 s .c o m*/ return instanceService.getEntity(id, transformerManager.getTransformerProvider(TransformerType.SWARM)) .map(swar -> new ResponseEntity<>(((Swarm) swar).getRendering(), HttpStatus.OK)) .orElse(new ResponseEntity(HttpStatus.NOT_FOUND)); } catch (ClientException e) { logger.error(this.getClass().getName(), e); return new ResponseEntity(e.getJsonError(), HttpStatus.BAD_REQUEST); } catch (ServerException e) { logger.error(this.getClass().getName(), e); return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:org.osiam.resources.exceptions.OsiamExceptionHandler.java
private HttpStatus setStatus(Exception ex) { if (ex instanceof ResourceNotFoundException) { return HttpStatus.NOT_FOUND; }//from w ww . j a v a 2s . c o m if (ex instanceof SchemaUnknownException) { return HttpStatus.I_AM_A_TEAPOT; } if (ex instanceof UnsupportedOperationException) { return HttpStatus.NOT_IMPLEMENTED; } return HttpStatus.CONFLICT; }
From source file:eu.dime.dnsregister.controllers.RecordsController.java
@RequestMapping(value = "/findbyip", headers = "Accept=application/json") @ResponseBody// w w w. j a va2s. c o m public ResponseEntity<String> showJson(@RequestParam(required = true) String ip) { Records records = null; try { records = Records.findRecordsesByContentEquals(ip).getSingleResult(); } catch (Exception e) { System.out.println("Obviament la excepcio l'has creat tu [" + Records.findRecordsesByContentEquals(ip)); } HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json; charset=utf-8"); if (records == null) { return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND); } return new ResponseEntity<String>("{\"publickey\":\"" + records.getPublickey() + "\"}", headers, HttpStatus.OK); }
From source file:org.nekorp.workflow.backend.controller.imp.UploadControllerImp.java
/**{@inheritDoc}*/ @Override//from w w w. j av a 2 s . c o m @RequestMapping(value = "/imagenes/{rawBlobKey}", method = RequestMethod.DELETE) public void deleteImage(@PathVariable final String rawBlobKey, final HttpServletResponse response) { try { BlobKey blobKey = new BlobKey(rawBlobKey); blobstoreService.delete(blobKey); response.setStatus(HttpStatus.ACCEPTED.value()); } catch (Exception e) { response.setStatus(HttpStatus.NOT_FOUND.value()); } }