diff --git a/src/main/java/de/bstly/board/businesslogic/BookmarksManager.java b/src/main/java/de/bstly/board/businesslogic/BookmarksManager.java index 14714a3..66f1a7c 100644 --- a/src/main/java/de/bstly/board/businesslogic/BookmarksManager.java +++ b/src/main/java/de/bstly/board/businesslogic/BookmarksManager.java @@ -43,7 +43,7 @@ public class BookmarksManager { * Checks for entry. * * @param username the username - * @param entryId the entry id + * @param entryId the entry id * @return true, if successful */ public boolean hasEntry(String username, Long entryId) { @@ -55,7 +55,7 @@ public class BookmarksManager { * Adds the entry. * * @param username the username - * @param entryId the entry id + * @param entryId the entry id */ public void addEntry(String username, Long entryId) { Assert.isTrue(entryRepository.existsById(entryId), "Invalid entryid"); @@ -76,7 +76,7 @@ public class BookmarksManager { * Removes the entry. * * @param username the username - * @param entryId the entry id + * @param entryId the entry id */ public void removeEntry(String username, Long entryId) { Assert.isTrue(entryRepository.existsById(entryId), "Invalid entryid"); diff --git a/src/main/java/de/bstly/board/businesslogic/CommentManager.java b/src/main/java/de/bstly/board/businesslogic/CommentManager.java index 8612360..5027c06 100644 --- a/src/main/java/de/bstly/board/businesslogic/CommentManager.java +++ b/src/main/java/de/bstly/board/businesslogic/CommentManager.java @@ -43,12 +43,12 @@ public class CommentManager { /** * Fetch by ranking. * - * @param target the target - * @param parent the parent - * @param date the date + * @param target the target + * @param parent the parent + * @param date the date * @param gravity the gravity - * @param page the page - * @param size the size + * @param page the page + * @param size the size * @return the page */ @@ -68,23 +68,43 @@ public class CommentManager { * * @param target the target * @param parent the parent - * @param date the date - * @param page the page - * @param size the size + * @param date the date + * @param page the page + * @param size the size + * @param desc the desc * @return the page */ - public Page fetchByDate(Long target, Long parent, Instant date, int page, int size) { + public Page fetchByDate(Long target, Long parent, Instant date, int page, int size, + boolean desc) { + Sort sort = Sort.by(desc ? Order.desc("created") : Order.asc("created")); if (parent == null) { - return commentRepository.findAll( - qComment.target.eq(target).and(qComment.parent.isNull()) - .and(qComment.created.before(date)), - PageRequest.of(page, size, Sort.by(Order.asc("created")))); + return commentRepository + .findAll( + qComment.target.eq(target).and(qComment.parent.isNull()) + .and(qComment.created.before(date)), + PageRequest.of(page, size, sort)); } - return commentRepository.findAll( - qComment.target.eq(target).and(qComment.parent.eq(parent)) - .and(qComment.created.before(date)), - PageRequest.of(page, size, Sort.by(Order.asc("created")))); + return commentRepository.findAll(qComment.target.eq(target).and(qComment.parent.eq(parent)) + .and(qComment.created.before(date)), PageRequest.of(page, size, sort)); + } + + /** + * Fetch by username. + * + * @param username the username + * @param orElse the or else + * @param date the date + * @param page the page + * @param size the size + * @param asc the asc + * @return the page + */ + public Page fetchByUsername(String username, Long orElse, Instant date, int page, + int size, boolean asc) { + Sort sort = Sort.by(asc ? Order.asc("created") : Order.desc("created")); + return commentRepository.findAll(qComment.author.eq(username).and(qComment.parent.isNull()) + .and(qComment.created.before(date)), PageRequest.of(page, size, sort)); } /** @@ -116,7 +136,7 @@ public class CommentManager { * Apply metadata. * * @param username the username - * @param comment the comment + * @param comment the comment */ public void applyMetadata(String username, Comment comment) { if (!comment.getMetadata().containsKey("comments")) { @@ -153,7 +173,7 @@ public class CommentManager { * Apply metadata. * * @param username the username - * @param entries the entries + * @param entries the entries */ public void applyMetadata(String username, List entries) { for (Comment comment : entries) { diff --git a/src/main/java/de/bstly/board/businesslogic/EntryManager.java b/src/main/java/de/bstly/board/businesslogic/EntryManager.java index 2c5cd84..07a42ec 100644 --- a/src/main/java/de/bstly/board/businesslogic/EntryManager.java +++ b/src/main/java/de/bstly/board/businesslogic/EntryManager.java @@ -50,19 +50,16 @@ public class EntryManager { @Value("${bstly.board.ranking.gravity:1.8}") private double GRAVITY; - - /** - * Direct fetch by ranking. + * Fetch by ranking. * - * @param date the date + * @param date the date * @param gravity the gravity - * @param page the page - * @param size the size + * @param page the page + * @param size the size * @return the page */ - public Page fetchByRanking(Instant date, double gravity, int page, - int size) { + public Page fetchByRanking(Instant date, double gravity, int page, int size) { return entryRepository.findAllByRanking(date, gravity, PageRequest.of(page, size)); } @@ -80,12 +77,28 @@ public class EntryManager { } /** - * Gets the entries. + * Fetch by user. * * @param username the username - * @param page the page - * @param size the size - * @return the entries + * @param date the date + * @param page the page + * @param size the size + * @param asc the asc + * @return the page + */ + public Page fetchByUser(String username, Instant date, int page, int size, boolean asc) { + Sort sort = Sort.by(asc ? Order.asc("created") : Order.desc("created")); + return entryRepository.findAll(qEntry.author.eq(username).and(qEntry.created.before(date)), + PageRequest.of(page, size, sort)); + } + + /** + * Fetch by bookmarks. + * + * @param username the username + * @param page the page + * @param size the size + * @return the page */ public Page fetchByBookmarks(String username, int page, int size) { Bookmarks bookmarks = bookmarksManager.get(username); @@ -102,7 +115,7 @@ public class EntryManager { * Apply metadata. * * @param username the username - * @param entry the entry + * @param entry the entry */ public void applyMetadata(String username, Entry entry) { if (!entry.getMetadata().containsKey("comments")) { @@ -142,7 +155,7 @@ public class EntryManager { * Apply metadata. * * @param username the username - * @param entries the entries + * @param entries the entries */ public void applyMetadata(String username, List entries) { for (Entry entry : entries) { diff --git a/src/main/java/de/bstly/board/businesslogic/InstantHelper.java b/src/main/java/de/bstly/board/businesslogic/InstantHelper.java index aab9d9e..aba30cf 100644 --- a/src/main/java/de/bstly/board/businesslogic/InstantHelper.java +++ b/src/main/java/de/bstly/board/businesslogic/InstantHelper.java @@ -20,7 +20,7 @@ public class InstantHelper { * Plus. * * @param instant the instant - * @param amount the amount + * @param amount the amount * @return the instant */ public static Instant plus(Instant instant, TemporalAmount amount) { @@ -30,9 +30,9 @@ public class InstantHelper { /** * Plus. * - * @param instant the instant + * @param instant the instant * @param amountToAdd the amount to add - * @param unit the unit + * @param unit the unit * @return the instant */ public static Instant plus(Instant instant, long amountToAdd, TemporalUnit unit) { @@ -43,7 +43,7 @@ public class InstantHelper { * Minus. * * @param instant the instant - * @param amount the amount + * @param amount the amount * @return the instant */ public static Instant minus(Instant instant, TemporalAmount amount) { @@ -53,9 +53,9 @@ public class InstantHelper { /** * Minus. * - * @param instant the instant + * @param instant the instant * @param amountToAdd the amount to add - * @param unit the unit + * @param unit the unit * @return the instant */ public static Instant minus(Instant instant, long amountToAdd, TemporalUnit unit) { @@ -67,7 +67,7 @@ public class InstantHelper { * Truncate. * * @param instant the instant - * @param unit the unit + * @param unit the unit * @return the instant */ public static Instant truncate(Instant instant, TemporalUnit unit) { diff --git a/src/main/java/de/bstly/board/businesslogic/UserManager.java b/src/main/java/de/bstly/board/businesslogic/UserManager.java index 4442a8c..8ffabc7 100644 --- a/src/main/java/de/bstly/board/businesslogic/UserManager.java +++ b/src/main/java/de/bstly/board/businesslogic/UserManager.java @@ -64,6 +64,12 @@ public class UserManager implements UserDetailsService, SmartInitializingSinglet * @see org.springframework.security.core.userdetails.UserDetailsService# * loadUserByUsername(java.lang.String) */ + /* + * @see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String) + */ + /* + * @see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String) + */ /* * @see * de.bstly.board.businesslogic.LocalUserManager#loadUserByUsername(java.lang. @@ -91,6 +97,12 @@ public class UserManager implements UserDetailsService, SmartInitializingSinglet * @see org.springframework.beans.factory.SmartInitializingSingleton# * afterSingletonsInstantiated() */ + /* + * @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated() + */ + /* + * @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated() + */ /* * * @see org.springframework.beans.factory.SmartInitializingSingleton# @@ -199,7 +211,7 @@ public class UserManager implements UserDetailsService, SmartInitializingSinglet * Apply metadata. * * @param username the username - * @param user the user + * @param user the user */ public void applyMetadata(String username, LocalUser user) { if (user.getUsername().equals(username) && !user.getMetadata().containsKey("self")) { diff --git a/src/main/java/de/bstly/board/businesslogic/VoteManager.java b/src/main/java/de/bstly/board/businesslogic/VoteManager.java index 30604e3..2796538 100644 --- a/src/main/java/de/bstly/board/businesslogic/VoteManager.java +++ b/src/main/java/de/bstly/board/businesslogic/VoteManager.java @@ -26,9 +26,9 @@ public class VoteManager { /** * Gets the. * - * @param author the author + * @param author the author * @param targetType the target type - * @param target the target + * @param target the target * @return the vote */ public Vote get(String author, Types targetType, Long target) { @@ -58,7 +58,7 @@ public class VoteManager { /** * Delete by target. * - * @param target the target + * @param target the target * @param targetType the target type */ public void deleteByTarget(Long target, Types targetType) { @@ -71,7 +71,7 @@ public class VoteManager { /** * Gets the points. * - * @param target the target + * @param target the target * @param targetType the target type * @return the points */ diff --git a/src/main/java/de/bstly/board/controller/BookmarksController.java b/src/main/java/de/bstly/board/controller/BookmarksController.java index 57beed1..fc8ecf7 100644 --- a/src/main/java/de/bstly/board/controller/BookmarksController.java +++ b/src/main/java/de/bstly/board/controller/BookmarksController.java @@ -27,7 +27,7 @@ import de.bstly.board.model.Entry; * The Class BookmarksController. */ @RestController -@RequestMapping("/b") +@RequestMapping("/bookmarks") public class BookmarksController extends BaseController { @Autowired diff --git a/src/main/java/de/bstly/board/controller/CommentController.java b/src/main/java/de/bstly/board/controller/CommentController.java index c9ff531..524794b 100644 --- a/src/main/java/de/bstly/board/controller/CommentController.java +++ b/src/main/java/de/bstly/board/controller/CommentController.java @@ -29,36 +29,30 @@ import de.bstly.board.model.Types; import de.bstly.board.model.Vote; import de.bstly.board.model.VoteType; - /** * The Class CommentController. */ @RestController -@RequestMapping("/c") +@RequestMapping("/comments") public class CommentController extends BaseController { - @Autowired private CommentManager commentManager; - - + @Autowired private CommentValidator commentValidator; - - + @Autowired private VoteManager voteManager; - @Value("${bstly.board.size:30}") private int SIZE; - - + @Value("${bstly.board.ranking.gravity:1.8}") private double GRAVITY; /** - * Ranked comments. + * Fetch by rank. * * @param target the target * @param parent the parent @@ -69,23 +63,70 @@ public class CommentController extends BaseController { * @return the page */ @PreAuthorize("isAuthenticated()") - @GetMapping({ "/e/{target}", "/e/{target}/{parent}" }) - public Page rankedComments(@PathVariable("target") Long target, + @GetMapping({ "/{target}", "/{target}/{parent}" }) + public Page fetchByRank(@PathVariable("target") Long target, @PathVariable("parent") Optional parent, @RequestParam("page") Optional pageParameter, @RequestParam("size") Optional sizeParameter, @RequestParam("date") Optional dateParameter, @RequestParam("gravity") Optional gravityParameter) { - Page comments = newComments(target, parent, pageParameter, sizeParameter, - dateParameter); + Page comments = fetchByDate(target, parent, pageParameter, sizeParameter, + dateParameter, Optional.of(false)); commentManager.applyMetadata(getCurrentUsername(), comments.getContent()); return comments; + } -// Page comments = commentManager.fetchByRanking(target, parent.orElse(null), -// dateParameter.orElse(Instant.now()), gravityParameter.orElse(GRAVITY), -// pageParameter.orElse(0), sizeParameter.orElse(SIZE)); -// return comments; + /** + * Fetch by date. + * + * @param target the target + * @param parent the parent + * @param pageParameter the page parameter + * @param sizeParameter the size parameter + * @param dateParameter the date parameter + * @param descParameter the desc parameter + * @return the page + */ + @PreAuthorize("isAuthenticated()") + @GetMapping({ "/new/{target}", "/new/{target}/{parent}" }) + public Page fetchByDate(@PathVariable("target") Long target, + @PathVariable("parent") Optional parent, + @RequestParam("page") Optional pageParameter, + @RequestParam("size") Optional sizeParameter, + @RequestParam("date") Optional dateParameter, + @RequestParam("desc") Optional descParameter) { + Page comments = commentManager.fetchByDate(target, parent.orElse(null), + dateParameter.orElse(Instant.now()), pageParameter.orElse(0), + sizeParameter.orElse(SIZE), descParameter.orElse(false)); + commentManager.applyMetadata(getCurrentUsername(), comments.getContent()); + return comments; + } + + /** + * Fetch by username. + * + * @param username the username + * @param parent the parent + * @param pageParameter the page parameter + * @param sizeParameter the size parameter + * @param dateParameter the date parameter + * @param ascParameter the asc parameter + * @return the page + */ + @PreAuthorize("isAuthenticated()") + @GetMapping({ "/byuser/{username}" }) + public Page fetchByUsername(@PathVariable("username") String username, + @PathVariable("parent") Optional parent, + @RequestParam("page") Optional pageParameter, + @RequestParam("size") Optional sizeParameter, + @RequestParam("date") Optional dateParameter, + @RequestParam("asc") Optional ascParameter) { + Page comments = commentManager.fetchByUsername(username, parent.orElse(null), + dateParameter.orElse(Instant.now()), pageParameter.orElse(0), + sizeParameter.orElse(SIZE), ascParameter.orElse(false)); + commentManager.applyMetadata(getCurrentUsername(), comments.getContent()); + return comments; } /** @@ -96,36 +137,12 @@ public class CommentController extends BaseController { * @return the long */ @PreAuthorize("isAuthenticated()") - @GetMapping({ "/c/{target}", "/c/{target}/{parent}" }) + @GetMapping({ "/count/{target}", "/count/{target}/{parent}" }) public Long countComments(@PathVariable("target") Long target, @PathVariable("parent") Optional parent) { return commentManager.count(target, parent.orElse(null)); } - /** - * New comments. - * - * @param target the target - * @param parent the parent - * @param pageParameter the page parameter - * @param sizeParameter the size parameter - * @param dateParameter the date parameter - * @return the page - */ - @PreAuthorize("isAuthenticated()") - @GetMapping({ "/e/new/{target}", "/e/new/{target}/{parent}" }) - public Page newComments(@PathVariable("target") Long target, - @PathVariable("parent") Optional parent, - @RequestParam("page") Optional pageParameter, - @RequestParam("size") Optional sizeParameter, - @RequestParam("date") Optional dateParameter) { - Page comments = commentManager.fetchByDate(target, parent.orElse(null), - dateParameter.orElse(Instant.now()), pageParameter.orElse(0), - sizeParameter.orElse(SIZE)); - commentManager.applyMetadata(getCurrentUsername(), comments.getContent()); - return comments; - } - /** * Gets the comment. * @@ -133,7 +150,7 @@ public class CommentController extends BaseController { * @return the comment */ @PreAuthorize("isAuthenticated()") - @GetMapping("/{id}") + @GetMapping("/comment/{id}") public Comment getComment(@PathVariable("id") Long id) { Comment comment = commentManager.get(id); @@ -153,7 +170,7 @@ public class CommentController extends BaseController { * @return the comment */ @PreAuthorize("isAuthenticated()") - @PostMapping() + @PostMapping public Comment createComment(@RequestBody Comment comment) { RequestBodyErrors bindingResult = new RequestBodyErrors(comment); commentValidator.validate(comment, bindingResult); @@ -175,7 +192,7 @@ public class CommentController extends BaseController { voteManager.save(vote); commentManager.applyMetadata(getCurrentUsername(), comment); - + return comment; } diff --git a/src/main/java/de/bstly/board/controller/EntryController.java b/src/main/java/de/bstly/board/controller/EntryController.java index 72de133..76fd37e 100644 --- a/src/main/java/de/bstly/board/controller/EntryController.java +++ b/src/main/java/de/bstly/board/controller/EntryController.java @@ -37,7 +37,7 @@ import de.bstly.board.model.VoteType; * The Class EntryController. */ @RestController -@RequestMapping("/e") +@RequestMapping("/entries") public class EntryController extends BaseController { @Autowired @@ -56,17 +56,17 @@ public class EntryController extends BaseController { private double GRAVITY; /** - * Ranked entries. + * Fetch by ranking. * - * @param pageParameter the page parameter - * @param sizeParameter the size parameter - * @param dateParameter the date parameter + * @param pageParameter the page parameter + * @param sizeParameter the size parameter + * @param dateParameter the date parameter * @param gravityParameter the gravity parameter * @return the page */ @PreAuthorize("isAuthenticated()") @GetMapping() - public Page rankedEntries(@RequestParam("page") Optional pageParameter, + public Page fetchByRanking(@RequestParam("page") Optional pageParameter, @RequestParam("size") Optional sizeParameter, @RequestParam("date") Optional dateParameter, @RequestParam("gravity") Optional gravityParameter) { @@ -89,7 +89,7 @@ public class EntryController extends BaseController { } /** - * New entries. + * Fetch by date. * * @param pageParameter the page parameter * @param sizeParameter the size parameter @@ -98,7 +98,7 @@ public class EntryController extends BaseController { */ @PreAuthorize("isAuthenticated()") @GetMapping("/new") - public Page newEntries(@RequestParam("page") Optional pageParameter, + public Page fetchByDate(@RequestParam("page") Optional pageParameter, @RequestParam("size") Optional sizeParameter, @RequestParam("date") Optional dateParameter) { @@ -112,6 +112,35 @@ public class EntryController extends BaseController { return entries; } + /** + * Fetch by user. + * + * @param username the username + * @param pageParameter the page parameter + * @param sizeParameter the size parameter + * @param dateParameter the date parameter + * @param ascParameter the asc parameter + * @return the page + */ + @PreAuthorize("isAuthenticated()") + @GetMapping("/byuser/{username}") + public Page fetchByUser(@PathVariable("username") String username, + @RequestParam("page") Optional pageParameter, + @RequestParam("size") Optional sizeParameter, + @RequestParam("date") Optional dateParameter, + @RequestParam("asc") Optional ascParameter) { + + if (sizeParameter.isPresent() && sizeParameter.get() > 100) { + sizeParameter = Optional.of(100); + } + + Page entries = entryManager.fetchByUser(username, + dateParameter.orElse(Instant.now()), pageParameter.orElse(0), + sizeParameter.orElse(SIZE), ascParameter.orElse(false)); + entryManager.applyMetadata(getCurrentUsername(), entries.getContent()); + return entries; + } + /** * Gets the entry. * @@ -119,7 +148,7 @@ public class EntryController extends BaseController { * @return the entry */ @PreAuthorize("isAuthenticated()") - @GetMapping("/{id}") + @GetMapping("/entry/{id}") public Entry getEntry(@PathVariable("id") Long id) { Entry entry = entryManager.get(id); @@ -162,7 +191,7 @@ public class EntryController extends BaseController { voteManager.save(vote); entryManager.applyMetadata(getCurrentUsername(), entry); - + return entry; } diff --git a/src/main/java/de/bstly/board/controller/ModerationController.java b/src/main/java/de/bstly/board/controller/ModerationController.java index dc8379c..2023af0 100644 --- a/src/main/java/de/bstly/board/controller/ModerationController.java +++ b/src/main/java/de/bstly/board/controller/ModerationController.java @@ -25,7 +25,7 @@ import de.bstly.board.model.LocalUser; * The Class ModerationController. */ @RestController -@RequestMapping("/m") +@RequestMapping("/moderation") public class ModerationController { @@ -46,7 +46,7 @@ public class ModerationController { * @param id the id */ @PreAuthorize("hasRole('ROLE_ADMIN') || hasRole('ROLE_MOD')") - @DeleteMapping("/c/{id}") + @DeleteMapping("/comment/{id}") public void deleteComment(@PathVariable("id") Long id) { if (!commentManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -61,7 +61,7 @@ public class ModerationController { * @param id the id */ @PreAuthorize("hasRole('ROLE_ADMIN') || hasRole('ROLE_MOD')") - @DeleteMapping("/e/{id}") + @DeleteMapping("/entry/{id}") public void deleteEntry(@PathVariable("id") Long id) { if (!entryManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -76,7 +76,7 @@ public class ModerationController { * @param username the username */ @PreAuthorize("hasRole('ROLE_ADMIN')") - @PutMapping("/u/{username}") + @PutMapping("/user/{username}") public void makeMod(@PathVariable("username") String username) { LocalUser user = userManager.getByUsername(username); @@ -103,7 +103,7 @@ public class ModerationController { * @param username the username */ @PreAuthorize("hasRole('ROLE_ADMIN')") - @DeleteMapping("/u/{username}") + @DeleteMapping("/user/{username}") public void unmakeMode(@PathVariable("username") String username) { LocalUser user = userManager.getByUsername(username); diff --git a/src/main/java/de/bstly/board/controller/UserController.java b/src/main/java/de/bstly/board/controller/UserController.java index 1a1afb0..55a03a1 100644 --- a/src/main/java/de/bstly/board/controller/UserController.java +++ b/src/main/java/de/bstly/board/controller/UserController.java @@ -24,7 +24,7 @@ import de.bstly.board.model.LocalUser; * The Class UserController. */ @RestController -@RequestMapping("/u") +@RequestMapping("/users") public class UserController extends BaseController { @@ -38,7 +38,7 @@ public class UserController extends BaseController { * @return the user */ @PreAuthorize("isAuthenticated()") - @GetMapping({ "", "/{username}" }) + @GetMapping({ "/user", "/user/{username}" }) public LocalUser getUser(@PathVariable("username") Optional usernameParameter) { String username = usernameParameter.orElse(getCurrentUsername()); @@ -68,7 +68,7 @@ public class UserController extends BaseController { * @return the local user */ @PreAuthorize("isAuthenticated()") - @PostMapping() + @PostMapping("/user") public LocalUser updateUser(@RequestBody LocalUser user) { if (!getCurrentUsername().equals(user.getUsername())) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); diff --git a/src/main/java/de/bstly/board/controller/VoteController.java b/src/main/java/de/bstly/board/controller/VoteController.java index 48fa54b..8302994 100644 --- a/src/main/java/de/bstly/board/controller/VoteController.java +++ b/src/main/java/de/bstly/board/controller/VoteController.java @@ -26,7 +26,7 @@ import de.bstly.board.model.VoteType; * The Class VoteController. */ @RestController -@RequestMapping("/v") +@RequestMapping("/votes") public class VoteController extends BaseController { @@ -48,7 +48,7 @@ public class VoteController extends BaseController { * @return the entry points */ @PreAuthorize("isAuthenticated()") - @GetMapping("/e/{id}") + @GetMapping("/entry/{id}") public long getEntryPoints(@PathVariable("id") Long id) { if (!entryManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -63,7 +63,7 @@ public class VoteController extends BaseController { * @param id the id */ @PreAuthorize("isAuthenticated()") - @PutMapping("/e/{id}/up") + @PutMapping("/entry/{id}/up") public void voteEntryUp(@PathVariable("id") Long id) { if (!entryManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -89,7 +89,7 @@ public class VoteController extends BaseController { * @param id the id */ @PreAuthorize("isAuthenticated()") - @PutMapping("/e/{id}/down") + @PutMapping("/entry/{id}/down") public void voteEntryDown(@PathVariable("id") Long id) { if (!entryManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -115,7 +115,7 @@ public class VoteController extends BaseController { * @param id the id */ @PreAuthorize("isAuthenticated()") - @DeleteMapping("/e/{id}") + @DeleteMapping("/entry/{id}") public void unvoteEntry(@PathVariable("id") Long id) { if (!entryManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -136,7 +136,7 @@ public class VoteController extends BaseController { * @return the comment points */ @PreAuthorize("isAuthenticated()") - @GetMapping("/c/{id}") + @GetMapping("/comment/{id}") public long getCommentPoints(@PathVariable("id") Long id) { if (!commentManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -151,7 +151,7 @@ public class VoteController extends BaseController { * @param id the id */ @PreAuthorize("isAuthenticated()") - @PutMapping("/c/{id}/up") + @PutMapping("/comment/{id}/up") public void voteCommentUp(@PathVariable("id") Long id) { if (!commentManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -177,7 +177,7 @@ public class VoteController extends BaseController { * @param id the id */ @PreAuthorize("isAuthenticated()") - @PutMapping("/c/{id}/down") + @PutMapping("/comment/{id}/down") public void voteCommentDown(@PathVariable("id") Long id) { if (!commentManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); @@ -203,7 +203,7 @@ public class VoteController extends BaseController { * @param id the id */ @PreAuthorize("isAuthenticated()") - @DeleteMapping("/c/{id}") + @DeleteMapping("/comment/{id}") public void unvoteComment(@PathVariable("id") Long id) { if (!commentManager.exists(id)) { throw new EntityResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY); diff --git a/src/main/java/de/bstly/board/model/Bookmarks.java b/src/main/java/de/bstly/board/model/Bookmarks.java index 048b431..cb7a6a5 100644 --- a/src/main/java/de/bstly/board/model/Bookmarks.java +++ b/src/main/java/de/bstly/board/model/Bookmarks.java @@ -36,14 +36,16 @@ public class Bookmarks { private List entries; /** - * @param username + * Instantiates a new bookmarks. */ public Bookmarks() { super(); } /** - * @param username + * Instantiates a new bookmarks. + * + * @param username the username */ public Bookmarks(String username) { super();