diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/tag/UserTagController.java b/src/main/java/org/wise/portal/presentation/web/controllers/tag/UserTagController.java index e05cb15cd..7b06e435f 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/tag/UserTagController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/tag/UserTagController.java @@ -62,8 +62,12 @@ protected ResponseEntity>> getTags(Authentication auth) protected ResponseEntity> updateTag(Authentication auth, @PathVariable("tagId") Long tagId, @RequestBody Map tag) { User user = userService.retrieveUserByUsername(auth.getName()); + String tagText = ((String) tag.get("text")).trim(); + if (userTagsService.hasTag(user, tagText)) { + return ResponseEntityGenerator.createError("tagAlreadyExists"); + } UserTag userTag = userTagsService.get(tagId); - userTag.setText((String) tag.get("text")); + userTag.setText(tagText); userTagsService.updateTag(user, userTag); return ResponseEntityGenerator.createSuccess(userTag.toMap()); }