Source Code Cross Referenced for TEUtils.java in  » Content-Management-System » webman » de » webman » template » eventhandler » 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 » Content Management System » webman » de.webman.template.eventhandler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.webman.template.eventhandler;
002:
003:        import java.io.*;
004:        import java.sql.*;
005:        import com.teamkonzept.db.*;
006:        import com.teamkonzept.webman.WebManEvent;
007:        import com.teamkonzept.lib.*;
008:        import com.teamkonzept.lib.templates.*;
009:        import com.teamkonzept.webman.mainint.events.*;
010:        import com.teamkonzept.webman.mainint.*;
011:        import com.teamkonzept.web.*;
012:        import com.oroinc.text.regex.*;
013:        import com.teamkonzept.webman.mainint.db.queries.template.CheckTemplateDependency;
014:        import com.teamkonzept.webman.mainint.db.queries.template.CheckTemplateExists;
015:
016:        /**
017:         * Utility Klasse für die "TE-" -EventHandler
018:         *
019:         * @author  $Author: tina $
020:         * @version $Revision: 1.5 $
021:         */
022:        public class TEUtils implements  TemplateTypes, UserCodes,
023:                ParameterTypes {
024:            /**
025:             * Methode zum Anzeigen des Templatetextes.
026:             *
027:             * @param evt  über den Event werden die verschiedenen Parameter
028:             * 				wie TEMPLATE_NAME, etc. ausgewertet
029:             * @throws Throwable schiefgehen kann immer etwas
030:             * @throws FileNotFoundException im Falle das File existiert gar nicht
031:             * @return true einfach nur um zusagen das alles okay ist
032:             */
033:            public static boolean showSavedText(TKEvent evt) throws Throwable,
034:                    FileNotFoundException {
035:                try {
036:                    TKHTMLTemplate t = evt
037:                            .getPrepHTMLTemplate("te_editTmpl.tmpl");
038:                    String tmplName = evt.getParameter(PARAMETER,
039:                            "TEMPLATE_NAME");
040:                    String tmplId = evt.getParameter(PARAMETER, "TEMPLATE_ID");
041:                    t.set("TEMPLATE_NAME", tmplName);
042:                    t.set("TEMPLATE_ID", tmplId);
043:
044:                    // Text bekommen !!!
045:                    String s = TKTemplateCache
046:                            .getSource("file://"
047:                                    + evt.getHttpInterface().getDocumentRoot()
048:                                    + File.separator
049:                                    + TemplateUtils.getGenerationDirectory()
050:                                    + tmplName);
051:                    t.set("TEMPLATE_TEXT", s);
052:
053:                    WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t,
054:                            ContextConstants.TEMPLATES);
055:                    evt.finishTemplate(t);
056:                } catch (Throwable e) {
057:                    throw WebmanExceptionHandler.getException(e);
058:                }
059:                return true;
060:            }
061:
062:            /**
063:             * Methode prüft ob der eingegebene Templatename eine gültige Endung hat.
064:             *
065:             * @param name  der Name des Templates.
066:             * @throws TKException  warum weiß ich auch nicht.
067:             * @throws Throwable falls was schief geht
068:             * @return cName  Templatename
069:             */
070:            public static boolean isValidTemplateName(String name)
071:                    throws TKException, Throwable {
072:                try {
073:                    String cName = name.toUpperCase();
074:                    // hier noch auf Sonderzeichen pruefen !
075:                    isValidName(name);
076:                    return cName.endsWith(TK_TEMPLATE)
077:                            || cName.endsWith(JSP_TEMPLATE)
078:                            || cName.endsWith(XSLT_TEMPLATE);
079:                } catch (Throwable e) {
080:                    throw WebmanExceptionHandler.getException(e);
081:                }
082:            }
083:
084:            public static boolean isValidName(String name) throws Throwable {
085:                if (name == null || name.equals("")) {
086:                    // leer ist natuerlich auch nicht gut...
087:                    throw new TKUserException(
088:                            "Es muß ein Name angegeben werden", NO_PATHNAME,
089:                            USER_SEVERITY, true, null);
090:                }
091:
092:                PatternMatcher matcher = TKReg.getMatcher();
093:                PatternCompiler compiler = TKReg.getCompiler();
094:                Pattern patNotAllowed;
095:
096:                // nur wordcharacter (alphanumeric) fuer dirnamen: a-zA-Z_0-9 und das -
097:                // to DO :: Das paßt nicht zur Localisation !!!
098:                patNotAllowed = compiler.compile("[^a-zA-Z_0-9\\-./]");
099:                if (matcher.contains(name, patNotAllowed)) {
100:                    // kein gueltiger TemplateName
101:                    throw new TKUserException(
102:                            "Kein gültiger Pfadname: " + name,
103:                            NO_VALID_PATHNAME, USER_SEVERITY, true, null);
104:                } else {
105:                    return true;
106:                }
107:            }
108:
109:            /**
110:             * Diese Methode soll gucken ob es dieses Template (beim Neuanlegen) schon
111:             * gibt, und wenn ja den user informieren
112:             *
113:             * @param name  der zuüberprüfende Templatename 
114:             * @throws Throwable 
115:             * @return true  wenn der Templatename in der DB bereits existitert.
116:             *
117:             */
118:            public static boolean templateNameExists(String name)
119:                    throws Throwable {
120:                TKQuery q = TKDBManager.newQuery(CheckTemplateExists.class);
121:                q.setQueryParams("TEMPLATE_NAME", name);
122:                q.execute();
123:                ResultSet rs = q.fetchResultSet();
124:                if (rs.next()) {// Template exists
125:                    return true;
126:                } else {// Template doesn't exist
127:                    return false;
128:                }
129:            }
130:
131:            /** 
132:             * Methode checked die Abhängigkeiten des Templates vor dem Löschen 
133:             *
134:             * @param templateId  die ID des Templates, zur Identifizierung in
135:             * 		  der DB
136:             * @throws SQLException falls die ID nicht gefunden werden konnte
137:             * @return references  TKVector welcher die Abhängigkeiten enthält.
138:             */
139:            public static TKVector getDependencies(Integer templateId)
140:                    throws SQLException {
141:                TKVector references = new TKVector();
142:
143:                TKQuery q = TKDBManager.newQuery(CheckTemplateDependency.class);
144:                q.setQueryParams("TEMPLATE_ID", templateId);
145:                q.execute();
146:                ResultSet rs = q.fetchResultSet();
147:                while (rs.next()) {
148:                    TKHashtable temp = new TKHashtable();
149:                    String name = rs.getString("PRESENTATION_NAME");
150:                    temp.put("REF2", name);
151:                    references.addElement(temp);
152:                }
153:                return references;
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.