}
}
@Override
public GraphNode getUserInContentGraph(final String name) {
final LockableMGraph contentGraph = (LockableMGraph) cgProvider.getContentGraph();
Iterator<Triple> triples = contentGraph.filter(null, PLATFORM.userName,
new PlainLiteralImpl(name));
GraphNode resultNode = null;
if (triples.hasNext()) {
Lock readLock = contentGraph.getLock().readLock();
readLock.lock();
try {
resultNode = new GraphNode(triples.next().getSubject(), contentGraph);
} finally {
readLock.unlock();
}
} else {
NonLiteral user = AccessController.doPrivileged(
new PrivilegedAction<NonLiteral>() {
@Override
public NonLiteral run() {
return getUserByUserName(name);
}
});
if (user != null) {
Lock writeLock = contentGraph.getLock().writeLock();
writeLock.lock();
try {
resultNode = new GraphNode(new BNode(), contentGraph);
resultNode.addProperty(PLATFORM.userName,
new PlainLiteralImpl(name));