Improved Dataset error handling when retrieving data
This commit is contained in:
parent
d4e4d5ca13
commit
e6da46730b
|
@ -149,17 +149,15 @@ public class Datasets extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
if (e instanceof UnauthorisedException) {
|
if (e instanceof UnauthorisedException) {
|
||||||
if (e instanceof UnauthorisedException) {
|
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
} else if (e instanceof NoResultException) {
|
||||||
} else if (e instanceof NoResultException) {
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
} else {
|
||||||
} else {
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null; // ????
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDatasets/paged"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDatasets/paged"}, produces = "application/json")
|
||||||
|
|
|
@ -299,7 +299,11 @@ public class DatasetManager {
|
||||||
Stream<DatasetProfile> sorted = profileVersionsIncluded.stream().sorted(Comparator.comparing(DatasetProfile::getVersion).reversed());
|
Stream<DatasetProfile> sorted = profileVersionsIncluded.stream().sorted(Comparator.comparing(DatasetProfile::getVersion).reversed());
|
||||||
|
|
||||||
// Make the Stream into List and get the first item.
|
// Make the Stream into List and get the first item.
|
||||||
DatasetProfile profile = sorted.collect(Collectors.toList()).iterator().next();
|
List<DatasetProfile> profiles = sorted.collect(Collectors.toList());
|
||||||
|
if (profiles.isEmpty())
|
||||||
|
throw new NoSuchElementException("No profiles found for the specific Dataset");
|
||||||
|
|
||||||
|
DatasetProfile profile = profiles.get(0);
|
||||||
|
|
||||||
// Check if the dataset is on the latest Version.
|
// Check if the dataset is on the latest Version.
|
||||||
boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString());
|
boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString());
|
||||||
|
|
Loading…
Reference in New Issue