Package org.apache.camel.component.file
Class FileOperations
- java.lang.Object
-
- org.apache.camel.component.file.FileOperations
-
- All Implemented Interfaces:
GenericFileOperations<File>
public class FileOperations extends Object implements GenericFileOperations<File>
File operations forFile.
-
-
Constructor Summary
Constructors Constructor Description FileOperations()FileOperations(FileEndpoint endpoint)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanbuildDirectory(File dir, Set<PosixFilePermission> permissions, boolean absolute)booleanbuildDirectory(String directory, boolean absolute)Builds the directory structure.voidchangeCurrentDirectory(String path)Change the current remote directoryvoidchangeToParentDirectory()Change the current remote directory to the parentbooleandeleteFile(String name)Deletes the file name by name, relative to the current directorybooleanexistsFile(String name)Determines whether the files exists or notStringgetCurrentDirectory()Gets the current remote directoryFile[]listFiles()List the files in the current directoryFile[]listFiles(String path)List the files in the given remote directoryGenericFile<File>newGenericFile()Creates a new instance ofGenericFilevoidreleaseRetrievedFileResources(org.apache.camel.Exchange exchange)Releases the resources consumed by a retrieved filebooleanrenameFile(String from, String to)Renames the filebooleanretrieveFile(String name, org.apache.camel.Exchange exchange, long size)Retrieves the filevoidsetEndpoint(GenericFileEndpoint<File> endpoint)Sets the endpoint as some implementations need access to the endpoint and how its configured.booleanstoreFile(String fileName, org.apache.camel.Exchange exchange, long size)Stores the content as a new remote file (upload)
-
-
-
Constructor Detail
-
FileOperations
public FileOperations()
-
FileOperations
public FileOperations(FileEndpoint endpoint)
-
-
Method Detail
-
newGenericFile
public GenericFile<File> newGenericFile()
Description copied from interface:GenericFileOperationsCreates a new instance ofGenericFile- Specified by:
newGenericFilein interfaceGenericFileOperations<File>
-
setEndpoint
public void setEndpoint(GenericFileEndpoint<File> endpoint)
Description copied from interface:GenericFileOperationsSets the endpoint as some implementations need access to the endpoint and how its configured.- Specified by:
setEndpointin interfaceGenericFileOperations<File>- Parameters:
endpoint- the endpoint
-
deleteFile
public boolean deleteFile(String name) throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsDeletes the file name by name, relative to the current directory- Specified by:
deleteFilein interfaceGenericFileOperations<File>- Parameters:
name- name of the file- Returns:
- true if deleted, false if not
- Throws:
GenericFileOperationFailedException- can be thrown
-
renameFile
public boolean renameFile(String from, String to) throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsRenames the file- Specified by:
renameFilein interfaceGenericFileOperations<File>- Parameters:
from- original nameto- the new name- Returns:
- true if renamed, false if not
- Throws:
GenericFileOperationFailedException- can be thrown
-
existsFile
public boolean existsFile(String name) throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsDetermines whether the files exists or not- Specified by:
existsFilein interfaceGenericFileOperations<File>- Parameters:
name- name of the file- Returns:
- true if exists, false if not
- Throws:
GenericFileOperationFailedException- can be thrown
-
buildDirectory
protected boolean buildDirectory(File dir, Set<PosixFilePermission> permissions, boolean absolute)
-
buildDirectory
public boolean buildDirectory(String directory, boolean absolute) throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsBuilds the directory structure. Will test if the folder already exists.- Specified by:
buildDirectoryin interfaceGenericFileOperations<File>- 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
-
listFiles
public File[] listFiles() throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsList the files in the current directory- Specified by:
listFilesin interfaceGenericFileOperations<File>- Returns:
- a list of backing objects representing the files
- Throws:
GenericFileOperationFailedException- can be thrown
-
listFiles
public File[] listFiles(String path) throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsList the files in the given remote directory- Specified by:
listFilesin interfaceGenericFileOperations<File>- Parameters:
path- the remote directory- Returns:
- a list of backing objects representing the files
- Throws:
GenericFileOperationFailedException- can be thrown
-
changeCurrentDirectory
public void changeCurrentDirectory(String path) throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsChange the current remote directory- Specified by:
changeCurrentDirectoryin interfaceGenericFileOperations<File>- Parameters:
path- the path to change to- Throws:
GenericFileOperationFailedException- can be thrown
-
changeToParentDirectory
public void changeToParentDirectory() throws GenericFileOperationFailedExceptionDescription copied from interface:GenericFileOperationsChange the current remote directory to the parent- Specified by:
changeToParentDirectoryin interfaceGenericFileOperations<File>- Throws:
GenericFileOperationFailedException- can be thrown
-
getCurrentDirectory
public String getCurrentDirectory() throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsGets the current remote directory- Specified by:
getCurrentDirectoryin interfaceGenericFileOperations<File>- Returns:
- the current directory path
- Throws:
GenericFileOperationFailedException- can be thrown
-
retrieveFile
public boolean retrieveFile(String name, org.apache.camel.Exchange exchange, long size) throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsRetrieves the file- Specified by:
retrieveFilein interfaceGenericFileOperations<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
public void releaseRetrievedFileResources(org.apache.camel.Exchange exchange) throws GenericFileOperationFailedExceptionDescription copied from interface:GenericFileOperationsReleases the resources consumed by a retrieved file- Specified by:
releaseRetrievedFileResourcesin interfaceGenericFileOperations<File>- Parameters:
exchange- exchange with the content of the file- Throws:
GenericFileOperationFailedException- can be thrown
-
storeFile
public boolean storeFile(String fileName, org.apache.camel.Exchange exchange, long size) throws GenericFileOperationFailedException
Description copied from interface:GenericFileOperationsStores the content as a new remote file (upload)- Specified by:
storeFilein interfaceGenericFileOperations<File>- Parameters:
fileName- 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
-
-