Refactors Dataset update so it cannot be edited if it's DMP is public.
This commit is contained in:
parent
ae22578710
commit
425a64e60a
|
@ -316,8 +316,11 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public eu.eudat.data.entities.Dataset createOrUpdate(DatasetWizardModel datasetWizardModel, Principal principal) throws Exception {
|
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();
|
eu.eudat.data.entities.Dataset dataset = datasetWizardModel.toDataModel();
|
||||||
dataset.setDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId()));
|
dataset.setDmp(dmp);
|
||||||
propertiesModelToString(datasetWizardModel, dataset);
|
propertiesModelToString(datasetWizardModel, dataset);
|
||||||
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||||
dataset.setCreator(userInfo);
|
dataset.setCreator(userInfo);
|
||||||
|
|
Loading…
Reference in New Issue