Add starred get endpoint

main
Paulo Gustavo Veiga 2022-10-21 17:26:19 -07:00
parent 6b220ccb81
commit 44bb67936b
2 changed files with 15 additions and 1 deletions

View File

@ -462,6 +462,20 @@ public class MindmapController extends BaseController {
mindmapService.updateCollaboration(user, collaboration.get()); 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> 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") @RequestMapping(method = RequestMethod.DELETE, value = "/maps/batch")
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void batchDelete(@RequestParam() String ids) throws IOException, WiseMappingException { public void batchDelete(@RequestParam() String ids) throws IOException, WiseMappingException {

View File

@ -227,7 +227,7 @@ public class RestMindmapITCase {
Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId); Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId);
// @todo: Enforce check... // @todo: Enforce check...
// assertTrue(mindmapInfo.get().getStarred() == true); assertTrue(mindmapInfo.get().getStarred() == true);
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")