Fixes bug on being able to fetch deleted DMPs on "DMP overview" view.
This commit is contained in:
parent
116aa365c5
commit
691508aa0c
|
@ -115,9 +115,13 @@ public class DMPs extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity getOverviewSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
ResponseEntity getOverviewSingle(@PathVariable String id, Principal principal) {
|
||||||
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal);
|
try {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.ERROR_MESSAGE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
|
||||||
|
|
|
@ -359,8 +359,11 @@ public class DataManagementPlanManager {
|
||||||
return dataManagementPlan;
|
return dataManagementPlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanOverviewModel getOverviewSingle(String id, Principal principal) throws InstantiationException, IllegalAccessException {
|
public DataManagementPlanOverviewModel getOverviewSingle(String id, Principal principal) throws Exception {
|
||||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||||
|
if (dataManagementPlanEntity.getStatus() == DMP.DMPStatus.DELETED.getValue()) {
|
||||||
|
throw new Exception("DMP is deleted.");
|
||||||
|
}
|
||||||
if (dataManagementPlanEntity.getUsers()
|
if (dataManagementPlanEntity.getUsers()
|
||||||
.stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
|
.stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
|
|
|
@ -69,7 +69,11 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DMPS'), url: "/plans" });
|
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DMPS'), url: "/plans" });
|
||||||
breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/overview/' + this.dmp.id });
|
breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/overview/' + this.dmp.id });
|
||||||
this.breadCrumbs = observableOf(breadCrumbs);
|
this.breadCrumbs = observableOf(breadCrumbs);
|
||||||
})
|
}, (error: any) => {
|
||||||
|
if (error.status === 404) {
|
||||||
|
return this.onFetchingDeletedCallbackError('/plans/');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (publicId != null) {
|
else if (publicId != null) {
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
|
@ -84,11 +88,20 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), url: "/explore-plans" });
|
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), url: "/explore-plans" });
|
||||||
breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/publicOverview/' + this.dmp.id });
|
breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/publicOverview/' + this.dmp.id });
|
||||||
this.breadCrumbs = observableOf(breadCrumbs);
|
this.breadCrumbs = observableOf(breadCrumbs);
|
||||||
|
}, (error: any) => {
|
||||||
|
if (error.status === 404) {
|
||||||
|
return this.onFetchingDeletedCallbackError('/plans/');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onFetchingDeletedCallbackError(redirectRoot: string) {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-OVERVIEW.ERROR.DELETED-DMP'), SnackBarNotificationLevel.Error);
|
||||||
|
this.router.navigate([redirectRoot]);
|
||||||
|
}
|
||||||
|
|
||||||
setIsUserOwner() {
|
setIsUserOwner() {
|
||||||
if (this.dmp) {
|
if (this.dmp) {
|
||||||
const principal: Principal = this.authentication.current();
|
const principal: Principal = this.authentication.current();
|
||||||
|
|
|
@ -502,6 +502,9 @@
|
||||||
"LEVEL-OF-ACCESS": "Level of Access",
|
"LEVEL-OF-ACCESS": "Level of Access",
|
||||||
"INVOLVED-DATASETS": "Involved Dataset Descriptions",
|
"INVOLVED-DATASETS": "Involved Dataset Descriptions",
|
||||||
"TEMPLATES-INVOLVED": "Dataset Description Templates Involved"
|
"TEMPLATES-INVOLVED": "Dataset Description Templates Involved"
|
||||||
|
},
|
||||||
|
"ERROR": {
|
||||||
|
"DELETED-DMP": "The requested DMP is deleted"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DATASET-LISTING": {
|
"DATASET-LISTING": {
|
||||||
|
|
Loading…
Reference in New Issue