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.rx4dr.service.controller.RestExceptionHandler.java
@ExceptionHandler({ UnknownResourceException.class }) public ResponseEntity<Map<String, String>> handleUnknownResourceException(UnknownResourceException e) { logger.debug("Enyeting handleUnknownResourceException"); Map<String, String> map = new HashMap<String, String>(); map.put(status, HttpStatus.NOT_FOUND.toString()); map.put(error, e.getClass().getSimpleName()); map.put(description, e.getMessage()); return new ResponseEntity<Map<String, String>>(map, HttpStatus.OK); }
From source file:io.pivotal.ecosystem.service.HelloController.java
@RequestMapping(value = "/users", method = RequestMethod.PUT) ResponseEntity<User> updateUser(@RequestBody User user) { if (!userStore.userExists(user.getName())) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/*from w w w.j av a2s . c o m*/ setPassword(user); userStore.save(user); return new ResponseEntity<>(user, HttpStatus.CREATED); }
From source file:com.srinathavan.mwbng.rest.mvc.BlogEntryController.java
/** * Method to blog entry data by its id//from w w w .j a v a2 s . c om * * @param blogEntryId * @return */ @RequestMapping(value = "/{blogEntryId}") public @ResponseBody ResponseEntity<Object> getBlogEntry(@PathVariable Long blogEntryId) { BlogEntry blogEntry = blogEntryService.findBlogEntry(blogEntryId); if (null != blogEntry) { return new ResponseEntity<Object>(blogEntry, HttpStatus.OK); } else { return new ResponseEntity<Object>(HttpStatus.NOT_FOUND); } }
From source file:au.id.hazelwood.sos.web.controller.framework.GlobalExceptionHandler.java
@ExceptionHandler(value = NotFoundException.class) public ResponseEntity<Object> handleNotFound(Exception ex, WebRequest request) { return handleExceptionInternal(ex, createDefaultResponseBody(ex, HttpStatus.NOT_FOUND), new HttpHeaders(), HttpStatus.NOT_FOUND, request); }
From source file:nu.yona.server.rest.HibernateStatisticsController.java
@RequestMapping(value = "/enable/", params = { "enable" }, method = RequestMethod.POST) @ResponseBody/*from w w w . j a v a 2 s . co m*/ public ResponseEntity<Void> enable(@RequestParam(value = "enable", defaultValue = "false") String enableStr) { if (!yonaProperties.isEnableHibernateStatsAllowed()) { return createResponse(HttpStatus.NOT_FOUND); } hibernateStatisticsService.setEnabled(Boolean.TRUE.toString().equals(enableStr)); return createOkResponse(); }
From source file:com.redblackit.web.test.RestTemplateTestHelperTest.java
/** * Method returning parameters, which also sets up the servlets to use *//* w ww . java 2 s . c om*/ @Parameters public static List<Object[]> getParameters() throws Exception { final String[] methods = { "GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS" }; final HttpStatus[][] codes = { { HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR }, { HttpStatus.NOT_FOUND, HttpStatus.FORBIDDEN, HttpStatus.CONFLICT, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.METHOD_NOT_ALLOWED, HttpStatus.PRECONDITION_FAILED }, { HttpStatus.NOT_FOUND, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND } }; ServletContextHandler jettyContext = new ServletContextHandler(ServletContextHandler.SESSIONS); jettyContext.setContextPath("/"); server.setHandler(jettyContext); List<Object[]> parameters = new ArrayList<Object[]>(); for (int i = 0; i < codes.length; ++i) { String url = "/test" + i; Map<String, HttpStatus> mcmap = new HashMap<String, HttpStatus>(); for (int j = 0; j < methods.length; ++j) { mcmap.put(methods[j], codes[i][j]); } jettyContext.addServlet(new ServletHolder(new StatusCodeServlet(mcmap)), url); parameters.add(new Object[] { BASE_URL + url, mcmap }); } server.start(); int i = 0; while (!server.isStarted() && i < 20) { Thread.sleep(200); ++i; } if (!server.isStarted()) { Assert.fail("server not started"); } return parameters; }
From source file:org.openbaton.nfvo.api.exceptions.GlobalExceptionHandler.java
@ExceptionHandler({ NotFoundException.class, NoResultException.class }) @ResponseStatus(value = HttpStatus.NOT_FOUND) protected ResponseEntity<Object> handleNotFoundException(Exception e, WebRequest request) { if (log.isDebugEnabled()) { log.error("Exception was thrown -> Return message: " + e.getMessage(), e); } else {/*from w w w . j a v a 2s . c om*/ log.error("Exception was thrown -> Return message: " + e.getMessage()); } ExceptionResource exc = new ExceptionResource("Not Found", e.getMessage()); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); return handleExceptionInternal(e, exc, headers, HttpStatus.UNPROCESSABLE_ENTITY, request); }
From source file:edu.eci.arsw.kalendan.controllers.ProjectResourceController.java
@RequestMapping(path = "/projects/{projectid}/{username}", method = RequestMethod.GET) public ResponseEntity<?> projectGetRecursoActividades(@PathVariable Integer projectid, @PathVariable String username) { try {/*w ww .j a v a 2 s . co m*/ //System.out.println("lalalalala"); //obtener datos que se enviarn a travs del API return new ResponseEntity<>(pj.getActividadesProject(projectid, username), HttpStatus.ACCEPTED); } catch (Exception ex) { Logger.getLogger(ProjectResourceController.class.getName()).log(Level.SEVERE, null, ex); return new ResponseEntity<>("No encontro Datos!", HttpStatus.NOT_FOUND); } }
From source file:com.marklogic.samplestack.web.security.ExceptionAdvice.java
/** * Not found should return 404 and a JSON body. * //from w w w . j av a 2s . c o m * @param ex * Exception that triggers a 404. * @return A JSON message body and 404 response code. */ @ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler(SamplestackNotFoundException.class) public @ResponseBody JsonNode handleNotFound(Exception ex) { return errors.makeJsonResponse(404, ex.getMessage()); }