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));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
if (e instanceof UnauthorisedException) {
|
||||
if (e instanceof UnauthorisedException) {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
} else if (e instanceof NoResultException) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
} else if (e instanceof NoResultException) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||
}
|
||||
}
|
||||
return null; // ????
|
||||
}
|
||||
|
||||
@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());
|
||||
|
||||
// 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.
|
||||
boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString());
|
||||
|
|
Loading…
Reference in New Issue