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:io.github.proxyprint.kitchen.controllers.printshops.ReviewController.java
@ApiOperation(value = "Returns all printshop reviews", notes = "404 if the printshop doesn't exist.") @Secured({ "ROLE_MANAGER", "ROLE_EMPLOYEE", "ROLE_USER" }) @RequestMapping(value = "/printshops/{id}/reviews", method = RequestMethod.GET) public ResponseEntity<String> getPrintShopReviews(@PathVariable("id") long id) { PrintShop pShop = this.printshops.findOne(id); if (pShop == null) { return new ResponseEntity(HttpStatus.NOT_FOUND); } else {/* w w w. j av a 2s . c o m*/ Set<Review> reviews = pShop.getReviews(); JsonObject review; JsonArray obj = new JsonArray(); for (Review r : reviews) { review = new JsonObject(); review.addProperty("id", r.getId()); review.addProperty("description", r.getDescription()); review.addProperty("rating", r.getRating()); review.addProperty("username", r.getConsumer().getName()); obj.add(review); } return new ResponseEntity(this.GSON.toJson(obj), HttpStatus.OK); } }
From source file:de.pentasys.playground.springbootexample.NoManagementSampleActuatorApplicationTests.java
@Test public void testMetricsNotAvailable() throws Exception { testHome(); // makes sure some requests have been made @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate("admin", getPassword()) .getForEntity("http://localhost:" + this.port + "/metrics", Map.class); assertEquals(HttpStatus.NOT_FOUND, entity.getStatusCode()); }
From source file:fi.helsinki.opintoni.server.WebPageServer.java
public void expectMetaDataNotFound() { server.expect(requestTo(OpenGraphSampleData.INVALID_URL)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); }
From source file:se.skltp.cooperation.web.rest.exception.DefaultExceptionHandler.java
@ExceptionHandler(ResourceNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody/*from ww w.j ava 2 s . co m*/ public ProblemDetail handleResourceNotFound(HttpServletRequest request, ResourceNotFoundException e) { ProblemDetail error = new ProblemDetail(); buildErrorMessage(request, e, HttpStatus.NOT_FOUND, error); return error; }
From source file:com.cloudbees.jenkins.plugins.demo.actuator.NoManagementSampleActuatorApplicationTests.java
@Test public void testMetricsNotAvailable() throws Exception { testHome(); // makes sure some requests have been made @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword()) .getForEntity("http://localhost:" + this.port + "/metrics", Map.class); assertEquals(HttpStatus.NOT_FOUND, entity.getStatusCode()); }
From source file:com.autentia.showcase.web.rest.wadl.WadlController.java
@ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler(ClassTypeNotFoundException.class) public void handleException() { // Do nothing, just magic annotations to return 404. }
From source file:comsat.sample.freemarker.SampleWebFreeMarkerApplicationTests.java
@Test public void testFreeMarkerErrorTemplate() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); HttpEntity<String> requestEntity = new HttpEntity<String>(headers); ResponseEntity<String> responseEntity = new TestRestTemplate().exchange( "http://localhost:" + port + "/does-not-exist", HttpMethod.GET, requestEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody().contains("Something went wrong: 404 Not Found")); }
From source file:org.apigw.authserver.web.admin.DefaultAdminExceptionHandler.java
@ExceptionHandler(TypeMismatchException.class) @ResponseStatus(HttpStatus.NOT_FOUND) public @ResponseBody Map<String, Object> handleTypeMismatch(TypeMismatchException e) { Map<String, Object> map = Maps.newHashMap(); map.put("error", "Type mismatch"); map.put("cause", "Argument with the value " + e.getValue() + " is not valid"); log.info("Handle TypeMismatch. Returning {}", map); return map;/*from w w w .ja v a 2 s. c o m*/ }
From source file:ca.qhrtech.controllers.CategoryController.java
@ApiMethod(description = "Updates the Category at the specified location. Passed Category should contain updated fields") @RequestMapping(value = "/category/{id}", method = RequestMethod.PUT) public ResponseEntity<Category> updateCategory(@PathVariable("id") long id, @RequestBody Category category) { Category currentCategory = categoryService.findCategoryById(id); if (category == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }// w w w .j a v a2s . c o m currentCategory.setName(category.getName()); categoryService.updateCategory(currentCategory); return new ResponseEntity<>(currentCategory, HttpStatus.OK); }
From source file:com.tamnd.app.rest.controller.AccountController.java
@RequestMapping(value = "/{accountId}", method = RequestMethod.GET) public ResponseEntity<AccountResource> getAccount(@PathVariable Integer accountId) { Account account = accountService.findAccount(accountId); if (account != null) { AccountResource res = new AccountResourceAsm().toResource(account); return new ResponseEntity<>(res, HttpStatus.OK); }// w w w. ja v a 2 s .co m return new ResponseEntity<>(HttpStatus.NOT_FOUND); }