01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16:
17: package org.columba.mail.folder.mbox;
18:
19: import org.columba.mail.config.FolderItem;
20: import org.columba.mail.config.IFolderItem;
21: import org.columba.mail.folder.AbstractLocalFolder;
22: import org.columba.mail.folder.IDataStorage;
23: import org.columba.mail.folder.search.LuceneQueryEngine;
24:
25: public class CachedMboxFolder extends AbstractLocalFolder {
26:
27: /**
28: * Constructs the CachedMboxFolder.java.
29: *
30: * @param item
31: * @param path
32: */
33: public CachedMboxFolder(FolderItem item, String path) {
34: super (item, path);
35:
36: // enable lucene search index by default
37: boolean enableLucene = getConfiguration()
38: .getBooleanWithDefault("property", "enable_lucene",
39: true);
40: if (enableLucene) {
41: getSearchEngine().setNonDefaultEngine(
42: new LuceneQueryEngine(this ));
43: }
44: }
45:
46: /**
47: * Constructs the CachedMboxFolder.java.
48: *
49: * @param name
50: * @param type
51: * @param path
52: */
53: public CachedMboxFolder(String name, String type, String path) {
54: super (name, type, path);
55:
56: IFolderItem item = getConfiguration();
57: item.setString("property", "accessrights", "user");
58: item.setString("property", "subfolder", "true");
59:
60: boolean enableLucene = getConfiguration()
61: .getBooleanWithDefault("property", "enable_lucene",
62: false);
63: if (enableLucene) {
64: getSearchEngine().setNonDefaultEngine(
65: new LuceneQueryEngine(this ));
66: }
67: }
68:
69: /**
70: * @see org.columba.mail.folder.AbstractLocalFolder#getDataStorageInstance()
71: */
72: public IDataStorage getDataStorageInstance() {
73: if (dataStorage == null) {
74: dataStorage = new MboxDataStorage(this );
75: }
76:
77: return dataStorage;
78: }
79:
80: /**
81: * @see org.columba.mail.folder.AbstractMessageFolder#save()
82: */
83: public void save() throws Exception {
84: super .save();
85: ((MboxDataStorage) getDataStorageInstance()).save();
86: }
87: }
|