publication link comment
Merge request reports
Activity
36 @RequestMapping(UrlPath.ADMIN_PUBLICATIONS + SolidifyConstants.URL_PARENT_ID + ResourceName.COMMENTS) 37 public class PublicationCommentController extends CompositionController<Publication, Comment> { 38 39 private PersonService personService; 40 41 public PublicationCommentController(PersonService personService) { 42 this.personService = personService; 43 } 44 45 @GetMapping 46 @Override 47 public HttpEntity<Collection<Comment>> list(@PathVariable String parentid, @ModelAttribute Comment comment, Pageable pageable) { 48 return super.list(parentid, comment, pageable); 49 } 50 51 @GetMapping({"/{id}"}) No need to use
@GetMapping({"/{id}"})
since it's already in the parent method. In fact, there is no need to this method since you could use the one defined in the parent class.Edited by Alicia.DeDiosFuentechanged this line in version 2 of the diff
52 @Override 53 public HttpEntity<Comment> get(@PathVariable String parentid, @PathVariable String id) { 54 return super.get(parentid, id); 55 } 56 57 @PostMapping 58 @Override 59 public HttpEntity<Comment> create(@PathVariable final String parentid, @Valid @RequestBody final Comment comment) { 60 String authenticatedPersonId = this.personService.getLinkedPersonId(SecurityContextHolder.getContext().getAuthentication()); 61 Person person = this.personService.findOne(authenticatedPersonId); 62 //set Person 63 comment.setPerson(person); 64 return super.create(parentid, comment); 65 } 66 67 @PatchMapping({"/{id}"}) changed this line in version 2 of the diff
58 @Override 59 public HttpEntity<Comment> create(@PathVariable final String parentid, @Valid @RequestBody final Comment comment) { 60 String authenticatedPersonId = this.personService.getLinkedPersonId(SecurityContextHolder.getContext().getAuthentication()); 61 Person person = this.personService.findOne(authenticatedPersonId); 62 //set Person 63 comment.setPerson(person); 64 return super.create(parentid, comment); 65 } 66 67 @PatchMapping({"/{id}"}) 68 @Override 69 public HttpEntity<Comment> update(@PathVariable final String parentid, @PathVariable final String id, @RequestBody final Comment comment) { 70 String authenticatedPersonId = this.personService.getLinkedPersonId(SecurityContextHolder.getContext().getAuthentication()); 71 Person person = this.personService.findOne(authenticatedPersonId); 72 //set Person 73 comment.setPerson(person); Yes, but it's not implemented like that. There should be a verification that the
authenticatedPersonId
is the same as it was in the original comment. As you have implemented, it will take ownership sincecomment.setPerson(person);
without verifying if the original comment was created by the same person. You could do a commentPermissionService.Edited by Alicia.DeDiosFuentechanged this line in version 3 of the diff
62 //set Person 63 comment.setPerson(person); 64 return super.create(parentid, comment); 65 } 66 67 @PatchMapping({"/{id}"}) 68 @Override 69 public HttpEntity<Comment> update(@PathVariable final String parentid, @PathVariable final String id, @RequestBody final Comment comment) { 70 String authenticatedPersonId = this.personService.getLinkedPersonId(SecurityContextHolder.getContext().getAuthentication()); 71 Person person = this.personService.findOne(authenticatedPersonId); 72 //set Person 73 comment.setPerson(person); 74 return super.update(parentid, id, comment); 75 } 76 77 @DeleteMapping({"/{id}"}) changed this line in version 2 of the diff
- Resolved by Alicia.DeDiosFuente
- Resolved by Alicia.DeDiosFuente
7 import javax.persistence.criteria.Predicate; 8 import javax.persistence.criteria.Root; 9 import java.util.List; 10 11 import ch.unige.solidify.specification.SolidifySpecification; 12 13 public class CommentSpecification extends SolidifySpecification<Comment> { 14 15 public CommentSpecification(Comment criteria) { 16 super(criteria); 17 } 18 19 @Override 20 protected void completePredicatesList(Root<Comment> root, CriteriaQuery<?> query, CriteriaBuilder builder, List<Predicate> predicatesList) { 21 if (this.criteria.getText() != null) { 22 predicatesList.add(builder.like(root.get("code"), "%" + this.criteria.getText() + "%")); changed this line in version 3 of the diff
added 1 commit
- 1c46d9dc - refactor: reorganize import + replace string by constant inside controller
added 1 commit
- b5200ce9 - refactor: add verification of person on updating comment
added 18 commits
-
b5200ce9...7843f341 - 7 commits from branch
master
- d1236d54 - feat: publication/comment
- 3b160365 - wip
- 8cedb6f2 - test(aou): publication IT tests
- 81772fcb - test: publication
- 548e80b3 - test: publication
- 15504891 - test: publication
- 45dc3720 - refactor: publication/comment
- 6e37bf1e - test: publication/comment
- b324f29f - refactor: reorganize import + replace string by constant inside controller
- 36ebfa51 - refactor: add verification of person on updating comment
- 715abead - refactor: refactor code after rebase with master
Toggle commit list-
b5200ce9...7843f341 - 7 commits from branch
marked as a Work In Progress from 3b160365
added 12 commits
-
faef00a3 - 1 commit from branch
master
- 95dad1b4 - feat: publication/comment
- 8a192330 - wip
- 52c85972 - test(aou): publication IT tests
- 9bdc666d - test: publication
- 9e6b718f - test: publication
- 1b24672b - test: publication
- 684faf89 - refactor: publication/comment
- fce4eee2 - test: publication/comment
- f56be9f0 - refactor: reorganize import + replace string by constant inside controller
- d9dacf03 - refactor: add verification of person on updating comment
- da8475c8 - refactor: refactor code after rebase with master
Toggle commit list-
faef00a3 - 1 commit from branch