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:de.hska.ld.content.controller.CommentController.java
/** * <pre>/*from w w w.j ava 2 s.c om*/ * Gets a page of comments. * * <b>Required roles:</b> ROLE_USER * <b>Path:</b> GET /api/comments/{commentId}/comment?page-number=0&page-size=10&sort-direction=DESC&sort-property=createdAt * http://localhost/api/comments/0/comment?page-number=0&page-size=10&sort-direction=DESC&sort-property=createdAt" * http://localhos/api/comments/0/comment?page-number=0&page-size=10&sort-direction=DESC&sort-property=createdAt%20* * </pre> * * @param commentId the comment ID * @param pageNumber the page number as a request parameter (default: 0) * @param pageSize the page size as a request parameter (default: 10) * @param sortDirection the sort direction as a request parameter (default: 'DESC') * @param sortProperty the sort property as a request parameter (default: 'createdAt') * @return the requested subcomments page */ @Secured(Core.ROLE_USER) @RequestMapping(method = RequestMethod.GET, value = "/{commentId}/comment") public Callable getCommentsPage(@PathVariable Long commentId, @RequestParam(value = "page-number", defaultValue = "0") Integer pageNumber, @RequestParam(value = "page-size", defaultValue = "10") Integer pageSize, @RequestParam(value = "sort-direction", defaultValue = "DESC") String sortDirection, @RequestParam(value = "sort-property", defaultValue = "createdAt") String sortProperty) { return () -> { Page<Comment> commentsPage = commentService.getCommentCommentsPage(commentId, pageNumber, pageSize, sortDirection, sortProperty); if (commentsPage != null) { return new ResponseEntity<>(commentsPage, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }; }
From source file:com.basicservice.controller.UserController.java
@RequestMapping(value = "/login", method = RequestMethod.POST) public ResponseEntity<String> login(HttpServletRequest request, @RequestParam(value = "email") EmailValidatedString email, @RequestParam(value = "password") String password) { if (email == null || email.getValue() == null || password == null) { return new ResponseEntity<String>(HttpStatus.NOT_FOUND); }/*w ww .j a v a2 s. c om*/ User user = userService.login(email.getValue(), password); LOG.debug("Got login request: email:" + email.getValue() + ", pass:" + password); if (user == null) { try { new AppSensorException("AF1", "Authentication Failure", "Authentication Failure detected"); } catch (Exception e) { // AppSensor might throw an exception, but we want to catch it here and stop propagation } return new ResponseEntity<String>(HttpStatus.NOT_FOUND); } else if (!user.isEmailConfirmed()) { // let the user know that she can't login until she confirms the email return new ResponseEntity<String>(HttpStatus.FORBIDDEN); } user.setLastLogin(new Date()); LOG.debug("Preparing to save user to db"); userService.save(user); final HttpHeaders headers = new HttpHeaders(); headers.add("Set-Cookie", Constants.AUTHENTICATED_USER_ID_COOKIE + "=" + user.getSessionId() + "; Path=/"); return new ResponseEntity<String>(headers, HttpStatus.OK); }
From source file:com.nebhale.buildmonitor.web.ProjectController.java
@Transactional(readOnly = true) @RequestMapping(method = RequestMethod.GET, value = "/{project}", produces = MEDIA_TYPE) ResponseEntity<?> read(@PathVariable Project project) { if (project == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/*from ww w . j a va 2 s .c o m*/ return new ResponseEntity<>(this.resourceAssembler.toResource(project), HttpStatus.OK); }
From source file:za.ac.cput.project.universalhardwarestorev2.api.ItemApi.java
@RequestMapping(value = "/item/update/{id}", method = RequestMethod.PUT) public ResponseEntity<Item> updateItem(@PathVariable("id") long id, @RequestBody Item Item) { System.out.println("Updating Item " + id); Item currentItem = service.findById(id); if (currentItem == null) { System.out.println("Item with id " + id + " not found"); return new ResponseEntity<Item>(HttpStatus.NOT_FOUND); }// w ww . j a va 2s. c om Item updatedItem = new Item.Builder(currentItem.getCode()).copy(currentItem).name(Item.getName()) .description(Item.getDescription()).price(Item.getPrice()).quantity(Item.getQuantity()).build(); service.update(updatedItem); return new ResponseEntity<Item>(updatedItem, HttpStatus.OK); }
From source file:com.nicusa.controller.DrugControllerTest.java
@Test public void testGetDrugNotFound() { when(entityManager.find(Drug.class, 1L)).thenReturn(null); ResponseEntity<DrugResource> drugResourceResponseEntity = drugController.get(1L); assertThat(HttpStatus.NOT_FOUND, is(drugResourceResponseEntity.getStatusCode())); assertThat(drugResourceResponseEntity.getBody(), is(nullValue())); }
From source file:org.cloudfoundry.test.ServiceController.java
@RequestMapping(value = "/postgres", method = RequestMethod.GET) public ResponseEntity<String> getPostgresDataSourceDBUrl() { if (serviceHolder.getPostgresDataSource() == null) { return new ResponseEntity<String>(HttpStatus.NOT_FOUND); }/*from ww w . j ava 2 s . co m*/ return new ResponseEntity<String>(serviceHolder.getPostgresDataSource().getUrl(), HttpStatus.OK); }
From source file:ca.qhrtech.controllers.TableController.java
@RequestMapping(value = "/table/{id}", method = RequestMethod.PUT) public ResponseEntity<BGLTable> updateTable(@PathVariable("id") long id, @RequestBody BGLTable table) { BGLTable currentTable = tableService.findTableById(id); if (currentTable == null) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }// w ww . j a va 2 s . c o m currentTable.setCompleted(table.isCompleted()); currentTable.setGame(table.getGame()); currentTable.setInvites(new ArrayList<>(table.getInvites())); currentTable.setPollId(table.getPollId()); currentTable.setPubliclyVisible(table.isPubliclyVisible()); currentTable.setStartDate(table.getStartDate()); tableService.updateTable(currentTable); return new ResponseEntity<>(currentTable, HttpStatus.OK); }
From source file:com.artivisi.belajar.restful.ui.controller.MenuController.java
@ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler({ IllegalStateException.class }) public void handle() { logger.debug("Resource dengan URI tersebut tidak ditemukan"); }
From source file:net.cpollet.shoppist.web.controller.ShoppingListsController.java
@ExceptionHandler({ ListNotFoundException.class }) @ResponseStatus(value = HttpStatus.NOT_FOUND) @ResponseBody//from w w w . j av a 2 s.c om public RestResponse usernameError(HttpServletRequest req, Exception exception) { return RestResponseBuilder.aRestResponse() // .withHttpStatus(HttpStatus.NOT_FOUND.value()) // .withErrorStatus("ListNotFound") // .withErrorDescription(exception.getMessage()) // .build(); }
From source file:org.nekorp.workflow.backend.controller.imp.EventoControllerImp.java
@Override @RequestMapping(method = RequestMethod.POST) public void crearEvento(@PathVariable final Long idServicio, @Valid @RequestBody final Evento dato, final HttpServletResponse response) { dato.setId(null);/* ww w . ja v a 2 s .c o m*/ if (!idServicioValido(idServicio)) { response.setStatus(HttpStatus.NOT_FOUND.value()); return; } this.eventoDAO.guardar(idServicio, dato); response.setStatus(HttpStatus.CREATED.value()); response.setHeader("Location", "/servicios/" + idServicio + "/bitacora/eventos/" + dato.getId()); }