Source Code Cross Referenced for Previewer.java in  » Search-Engine » snapper » org » enhydra » snapperPreviewer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » snapper » org.enhydra.snapperPreviewer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * snapperPreviewer 
003:         *
004:         * Enhydra super-servlet
005:         * 
006:         */
007:
008:        package org.enhydra.snapperPreviewer;
009:
010:        import java.io.File;
011:        import java.io.FileInputStream;
012:        import java.io.FileOutputStream;
013:        import java.io.InputStream;
014:        import java.util.Properties;
015:        import java.util.StringTokenizer;
016:
017:        import javax.xml.transform.Templates;
018:        import javax.xml.transform.TransformerFactory;
019:        import javax.xml.transform.stream.StreamSource;
020:
021:        import org.enhydra.snapper.SnapperManager;
022:        import org.enhydra.snapperPreviewer.spec.SiteList;
023:        import org.enhydra.snapperPreviewer.spec.SiteListFactory;
024:
025:        import com.lutris.appserver.server.ApplicationException;
026:        import com.lutris.appserver.server.StandardApplication;
027:        import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
028:        import com.lutris.logging.LogChannel;
029:        import com.lutris.logging.Logger;
030:        import com.lutris.util.Config;
031:        import com.lutris.util.ConfigException;
032:
033:        /**
034:         * The application object.
035:         *
036:         * Application-wide data would go here.
037:         * 
038:         * @author Milin Radivoj
039:         */
040:        public class Previewer extends StandardApplication {
041:
042:            protected static String version = "v1.1";
043:
044:            private static LogChannel log;
045:
046:            private static String indexDir;
047:
048:            private static String xslDirectory;
049:
050:            private static Properties converterClassNames = new Properties();
051:
052:            //private static int parsedTextLength;
053:            private static int picturePixel;
054:
055:            private static int pictureColorNumber;
056:
057:            //private static int pictureMaxPerPage;
058:            private static String outputFileFormat;
059:
060:            private static boolean useGrayFilter = false;
061:
062:            private static int filesInContainer;
063:
064:            private static boolean filesInContainerPrev = false;
065:
066:            protected static String siteConfFile = null;
067:
068:            protected static String documentGroupConfFile = null;
069:
070:            // private static int maxPixelNumberPictureInDocument;
071:            private static boolean relative = false;
072:
073:            private static String zoomed;
074:
075:            protected static String pathOfConvertedFiles = null;
076:
077:            protected static boolean toReadConvertedFile = false;
078:
079:            protected static int reReadConfigFilesEveryMinutes;
080:
081:            protected static long timeToSleep = 24;
082:
083:            private Thread reader = null;
084:
085:            private Thread deleter = null;
086:
087:            protected static String JBIGConverterPath = null;
088:
089:            private static String word2007HTMLTransformationPath = "";
090:
091:            private static String word2007TextTransformationPath = "";
092:
093:            private static String excel2007HTMLTransformationPath = "";
094:
095:            private static String excel2007TextTransformationPath = "";
096:
097:            private static String powerpoint2007HTMLTransformationPath = "";
098:
099:            private static String powerpoint2007TextTransformationPath = "";
100:
101:            private static long timeLimit = 0;
102:
103:            private static int containerFilesPreviewLimit;
104:
105:            private static String translatorConnectionString = "";
106:
107:            private static String translatorContentString = "";
108:
109:            private static String translatorLangpairString = "";
110:
111:            private static String translatorContentStartString = "";
112:
113:            private static String translatorContentEndString = "";
114:
115:            private static Templates word2007TextTemplates = null;
116:
117:            private static Templates word2007HTMLTemplates = null;
118:
119:            private static Templates excel2007TextTemplates = null;
120:
121:            private static Templates excel2007HTMLTemplates = null;
122:
123:            private static Templates powerpoint2007TextTemplates = null;
124:
125:            private static Templates powerpoint2007HTMLTemplates = null;
126:
127:            private static String showTranslateBar = "true";
128:
129:            public void startup(Config appConfig) throws ApplicationException {
130:                super .startup(appConfig);
131:
132:                log = this .getLogChannel();
133:
134:                Properties prop = new Properties();
135:                try {
136:                    prop.put("SearcherFactoryClassName", appConfig
137:                            .getString("Previewer.SearcherFactoryClassName"));
138:                    prop.put("LoggingManagerClassName", appConfig
139:                            .getString("Previewer.LoggingManagerClassName"));
140:                    prop
141:                            .put("LoggerName",
142:                                    "org.enhydra.snapper.SnapperManager");
143:                    prop.put("TempDir", appConfig.getString(
144:                            "Previewer.TempDir", System
145:                                    .getProperty("user.home")
146:                                    + File.separator + ".previewerTemp"));
147:                } catch (ConfigException except) {
148:                    throw new ApplicationException(except);
149:                }
150:
151:                SnapperManager.getInstance().init(prop);
152:
153:                try {
154:                    xslDirectory = appConfig
155:                            .getString("Previewer.Xsl.Directory");
156:                    File temp = new File(xslDirectory);
157:
158:                    if (!temp.isDirectory())
159:                        temp = new File(appConfig.getConfigFile().getFile()
160:                                .getParent()
161:                                + File.separator + xslDirectory);
162:
163:                    if (temp.isDirectory()) {
164:                        xslDirectory = temp.getCanonicalPath();
165:                    } else {
166:                        Previewer
167:                                .logError("Previewer.Xsl.Directory application parameter isn't properly initialized!");
168:                    }
169:                } catch (Exception e) {
170:                    Previewer
171:                            .logError("Previewer.Xsl.Directory application parameter isn't properly initialized!");
172:                }
173:
174:                try {
175:                    indexDir = appConfig.getString("Snapper.IndexDir");
176:                } catch (ConfigException e) {
177:                    Previewer
178:                            .logError("Snapper.IndexDir application parameter isn't properly initialized!");
179:                }
180:
181:                try {
182:                    filesInContainer = appConfig.getInt(
183:                            "Previewer.FilesInContainer.NumberOf", 0);
184:                } catch (ConfigException e) {
185:                    Previewer
186:                            .logError("Previewer.PictureMaxScale application parameter isn't properly initialized!");
187:                }
188:
189:                try {
190:                    String excelConverterClassName = appConfig
191:                            .getString(
192:                                    "Previewer.Parser.Excel.ConverterClassName",
193:                                    "org.enhydra.snapper.parsers.fileparsers.parsers.excelparser.ExcelToText");
194:                    converterClassNames.put("xls", excelConverterClassName);
195:
196:                } catch (ConfigException e) {
197:                    Previewer
198:                            .logError("Previewer.Parser.Excel.ConverterClassName application parameter isn't properly initialized!");
199:                }
200:
201:                try {
202:                    String powerConverterClassName = appConfig
203:                            .getString(
204:                                    "Previewer.Parser.PowerPoint.ConverterClassName",
205:                                    "org.enhydra.snapper.parsers.fileparsers.parsers.powerparser.PowerToText");
206:                    converterClassNames.put("ppt", powerConverterClassName);
207:
208:                } catch (ConfigException e) {
209:                    log
210:                            .write(
211:                                    Logger.ERROR,
212:                                    "Previewer.Parser.Excel.ConverterClassName application parameter isn't properly initialized!");
213:                }
214:
215:                try {
216:                    String wordConverterClassName = appConfig
217:                            .getString(
218:                                    "Previewer.Parser.Word.ConverterClassName",
219:                                    "org.enhydra.snapper.parsers.fileparsers.parsers.wordparser.WordToText");
220:                    converterClassNames.put("doc", wordConverterClassName);
221:
222:                } catch (ConfigException e) {
223:                    log
224:                            .write(
225:                                    Logger.ERROR,
226:                                    "Previewer.Parser.Word.ConverterClassName application parameter isn't properly initialized!");
227:                }
228:
229:                try {
230:                    String excel2007ConverterClassName = appConfig
231:                            .getString(
232:                                    "Previewer.Parser.Excel2007.ConverterClassName",
233:                                    "org.enhydra.snapper.parsers.fileparsers.parsers.excel2007parser.Excel2007ToText");
234:                    converterClassNames
235:                            .put("xlsx", excel2007ConverterClassName);
236:
237:                } catch (ConfigException e) {
238:                    Previewer
239:                            .logError("Previewer.Parser.Excel2007.ConverterClassName application parameter isn't properly initialized!");
240:                }
241:
242:                try {
243:                    String power2007ConverterClassName = appConfig
244:                            .getString(
245:                                    "Previewer.Parser.PowerPoint2007.ConverterClassName",
246:                                    "org.enhydra.snapper.parsers.fileparsers.parsers.powerpoint2007parser.PowerPoint2007ToText");
247:                    converterClassNames
248:                            .put("pptx", power2007ConverterClassName);
249:
250:                } catch (ConfigException e) {
251:                    log
252:                            .write(
253:                                    Logger.ERROR,
254:                                    "Previewer.Parser.PowerPoint2007.ConverterClassName application parameter isn't properly initialized!");
255:                }
256:
257:                try {
258:                    String word2007ConverterClassName = appConfig
259:                            .getString(
260:                                    "Previewer.Parser.Word2007.ConverterClassName",
261:                                    "org.enhydra.snapper.parsers.fileparsers.parsers.wordparser2007parser.Word2007ToText");
262:                    converterClassNames.put("docx", word2007ConverterClassName);
263:
264:                } catch (ConfigException e) {
265:                    log
266:                            .write(
267:                                    Logger.ERROR,
268:                                    "Previewer.Parser.Word207.ConverterClassName application parameter isn't properly initialized!");
269:                }
270:
271:                try {
272:                    String use = appConfig.getString(
273:                            "Previewer.FilesInContainer.toPreview", "false");
274:                    if (use.equals("true"))
275:                        filesInContainerPrev = true;
276:                } catch (ConfigException e) {
277:                    Previewer
278:                            .logError("Previewer.OutputFileFormat application parameter isn't properly initialized!");
279:                }
280:
281:                try {
282:                    picturePixel = appConfig.getInt(
283:                            "Previewer.Picture.MaxPixelNumber", 200);
284:                } catch (ConfigException e) {
285:                    Previewer
286:                            .logError("Previewer.PictureMaxScale application parameter isn't properly initialized!");
287:                }
288:
289:                try {
290:                    zoomed = appConfig.getString("Previewer.Picture.Zoomed",
291:                            "false");
292:                } catch (ConfigException e) {
293:                    Previewer
294:                            .logError("Previewer.Zoomed application parameter isn't properly initialized!");
295:                }
296:
297:                try {
298:                    pictureColorNumber = appConfig.getInt(
299:                            "Previewer.Picture.ReduceColor", 0);
300:                } catch (ConfigException e) {
301:                    Previewer
302:                            .logError("Previewer.PictureColorNumber application parameter isn't properly initialized!");
303:                }
304:
305:                try {
306:                    relative = (new Boolean(appConfig.getString(
307:                            "Previewer.RelativeIndexPath", "false")))
308:                            .booleanValue();
309:                } catch (ConfigException e) {
310:                    relative = false;
311:                    //Previewer.logError("Previewer.PictureColorNumber application parameter isn't properly initialized!");
312:                }
313:
314:                try {
315:                    outputFileFormat = appConfig.getString(
316:                            "Previewer.Picture.ForceOutputFileFormat", "no");
317:                } catch (ConfigException e) {
318:                    Previewer
319:                            .logError("Previewer.OutputFileFormat application parameter isn't properly initialized!");
320:                }
321:
322:                try {
323:                    String use = appConfig.getString(
324:                            "Previewer.Picture.UseGrayFilter", "false");
325:                    if (use.equals("true"))
326:                        useGrayFilter = true;
327:                } catch (ConfigException e) {
328:                    Previewer
329:                            .logError("Previewer.OutputFileFormat application parameter isn't properly initialized!");
330:                }
331:                int pageLimit = 0;
332:                try {
333:                    pageLimit = appConfig
334:                            .getInt("Previewer.ParserPageLimit", 0);
335:                } catch (ConfigException e) {
336:                    pageLimit = 0;
337:                }
338:
339:                int characterLimit = 0;
340:                try {
341:                    characterLimit = appConfig.getInt(
342:                            "Previewer.ParserCharacterLimit", 0);
343:                } catch (ConfigException e) {
344:                    characterLimit = 0;
345:                }
346:
347:                Properties limit = new Properties();
348:
349:                try {
350:                    String pageLimitForParser = "";
351:                    try {
352:                        pageLimitForParser = appConfig.getString(
353:                                "Previewer.PageLimitForParser",
354:                                "pdf,docx,xlsx,pptx");
355:                    } catch (ConfigException e) {
356:                        pageLimitForParser = "pdf,docx,xlsx,pptx";
357:                    }
358:
359:                    StringTokenizer st = new StringTokenizer(
360:                            pageLimitForParser, ",");
361:                    if (st.countTokens() > 0) {
362:                        while (st.hasMoreTokens()) {
363:                            String token = st.nextToken();
364:                            limit.put(token.trim(), (new Integer(pageLimit))
365:                                    .toString());
366:                        }
367:                    }
368:                } catch (Exception e) {
369:                    characterLimit = 0;
370:                }
371:
372:                try {
373:                    String characterLimitForParser = "";
374:                    try {
375:                        characterLimitForParser = appConfig.getString(
376:                                "Previewer.CharacterLimitForParser", "");
377:                    } catch (ConfigException e) {
378:                        characterLimitForParser = "";
379:                    }
380:
381:                    StringTokenizer st = new StringTokenizer(
382:                            characterLimitForParser, ",");
383:                    if (st.countTokens() > 0) {
384:                        while (st.hasMoreTokens()) {
385:                            String token = st.nextToken();
386:                            limit.put(token.trim(),
387:                                    (new Integer(characterLimit)).toString());
388:                        }
389:                    }
390:                } catch (Exception e) {
391:                    characterLimit = 0;
392:                }
393:                try {
394:                    SnapperManager.getInstance()
395:                            .setParserLimitProperties(limit);
396:                } catch (Exception e) {
397:                }
398:
399:                try {
400:                    siteConfFile = appConfig
401:                            .getString("Previewer.SiteConfFile");
402:
403:                    File temp = new File(siteConfFile);
404:
405:                    if (!(temp.isFile() && temp.exists()))
406:                        temp = new File(System.getProperty("catalina.base"),
407:                                siteConfFile);
408:
409:                    if (temp.isFile() && temp.exists()) {
410:                        siteConfFile = temp.getCanonicalPath();
411:                    } else {
412:                        log
413:                                .write(Logger.WARNING,
414:                                        " 'Previewer.SiteConfFile' application parameter isn't properly initialized!");
415:                        siteConfFile = null;
416:                    }
417:
418:                } catch (Exception e) {
419:                    log
420:                            .write(Logger.WARNING,
421:                                    " 'Previewer.SiteConfFile' application parameter isn't properly initialized!");
422:                    siteConfFile = null;
423:                }
424:
425:                try {
426:                    documentGroupConfFile = appConfig
427:                            .getString("Previewer.DocumentGroupConfFile");
428:
429:                    File temp = new File(documentGroupConfFile);
430:
431:                    if (!(temp.isFile() && temp.exists()))
432:                        temp = new File(System.getProperty("catalina.base"),
433:                                documentGroupConfFile);
434:
435:                    if (temp.isFile() && temp.exists()) {
436:                        documentGroupConfFile = temp.getCanonicalPath();
437:                    } else {
438:                        log
439:                                .write(
440:                                        Logger.WARNING,
441:                                        " 'Previewer.DocumentGroupConfFile' application parameter isn't properly initialized!");
442:                        documentGroupConfFile = null;
443:                    }
444:
445:                } catch (Exception e) {
446:                    log
447:                            .write(
448:                                    Logger.WARNING,
449:                                    " 'Previewer.DocumentGroupConfFile' application parameter isn't properly initialized! ");
450:                    documentGroupConfFile = null;
451:                }
452:
453:                try {
454:                    reReadConfigFilesEveryMinutes = appConfig.getInt(
455:                            "Previewer.ReReadConfigFilesEveryMinutes", 5);
456:                } catch (ConfigException e) {
457:                    reReadConfigFilesEveryMinutes = 5;
458:                }
459:
460:                try {
461:                    SiteList sl = SiteListFactory
462:                            .getSiteList("org.enhydra.snapperPreviewer.business.SiteListImpl");
463:                    sl.init(siteConfFile, documentGroupConfFile);
464:                    reader = new Thread(sl);
465:                    reader.start();
466:                } catch (Exception e1) {
467:                    log.write(Logger.ERROR,
468:                            " Problem in configuration section : "
469:                                    + e1.getMessage());
470:                }
471:
472:                try {
473:                    timeToSleep = appConfig.getLong("Previewer.TimeToSleep");
474:                    SiteList del = SiteListFactory
475:                            .getSiteList("org.enhydra.snapperPreviewer.business.DeleterImpl");
476:                    //del.init(siteConfFile,documentGroupConfFile);
477:                    deleter = new Thread(del);
478:                    deleter.start();
479:                } catch (Exception e1) {
480:                    log.write(Logger.ERROR,
481:                            " Problem in configuration section : "
482:                                    + e1.getMessage());
483:                }
484:
485:                try {
486:                    pathOfConvertedFiles = appConfig
487:                            .getString("Previewer.PathOfConvertedFiles");
488:                } catch (ConfigException e) {
489:                    if (logChannel != null) {
490:                        logChannel
491:                                .write(
492:                                        Logger.INFO,
493:                                        "Previewer.PathOfConvertedFiles application parameter isn't properly initialized!");
494:
495:                    }
496:                }
497:
498:                try {
499:                    JBIGConverterPath = appConfig
500:                            .getString("Previewer.JBIGConverterPath");
501:                } catch (ConfigException e) {
502:                    if (logChannel != null) {
503:                        logChannel
504:                                .write(Logger.INFO,
505:                                        "Previewer.JBIGConverterPath application parameter isn't properly initialized!");
506:                    }
507:                }
508:
509:                try {
510:                    toReadConvertedFile = appConfig.getBoolean(
511:                            "Previewer.ReadConvertedFile", false);
512:                } catch (ConfigException e) {
513:                    toReadConvertedFile = false;
514:                }
515:
516:                try {
517:                    timeLimit = appConfig.getLong("Previewer.TimeLimit", 0);
518:                } catch (ConfigException e) {
519:                    timeLimit = 0;
520:                }
521:
522:                try {
523:                    containerFilesPreviewLimit = appConfig.getInt(
524:                            "Previewer.ContainerFilesPreviewLimit", 3);
525:                } catch (ConfigException e) {
526:                    Previewer
527:                            .logError("Previewer.ContainerFilesPreviewLimit application parameter isn't properly initialized!");
528:                }
529:
530:                try {
531:                    log.write(Logger.INFO, " Snapper Previewer " + version
532:                            + " started");
533:                } catch (Exception e) {
534:                }
535:
536:                try {
537:
538:                    translatorConnectionString = appConfig.getString(
539:                            "Previewer.TranslatorConnectionString", "");
540:                } catch (ConfigException e) {
541:                    translatorConnectionString = "";
542:                }
543:
544:                try {
545:
546:                    translatorContentString = appConfig.getString(
547:                            "Previewer.TranslatorContentString", "");
548:                } catch (ConfigException e) {
549:                    translatorContentString = "";
550:                }
551:
552:                try {
553:
554:                    translatorLangpairString = appConfig.getString(
555:                            "Previewer.TranslatorLangpairString", "");
556:                } catch (ConfigException e) {
557:                    translatorLangpairString = "";
558:                }
559:
560:                try {
561:
562:                    translatorContentStartString = appConfig.getString(
563:                            "Previewer.TranslatorContentStartString", "");
564:                } catch (ConfigException e) {
565:                    translatorContentStartString = "";
566:                }
567:
568:                try {
569:
570:                    translatorContentEndString = appConfig.getString(
571:                            "Previewer.TranslatorContentEndString", "");
572:                } catch (ConfigException e) {
573:                    translatorContentEndString = "";
574:                }
575:
576:                try {
577:                    word2007TextTransformationPath = appConfig
578:                            .getString("Previewer.Word2007TextTransformationPath");
579:                    File temp = new File(word2007TextTransformationPath);
580:
581:                    if (temp.exists()) {
582:                        TransformerFactory tFactory = TransformerFactory
583:                                .newInstance();
584:                        word2007TextTemplates = tFactory
585:                                .newTemplates(new StreamSource(temp));
586:                    } else {
587:                        java.net.URL url = null;
588:                        ClassLoader cl = this .getClass().getClassLoader();
589:                        url = cl.getResource("xsl/docx2txt.xsl");
590:                        InputStream xslFile = url.openStream();
591:                        TransformerFactory tFactory = TransformerFactory
592:                                .newInstance();
593:                        word2007TextTemplates = tFactory
594:                                .newTemplates(new StreamSource(xslFile));
595:                    }
596:                } catch (Exception e) {
597:                }
598:
599:                try {
600:                    word2007HTMLTransformationPath = appConfig
601:                            .getString("Previewer.Word2007HTMLTransformationPath");
602:                    File temp = new File(word2007HTMLTransformationPath);
603:
604:                    if (temp.exists()) {
605:                        TransformerFactory tFactory = TransformerFactory
606:                                .newInstance();
607:                        word2007HTMLTemplates = tFactory
608:                                .newTemplates(new StreamSource(temp));
609:                    } else {
610:                        java.net.URL url = null;
611:                        ClassLoader cl = this .getClass().getClassLoader();
612:                        url = cl.getResource("xsl/docx2html.xsl");
613:                        InputStream xslFile = url.openStream();
614:                        TransformerFactory tFactory = TransformerFactory
615:                                .newInstance();
616:                        word2007HTMLTemplates = tFactory
617:                                .newTemplates(new StreamSource(xslFile));
618:                    }
619:                } catch (Exception e) {
620:                }
621:
622:                try {
623:                    excel2007TextTransformationPath = appConfig
624:                            .getString("Previewer.Excel2007TextTransformationPath");
625:                    File temp = new File(excel2007TextTransformationPath);
626:
627:                    if (temp.exists()) {
628:                        TransformerFactory tFactory = TransformerFactory
629:                                .newInstance();
630:                        excel2007TextTemplates = tFactory
631:                                .newTemplates(new StreamSource(temp));
632:                    } else {
633:                        java.net.URL url = null;
634:                        ClassLoader cl = this .getClass().getClassLoader();
635:                        url = cl.getResource("xsl/xlsx2txt.xsl");
636:                        InputStream xslFile = url.openStream();
637:                        TransformerFactory tFactory = TransformerFactory
638:                                .newInstance();
639:                        excel2007TextTemplates = tFactory
640:                                .newTemplates(new StreamSource(xslFile));
641:                    }
642:                } catch (Exception e) {
643:                }
644:
645:                try {
646:                    excel2007HTMLTransformationPath = appConfig
647:                            .getString("Previewer.Excel2007HTMLTransformationPath");
648:                    File temp = new File(excel2007HTMLTransformationPath);
649:
650:                    if (temp.exists()) {
651:                        TransformerFactory tFactory = TransformerFactory
652:                                .newInstance();
653:                        excel2007HTMLTemplates = tFactory
654:                                .newTemplates(new StreamSource(temp));
655:                    } else {
656:                        java.net.URL url = null;
657:                        ClassLoader cl = this .getClass().getClassLoader();
658:                        url = cl.getResource("xsl/Excel2XML.xsl");
659:                        InputStream xslFile = url.openStream();
660:                        TransformerFactory tFactory = TransformerFactory
661:                                .newInstance();
662:                        excel2007HTMLTemplates = tFactory
663:                                .newTemplates(new StreamSource(xslFile));
664:                    }
665:                } catch (Exception e) {
666:                }
667:
668:                try {
669:                    powerpoint2007TextTransformationPath = appConfig
670:                            .getString("Previewer.PowerPoint2007TextTransformationPath");
671:                    File temp = new File(powerpoint2007TextTransformationPath);
672:
673:                    if (temp.exists()) {
674:                        TransformerFactory tFactory = TransformerFactory
675:                                .newInstance();
676:                        powerpoint2007TextTemplates = tFactory
677:                                .newTemplates(new StreamSource(temp));
678:                    } else {
679:                        java.net.URL url = null;
680:                        ClassLoader cl = this .getClass().getClassLoader();
681:                        url = cl.getResource("xsl/pptx2txt.xsl");
682:                        InputStream xslFile = url.openStream();
683:                        TransformerFactory tFactory = TransformerFactory
684:                                .newInstance();
685:                        powerpoint2007TextTemplates = tFactory
686:                                .newTemplates(new StreamSource(xslFile));
687:                    }
688:                } catch (Exception e) {
689:                }
690:
691:                try {
692:
693:                    powerpoint2007HTMLTransformationPath = appConfig
694:                            .getString("Previewer.PowerPoint2007HTMLTransformationPath");
695:                    File temp = new File(powerpoint2007HTMLTransformationPath);
696:
697:                    if (temp.exists()) {
698:                        TransformerFactory tFactory = TransformerFactory
699:                                .newInstance();
700:                        powerpoint2007HTMLTemplates = tFactory
701:                                .newTemplates(new StreamSource(temp));
702:                    } else {
703:                        java.net.URL url = null;
704:                        ClassLoader cl = this .getClass().getClassLoader();
705:                        url = cl.getResource("xsl/pptx2html.xsl");
706:                        InputStream xslFile = url.openStream();
707:                        TransformerFactory tFactory = TransformerFactory
708:                                .newInstance();
709:                        powerpoint2007HTMLTemplates = tFactory
710:                                .newTemplates(new StreamSource(xslFile));
711:                    }
712:                } catch (Exception e) {
713:                }
714:
715:                try {
716:                    showTranslateBar = appConfig.getString(
717:                            "Previewer.ToShowTranslateBar", "true");
718:                } catch (ConfigException e) {
719:                    showTranslateBar = "true";
720:                    //Previewer.logError("Previewer.PictureColorNumber application parameter isn't properly initialized!");
721:                }
722:
723:            }
724:
725:            public boolean requestPreprocessor(HttpPresentationComms comms)
726:                    throws Exception {
727:                return super .requestPreprocessor(comms);
728:            }
729:
730:            public synchronized void shutdown() {
731:                try {
732:                    if (reader != null) {
733:                        SiteList sl = SiteListFactory
734:                                .getSiteList("org.enhydra.snapperPreviewer.business.SiteListImpl");
735:                        sl.stopThread();
736:                        SiteList del = SiteListFactory
737:                                .getSiteList("org.enhydra.snapperPreviewer.business.DeleterImpl");
738:                        del.stopThread();
739:                        reader.interrupt();
740:                        reader = null;
741:                        deleter.interrupt();
742:                        deleter = null;
743:                    }
744:                } catch (Exception e) {
745:                }
746:                super .shutdown();
747:            }
748:
749:            public String toHtml() {
750:                return "This is <I>snapperPreviewer</I>";
751:            }
752:
753:            public static String getXslDirectory() {
754:                return xslDirectory;
755:            }
756:
757:            public static String getIndexDir() {
758:                return indexDir;
759:            }
760:
761:            public static String getOutputFileFormat() {
762:                return outputFileFormat;
763:            }
764:
765:            public static int getPictureColorNumber() {
766:                return pictureColorNumber;
767:            }
768:
769:            public static boolean getUseGrayFilter() {
770:                return useGrayFilter;
771:            }
772:
773:            public static boolean getPreviewFilesInContainer() {
774:                return filesInContainerPrev;
775:            }
776:
777:            public static int getPicturePixel() {
778:                return picturePixel;
779:            }
780:
781:            public static int getFilesInContainerNumber() {
782:                return filesInContainer;
783:            }
784:
785:            public static void logDebug(String message) {
786:                log.write(Logger.DEBUG, message);
787:            }
788:
789:            public static void logInfo(String message) {
790:                log.write(Logger.INFO, message);
791:            }
792:
793:            public static void logWarrning(String message) {
794:                log.write(Logger.WARNING, message);
795:            }
796:
797:            public static void logError(String message) {
798:                log.write(Logger.ERROR, message);
799:            }
800:
801:            public static boolean isRelitive() {
802:                return relative;
803:            }
804:
805:            public static Properties getConverterClassNames() {
806:                return converterClassNames;
807:            }
808:
809:            public static String pathOfConvertedFiles() {
810:                return pathOfConvertedFiles;
811:            }
812:
813:            public static String jbigConverterPath() {
814:                return JBIGConverterPath;
815:            }
816:
817:            public static boolean toReadConvertedFile() {
818:                return toReadConvertedFile;
819:            }
820:
821:            public static int getReReadConfigFilesEveryMinutes() {
822:                return reReadConfigFilesEveryMinutes;
823:            }
824:
825:            public static long getTimeToSleep() {
826:                return timeToSleep;
827:            }
828:
829:            public static String getWord2007HTMLTransformationPath() {
830:                return word2007HTMLTransformationPath;
831:            }
832:
833:            public static String getWord2007TextTransformationPath() {
834:                return word2007TextTransformationPath;
835:            }
836:
837:            public static String getExcel2007HTMLTransformationPath() {
838:                return excel2007HTMLTransformationPath;
839:            }
840:
841:            public static String getExcel2007TextTransformationPath() {
842:                return excel2007TextTransformationPath;
843:            }
844:
845:            public static String getPowerPoint2007HTMLTransformationPath() {
846:                return powerpoint2007HTMLTransformationPath;
847:            }
848:
849:            public static String getPowerPoint2007TextTransformationPath() {
850:                return powerpoint2007TextTransformationPath;
851:            }
852:
853:            public static long getTimeLimit() {
854:                return timeLimit;
855:            }
856:
857:            public static int getContainerFilesPreviewLimit() {
858:                return containerFilesPreviewLimit;
859:            }
860:
861:            public static void setContainerFilesPreviewLimit(
862:                    int containerFilesPreviewLimit) {
863:                Previewer.containerFilesPreviewLimit = containerFilesPreviewLimit;
864:            }
865:
866:            public static String getTranslatorConnectionString() {
867:                return translatorConnectionString;
868:            }
869:
870:            public static void setTranslatorConnectionString(
871:                    String translatorConnectionString) {
872:                Previewer.translatorConnectionString = translatorConnectionString;
873:            }
874:
875:            public static String getTranslatorContentEndString() {
876:                return translatorContentEndString;
877:            }
878:
879:            public static void setTranslatorContentEndString(
880:                    String translatorContentEndString) {
881:                Previewer.translatorContentEndString = translatorContentEndString;
882:            }
883:
884:            public static String getTranslatorContentStartString() {
885:                return translatorContentStartString;
886:            }
887:
888:            public static void setTranslatorContentStartString(
889:                    String translatorContentStartString) {
890:                Previewer.translatorContentStartString = translatorContentStartString;
891:            }
892:
893:            public static String getTranslatorContentString() {
894:                return translatorContentString;
895:            }
896:
897:            public static void setTranslatorContentString(
898:                    String translatorContentString) {
899:                Previewer.translatorContentString = translatorContentString;
900:            }
901:
902:            public static String getTranslatorLangpairString() {
903:                return translatorLangpairString;
904:            }
905:
906:            public static void setTranslatorLangpairString(
907:                    String translatorLangpairString) {
908:                Previewer.translatorLangpairString = translatorLangpairString;
909:            }
910:
911:            public static Templates getExcel2007HTMLTemplates() {
912:                return excel2007HTMLTemplates;
913:            }
914:
915:            public static void setExcel2007HTMLTemplates(
916:                    Templates excel2007HTMLTransformer) {
917:                Previewer.excel2007HTMLTemplates = excel2007HTMLTransformer;
918:            }
919:
920:            public static Templates getExcel2007TextTemplates() {
921:                return excel2007TextTemplates;
922:            }
923:
924:            public static void setExcel2007TextTemplates(
925:                    Templates excel2007TextTransformer) {
926:                Previewer.excel2007TextTemplates = excel2007TextTransformer;
927:            }
928:
929:            public static Templates getPowerpoint2007HTMLTemplates() {
930:                return powerpoint2007HTMLTemplates;
931:            }
932:
933:            public static void setPowerpoint2007HTMLTemplates(
934:                    Templates powerpoint2007HTMLTransformer) {
935:                Previewer.powerpoint2007HTMLTemplates = powerpoint2007HTMLTransformer;
936:            }
937:
938:            public static Templates getPowerpoint2007TextTemplates() {
939:                return powerpoint2007TextTemplates;
940:            }
941:
942:            public static void setPowerpoint2007TextTemplates(
943:                    Templates powerpoint2007TextTransformer) {
944:                Previewer.powerpoint2007TextTemplates = powerpoint2007TextTransformer;
945:            }
946:
947:            public static Templates getWord2007HTMLTemplates() {
948:                return word2007HTMLTemplates;
949:            }
950:
951:            public static void setWord2007HTMLTemplates(
952:                    Templates word2007HTMLTransformer) {
953:                Previewer.word2007HTMLTemplates = word2007HTMLTransformer;
954:            }
955:
956:            public static Templates getWord2007TextTemplates() {
957:                return word2007TextTemplates;
958:            }
959:
960:            public static void setWord2007TextTemplates(
961:                    Templates word2007TextTransformer) {
962:                Previewer.word2007TextTemplates = word2007TextTransformer;
963:            }
964:
965:            public static String toShowTranslateBar() {
966:                return showTranslateBar;
967:            }
968:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.