KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > business > search > operations > RemoveEntryOperation


1 /*
2  * Created on Jul 16, 2003
3  * Authored by: Mindaugas Idzelis (min@idzelis.com)
4  *
5  */

6 package org.roller.business.search.operations;
7
8 import java.io.IOException JavaDoc;
9
10 import org.apache.commons.logging.Log;
11 import org.apache.commons.logging.LogFactory;
12 import org.apache.lucene.index.IndexReader;
13 import org.apache.lucene.index.Term;
14 import org.roller.business.IndexManagerImpl;
15 import org.roller.business.search.FieldConstants;
16 import org.roller.pojos.WeblogEntryData;
17
18
19 /**
20  * @author aim4min
21  *
22  * An operation that removes the weblog from the index.
23  */

24 public class RemoveEntryOperation extends WriteToIndexOperation
25 {
26     //~ Static fields/initializers =============================================
27

28     private static Log mLogger =
29         LogFactory.getFactory().getInstance(RemoveEntryOperation.class);
30
31     //~ Instance fields ========================================================
32

33     private WeblogEntryData data;
34
35     //~ Constructors ===========================================================
36

37     /**
38      *
39      */

40     public RemoveEntryOperation(IndexManagerImpl mgr, WeblogEntryData data)
41     {
42         super(mgr);
43         this.data = data;
44     }
45
46     //~ Methods ================================================================
47

48     /* (non-Javadoc)
49      * @see java.lang.Runnable#run()
50      */

51     public void doRun()
52     {
53         IndexReader reader = beginDeleting();
54         try
55         {
56             if (reader != null)
57             {
58                 Term term = new Term(FieldConstants.ID, data.getId());
59                 reader.delete(term);
60             }
61         }
62         catch (IOException JavaDoc e)
63         {
64             mLogger.error("Error deleting doc from index", e);
65         }
66         finally
67         {
68             endDeleting();
69         }
70     }
71
72  
73 }
74
Popular Tags