package eu.dnetlib.dnetrolemanagement.controllers; import com.google.gson.Gson; import com.google.gson.JsonArray; import eu.dnetlib.dnetrolemanagement.dto.Manager; import eu.dnetlib.dnetrolemanagement.services.RegistryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/registry") public class RegistryController { private RegistryService registryService; Gson gson = new Gson(); @Autowired public RegistryController(RegistryService registryService) { this.registryService = registryService; } @RequestMapping(value = "/{type}/{id}/managers/id", method = RequestMethod.GET) public ResponseEntity getManagers(@PathVariable("type") String type, @PathVariable("id") String id) { Integer couId = registryService.getCouId(type, id); if(couId != null) { JsonArray managers = registryService.getUserIdByCouId(couId, true); return ResponseEntity.ok(gson.fromJson(managers, Manager[].class)); } return null; } }