-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to contentgrid-spring 0.7.1, which supports spring boot 3
- Loading branch information
1 parent
5947d6b
commit c9d4965
Showing
4 changed files
with
60 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...rc/main/java/com/contentgrid/thunx/spring/data/querydsl/AbacQuerydslPredicateBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.springframework.data.querydsl.binding; | ||
|
||
import com.contentgrid.thunx.predicates.querydsl.FieldByReflectionAccessStrategy; | ||
import com.contentgrid.thunx.predicates.querydsl.QueryDslConverter; | ||
import com.contentgrid.thunx.spring.data.context.AbacContext; | ||
import com.contentgrid.thunx.spring.data.querydsl.EntityPathResolverBasedPathBuilderFactory; | ||
import com.querydsl.core.BooleanBuilder; | ||
import com.querydsl.core.types.Path; | ||
import com.querydsl.core.types.Predicate; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.core.convert.ConversionService; | ||
import org.springframework.data.querydsl.EntityPathResolver; | ||
import org.springframework.data.util.TypeInformation; | ||
import org.springframework.lang.Nullable; | ||
import org.springframework.util.Assert; | ||
import org.springframework.util.MultiValueMap; | ||
|
||
@Slf4j | ||
public class AbacQuerydslPredicateBuilder { | ||
|
||
private final QuerydslPredicateBuilder querydslPredicateBuilder; | ||
private final EntityPathResolver resolver; | ||
private final QueryDslConverter queryDslConverter; | ||
|
||
public AbacQuerydslPredicateBuilder(ConversionService conversionService, EntityPathResolver resolver) { | ||
|
||
Assert.notNull(conversionService, "ConversionService must not be null!"); | ||
|
||
this.querydslPredicateBuilder = new QuerydslPredicateBuilder(conversionService, resolver); | ||
this.resolver = resolver; | ||
|
||
this.queryDslConverter = new QueryDslConverter(new FieldByReflectionAccessStrategy(), new EntityPathResolverBasedPathBuilderFactory( | ||
resolver)); | ||
} | ||
|
||
@Nullable | ||
public Predicate getPredicate(TypeInformation<?> type, MultiValueMap<String, String> values, QuerydslBindings bindings) { | ||
|
||
Assert.notNull(bindings, "Context must not be null!"); | ||
|
||
BooleanBuilder builder = new BooleanBuilder(); | ||
|
||
var abacContext = AbacContext.getCurrentAbacContext(); | ||
if (abacContext != null) { | ||
Predicate queryDslPredicate = this.queryDslConverter.from(abacContext, type.getType()); | ||
Assert.notNull(queryDslPredicate, "abac expression cannot be null"); | ||
log.debug("ABAC Querydsl Predicate: {}", queryDslPredicate); | ||
|
||
builder.and(queryDslPredicate); | ||
} | ||
|
||
builder.and(querydslPredicateBuilder.getPredicate(type, values, bindings)); | ||
|
||
return builder.getValue(); | ||
} | ||
|
||
} |
194 changes: 0 additions & 194 deletions
194
...src/main/java/org/springframework/data/querydsl/binding/AbacQuerydslPredicateBuilder.java
This file was deleted.
Oops, something went wrong.