Refactors Dataset update so it cannot be edited if it's DMP is public.

This commit is contained in:
gkolokythas 2019-06-24 13:00:59 +03:00
parent ae22578710
commit 425a64e60a
1 changed files with 4 additions and 1 deletions

View File

@ -316,8 +316,11 @@ public class DatasetManager {
}
public eu.eudat.data.entities.Dataset createOrUpdate(DatasetWizardModel datasetWizardModel, Principal principal) throws Exception {
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId());
if (dmp.isPublic())
throw new Exception("DMP is public, therefore Dataset cannot be edited.");
eu.eudat.data.entities.Dataset dataset = datasetWizardModel.toDataModel();
dataset.setDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId()));
dataset.setDmp(dmp);
propertiesModelToString(datasetWizardModel, dataset);
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
dataset.setCreator(userInfo);