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

Partial implementation of node collections controller

parent 02a698bb
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,7 @@ public class VOSpaceClient { ...@@ -86,7 +86,7 @@ public class VOSpaceClient {
return call(request, BodyHandlers.ofInputStream(), 200, res -> unmarshal(res, Node.class)); return call(request, BodyHandlers.ofInputStream(), 200, res -> unmarshal(res, Node.class));
} }
public List<NodeCollection> getNodeCollections(Optional<String> token) { public NodeCollectionsWrapper getNodeCollections(Optional<String> token) {
HttpRequest request = getRequest("/collections", token) HttpRequest request = getRequest("/collections", token)
.header("Accept", useJson ? "application/json" : "text/xml") .header("Accept", useJson ? "application/json" : "text/xml")
...@@ -94,7 +94,7 @@ public class VOSpaceClient { ...@@ -94,7 +94,7 @@ public class VOSpaceClient {
.build(); .build();
return call(request, BodyHandlers.ofInputStream(), 200, return call(request, BodyHandlers.ofInputStream(), 200,
res -> unmarshal(res, NodeCollectionsWrapper.class)).getNodeCollections(); res -> unmarshal(res, NodeCollectionsWrapper.class));
} }
public JobSummary startTransferJob(Transfer transfer, Optional<String> token) { public JobSummary startTransferJob(Transfer transfer, Optional<String> token) {
......
/*
* This file is part of vospace-ui
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package it.inaf.ia2.vospace.ui.controller;
import it.inaf.ia2.aa.data.User;
import it.inaf.ia2.vospace.ui.TokenProvider;
import it.inaf.ia2.vospace.ui.client.VOSpaceClient;
import it.inaf.oats.vospace.datamodel.collections.NodeCollectionsWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class NodeCollectionsController extends BaseController {
private static final Logger LOG = LoggerFactory.getLogger(NodeCollectionsController.class);
@Autowired
private VOSpaceClient client;
@Autowired
private TokenProvider tokenProvider;
@GetMapping(value = "/collections", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<NodeCollectionsWrapper> listNodeCollections(User principal)
throws Exception
{
LOG.debug("listNodeCollections called for user {}", principal.getName());
NodeCollectionsWrapper ncw =
client.getNodeCollections(tokenProvider.getToken());
return ResponseEntity.ok(ncw);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment