/** DELETE /projects/:id -> delete the "id" project. */ @RequestMapping( value = "/projects/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public void delete(@PathVariable Long id) { log.debug("REST request to delete Project : {}", id); projectRepository.delete(id); }
/** GET /projects -> get all the projects. */ @RequestMapping( value = "/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public List<Project> getAll() { log.debug("REST request to get all Projects"); return projectRepository.findAll(); }
/** GET /projects/:id -> get the "id" project. */ @RequestMapping( value = "/projects/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Project> get(@PathVariable Long id) { log.debug("REST request to get Project : {}", id); return Optional.ofNullable(projectRepository.findOne(id)) .map(project -> new ResponseEntity<>(project, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }
/** PUT /projects -> Updates an existing project. */ @RequestMapping( value = "/projects", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Void> update(@Valid @RequestBody Project project) throws URISyntaxException { log.debug("REST request to update Project : {}", project); if (project.getId() == null) { return create(project); } projectRepository.save(project); return ResponseEntity.ok().build(); }
/** POST /projects -> Create a new project. */ @RequestMapping( value = "/projects", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Void> create(@Valid @RequestBody Project project) throws URISyntaxException { log.debug("REST request to save Project : {}", project); if (project.getId() != null) { return ResponseEntity.badRequest() .header("Failure", "A new project cannot already have an ID") .build(); } projectRepository.save(project); return ResponseEntity.created(new URI("/api/projects/" + project.getId())).build(); }