1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.search.lucene;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  
28  import java.io.IOException;
29  
30  import org.apache.lucene.analysis.Analyzer;
31  import org.apache.lucene.document.Document;
32  import org.apache.lucene.index.IndexReader;
33  import org.apache.lucene.index.IndexWriter;
34  import org.apache.lucene.index.Term;
35  import org.apache.lucene.store.Directory;
36  
37  /**
38   * <a href="ReadOnlyIndexWriter.java.html"><b><i>View Source</i></b></a>
39   *
40   * @author Jorge Ferrer
41   */
42  public class ReadOnlyIndexWriter extends IndexWriter {
43  
44      public ReadOnlyIndexWriter(
45              Directory luceneDir, Analyzer analyzer, boolean create)
46          throws IOException {
47  
48          super(luceneDir, analyzer, create);
49      }
50  
51      public void addDocument(Document document) {
52          if (_log.isDebugEnabled()) {
53              _log.debug("Ignoring invocation to addDocument");
54          }
55      }
56  
57      public void addDocument(Document document, Analyzer analyzer) {
58          if (_log.isDebugEnabled()) {
59              _log.debug("Ignoring invocation to addDocument");
60          }
61      }
62  
63      public synchronized void addIndexes(Directory[] directories) {
64          if (_log.isDebugEnabled()) {
65              _log.debug("Ignoring invocation to addIndexes");
66          }
67      }
68  
69      public synchronized void addIndexes(IndexReader[] indexReaders) {
70          if (_log.isDebugEnabled()) {
71              _log.debug("Ignoring invocation to addIndexes");
72          }
73      }
74  
75      public synchronized void addIndexesNoOptimize(Directory[] directories) {
76          if (_log.isDebugEnabled()) {
77              _log.debug("Ignoring invocation to addIndexesNoOptimize");
78          }
79      }
80  
81      public synchronized void deleteDocuments(Term term) {
82          if (_log.isDebugEnabled()) {
83              _log.debug("Ignoring invocation to deleteDocuments");
84          }
85      }
86  
87      public synchronized void deleteDocuments(Term[] terms) {
88          if (_log.isDebugEnabled()) {
89              _log.debug("Ignoring invocation to deleteDocuments");
90          }
91      }
92  
93      public void updateDocument(Term term, Document document) {
94          if (_log.isDebugEnabled()) {
95              _log.debug("Ignoring invocation to updateDocument");
96          }
97      }
98  
99      public void updateDocument(
100         Term term, Document document, Analyzer analyzer) {
101 
102         if (_log.isDebugEnabled()) {
103             _log.debug("Ignoring invocation to updateDocument");
104         }
105     }
106 
107     public synchronized void optimize() {
108         if (_log.isDebugEnabled()) {
109             _log.debug("Ignoring invocation to optimize");
110         }
111     }
112 
113     private static Log _log = LogFactoryUtil.getLog(ReadOnlyIndexWriter.class);
114 
115 }