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


001:        package de.webman.content.eventhandler;
002:
003:        import com.teamkonzept.web.*;
004:        import com.teamkonzept.webman.*;
005:        import com.teamkonzept.webman.db.TKWebmanDBManager;
006:        import com.teamkonzept.webman.mainint.*;
007:        import com.teamkonzept.webman.mainint.db.*;
008:        import com.teamkonzept.webman.mainint.db.queries.*;
009:        import com.teamkonzept.webman.mainint.events.*;
010:        import com.teamkonzept.lib.*;
011:        import com.teamkonzept.field.*;
012:        import com.teamkonzept.field.db.*;
013:        import com.teamkonzept.db.*;
014:        import com.teamkonzept.publishing.markups.*;
015:        import org.apache.log4j.Category;
016:        import de.webman.acl.Policy;
017:        import java.sql.*;
018:        import java.io.*;
019:
020:        /**
021:         * Modifes either a new or an existing content.
022:         *
023:         * @author $Author: alex $
024:         * @version $Revision: 1.14.2.1 $
025:         */
026:        public class CEExtModifyHandler extends DefaultEventHandler implements 
027:                ParameterTypes, FrameConstants, DatabaseDefaults,
028:                QueryConstants {
029:
030:            /** for Logging */
031:            // private static Category cat = Category.getInstance(CEExtModifyHandler.class);
032:            /** Action command */
033:            static final String DELETE = "DELETE";
034:
035:            static final String EXT_MODIFY = "EXT_MODIFY";
036:            static final String TARGET = "TARGET";
037:            /** Action command */
038:            static final String UPLOAD = "UPLOAD";
039:
040:            static final String CE_EXT_MODIFY = "CE_EXT_MODIFY";
041:
042:            /**
043:             * The singleton instance.
044:             */
045:            private static final CEExtModifyHandler INSTANCE = new CEExtModifyHandler();
046:
047:            /**
048:             * Prevents outside instantiation.
049:             */
050:            private CEExtModifyHandler() {
051:                // NOP
052:            }
053:
054:            /**
055:             * Returns the singleton instance of this handler.
056:             */
057:            public static CEExtModifyHandler getInstance() {
058:                return INSTANCE;
059:            }
060:
061:            /**
062:             * Handles the specified event.
063:             *
064:             * @param evt the event to be handled.
065:             * @throws TKException if any error occurred during event handling.
066:             */
067:            public void handleEvent(TKEvent evt) throws TKException {
068:                try {
069:                    CEUtils.checkEvent(evt);
070:                    TKHashtable params = evt.getParams().getClass(PARAMETER);
071:
072:                    TKHTMLTemplate t;// = evt.getPrepHTMLTemplate( "ce_upload.tmpl" );
073:
074:                    ContentContext ceContext = new ContentContext(evt
075:                            .getParams(), evt.getName());
076:                    TKFormDBData data = new TKFormDBData(ceContext.formId
077:                            .intValue());
078:                    TKFormDBInterface.Get(data);
079:                    TKBaseField field = TKFieldRegistry.getFieldFromDB(data);
080:
081:                    String action = evt.getParameter(ACTION, EXT_MODIFY);
082:                    String target = evt.getParameter(TARGET, EXT_MODIFY);
083:                    //---- ACTION: SHOWFILE ----//
084:                    if (target == null || target.equals(""))
085:                        target = evt.getParameter(PARAMETER, TARGET);
086:
087:                    TKUploadField extField = (TKUploadField) field.getTarget(
088:                            target, "");
089:
090:                    if (action != null && action.equals(UPLOAD)) {
091:
092:                        t = evt.getPrepHTMLTemplate("ce_fields.tmpl");
093:                        // Content auf geändert setzten
094:                        t.set("CHANGED", new Integer(1));
095:                        TKUploadFileInputStream fileInputStr = ((TKUploadFileInputStream) params
096:                                .get(TKUploadField.GETFILENAMESTREAM));
097:                        File tmpFile = fileInputStr.file;
098:                        /* TKUploadField eventually modifies NEW_FILENAME */
099:                        String filename = evt.getParameter(PARAMETER,
100:                                TKUploadField.NEW_FILENAME);
101:                        if (filename == null || filename.equals("")) {
102:                            filename = extField
103:                                    .splitBrowserFileName(fileInputStr
104:                                            .getUploadFileName());
105:                        }
106:                        filename = TKUploadField.checkFileName(filename);
107:                        TKHashtable header = fileInputStr.getUploadHeader();
108:                        String contentType = TKUploadField
109:                                .fixContentType(header.get(
110:                                        TKUploadField.CONTENT_TYPE).toString());
111:
112:                        // Mimetype checken !
113:                        if (!extField.compareMimes(contentType)) {
114:                            Object[] args = { contentType };
115:                            throw new TKUserException(
116:                                    "Mime Typen matchen nicht",
117:                                    NOT_MATCHING_MIMETYPES, USER_SEVERITY,
118:                                    false, args, null);
119:                        }
120:
121:                        if (extField.isSaveInDB()) {
122:                            // save in DB
123:                            int newMediaID = MediaManager.storeMedia(tmpFile,
124:                                    filename);
125:                            params.put(target + "."
126:                                    + TKUploadField.NEW_MEDIA_ID, String
127:                                    .valueOf(newMediaID));
128:                            tmpFile.delete();
129:                        } else {
130:                            // Upload kommt ins Filesystem
131:                            extField
132:                                    .saveToFilesystem(params, tmpFile, filename);
133:                            t.set(TKUploadField.DOCUMENTS_FROM_FILESYSTEM,
134:                                    Boolean.TRUE);
135:                            params.remove(target + ".MEDIA_ID"); // falls sie vorher (Umschalten im Formular) da war
136:
137:                        }
138:
139:                        // delete the tempfile
140:                        fileInputStr.close();
141:
142:                        Object realData = field.compileData("", evt.getParams()
143:                                .getClass(PARAMETER), new TKHashtable());
144:
145:                        field.fillIntoTemplate(t, realData, "");
146:
147:                        extField.extModify(action, t, params, target);
148:
149:                    } else if (action != null && action.equals(DELETE)) {
150:                        t = evt.getPrepHTMLTemplate("ce_fields.tmpl");
151:
152:                        params.put(target + "."
153:                                + TKUploadField.MEDIA_ID_PARNAME, "");
154:                        params.put(target, ""); // Filneame
155:
156:                        Object realData = field.compileData("", evt.getParams()
157:                                .getClass(PARAMETER), new TKHashtable());
158:
159:                        field.fillIntoTemplate(t, realData, "");
160:
161:                    } else {
162:                        // for  actions: CANCEL, MODIFY,
163:                        t = evt.getPrepHTMLTemplate("ce_upload.tmpl");
164:                        extField.extModify(action, t, params, target);
165:                    }
166:                    CEUtils.keepCEContext(evt, t);
167:
168:                    WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t,
169:                            ContextConstants.CONTENT_EDIT,
170:                            Policy.CONTENT_TREE_ID, ceContext.conNodeId);
171:
172:                    evt.finishTemplate(t);
173:
174:                } catch (Throwable e) {
175:                    // TO DO : Analyze Exception !
176:                    throw WebmanExceptionHandler.getException(e);
177:                }
178:            }
179:
180:            /**
181:             * Checks wether this handler is capable to handle the specified event.
182:             *
183:             * @param evt the event to be handled.
184:             * @return <CODE>true</CODE> if this handler is capable to handle the
185:             * specified event, otherwise <CODE>false</CODE>.
186:             */
187:            public boolean isHandler(TKEvent evt) {
188:                return evt.getName().equalsIgnoreCase(CE_EXT_MODIFY);
189:            }
190:
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.