@Test void testGetAuthorizationFromGraphError() { final Graph mockGraph = mock(Graph.class); final IRI subject = rdf.createIRI("https: when(mockGraph.stream()).thenAnswer(inv -> Stream.of(rdf.createTriple(subject, RDFS.label, rdf.createLiteral("literal")))); when(mockGraph.stream(eq(subject), any(), any())).thenThrow(new RuntimeException("Expected")); assertThrows(TrellisRuntimeException.class, () -> WebAcService.getAuthorizationFromGraph(resourceIRI, mockGraph)); }
static List<Authorization> getAuthorizationFromGraph(final IRI identifier, final Graph graph) { return graph.stream().map(Triple::getSubject).distinct().map(subject -> { try (final Graph subGraph = graph.stream(subject, null, null).collect(toGraph())) { return Authorization.from(subject, subGraph); } catch (final Exception ex) { throw new TrellisRuntimeException("Error closing graph", ex); } }) .filter(auth -> auth.getAccessTo().contains(identifier) || auth.getDefault().contains(identifier)) .collect(toList()); }
WebAcService { static List<Authorization> getAuthorizationFromGraph(final IRI identifier, final Graph graph) { return graph.stream().map(Triple::getSubject).distinct().map(subject -> { try (final Graph subGraph = graph.stream(subject, null, null).collect(toGraph())) { return Authorization.from(subject, subGraph); } catch (final Exception ex) { throw new TrellisRuntimeException("Error closing graph", ex); } }) .filter(auth -> auth.getAccessTo().contains(identifier) || auth.getDefault().contains(identifier)) .collect(toList()); } }
WebAcService { static List<Authorization> getAuthorizationFromGraph(final IRI identifier, final Graph graph) { return graph.stream().map(Triple::getSubject).distinct().map(subject -> { try (final Graph subGraph = graph.stream(subject, null, null).collect(toGraph())) { return Authorization.from(subject, subGraph); } catch (final Exception ex) { throw new TrellisRuntimeException("Error closing graph", ex); } }) .filter(auth -> auth.getAccessTo().contains(identifier) || auth.getDefault().contains(identifier)) .collect(toList()); } WebAcService(); @Inject  WebAcService(final ResourceService resourceService,
            @TrellisAuthorizationCache final CacheService<String, AuthorizedModes> cache); private  WebAcService(final ResourceService resourceService, final CacheService<String, AuthorizedModes> cache,
            final Config config);  WebAcService(final ResourceService resourceService, final CacheService<String, AuthorizedModes> cache,
            final boolean checkMembershipResources, final String defaultAuthResourceLocation); }
WebAcService { static List<Authorization> getAuthorizationFromGraph(final IRI identifier, final Graph graph) { return graph.stream().map(Triple::getSubject).distinct().map(subject -> { try (final Graph subGraph = graph.stream(subject, null, null).collect(toGraph())) { return Authorization.from(subject, subGraph); } catch (final Exception ex) { throw new TrellisRuntimeException("Error closing graph", ex); } }) .filter(auth -> auth.getAccessTo().contains(identifier) || auth.getDefault().contains(identifier)) .collect(toList()); } WebAcService(); @Inject  WebAcService(final ResourceService resourceService,
            @TrellisAuthorizationCache final CacheService<String, AuthorizedModes> cache); private  WebAcService(final ResourceService resourceService, final CacheService<String, AuthorizedModes> cache,
            final Config config);  WebAcService(final ResourceService resourceService, final CacheService<String, AuthorizedModes> cache,
            final boolean checkMembershipResources, final String defaultAuthResourceLocation); @PostConstruct void initialize(); Set<IRI> getAccessModes(final IRI identifier, final Session session); AuthorizedModes getAuthorizedModes(final IRI identifier, final Session session); static String generateCacheKey(final IRI identifier, final IRI agent); }
WebAcService { static List<Authorization> getAuthorizationFromGraph(final IRI identifier, final Graph graph) { return graph.stream().map(Triple::getSubject).distinct().map(subject -> { try (final Graph subGraph = graph.stream(subject, null, null).collect(toGraph())) { return Authorization.from(subject, subGraph); } catch (final Exception ex) { throw new TrellisRuntimeException("Error closing graph", ex); } }) .filter(auth -> auth.getAccessTo().contains(identifier) || auth.getDefault().contains(identifier)) .collect(toList()); } WebAcService(); @Inject  WebAcService(final ResourceService resourceService,
            @TrellisAuthorizationCache final CacheService<String, AuthorizedModes> cache); private  WebAcService(final ResourceService resourceService, final CacheService<String, AuthorizedModes> cache,
            final Config config);  WebAcService(final ResourceService resourceService, final CacheService<String, AuthorizedModes> cache,
            final boolean checkMembershipResources, final String defaultAuthResourceLocation); @PostConstruct void initialize(); Set<IRI> getAccessModes(final IRI identifier, final Session session); AuthorizedModes getAuthorizedModes(final IRI identifier, final Session session); static String generateCacheKey(final IRI identifier, final IRI agent); static final String CONFIG_WEBAC_MEMBERSHIP_CHECK; static final String CONFIG_WEBAC_DEFAULT_ACL_LOCATION; static final String CONFIG_WEBAC_INITIALIZE_ROOT_ACL; static final String DEFAULT_ACL_LOCATION; }