001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/service/impl/SearchServiceImplDisk.java,v 1.13 2007/11/09 10:38:27 minhnn Exp $
003: * $Author: minhnn $
004: * $Revision: 1.13 $
005: * $Date: 2007/11/09 10:38:27 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Phong Ta Quoc
039: */
040: package com.mvnforum.service.impl;
041:
042: import java.io.IOException;
043:
044: import net.myvietnam.mvncore.util.AssertionUtil;
045:
046: import org.apache.commons.logging.Log;
047: import org.apache.commons.logging.LogFactory;
048: import org.apache.lucene.store.Directory;
049: import org.apache.lucene.store.FSDirectory;
050:
051: import com.mvnforum.MVNForumConfig;
052: import com.mvnforum.MVNForumGlobal;
053: import com.mvnforum.service.SearchService;
054:
055: public class SearchServiceImplDisk implements SearchService {
056:
057: private static Log log = LogFactory
058: .getLog(SearchServiceImplDisk.class);
059:
060: private boolean failed = false;
061: private static int count;
062:
063: public SearchServiceImplDisk() {
064: count++;
065: AssertionUtil.doAssert(count == 1,
066: "Assertion: Must have only one instance.");
067: load();
068: }
069:
070: public void load() {
071: log.info("Using Search Service " + this .getClass().getName());
072: }
073:
074: public boolean isFailed() {
075: return this .failed;
076: }
077:
078: public Directory getSearchPostIndexDir(boolean create)
079: throws IOException {
080: return FSDirectory.getDirectory(MVNForumConfig
081: .getSearchPostIndexDirName(), create);
082: }
083:
084: public Directory getSearchPostIndexDir() throws IOException {
085: return getSearchPostIndexDir(false);
086: }
087:
088: public Directory getSearchMemberIndexDir(boolean create)
089: throws IOException {
090: return FSDirectory.getDirectory(MVNForumConfig
091: .getSearchMemberIndexDirName(), create);
092: }
093:
094: public Directory getSearchMemberIndexDir() throws IOException {
095: return getSearchMemberIndexDir(false);
096: }
097:
098: public Directory getSearchAttachmentIndexDir(boolean create)
099: throws IOException {
100: return FSDirectory.getDirectory(MVNForumConfig
101: .getSearchAttachmentIndexDirName(), create);
102: }
103:
104: public Directory getSearchAttachmentIndexDir() throws IOException {
105: return getSearchAttachmentIndexDir(false);
106: }
107:
108: public Directory getSearchAlbumItemIndexDir() throws IOException {
109: return getSearchAlbumItemIndexDir(false);
110: }
111:
112: public Directory getSearchAlbumItemIndexDir(boolean create)
113: throws IOException {
114: return FSDirectory.getDirectory(MVNForumConfig
115: .getSearchAlbumItemIndexDirName(), create);
116: }
117:
118: public void deleteContent(Directory directory) throws IOException {
119: //dont need to implement ???
120: }
121:
122: public boolean savePostOnDisk() {
123: return true;
124: }
125:
126: public boolean saveAlbumItemOnDisk() {
127: return true;
128: }
129:
130: public boolean saveMemberOnDisk() {
131: return true;
132: }
133:
134: public boolean saveAttachmentOnDisk() {
135: return true;
136: }
137:
138: public int getPostSearchImplType() {
139: return MVNForumGlobal.SEARCH_INDEX_TYPE_DISK;
140: }
141:
142: public int getMemberSearchImplType() {
143: return MVNForumGlobal.SEARCH_INDEX_TYPE_DISK;
144: }
145:
146: public int getAttachmentSearchImplType() {
147: return MVNForumGlobal.SEARCH_INDEX_TYPE_DISK;
148: }
149:
150: public int getAlbumItemSearchImplType() {
151: return MVNForumGlobal.SEARCH_INDEX_TYPE_DISK;
152: }
153:
154: public void clearData() {
155: }
156: }
|