Class VFSConnectionManagerHelper
VFSConnectionManagerHelper
class contains connection management logic which is VFS-specific.
Specifically, this class contains logic which is common to all VFS providers. Logic which is VFS-provider-specific is
instead handled by implementations of VFSConnectionProvider<VFSConnectionDetails>
.
The ConnectionManager
delegates certain operations to this helper class, for VFSConnectionDetails
connections. For example, this is the case of ConnectionManager.test(ConnectionDetails)
.
However, this class can also be used directly, to gain access to VFS-specific functionality, not exposed generically
via ConnectionManager
.
This pattern may work in the future if ConnectionManager
is expanded to work with other connection types,
such as database connections.
-
Constructor Summary
ConstructorDescriptionVFSConnectionManagerHelper
(ConnectionFileNameUtils vfsConnectionFileNameUtils) -
Method Summary
Modifier and TypeMethodDescriptiongetAllDetails
(ConnectionManager manager) <T extends VFSConnectionDetails>
VFSConnectionProvider<T>getExistingProvider
(ConnectionManager manager, String key) Gets a VFS connection provider, given its key, and throwing an exception if one is not defined.<T extends VFSConnectionDetails>
VFSConnectionProvider<T>getExistingProvider
(ConnectionManager manager, T details) Gets a VFS provider, given the details of the VFS connection, and throwing an exception if one is not defined.static VFSConnectionManagerHelper
<T extends VFSConnectionDetails>
VFSConnectionProvider<T>getProvider
(ConnectionManager manager, String key) Gets a VFS connection provider, given its key.<T extends VFSConnectionDetails>
VFSConnectionProvider<T>getProvider
(ConnectionManager manager, T details) Gets a VFS provider, given the details of the VFS connection.getProviders
(ConnectionManager manager) getResolvedRootPath
(VFSConnectionDetails details) Gets the resolved root path of a given connection.protected String
normalizeRootPath
(String rootPath) <T extends VFSConnectionDetails>
booleantest
(ConnectionManager manager, T details, VFSConnectionTestOptions options) Tests if a VFS connection is valid, given its details, optionally, with certain testing options.boolean
usesBuckets
(VFSConnectionDetails details) Indicates if a VFS connection, given its details, uses buckets in its current configuration.
-
Constructor Details
-
VFSConnectionManagerHelper
public VFSConnectionManagerHelper() -
VFSConnectionManagerHelper
-
-
Method Details
-
getInstance
-
getProviders
public List<VFSConnectionProvider<VFSConnectionDetails>> getProviders(@NonNull ConnectionManager manager) -
getAllDetails
-
getProvider
@Nullable public <T extends VFSConnectionDetails> VFSConnectionProvider<T> getProvider(@NonNull ConnectionManager manager, @Nullable String key) Gets a VFS connection provider, given its key.A provider key is either its own
ConnectionProvider.getKey()
or a registered alias, viaConnectionManager.addLookupFilter(LookupFilter)
.This method will throw a
ClassCastException
exception if a provider with the given key is defined which is not of the expected type,VFSConnectionProvider<T extends VFSConnectionDetails>
.- Parameters:
key
- The VFS connection provider key.- Returns:
- The VFS connection provider, if one exists;
null
, otherwise.
-
getExistingProvider
@NonNull public <T extends VFSConnectionDetails> VFSConnectionProvider<T> getExistingProvider(@NonNull ConnectionManager manager, @Nullable String key) throws KettleException Gets a VFS connection provider, given its key, and throwing an exception if one is not defined.A provider key is either its own
ConnectionProvider.getKey()
or a registered alias, viaConnectionManager.addLookupFilter(LookupFilter)
.This method will throw a
ClassCastException
exception if a provider with the given key is defined which is not of the expected type,VFSConnectionProvider<T extends VFSConnectionDetails>
.- Parameters:
key
- The provider key.- Returns:
- The VFS connection provider.
- Throws:
KettleException
- When a provider with the given key is not defined.
-
getProvider
@Nullable public <T extends VFSConnectionDetails> VFSConnectionProvider<T> getProvider(@NonNull ConnectionManager manager, @Nullable T details) Gets a VFS provider, given the details of the VFS connection.This method will throw a
ClassCastException
exception if a provider with the given key is defined which is not of the expected type,VFSConnectionProvider<T extends VFSConnectionDetails>
.- Parameters:
details
- The details of the VFS connection.- Returns:
- The VFS connection provider, if one exists;
null
, otherwise.
-
getExistingProvider
@NonNull public <T extends VFSConnectionDetails> VFSConnectionProvider<T> getExistingProvider(@NonNull ConnectionManager manager, @NonNull T details) throws KettleException Gets a VFS provider, given the details of the VFS connection, and throwing an exception if one is not defined.- Parameters:
details
- The details of the VFS connection.- Returns:
- The VFS connection provider.
- Throws:
KettleException
- When a provider with the given key is not defined.
-
getConnectionRootFileName
-
getResolvedRootPath
@Nullable public String getResolvedRootPath(@NonNull VFSConnectionDetails details) throws KettleException Gets the resolved root path of a given connection.This method returns the value of the
root path
after any variables substituted and subsequent normalization.Root path normalization fixes separators, resolves "." and ".." segments, and removes any leading and trailing path separator.
Root path normalization does not affect the encoding of the original root path value, after variable substitution, which should be that of the specific connection/file provider.
- Parameters:
details
- The VFS connection details.- Returns:
- The non-empty resolved root path, if any;
null
, if. none. - Throws:
KettleException
-
normalizeRootPath
- Throws:
KettleException
-
test
public <T extends VFSConnectionDetails> boolean test(@NonNull ConnectionManager manager, @NonNull T details, @Nullable VFSConnectionTestOptions options) throws KettleException Tests if a VFS connection is valid, given its details, optionally, with certain testing options.This method first delegates to
ConnectionProvider.test(ConnectionDetails)
to perform basic validation, independent of the connection's root path,VFSConnectionDetails.getRootPath()
, if any, immediately returningfalse
, when unsuccessful.When base validation is successful, if
options
has atrue
VFSConnectionTestOptions.isRootPathIgnored()
, this method should immediately returntrue
.Otherwise, the method should validate that the connection's root folder path is valid, taking into account the values of
VFSConnectionDetails.isRootPathSupported()
,VFSConnectionDetails.isRootPathRequired()
andVFSConnectionDetails.getRootPath()
.- Parameters:
manager
- The connection manager.details
- The details of the VFS connection to test.options
- The testing options, ornull
. Whennull
, a default instance ofVFSConnectionTestOptions
is constructed and used.- Returns:
true
if the connection is valid;false
otherwise.- Throws:
KettleException
-
usesBuckets
Indicates if a VFS connection, given its details, uses buckets in its current configuration.A VFS connection is using buckets if it can have buckets, as determined by
VFSConnectionDetails.hasBuckets()
, and if itsresolved root path
isnull
.- Parameters:
details
- The VFS connection to check.- Returns:
true
if a connection uses buckets;false
otherwise.- Throws:
KettleException
-