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 TypeMethodDescriptionvoiddeleteFile(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.SftpClientgetSftpClient(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.SftpClientmakeConnection(String username, String hostName, Integer port, String password, byte[] privateKeyBytes) voidmoveFile(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.voidMethod that subclasses can override to add post-action things (e.g., closing resources)voidpreAction(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.voidwriteFile(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:
preActionin classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>- Throws:
QException
-
postAction
public void postAction()Description copied from class:AbstractBaseFilesystemActionMethod that subclasses can override to add post-action things (e.g., closing resources)- Overrides:
postActionin classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
makeConnection
-
getFileSize
Description copied from class:AbstractBaseFilesystemActionget the size of the specified file, null if not supported/available- Specified by:
getFileSizein classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
getFileCreateDate
Description copied from class:AbstractBaseFilesystemActionget the createDate of the specified file, null if not supported/available- Specified by:
getFileCreateDatein classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
getFileModifyDate
Description copied from class:AbstractBaseFilesystemActionget the createDate of the specified file, null if not supported/available- Specified by:
getFileModifyDatein classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
listFiles
public List<SFTPDirEntryWithPath> listFiles(QTableMetaData table, QBackendMetaData backendBase, String requestedPath) throws QException Description copied from class:AbstractBaseFilesystemActionList the files for a table - or optionally, just a single file name - to be implemented in module-specific subclasses.- Specified by:
listFilesin classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>- Throws:
QException
-
readFile
Description copied from class:AbstractBaseFilesystemActionRead the contents of a file - to be implemented in module-specific subclasses.- Specified by:
readFilein classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>- Throws:
IOException
-
writeFile
public void writeFile(QBackendMetaData backend, QTableMetaData table, QRecord record, String path, byte[] contents) throws IOException Description copied from class:AbstractBaseFilesystemActionWrite a file - to be implemented in module-specific subclasses.- Specified by:
writeFilein classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>- Throws:
IOException
-
getFullPathForFile
Description copied from class:AbstractBaseFilesystemActionGet a string that represents the full path to a file.- Specified by:
getFullPathForFilein classAbstractBaseFilesystemAction<SFTPDirEntryWithPath>
-
deleteFile
Description copied from class:AbstractBaseFilesystemActionIn 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:
deleteFilein 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:AbstractBaseFilesystemActionMove a file from a source path, to a destination path.- Specified by:
moveFilein 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.
-