Class FtpFileObject

    • Field Detail

      • EMPTY_FTP_FILE_MAP

        private static final java.util.Map<java.lang.String,​org.apache.commons.net.ftp.FTPFile> EMPTY_FTP_FILE_MAP
      • UNKNOWN

        private static final org.apache.commons.net.ftp.FTPFile UNKNOWN
      • log

        private static final org.apache.commons.logging.Log log
      • mdtmSet

        private volatile boolean mdtmSet
      • relPath

        private final java.lang.String relPath
      • ftpFile

        private volatile org.apache.commons.net.ftp.FTPFile ftpFile
      • childMap

        private volatile java.util.Map<java.lang.String,​org.apache.commons.net.ftp.FTPFile> childMap
      • linkDestination

        private volatile FileObject linkDestination
      • inRefresh

        private final java.util.concurrent.atomic.AtomicBoolean inRefresh
    • Method Detail

      • doAttach

        protected void doAttach()
                         throws java.io.IOException
        Attaches this file object to its file resource.
        Overrides:
        doAttach in class AbstractFileObject<FtpFileSystem>
        Throws:
        java.io.IOException
      • doCreateFolder

        protected void doCreateFolder()
                               throws java.lang.Exception
        Creates this file as a folder.
        Overrides:
        doCreateFolder in class AbstractFileObject<FtpFileSystem>
        Throws:
        java.lang.Exception - if an error occurs.
      • doDelete

        protected void doDelete()
                         throws java.lang.Exception
        Deletes the file.
        Overrides:
        doDelete in class AbstractFileObject<FtpFileSystem>
        Throws:
        java.lang.Exception - if an error occurs.
      • doGetChildren

        private void doGetChildren()
                            throws java.io.IOException
        Fetches the children of this file, if not already cached.
        Throws:
        java.io.IOException
      • doGetContentSize

        protected long doGetContentSize()
                                 throws java.lang.Exception
        Returns the size of the file content (in bytes).
        Specified by:
        doGetContentSize in class AbstractFileObject<FtpFileSystem>
        Returns:
        The size of the file in bytes.
        Throws:
        java.lang.Exception - if an error occurs.
      • doGetInputStream

        protected java.io.InputStream doGetInputStream​(int bufferSize)
                                                throws java.lang.Exception
        Creates an input stream to read the file content from.
        Overrides:
        doGetInputStream in class AbstractFileObject<FtpFileSystem>
        Parameters:
        bufferSize - Buffer size hint.
        Returns:
        An InputStream to read the file content.
        Throws:
        java.lang.Exception - if an error occurs.
      • doGetOutputStream

        protected java.io.OutputStream doGetOutputStream​(boolean bAppend)
                                                  throws java.lang.Exception
        Creates an output stream to write the file content to.
        Overrides:
        doGetOutputStream in class AbstractFileObject<FtpFileSystem>
        Parameters:
        bAppend - true if the file should be appended to, false if it should be overwritten.
        Returns:
        An OutputStream to write to the file.
        Throws:
        java.lang.Exception - if an error occurs.
      • doGetType

        protected FileType doGetType()
                              throws java.lang.Exception
        Determines the type of the file, returns null if the file does not exist.
        Specified by:
        doGetType in class AbstractFileObject<FtpFileSystem>
        Returns:
        the type of the file.
        Throws:
        java.lang.Exception - if an error occurs.
      • doListChildren

        protected java.lang.String[] doListChildren()
                                             throws java.lang.Exception
        Lists the children of the file.
        Specified by:
        doListChildren in class AbstractFileObject<FtpFileSystem>
        Returns:
        a possible empty String array if the file is a directory or null or an exception if the file is not a directory or can't be read.
        Throws:
        java.lang.Exception - if an error occurs.
      • doListChildrenResolved

        protected FileObject[] doListChildrenResolved()
                                               throws java.lang.Exception
        Description copied from class: AbstractFileObject
        Lists the children of this file.

        Is only called if AbstractFileObject.doGetType() returns FileType.FOLDER.

        The return value of this method is cached, so the implementation can be expensive. Other than doListChildren you could return FileObject's to e.g. reinitialize the type of the file.

        (Introduced for Webdav: "permission denied on resource" during getType())

        Overrides:
        doListChildrenResolved in class AbstractFileObject<FtpFileSystem>
        Returns:
        The children of this FileObject.
        Throws:
        java.lang.Exception - if an error occurs.
      • doRename

        protected void doRename​(FileObject newFile)
                         throws java.lang.Exception
        Renames the file
        Overrides:
        doRename in class AbstractFileObject<FtpFileSystem>
        Parameters:
        newFile - A FileObject with the new file name.
        Throws:
        java.lang.Exception - if an error occurs.
      • getChildFile

        private org.apache.commons.net.ftp.FTPFile getChildFile​(java.lang.String name,
                                                                boolean flush)
                                                         throws java.io.IOException
        Called by child file objects, to locate their FTP file info.
        Parameters:
        name - the file name in its native form ie. without URI stuff (%nn)
        flush - recreate children cache
        Throws:
        java.io.IOException
      • getRelPath

        java.lang.String getRelPath()
      • getTimestampMillis

        private long getTimestampMillis()
                                 throws java.io.IOException
        ftpFile is not null.
        Throws:
        java.io.IOException
      • onChange

        protected void onChange()
                         throws java.io.IOException
        Called when the type or content of this file changes.
        Overrides:
        onChange in class AbstractFileObject<FtpFileSystem>
        Throws:
        java.io.IOException
      • setFTPFile

        private void setFTPFile​(boolean flush)
                         throws java.io.IOException
        Sets the internal FTPFile for this instance.
        Throws:
        java.io.IOException