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:com.nebhale.buildmonitor.web.BuildController.java
@Transactional(readOnly = true) @RequestMapping(method = RequestMethod.GET, value = "", produces = MEDIA_TYPE) ResponseEntity<?> readAll(@PathVariable Project project, @PageableDefault(size = 10) Pageable pageable) { if (project == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/*from w ww. j a va2 s .co m*/ Page<Build> builds = this.repository.findAllByProjectOrderByCreatedDesc(project, pageable); PagedResources<Resource<Build>> resources = this.pagedResourcesAssembler.toResource(builds, this.resourceAssembler); return new ResponseEntity<>(resources, HttpStatus.OK); }
From source file:net.jkratz.igdb.controller.ESRBRatingController.java
/** * Returns a single ESRB rating object if exists, otherwise returns HTTP status code 404 * * @param id ID of the ESRB Rating//from ww w .j av a 2 s.co m * @return ESRB Rating when found * @see ESRBRating */ @RequestMapping(value = "/{id}", method = RequestMethod.GET) public ResponseEntity<?> getUser(@PathVariable("id") Long id) { logger.debug("Attempting to fetch ESRB rating with ID: {}", id); ESRBRating esrbRating = esrbRatingService.getESRBRating(id); //ESRBRating esrbRating = esrbRatingRepository.findOne(id); if (esrbRating == null) { return new ResponseEntity<>("ESRB Rating not found", HttpStatus.NOT_FOUND); } else { return new ResponseEntity<>(esrbRating, HttpStatus.OK); } }
From source file:py.com.sodep.web.UserWatchListController.java
@ExceptionHandler @ResponseStatus(HttpStatus.NOT_FOUND) public RestResponse handleUserNotFound(UserNameNotFoundException ex) { return new RestResponse(false, ex.getMessage()); }
From source file:com.companyname.controller.OAuth2AdminController.java
@RequestMapping(value = "/oauth/users/{user}/tokens/{token}", method = RequestMethod.DELETE) public ResponseEntity<Void> revokeToken(@PathVariable String user, @PathVariable String token, Principal principal) throws Exception { checkResourceOwner(user, principal); if (tokenServices.revokeToken(token)) { return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); } else {/*from w w w .j a va 2s . c o m*/ return new ResponseEntity<Void>(HttpStatus.NOT_FOUND); } }
From source file:net.jkratz.igdb.controller.GameController.java
@RequestMapping(value = "/game/{id}", method = RequestMethod.GET) public ResponseEntity<?> getGame(@PathVariable("id") Long id) { Game game = gameService.getGame(id); if (game == null) { return new ResponseEntity<>("User not found", HttpStatus.NOT_FOUND); } else {//from w w w. j av a2 s . c om return new ResponseEntity<>(game, HttpStatus.OK); } }
From source file:org.nekorp.workflow.backend.controller.imp.RegistroCostoControllerImp.java
@Override @RequestMapping(method = RequestMethod.GET) public @ResponseBody Page<RegistroCosto, Long> getRegistros(@PathVariable final Long idServicio, @Valid @ModelAttribute final PaginationDataLong pagination, final HttpServletResponse response) { if (!idServicioValido(idServicio)) { response.setStatus(HttpStatus.NOT_FOUND.value()); return null; }/*from w w w. j a v a 2s . c o m*/ List<RegistroCosto> datos = registroCostoDAO.consultarTodos(idServicio, null, pagination); Page<RegistroCosto, Long> r = pagFactory.getPage(); r.setTipoItems("registroCosto"); r.setLinkPaginaActual(armaUrl(idServicio, pagination.getSinceId(), pagination.getMaxResults())); if (pagination.hasNext()) { r.setLinkSiguientePagina(armaUrl(idServicio, pagination.getNextId(), pagination.getMaxResults())); r.setSiguienteItem(pagination.getNextId()); } r.setItems(datos); response.setHeader("Content-Type", "application/json;charset=UTF-8"); return r; }
From source file:comsat.sample.mustache.SampleWebMustacheApplicationTests.java
@Test public void testMustacheErrorTemplate() 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:" + this.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:comsat.sample.velocity.SampleWebVelocityApplicationTests.java
@Test public void testVelocityErrorTemplate() 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:" + this.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:edu.sjsu.cmpe275.project.controller.UserController.java
/** Get a user * @param name User Name//from w ww. ja v a 2 s . com * @return void */ @RequestMapping(value = "/{id}", method = RequestMethod.GET) public ResponseEntity<?> getUserJson(@PathVariable("id") String name) { User user = userDao.getUser(name); if (user == null) { return new ResponseEntity<Object>(null, HttpStatus.NOT_FOUND); } else { return new ResponseEntity<>(user, HttpStatus.OK); } }