argos/dmp-backend/web/src/main/java/eu/eudat/controllers/CommonController.java

48 lines
2.1 KiB
Java
Raw Normal View History

2018-03-28 15:24:47 +02:00
package eu.eudat.controllers;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
import eu.eudat.configurations.dynamicgrant.entities.Language;
2018-06-27 12:29:21 +02:00
import eu.eudat.logic.managers.CommonsManager;
2018-08-31 16:12:31 +02:00
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
2018-06-27 12:29:21 +02:00
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
import eu.eudat.models.data.helpers.responses.ResponseItem;
2018-03-28 15:24:47 +02:00
import eu.eudat.types.ApiMessageCode;
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;
/**
* Created by ikalyvas on 3/28/2018.
*/
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/common"})
public class CommonController {
private DynamicGrantConfiguration dynamicGrantConfiguration;
2018-05-28 11:50:42 +02:00
private ConfigLoader configLoader;
2018-03-28 15:24:47 +02:00
@Autowired
public CommonController(DynamicGrantConfiguration dynamicGrantConfiguration, ConfigLoader configLoader) {
this.dynamicGrantConfiguration = dynamicGrantConfiguration;
2018-05-28 11:50:42 +02:00
this.configLoader = configLoader;
2018-03-28 15:24:47 +02:00
}
@RequestMapping(method = RequestMethod.GET, value = {"/language"}, produces = "application/json")
public @ResponseBody
2018-05-14 08:44:35 +02:00
ResponseEntity<ResponseItem<List<Language>>> getPaged() {
List<Language> language = this.dynamicGrantConfiguration.getConfiguration().getMainExternalField().getLanguage();
2018-08-31 16:12:31 +02:00
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Language>>().status(ApiMessageCode.NO_MESSAGE).payload(language));
2018-03-28 15:24:47 +02:00
}
2018-05-28 11:50:42 +02:00
@RequestMapping(method = RequestMethod.GET, value = {"/externalSourcesConfiguration"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<ExternalSourcesConfiguration>> getExternalSourcesConfiguration() {
2018-08-31 16:12:31 +02:00
ExternalSourcesConfiguration configuration = CommonsManager.getExternalSourcesConfiguration(configLoader);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalSourcesConfiguration>().status(ApiMessageCode.NO_MESSAGE).payload(configuration));
2018-05-28 11:50:42 +02:00
}
2018-03-28 15:24:47 +02:00
}