Package org.apache.camel.component.file
Interface GenericFileOperations<T>
-
- All Known Implementing Classes:
FileOperations
public interface GenericFileOperations<T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
buildDirectory(String directory, boolean absolute)
Builds the directory structure.void
changeCurrentDirectory(String path)
Change the current remote directoryvoid
changeToParentDirectory()
Change the current remote directory to the parentboolean
deleteFile(String name)
Deletes the file name by name, relative to the current directoryboolean
existsFile(String name)
Determines whether the files exists or notString
getCurrentDirectory()
Gets the current remote directoryT[]
listFiles()
List the files in the current directoryT[]
listFiles(String path)
List the files in the given remote directoryGenericFile<T>
newGenericFile()
Creates a new instance ofGenericFile
void
releaseRetrievedFileResources(org.apache.camel.Exchange exchange)
Releases the resources consumed by a retrieved fileboolean
renameFile(String from, String to)
Renames the fileboolean
retrieveFile(String name, org.apache.camel.Exchange exchange, long size)
Retrieves the filevoid
setEndpoint(GenericFileEndpoint<T> endpoint)
Sets the endpoint as some implementations need access to the endpoint and how its configured.boolean
storeFile(String name, org.apache.camel.Exchange exchange, long size)
Stores the content as a new remote file (upload)
-
-
-
Method Detail
-
newGenericFile
GenericFile<T> newGenericFile()
Creates a new instance ofGenericFile
-
setEndpoint
void setEndpoint(GenericFileEndpoint<T> endpoint)
Sets the endpoint as some implementations need access to the endpoint and how its configured.- Parameters:
endpoint
- the endpoint
-
deleteFile
boolean deleteFile(String name) throws GenericFileOperationFailedException
Deletes the file name by name, relative to the current directory- Parameters:
name
- name of the file- Returns:
- true if deleted, false if not
- Throws:
GenericFileOperationFailedException
- can be thrown
-
existsFile
boolean existsFile(String name) throws GenericFileOperationFailedException
Determines whether the files exists or not- Parameters:
name
- name of the file- Returns:
- true if exists, false if not
- Throws:
GenericFileOperationFailedException
- can be thrown
-
renameFile
boolean renameFile(String from, String to) throws GenericFileOperationFailedException
Renames the file- Parameters:
from
- original nameto
- the new name- Returns:
- true if renamed, false if not
- Throws:
GenericFileOperationFailedException
- can be thrown
-
buildDirectory
boolean buildDirectory(String directory, boolean absolute) throws GenericFileOperationFailedException
Builds the directory structure. Will test if the folder already exists.- Parameters:
directory
- the directory path to build as a relative string nameabsolute
- whether the directory is an absolute or relative path- Returns:
- true if build or already exists, false if not possible (could be lack of permissions)
- Throws:
GenericFileOperationFailedException
- can be thrown
-
retrieveFile
boolean retrieveFile(String name, org.apache.camel.Exchange exchange, long size) throws GenericFileOperationFailedException
Retrieves the file- Parameters:
name
- name of the fileexchange
- stream to write the content of the file intosize
- the total file size to retrieve, if possible to determine- Returns:
- true if file has been retrieved, false if not
- Throws:
GenericFileOperationFailedException
- can be thrown
-
releaseRetrievedFileResources
void releaseRetrievedFileResources(org.apache.camel.Exchange exchange) throws GenericFileOperationFailedException
Releases the resources consumed by a retrieved file- Parameters:
exchange
- exchange with the content of the file- Throws:
GenericFileOperationFailedException
- can be thrown
-
storeFile
boolean storeFile(String name, org.apache.camel.Exchange exchange, long size) throws GenericFileOperationFailedException
Stores the content as a new remote file (upload)- Parameters:
name
- name of new fileexchange
- with the content content of the filesize
- the total file size to store, if possible to determine- Returns:
- true if the file was stored, false if not
- Throws:
GenericFileOperationFailedException
- can be thrown
-
getCurrentDirectory
String getCurrentDirectory() throws GenericFileOperationFailedException
Gets the current remote directory- Returns:
- the current directory path
- Throws:
GenericFileOperationFailedException
- can be thrown
-
changeCurrentDirectory
void changeCurrentDirectory(String path) throws GenericFileOperationFailedException
Change the current remote directory- Parameters:
path
- the path to change to- Throws:
GenericFileOperationFailedException
- can be thrown
-
changeToParentDirectory
void changeToParentDirectory() throws GenericFileOperationFailedException
Change the current remote directory to the parent- Throws:
GenericFileOperationFailedException
- can be thrown
-
listFiles
T[] listFiles() throws GenericFileOperationFailedException
List the files in the current directory- Returns:
- a list of backing objects representing the files
- Throws:
GenericFileOperationFailedException
- can be thrown
-
listFiles
T[] listFiles(String path) throws GenericFileOperationFailedException
List the files in the given remote directory- Parameters:
path
- the remote directory- Returns:
- a list of backing objects representing the files
- Throws:
GenericFileOperationFailedException
- can be thrown
-
-