Class DefaultVFSConnectionFileNameTransformer<T extends VFSConnectionDetails>
- All Implemented Interfaces:
VFSConnectionFileNameTransformer<T>
-
Constructor Summary
ConstructorDescriptionDefaultVFSConnectionFileNameTransformer
(ConnectionManager connectionManager) DefaultVFSConnectionFileNameTransformer
(ConnectionManager connectionManager, VFSConnectionManagerHelper vfsConnectionManagerHelper, ConnectionFileNameUtils connectionFileNameUtils) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
appendProviderUriConnectionRoot
(StringBuilder providerUriBuilder, T details) Appends to the provider URI builder the root of the connection, which includes the scheme, the domain and the root path.protected void
appendProviderUriDomain
(StringBuilder providerUriBuilder, T details) protected void
appendProviderUriRestPath
(StringBuilder providerUriBuilder, String restPath, T details) Appends the rest of the path to the provider URI string builder of a given connection.protected void
appendProviderUriRootPath
(StringBuilder providerUriBuilder, T details) protected void
appendProviderUriSchemePrefix
(StringBuilder providerUriBuilder, T details) protected ConnectionFileName
buildPvfsFileName
(T details, String nonNormalizedRestPath, org.apache.commons.vfs2.FileType fileType) Builds a PVFS file name for a connection given the URI path and the file type.protected ConnectionFileNameUtils
protected ConnectionManager
protected VFSConnectionManagerHelper
protected String
normalizeConnectionRootProviderUriPrefix
(String providerUriPrefix, T details) Normalizes the connection root provider URI prefix.protected String
normalizeUri
(String nonNormalizedUri) Normalizes a URI by parsing it into a file name and then obtaining its URI string.protected <F extends org.apache.commons.vfs2.FileName>
FParses a given PVFS or Provider URI string, which may not be in canonical form (w.r.t., for example, to separators, percent-encoding).org.apache.commons.vfs2.FileName
toProviderFileName
(ConnectionFileName pvfsFileName, T details) Transforms a PVFS file name to a provider file name.toPvfsFileName
(org.apache.commons.vfs2.FileName providerFileName, T details) Transforms a provider file name to a PVFS file name.
-
Constructor Details
-
DefaultVFSConnectionFileNameTransformer
-
DefaultVFSConnectionFileNameTransformer
public DefaultVFSConnectionFileNameTransformer(@NonNull ConnectionManager connectionManager, @NonNull VFSConnectionManagerHelper vfsConnectionManagerHelper, @NonNull ConnectionFileNameUtils connectionFileNameUtils)
-
-
Method Details
-
getConnectionManager
-
getVfsConnectionManagerHelper
-
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 interfaceVFSConnectionFileNameTransformer<T extends VFSConnectionDetails>
- Parameters:
pvfsFileName
- The PVFS file name.details
- The connection details of the connection referenced bypvfsFileName
.- 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 interfaceVFSConnectionFileNameTransformer<T extends VFSConnectionDetails>
- Parameters:
providerFileName
- The provider file name.details
- The connection details associated withproviderFileName
.- 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 fromFileName.getURI()
(which is ensured byAbstractFileName#handleURISpecialCharacters(..)
), which additionally encodes" "
and"#"
on the URI path section, compared to only"%"
in the path section of aConnectionFileName
.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 callingUriParser.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 toVFSConnectionManagerHelper.usesBuckets(VFSConnectionDetails)
, and with nodomain
, 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
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(String)
FileName.getURI()
-
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, viaFileName.getURI()
.- Parameters:
nonNormalizedUri
- A URI string.- Returns:
- The file name.
- Throws:
KettleException
-