Search in sources :

Example 1 with IgfsPathIsNotDirectoryException

use of org.apache.ignite.igfs.IgfsPathIsNotDirectoryException in project ignite by apache.

the class LocalIgfsSecondaryFileSystem method rename.

/** {@inheritDoc} */
@Override
public void rename(IgfsPath src, IgfsPath dest) {
    File srcFile = fileForPath(src);
    File destFile = fileForPath(dest);
    if (!srcFile.exists())
        throw new IgfsPathNotFoundException("Failed to perform rename because source path not found: " + src);
    if (srcFile.isDirectory() && destFile.isFile())
        throw new IgfsPathIsNotDirectoryException("Failed to perform rename because destination path is " + "directory and source path is file [src=" + src + ", dest=" + dest + ']');
    try {
        if (destFile.isDirectory())
            Files.move(srcFile.toPath(), destFile.toPath().resolve(srcFile.getName()));
        else if (!srcFile.renameTo(destFile))
            throw new IgfsException("Failed to perform rename (underlying file system returned false) " + "[src=" + src + ", dest=" + dest + ']');
    } catch (IOException e) {
        throw handleSecondaryFsError(e, "Failed to rename [src=" + src + ", dest=" + dest + ']');
    }
}
Also used : IgfsException(org.apache.ignite.igfs.IgfsException) IOException(java.io.IOException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException) IgfsPathIsNotDirectoryException(org.apache.ignite.igfs.IgfsPathIsNotDirectoryException) IgfsFile(org.apache.ignite.igfs.IgfsFile) LocalFileSystemIgfsFile(org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemIgfsFile) File(java.io.File)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 IgfsException (org.apache.ignite.igfs.IgfsException)1 IgfsFile (org.apache.ignite.igfs.IgfsFile)1 IgfsPathIsNotDirectoryException (org.apache.ignite.igfs.IgfsPathIsNotDirectoryException)1 IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)1 LocalFileSystemIgfsFile (org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemIgfsFile)1