use of org.apache.jena.ext.com.google.common.collect.Multimap in project jena by apache.
the class AssemblerSecurityRegistry method parseStruct.
/**
* Format:: access:entry [ :user "user2"; :graphs (<http://host/graphname3> ) ]
*/
private void parseStruct(Multimap<String, Node> map, Resource root, Resource r) {
if (!GraphUtils.exactlyOneProperty(r, VocabSecurity.pUser))
throw new AssemblerException(root, "Expected exactly one access:user property for " + r);
if (!GraphUtils.exactlyOneProperty(r, VocabSecurity.pGraphs))
throw new AssemblerException(root, "Expected exactly one access:graphs property for " + r);
String user = GraphUtils.getStringValue(r, VocabSecurity.pUser);
r.listProperties(VocabSecurity.pGraphs).mapWith(s -> s.getObject()).forEachRemaining(x -> {
List<Node> graphs = new ArrayList<>();
if (x.isURIResource()) {
// System.out.printf("S: user %s : access : %s\n", user, x.asNode());
graphs.add(x.asNode());
} else {
// List?
RDFList list = x.as(RDFList.class);
list.iterator().forEachRemaining(rn -> {
graphs.add(rn.asNode());
});
}
accessEntries(root, map, user, graphs);
});
}
use of org.apache.jena.ext.com.google.common.collect.Multimap in project jena by apache.
the class AssemblerSecurityRegistry method accessEntries.
private void accessEntries(Resource root, Multimap<String, Node> map, String user, List<Node> _graphs) {
// Convert string names for graphs to URIs.
Set<Node> graphs = _graphs.stream().map(n -> graphLabel(n, root)).collect(Collectors.toSet());
if (graphs.contains(SecurityContext.allGraphs)) {
map.removeAll(user);
map.put(user, SecurityContext.allGraphs);
return;
}
if (graphs.contains(SecurityContext.allNamedGraphs)) {
boolean dft = dftPresent(graphs);
Node x = SecurityContext.allNamedGraphs;
if (dft)
// Put in "*" instead.
x = SecurityContext.allGraphs;
map.removeAll(user);
map.put(user, x);
return;
}
if (SKIP_ALLGRAPH) {
if (graphs.contains(SecurityContext.allGraphs)) {
Log.warn(this, "Graph name '" + SecurityContext.allGraphsStr + "' not supported yet");
graphs.remove(SecurityContext.allGraphs);
}
if (graphs.contains(SecurityContext.allNamedGraphs)) {
Log.warn(this, "Graph name '" + SecurityContext.allNamedGraphsStr + "' not supported yet");
graphs.remove(SecurityContext.allNamedGraphs);
}
}
map.putAll(user, graphs);
}
Aggregations