fix reference authz

This commit is contained in:
Efstratios Giannopoulos 2024-04-17 11:27:25 +03:00
parent a158e78101
commit cc1be4f194
1 changed files with 11 additions and 1 deletions

View File

@ -5,9 +5,11 @@ import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.ReferenceSourceType; import eu.eudat.commons.enums.ReferenceSourceType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionReferenceEntity;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.DmpReferenceEntity; import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.data.ReferenceEntity; import eu.eudat.data.ReferenceEntity;
import eu.eudat.model.DescriptionReference;
import eu.eudat.model.PublicReference; import eu.eudat.model.PublicReference;
import eu.eudat.model.Reference; import eu.eudat.model.Reference;
import eu.eudat.query.utils.BuildSubQueryInput; import eu.eudat.query.utils.BuildSubQueryInput;
@ -224,7 +226,15 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
.filterFunc((subQueryRoot, cb) -> .filterFunc((subQueryRoot, cb) ->
cb.in(subQueryRoot.get(DmpReferenceEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) cb.in(subQueryRoot.get(DmpReferenceEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))
) )
))) //Creates a false query ))),
queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id)).value(queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DescriptionReferenceEntity.class, UUID.class)
.query(queryContext.Query)
.criteriaBuilder(queryContext.CriteriaBuilder)
.keyPathFunc((subQueryRoot) -> subQueryRoot.get(DescriptionReferenceEntity._referenceId))
.filterFunc((subQueryRoot, cb) ->
cb.in(subQueryRoot.get(DescriptionReferenceEntity._descriptionId)).value(queryUtilsService.buildDescriptionAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))
)
)))
)); ));
} }
if (!predicates.isEmpty()) { if (!predicates.isEmpty()) {