Class AbstractBaseFilesystemAction<FILE>

java.lang.Object
com.kingsrook.qqq.backend.module.filesystem.base.actions.AbstractBaseFilesystemAction<FILE>
Record Components:
FILE - The class that represents a file in the sub-module. e.g., a java.io.File, or an S3Object.
Direct Known Subclasses:
AbstractFilesystemAction, AbstractS3Action, AbstractSFTPAction

public abstract class AbstractBaseFilesystemAction<FILE> extends Object
Base class for all Filesystem actions across all modules.
  • Field Details

    • backendVariantRecord

      protected QRecord backendVariantRecord
  • Constructor Details

    • AbstractBaseFilesystemAction

      public AbstractBaseFilesystemAction()
  • Method Details

    • listFiles

      public List<FILE> listFiles(QTableMetaData table, QBackendMetaData backendBase) throws QException
      List the files for a table - to be implemented in module-specific subclasses.
      Throws:
      QException
    • getFileSize

      public abstract Long getFileSize(FILE file)
      get the size of the specified file, null if not supported/available
    • getFileCreateDate

      public abstract Instant getFileCreateDate(FILE file)
      get the createDate of the specified file, null if not supported/available
    • getFileModifyDate

      public abstract Instant getFileModifyDate(FILE file)
      get the createDate of the specified file, null if not supported/available
    • listFiles

      public abstract List<FILE> listFiles(QTableMetaData table, QBackendMetaData backendBase, String requestedSingleFileName) throws QException
      List the files for a table - or optionally, just a single file name - to be implemented in module-specific subclasses.
      Throws:
      QException
    • readFile

      public abstract InputStream readFile(FILE file) throws IOException
      Read the contents of a file - to be implemented in module-specific subclasses.
      Throws:
      IOException
    • writeFile

      @Deprecated(since="call the overload that takes table and record") public void writeFile(QBackendMetaData backend, String path, byte[] contents) throws IOException
      Deprecated.
      Legacy signature for this method - before table invalid input: '&' record params were added.
      Throws:
      IOException
    • writeFile

      public abstract void writeFile(QBackendMetaData backend, QTableMetaData table, QRecord record, String path, byte[] contents) throws IOException
      Write a file - to be implemented in module-specific subclasses.
      Throws:
      IOException
    • getFullPathForFile

      public abstract String getFullPathForFile(FILE file)
      Get a string that represents the full path to a file.
    • deleteFile

      public abstract void deleteFile(QTableMetaData table, String fileReference) throws FilesystemException
      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.
      Throws:
      FilesystemException - if the delete is known to have failed, and the file is thought to still exit
    • moveFile

      public abstract void moveFile(QInstance instance, QTableMetaData table, String source, String destination) throws FilesystemException
      Move a file from a source path, to a destination path.
      Throws:
      FilesystemException - if the move is known to have failed
    • stripBackendAndTableBasePathsFromFileName

      public String stripBackendAndTableBasePathsFromFileName(String filePath, QBackendMetaData backend, QTableMetaData table)
      e.g., with a base path of /foo/ and a table path of /bar/ and a file at /foo/bar/baz.txt give us just the baz.txt part.
    • getFullBasePath

      public String getFullBasePath(QTableMetaData table, QBackendMetaData backendBase)
      Append together the backend's base path (if present), with a table's base path (again, if present).
    • stripDuplicatedSlashes

      public static String stripDuplicatedSlashes(String path)
    • stripLeadingSlash

      public static String stripLeadingSlash(String path)
    • stripTrailingSlash

      public static String stripTrailingSlash(String path)
    • getBackendMetaData

      protected <T extends AbstractFilesystemBackendMetaData> T getBackendMetaData(Class<T> outputClass, QBackendMetaData metaData)
      Get the backend metaData, type-checked as the requested type.
    • getTableBackendDetails

      protected <T extends AbstractFilesystemTableBackendDetails> T getTableBackendDetails(Class<T> outputClass, QTableMetaData tableMetaData)
      Get the backendDetails out of a table, type-checked as the requested type
    • executeQuery

      public QueryOutput executeQuery(QueryInput queryInput) throws QException
      Generic implementation of the execute method from the QueryInterface
      Throws:
      QException
    • isPathEqualsCriteria

      protected static boolean isPathEqualsCriteria(QFilterCriteria criteria)
    • executeCount

      public CountOutput executeCount(CountInput countInput) throws QException
      Throws:
      QException
    • addBackendDetailsToRecords

      protected void addBackendDetailsToRecords(List<QRecord> recordsInFile, FILE file)
      Add backend details to records about the file that they are in.
    • addBackendDetailsToRecord

      protected void addBackendDetailsToRecord(QRecord record, FILE file)
      Add backend details to a record about the file that it is in.
    • preAction

      public void preAction(QBackendMetaData backendMetaData) throws QException
      Method that subclasses can override to add pre-action things (e.g., setting up s3 client).
      Throws:
      QException
    • postAction

      public void postAction()
      Method that subclasses can override to add post-action things (e.g., closing resources)
    • executeInsert

      protected InsertOutput executeInsert(InsertInput insertInput) throws QException
      Throws:
      QException
    • executeDelete

      protected DeleteOutput executeDelete(DeleteInput deleteInput) throws QException
      Throws:
      QException