package org.argeo.jcr.fs; import java.io.File; import java.io.IOException; import java.net.URI; import java.nio.file.FileSystem; import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.WatchEvent.Kind; import java.nio.file.WatchEvent.Modifier; import java.nio.file.WatchKey; import java.nio.file.WatchService; import java.util.Iterator; import javax.jcr.Node; import javax.jcr.RepositoryException; public class JcrPath implements Path { private JcrFileSystem filesSystem; private String path; private Node node; public JcrPath(JcrFileSystem filesSystem, Node node) { super(); this.filesSystem = filesSystem; this.node = node; } @Override public FileSystem getFileSystem() { return filesSystem; } @Override public boolean isAbsolute() { return path.startsWith("/"); } @Override public Path getRoot() { try { return new JcrPath(filesSystem, node.getSession().getRootNode()); } catch (RepositoryException e) { throw new JcrFsException("Cannot get root", e); } } @Override public Path getFileName() { return null; } @Override public Path getParent() { // TODO Auto-generated method stub return null; } @Override public int getNameCount() { // TODO Auto-generated method stub return 0; } @Override public Path getName(int index) { // TODO Auto-generated method stub return null; } @Override public Path subpath(int beginIndex, int endIndex) { // TODO Auto-generated method stub return null; } @Override public boolean startsWith(Path other) { // TODO Auto-generated method stub return false; } @Override public boolean startsWith(String other) { // TODO Auto-generated method stub return false; } @Override public boolean endsWith(Path other) { // TODO Auto-generated method stub return false; } @Override public boolean endsWith(String other) { // TODO Auto-generated method stub return false; } @Override public Path normalize() { // TODO Auto-generated method stub return null; } @Override public Path resolve(Path other) { // TODO Auto-generated method stub return null; } @Override public Path resolve(String other) { // TODO Auto-generated method stub return null; } @Override public Path resolveSibling(Path other) { // TODO Auto-generated method stub return null; } @Override public Path resolveSibling(String other) { // TODO Auto-generated method stub return null; } @Override public Path relativize(Path other) { // TODO Auto-generated method stub return null; } @Override public URI toUri() { // TODO Auto-generated method stub return null; } @Override public Path toAbsolutePath() { // TODO Auto-generated method stub return null; } @Override public Path toRealPath(LinkOption... options) throws IOException { // TODO Auto-generated method stub return null; } @Override public File toFile() { throw new UnsupportedOperationException(); } @Override public WatchKey register(WatchService watcher, Kind[] events, Modifier... modifiers) throws IOException { // TODO Auto-generated method stub return null; } @Override public WatchKey register(WatchService watcher, Kind... events) throws IOException { // TODO Auto-generated method stub return null; } @Override public Iterator iterator() { // TODO Auto-generated method stub return null; } @Override public int compareTo(Path other) { // TODO Auto-generated method stub return 0; } public Node getNode() { if (!isAbsolute())// TODO default dir throw new JcrFsException("Cannot get node from relative path"); try { if (node == null) node = filesSystem.getSession().getNode(path); return node; } catch (RepositoryException e) { throw new JcrFsException("Cannot get node", e); } } }