/** 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); }