Search in sources :

Example 1 with VisibilityParseException

use of uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.exception.VisibilityParseException 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)1 VisibilityEvaluator (uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.VisibilityEvaluator)1 VisibilityParseException (uk.gov.gchq.gaffer.commonutil.elementvisibilityutil.exception.VisibilityParseException)1