2022-01-21 14:44:51 +01:00
|
|
|
package eu.eudat.controllers;
|
|
|
|
|
2023-10-18 17:52:03 +02:00
|
|
|
import eu.eudat.authorization.Permission;
|
2022-01-21 14:44:51 +01:00
|
|
|
import eu.eudat.logic.managers.TaxonomyManager;
|
|
|
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
|
|
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
|
|
import eu.eudat.logic.services.ApiContext;
|
|
|
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
|
|
import eu.eudat.models.data.taxonomy.TaxonomyModel;
|
|
|
|
import eu.eudat.types.ApiMessageCode;
|
2023-10-18 17:52:03 +02:00
|
|
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
2022-01-21 14:44:51 +01:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
|
|
|
@RequestMapping(value = {"/api/external/taxonomies"})
|
|
|
|
public class TaxonomiesController extends BaseController {
|
|
|
|
|
|
|
|
private TaxonomyManager taxonomyManager;
|
2023-10-18 17:52:03 +02:00
|
|
|
private final AuthorizationService authorizationService;
|
2022-01-21 14:44:51 +01:00
|
|
|
|
|
|
|
@Autowired
|
2023-10-18 17:52:03 +02:00
|
|
|
public TaxonomiesController(ApiContext apiContext, TaxonomyManager taxonomyManager, AuthorizationService authorizationService) {
|
2022-01-21 14:44:51 +01:00
|
|
|
super(apiContext);
|
|
|
|
this.taxonomyManager = taxonomyManager;
|
2023-10-18 17:52:03 +02:00
|
|
|
this.authorizationService = authorizationService;
|
2022-01-21 14:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseEntity<ResponseItem<List<TaxonomyModel>>> listExternalPublications(
|
2023-10-18 17:52:03 +02:00
|
|
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
2022-01-21 14:44:51 +01:00
|
|
|
) throws HugeResultSet, NoURLFound {
|
2023-10-18 17:52:03 +02:00
|
|
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
|
|
|
2022-01-21 14:44:51 +01:00
|
|
|
List<TaxonomyModel> taxonomyModels = this.taxonomyManager.getTaxonomies(query, type);
|
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<TaxonomyModel>>().status(ApiMessageCode.NO_MESSAGE).payload(taxonomyModels));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|