Search in sources :

Example 1 with ElementVisibility

use of uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.ElementVisibility in project Gaffer by gchq.

the class RetrieveElementsFromFile method isVisible.

private Boolean isVisible(final Element e) throws VisibilityParseException {
    if (e.getProperty(visibility) != null) {
        final VisibilityEvaluator visibilityEvaluator = new VisibilityEvaluator(auths);
        final ElementVisibility elementVisibility = new ElementVisibility((String) e.getProperty(visibility));
        return visibilityEvaluator.evaluate(elementVisibility);
    } else {
        e.putProperty(visibility, new String());
        return true;
    }
}
Also used : VisibilityEvaluator(uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.VisibilityEvaluator) ElementVisibility(uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.ElementVisibility)

Example 2 with ElementVisibility

use of uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.ElementVisibility in project Gaffer by gchq.

the class GetElementsUtil method isVisible.

private static boolean isVisible(final Element e, final String visibilityProperty, final Authorisations authorisations) {
    if (e.getProperty(visibilityProperty) != null) {
        final VisibilityEvaluator visibilityEvaluator = new VisibilityEvaluator(authorisations);
        final ElementVisibility elementVisibility = new ElementVisibility((String) e.getProperty(visibilityProperty));
        try {
            return visibilityEvaluator.evaluate(elementVisibility);
        } catch (final VisibilityParseException visibilityParseException) {
            LOGGER.warn("Unable to parse element visibility: {}. Received exception: {}", elementVisibility, visibilityParseException.getMessage());
            return false;
        }
    } else {
        e.putProperty(visibilityProperty, new String());
        return true;
    }
}
Also used : VisibilityEvaluator(uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.VisibilityEvaluator) ElementVisibility(uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.ElementVisibility) VisibilityParseException(uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.exception.VisibilityParseException)

Aggregations

ElementVisibility (uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.ElementVisibility)2 VisibilityEvaluator (uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.VisibilityEvaluator)2 VisibilityParseException (uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.exception.VisibilityParseException)1