package eu.eudat.controllers; import eu.eudat.data.entities.Dataset; import eu.eudat.data.query.items.table.dataset.DatasetTableRequest; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.services.ApiContext; import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.listingmodels.DatasetListingModel; import eu.eudat.models.data.security.Principal; import eu.eudat.types.ApiMessageCode; import eu.eudat.types.Authorities; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.Locale; import java.util.UUID; @RestController @CrossOrigin @RequestMapping(value = {"/api"}) public class Datasets extends BaseController { @Autowired public Datasets(ApiContext apiContext) { super(apiContext); } @RequestMapping(method = RequestMethod.POST, value = {"/datasets/getPaged"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception { DataTableData dataTable = new DatasetManager().getPaged(this.getApiContext(), datasetTableRequest, principal); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); } @Transactional @RequestMapping(method = RequestMethod.GET, value = {"/datasets/makepublic/{id}"}, produces = "application/json") public @ResponseBody ResponseEntity> makePublic(@PathVariable UUID id, Principal principal, Locale locale) throws Exception { DatasetManager.makePublic(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message(this.getApiContext().getHelpersService().getMessageSource().getMessage("dataset.public", new Object[]{}, locale))); } }