001: /*
002: * snapper
003: *
004: * Enhydra super-servlet business object
005: *
006: */
007:
008: package org.enhydra.snapperAdmin.business;
009:
010: import java.io.BufferedReader;
011: import java.io.File;
012: import java.io.FileInputStream;
013: import java.io.InputStreamReader;
014: import java.sql.Timestamp;
015: import java.util.Date;
016:
017: import org.enhydra.snapperAdmin.SnapperAdmin;
018: import org.enhydra.snapper.api.Reader;
019: import org.enhydra.snapperAdmin.spec.DocumentGroup;
020: import org.enhydra.snapperAdmin.spec.FileType;
021: import org.enhydra.snapperAdmin.spec.Path;
022: import org.enhydra.snapperAdmin.spec.ReaderFactory;
023: import org.enhydra.snapperAdmin.spec.Site;
024:
025: public class SiteImpl implements Site {
026:
027: private String NAME;
028: private String LANGUAGE;
029: private int QUERYNR;
030: private String LASTQUERY;
031: private int MAXSIZE;
032: private int MAXAGE;
033: private int FILENR;
034: private boolean SEARCH;
035: private boolean DOWNLOAD;
036: private boolean INDEXCONTENT;
037: private boolean INDEXDIRECTORY;
038: private boolean INDEXUNKNOWNFILETYPES;
039: private String INDEXDIR;
040: private String FILTERDB;
041: private String FILTERTABLE;
042: private String FILTERCOLUMN;
043: private String INCLUDEDB;
044: private String INCLUDETABLE;
045: private String INCLUDECOLUMN;
046: private String INCLUDECOLUMNMODIFIED;
047: private String METADB;
048: private String METATABLE;
049: private String METAFILE;
050: private String METAKEY;
051: private String METAVALUE;
052: private String LASTUPDATE;
053: private Path[] pathList;
054: private FileType[] fileTypeList;
055: private DocumentGroup dg;
056: private Timestamp STARTTIME;
057:
058: public String getNAME() {
059: return NAME;
060: }
061:
062: public String getLANGUAGE() {
063: return LANGUAGE;
064: }
065:
066: public int getMAXSIZE() {
067: return MAXSIZE;
068: }
069:
070: public int getMAXAGE() {
071: return MAXAGE;
072: }
073:
074: public int getFILENR() {
075: //return FILENR;
076:
077: String dir = null;
078: try {
079: Reader lr = ReaderFactory
080: .createReader("org.enhydra.snapper.wrapper.lucene.LuceneReader");
081: if (INDEXDIR != null) {
082: dir = INDEXDIR;
083: lr.setUpReader(dir);
084: } else {
085: dir = SnapperAdmin.getIndexDir();
086:
087: if (dir.endsWith("\\") || dir.endsWith("/"))
088: dir = dir + NAME;
089: else
090: dir = dir + File.separator + NAME;
091:
092: lr.setUpReader(dir);
093:
094: }
095:
096: int fileNumber = lr.getSize();
097: long lastModofied = lr.lastModified();
098:
099: lr.closeReader();
100:
101: return fileNumber;
102:
103: } catch (Exception e) {
104: // SnapperAdmin.logWarrning(" For Site :" + NAME + " could not acces indexed directory :" + dir + " message : " + e.getMessage());
105: return 0;
106: }
107: }
108:
109: public boolean getSEARCH() {
110: return SEARCH;
111: }
112:
113: public boolean getDOWNLOAD() {
114: return DOWNLOAD;
115: }
116:
117: public boolean getINDEXCONTENT() {
118: return INDEXCONTENT;
119: }
120:
121: public boolean getINDEXDIRECTORY() {
122: return INDEXDIRECTORY;
123: }
124:
125: public boolean getINDEXUNKNOWNFILETYPES() {
126: return INDEXUNKNOWNFILETYPES;
127: }
128:
129: public String getINDEXDIR() {
130: return INDEXDIR;
131: }
132:
133: public String getFILTERDB() {
134: return FILTERDB;
135: }
136:
137: public String getFILTERTABLE() {
138: return FILTERTABLE;
139: }
140:
141: public String getFILTERCOLUMN() {
142: return FILTERCOLUMN;
143: }
144:
145: public String getINCLUDEDB() {
146: return INCLUDEDB;
147: }
148:
149: public String getINCLUDETABLE() {
150: return INCLUDETABLE;
151: }
152:
153: public String getINCLUDECOLUMN() {
154: return INCLUDECOLUMN;
155: }
156:
157: public String getINCLUDECOLUMNMODIFIED() {
158: return INCLUDECOLUMNMODIFIED;
159: }
160:
161: public String getMETADB() {
162: return METADB;
163: }
164:
165: public String getMETATABLE() {
166: return METATABLE;
167: }
168:
169: public String getMETAFILE() {
170: return METAFILE;
171: }
172:
173: public String getMETAKEY() {
174: return METAKEY;
175: }
176:
177: public String getMETAVALUE() {
178: return METAVALUE;
179: }
180:
181: public void setNAME(String str) {
182: NAME = str;
183: }
184:
185: public void setLANGUAGE(String str) {
186: LANGUAGE = str;
187: }
188:
189: public void setMAXSIZE(int str) {
190: MAXSIZE = str;
191: }
192:
193: public void setMAXAGE(int str) {
194: MAXAGE = str;
195: }
196:
197: public void setFILENR(int str) {
198: FILENR = str;
199: }
200:
201: public void setSEARCH(boolean str) {
202: SEARCH = str;
203: }
204:
205: public void setDOWNLOAD(boolean str) {
206: DOWNLOAD = str;
207: }
208:
209: public void setINDEXCONTENT(boolean str) {
210: INDEXCONTENT = str;
211: }
212:
213: public void setINDEXDIRECTORY(boolean str) {
214: INDEXDIRECTORY = str;
215: }
216:
217: public void setINDEXUNKNOWNFILETYPES(boolean str) {
218: INDEXUNKNOWNFILETYPES = str;
219: }
220:
221: public void setINDEXDIR(String str) {
222: INDEXDIR = str;
223: }
224:
225: public void setFILTERDB(String str) {
226: FILTERDB = str;
227: }
228:
229: public void setFILTERTABLE(String str) {
230: FILTERTABLE = str;
231: }
232:
233: public void setFILTERCOLUMN(String str) {
234: FILTERCOLUMN = str;
235: }
236:
237: public void setINCLUDEDB(String str) {
238: INCLUDEDB = str;
239: }
240:
241: public void setINCLUDETABLE(String str) {
242: INCLUDETABLE = str;
243: }
244:
245: public void setINCLUDECOLUMN(String str) {
246: INCLUDECOLUMN = str;
247: }
248:
249: public void setINCLUDECOLUMNMODIFIED(String str) {
250: INCLUDECOLUMNMODIFIED = str;
251: }
252:
253: public void setMETADB(String str) {
254: METADB = str;
255: }
256:
257: public void setMETATABLE(String str) {
258: METATABLE = str;
259: }
260:
261: public void setMETAFILE(String str) {
262: METAFILE = str;
263: }
264:
265: public void setMETAKEY(String str) {
266: METAKEY = str;
267: }
268:
269: public void setMETAVALUE(String str) {
270: METAVALUE = str;
271: }
272:
273: public void deleteDir(String index) {
274: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
275: }
276:
277: public Path[] getPathList() {
278: return pathList;
279: }
280:
281: public void setPathList(Path[] pathList) {
282: this .pathList = pathList;
283: }
284:
285: public DocumentGroup getDocumentGroup() {
286: return dg;
287: }
288:
289: public void setDocumentGroup(DocumentGroup group) {
290: dg = group;
291: }
292:
293: public Timestamp getStartTime() {
294: return STARTTIME;
295: }
296:
297: public void setStartTime(Timestamp time) {
298: STARTTIME = time;
299: }
300:
301: public String getLASTUPDATE() {
302: String dir = null;
303: try {
304: Reader lr = ReaderFactory
305: .createReader("org.enhydra.snapper.wrapper.lucene.LuceneReader");
306:
307: if (INDEXDIR != null) {
308: dir = INDEXDIR;
309: lr.setUpReader(dir);
310: } else {
311: dir = SnapperAdmin.getIndexDir();
312:
313: if (dir.endsWith("\\") || dir.endsWith("/"))
314: dir = dir + NAME;
315: else
316: dir = dir + File.separator + NAME;
317:
318: lr.setUpReader(dir);
319:
320: }
321:
322: long lastModofied = lr.lastModified();
323:
324: lr.closeReader();
325: Date date = new Date(lastModofied);
326:
327: return date.toString();
328:
329: } catch (Exception e) {
330: // SnapperAdmin.logWarrning(" For Site :" + NAME + " could not acces indexed directory :" + dir + " message : " + e.getMessage());
331: return "0";
332: }
333: }
334:
335: public void setLASTUPDATE(String str) {
336: LASTUPDATE = str;
337: }
338:
339: public void setQUERYNR(int str) {
340: QUERYNR = str;
341: }
342:
343: public int getQUERYNR() {
344: //return QUERYNR;
345: String statisticFilePath = SnapperAdmin.getStatisticDirectory();
346: statisticFilePath = statisticFilePath + NAME;
347: File statisticFile = new File(statisticFilePath);
348:
349: if (SnapperAdmin.getStatisticActive()) {
350: if (!statisticFile.exists()) {
351: //SnapperAdmin.logWarrning(" For Site :" + NAME + " statistic file "+statisticFilePath+" does not exist !!! ");
352: return 0;
353: } else {
354: //citamo iz fajla
355: BufferedReader d = null;
356:
357: try {
358:
359: FileInputStream fis = new FileInputStream(
360: statisticFile);
361: d = new BufferedReader(new InputStreamReader(fis));
362:
363: String curentObject = d.readLine();
364: int num = (new Integer(curentObject)).intValue();
365:
366: return num;
367:
368: } catch (Exception e) {
369: SnapperAdmin
370: .logWarrning(" For Site :"
371: + NAME
372: + " problem ocured while reading statistic file "
373: + statisticFilePath);
374: return 0;
375: } finally {
376: if (d != null) {
377: try {
378: d.close();
379: } catch (Exception e) {
380: }
381: d = null;
382: }
383: }
384:
385: }
386: } else {
387: return 0;
388: }
389: }
390:
391: public String getLASTQUERY() {
392: // return LASTQUERY;
393: String statisticFilePath = SnapperAdmin.getStatisticDirectory();
394: statisticFilePath = statisticFilePath + NAME;
395: File statisticFile = new File(statisticFilePath);
396:
397: if (SnapperAdmin.getStatisticActive()) {
398: if (!statisticFile.exists()) {
399: //SnapperAdmin.logWarrning(" For Site :" + NAME + " statistic file "+statisticFilePath+" does not exist !!! ");
400: return "0";
401: } else {
402: //citamo iz fajla
403: BufferedReader d = null;
404:
405: try {
406:
407: FileInputStream fis = new FileInputStream(
408: statisticFile);
409: d = new BufferedReader(new InputStreamReader(fis));
410:
411: String curentObject = d.readLine();
412: curentObject = d.readLine();
413:
414: return curentObject;
415:
416: } catch (Exception e) {
417: SnapperAdmin
418: .logWarrning(" For Site :"
419: + NAME
420: + " problem ocured while reading statistic file "
421: + statisticFilePath);
422: return "0";
423: } finally {
424: if (d != null) {
425: try {
426: d.close();
427: } catch (Exception e) {
428: }
429: d = null;
430: }
431: }
432:
433: }
434: } else {
435: return "0";
436: }
437:
438: }
439:
440: public void setLASTQUERY(String str) {
441: LASTQUERY = str;
442: }
443: }
|