Search in sources :

Example 1 with PrimaryKeyObject

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);
        }
    }
}
Also used : Schema(org.hisp.dhis.schema.Schema) PrimaryKeyObject(org.hisp.dhis.common.PrimaryKeyObject) Property(org.hisp.dhis.schema.Property)

Aggregations

PrimaryKeyObject (org.hisp.dhis.common.PrimaryKeyObject)1 Property (org.hisp.dhis.schema.Property)1 Schema (org.hisp.dhis.schema.Schema)1