Minor refactoring
This commit is contained in:
parent
a1b067071a
commit
e2326e1070
|
@ -357,10 +357,13 @@ public class DataManagementPlanManager {
|
||||||
if (dataManagementPlan.getId() != null) {
|
if (dataManagementPlan.getId() != null) {
|
||||||
DMP dmp1 = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
|
DMP dmp1 = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
|
||||||
|
|
||||||
|
Instant dbTime = Instant.ofEpochMilli(dmp1.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
Instant modelTime = Instant.ofEpochMilli(dataManagementPlan.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
|
||||||
if (!isUserOwnerOfDmp(dmp1, principal)) {
|
if (!isUserOwnerOfDmp(dmp1, principal)) {
|
||||||
throw new Exception("User not being the creator is not authorized to edit this DMP.");
|
throw new Exception("User not being the creator is not authorized to edit this DMP.");
|
||||||
}
|
}
|
||||||
if (Instant.ofEpochMilli(dmp1.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS).toEpochMilli() != Instant.ofEpochMilli(dataManagementPlan.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS).toEpochMilli()) {
|
if (dbTime.toEpochMilli() != modelTime.toEpochMilli()) {
|
||||||
throw new Exception("Another user have already edit that DMP.");
|
throw new Exception("Another user have already edit that DMP.");
|
||||||
}
|
}
|
||||||
List<Dataset> datasetList = new ArrayList<>(dmp1.getDataset());
|
List<Dataset> datasetList = new ArrayList<>(dmp1.getDataset());
|
||||||
|
@ -479,10 +482,13 @@ public class DataManagementPlanManager {
|
||||||
if (dataManagementPlan.getId() != null) {
|
if (dataManagementPlan.getId() != null) {
|
||||||
DMP dmp1 = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
|
DMP dmp1 = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
|
||||||
|
|
||||||
|
Instant dbTime = Instant.ofEpochMilli(dmp1.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
Instant modelTime = Instant.ofEpochMilli(dataManagementPlan.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
|
||||||
if (!isUserOwnerOfDmp(dmp1, principal)) {
|
if (!isUserOwnerOfDmp(dmp1, principal)) {
|
||||||
throw new Exception("User not being the creator is not authorized to edit this DMP.");
|
throw new Exception("User not being the creator is not authorized to edit this DMP.");
|
||||||
}
|
}
|
||||||
if (Instant.ofEpochMilli(dmp1.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS).toEpochMilli() != Instant.ofEpochMilli(dataManagementPlan.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS).toEpochMilli()) {
|
if (dbTime.toEpochMilli() != modelTime.toEpochMilli()) {
|
||||||
throw new Exception("Another user have already edit that DMP.");
|
throw new Exception("Another user have already edit that DMP.");
|
||||||
}
|
}
|
||||||
for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) {
|
for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) {
|
||||||
|
|
Loading…
Reference in New Issue