Beispiel #1
0
 @RequestMapping(value = "/{storyId}", method = RequestMethod.PUT)
 @Interceptors({ProjectMemberRequired.class})
 @ResponseBody
 @Caching(
     evict = {
       @CacheEvict(value = GET_STORIES_CACHE, key = "#projectId + '*'"),
       @CacheEvict(value = IterationApiController.ITERATION_CACHE_NAME, key = "#projectId + '*'"),
       @CacheEvict(value = IterationApiController.ITERATIONS_CACHE_NAME, key = "#projectId + '*'")
     })
 public StoryDTO updateStory(
     @PathVariable("companyId") int companyId,
     @PathVariable("projectId") int projectId,
     @PathVariable("storyId") int storyId,
     @Valid @RequestBody StoryForm form) {
   Story story = storyService.getStoryByIdWithoutChilds(storyId);
   form.setId(storyId);
   if (form.getParentStoryId() != null && form.getParentStoryId() != story.getParentStoryId()) {
     boolean succeed = storyService.changeStoryParentStoryId(storyId, form.getParentStoryId());
     if (!succeed) {
       throw new BadRequestException();
     }
   }
   storyService.updateStoryWithoutChangingParent(form);
   Story updatedStory = storyService.getById(story.getId());
   StoryDTO storyDTO = StoryTransform.storyToStoryDTO(updatedStory);
   fillStoryDTO(storyDTO);
   return storyDTO;
 }
Beispiel #2
0
 @RequestMapping(value = "/{storyId}/complete", method = RequestMethod.PUT)
 @Interceptors({ProjectMemberRequired.class})
 @ResponseStatus(HttpStatus.OK)
 @Caching(
     evict = {
       @CacheEvict(value = GET_STORIES_CACHE, key = "#projectId + '*'"),
       @CacheEvict(value = IterationApiController.ITERATION_CACHE_NAME, key = "#projectId + '*'"),
       @CacheEvict(value = IterationApiController.ITERATIONS_CACHE_NAME, key = "#projectId + '*'")
     })
 public void completeStory(
     @PathVariable("companyId") int companyId,
     @PathVariable("projectId") int projectId,
     @PathVariable("storyId") int storyId) {
   Story story = storyService.getById(storyId);
   if (!story.getCompletable()) {
     throw new NoPermissionException("user cannot complete an uncompletable story!");
   }
   Story newStory = new Story();
   newStory.setId(storyId);
   newStory.setCompleted(true);
   storyService.updateStoryWithoutChangingParent(newStory);
 }