}
@Override
public Node storeAsNode(String absPath) throws RepositoryException {
manager.ensureIsAlive();
SessionDelegate sessionDelegate = manager.getSessionDelegate();
String oakPath = sessionDelegate.getOakPath(absPath);
String parent = PathUtils.getParentPath(oakPath);
NodeDelegate parentDelegate = sessionDelegate.getNode(parent);
if (parentDelegate == null) {
throw new PathNotFoundException("The specified path does not exist: " + parent);
}
Node parentNode = new NodeImpl<NodeDelegate>(parentDelegate);
if (!parentNode.isCheckedOut()) {
throw new VersionException("Cannot store query. Node at " +
absPath + " is checked in.");
}
String nodeName = PathUtils.getName(oakPath);
ValueFactory vf = sessionDelegate.getValueFactory();
Node n = parentNode.addNode(nodeName, JcrConstants.NT_QUERY);
n.setProperty(JcrConstants.JCR_STATEMENT, vf.createValue(statement));
n.setProperty(JcrConstants.JCR_LANGUAGE, vf.createValue(language));
setStoredQueryPath(oakPath);
return n;