Add new endpoint in order to validate datasets
This commit is contained in:
parent
15c3a6fcb5
commit
1d5befaf6a
|
@ -280,6 +280,18 @@ public class Datasets extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/validate"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Boolean>> validate(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
|
||||
try {
|
||||
Dataset dataset = datasetManager.getEntitySingle(id);
|
||||
datasetManager.checkDatasetValidation(dataset);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Valid"));
|
||||
} catch (Exception datasetWizardCannotUnlockException) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Boolean>().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Data Import
|
||||
* */
|
||||
|
|
|
@ -351,6 +351,10 @@ public class DatasetManager {
|
|||
return dataset;
|
||||
}
|
||||
|
||||
public Dataset getEntitySingle(UUID id) {
|
||||
return databaseRepository.getDatasetDao().find(id);
|
||||
}
|
||||
|
||||
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, eu.eudat.data.entities.Dataset datasetEntity) {
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
||||
datasetprofile.setStatus(dataset.getStatus());
|
||||
|
@ -653,7 +657,7 @@ public class DatasetManager {
|
|||
|
||||
}
|
||||
|
||||
private void checkDatasetValidation(Dataset dataset) throws Exception {
|
||||
public void checkDatasetValidation(Dataset dataset) throws Exception {
|
||||
List<String> datasetProfileValidators = new LinkedList<>();
|
||||
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(dataset.getProfile().getId());
|
||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
||||
|
|
Loading…
Reference in New Issue