Apply some minor fixes

This commit is contained in:
George Kalampokis 2023-10-20 11:57:25 +03:00
parent 0b3178177a
commit 7d4b4c171b
2 changed files with 7 additions and 3 deletions

View File

@ -367,7 +367,7 @@ public class DataManagementPlanManager {
throw new UnauthorisedException(); throw new UnauthorisedException();
} else } else
if (!isPublic && dataManagementPlanEntity.getUsers() if (!isPublic && dataManagementPlanEntity.getUsers()
.stream().noneMatch(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe())) { .stream().noneMatch(userInfo -> userInfo.getUser().getId().equals(this.userScope.getUserIdSafe()))) {
throw new UnauthorisedException(); throw new UnauthorisedException();
} else if (isPublic && !dataManagementPlanEntity.isPublic()) { } else if (isPublic && !dataManagementPlanEntity.isPublic()) {
throw new ForbiddenException("Selected DMP is not public"); throw new ForbiddenException("Selected DMP is not public");
@ -1321,7 +1321,7 @@ public class DataManagementPlanManager {
XWPFDocument document = configLoader.getDocument(); XWPFDocument document = configLoader.getDocument();
DMP dmpEntity = databaseRepository.getDmpDao().find(UUID.fromString(id)); DMP dmpEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == this.userScope.getUserIdSafe()).collect(Collectors.toList()).size() == 0) if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId().equals(this.userScope.getUserIdSafe())).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException(); throw new UnauthorisedException();
wordBuilder.fillFirstPage(dmpEntity, null, document, false); wordBuilder.fillFirstPage(dmpEntity, null, document, false);

View File

@ -217,7 +217,11 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
} }
this.isPublic = entity.isPublic(); this.isPublic = entity.isPublic();
this.publishedAt = entity.getPublishedAt(); this.publishedAt = entity.getPublishedAt();
this.dois = entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList()); if (entity.getDois() != null) {
this.dois = entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList());
} else {
this.dois = new ArrayList<>();
}
return this; return this;
} }