Class AbstractSFTPAction
java.lang.Object
com.kingsrook.qqq.backend.module.filesystem.base.actions.AbstractBaseFilesystemAction<SFTPDirEntryWithPath>
com.kingsrook.qqq.backend.module.filesystem.sftp.actions.AbstractSFTPAction
- Direct Known Subclasses:
SFTPCountAction
,SFTPDeleteAction
,SFTPInsertAction
,SFTPQueryAction
,SFTPStorageAction
,SFTPTestConnectionAction
Base class for all SFTP filesystem actions
-
Field Summary
Fields inherited from class com.kingsrook.qqq.backend.module.filesystem.base.actions.AbstractBaseFilesystemAction
backendVariantRecord
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteFile
(QTableMetaData table, String fileReference) In contrast with the DeleteAction, which deletes RECORDS - this is a filesystem-(or s3, sftp, etc)-specific extension to delete an entire FILE e.g., for post-ETL.getFileCreateDate
(SFTPDirEntryWithPath sftpDirEntryWithPath) get the createDate of the specified file, null if not supported/availablegetFileModifyDate
(SFTPDirEntryWithPath sftpDirEntryWithPath) get the createDate of the specified file, null if not supported/availablegetFileSize
(SFTPDirEntryWithPath sftpDirEntryWithPath) get the size of the specified file, null if not supported/availablegetFullPathForFile
(SFTPDirEntryWithPath dirEntry) Get a string that represents the full path to a file.protected org.apache.sshd.sftp.client.SftpClient
getSftpClient
(QBackendMetaData backend) listFiles
(QTableMetaData table, QBackendMetaData backendBase, String requestedPath) List the files for a table - or optionally, just a single file name - to be implemented in module-specific subclasses.protected org.apache.sshd.sftp.client.SftpClient
makeConnection
(String username, String hostName, Integer port, String password, byte[] privateKeyBytes) void
moveFile
(QInstance instance, QTableMetaData table, String source, String destination) Move a file from a source path, to a destination path.static byte[]
pemStringToDecodedBytes
(String pemString) take a string, which is the contents of a PEM file (like a private key) - and if it has the -----BEGIN...----- and -----END...---- lines, strip them away, and strip away any whitespace, and then base-64 decode it.void
Method that subclasses can override to add post-action things (e.g., closing resources)void
preAction
(QBackendMetaData backendMetaData) Set up the sftp utils object to be used for this action.readFile
(SFTPDirEntryWithPath dirEntry) Read the contents of a file - to be implemented in module-specific subclasses.void
writeFile
(QBackendMetaData backend, QTableMetaData table, QRecord record, String path, byte[] contents) Write a file - to be implemented in module-specific subclasses.Methods inherited from class com.kingsrook.qqq.backend.module.filesystem.base.actions.AbstractBaseFilesystemAction
addBackendDetailsToRecord, addBackendDetailsToRecords, executeCount, executeDelete, executeInsert, executeQuery, getBackendMetaData, getFullBasePath, getTableBackendDetails, isPathEqualsCriteria, listFiles, stripBackendAndTableBasePathsFromFileName, stripDuplicatedSlashes, stripLeadingSlash, stripTrailingSlash, writeFile
-
Constructor Details
-
AbstractSFTPAction
public AbstractSFTPAction()
-
-
Method Details
-
preAction
Set up the sftp utils object to be used for this action.- Overrides:
preAction
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
- Throws:
QException
-
postAction
public void postAction()Description copied from class:AbstractBaseFilesystemAction
Method that subclasses can override to add post-action things (e.g., closing resources)- Overrides:
postAction
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
makeConnection
-
getFileSize
Description copied from class:AbstractBaseFilesystemAction
get the size of the specified file, null if not supported/available- Specified by:
getFileSize
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
getFileCreateDate
Description copied from class:AbstractBaseFilesystemAction
get the createDate of the specified file, null if not supported/available- Specified by:
getFileCreateDate
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
getFileModifyDate
Description copied from class:AbstractBaseFilesystemAction
get the createDate of the specified file, null if not supported/available- Specified by:
getFileModifyDate
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
listFiles
public List<SFTPDirEntryWithPath> listFiles(QTableMetaData table, QBackendMetaData backendBase, String requestedPath) throws QException Description copied from class:AbstractBaseFilesystemAction
List the files for a table - or optionally, just a single file name - to be implemented in module-specific subclasses.- Specified by:
listFiles
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
- Throws:
QException
-
readFile
Description copied from class:AbstractBaseFilesystemAction
Read the contents of a file - to be implemented in module-specific subclasses.- Specified by:
readFile
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
- Throws:
IOException
-
writeFile
public void writeFile(QBackendMetaData backend, QTableMetaData table, QRecord record, String path, byte[] contents) throws IOException Description copied from class:AbstractBaseFilesystemAction
Write a file - to be implemented in module-specific subclasses.- Specified by:
writeFile
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
- Throws:
IOException
-
getFullPathForFile
Description copied from class:AbstractBaseFilesystemAction
Get a string that represents the full path to a file.- Specified by:
getFullPathForFile
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
deleteFile
Description copied from class:AbstractBaseFilesystemAction
In contrast with the DeleteAction, which deletes RECORDS - this is a filesystem-(or s3, sftp, etc)-specific extension to delete an entire FILE e.g., for post-ETL.- Specified by:
deleteFile
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
- Throws:
FilesystemException
- if the delete is known to have failed, and the file is thought to still exit
-
moveFile
public void moveFile(QInstance instance, QTableMetaData table, String source, String destination) throws FilesystemException Description copied from class:AbstractBaseFilesystemAction
Move a file from a source path, to a destination path.- Specified by:
moveFile
in classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
- Throws:
FilesystemException
- if the move is known to have failed
-
getSftpClient
protected org.apache.sshd.sftp.client.SftpClient getSftpClient(QBackendMetaData backend) throws QException - Throws:
QException
-
pemStringToDecodedBytes
take a string, which is the contents of a PEM file (like a private key) - and if it has the -----BEGIN...----- and -----END...---- lines, strip them away, and strip away any whitespace, and then base-64 decode it.
-