Disables Grant's "Funder" property edit by other than creation user.

This commit is contained in:
gkolokythas 2019-08-26 16:52:05 +03:00
parent efde5fe5a3
commit 44973ef3a9
1 changed files with 8 additions and 0 deletions

View File

@ -453,6 +453,14 @@ public class DataManagementPlanManager {
}
}
}
if (newDmp.getGrant().getId() != null) {
Grant grant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(newDmp.getGrant().getId());
if ( !grant.getFunder().getId().equals(newDmp.getGrant().getFunder().getId()) && !newDmp.getGrant().getCreationUser().getId().equals(user.getId())){
throw new Exception("User is not the owner of the Grant therefore, cannot edit it");
}
}
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
// Dataset manipulation for when the DMP is set to be finalized.