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


001:        package de.webman.duplication.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:
009:        import com.teamkonzept.webman.mainint.db.queries.*;
010:        import com.teamkonzept.webman.mainint.db.queries.duplication.*;
011:        import com.teamkonzept.webman.mainint.events.*;
012:        import com.teamkonzept.lib.*;
013:        import com.teamkonzept.db.*;
014:
015:        import java.sql.*;
016:        import java.io.*;
017:        import org.apache.log4j.Category;
018:
019:        /**
020:         *
021:         *
022:         *
023:         * @author  $Author: ralf $
024:         * @version $Revision: 1.4 $
025:         */
026:        public class DUMultiDuplicateHandler extends DefaultEventHandler
027:                implements  ParameterTypes, FrameConstants, DatabaseDefaults {
028:            /**
029:             * the log category
030:             */
031:            private static Category CAT = Category
032:                    .getInstance(DUMultiDuplicateHandler.class);
033:
034:            private DUMultiDuplicateHandler() {
035:            }
036:
037:            private static DUMultiDuplicateHandler instance = new DUMultiDuplicateHandler();
038:
039:            public static DUMultiDuplicateHandler getInstance() {
040:                return instance;
041:            }
042:
043:            public void handleEvent(TKEvent evt) throws TKException {
044:                try {
045:
046:                    TKParams params = evt.getParams();
047:
048:                    String numberOfCopiesString = params.get("PAR",
049:                            "NUMBER_OF_COPIES");
050:                    //String numberingDirection = params.get( "PAR", "NUM_DIRECTION" );
051:
052:                    if (numberOfCopiesString != null
053:                            && !numberOfCopiesString.equals("")) {
054:                        // Falls dieser Parameter nicht bereitgestellt wird, so wird nur einmal dupliziert
055:                        NameAssembler nameAssembler = new NameAssembler(params);
056:
057:                        Integer numberOfCopies = new Integer(
058:                                numberOfCopiesString);
059:                        for (int i = 0; i < numberOfCopies.intValue(); i++) {
060:
061:                            Integer[] newRootIDs = new Integer[2];
062:                            //doDuDuplicate((i == numberOfCopies.intValue() -1), newRootIDs);
063:                            //doDURenameDuplicates(i+1 , numberOfCopies, newRootIDs);
064:
065:                            DUDuplicateHandler.getInstance().doDuDuplicate(
066:                                    i == numberOfCopies.intValue() - 1,
067:                                    newRootIDs, evt);
068:                            String nameExtension = nameAssembler.assemble(i,
069:                                    null);
070:                            doDURenameDuplicates(nameExtension, newRootIDs, evt);
071:                            // note: this is a hack!!! oracle 9i throws an exception otherwise!
072:                            TKDBConnectionManager.getInstance()
073:                                    .closeConnection();
074:                        }
075:
076:                    } else {// Nur eine Kopie
077:                        DUDuplicateHandler.getInstance().doDuDuplicate(evt);
078:                    }
079:                } catch (Throwable e) {
080:                    // TO DO : Analyze Exception !
081:                    throw WebmanExceptionHandler.getException(e);
082:                }
083:            }
084:
085:            public boolean isHandler(TKEvent evt) {
086:                return evt.getName().equalsIgnoreCase("DU_MULTI_DUPLICATE");
087:            }
088:
089:            /** 
090:             * Umbenennt Knoten oder ganze Bäume
091:             * 	 
092:             * @param
093:             */
094:            //doDURenameDuplicates(int copyNr, Integer numOfCopies, Integer[] newRootIDs)
095:            public boolean doDURenameDuplicates(String nameExtension,
096:                    Integer[] newRootIDs, TKEvent evt) throws Throwable {
097:                TKParams params = evt.getParams();
098:
099:                //if(printwriter != null) printwriter.println("doDURenameDuplicates called with copyNr " + copyNr + " numOfCopies " + numOfCopies +
100:                //					" newRootIDs[0] " + newRootIDs[0] + " newRootIDs[1] "+newRootIDs[1] );
101:                Integer contentRoot = newRootIDs[0];
102:                Integer siteRoot = newRootIDs[1];
103:
104:                String extModeStr = params.get("PAR", "NAME_EXTENSION"); // NAME_EXTENSION: Nein (0) Ja (1) oder Recursiv (2) 
105:
106:                int extMode;
107:
108:                if (extModeStr == null || extModeStr.equals("")) {
109:                    extMode = 0;
110:                } else {
111:                    try {
112:                        extMode = (new Integer(extModeStr)).intValue();
113:                    } catch (NumberFormatException e) {
114:                        CAT
115:                                .warn(
116:                                        " Exception caught by DuplicateServlet.doDuMultiDuplicate() ",
117:                                        e);
118:                        extMode = 0;
119:                    }
120:                }
121:
122:                //		if(printwriter != null) printwriter.println(" nameExtension " + nameExtension);
123:                if (extMode == 2) {
124:                    if (contentRoot != null) {
125:                        //printwriter.println("doDURenameDuplicates contentRoot " + contentRoot);
126:                        TKQuery qContentRename = TKDBManager
127:                                .newQuery(TKDBContentTreeRenameRecursive.class);
128:                        qContentRename
129:                                .setQueryParams("NAME_EXT", nameExtension);
130:                        qContentRename.setQueryParams("ROOT_ID", contentRoot);
131:                        if (true) {
132:                            qContentRename
133:                                    .setQueryParams("POS", new Integer(1));
134:                            // Wenn dieser Queryparameter nicht geestzt ist, wird die Extension hinten angehangt
135:                        }
136:                        qContentRename.execute();
137:                        qContentRename.close();
138:                        //printwriter.println("TKDBContentTreeRenameRecursive executed witth  contentRoot " + contentRoot);
139:                    }
140:                    if (siteRoot != null) {// Auch im Sitetree  Recursives Umbenennen der neu erzeugten Knoten
141:                        TKQuery qSiteRename = TKDBManager
142:                                .newQuery(TKDBSiteTreeRenameRecursive.class);
143:                        qSiteRename.setQueryParams("NAME_EXT", nameExtension);
144:                        qSiteRename.setQueryParams("ROOT_ID", siteRoot);
145:                        if (true) {
146:                            qSiteRename.setQueryParams("POS", new Integer(1));
147:                            // Wenn dieser Queryparameter nicht geestzt ist, wird die Extension hinten angehangt
148:                        }
149:                        qSiteRename.execute();
150:                        qSiteRename.close();
151:                    }
152:                }
153:                if (extMode >= 1) {// Umbenennen der Roots der neuen Subtrees
154:
155:                    TKQuery TKDBContentNodeNameExtend = TKDBManager
156:                            .newQuery(TKDBContentNodeNameExtend.class);
157:                    TKDBContentNodeNameExtend.setQueryParams("NAME_EXT",
158:                            nameExtension);
159:                    TKDBContentNodeNameExtend.setQueryParams("CONTENT_NODE_ID",
160:                            contentRoot);
161:                    if (true) {
162:                        TKDBContentNodeNameExtend.setQueryParams("POS",
163:                                new Integer(1));
164:                        // Wenn dieser Queryparameter nicht geestzt ist, wird die Extension hinten angehangt
165:                    }
166:                    //TKLog.println("executing with nameExtension "+ nameExtension + " contentRoot " +  contentRoot +""+ TKDBContentNodeNameExtend);
167:
168:                    TKDBContentNodeNameExtend.execute();
169:                    //if(printwriter != null) printwriter.println("TKDBContentNodeNameExtend contentRoot " + contentRoot);
170:                    TKDBContentNodeNameExtend.close();
171:                    if (siteRoot != null) {
172:                        TKQuery TKDBSiteNodeNameExtend = TKDBManager
173:                                .newQuery(TKDBSiteNodeNameExtend.class);
174:                        TKDBSiteNodeNameExtend.setQueryParams("NAME_EXT",
175:                                nameExtension);
176:                        TKDBSiteNodeNameExtend.setQueryParams("SITE_NODE_ID",
177:                                siteRoot);
178:                        if (true) {
179:                            TKDBSiteNodeNameExtend.setQueryParams("POS",
180:                                    new Integer(1));
181:                            // Wenn dieser Queryparameter nicht geestzt ist, wird die Extension hinten angehangt
182:                        }
183:                        TKDBSiteNodeNameExtend.execute();
184:                        TKDBSiteNodeNameExtend.close();
185:                    }
186:                }
187:                return true;
188:            }
189:
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.