package eu.eudat.controllers; import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration; import eu.eudat.configurations.dynamicgrant.entities.Language; import eu.eudat.logic.managers.CommonsManager; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration; import eu.eudat.models.data.helpers.responses.ResponseItem; 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; private ConfigLoader configLoader; @Autowired public CommonController(DynamicGrantConfiguration dynamicGrantConfiguration, ConfigLoader configLoader) { this.dynamicGrantConfiguration = dynamicGrantConfiguration; this.configLoader = configLoader; } @RequestMapping(method = RequestMethod.GET, value = {"/language"}, produces = "application/json") public @ResponseBody ResponseEntity>> getPaged() { List language = this.dynamicGrantConfiguration.getConfiguration().getMainExternalField().getLanguage(); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(language)); } @RequestMapping(method = RequestMethod.GET, value = {"/externalSourcesConfiguration"}, produces = "application/json") public @ResponseBody ResponseEntity> getExternalSourcesConfiguration() { ExternalSourcesConfiguration configuration = CommonsManager.getExternalSourcesConfiguration(configLoader); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(configuration)); } }