/** GET /projects -> get all the projects. */ @RequestMapping( value = "/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed @Transactional(readOnly = true) public List<ProjectDTO> getAllProjects() { log.debug("REST request to get all Projects"); return projectService.findAll(); }
/** GET /projects/:id -> get the "id" project. */ @RequestMapping( value = "/projects/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<ProjectDTO> getProject(@PathVariable String id) { log.debug("REST request to get Project : {}", id); ProjectDTO projectDTO = projectService.findOne(id); return Optional.ofNullable(projectDTO) .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }
/** DELETE /projects/:id -> delete the "id" project. */ @RequestMapping( value = "/projects/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Void> deleteProject(@PathVariable String id) { log.debug("REST request to delete Project : {}", id); projectService.delete(id); return ResponseEntity.ok() .headers(HeaderUtil.createEntityDeletionAlert("project", id.toString())) .build(); }
/** PUT /projects -> Updates an existing project. */ @RequestMapping( value = "/projects", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<ProjectDTO> updateProject(@RequestBody ProjectDTO projectDTO) throws URISyntaxException { log.debug("REST request to update Project : {}", projectDTO); if (projectDTO.getId() == null) { return createProject(projectDTO); } ProjectDTO result = projectService.save(projectDTO); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("project", projectDTO.getId().toString())) .body(result); }
/** POST /projects -> Create a new project. */ @RequestMapping( value = "/projects", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<ProjectDTO> createProject(@RequestBody ProjectDTO projectDTO) throws URISyntaxException { log.debug("REST request to save Project : {}", projectDTO); if (projectDTO.getId() != null) { return ResponseEntity.badRequest() .headers( HeaderUtil.createFailureAlert( "project", "idexists", "A new project cannot already have an ID")) .body(null); } ProjectDTO result = projectService.save(projectDTO); return ResponseEntity.created(new URI("/api/projects/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert("project", result.getId().toString())) .body(result); }