Skip to content
CreateNodeController.java 1.02 KiB
Newer Older
Sara Bertocco's avatar
Sara Bertocco committed
package it.inaf.oats.vospace;

Sara Bertocco's avatar
Sara Bertocco committed
import net.ivoa.xml.vospace.v2.Node;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import it.inaf.oats.vospace.persistence.NodeDAO;
import java.util.List;
import org.springframework.web.bind.annotation.PutMapping;
Sara Bertocco's avatar
Sara Bertocco committed

@RestController
public class CreateNodeController extends BaseNodeController {
Sara Bertocco's avatar
Sara Bertocco committed

    @Autowired
    private NodeDAO nodeDao;

    @PutMapping(value = {"/nodes", "/nodes/**"},
Sara Bertocco's avatar
Sara Bertocco committed
            consumes = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE},
            produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE})
    public Node createNode(@RequestBody Node node, User principal) {

        String path = getPath();
Sara Bertocco's avatar
Sara Bertocco committed

        List<String> userGroups = principal.getGroups();

        nodeDao.createNode(node);
        return node;
Sara Bertocco's avatar
Sara Bertocco committed
    }
}