1 6 package org.roller.business.search.operations; 7 8 import java.io.IOException ; 9 10 import org.apache.commons.logging.Log; 11 import org.apache.commons.logging.LogFactory; 12 import org.apache.lucene.index.IndexWriter; 13 import org.roller.business.IndexManagerImpl; 14 import org.roller.model.Roller; 15 import org.roller.model.RollerFactory; 16 import org.roller.pojos.WeblogEntryData; 17 18 19 24 public class AddEntryOperation extends WriteToIndexOperation 25 { 26 28 private static Log mLogger = 29 LogFactory.getFactory().getInstance(AddEntryOperation.class); 30 31 33 private WeblogEntryData data; 34 35 37 40 public AddEntryOperation(IndexManagerImpl mgr, WeblogEntryData data) 41 { 42 super(mgr); 43 this.data = data; 44 } 45 46 48 51 public void doRun() 52 { 53 IndexWriter writer = beginWriting(); 54 Roller roller = RollerFactory.getRoller(); 55 try 56 { 57 if (writer != null) 58 { 59 writer.addDocument(getDocument(data)); 60 } 61 } 62 catch (IOException e) 63 { 64 mLogger.error("Problems adding doc to index", e); 65 } 66 finally 67 { 68 if (roller != null) roller.release(); 69 endWriting(); 70 } 71 } 72 73 } 74 | Popular Tags |