X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.jcr%2Fsrc%2Forg%2Fargeo%2Fjcr%2Ffs%2FJcrFileSystemProvider.java;h=74d9a198e71299e8a08af786494792c74752afb6;hb=93989c5786472b5fad58aec868fcfd1cd07059da;hp=bd0befe7c6c3346bdbc946b9010e4d21c4f35f79;hpb=638e94cf1ad4bea9ce39232725d4e21775ce49b3;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.jcr/src/org/argeo/jcr/fs/JcrFileSystemProvider.java b/org.argeo.jcr/src/org/argeo/jcr/fs/JcrFileSystemProvider.java index bd0befe7c..74d9a198e 100644 --- a/org.argeo.jcr/src/org/argeo/jcr/fs/JcrFileSystemProvider.java +++ b/org.argeo.jcr/src/org/argeo/jcr/fs/JcrFileSystemProvider.java @@ -25,6 +25,7 @@ import javax.jcr.Node; import javax.jcr.Property; import javax.jcr.PropertyIterator; import javax.jcr.PropertyType; +import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.nodetype.NodeType; @@ -69,7 +70,8 @@ public abstract class JcrFileSystemProvider extends FileSystemProvider { Node base = toNode(dir); if (base == null) throw new IOException(dir + " is not a JCR node"); - return new NodeDirectoryStream((JcrFileSystem) dir.getFileSystem(), base.getNodes(), filter); + JcrFileSystem fileSystem = (JcrFileSystem) dir.getFileSystem(); + return new NodeDirectoryStream(fileSystem, base.getNodes(), fileSystem.listDirectMounts(dir), filter); } catch (RepositoryException e) { throw new IOException("Cannot list directory", e); } @@ -149,17 +151,32 @@ public abstract class JcrFileSystemProvider extends FileSystemProvider { @Override public void move(Path source, Path target, CopyOption... options) throws IOException { - Node sourceNode = toNode(source); + JcrFileSystem sourceFileSystem = (JcrFileSystem) source.getFileSystem(); + WorkspaceFileStore sourceStore = sourceFileSystem.getFileStore(source.toString()); + WorkspaceFileStore targetStore = sourceFileSystem.getFileStore(target.toString()); try { - Session session = sourceNode.getSession(); - synchronized (session) { - session.move(sourceNode.getPath(), target.toString()); - save(session); + if (sourceStore.equals(targetStore)) { + sourceStore.getWorkspace().move(sourceStore.toJcrPath(source.toString()), + targetStore.toJcrPath(target.toString())); + } else { + // TODO implement it + throw new UnsupportedOperationException("Can only move paths within the same workspace."); } } catch (RepositoryException e) { - discardChanges(sourceNode); throw new IOException("Cannot move from " + source + " to " + target, e); } + +// Node sourceNode = toNode(source); +// try { +// Session session = sourceNode.getSession(); +// synchronized (session) { +// session.move(sourceNode.getPath(), target.toString()); +// save(session); +// } +// } catch (RepositoryException e) { +// discardChanges(sourceNode); +// throw new IOException("Cannot move from " + source + " to " + target, e); +// } } @Override @@ -188,20 +205,16 @@ public abstract class JcrFileSystemProvider extends FileSystemProvider { @Override public FileStore getFileStore(Path path) throws IOException { - Session session = ((JcrFileSystem) path.getFileSystem()).getSession(); - return new WorkSpaceFileStore(session.getWorkspace()); + JcrFileSystem fileSystem = (JcrFileSystem) path.getFileSystem(); + return fileSystem.getFileStore(path.toString()); } @Override public void checkAccess(Path path, AccessMode... modes) throws IOException { - try { - Session session = ((JcrFileSystem) path.getFileSystem()).getSession(); - if (!session.itemExists(path.toString())) - throw new NoSuchFileException(path + " does not exist"); - // TODO check access via JCR api - } catch (RepositoryException e) { - throw new IOException("Cannot delete " + path, e); - } + Node node = toNode(path); + if (node == null) + throw new NoSuchFileException(path + " does not exist"); + // TODO check access via JCR api } @Override @@ -317,7 +330,8 @@ public abstract class JcrFileSystemProvider extends FileSystemProvider { * * @return null by default */ - public Node getUserHome(Session session) { + public Node getUserHome(Repository session) { return null; } + }