X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.jcr%2Fsrc%2Forg%2Fargeo%2Fjcr%2Ffs%2FJcrFileSystemProvider.java;h=74d9a198e71299e8a08af786494792c74752afb6;hb=46cc2039ac20703c484aa994b830a2da113f2c97;hp=a9ea14826d2bc7c1937a6f8a9390f1f6ab588b84;hpb=6d8432bcf931c7525ecc4254b2a95e8a413a06f1;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 a9ea14826..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 @@ -194,14 +211,10 @@ public abstract class JcrFileSystemProvider extends FileSystemProvider { @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,7 @@ public abstract class JcrFileSystemProvider extends FileSystemProvider { * * @return null by default */ - public Node getUserHome(Session session) { + public Node getUserHome(Repository session) { return null; }