From bbdd9290ba340e3d5a4ce4a2349d56902f5b0cf3 Mon Sep 17 00:00:00 2001 From: Nicola Fulvio Calabria <nicola.calabria@inaf.it> Date: Wed, 22 Mar 2023 23:15:13 +0100 Subject: [PATCH] fixed create collection --- .../inaf/oats/vospace/CollectionsController.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/inaf/oats/vospace/CollectionsController.java b/src/main/java/it/inaf/oats/vospace/CollectionsController.java index 3c50a24..b28ce23 100644 --- a/src/main/java/it/inaf/oats/vospace/CollectionsController.java +++ b/src/main/java/it/inaf/oats/vospace/CollectionsController.java @@ -6,6 +6,7 @@ package it.inaf.oats.vospace; import it.inaf.ia2.aa.data.User; +import it.inaf.oats.vospace.datamodel.collections.NodeCollection; import it.inaf.oats.vospace.datamodel.collections.NodeCollectionsWrapper; import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -47,11 +49,11 @@ public class CollectionsController { // create a new collection with specified title @PutMapping(value = "/collections") public ResponseEntity<String> createCollection( - @RequestBody String collectionName, User principal) { + @RequestBody NodeCollection nc, User principal) { LOG.debug("create collection called with name {} called for user {}", - collectionName, principal.getName()); + nc.getTitle(), principal.getName()); - collectionsService.createNewCollection(collectionName, principal.getName()); + collectionsService.createNewCollection(nc.getTitle(), principal.getName()); return ResponseEntity.ok("Collection created"); } @@ -59,11 +61,11 @@ public class CollectionsController { // delete collection by id @DeleteMapping(value = "/collections") public ResponseEntity<String> deleteCollection( - @RequestBody Long collectionId, User principal) { + @RequestParam("id") Long id, User principal) { LOG.debug("delete collection called with id {} for user {}", - collectionId, principal.getName()); + id, principal.getName()); - collectionsService.deleteCollectionById(collectionId, principal.getName()); + collectionsService.deleteCollectionById(id, principal.getName()); return ResponseEntity.ok("Collection deleted"); -- GitLab