Class ArchiveFetcher
- All Implemented Interfaces:
Configurable<ArchiveFetcherConfig>,EventListener<Event>,Fetcher,EventListener,Consumer<Event>
Fetcher for archive file systems treated as virtual directory trees. Each entry in the archive is crawled as an individual document, enabling recursive traversal and per-document metadata extraction.
This fetcher supports archives that wrap any inner file system, including
remote ones such as FTP or SFTP. When credentials are required to access
the inner file system (e.g., an FTP server hosting a ZIP file), configure
them via the ArchiveFetcherConfig — they are forwarded
automatically to the inner scheme.
Supported archive schemes (outer layer)
zip://— ZIP archivesjar://— JAR filestar://— TAR archivestgz://— Gzip-compressed TAR (alias fortar:gz://)tbz2://— Bzip2-compressed TAR (alias fortar:bz2://)gz:///gzip://— Gzip-compressed single filesbz2:///bzip2://— Bzip2-compressed single files
Example URIs
- Local:
zip:file:///backups/data.zip!/ - FTP:
zip:ftp://host/backups/data.zip!/ - SFTP:
tgz:sftp://host/exports/dump.tar.gz!/ - HTTP:
zip:https://example.com/release.zip!/
ZIP/JAR archives are mounted lazily via the JDK's built-in zipfs
provider (remote sources are first spooled to a local temporary file,
since zipfs requires true random access that remote NIO.2
providers such as FTP/SFTP do not support). TAR/GZIP/BZIP2 archives have
no such built-in provider and are instead fully extracted once to a
local temporary directory on first access, which is then treated like
any other local directory.
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptRequest(@NonNull FetchRequest fetchRequest) Optional method for subclasses to override when in need for additional acceptance logic beyond reference filters (which this abstract class provides).protected booleanbooleanprotected FolderPathsFetchResponseprotected voidfetcherShutdown(CrawlerSession crawler) Invoked once per fetcher when the crawler ends.protected voidfetcherStartup(CrawlerSession crawler) Invoked once per fetcher instance, when the crawler starts.inthashCode()protected PathresolvePath(String reference) Resolves a crawler reference (as found onDoc.getReference()) into a NIO.2Path.toString()Methods inherited from class com.norconex.crawler.fs.fetch.impl.AbstractNioFetcher
fetch, fetchContent, fetchFileObject, fetchMetadata, getOrOpenFileSystemMethods inherited from class com.norconex.crawler.core.fetch.AbstractFetcher
accept, accept
-
Constructor Details
-
ArchiveFetcher
public ArchiveFetcher()
-
-
Method Details
-
fetcherStartup
Description copied from class:AbstractFetcherInvoked once per fetcher instance, when the crawler starts. Default implementation does nothing.- Overrides:
fetcherStartupin classAbstractFetcher<ArchiveFetcherConfig>- Parameters:
crawler- crawler
-
fetcherShutdown
Description copied from class:AbstractFetcherInvoked once per fetcher when the crawler ends. Default implementation does nothing.- Overrides:
fetcherShutdownin classAbstractNioFetcher<ArchiveFetcherConfig>- Parameters:
crawler- crawler
-
acceptRequest
Description copied from class:AbstractFetcherOptional method for subclasses to override when in need for additional acceptance logic beyond reference filters (which this abstract class provides). This method is only invoked if there are no reference filters configured on this class, or all of them accepts the request document. Default implementation does nothing (always returntrue).- Overrides:
acceptRequestin classAbstractFetcher<ArchiveFetcherConfig>- Parameters:
fetchRequest- the fetch request to evaluate (nevernull)- Returns:
trueif accepted
-
resolvePath
Description copied from class:AbstractNioFetcherResolves a crawler reference (as found onDoc.getReference()) into a NIO.2Path.- Specified by:
resolvePathin classAbstractNioFetcher<ArchiveFetcherConfig>- Parameters:
reference- the reference to resolve- Returns:
- the resolved path
- Throws:
IOException- if the reference cannot be resolved
-
fetchChildPaths
protected FolderPathsFetchResponse fetchChildPaths(FolderPathsFetchRequest req) throws FetchException - Overrides:
fetchChildPathsin classAbstractNioFetcher<ArchiveFetcherConfig>- Throws:
FetchException
-
toString
- Overrides:
toStringin classAbstractNioFetcher<ArchiveFetcherConfig>
-
equals
- Overrides:
equalsin classAbstractNioFetcher<ArchiveFetcherConfig>
-
canEqual
- Overrides:
canEqualin classAbstractNioFetcher<ArchiveFetcherConfig>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractNioFetcher<ArchiveFetcherConfig>
-
getConfiguration
-