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:edu.sjsu.cmpe275.project.controller.RoomController.java
/** Get a room * @param roomNo Room No/*from w w w . j a va 2 s . co m*/ * @return void */ @RequestMapping(value = "/{id}", method = RequestMethod.GET) public ResponseEntity<?> getRoomJson(@PathVariable("id") String roomNo) { Room room = roomDao.getRoom(roomNo); if (room == null) { return new ResponseEntity<Object>(null, HttpStatus.NOT_FOUND); } else { return new ResponseEntity<>(room, HttpStatus.OK); } }
From source file:fi.helsinki.opintoni.config.WebConfigurer.java
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return (container -> { ErrorPage error403Page = new ErrorPage(HttpStatus.FORBIDDEN, "/errors/403.html"); ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/errors/404.html"); ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/errors/500.html"); container.addErrorPages(error403Page, error404Page, error500Page); });// ww w. j av a 2 s. com }
From source file:things.view.rest.ThingRestExceptionHandler.java
@ExceptionHandler(NoSuchThingException.class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody// w w w . j a va2 s.com public ErrorInfo noSuchThingException(final HttpServletRequest req, final NoSuchThingException ex) { myLogger.debug("NoSuchEntityException: " + ex.getLocalizedMessage(), ex); return new ErrorInfo(req.getRequestURL().toString(), ex); }
From source file:org.swarmcom.jsynapse.controller.client.api.v1.AuthenticationRestApiTest.java
@Test public void testRegisterAndLoginPassword() throws Exception { // login with user not registered postAndCheckStatus("/_matrix/client/api/v1/login", postLoginRequest, HttpStatus.NOT_FOUND); // register//from w w w.j a va2 s . co m postAndCompareResult("/_matrix/client/api/v1/register", postLoginRequest, postLoginResponse); // login postAndCompareResult("/_matrix/client/api/v1/login", postLoginRequest, postLoginResponse); // register with an existing user postAndCheckStatus("/_matrix/client/api/v1/register", postLoginRequest, HttpStatus.CONFLICT); }
From source file:net.bluewizardhat.tfa.web.controller.AbstractBaseController.java
/** * Returns a 404 Not Found HTTP error code if a controller method throws a {@link NotFoundException} *//*ww w. j a va 2 s . co m*/ @ExceptionHandler(NotFoundException.class) @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "The requested resource was not found") public void handleNotFound() { }
From source file:ru.portal.config.WebConfig.java
@Bean public SimpleMappingExceptionResolver simpleMappingExceptionResolver() { SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver(); resolver.setDefaultErrorView("404"); resolver.setDefaultStatusCode(HttpStatus.NOT_FOUND.value()); resolver.setOrder(1);/* www . j a v a2 s.co m*/ return resolver; }
From source file:com.envision.envservice.rest.UserResource.java
@GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON)//from www. jav a2 s.co m public Response queryUser(@PathParam("id") String id) throws Exception { HttpStatus status = HttpStatus.OK; String repsonse = null; paramCheck(id); UserBo user = userService.queryUser(id); if (user != null) { repsonse = JSONObject.toJSONString(user, buildLimitFieldFilter()); } else { status = HttpStatus.NOT_FOUND; repsonse = FailResult.toJson(Code.USER_NOT_FOUND, ""); } return Response.status(status.value()).entity(repsonse).build(); }
From source file:com.haulmont.restapi.controllers.FileDownloadController.java
@GetMapping("/{fileDescriptorId}") public void downloadFile(@PathVariable String fileDescriptorId, @RequestParam(required = false) Boolean attachment, HttpServletResponse response) { UUID uuid;/*w w w. j av a 2 s. co m*/ try { uuid = UUID.fromString(fileDescriptorId); } catch (IllegalArgumentException e) { throw new RestAPIException("Invalid entity ID", String.format("Cannot convert %s into valid entity ID", fileDescriptorId), HttpStatus.BAD_REQUEST); } LoadContext<FileDescriptor> ctx = LoadContext.create(FileDescriptor.class).setId(uuid); FileDescriptor fd = dataService.load(ctx); if (fd == null) { throw new RestAPIException("File not found", "File not found. Id: " + fileDescriptorId, HttpStatus.NOT_FOUND); } try { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); response.setHeader("Content-Type", getContentType(fd)); response.setHeader("Content-Disposition", (BooleanUtils.isTrue(attachment) ? "attachment" : "inline") + "; filename=\"" + fd.getName() + "\""); downloadFromMiddlewareAndWriteResponse(fd, response); } catch (Exception e) { log.error("Error on downloading the file {}", fileDescriptorId, e); throw new RestAPIException("Error on downloading the file", "", HttpStatus.INTERNAL_SERVER_ERROR); } }
From source file:locksdemo.LocksController.java
@ExceptionHandler(NoSuchLockException.class) @ResponseBody/*from w w w. ja va 2 s . com*/ public ResponseEntity<Map<String, Object>> noSuchLock() { Map<String, Object> body = new HashMap<String, Object>(); body.put("status", "INVALID"); body.put("description", "Lock not found"); return new ResponseEntity<Map<String, Object>>(body, HttpStatus.NOT_FOUND); }
From source file:org.ff4j.spring.boot.exceptions.FF4jExceptionHandler.java
@ExceptionHandler(value = RoleNotExistsException.class) @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "role does not exist") public void roleNotExistsException() { // Not necessary to handle this exception }