1   /**
2    * Copyright (c) 2000-2008 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 java.io.IOException;
26  
27  import org.apache.commons.logging.Log;
28  import org.apache.commons.logging.LogFactory;
29  import org.apache.lucene.analysis.Analyzer;
30  import org.apache.lucene.document.Document;
31  import org.apache.lucene.index.IndexReader;
32  import org.apache.lucene.index.IndexWriter;
33  import org.apache.lucene.index.Term;
34  import org.apache.lucene.store.Directory;
35  
36  /**
37   * <a href="ReadOnlyIndexWriter.java.html"><b><i>View Source</i></b></a>
38   *
39   * @author Jorge Ferrer
40   */
41  public class ReadOnlyIndexWriter extends IndexWriter {
42  
43      public ReadOnlyIndexWriter(
44              Directory luceneDir, Analyzer analyzer, boolean create)
45          throws IOException {
46  
47          super(luceneDir, analyzer, create);
48      }
49  
50      public void addDocument(Document document) {
51          if (_log.isDebugEnabled()) {
52              _log.debug("Ignoring invocation to addDocument");
53          }
54      }
55  
56      public void addDocument(Document document, Analyzer analyzer) {
57          if (_log.isDebugEnabled()) {
58              _log.debug("Ignoring invocation to addDocument");
59          }
60      }
61  
62      public synchronized void addIndexes(Directory[] directories) {
63          if (_log.isDebugEnabled()) {
64              _log.debug("Ignoring invocation to addIndexes");
65          }
66      }
67  
68      public synchronized void addIndexes(IndexReader[] indexReaders) {
69          if (_log.isDebugEnabled()) {
70              _log.debug("Ignoring invocation to addIndexes");
71          }
72      }
73  
74      public synchronized void addIndexesNoOptimize(Directory[] directories) {
75          if (_log.isDebugEnabled()) {
76              _log.debug("Ignoring invocation to addIndexesNoOptimize");
77          }
78      }
79  
80      public synchronized void deleteDocuments(Term term) {
81          if (_log.isDebugEnabled()) {
82              _log.debug("Ignoring invocation to deleteDocuments");
83          }
84      }
85  
86      public synchronized void deleteDocuments(Term[] terms) {
87          if (_log.isDebugEnabled()) {
88              _log.debug("Ignoring invocation to deleteDocuments");
89          }
90      }
91  
92      public void updateDocument(Term term, Document document) {
93          if (_log.isDebugEnabled()) {
94              _log.debug("Ignoring invocation to updateDocument");
95          }
96      }
97  
98      public void updateDocument(
99          Term term, Document document, Analyzer analyzer) {
100 
101         if (_log.isDebugEnabled()) {
102             _log.debug("Ignoring invocation to updateDocument");
103         }
104     }
105 
106     public synchronized void optimize() {
107         if (_log.isDebugEnabled()) {
108             _log.debug("Ignoring invocation to optimize");
109         }
110     }
111 
112     private static Log _log = LogFactory.getLog(ReadOnlyIndexWriter.class);
113 
114 }