use of org.hisp.dhis.common.PrimaryKeyObject in project dhis2-core by dhis2.
the class GistValidator method validateFieldAccess.
/**
* Can the current user view the field? Usually this asks if the user can
* view the owning object type but there are fields that are generally
* visible.
*/
private void validateFieldAccess(Field f, RelativePropertyContext context) {
String path = f.getPropertyPath();
Property field = context.resolveMandatory(path);
if (!access.canRead(query.getElementType(), path)) {
throw createNoReadAccess(f, query.getElementType());
}
if (!isNonNestedPath(path)) {
Schema fieldOwner = context.switchedTo(path).getHome();
@SuppressWarnings("unchecked") Class<? extends PrimaryKeyObject> ownerType = (Class<? extends PrimaryKeyObject>) fieldOwner.getKlass();
if (fieldOwner.isIdentifiableObject() && !access.canRead(ownerType, field.getName())) {
throw createNoReadAccess(f, ownerType);
}
}
}
Aggregations