Class DefaultVFSConnectionFileNameTransformer<T extends VFSConnectionDetails>

java.lang.Object
org.pentaho.di.connections.vfs.DefaultVFSConnectionFileNameTransformer<T>
All Implemented Interfaces:
VFSConnectionFileNameTransformer<T>

public class DefaultVFSConnectionFileNameTransformer<T extends VFSConnectionDetails> extends Object implements VFSConnectionFileNameTransformer<T>
  • Constructor Details

  • Method Details

    • getConnectionManager

      @NonNull protected ConnectionManager getConnectionManager()
    • getVfsConnectionManagerHelper

      @NonNull protected VFSConnectionManagerHelper getVfsConnectionManagerHelper()
    • getConnectionFileNameUtils

      @NonNull protected ConnectionFileNameUtils getConnectionFileNameUtils()
    • toProviderFileName

      @NonNull public org.apache.commons.vfs2.FileName toProviderFileName(@NonNull ConnectionFileName pvfsFileName, @NonNull T details) throws KettleException
      Description copied from interface: VFSConnectionFileNameTransformer
      Transforms a PVFS file name to a provider file name.
      Specified by:
      toProviderFileName in interface VFSConnectionFileNameTransformer<T extends VFSConnectionDetails>
      Parameters:
      pvfsFileName - The PVFS file name.
      details - The connection details of the connection referenced by pvfsFileName.
      Returns:
      The provider file name.
      Throws:
      KettleException
    • appendProviderUriConnectionRoot

      protected void appendProviderUriConnectionRoot(@NonNull StringBuilder providerUriBuilder, @NonNull T details) throws KettleException
      Appends to the provider URI builder the root of the connection, which includes the scheme, the domain and the root path.

      The components appended to the builder may not be normalized. It is expected that an overall normalization step follows on the entirety of the provider URI string.

      Parameters:
      providerUriBuilder - The provider URI builder.
      details - The details of the connection.
      Throws:
      KettleException
    • appendProviderUriSchemePrefix

      protected void appendProviderUriSchemePrefix(@NonNull StringBuilder providerUriBuilder, @NonNull T details) throws KettleException
      Throws:
      KettleException
    • appendProviderUriDomain

      protected void appendProviderUriDomain(@NonNull StringBuilder providerUriBuilder, @NonNull T details) throws KettleException
      Throws:
      KettleException
    • appendProviderUriRootPath

      protected void appendProviderUriRootPath(@NonNull StringBuilder providerUriBuilder, @NonNull T details) throws KettleException
      Throws:
      KettleException
    • appendProviderUriRestPath

      protected void appendProviderUriRestPath(@NonNull StringBuilder providerUriBuilder, @NonNull String restPath, @NonNull T details) throws KettleException
      Appends the rest of the path to the provider URI string builder of a given connection.
      Parameters:
      providerUriBuilder - The provider URI string builder.
      restPath - The part of the original PVFS path following the PVFS connection root prefix.
      details - The associated connection details.
      Throws:
      KettleException
    • toPvfsFileName

      @NonNull public ConnectionFileName toPvfsFileName(@NonNull org.apache.commons.vfs2.FileName providerFileName, @NonNull T details) throws KettleException
      Description copied from interface: VFSConnectionFileNameTransformer
      Transforms a provider file name to a PVFS file name.
      Specified by:
      toPvfsFileName in interface VFSConnectionFileNameTransformer<T extends VFSConnectionDetails>
      Parameters:
      providerFileName - The provider file name.
      details - The connection details associated with providerFileName.
      Returns:
      The PVFS file name.
      Throws:
      KettleException
    • buildPvfsFileName

      @NonNull protected ConnectionFileName buildPvfsFileName(@NonNull T details, @NonNull String nonNormalizedRestPath, @NonNull org.apache.commons.vfs2.FileType fileType) throws KettleException
      Builds a PVFS file name for a connection given the URI path and the file type.

      Implementation Notes

      nonNormalizedRestPath may be using the URI encoding, resulting from FileName.getURI() (which is ensured by

      AbstractFileName#handleURISpecialCharacters(..)
      ), which additionally encodes " " and "#" on the URI path section, compared to only "%" in the path section of a ConnectionFileName.

      If the PVFS file name were built using

      connectionRootFileName#createName(nonNormalizedRestPath ..)
      , it could get a non-normalized path, which should not happen and is usually assured by the file name parser.

      The encoding of nonNormalizedRestPath could be normalized beforehand, by explicitly calling UriParser.canonicalizePath(StringBuilder, int, int, FileNameParser). However, that would be duplicating logic that only the file name parser should have.

      Opting instead to take the slower route of giving the URI to the parser for full parsing, normalization, and later re-considering if a performance bottleneck is found.

      Parameters:
      details - The details of the connection.
      nonNormalizedRestPath - The possibly non-normalized file name path.
      fileType - The file type.
      Returns:
      The PVFS file name.
      Throws:
      KettleException
    • normalizeConnectionRootProviderUriPrefix

      @NonNull protected String normalizeConnectionRootProviderUriPrefix(@NonNull String providerUriPrefix, @NonNull T details) throws KettleException
      Normalizes the connection root provider URI prefix.

      This method is used by the default implementation of toPvfsFileName(FileName, VFSConnectionDetails)

      This implementation normalizes the given URI prefixes by calling normalizeUri(String). However, the normalization is skipped for connections using buckets, according to VFSConnectionManagerHelper.usesBuckets(VFSConnectionDetails), and with no domain, given in general these URI prefixes cannot be normalized. If, for a specific connection type, special normalization is needed in this situation, define a custom transformer class and override this method.

      Parameters:
      providerUriPrefix - The connection root provider URI prefix.
      details - The details of the connection.
      Returns:
      A normalized connection root provider URI prefix.
      Throws:
      KettleException
    • normalizeUri

      @NonNull protected String normalizeUri(@NonNull String nonNormalizedUri) throws KettleException
      Normalizes a URI by parsing it into a file name and then obtaining its URI string.
      Parameters:
      nonNormalizedUri - The URI to normalize.
      Returns:
      The normalized URI.
      Throws:
      KettleException - If the given URI has an invalid syntax, including when it is a degenerate connection root provider URI prefix.
      See Also:
    • parseUri

      @NonNull protected <F extends org.apache.commons.vfs2.FileName> F parseUri(@NonNull String nonNormalizedUri) throws KettleException
      Parses a given PVFS or Provider URI string, which may not be in canonical form (w.r.t., for example, to separators, percent-encoding).

      The resulting file name can then be used to get a normalized path, via FileName.getPath(), or the URI, via FileName.getURI().

      Parameters:
      nonNormalizedUri - A URI string.
      Returns:
      The file name.
      Throws:
      KettleException