If RDA Export fail show properly an error message
This commit is contained in:
parent
5fe0d40b7e
commit
9dd76a739d
|
@ -173,8 +173,12 @@ public class DMPs extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IOException {
|
||||
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||
try {
|
||||
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, principal);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(new ResponseItem<>().message(e.getMessage()).status(ApiMessageCode.ERROR_MESSAGE));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
|
||||
|
|
|
@ -352,11 +352,19 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
downloadJson(id: string) {
|
||||
this.dmpService.downloadJson(id)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(response => {
|
||||
const blob = new Blob([response.body], { type: 'application/json' });
|
||||
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||
.subscribe(complete => {
|
||||
const blob = new Blob([complete.body], { type: 'application/json' });
|
||||
const filename = this.getFilenameFromContentDispositionHeader(complete.headers.get('Content-Disposition'));
|
||||
FileSaver.saveAs(blob, filename);
|
||||
})
|
||||
}, async error => {
|
||||
this.onExportCallbackError(error);
|
||||
});
|
||||
}
|
||||
|
||||
async onExportCallbackError(error: any) {
|
||||
const errorJsonText = await error.error.text();
|
||||
const errorObj = JSON.parse(errorJsonText);
|
||||
this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error);
|
||||
}
|
||||
|
||||
getFilenameFromContentDispositionHeader(header: string): string {
|
||||
|
|
Loading…
Reference in New Issue