1 18 19 package org.apache.roller.business.search.operations; 20 21 import java.io.IOException ; 22 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 import org.apache.lucene.index.IndexReader; 26 import org.apache.lucene.index.Term; 27 import org.apache.roller.business.IndexManagerImpl; 28 import org.apache.roller.business.search.FieldConstants; 29 import org.apache.roller.pojos.WeblogEntryData; 30 31 32 36 public class RemoveEntryOperation extends WriteToIndexOperation { 37 38 40 private static Log mLogger = 41 LogFactory.getFactory().getInstance(RemoveEntryOperation.class); 42 43 45 private WeblogEntryData data; 46 47 49 public RemoveEntryOperation(IndexManagerImpl mgr, WeblogEntryData data) { 50 super(mgr); 51 this.data = data; 52 } 53 54 56 public void doRun() { 57 IndexReader reader = beginDeleting(); 58 try { 59 if (reader != null) { 60 Term term = new Term(FieldConstants.ID, data.getId()); 61 reader.delete(term); 62 } 63 } catch (IOException e) { 64 mLogger.error("Error deleting doc from index", e); 65 } finally { 66 endDeleting(); 67 } 68 } 69 70 71 } 72 | Popular Tags |