Class WebdavFileSystem

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class WebdavFileSystem
    extends FileSystem
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • client

        private final com.github.sardine.Sardine client
      • server

        private final java.lang.String server
    • Constructor Detail

      • WebdavFileSystem

        protected WebdavFileSystem​(java.lang.String uniqueID,
                                   java.lang.String name,
                                   java.lang.String location,
                                   Credential credential,
                                   java.lang.String server,
                                   Path entryPath,
                                   int bufferSize,
                                   com.github.sardine.Sardine client,
                                   XenonProperties properties)
    • Method Detail

      • getFilePath

        private java.lang.String getFilePath​(Path path)
      • getDirectoryPath

        private java.lang.String getDirectoryPath​(Path path)
      • getAttributes

        private PathAttributes getAttributes​(Path path,
                                             com.github.sardine.DavResource p)
      • listDirectory

        protected java.util.List<PathAttributes> listDirectory​(Path path)
                                                        throws XenonException
        Description copied from class: FileSystem
        Return the list of entries in a directory. This operation is non-recursive; any subdirectories in dir will be returned as part of the list, but they will not be listed themselves. This operation must be implemented by the various implementations of FileSystem.
        Specified by:
        listDirectory in class FileSystem
        Parameters:
        path - the directory to list
        Returns:
        a Iterable that iterates over all entries in dir
        Throws:
        XenonException - If the list could not be retrieved.
      • isOpen

        public boolean isOpen()
                       throws XenonException
        Description copied from class: FileSystem
        Return if the connection to the FileSystem is open. An adaptor which does not support closing is always open.
        Specified by:
        isOpen in class FileSystem
        Returns:
        if the connection to the FileSystem is open.
        Throws:
        XenonException - if the test failed or an I/O error occurred.
      • rename

        public void rename​(Path source,
                           Path target)
                    throws XenonException
        Description copied from class: FileSystem
        Rename an existing source path to a non-existing target path (optional operation).

        This method only implements a rename operation, not a move operation. Hence, this method will not copy files and should return (almost) instantaneously. The parent of the target path (e.g. target.getParent) must exist. If the target is equal to the source this method has no effect. If the source is a link, the link itself will be renamed, not the path to which it refers. If the source is a directory, it will be renamed to the target. This implies that a moving a directory between physical locations may fail.

        Specified by:
        rename in class FileSystem
        Parameters:
        source - the existing source path.
        target - the non existing target path.
        Throws:
        UnsupportedOperationException - If the adapter does not support renaming.
        NoSuchPathException - If the source file does not exist or the target parent directory does not exist.
        PathAlreadyExistsException - If the target file already exists.
        NotConnectedException - If file system is closed.
        XenonException - If the move failed.
      • deleteFile

        protected void deleteFile​(Path path)
                           throws XenonException
        Description copied from class: FileSystem
        Delete a file. Is only called on existing files This operation must be implemented by the various implementations of FileSystem.
        Specified by:
        deleteFile in class FileSystem
        Parameters:
        path - the file to remove
        Throws:
        InvalidPathException - if the provided path is not a file.
        NoSuchPathException - if the provided file does not exist.
        XenonException - If the file could not be removed.
      • deleteDirectory

        protected void deleteDirectory​(Path path)
                                throws XenonException
        Description copied from class: FileSystem
        Delete an empty directory. Is only called on empty directories This operation can only delete empty directories (analogous to rmdir in Linux). This operation must be implemented by the various implementations of FileSystem.
        Specified by:
        deleteDirectory in class FileSystem
        Parameters:
        path - the directory to remove
        Throws:
        InvalidPathException - if the provided path is not a directory.
        NoSuchPathException - if the provided path does not exist.
        XenonException - If the directory could not be removed.
      • writeToFile

        public java.io.OutputStream writeToFile​(Path file,
                                                long size)
                                         throws XenonException
        Description copied from class: FileSystem
        Open a file and return an OutputStream to write to this file.

        The size of the file (once all data has been written) must be specified using the size parameter. This is required by some implementations (typically blob-stores).

        Specified by:
        writeToFile in class FileSystem
        Parameters:
        file - the target file for the OutputStream.
        size - the size of the file once fully written.
        Returns:
        the OutputStream to write to the file.
        Throws:
        PathAlreadyExistsException - If the target existed.
        NoSuchPathException - if a parent directory does not exist.
        NotConnectedException - If file system is closed.
        XenonException - if an I/O error occurred.
      • writeToFile

        public java.io.OutputStream writeToFile​(Path file)
                                         throws XenonException
        Description copied from class: FileSystem
        Open a file and return an OutputStream to write to this file. (optional operation)

        If the file already exists it will be replaced and its data will be lost. The amount of data that will be written to the file is not specified in advance. This operation may not be supported by all implementations.

        Specified by:
        writeToFile in class FileSystem
        Parameters:
        file - the target file for the OutputStream.
        Returns:
        the OutputStream to write to the file.
        Throws:
        PathAlreadyExistsException - If the target existed.
        NoSuchPathException - if a parent directory does not exist.
        NotConnectedException - If file system is closed.
        XenonException - if an I/O error occurred.