use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class VerifyFieldAccessFilterExpressionVisitor method getValueChecked.
private Observable<PersistentResource> getValueChecked(PersistentResource<?> resource, String fieldName, RequestScope requestScope) {
EntityDictionary dictionary = resource.getDictionary();
// checkFieldAwareReadPermissions
requestScope.getPermissionExecutor().checkSpecificFieldPermissions(resource, null, ReadPermission.class, fieldName);
Object entity = resource.getObject();
if (entity == null || resource.getDictionary().getRelationshipType(resource.getResourceType(), fieldName) == RelationshipType.NONE) {
return Observable.empty();
}
Relationship relationship = Relationship.builder().name(fieldName).alias(fieldName).projection(EntityProjection.builder().type(dictionary.getParameterizedType(resource.getResourceType(), fieldName)).build()).build();
// use no filter to allow the read directly from loaded resource
return resource.getRelationChecked(relationship);
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class CanPaginateVisitorTest method testNotOperationExpression.
@Test
public void testNotOperationExpression() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "NOT In Memory Check")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertFalse(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class CanPaginateVisitorTest method testSparseFields.
@Test
public void testSparseFields() throws Exception {
@Entity
@Include(rootLevel = false)
@ReadPermission(expression = "In Memory Check")
class Book {
@Id
private long id;
@ReadPermission(expression = "Filter Expression Check")
private String title;
@ReadPermission(expression = "Filter Expression Check")
private Date publicationDate;
private boolean outOfPrint;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
Set<String> sparseFields = new HashSet<>();
assertFalse(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, sparseFields));
sparseFields.add("title");
sparseFields.add("publicationDate");
assertTrue(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, sparseFields));
sparseFields.add("outOfPrint");
assertFalse(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, sparseFields));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class CanPaginateVisitorTest method testFieldFilterPermissions.
@Test
public void testFieldFilterPermissions() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "Filter Expression Check")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertTrue(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class CanPaginateVisitorTest method testFalseUserOROperationExpression.
@Test
public void testFalseUserOROperationExpression() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "False User Check OR In Memory Check")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertFalse(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
Aggregations