1 43 package net.jforum.util.search.simple; 44 45 import net.jforum.JForumExecutionContext; 46 import net.jforum.dao.DataAccessDriver; 47 import net.jforum.dao.SearchIndexerDAO; 48 import net.jforum.entities.Post; 49 import net.jforum.exceptions.SearchException; 50 import net.jforum.util.concurrent.executor.QueuedExecutor; 51 import net.jforum.util.preferences.ConfigKeys; 52 import net.jforum.util.preferences.SystemGlobals; 53 import net.jforum.util.search.SearchManager; 54 55 import org.apache.log4j.Logger; 56 57 61 public class SimpleSearchManager implements SearchManager 62 { 63 private static Logger logger = Logger.getLogger(SimpleSearchManager.class); 64 65 68 public void init() {} 69 70 73 public void index(Post post) 74 { 75 if (SystemGlobals.getBoolValue(ConfigKeys.BACKGROUND_TASKS)) { 76 try { 77 QueuedExecutor.getInstance().execute(new MessageIndexerTask(post)); 78 } 79 catch (Exception e) { 80 logger.error("Error while running the search task", e); 81 } 82 } 83 else { 84 try { 85 SearchIndexerDAO indexer = DataAccessDriver.getInstance().newSearchIndexerDAO(); 86 indexer.setConnection(JForumExecutionContext.getConnection()); 87 indexer.insertSearchWords(post); 88 } 89 catch (Exception e) { 90 throw new SearchException("Error while indexing a message", e); 91 } 92 } 93 } 94 } 95 | Popular Tags |