import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
+import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
Session session = repository.login(new SimpleCredentials(username, username.toCharArray()));
fileSystem = new JcrFileSystem(this, session);
return fileSystem;
- } catch (Exception e) {
- throw new JcrFsException("Cannot login to repository", e);
+ } catch (RepositoryException | URISyntaxException e) {
+ throw new IOException("Cannot login to repository", e);
}
}
@Override
public Path getPath(URI uri) {
String path = uri.getPath();
- if(fileSystem==null)
+ if (fileSystem == null)
try {
newFileSystem(uri, new HashMap<String, Object>());
} catch (IOException e) {
- throw new JcrFsException("Could not autocreate file system",e);
+ throw new JcrFsException("Could not autocreate file system", e);
}
return fileSystem.getPath(path);
}
session.save();
open = false;
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot close " + file, e);
+ throw new IOException("Cannot close " + file, e);
} finally {
JcrUtils.closeQuietly(newBinary);
// IOUtils.closeQuietly(fc);
position = position + read;
return read;
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot read into buffer", e);
+ throw new IOException("Cannot read into buffer", e);
}
}
}
try {
return binary.getSize();
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot get size", e);
+ throw new IOException("Cannot get size", e);
}
}
}
}
return fc;
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot get temp file channel", e);
+ throw new IOException("Cannot get temp file channel", e);
}
}
if (node == null) {
Node parent = toNode(path.getParent());
if (parent == null)
- throw new JcrFsException("No parent directory for " + path);
+ throw new IOException("No parent directory for " + path);
if (parent.getPrimaryNodeType().isNodeType(NodeType.NT_FILE)
|| parent.getPrimaryNodeType().isNodeType(NodeType.NT_LINKED_FILE))
- throw new JcrFsException(path + " parent is a file");
+ throw new IOException(path + " parent is a file");
String fileName = path.getFileName().toString();
fileName = Text.escapeIllegalJcrChars(fileName);
throw new UnsupportedOperationException(node + " must be a file");
return new BinaryChannel(node);
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot read file", e);
+ throw new IOException("Cannot read file", e);
}
}
Node base = toNode(dir);
return new NodeDirectoryStream((JcrFileSystem) dir.getFileSystem(), base.getNodes(), filter);
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot list directory", e);
+ throw new IOException("Cannot list directory", e);
}
}
throw new IOException("Parent of " + dir + " does not exist");
if (parent.getPrimaryNodeType().isNodeType(NodeType.NT_FILE)
|| parent.getPrimaryNodeType().isNodeType(NodeType.NT_LINKED_FILE))
- throw new JcrFsException(dir + " parent is a 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);
throw new FileExistsException(dir + " exists and is not a directory");
}
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot create directory " + dir, e);
+ throw new IOException("Cannot create directory " + dir, e);
}
}
}
session.save();
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot delete " + path, e);
+ throw new IOException("Cannot delete " + path, e);
}
}
JcrUtils.copy(sourceNode, targetNode);
sourceNode.getSession().save();
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot copy from " + source + " to " + target, e);
+ throw new IOException("Cannot copy from " + source + " to " + target, e);
}
}
session.move(sourceNode.getPath(), target.toString());
session.save();
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot move from " + source + " to " + target, e);
+ throw new IOException("Cannot move from " + source + " to " + target, e);
}
}
Node node2 = toNode(path2);
return node.isSame(node2);
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot check whether " + path + " and " + path2 + " are same", e);
+ throw new IOException("Cannot check whether " + path + " and " + path2 + " are same", e);
}
}
throw new NoSuchFileException(path + " does not exist");
// TODO check access via JCR api
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot delete " + path, e);
+ throw new IOException("Cannot delete " + path, e);
}
}
try {
// TODO check if assignable
Node node = toNode(path);
- if(node==null) {
- throw new JcrFsException("JCR node not found for "+path);
+ if (node == null) {
+ throw new IOException("JCR node not found for " + path);
}
return (A) new JcrBasicfileAttributes(node);
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot read basic attributes of " + path, e);
+ throw new IOException("Cannot read basic attributes of " + path, e);
}
}
}
return res;
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot read attributes of " + path, e);
+ throw new IOException("Cannot read attributes of " + path, e);
}
}
}
node.getSession().save();
} catch (RepositoryException e) {
- throw new JcrFsException("Cannot set attribute " + attribute + " on " + path, e);
+ throw new IOException("Cannot set attribute " + attribute + " on " + path, e);
}
}