Package org.codelibs.fess.helper
Class ProtocolHelper
java.lang.Object
org.codelibs.fess.helper.ProtocolHelper
Helper class for managing and validating URL protocols in Fess crawling system.
This class handles the initialization and validation of web and file protocols
used by the crawler to determine which URLs can be crawled.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFileProtocol(String protocol) Adds a new file protocol to the supported protocols list.voidaddWebProtocol(String protocol) Adds a new web protocol to the supported protocols list.String[]Returns the array of supported file protocols.String[]Returns the array of supported web protocols.voidinit()Initializes the protocol helper by loading configured protocols from FessConfig and scanning for available protocol handlers in the classpath.booleanChecks if the given URL uses a valid file protocol.booleanisValidWebProtocol(String url) Checks if the given URL uses a valid web protocol.protected voidloadProtocols(String basePackage) Loads protocol handlers from the specified base package by scanning for Handler classes in subpackages and registering them as web or file protocols based on their PROTOCOL_TYPE field.
-
Field Details
-
webProtocols
Array of supported web protocols with colon suffix (e.g., "http:", "https:") -
fileProtocols
Array of supported file protocols with colon suffix (e.g., "file:", "ftp:")
-
-
Constructor Details
-
ProtocolHelper
public ProtocolHelper()Default constructor for ProtocolHelper. Initializes the helper with empty protocol arrays that will be populated during init().
-
-
Method Details
-
init
@PostConstruct public void init()Initializes the protocol helper by loading configured protocols from FessConfig and scanning for available protocol handlers in the classpath. This method is called automatically after bean construction. -
loadProtocols
Loads protocol handlers from the specified base package by scanning for Handler classes in subpackages and registering them as web or file protocols based on their PROTOCOL_TYPE field.- Parameters:
basePackage- the base package to scan for protocol handlers
-
getWebProtocols
Returns the array of supported web protocols.- Returns:
- array of web protocol strings with colon suffix (e.g., "http:", "https:")
-
getFileProtocols
Returns the array of supported file protocols.- Returns:
- array of file protocol strings with colon suffix (e.g., "file:", "ftp:")
-
isValidWebProtocol
Checks if the given URL uses a valid web protocol.- Parameters:
url- the URL to validate- Returns:
- true if the URL starts with a supported web protocol, false otherwise
-
isValidFileProtocol
Checks if the given URL uses a valid file protocol.- Parameters:
url- the URL to validate- Returns:
- true if the URL starts with a supported file protocol, false otherwise
-
addWebProtocol
Adds a new web protocol to the supported protocols list. If the protocol already exists, it will not be added again.- Parameters:
protocol- the protocol name to add (without colon suffix)
-
addFileProtocol
Adds a new file protocol to the supported protocols list. If the protocol already exists, it will not be added again.- Parameters:
protocol- the protocol name to add (without colon suffix)
-