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.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.CorruptIndexException;
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          throws CorruptIndexException, IOException {
53  
54          if (_log.isDebugEnabled()) {
55              _log.debug("Ignoring invocation to addDocument");
56          }
57      }
58  
59      public void addDocument(Document document, Analyzer analyzer)
60          throws CorruptIndexException, IOException {
61  
62          if (_log.isDebugEnabled()) {
63              _log.debug("Ignoring invocation to addDocument");
64          }
65      }
66  
67      public synchronized void addIndexes(Directory[] directories)
68          throws CorruptIndexException, IOException {
69  
70          if (_log.isDebugEnabled()) {
71              _log.debug("Ignoring invocation to addIndexes");
72          }
73      }
74  
75      public synchronized void addIndexes(IndexReader[] indexReaders)
76          throws CorruptIndexException, IOException {
77  
78          if (_log.isDebugEnabled()) {
79              _log.debug("Ignoring invocation to addIndexes");
80          }
81      }
82  
83      public synchronized void addIndexesNoOptimize(Directory[] directories)
84          throws CorruptIndexException, IOException {
85  
86          if (_log.isDebugEnabled()) {
87              _log.debug("Ignoring invocation to addIndexesNoOptimize");
88          }
89      }
90  
91      public synchronized void deleteDocuments(Term term)
92          throws CorruptIndexException, IOException {
93  
94          if (_log.isDebugEnabled()) {
95              _log.debug("Ignoring invocation to deleteDocuments");
96          }
97      }
98  
99      public synchronized void deleteDocuments(Term[] terms)
100         throws CorruptIndexException, IOException {
101 
102         if (_log.isDebugEnabled()) {
103             _log.debug("Ignoring invocation to deleteDocuments");
104         }
105     }
106 
107     public void updateDocument(Term term, Document document)
108         throws CorruptIndexException, IOException {
109 
110         if (_log.isDebugEnabled()) {
111             _log.debug("Ignoring invocation to updateDocument");
112         }
113     }
114 
115     public void updateDocument(Term term, Document document, Analyzer analyzer)
116         throws CorruptIndexException, IOException {
117 
118         if (_log.isDebugEnabled()) {
119             _log.debug("Ignoring invocation to updateDocument");
120         }
121     }
122 
123     public synchronized void optimize()
124         throws CorruptIndexException, IOException {
125 
126         if (_log.isDebugEnabled()) {
127             _log.debug("Ignoring invocation to optimize");
128         }
129     }
130 
131     private static Log _log = LogFactory.getLog(ReadOnlyIndexWriter.class);
132 
133 }