1 package org
.argeo
.jcr
.fs
;
3 import java
.io
.IOException
;
4 import java
.nio
.file
.FileStore
;
5 import java
.nio
.file
.FileSystem
;
6 import java
.nio
.file
.Path
;
7 import java
.nio
.file
.PathMatcher
;
8 import java
.nio
.file
.WatchService
;
9 import java
.nio
.file
.attribute
.UserPrincipalLookupService
;
10 import java
.nio
.file
.spi
.FileSystemProvider
;
11 import java
.util
.HashSet
;
14 import javax
.jcr
.RepositoryException
;
15 import javax
.jcr
.Session
;
17 import org
.argeo
.jcr
.JcrUtils
;
19 public class JcrFileSystem
extends FileSystem
{
20 private final JcrFileSystemProvider provider
;
21 private final Session session
;
23 public JcrFileSystem(JcrFileSystemProvider provider
, Session session
) {
25 this.provider
= provider
;
26 this.session
= session
;
30 public FileSystemProvider
provider() {
35 public void close() throws IOException
{
36 JcrUtils
.logoutQuietly(session
);
40 public boolean isOpen() {
41 return session
.isLive();
45 public boolean isReadOnly() {
50 public String
getSeparator() {
55 public Iterable
<Path
> getRootDirectories() {
57 Set
<Path
> single
= new HashSet
<>();
58 single
.add(new JcrPath(this, session
.getRootNode()));
60 } catch (RepositoryException e
) {
61 throw new JcrFsException("Cannot get root path", e
);
66 public Iterable
<FileStore
> getFileStores() {
67 throw new UnsupportedOperationException();
71 public Set
<String
> supportedFileAttributeViews() {
73 String
[] prefixes
= session
.getNamespacePrefixes();
74 Set
<String
> res
= new HashSet
<>();
75 for (String prefix
: prefixes
)
79 } catch (RepositoryException e
) {
80 throw new JcrFsException("Cannot get supported file attributes views", e
);
85 public Path
getPath(String first
, String
... more
) {
86 StringBuilder sb
= new StringBuilder(first
);
87 // TODO Make it more robust
88 for (String part
: more
)
89 sb
.append('/').append(part
);
90 return new JcrPath(this, sb
.toString());
94 public PathMatcher
getPathMatcher(String syntaxAndPattern
) {
95 throw new UnsupportedOperationException();
99 public UserPrincipalLookupService
getUserPrincipalLookupService() {
100 throw new UnsupportedOperationException();
104 public WatchService
newWatchService() throws IOException
{
105 throw new UnsupportedOperationException();
108 public Session
getSession() {