Package org.codelibs.fess.dict
Class DictionaryManager
java.lang.Object
org.codelibs.fess.dict.DictionaryManager
Manager class for handling dictionary files in the Fess search system.
This class provides functionality to retrieve, store, and manage various
dictionary files such as synonyms, kuromoji, protwords, and stopwords.
It coordinates with DictionaryCreator instances to handle different
dictionary types and manages file synchronization through ConfigSync.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<DictionaryCreator> List of dictionary creators for handling different dictionary types -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCreator(DictionaryCreator creator) Adds a new dictionary creator to this manager.org.codelibs.curl.CurlResponsegetContentResponse(DictionaryFile<? extends DictionaryItem> dictFile) Gets the HTTP response containing the content of a dictionary file.org.dbflute.optional.OptionalEntity<DictionaryFile<? extends DictionaryItem>> Retrieves a specific dictionary file by its ID.DictionaryFile<? extends DictionaryItem>[]Retrieves all available dictionary files from the ConfigSync storage.voidinit()Initializes the dictionary manager after construction.voidstore(DictionaryFile<? extends DictionaryItem> dictFile, File file) Stores or updates a dictionary file in the ConfigSync storage.
-
Field Details
-
creatorList
List of dictionary creators for handling different dictionary types
-
-
Constructor Details
-
DictionaryManager
public DictionaryManager()Default constructor for DictionaryManager. Creates a new dictionary manager with an empty creator list.
-
-
Method Details
-
init
@PostConstruct public void init()Initializes the dictionary manager after construction. Sets up the relationship between this manager and all registered creators. -
getDictionaryFiles
Retrieves all available dictionary files from the ConfigSync storage. This method queries the ConfigSync API to get file information and uses registered DictionaryCreator instances to create appropriate DictionaryFile objects.- Returns:
- an array of dictionary files available in the system
- Throws:
DictionaryException- if there's an error accessing the dictionaries
-
getDictionaryFile
public org.dbflute.optional.OptionalEntity<DictionaryFile<? extends DictionaryItem>> getDictionaryFile(String id) Retrieves a specific dictionary file by its ID.- Parameters:
id- the unique identifier of the dictionary file to retrieve- Returns:
- an OptionalEntity containing the dictionary file if found, empty otherwise
-
store
Stores or updates a dictionary file in the ConfigSync storage. This method checks for concurrent modifications by comparing timestamps and uploads the file content to the ConfigSync API.- Parameters:
dictFile- the dictionary file metadata to storefile- the actual file containing the dictionary content- Throws:
DictionaryException- if the file was updated by another process, if the file doesn't exist, or if there's an error during storage
-
getContentResponse
public org.codelibs.curl.CurlResponse getContentResponse(DictionaryFile<? extends DictionaryItem> dictFile) Gets the HTTP response containing the content of a dictionary file. This method retrieves the raw file content from ConfigSync storage.- Parameters:
dictFile- the dictionary file to retrieve content for- Returns:
- a CurlResponse containing the file content
-
addCreator
Adds a new dictionary creator to this manager. Dictionary creators are responsible for creating specific types of dictionary files based on file paths and timestamps.- Parameters:
creator- the dictionary creator to add
-