From 44bb67936b892d8ef02d6fe49d5436591eac651d Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Fri, 21 Oct 2022 17:26:19 -0700 Subject: [PATCH] Add starred get endpoint --- .../com/wisemapping/rest/MindmapController.java | 14 ++++++++++++++ .../wisemapping/test/rest/RestMindmapITCase.java | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index da86633b..8dba8df1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -462,6 +462,20 @@ public class MindmapController extends BaseController { mindmapService.updateCollaboration(user, collaboration.get()); } + @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/starred", produces = {"text/plain"}) + @ResponseBody + public String fetchStarred(@PathVariable int id) throws WiseMappingException { + final Mindmap mindmap = findMindmapById(id); + final User user = Utils.getUser(); + + final Optional collaboration = mindmap.findCollaboration(user); + if (!collaboration.isPresent()) { + throw new WiseMappingException("No enough permissions."); + } + boolean result = collaboration.get().getCollaborationProperties().getStarred(); + return Boolean.toString(result); + } + @RequestMapping(method = RequestMethod.DELETE, value = "/maps/batch") @ResponseStatus(value = HttpStatus.NO_CONTENT) public void batchDelete(@RequestParam() String ids) throws IOException, WiseMappingException { diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java index cf4f2586..72334816 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java @@ -227,7 +227,7 @@ public class RestMindmapITCase { Optional mindmapInfo = fetchMap(requestHeaders, template, mapId); // @todo: Enforce check... -// assertTrue(mindmapInfo.get().getStarred() == true); + assertTrue(mindmapInfo.get().getStarred() == true); } @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")