0001: /*
0002: * Created on Feb 2, 2006
0003: * Milin Radivoj
0004: * rmilin@gmail.com
0005: */
0006: package org.enhydra.snapperPreviewer.business;
0007:
0008: import java.io.File;
0009: import java.util.Enumeration;
0010: import java.util.StringTokenizer;
0011: import java.util.Vector;
0012: import org.enhydra.snapper.xml.tdv.*;
0013: import org.enhydra.snapper.xml.tdv.AbsolutFilePathDocument.AbsolutFilePath;
0014: import org.enhydra.snapper.xml.tdv.ContainerFileDocument.ContainerFile;
0015: import org.enhydra.snapper.xml.tdv.ContainerFileListDocument.ContainerFileList;
0016: import org.enhydra.snapper.xml.tdv.InsideContainerFilePathDocument.InsideContainerFilePath; //import org.enhydra.snapper.xml.tdv.ParameterDocument.Parameter;
0017: import org.enhydra.snapper.xml.tdv.PreviewDocument.Preview; //import org.enhydra.snapper.xml.tdv.SearchedParametersDocument.SearchedParameters;
0018: //import org.enhydra.snapper.xml.tdv.SummaryDocument.Summary;
0019: import org.enhydra.snapper.SnapperManager;
0020: import org.enhydra.snapper.api.Searcher;
0021: import org.enhydra.snapper.api.searching.ResultElement;
0022: import org.enhydra.snapper.api.searching.SearchResult;
0023: import org.enhydra.snapper.parsers.fileparsers.FileParserException;
0024: import org.enhydra.snapper.parsers.fileparsers.FileParserMaster;
0025: import org.enhydra.snapper.parsers.fileparsers.utils.ParserDataConstants;
0026: import org.enhydra.snapperPreviewer.Previewer;
0027: import org.enhydra.snapperPreviewer.spec.FileContainerManager;
0028: import org.enhydra.snapperPreviewer.spec.FileContainerManagerFactory;
0029: import org.enhydra.snapperPreviewer.spec.PDFPictureExtractor;
0030: import org.enhydra.snapperPreviewer.spec.PDFPictureExtractorFactory;
0031: import org.enhydra.snapperPreviewer.spec.PictureManager;
0032: import org.enhydra.snapperPreviewer.spec.PictureManagerFactory;
0033:
0034: /**
0035: * @author Milin Radivoj
0036: *
0037: */
0038:
0039: public class BuilderUtil {
0040:
0041: public static AbsolutFilePath createAbsolutFilePath(String filePath) {
0042: AbsolutFilePathDocument afpd = AbsolutFilePathDocument.Factory
0043: .newInstance();
0044: AbsolutFilePath fp = afpd.addNewAbsolutFilePath();
0045:
0046: String rootFP = "";
0047:
0048: InsideContainerFilePath inCFP = null;
0049:
0050: StringTokenizer st = new StringTokenizer(filePath, "|");
0051: if (st.countTokens() > 1) {
0052: rootFP = st.nextToken();
0053: fp.setFilePath(rootFP);
0054:
0055: while (st.hasMoreTokens()) {
0056:
0057: if (inCFP == null) {
0058: inCFP = fp.addNewInsideContainerFilePath();
0059: inCFP.setFilePath(st.nextToken());
0060: } else {
0061: InsideContainerFilePath inCFPTemp = inCFP
0062: .addNewInsideContainerFilePath();
0063: inCFPTemp.setFilePath(st.nextToken());
0064: inCFP.setInsideContainerFilePath(inCFPTemp);
0065: inCFP = inCFPTemp;
0066: }
0067:
0068: }
0069: } else {
0070: fp.setFilePath(filePath);
0071: }
0072: return fp;
0073: }
0074:
0075: public static InsideContainerFilePath createInsideContainerFilePath(
0076: String filePath) {
0077: InsideContainerFilePathDocument inCFPd = InsideContainerFilePathDocument.Factory
0078: .newInstance();
0079: InsideContainerFilePath finall = inCFPd
0080: .addNewInsideContainerFilePath();
0081: InsideContainerFilePath inCFP = null;
0082:
0083: //String rootFP = "";
0084:
0085: StringTokenizer st = new StringTokenizer(filePath, "|");
0086: if (st.countTokens() > 1) {
0087: finall.setFilePath(st.nextToken());
0088: while (st.hasMoreTokens()) {
0089:
0090: if (inCFP == null) {
0091: inCFP = finall.addNewInsideContainerFilePath();
0092: inCFP.setFilePath(st.nextToken());
0093:
0094: } else {
0095: InsideContainerFilePath inCFPTemp = inCFP
0096: .addNewInsideContainerFilePath();//inCFPd1.getInsideContainerFilePath();
0097: inCFPTemp.setFilePath(st.nextToken());
0098: inCFP.setInsideContainerFilePath(inCFPTemp);
0099: inCFP = inCFPTemp;
0100: }
0101:
0102: }
0103: } else {
0104: finall.setFilePath(filePath);
0105: }
0106:
0107: return finall;
0108: }
0109:
0110: public static Preview createPreview(Preview previewImp,
0111: String titleS, String fileTypeS, String absolutFileNameS,
0112: String fullFilePath, String siteNameS, String fromS,
0113: String toS, String ccS, String subjectS, String sentS,
0114: String contentS, String propertiesS, String metaData,
0115: java.util.Properties containerList) {
0116: previewImp.setTitle(titleS);
0117:
0118: previewImp.setFileType(fileTypeS);
0119:
0120: previewImp.setAbsolutFileName(absolutFileNameS);
0121:
0122: previewImp.setAbsolutFilePath(BuilderUtil
0123: .createAbsolutFilePath(fullFilePath));
0124:
0125: if (siteNameS != null) {
0126: previewImp.setSiteName(siteNameS);
0127: }
0128:
0129: if (fromS != null) {
0130: previewImp.setFrom(fromS);
0131: }
0132:
0133: if (toS != null) {
0134: previewImp.setTo(toS);
0135: }
0136:
0137: if (fromS != null) {
0138: previewImp.setCC(fromS);
0139: }
0140:
0141: if (subjectS != null) {
0142: previewImp.setSubject(subjectS);
0143: }
0144:
0145: if (sentS != null) {
0146: previewImp.setSent(sentS);
0147: }
0148:
0149: if ((fileTypeS.equalsIgnoreCase("xls")
0150: || fileTypeS.equalsIgnoreCase("ppt") || fileTypeS
0151: .equalsIgnoreCase("pps"))
0152: && Previewer.getConverterClassNames() != null
0153: && Previewer
0154: .getConverterClassNames()
0155: .equals(
0156: "org.enhydra.snapper.parsers.fileparsers.parsers.excelparser.ExcelToText"))
0157: contentS = filter(contentS, true);
0158: else
0159: contentS = filter(contentS, false);
0160:
0161: //contentS = filterIfNotHighlihted(contentS);
0162: contentS = filterNewLine(contentS);
0163: contentS = filterContentStartNewLine(contentS);
0164:
0165: previewImp.setContent(contentS);
0166:
0167: if (containerList != null && !containerList.isEmpty()) {
0168: ContainerFileList cfl = previewImp
0169: .addNewContainerFileList();
0170:
0171: for (Enumeration e = containerList.keys(); e
0172: .hasMoreElements();) {
0173:
0174: String insideFilePath = (String) e.nextElement();
0175: String lucineID = containerList
0176: .getProperty(insideFilePath);
0177:
0178: ContainerFile cf = cfl.addNewContainerFile();
0179:
0180: cf.setInsideContainerFilePath(BuilderUtil
0181: .createInsideContainerFilePath(insideFilePath));
0182: if (lucineID != null && lucineID != "") {
0183: cf.setLuceneID(lucineID);
0184: }
0185: }
0186:
0187: }
0188:
0189: if (propertiesS != null) {
0190: previewImp.setProperties(propertiesS);
0191: }
0192:
0193: if (metaData != null) {
0194: previewImp.setMetaData(filterNewLine(metaData));
0195: }
0196:
0197: return previewImp;
0198: }
0199:
0200: public static ContainerFileList createPDFContainerFileList(
0201: ContainerFileList atachedFileListO, File file,
0202: String fullFilePath, int numberOfImages,
0203: boolean toShowcontainerFilesData) {
0204: toShowcontainerFilesData = false;
0205: File pdfFile = file;
0206:
0207: if (numberOfImages >= 0 && pdfFile != null && pdfFile.exists()) {
0208:
0209: PDFPictureExtractor pdfExtractor;
0210: try {
0211: pdfExtractor = PDFPictureExtractorFactory
0212: .getPDFPictureExtractor("org.enhydra.snapperPreviewer.business.PDFPictureExtractorImpl");
0213: } catch (Exception e) {
0214: return null;
0215: }
0216:
0217: if (pdfExtractor == null)
0218: return null;
0219:
0220: Vector listOfPicture = pdfExtractor.getPictureList(pdfFile);
0221:
0222: //konfiguracioni parametar
0223:
0224: int parsedNumber = 0;
0225:
0226: if (listOfPicture != null)
0227: parsedNumber = listOfPicture.size();
0228:
0229: if (numberOfImages > 0 && parsedNumber > numberOfImages)
0230: parsedNumber = numberOfImages;
0231:
0232: if (parsedNumber > 0) {
0233: for (int k = 0; k < parsedNumber; k++) {
0234:
0235: if (!toShowcontainerFilesData) {
0236:
0237: String pictureId = (String) listOfPicture
0238: .elementAt(k);
0239:
0240: ContainerFile atachFileO = atachedFileListO
0241: .addNewContainerFile();
0242: atachFileO
0243: .setInsideContainerFilePath(BuilderUtil
0244: .createInsideContainerFilePath(pictureId));
0245:
0246: } else {
0247: String pictureId = (String) listOfPicture
0248: .elementAt(k);
0249:
0250: int ind = pictureId.indexOf('.');
0251:
0252: if (ind == -1)
0253: continue;
0254:
0255: String type = pictureId.substring(ind + 1,
0256: pictureId.length());
0257:
0258: ContainerFile atachFileO = atachedFileListO
0259: .addNewContainerFile();
0260:
0261: Preview currentAttacmentPrev = BuilderUtil
0262: .createPreview(atachFileO
0263: .addNewPreview(),
0264: filterAmp(pictureId),
0265: filterAmp(type),
0266: filterAmp(pictureId),
0267: filterAmp(fullFilePath) + "|"
0268: + filterAmp(pictureId),
0269: null, null, null, null, null,
0270: null, "", "", null, null);
0271:
0272: if (type.equalsIgnoreCase("g3f")
0273: || type.equalsIgnoreCase("tif")
0274: || type.equalsIgnoreCase("tiff")) {
0275: ContainerFileList cont = currentAttacmentPrev
0276: .addNewContainerFileList();
0277: ContainerFile atachFileO1 = cont
0278: .addNewContainerFile();
0279: InsideContainerFilePath ifp = atachFileO1
0280: .addNewInsideContainerFilePath();
0281:
0282: ifp.setFilePath("0");
0283: }
0284: }
0285:
0286: }
0287: }
0288: }
0289: return atachedFileListO;
0290:
0291: }
0292:
0293: public static ContainerFileList createPictureContainerFileList(
0294: ContainerFileList atachedFileListO, String filePath,
0295: int numberOfImages) {
0296: //ContainerFileList atachedFileListO = null;
0297:
0298: if (numberOfImages >= 0) {
0299: PictureManager pictureManager;
0300: try {
0301: pictureManager = PictureManagerFactory
0302: .getResize("org.enhydra.snapperPreviewer.business.PictureManagerImpl");
0303: } catch (Exception e) {
0304: return null;
0305: }
0306:
0307: if (pictureManager == null)
0308: return null;
0309:
0310: Vector listOfPicture = pictureManager
0311: .getPictureListInsidePicture(filePath);
0312:
0313: //konfiguracioni parametar
0314:
0315: int parsedNumber = 0;
0316:
0317: if (listOfPicture != null)
0318: parsedNumber = listOfPicture.size();
0319:
0320: if (numberOfImages > 0 && parsedNumber > numberOfImages)
0321: parsedNumber = numberOfImages;
0322:
0323: if (parsedNumber > 0) {
0324:
0325: for (int k = 0; k < parsedNumber; k++) {
0326: String pictureId = (String) listOfPicture
0327: .elementAt(k);
0328: ContainerFile atachFileO = atachedFileListO
0329: .addNewContainerFile();
0330: atachFileO.setInsideContainerFilePath(BuilderUtil
0331: .createInsideContainerFilePath(pictureId));
0332: }
0333: }
0334: }
0335: return atachedFileListO;
0336: }
0337:
0338: public static ContainerFileList createContainerFileList(
0339: ContainerFileList finallList, FileParserMaster parser,
0340: String fullFilePath, String rest, boolean toAddData,
0341: int showNumberOf) {
0342: String currentAttacmentName = null;
0343: Preview currentAttacmentPrev = null;
0344: ContainerFileList currentAttacmentPrevList = null;
0345: ContainerFile currentAttacmentContainerFile = null;
0346:
0347: int curentNumberOfAddedFiles = 0;
0348: int curentNumberOfPreviewFiles = 0;
0349: int previewNumLimit = Previewer.getContainerFilesPreviewLimit();
0350:
0351: while (parser.hasNext()) {
0352:
0353: Vector atachmentData = null;
0354:
0355: if ((showNumberOf == 0 || curentNumberOfAddedFiles < showNumberOf)) {
0356: try {
0357: if (rest.equals(""))
0358: atachmentData = parser.getNext();
0359: else {
0360: /*while(parser.getNext()!=null)
0361: if (((String)parser.getNext().elementAt(0)).endsWith(rest))
0362: {
0363: atachmentData = parser.getNext();
0364: break;
0365: }*/
0366: atachmentData = parser.getNext();
0367: toAddData = false;
0368: }
0369: } catch (FileParserException e) {
0370: Previewer.logDebug("File : " + e.getFileName()
0371: + " could not be parsed , cause "
0372: + e.getMessage());
0373: continue;
0374: }
0375: ///////novo
0376: /* String restrictFirstLevel = (String) atachmentData.get(ParserDataConstants.FILE_PATH_POSITION);
0377:
0378:
0379: if((new File(restrictFirstLevel)).getAbsolutePath().startsWith((new File(fullFilePath).getAbsolutePath())) && !fullFilePath.equals(""))
0380: restrictFirstLevel = restrictFirstLevel.substring(fullFilePath.length()+1);
0381:
0382: if((new File(restrictFirstLevel)).getAbsolutePath().startsWith(rest) && !rest.equals(""))
0383: restrictFirstLevel = restrictFirstLevel.substring(rest.length());
0384:
0385:
0386: if(restrictFirstLevel.indexOf("|")!=-1)
0387: continue;*/
0388: //////////
0389: if (!toAddData && currentAttacmentName == null
0390: && currentAttacmentPrev == null) {
0391: //String titleAtacmentS = (String) atachmentData.get(ParserDataConstants.TITLE_POSITION);
0392: //String fileAtacmentTypeS = (String) atachmentData.get(ParserDataConstants.FILE_TYPE_POSITION);
0393: String filePathAtacmentTypeS = (String) atachmentData
0394: .get(ParserDataConstants.FILE_PATH_POSITION);
0395: String atachedFileName = "";
0396:
0397: StringTokenizer stt = new StringTokenizer(
0398: filePathAtacmentTypeS, "|");
0399:
0400: if (stt.countTokens() > 1) {
0401: stt.nextToken();
0402: atachedFileName = stt.nextToken();
0403: while (stt.hasMoreTokens()) {
0404: atachedFileName += "|" + stt.nextToken();
0405: }
0406: }
0407:
0408: int indexOf = atachedFileName.lastIndexOf("/");
0409:
0410: String insideRest = "";
0411:
0412: if (indexOf != -1) {
0413: insideRest = atachedFileName.substring(0,
0414: indexOf + 1);
0415: }
0416:
0417: if (atachedFileName.startsWith(rest)
0418: && !rest.equals(""))
0419: atachedFileName = atachedFileName
0420: .substring(rest.length());
0421:
0422: //if(!rest.equals("") && !insideRest.equals("") && (insideRest.length() < rest.length()) && !insideRest.startsWith(rest))
0423: if ((insideRest.length() < rest.length())
0424: || !insideRest.startsWith(rest))
0425: atachedFileName = "";
0426:
0427: if (!atachedFileName.equals("")) {
0428: ContainerFile atachFileOO = finallList
0429: .addNewContainerFile();
0430: atachFileOO
0431: .setInsideContainerFilePath(BuilderUtil
0432: .createInsideContainerFilePath(filterAmp(atachedFileName)));
0433: }
0434: curentNumberOfPreviewFiles++;
0435: } else if (currentAttacmentName != null
0436: && currentAttacmentPrev != null) {//imamo previw sledeci je ili u njemu container file ili novi attaccment
0437:
0438: String titleAtacmentS = (String) atachmentData
0439: .get(ParserDataConstants.TITLE_POSITION);
0440: String fileAtacmentTypeS = (String) atachmentData
0441: .get(ParserDataConstants.FILE_TYPE_POSITION);
0442: String filePathAtacmentTypeS = (String) atachmentData
0443: .get(ParserDataConstants.FILE_PATH_POSITION);
0444: String contentAtached = (String) atachmentData
0445: .get(ParserDataConstants.CONTENT_POSITION);
0446: //Long lastModifiedL = (Long) atachmentData.get(ParserDataConstants.LAST_MODIFIED_DATE_POSITION);
0447: String propertS = (String) atachmentData
0448: .get(ParserDataConstants.PROPERTIES_POSITION);
0449:
0450: //String lastModifiedS = lastModifiedL.toString();
0451:
0452: String attach = "";
0453: String atachedFileName = "";
0454: StringTokenizer stt = new StringTokenizer(
0455: filePathAtacmentTypeS, "|");
0456:
0457: if (stt.countTokens() > 1) {
0458: stt.nextToken();
0459: atachedFileName = stt.nextToken();
0460: attach = atachedFileName;
0461: while (stt.hasMoreTokens()) {
0462: atachedFileName += "|" + stt.nextToken();
0463: }
0464: }
0465:
0466: if (attach.equals(currentAttacmentName)) {
0467: //imamo contejner fajl kao attacment
0468: if (!atachedFileName.equals("")) {
0469: if (currentAttacmentPrevList == null) {
0470: currentAttacmentPrevList = currentAttacmentPrev
0471: .addNewContainerFileList();
0472: }
0473:
0474: if (atachedFileName
0475: .startsWith(currentAttacmentName)
0476: && atachedFileName.length() > (currentAttacmentName
0477: .length() + 1))
0478: atachedFileName = atachedFileName
0479: .substring(currentAttacmentName
0480: .length() + 1,
0481: atachedFileName
0482: .length());
0483:
0484: ContainerFile atachFileOO = currentAttacmentPrevList
0485: .addNewContainerFile();
0486: atachFileOO
0487: .setInsideContainerFilePath(BuilderUtil
0488: .createInsideContainerFilePath(filterAmp(atachedFileName)));
0489: curentNumberOfAddedFiles++;
0490: }
0491: } else {//imamo sledeci attacment, tekuci prewie setujemo pravimo sledeci
0492: /*if (currentAttacmentPrev != null)
0493: currentAttacmentPrev
0494: .setContainerFileList(currentAttacmentPrevList);
0495: currentAttacmentContainerFile
0496: .setPreview(currentAttacmentPrev);
0497: currentAttacmentContainerFile = null;
0498: //currentAttacmentPrev = null;
0499: currentAttacmentName = null;
0500: currentAttacmentPrevList = null;
0501:
0502: if (!atachedFileName.equals("")) {
0503: if (currentAttacmentPrevList == null) {
0504: currentAttacmentPrevList = currentAttacmentPrev
0505: .addNewContainerFileList();
0506: }
0507:
0508: if (currentAttacmentContainerFile == null) {
0509: currentAttacmentContainerFile = currentAttacmentPrevList
0510: .addNewContainerFile();
0511: }
0512:
0513: currentAttacmentName = attach;
0514: currentAttacmentContainerFile
0515: .setInsideContainerFilePath(BuilderUtil
0516: .createInsideContainerFilePath(filterAmp(atachedFileName)));*/
0517:
0518: if (!atachedFileName.equals("")) {
0519: if (currentAttacmentPrevList == null)
0520: currentAttacmentPrevList = currentAttacmentPrev
0521: .addNewContainerFileList();
0522:
0523: if (currentAttacmentContainerFile == null)
0524: currentAttacmentContainerFile = finallList
0525: .addNewContainerFile();
0526: currentAttacmentContainerFile
0527: .setInsideContainerFilePath(BuilderUtil
0528: .createInsideContainerFilePath(filterAmp(atachedFileName)));
0529:
0530: if (fileAtacmentTypeS
0531: .equalsIgnoreCase("msg")
0532: || fileAtacmentTypeS
0533: .equalsIgnoreCase("pst")
0534: || fileAtacmentTypeS
0535: .equalsIgnoreCase("eml")) {
0536: currentAttacmentPrev = currentAttacmentContainerFile
0537: .addNewPreview();
0538: currentAttacmentPrev = BuilderUtil
0539: .createPreview(
0540: currentAttacmentPrev,
0541: filterAmp(titleAtacmentS),
0542: filterAmp(fileAtacmentTypeS),
0543: filterAmp(atachedFileName),
0544: filterAmp(fullFilePath)
0545: + "|"
0546: + filterAmp(atachedFileName),
0547: null,
0548: null,
0549: null,
0550: null,
0551: null,
0552: null,
0553: filterAmp(contentAtached),
0554: filterAmp(propertS),
0555: null, null);
0556:
0557: currentAttacmentPrev = prepareEmailFiles(currentAttacmentPrev);
0558: } else if (fileAtacmentTypeS
0559: .equalsIgnoreCase("pdf")) {
0560: currentAttacmentPrev = currentAttacmentContainerFile
0561: .addNewPreview();
0562: currentAttacmentPrev = BuilderUtil
0563: .createPreview(
0564: currentAttacmentPrev,
0565: filterAmp(titleAtacmentS),
0566: filterAmp(fileAtacmentTypeS),
0567: filterAmp(atachedFileName),
0568: filterAmp(fullFilePath)
0569: + "|"
0570: + filterAmp(atachedFileName),
0571: null,
0572: null,
0573: null,
0574: null,
0575: null,
0576: null,
0577: filterAmp(contentAtached),
0578: filterAmp(propertS),
0579: null, null);
0580:
0581: File file = null;
0582: try {
0583:
0584: //boolean isContainer = false;
0585: FileContainerManager manager = null;
0586: //String typeOfFile = "";
0587:
0588: if (filePathAtacmentTypeS
0589: .indexOf("|") != -1) {
0590: try {
0591: manager = FileContainerManagerFactory
0592: .getFileContainerManager("org.enhydra.snapperPreviewer.business.FileContainerManagerImpl");
0593: manager.init();
0594: file = manager
0595: .getContainerFile(
0596: filePathAtacmentTypeS,
0597: null);
0598: } catch (Exception e) {
0599: file = null;
0600: }
0601: //isContainer = true;
0602:
0603: String filePath = "";
0604: if (file != null)
0605: filePath = file
0606: .getAbsolutePath();
0607:
0608: int indexOfExtension = filePath
0609: .lastIndexOf(".");
0610: if (indexOfExtension != -1) {
0611: //typeOfFile = filePath.substring(indexOfExtension+1,filePath.length());
0612: }
0613:
0614: } else {
0615:
0616: int indexOfExtension = filePathAtacmentTypeS
0617: .lastIndexOf(".");
0618: if (indexOfExtension != -1) {
0619: //typeOfFile = filePathAtacmentTypeS.substring(indexOfExtension+1,filePathAtacmentTypeS.length());
0620: }
0621:
0622: if (!filePathAtacmentTypeS
0623: .startsWith("ftp")) {
0624: file = new File(
0625: filePathAtacmentTypeS);
0626: } else {
0627:
0628: }
0629: }
0630:
0631: } catch (Exception e) {
0632:
0633: }
0634:
0635: if (file != null)
0636: currentAttacmentPrevList = createPDFContainerFileList(
0637: currentAttacmentPrevList,
0638: file,
0639: filePathAtacmentTypeS,
0640: showNumberOf, false);
0641: } else {
0642: currentAttacmentPrev = currentAttacmentContainerFile
0643: .addNewPreview();
0644: currentAttacmentPrev = BuilderUtil
0645: .createPreview(
0646: currentAttacmentPrev,
0647: filterAmp(titleAtacmentS),
0648: filterAmp(fileAtacmentTypeS),
0649: filterAmp(atachedFileName),
0650: filterAmp(fullFilePath)
0651: + "|"
0652: + filterAmp(atachedFileName),
0653: null,
0654: null,
0655: null,
0656: null,
0657: null,
0658: null,
0659: filterAmp(contentAtached),
0660: filterNewLine(filterAmp(propertS)),
0661: null, null);
0662:
0663: }
0664: }
0665:
0666: }
0667: curentNumberOfPreviewFiles++;
0668: } else {
0669: //preview napravi
0670: String titleAtacmentS = (String) atachmentData
0671: .get(ParserDataConstants.TITLE_POSITION);
0672: String fileAtacmentTypeS = (String) atachmentData
0673: .get(ParserDataConstants.FILE_TYPE_POSITION);
0674: String filePathAtacmentTypeS = (String) atachmentData
0675: .get(ParserDataConstants.FILE_PATH_POSITION);
0676: String contentAtached = (String) atachmentData
0677: .get(ParserDataConstants.CONTENT_POSITION);
0678: //Long lastModifiedL = (Long) atachmentData.get(ParserDataConstants.LAST_MODIFIED_DATE_POSITION);
0679: String propertS = (String) atachmentData
0680: .get(ParserDataConstants.PROPERTIES_POSITION);
0681:
0682: //String lastModifiedS = lastModifiedL.toString();
0683:
0684: String atachedFileName = "";
0685: StringTokenizer stt = new StringTokenizer(
0686: filePathAtacmentTypeS, "|");
0687:
0688: if (stt.countTokens() > 1) {
0689: stt.nextToken();
0690: atachedFileName = stt.nextToken();
0691: currentAttacmentName = atachedFileName;
0692: while (stt.hasMoreTokens()) {
0693: atachedFileName += "|" + stt.nextToken();
0694: }
0695: }
0696:
0697: if (!atachedFileName.equals("")) {
0698: if (currentAttacmentContainerFile == null)
0699: currentAttacmentContainerFile = finallList
0700: .addNewContainerFile();
0701: currentAttacmentContainerFile
0702: .setInsideContainerFilePath(BuilderUtil
0703: .createInsideContainerFilePath(filterAmp(atachedFileName)));
0704:
0705: if (fileAtacmentTypeS.equalsIgnoreCase("msg")
0706: || fileAtacmentTypeS
0707: .equalsIgnoreCase("pst")
0708: || fileAtacmentTypeS
0709: .equalsIgnoreCase("eml")) {
0710: currentAttacmentPrev = currentAttacmentContainerFile
0711: .addNewPreview();
0712: currentAttacmentPrev = BuilderUtil
0713: .createPreview(
0714: currentAttacmentPrev,
0715: filterAmp(titleAtacmentS),
0716: filterAmp(fileAtacmentTypeS),
0717: filterAmp(atachedFileName),
0718: filterAmp(fullFilePath)
0719: + "|"
0720: + filterAmp(atachedFileName),
0721: null, null, null, null,
0722: null, null,
0723: filterAmp(contentAtached),
0724: filterAmp(propertS), null,
0725: null);
0726:
0727: currentAttacmentPrev = prepareEmailFiles(currentAttacmentPrev);
0728: } else if (fileAtacmentTypeS
0729: .equalsIgnoreCase("pdf")) {
0730: currentAttacmentPrev = currentAttacmentContainerFile
0731: .addNewPreview();
0732: currentAttacmentPrev = BuilderUtil
0733: .createPreview(
0734: currentAttacmentPrev,
0735: filterAmp(titleAtacmentS),
0736: filterAmp(fileAtacmentTypeS),
0737: filterAmp(atachedFileName),
0738: filterAmp(fullFilePath)
0739: + "|"
0740: + filterAmp(atachedFileName),
0741: null, null, null, null,
0742: null, null,
0743: filterAmp(contentAtached),
0744: filterAmp(propertS), null,
0745: null);
0746:
0747: File file = null;
0748: try {
0749:
0750: //boolean isContainer = false;
0751: FileContainerManager manager = null;
0752: //String typeOfFile = "";
0753:
0754: if (filePathAtacmentTypeS.indexOf("|") != -1) {
0755: try {
0756: manager = FileContainerManagerFactory
0757: .getFileContainerManager("org.enhydra.snapperPreviewer.business.FileContainerManagerImpl");
0758: file = manager
0759: .getContainerFile(
0760: filePathAtacmentTypeS,
0761: null);
0762: } catch (Exception e) {
0763: file = null;
0764: }
0765: //isContainer = true;
0766:
0767: String filePath = "";
0768: if (file != null)
0769: filePath = file
0770: .getAbsolutePath();
0771:
0772: int indexOfExtension = filePath
0773: .lastIndexOf(".");
0774: if (indexOfExtension != -1) {
0775: //typeOfFile = filePath.substring(indexOfExtension+1,filePath.length());
0776: }
0777:
0778: } else {
0779:
0780: int indexOfExtension = filePathAtacmentTypeS
0781: .lastIndexOf(".");
0782: if (indexOfExtension != -1) {
0783: //typeOfFile = filePathAtacmentTypeS.substring(indexOfExtension+1,filePathAtacmentTypeS.length());
0784: }
0785:
0786: if (!filePathAtacmentTypeS
0787: .startsWith("ftp")) {
0788: file = new File(
0789: filePathAtacmentTypeS);
0790: } else {
0791:
0792: }
0793: }
0794:
0795: } catch (Exception e) {
0796:
0797: }
0798:
0799: if (file != null) {
0800: if (currentAttacmentPrevList == null)
0801: currentAttacmentPrevList = currentAttacmentPrev
0802: .addNewContainerFileList();
0803: currentAttacmentPrevList = createPDFContainerFileList(
0804: currentAttacmentPrevList, file,
0805: filePathAtacmentTypeS,
0806: showNumberOf, false);
0807: }
0808: } else {
0809: currentAttacmentPrev = currentAttacmentContainerFile
0810: .addNewPreview();
0811: currentAttacmentPrev = BuilderUtil
0812: .createPreview(
0813: currentAttacmentPrev,
0814: filterAmp(titleAtacmentS),
0815: filterAmp(fileAtacmentTypeS),
0816: filterAmp(atachedFileName),
0817: filterAmp(fullFilePath)
0818: + "|"
0819: + filterAmp(atachedFileName),
0820: null,
0821: null,
0822: null,
0823: null,
0824: null,
0825: null,
0826: filterAmp(contentAtached),
0827: filterNewLine(filterAmp(propertS)),
0828: null, null);
0829:
0830: }
0831:
0832: }
0833: curentNumberOfPreviewFiles++;
0834: }
0835: } else {
0836: break;
0837: }
0838: }
0839:
0840: return finallList;
0841: }
0842:
0843: public static String replaceAll(String input, String forReplace,
0844: String replaceWith) {
0845: if (input == null)
0846: return null;
0847: StringBuffer result = new StringBuffer();
0848: boolean hasMore = true;
0849: while (hasMore) {
0850: int start = input.indexOf(forReplace);
0851: int end = start + forReplace.length();
0852: if (start != -1) {
0853: result.append(input.substring(0, start) + replaceWith);
0854: input = input.substring(end);
0855: } else {
0856: hasMore = false;
0857: result.append(input);
0858: }
0859: }
0860: if (result.toString().equals(""))
0861: return input; // nothing is changed
0862:
0863: return result.toString();
0864: }
0865:
0866: public static String clearContent(String oldContent, String title,
0867: String filePath, String properties, String meatData) {
0868: String newContent = "";
0869:
0870: int ind = filePath.indexOf('|');
0871: if (ind == -1)
0872: ind = filePath.length();
0873: String remfp = filePath.substring(0, ind);
0874:
0875: if (!title.equals("") && oldContent.startsWith(title)) {
0876: if ((oldContent.length() == (title.length())))
0877: oldContent = "";
0878: else
0879: oldContent = oldContent.substring(title.length() + 1);
0880:
0881: }
0882:
0883: if (!filePath.equals("") && oldContent.startsWith(filePath)) {
0884: if ((oldContent.length() == (filePath.length())))
0885: oldContent = "";
0886: else
0887: oldContent = oldContent
0888: .substring(filePath.length() + 1);
0889:
0890: }
0891:
0892: if (!remfp.equals("") && oldContent.startsWith(remfp)) {
0893: if ((oldContent.length() == remfp.length()))
0894: oldContent = "";
0895: else
0896: oldContent = oldContent.substring(remfp.length() + 1);
0897:
0898: }
0899:
0900: if (!properties.equals("") && oldContent.startsWith(properties)) {
0901: if ((oldContent.length() == (properties.length())))
0902: oldContent = "";
0903: else
0904: oldContent = oldContent
0905: .substring(properties.length() + 1);
0906:
0907: }
0908:
0909: if (meatData != null && !meatData.equals("")
0910: && oldContent.startsWith(meatData)) {
0911: if ((oldContent.length() == (meatData.length())))
0912: oldContent = "";
0913: else
0914: oldContent = oldContent
0915: .substring(meatData.length() + 1);
0916: }
0917:
0918: newContent = new String(oldContent);
0919:
0920: return newContent;
0921: }
0922:
0923: public static String filter(String stringToFilter, boolean filter) {
0924: //potrebno zbog xml-a
0925: if (stringToFilter == null)
0926: return "";
0927:
0928: if (filter) {
0929: stringToFilter = stringToFilter.replaceAll("<B>", " ");
0930: stringToFilter = stringToFilter.replaceAll("</B>", " ");
0931: stringToFilter = stringToFilter.replaceAll("<b>", " ");
0932: stringToFilter = stringToFilter.replaceAll("</b>", " ");
0933: }
0934:
0935: stringToFilter = stringToFilter.replaceAll("\u0000", " ");
0936: stringToFilter = stringToFilter.replaceAll("\u0001", " ");
0937: stringToFilter = stringToFilter.replaceAll("\u0002", " ");
0938: stringToFilter = stringToFilter.replaceAll("\u0003", " ");
0939: stringToFilter = stringToFilter.replaceAll("\u0004", " ");
0940: stringToFilter = stringToFilter.replaceAll("\u0005", " ");
0941: stringToFilter = stringToFilter.replaceAll("\u0006", " ");
0942: stringToFilter = stringToFilter.replaceAll("\u0007", " ");
0943: stringToFilter = stringToFilter.replaceAll("\u0008", " ");
0944: stringToFilter = stringToFilter.replaceAll("\u0009", " ");
0945: stringToFilter = stringToFilter.replaceAll("\u0010", " ");
0946: stringToFilter = stringToFilter.replaceAll("\u0011", " ");
0947: stringToFilter = stringToFilter.replaceAll("\u0012", " ");
0948: stringToFilter = stringToFilter.replaceAll("\u0013", " ");
0949: stringToFilter = stringToFilter.replaceAll("\u0014", " ");
0950: stringToFilter = stringToFilter.replaceAll("\u0015", " ");
0951: stringToFilter = stringToFilter.replaceAll("\u0016", " ");
0952: stringToFilter = stringToFilter.replaceAll("\u0017", " ");
0953: stringToFilter = stringToFilter.replaceAll("\u0018", " ");
0954: stringToFilter = stringToFilter.replaceAll("\u0019", " ");
0955: stringToFilter = stringToFilter.replaceAll("\uffff", " ");
0956: stringToFilter = stringToFilter.replaceAll("\ufffe", " ");
0957: stringToFilter = stringToFilter.replaceAll("\ud800", " ");
0958: stringToFilter = stringToFilter.replaceAll("\udc00", " ");
0959: stringToFilter = stringToFilter.replaceAll("\u1c0000", " ");
0960: stringToFilter = stringToFilter.replaceAll("\u000b", " ");
0961: stringToFilter = stringToFilter.replaceAll("\u000c", " ");
0962: stringToFilter = stringToFilter.replaceAll("\u000e", " ");
0963: stringToFilter = stringToFilter.replaceAll("\u000f", " ");
0964: stringToFilter = stringToFilter.replaceAll("\u001a", " ");
0965: stringToFilter = stringToFilter.replaceAll("\u001b", " ");
0966: stringToFilter = stringToFilter.replaceAll("\u001c", " ");
0967: stringToFilter = stringToFilter.replaceAll("\u001d", " ");
0968: stringToFilter = stringToFilter.replaceAll("\u001e", " ");
0969: stringToFilter = stringToFilter.replaceAll("\u001f", "");
0970:
0971: return stringToFilter;
0972: }
0973:
0974: public static String filterNewLine(String stringToFilter) {
0975: // potrebno zbog zeusa (imamo valjan string za html kad vrati searcher, medjutim kad vraca xml on &nesto transformise u znak, a mi ocemo da ostane originalno tako da ce on vratiti kao shto smo mu i setovali)
0976: stringToFilter = replaceAll(stringToFilter, "\n", "<BR>");
0977: return stringToFilter;
0978: }
0979:
0980: public static String filterIfNotHighlihted(String stringToFilter) {
0981: //stringToFilter = stringToFilter.replaceAll("&","&");
0982: stringToFilter = stringToFilter.replaceAll("<", "<# ");
0983: stringToFilter = stringToFilter.replaceAll(">", " #>");
0984: return stringToFilter;
0985: }
0986:
0987: public static String filterIfNotHighlihtedInverse(
0988: String stringToFilter) {
0989: //stringToFilter = stringToFilter.replaceAll("&","&");
0990: stringToFilter = stringToFilter.replaceAll("&lt;# ", "<");
0991: stringToFilter = stringToFilter.replaceAll(" #&gt;", ">");
0992: return stringToFilter;
0993: }
0994:
0995: public static String filterAmp(String stringToFilter) {
0996: // potrebno zbog zeusa (imamo valjan string za html kad vrati searcher, medjutim kad vraca xml on &nesto transformise u znak, a mi ocemo da ostane originalno tako da ce on vratiti kao shto smo mu i setovali)
0997: //stringToFilter = replaceAll(stringToFilter, "&", "&");
0998: return stringToFilter;
0999: }
1000:
1001: public static String filterContentStartNewLine(String stringToFilter) {
1002:
1003: while (stringToFilter.startsWith(" ")) {
1004: stringToFilter = stringToFilter.replaceFirst(" ", "");
1005: }
1006:
1007: while (stringToFilter.startsWith("\r<BR>")) {
1008: stringToFilter = stringToFilter.replaceFirst("\r<BR>", "");
1009: }
1010: return stringToFilter;
1011: }
1012:
1013: public static String filterXLSDocument(String stringToFilter) {
1014:
1015: stringToFilter = stringToFilter.replaceAll("<", "<");
1016: stringToFilter = stringToFilter.replaceAll(">", ">");
1017:
1018: return stringToFilter;
1019: }
1020:
1021: public static String filterForQuery(String stringToFilter) {
1022: stringToFilter = replaceAll(stringToFilter, "\\\\", "\\");
1023: stringToFilter = replaceAll(stringToFilter, "\\:", ":");
1024: stringToFilter = replaceAll(stringToFilter, "\\", "\\\\");
1025: stringToFilter = replaceAll(stringToFilter, ":", "\\:");
1026: // stringToFilter = replaceAll(stringToFilter, "&", " ");
1027: return stringToFilter;
1028: }
1029:
1030: public static Preview prepareEmailFiles(Preview oldPreview) {
1031:
1032: String props = oldPreview.getProperties();
1033:
1034: StringTokenizer st = new StringTokenizer(props, "\n");
1035: while (st.hasMoreTokens()) {
1036: String line = st.nextToken();
1037:
1038: String key = null;
1039: String value = null;
1040:
1041: int index = line.indexOf(":");
1042: try {
1043: if (index != -1) {
1044: key = line.substring(0, index).trim();
1045: value = line.substring(index + 1);
1046: }
1047: } catch (Exception e) {
1048: key = null;
1049: }
1050:
1051: if (key != null) {
1052: if (key.trim().equals("From")) {
1053: if (value != null) {
1054: oldPreview
1055: .setFrom(filterIfNotHighlihted(filter(
1056: value, true)));
1057: }
1058: } else if (key.trim().equals("To")) {
1059: if (value != null) {
1060: oldPreview.setTo(filterIfNotHighlihted(filter(
1061: value, true)));
1062: }
1063: } else if (key.trim().equals("CC")) {
1064: if (value != null) {
1065: oldPreview.setCC(filterIfNotHighlihted(filter(
1066: value, true)));
1067: }
1068: } else if (key.trim().equals("Subject")) {
1069: if (value != null) {
1070: oldPreview
1071: .setSubject(filterIfNotHighlihted(filter(
1072: value, true)));
1073: }
1074: } else if (key.trim().equals("Sent")) {
1075: if (value != null) {
1076: oldPreview
1077: .setSent(filterIfNotHighlihted(filter(
1078: value, true)));
1079: }
1080: } else if (key.trim().equals("Received")) {
1081: if (value != null) {
1082: oldPreview
1083: .setReceived(filterIfNotHighlihted(filter(
1084: value, true)));
1085: }
1086: } else if (key.trim().equals("Bcc")) {
1087: if (value != null) {
1088: oldPreview.setBCC(filterIfNotHighlihted(filter(
1089: value, true)));
1090: }
1091: } else if (key.trim().equals("Signed")) {
1092: if (value != null) {
1093: oldPreview
1094: .setSigned(filterIfNotHighlihted(filter(
1095: value, true)));
1096: }
1097: } else if (key.trim().equals("Priority")) {
1098: if (value != null) {
1099: oldPreview
1100: .setPriority(filterIfNotHighlihted(filter(
1101: value, true)));
1102: }
1103: } else if (key.trim().equals(
1104: "Delivery Receipt Requested")) {
1105: if (value != null) {
1106: oldPreview
1107: .setDeliveryReceiptRequested(filterIfNotHighlihted(filter(
1108: value, true)));
1109: }
1110: } else if (key.trim().equals("Read Receipt Requested")) {
1111: if (value != null) {
1112: oldPreview
1113: .setReadReceiptRequested(filterIfNotHighlihted(filter(
1114: value, true)));
1115: }
1116: } else if (key.trim().equals("Expires")) {
1117: if (value != null) {
1118: oldPreview
1119: .setExpires(filterIfNotHighlihted(filter(
1120: value, true)));
1121: }
1122: } else if (key.trim().equals("Sensitivity")) {
1123: if (value != null) {
1124: oldPreview
1125: .setSensitivity(filterIfNotHighlihted(filter(
1126: value, true)));
1127: }
1128: }
1129: }
1130: }
1131: oldPreview.setProperties("");
1132:
1133: return oldPreview;
1134: }
1135:
1136: public static ContainerFileList createContainerFileList(
1137: ContainerFileList atachedFileListO, ResultElement[] re,
1138: String tempabsolutFilePath, String siteName,
1139: String indexDir, String query,
1140: java.util.Properties sitelist, int showNumberOf) {
1141: Vector filesToPreview = new Vector();
1142:
1143: for (int j = 0; j < re.length; j++) {
1144: String filePathAtacmentTypeS = re[j].getAbsolutFilePath();
1145: String luceneId = re[j].getLuceneID();
1146:
1147: String atachedFileName = "";
1148:
1149: if (filePathAtacmentTypeS.startsWith(tempabsolutFilePath
1150: + "|")) {
1151: atachedFileName = filePathAtacmentTypeS.substring(
1152: tempabsolutFilePath.length() + 1,
1153: filePathAtacmentTypeS.length());
1154: } else
1155: continue;
1156:
1157: if (atachedFileName.indexOf("|") != -1)
1158: continue;
1159:
1160: if (showNumberOf == 0
1161: || filesToPreview.size() < showNumberOf)
1162: filesToPreview.add(luceneId);
1163: }
1164:
1165: for (int k = 0; k < filesToPreview.size(); k++) {
1166: //preview napravi
1167: String curentLuceneID = (String) filesToPreview
1168: .elementAt(k);
1169: Searcher searcher1 = SnapperManager.getInstance()
1170: .getSearcherFactory().newSearcher();
1171: ResultElement currentRetVal = searcher1.getDocumentByID(
1172: siteName, indexDir, (new Integer(curentLuceneID))
1173: .intValue(), query);
1174: String titleAtacmentS = currentRetVal.getTitle();
1175: String fileAtacmentTypeS = currentRetVal.getFileType();
1176: String filePathAtacmentTypeS = currentRetVal
1177: .getAbsolutFilePath();
1178: String contentAtached = currentRetVal.getContent();
1179: //String lastModifiedL = currentRetVal.getModified();
1180: String propertS = currentRetVal.getProperties();
1181: String siteNameS = currentRetVal.getSiteName();
1182:
1183: String atachedFileName = "";
1184: if (filePathAtacmentTypeS.startsWith(tempabsolutFilePath
1185: + "|")) {
1186: atachedFileName = filePathAtacmentTypeS.substring(
1187: tempabsolutFilePath.length() + 1,
1188: filePathAtacmentTypeS.length());
1189: } else
1190: continue;
1191:
1192: if (atachedFileName.indexOf("|") != -1)
1193: continue;
1194:
1195: String rootContainer = tempabsolutFilePath;
1196:
1197: int indexOfRoot = rootContainer.indexOf("|");
1198:
1199: if (indexOfRoot != -1)
1200: rootContainer = rootContainer.substring(0, indexOfRoot);
1201:
1202: Preview currenPrev = null;
1203: ContainerFile cf = atachedFileListO.addNewContainerFile();
1204:
1205: if (fileAtacmentTypeS.equalsIgnoreCase("msg")
1206: || fileAtacmentTypeS.equalsIgnoreCase("pst")
1207: || fileAtacmentTypeS.equalsIgnoreCase("eml")) {
1208:
1209: currenPrev = BuilderUtil.createPreview(cf
1210: .addNewPreview(), filterAmp(titleAtacmentS),
1211: filterAmp(fileAtacmentTypeS),
1212: filterAmp(atachedFileName),
1213: filterAmp(filePathAtacmentTypeS),
1214: filterAmp(siteNameS), null, null, null, null,
1215: null, filterAmp(clearContent(contentAtached,
1216: titleAtacmentS, rootContainer,
1217: propertS, "")), filterAmp(propertS),
1218: null, null);
1219:
1220: currenPrev = prepareEmailFiles((Preview) currenPrev);
1221: } else if (fileAtacmentTypeS.equalsIgnoreCase("pdf")) {
1222: currenPrev = BuilderUtil.createPreview(cf
1223: .addNewPreview(), filterAmp(titleAtacmentS),
1224: filterAmp(fileAtacmentTypeS),
1225: filterAmp(atachedFileName),
1226: filterAmp(filePathAtacmentTypeS),
1227: filterAmp(siteNameS), null, null, null, null,
1228: null, filterAmp(clearContent(contentAtached,
1229: titleAtacmentS, rootContainer,
1230: propertS, "")), BuilderUtil
1231: .filterNewLine(filterAmp(propertS)),
1232: null, null);
1233:
1234: File file = null;
1235: try {
1236:
1237: //boolean isContainer = false;
1238: FileContainerManager manager = null;
1239: //String typeOfFile = "";
1240:
1241: if (filePathAtacmentTypeS.indexOf("|") != -1) {
1242: try {
1243: manager = FileContainerManagerFactory
1244: .getFileContainerManager("org.enhydra.snapperPreviewer.business.FileContainerManagerImpl");
1245: manager.init();
1246: file = manager.getContainerFile(
1247: filePathAtacmentTypeS, siteName);
1248: } catch (Exception e) {
1249: file = null;
1250: }
1251: //isContainer = true;
1252:
1253: String filePath = "";
1254: if (file != null)
1255: filePath = file.getAbsolutePath();
1256:
1257: int indexOfExtension = filePath
1258: .lastIndexOf(".");
1259: if (indexOfExtension != -1) {
1260: //typeOfFile = filePath.substring(indexOfExtension+1,filePath.length());
1261: }
1262:
1263: } else {
1264:
1265: int indexOfExtension = filePathAtacmentTypeS
1266: .lastIndexOf(".");
1267: if (indexOfExtension != -1) {
1268: //typeOfFile = filePathAtacmentTypeS.substring(indexOfExtension+1,filePathAtacmentTypeS.length());
1269: }
1270:
1271: if (!filePathAtacmentTypeS.startsWith("ftp")) {
1272: file = new File(filePathAtacmentTypeS);
1273: } else {
1274:
1275: }
1276: }
1277:
1278: } catch (Exception e) {
1279:
1280: }
1281:
1282: if (file != null)
1283: currenPrev
1284: .setContainerFileList(createPDFContainerFileList(
1285: currenPrev
1286: .addNewContainerFileList(),
1287: file, filePathAtacmentTypeS,
1288: showNumberOf, false));
1289:
1290: } else {
1291: currenPrev = BuilderUtil.createPreview(cf
1292: .addNewPreview(), filterAmp(titleAtacmentS),
1293: filterAmp(fileAtacmentTypeS),
1294: filterAmp(atachedFileName),
1295: filterAmp(filePathAtacmentTypeS),
1296: filterAmp(siteNameS), null, null, null, null,
1297: null, filterAmp(clearContent(contentAtached,
1298: titleAtacmentS, rootContainer,
1299: propertS, "")), BuilderUtil
1300: .filterNewLine(filterAmp(propertS)),
1301: null, null);
1302:
1303: }
1304:
1305: Searcher searcher = SnapperManager.getInstance()
1306: .getSearcherFactory().newSearcher();
1307: ResultElement[] re1 = null;
1308: try {
1309: searcher.setUpSearcher(sitelist);
1310: searcher.searchDocs("path:\""
1311: + BuilderUtil
1312: .filterForQuery(tempabsolutFilePath)
1313: + "|"
1314: + BuilderUtil.filterForQuery(atachedFileName)
1315: + "\"", "");
1316:
1317: SearchResult sR1 = searcher.getSearchResult();
1318: re1 = sR1.getResultElements();
1319: searcher.close();
1320: searcher = null;
1321: } catch (Exception e) {
1322: re1 = null;
1323: }
1324: if (re1 != null) {
1325: ContainerFileList atachedFileListO1 = null;
1326: for (int j = 0; j < re1.length; j++) {
1327: String luceneIDS = re1[j].getLuceneID();
1328: //String fileName = re1[j].getAbsolutFileName();
1329: String fullPath = re1[j].getAbsolutFilePath();
1330:
1331: String atachedFileName1 = "";
1332:
1333: if (fullPath.startsWith(tempabsolutFilePath + "|"
1334: + atachedFileName)) {
1335: atachedFileName1 = fullPath.substring(
1336: tempabsolutFilePath.length()
1337: + atachedFileName.length() + 1,
1338: fullPath.length());
1339: } else
1340: continue;
1341:
1342: if (!atachedFileName1.equals("")) {
1343: if (atachedFileListO1 == null) {
1344: atachedFileListO1 = currenPrev
1345: .addNewContainerFileList();
1346: }
1347:
1348: if (atachedFileName1.startsWith("|"))
1349: atachedFileName1 = atachedFileName1
1350: .substring(1, atachedFileName1
1351: .length());
1352:
1353: ContainerFile atachFileO = atachedFileListO1
1354: .addNewContainerFile();
1355: atachFileO.setLuceneID(luceneIDS);
1356: atachFileO
1357: .setInsideContainerFilePath(BuilderUtil
1358: .createInsideContainerFilePath(BuilderUtil
1359: .filterAmp(atachedFileName1)));
1360: }
1361: }
1362: }
1363: }
1364: return atachedFileListO;
1365:
1366: }
1367:
1368: }
|