SessionDelegate sessionDelegate = manager.getSessionDelegate();
String oakPath = sessionDelegate.getOakPathOrThrow(absPath);
// TODO query nodes should be of type nt:query
String parent = PathUtils.getParentPath(oakPath);
String nodeName = PathUtils.getName(oakPath);
NodeDelegate parentNode = sessionDelegate.getNode(parent);
ValueFactoryImpl vf = sessionDelegate.getValueFactory();
if (parentNode == null) {
throw new PathNotFoundException("The specified path does not exist: " + parent);
}
NodeDelegate node = parentNode.addChild(nodeName);
if (node == null) {
throw new ItemExistsException("Node already exists: " + absPath);
}
node.setProperty("statement", vf.getCoreValue(vf.createValue(statement)));
node.setProperty("language", vf.getCoreValue(vf.createValue(language)));
NodeImpl n = new NodeImpl(node);
n.setPrimaryType(NodeType.NT_QUERY);
storedQueryPath = oakPath;
return n;
}