public class GenericFilesystemOptionsProvider extends Object implements IFilesystemOptionsProvider, IXMLConfigurable
Generic implementation of IFilesystemOptionsProvider
. This provider
makes configurable many Commons VFS options. The same
FileSystemOptions
instance is returned regardless of
the FileObject
supplied. In many case, it is not necessary
to configure any file system options.
It is usually recommended to provide credentials here instead of doing
so directly on the requested URL to prevent password from appearing
in log entries.
The authPassword
can take a password that has been encrypted using EncryptionUtil
.
In order for the password to be decrypted properly by the crawler, you need
to specify the encryption key used to encrypt it. The key can be stored
in a few supported locations and a combination of
[auth|proxy]PasswordKey
and [auth|proxy]PasswordKeySource
must be specified to properly
locate the key. The supported sources are:
[...]PasswordKeySource |
[...]PasswordKey |
---|---|
key |
The actual encryption key. |
file |
Path to a file containing the encryption key. |
environment |
Name of an environment variable containing the key. |
property |
Name of a JVM system property containing the key. |
Still, if you insist in having the password set on the URL, Apache
Commons VFS offers a way to encrypt it there using their own
EncryptUtil
. More info under the "Naming" section here:
http://commons.apache.org/proper/commons-vfs/filesystems.html
You will not find methods or XML configuration tags for all options
supported by various file systems. If you need to configure more
advanced options for your file system, consider having your own
implementation of IFilesystemOptionsProvider
or extend this class
and implement the buildOptions(FileSystemOptions)
method to
set additional options.
As of 2.9.0, CMIS-enabled Content Management Systems (CMS) are supported
(Atom end-point).
The start path can be specified as:
cmis-atom:http://yourhost:port/path/to/atom
.
Optionally you can have a non-root starting path by adding the path
name to the base URL, with an exclamation mark as a separator:
cmis-atom:http://yourhost:port/path/to/atom!/MyFolder/MySubFolder
.
Start paths are assumed to be Atom URLs.
As of 2.7.0, XML configuration entries expecting millisecond durations
can be provided in human-readable format (English only), as per
DurationParser
(e.g., "5 minutes and 30 seconds" or "5m30s").
<optionsProvider class="com.norconex.collector.fs.option.impl.GenericFilesystemOptionsProvider"> <!-- Authentication (any file system) --> <authDomain>...</authDomain> <authUsername>...</authUsername> <authPassword>...</authPassword> <!-- Use the following if password is encrypted. --> <authPasswordKey>(the encryption key or a reference to it)</authPasswordKey> <authPasswordKeySource>[key|file|environment|property]</authPasswordKeySource> <!-- FTP (for FTPS options set ftpSecure to "true") --> <ftpSecure>[false|true]</ftpSecure> <ftpConnectTimeout>(milliseconds)</ftpConnectTimeout> <ftpControlEncoding>...</ftpControlEncoding> <ftpDataTimeout>(milliseconds)</ftpDataTimeout> <ftpDefaultDateFormat>...</ftpDefaultDateFormat> <ftpFileType>[ASCII|BINARY|LOCAL|EBCDIC]</ftpFileType> <ftpPassiveMode>[false|true]</ftpPassiveMode> <ftpRecentDateFormat>...</ftpRecentDateFormat> <ftpRemoteVerification>[false|true]</ftpRemoteVerification> <ftpServerLanguageCode>...</ftpServerLanguageCode> <ftpServerTimeZoneId>...</ftpServerTimeZoneId> <ftpShortMonthNames>(comma-separated list)</ftpShortMonthNames> <ftpSoTimeout>(milliseconds)</ftpSoTimeout> <ftpUserDirIsRoot>[false|true]</ftpUserDirIsRoot> <!-- HDFS --> <hdfsConfigName>...</hdfsConfigName> <hdfsConfigPath>...</hdfsConfigPath> <hdfsConfigURL>...</hdfsConfigURL> <!-- HTTP (for Webdav options, set httpWebdav to "true") --> <httpWebdav>[false|true]</httpWebdav> <httpConnectionTimeout>(milliseconds)</httpConnectionTimeout> <httpFollowRedirect>[false|true]</httpFollowRedirect> <httpMaxConnectionsPerHost>...</httpMaxConnectionsPerHost> <httpMaxTotalConnections>...</httpMaxTotalConnections> <httpPreemptiveAuth>[false|true]</httpPreemptiveAuth> <httpSoTimeout>(milliseconds)</httpSoTimeout> <httpUrlCharset>...</httpUrlCharset> <httpUserAgent>...</httpUserAgent> <httpWebdavCreatorName>...</httpWebdavCreatorName> <httpWebdavVersioning>[false|true]</httpWebdavVersioning> <!-- RAM --> <ramMaxSize>(number of bytes)</ramMaxSize> <!-- SFTP --> <sftpCompression>...</sftpCompression> <sftpFileNameEncoding>...</sftpFileNameEncoding> <sftpKnownHosts>...</sftpKnownHosts> <sftpPreferredAuthentications>...</sftpPreferredAuthentications> <sftpStrictHostKeyChecking>[no|yes|ask]</sftpStrictHostKeyChecking> <sftpTimeout>(milliseconds)</sftpTimeout> <sftpUserDirIsRoot>[false|true]</sftpUserDirIsRoot> <!-- CMIS --> <cmisRepositoryId> (Optional repository ID, defaults to first one found.) </cmisRepositoryId> <cmisXmlTargetField> (Optional target field name where to store the raw CMIS REST API XML. Default does not store the raw XML in a field.) </cmisXmlTargetField> </optionsProvider>
The following sets the FTP settings sometimes required to get directory listings on remote servers.
<optionsProvider class="com.norconex.collector.fs.option.impl.GenericFilesystemOptionsProvider"> <ftpPassiveMode>true</ftpPassiveMode> <ftpUserDirIsRoot>false</ftpUserDirIsRoot> </optionsProvider>
Constructor and Description |
---|
GenericFilesystemOptionsProvider() |
Modifier and Type | Method and Description |
---|---|
protected void |
buildOptions(org.apache.commons.vfs2.FileSystemOptions opts)
For subclasses to apply more advanced configuration on file system
options.
|
boolean |
equals(Object other) |
String |
getAuthDomain()
Gets the authentication domain.
|
String |
getAuthPassword()
Gets the authentication password.
|
EncryptionKey |
getAuthPasswordKey()
Gets the authentication password encryption key.
|
String |
getAuthUsername()
Gets the authentication username.
|
String |
getCmisRepositoryId()
Gets CMIS repository ID.
|
String |
getCmisXmlTargetField()
Sets the name of the field where the raw XML obtained from
the CMIS REST API will be stored.
|
org.apache.commons.vfs2.FileSystemOptions |
getFilesystemOptions(org.apache.commons.vfs2.FileObject fileObject)
Provide file system options associated with a file object.
|
Integer |
getFtpConnectTimeout() |
String |
getFtpControlEncoding() |
Integer |
getFtpDataTimeout() |
String |
getFtpDefaultDateFormat() |
org.apache.commons.vfs2.provider.ftp.FtpFileType |
getFtpFileType() |
String |
getFtpRecentDateFormat() |
String |
getFtpServerLanguageCode() |
String |
getFtpServerTimeZoneId() |
String[] |
getFtpShortMonthNames() |
Integer |
getFtpSoTimeout() |
String |
getHdfsConfigName() |
org.apache.hadoop.fs.Path |
getHdfsConfigPath() |
URL |
getHdfsConfigURL() |
int |
getHttpConnectionTimeout() |
int |
getHttpMaxConnectionsPerHost() |
int |
getHttpMaxTotalConnections() |
int |
getHttpSoTimeout() |
String |
getHttpUrlCharset() |
String |
getHttpUserAgent() |
String |
getHttpWebdavCreatorName() |
long |
getRamMaxSize() |
String |
getSftpCompression() |
String |
getSftpFileNameEncoding() |
File |
getSftpKnownHosts() |
String |
getSftpPreferredAuthentications() |
String |
getSftpStrictHostKeyChecking() |
int |
getSftpTimeout() |
int |
hashCode() |
boolean |
isFtpPassiveMode() |
boolean |
isFtpRemoteVerification() |
boolean |
isFtpSecure() |
boolean |
isFtpUserDirIsRoot() |
boolean |
isHttpFollowRedirect() |
boolean |
isHttpPreemptiveAuth() |
boolean |
isHttpWebdav() |
boolean |
isHttpWebdavVersioning() |
boolean |
isSftpUserDirIsRoot() |
void |
loadFromXML(Reader in) |
void |
rebuildOptions()
Rebuilds file system options.
|
void |
saveToXML(Writer out) |
void |
setAuthDomain(String authDomain)
Sets the authentication domain.
|
void |
setAuthPassword(String authPassword)
Sets the authentication password.
|
void |
setAuthPasswordKey(EncryptionKey authPasswordKey)
Sets the authentication password encryption key.
|
void |
setAuthUsername(String authUsername)
Sets the authentication username.
|
void |
setCmisRepositoryId(String cmisRepositoryId)
Sets CMIS repository ID.
|
void |
setCmisXmlTargetField(String cmisXmlTargetField)
Sets the name of the field where the raw XML obtained from
the CMIS REST API will be stored.
|
void |
setFtpConnectTimeout(Integer ftpConnectTimeout) |
void |
setFtpControlEncoding(String ftpControlEncoding) |
void |
setFtpDataTimeout(Integer ftpDataTimeout) |
void |
setFtpDefaultDateFormat(String ftpDefaultDateFormat) |
void |
setFtpFileType(org.apache.commons.vfs2.provider.ftp.FtpFileType ftpFileType) |
void |
setFtpPassiveMode(boolean ftpPassiveMode) |
void |
setFtpRecentDateFormat(String ftpRecentDateFormat) |
void |
setFtpRemoteVerification(boolean ftpRemoteVerification) |
void |
setFtpSecure(boolean ftpSecure) |
void |
setFtpServerLanguageCode(String ftpServerLanguageCode) |
void |
setFtpServerTimeZoneId(String ftpServerTimeZoneId) |
void |
setFtpShortMonthNames(String... ftpShortMonthNames) |
void |
setFtpSoTimeout(Integer ftpSoTimeout) |
void |
setFtpUserDirIsRoot(boolean ftpUserDirIsRoot) |
void |
setHdfsConfigName(String hdfsConfigName) |
void |
setHdfsConfigPath(org.apache.hadoop.fs.Path hdfsConfigPath) |
void |
setHdfsConfigURL(URL hdfsConfigURL) |
void |
setHttpConnectionTimeout(int httpConnectionTimeout) |
void |
setHttpFollowRedirect(boolean httpFollowRedirect) |
void |
setHttpMaxConnectionsPerHost(int httpMaxConnectionsPerHost) |
void |
setHttpMaxTotalConnections(int httpMaxTotalConnections) |
void |
setHttpPreemptiveAuth(boolean httpPreemptiveAuth) |
void |
setHttpSoTimeout(int httpSoTimeout) |
void |
setHttpUrlCharset(String httpUrlCharset) |
void |
setHttpUserAgent(String httpUserAgent) |
void |
setHttpWebdav(boolean httpWebdav) |
void |
setHttpWebdavCreatorName(String httpWebdavCreatorName) |
void |
setHttpWebdavVersioning(boolean httpWebdavVersioning) |
void |
setRamMaxSize(long ramMaxSize) |
void |
setSftpCompression(String sftpCompression) |
void |
setSftpFileNameEncoding(String sftpFileNameEncoding) |
void |
setSftpKnownHosts(File sftpKnownHosts) |
void |
setSftpPreferredAuthentications(String sftpPreferredAuthentications) |
void |
setSftpStrictHostKeyChecking(String sftpStrictHostKeyChecking) |
void |
setSftpTimeout(int sftpTimeout) |
void |
setSftpUserDirIsRoot(boolean sftpUserDirIsRoot) |
String |
toString() |
public void rebuildOptions()
protected void buildOptions(org.apache.commons.vfs2.FileSystemOptions opts)
opts
- file system optionspublic String getAuthDomain()
public void setAuthDomain(String authDomain)
authDomain
- domainpublic String getAuthUsername()
public void setAuthUsername(String authUsername)
authUsername
- usernamepublic String getAuthPassword()
public void setAuthPassword(String authPassword)
authPassword
- passwordpublic EncryptionKey getAuthPasswordKey()
null
if the password is not
encrypted.EncryptionUtil
public void setAuthPasswordKey(EncryptionKey authPasswordKey)
authPasswordKey
- password keyEncryptionUtil
public Integer getFtpConnectTimeout()
public void setFtpConnectTimeout(Integer ftpConnectTimeout)
public String getFtpControlEncoding()
public void setFtpControlEncoding(String ftpControlEncoding)
public Integer getFtpDataTimeout()
public void setFtpDataTimeout(Integer ftpDataTimeout)
public String getFtpDefaultDateFormat()
public void setFtpDefaultDateFormat(String ftpDefaultDateFormat)
public org.apache.commons.vfs2.provider.ftp.FtpFileType getFtpFileType()
public void setFtpFileType(org.apache.commons.vfs2.provider.ftp.FtpFileType ftpFileType)
public boolean isFtpPassiveMode()
public void setFtpPassiveMode(boolean ftpPassiveMode)
public String getFtpRecentDateFormat()
public void setFtpRecentDateFormat(String ftpRecentDateFormat)
public boolean isFtpRemoteVerification()
public void setFtpRemoteVerification(boolean ftpRemoteVerification)
public String getFtpServerLanguageCode()
public void setFtpServerLanguageCode(String ftpServerLanguageCode)
public String getFtpServerTimeZoneId()
public void setFtpServerTimeZoneId(String ftpServerTimeZoneId)
public String[] getFtpShortMonthNames()
public void setFtpShortMonthNames(String... ftpShortMonthNames)
public Integer getFtpSoTimeout()
public void setFtpSoTimeout(Integer ftpSoTimeout)
public boolean isFtpUserDirIsRoot()
public void setFtpUserDirIsRoot(boolean ftpUserDirIsRoot)
public boolean isFtpSecure()
public void setFtpSecure(boolean ftpSecure)
public String getHdfsConfigName()
public void setHdfsConfigName(String hdfsConfigName)
public org.apache.hadoop.fs.Path getHdfsConfigPath()
public void setHdfsConfigPath(org.apache.hadoop.fs.Path hdfsConfigPath)
public URL getHdfsConfigURL()
public void setHdfsConfigURL(URL hdfsConfigURL)
public int getHttpConnectionTimeout()
public void setHttpConnectionTimeout(int httpConnectionTimeout)
public boolean isHttpFollowRedirect()
public void setHttpFollowRedirect(boolean httpFollowRedirect)
public int getHttpMaxConnectionsPerHost()
public void setHttpMaxConnectionsPerHost(int httpMaxConnectionsPerHost)
public int getHttpMaxTotalConnections()
public void setHttpMaxTotalConnections(int httpMaxTotalConnections)
public boolean isHttpPreemptiveAuth()
public void setHttpPreemptiveAuth(boolean httpPreemptiveAuth)
public int getHttpSoTimeout()
public void setHttpSoTimeout(int httpSoTimeout)
public String getHttpUrlCharset()
public void setHttpUrlCharset(String httpUrlCharset)
public String getHttpUserAgent()
public void setHttpUserAgent(String httpUserAgent)
public boolean isHttpWebdav()
public void setHttpWebdav(boolean httpWebdav)
public String getHttpWebdavCreatorName()
public void setHttpWebdavCreatorName(String httpWebdavCreatorName)
public boolean isHttpWebdavVersioning()
public void setHttpWebdavVersioning(boolean httpWebdavVersioning)
public long getRamMaxSize()
public void setRamMaxSize(long ramMaxSize)
public String getSftpCompression()
public void setSftpCompression(String sftpCompression)
public String getSftpFileNameEncoding()
public void setSftpFileNameEncoding(String sftpFileNameEncoding)
public File getSftpKnownHosts()
public void setSftpKnownHosts(File sftpKnownHosts)
public String getSftpPreferredAuthentications()
public void setSftpPreferredAuthentications(String sftpPreferredAuthentications)
public String getSftpStrictHostKeyChecking()
public void setSftpStrictHostKeyChecking(String sftpStrictHostKeyChecking)
public int getSftpTimeout()
public void setSftpTimeout(int sftpTimeout)
public boolean isSftpUserDirIsRoot()
public void setSftpUserDirIsRoot(boolean sftpUserDirIsRoot)
public String getCmisRepositoryId()
public void setCmisRepositoryId(String cmisRepositoryId)
cmisRepositoryId
- repository IDpublic String getCmisXmlTargetField()
null
(does not store the raw XML).public void setCmisXmlTargetField(String cmisXmlTargetField)
cmisXmlTargetField
- target fieldpublic org.apache.commons.vfs2.FileSystemOptions getFilesystemOptions(org.apache.commons.vfs2.FileObject fileObject)
IFilesystemOptionsProvider
getFilesystemOptions
in interface IFilesystemOptionsProvider
fileObject
- the file for which to get optionspublic void loadFromXML(Reader in) throws IOException
loadFromXML
in interface IXMLConfigurable
IOException
public void saveToXML(Writer out) throws IOException
saveToXML
in interface IXMLConfigurable
IOException
Copyright © 2014–2023 Norconex Inc.. All rights reserved.