public class FileOperations extends Object implements GenericFileOperations<File>
File
.Constructor and Description |
---|
FileOperations() |
FileOperations(FileEndpoint endpoint) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
buildDirectory(File dir,
Set<PosixFilePermission> permissions,
boolean absolute) |
boolean |
buildDirectory(String directory,
boolean absolute)
Builds the directory structure.
|
void |
changeCurrentDirectory(String path)
Change the current remote directory
|
void |
changeToParentDirectory()
Change the current remote directory to the parent
|
boolean |
deleteFile(String name)
Deletes the file name by name, relative to the current directory
|
boolean |
existsFile(String name)
Determines whether the files exists or not
|
String |
getCurrentDirectory()
Gets the current remote directory
|
List<File> |
listFiles()
List the files in the current directory
|
List<File> |
listFiles(String path)
List the files in the given remote directory
|
void |
releaseRetrievedFileResources(Exchange exchange)
Releases the resources consumed by a retrieved file
|
boolean |
renameFile(String from,
String to)
Renames the file
|
boolean |
retrieveFile(String name,
Exchange exchange,
long size)
Retrieves the file
|
void |
setEndpoint(GenericFileEndpoint<File> endpoint)
Sets the endpoint as some implementations need access to the endpoint and how its configured.
|
boolean |
storeFile(String fileName,
Exchange exchange,
long size)
Stores the content as a new remote file (upload)
|
public FileOperations()
public FileOperations(FileEndpoint endpoint)
public void setEndpoint(GenericFileEndpoint<File> endpoint)
GenericFileOperations
setEndpoint
in interface GenericFileOperations<File>
endpoint
- the endpointpublic boolean deleteFile(String name) throws GenericFileOperationFailedException
GenericFileOperations
deleteFile
in interface GenericFileOperations<File>
name
- name of the fileGenericFileOperationFailedException
- can be thrownpublic boolean renameFile(String from, String to) throws GenericFileOperationFailedException
GenericFileOperations
renameFile
in interface GenericFileOperations<File>
from
- original nameto
- the new nameGenericFileOperationFailedException
- can be thrownpublic boolean existsFile(String name) throws GenericFileOperationFailedException
GenericFileOperations
existsFile
in interface GenericFileOperations<File>
name
- name of the fileGenericFileOperationFailedException
- can be thrownprotected boolean buildDirectory(File dir, Set<PosixFilePermission> permissions, boolean absolute)
public boolean buildDirectory(String directory, boolean absolute) throws GenericFileOperationFailedException
GenericFileOperations
buildDirectory
in interface GenericFileOperations<File>
directory
- the directory path to build as a relative string nameabsolute
- wether the directory is an absolute or relative pathGenericFileOperationFailedException
- can be thrownpublic List<File> listFiles() throws GenericFileOperationFailedException
GenericFileOperations
listFiles
in interface GenericFileOperations<File>
GenericFileOperationFailedException
- can be thrownpublic List<File> listFiles(String path) throws GenericFileOperationFailedException
GenericFileOperations
listFiles
in interface GenericFileOperations<File>
path
- the remote directoryGenericFileOperationFailedException
- can be thrownpublic void changeCurrentDirectory(String path) throws GenericFileOperationFailedException
GenericFileOperations
changeCurrentDirectory
in interface GenericFileOperations<File>
path
- the path to change toGenericFileOperationFailedException
- can be thrownpublic void changeToParentDirectory() throws GenericFileOperationFailedException
GenericFileOperations
changeToParentDirectory
in interface GenericFileOperations<File>
GenericFileOperationFailedException
- can be thrownpublic String getCurrentDirectory() throws GenericFileOperationFailedException
GenericFileOperations
getCurrentDirectory
in interface GenericFileOperations<File>
GenericFileOperationFailedException
- can be thrownpublic boolean retrieveFile(String name, Exchange exchange, long size) throws GenericFileOperationFailedException
GenericFileOperations
retrieveFile
in interface GenericFileOperations<File>
name
- name of the fileexchange
- stream to write the content of the file intosize
- the total file size to retrieve, if possible to determineGenericFileOperationFailedException
- can be thrownpublic void releaseRetrievedFileResources(Exchange exchange) throws GenericFileOperationFailedException
GenericFileOperations
releaseRetrievedFileResources
in interface GenericFileOperations<File>
exchange
- exchange with the content of the fileGenericFileOperationFailedException
- can be thrownpublic boolean storeFile(String fileName, Exchange exchange, long size) throws GenericFileOperationFailedException
GenericFileOperations
storeFile
in interface GenericFileOperations<File>
fileName
- name of new fileexchange
- with the content content of the filesize
- the total file size to store, if possible to determineGenericFileOperationFailedException
- can be thrownApache Camel