From 0039da7c3c4a45febeb53ae5bdb8673d1f13949b Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Wed, 6 Feb 2019 13:33:30 +0200 Subject: [PATCH] end Poind Try Catch to Delete DatasetProfile --- .../src/main/java/eu/eudat/controllers/Admin.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java index e817c622b..e9a431da0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java @@ -2,6 +2,7 @@ package eu.eudat.controllers; import eu.eudat.core.logger.Logger; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; +import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException; import eu.eudat.logic.managers.AdminManager; import eu.eudat.logic.managers.DatasetProfileManager; import eu.eudat.logic.managers.UserManager; @@ -94,13 +95,12 @@ public class Admin extends BaseController { @RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> inactivate(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException { - eu.eudat.data.entities.DatasetProfile ret= AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(),this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao() , id); - if(ret!=null){ + try{ + eu.eudat.data.entities.DatasetProfile ret= AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(),this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao() , id); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); + }catch (DMPWithDatasetsDeleteException exception) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage())); + } - }else { - return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); - - } } }