19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.util.prefs.BackingStoreException;
22 import java.util.prefs.PreferenceChangeListener;
23 import java.util.prefs.Preferences;
24 import org.openide.util.NbPreferences;
30 final class UserPreferences {
33 private static final String INDEXING_MAX_SHARDS =
"IndexingMaxShards";
34 private static final String INDEXING_DOC_QUEUE_SIZE =
"IndexingDocumentQueueSize";
35 private static final String INDEXING_NUM_THREADS =
"IndexingNumThreads";
36 private static final String SOLR_CONNECTION_TIMEOUT_MS =
"SolrConnectionTimeoutMs";
37 private static final int DEFAULT_CONNECTION_TIMEOUT_MS = 0;
38 private static final int DEFAULT_INDEXING_DOC_QUEUE_SIZE = 30;
61 public static void saveToStorage() throws BackingStoreException {
66 preferences.addPreferenceChangeListener(listener);
70 preferences.removePreferenceChangeListener(listener);
73 public static void setMaxNumShards(
int maxShards) {
74 preferences.putInt(INDEXING_MAX_SHARDS, maxShards);
77 public static int getMaxNumShards() {
78 return preferences.getInt(INDEXING_MAX_SHARDS, 0);
81 public static int getNumThreads() {
82 return preferences.getInt(INDEXING_NUM_THREADS, 5);
85 public static void setNumThreads(
int maxShards) {
86 preferences.putInt(INDEXING_NUM_THREADS, maxShards);
89 public static void setConnectionTimeout(
int connectionTimeoutMs) {
90 preferences.putInt(SOLR_CONNECTION_TIMEOUT_MS, connectionTimeoutMs);
93 public static int getConnectionTimeout() {
94 return preferences.getInt(SOLR_CONNECTION_TIMEOUT_MS, DEFAULT_CONNECTION_TIMEOUT_MS);
100 public static int getDocumentsQueueSize() {
101 return preferences.getInt(INDEXING_DOC_QUEUE_SIZE, DEFAULT_INDEXING_DOC_QUEUE_SIZE);
static void reloadFromStorage()
static void removeChangeListener(PreferenceChangeListener listener)
static final Preferences preferences
static void saveToStorage()
static void addChangeListener(PreferenceChangeListener listener)