Skip to content
Snippets Groups Projects
Commit bbdd9290 authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

fixed create collection

parent 8c30f6fc
Branches
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package it.inaf.oats.vospace; package it.inaf.oats.vospace;
import it.inaf.ia2.aa.data.User; import it.inaf.ia2.aa.data.User;
import it.inaf.oats.vospace.datamodel.collections.NodeCollection;
import it.inaf.oats.vospace.datamodel.collections.NodeCollectionsWrapper; import it.inaf.oats.vospace.datamodel.collections.NodeCollectionsWrapper;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.DeleteMapping; ...@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
...@@ -47,11 +49,11 @@ public class CollectionsController { ...@@ -47,11 +49,11 @@ public class CollectionsController {
// create a new collection with specified title // create a new collection with specified title
@PutMapping(value = "/collections") @PutMapping(value = "/collections")
public ResponseEntity<String> createCollection( public ResponseEntity<String> createCollection(
@RequestBody String collectionName, User principal) { @RequestBody NodeCollection nc, User principal) {
LOG.debug("create collection called with name {} called for user {}", 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"); return ResponseEntity.ok("Collection created");
} }
...@@ -59,11 +61,11 @@ public class CollectionsController { ...@@ -59,11 +61,11 @@ public class CollectionsController {
// delete collection by id // delete collection by id
@DeleteMapping(value = "/collections") @DeleteMapping(value = "/collections")
public ResponseEntity<String> deleteCollection( public ResponseEntity<String> deleteCollection(
@RequestBody Long collectionId, User principal) { @RequestParam("id") Long id, User principal) {
LOG.debug("delete collection called with id {} for user {}", 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"); return ResponseEntity.ok("Collection deleted");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment