import java.io.IOException;
import java.nio.channels.SeekableByteChannel;
-import java.nio.charset.Charset;
import java.nio.file.AccessMode;
import java.nio.file.CopyOption;
import java.nio.file.DirectoryNotEmptyException;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.PropertyDefinition;
-import org.apache.commons.io.FileExistsException;
import org.argeo.jcr.JcrUtils;
public abstract class JcrFileSystemProvider extends FileSystemProvider {
throw new IOException(path + " parent is a file");
String fileName = path.getFileName().toString();
+ fileName = Text.escapeIllegalJcrChars(fileName);
node = parent.addNode(fileName, NodeType.NT_FILE);
node.addMixin(NodeType.MIX_CREATED);
node.addMixin(NodeType.MIX_LAST_MODIFIED);
}
if (!node.isNodeType(NodeType.NT_FILE))
throw new UnsupportedOperationException(node + " must be a file");
- return new BinaryChannel(node);
+ return new BinaryChannel(node, path);
} catch (RepositoryException e) {
discardChanges(node);
throw new IOException("Cannot read file", e);
public DirectoryStream<Path> newDirectoryStream(Path dir, Filter<? super Path> filter) throws IOException {
try {
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);
} catch (RepositoryException e) {
throw new IOException("Cannot list directory", e);
|| parent.getPrimaryNodeType().isNodeType(NodeType.NT_LINKED_FILE))
throw new IOException(dir + " parent is a file");
String fileName = dir.getFileName().toString();
+ fileName = Text.escapeIllegalJcrChars(fileName);
node = parent.addNode(fileName, NodeType.NT_FOLDER);
node.addMixin(NodeType.MIX_CREATED);
node.addMixin(NodeType.MIX_LAST_MODIFIED);
node.getSession().save();
} else {
- if (!node.getPrimaryNodeType().isNodeType(NodeType.NT_FOLDER))
- throw new FileExistsException(dir + " exists and is not a directory");
+ // if (!node.getPrimaryNodeType().isNodeType(NodeType.NT_FOLDER))
+ // throw new FileExistsException(dir + " exists and is not a directory");
}
} catch (RepositoryException e) {
discardChanges(node);
@Override
public boolean isHidden(Path path) throws IOException {
- return false;
+ return path.getFileName().toString().charAt(0) == '.';
}
@Override