Source Code Cross Referenced for BaseConsoleServlet.java in  » Workflow-Engines » JFolder » org » jfolder » console » base » 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 » Workflow Engines » JFolder » org.jfolder.console.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
003:         *
004:         * Distributable under LGPL license.
005:         * See terms of license at gnu.org.
006:         */
007:
008:        package org.jfolder.console.base;
009:
010:        //base classes
011:        import java.io.IOException;
012:        import java.io.OutputStream;
013:        import java.io.PrintWriter;
014:        import java.lang.reflect.Modifier;
015:        import java.math.BigDecimal;
016:        import java.sql.Connection;
017:        import java.util.ArrayList;
018:        import java.util.HashMap;
019:        import java.util.Iterator;
020:        import javax.servlet.ServletException;
021:        import javax.servlet.http.HttpServlet;
022:        import javax.servlet.http.HttpServletRequest;
023:        import javax.servlet.http.HttpServletResponse;
024:
025:        //project specific classes
026:        import org.jfolder.common.UnexpectedSystemException;
027:        import org.jfolder.common.entity.SystemEntityUpdatesContext;
028:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
029:        import org.jfolder.common.tagging.ConceptTagPreferences;
030:        import org.jfolder.common.tagging.RootConceptTagHolder;
031:        import org.jfolder.common.tagging.StudioConceptTagCreParInfoContextHolder;
032:        import org.jfolder.common.tagging.StudioConceptTagUsabilityContext;
033:        import org.jfolder.common.utils.misc.MiscHelper;
034:        import org.jfolder.common.utils.web.ParameterHelper;
035:        import org.jfolder.common.utils.web.ParameterSet;
036:        import org.jfolder.common.web.template.ConsoleTemplateContext;
037:        import org.jfolder.common.web.template.ConsoleTemplateSession;
038:        import org.jfolder.common.web.template.PageSetupContext;
039:        import org.jfolder.common.web.template.SubmitActionContext;
040:        import org.jfolder.common.web.template.SubmitActionParameters;
041:        import org.jfolder.console.macro.ConsoleMacro;
042:        import org.jfolder.engines.call.GovernorCallHelper;
043:        import org.jfolder.platforms.servers.base.SystemServer;
044:        import org.jfolder.platforms.stores.base.SystemDatabase;
045:        import org.jfolder.platforms.stores.base.SystemStore;
046:        import org.jfolder.project.model.ProjectSystem;
047:        import org.jfolder.project.model.ProjectSystemUpdates;
048:        import org.jfolder.security.audit.SecurityAuditHelper;
049:        import org.jfolder.security.audit.SimpleSecurityAudit;
050:        import org.jfolder.security.lifecycle.SecurityLifecycle;
051:        import org.jfolder.security.lifecycle.SecurityLifecycleHelper;
052:        import org.jfolder.security.model.UserHolder;
053:        import org.jfolder.security.model.UserHolderContext;
054:        import org.jfolder.security.model.UserIdentity;
055:        import org.jfolder.services.project.ProjectService;
056:        import org.jfolder.services.project.ProjectServiceCallerFactory;
057:
058:        //other classes
059:
060:        public abstract class BaseConsoleServlet extends HttpServlet {
061:
062:            public BaseConsoleServlet() {
063:            }
064:
065:            protected boolean isLoginRequired() {
066:                return true;
067:            }
068:
069:            protected boolean checkBrowser(HttpServletRequest inRequest) {
070:                return true;
071:            }
072:
073:            protected boolean checkMethod(HttpServletRequest inRequest,
074:                    UserHolder inUser) {
075:
076:                boolean outValue = false;
077:
078:                boolean loginPage = inRequest.getRequestURI().equals(
079:                        ConsolePageParameters.SERVLET_CONSOLE);
080:
081:                String method = inRequest.getMethod().trim();
082:
083:                if (!loginPage) {
084:                    outValue = method.equalsIgnoreCase("POST");
085:                } else {
086:                    outValue = method.equalsIgnoreCase("POST")
087:                            || method.equalsIgnoreCase("GET");
088:                }
089:
090:                return outValue;
091:            }
092:
093:            protected boolean checkProtocol(HttpServletRequest inRequest) {
094:                return true;
095:            }
096:
097:            protected boolean checkParameters(SubmitActionContext inSac) {
098:                return inSac.isValid();
099:            }
100:
101:            protected abstract boolean checkAccess(ConsolePageSession inCps)
102:                    throws IOException, ServletException;
103:
104:            protected boolean checkSequenceCode(SubmitActionContext inSac,
105:                    String inSequenceCode) {
106:
107:                return (inSequenceCode.equals(inSac.getSequenceCode()));
108:            }
109:
110:            public void service(HttpServletRequest inRequest,
111:                    HttpServletResponse inResponse) throws IOException,
112:                    ServletException {
113:
114:                //
115:                boolean loginPage = inRequest.getRequestURI().equals(
116:                        ConsolePageParameters.SERVLET_CONSOLE);
117:                //
118:                if (!SystemStore.isInitialized()) {
119:                    if (!loginPage) {
120:                        inResponse
121:                                .sendRedirect(ConsolePageParameters.SERVLET_CONSOLE);
122:                    } else {
123:                        ParameterSet ps = ParameterHelper
124:                                .getParameterSet(inRequest);
125:                        SubmitActionContext sac = SubmitActionContext
126:                                .newInstance(ps);
127:                        if (sac
128:                                .isAction(SubmitActionParameters.CONFIGURE_SYSTEM)) {
129:
130:                            //
131:                            String database = ps
132:                                    .getParameter(SystemSetupContext.DATABASE);
133:                            String databaseClass = ps
134:                                    .getParameter(SystemSetupContext.DATABASE_CLASS);
135:                            String appServer = ps
136:                                    .getParameter(SystemSetupContext.APPLICATION_SERVER);
137:                            String appServerClass = ps
138:                                    .getParameter(SystemSetupContext.APPLICATION_SERVER_CLASS);
139:                            String sessionLocation = ps
140:                                    .getParameter(SystemSetupContext.SESSION_LOCATION);
141:                            String wrongDeploys = ps
142:                                    .getParameter(SystemSetupContext.WRONG_DEPLOYS);
143:                            String adminContextPath = ps
144:                                    .getParameter(SystemSetupContext.ADMIN_CONTEXT_PATH);
145:                            String machOfOrig = ps
146:                                    .getParameter(SystemSetupContext.MACH_OF_ORIG);
147:                            String permDir = ps
148:                                    .getParameter(SystemSetupContext.PERM_DIR);
149:                            String configReset = ps
150:                                    .getParameter(SystemSetupContext.CONFIG_RESET);
151:                            String understand = ps
152:                                    .getParameter(SystemSetupContext.UNDERSTAND);
153:
154:                            //
155:                            String actualDatabaseClassName = database;
156:                            if (database.equals(SubmitActionParameters.BLANK)) {
157:                                actualDatabaseClassName = databaseClass;
158:                            }
159:
160:                            //
161:                            String actualAppServerClassName = appServer;
162:                            if (appServer.equals(SubmitActionParameters.BLANK)) {
163:                                actualAppServerClassName = appServerClass;
164:                            }
165:
166:                            //
167:                            Class actualDatabaseClass = MiscHelper
168:                                    .getClassByName(actualDatabaseClassName,
169:                                            false);
170:
171:                            //
172:                            Class actualAppServerClass = MiscHelper
173:                                    .getClassByName(actualAppServerClassName,
174:                                            false);
175:
176:                            //
177:                            boolean correctDatabase = false;
178:                            boolean correctAppServer = false;
179:                            //
180:                            if (understand
181:                                    .equals(SubmitActionParameters.I_ACCEPT)
182:                                    && actualDatabaseClass != null
183:                                    && actualAppServerClass != null) {
184:
185:                                //
186:                                correctDatabase = SystemStore.class
187:                                        .isAssignableFrom(actualDatabaseClass)
188:                                        && ((actualDatabaseClass.getModifiers() & Modifier.ABSTRACT) == 0);
189:                                //
190:                                correctAppServer = SystemServer.class
191:                                        .isAssignableFrom(actualAppServerClass)
192:                                        && ((actualAppServerClass
193:                                                .getModifiers() & Modifier.ABSTRACT) == 0);
194:
195:                            }
196:                            //
197:                            if (correctDatabase && correctAppServer) {
198:
199:                                //
200:                                Object o = MiscHelper
201:                                        .newInstance(actualDatabaseClass);
202:                                SystemStore ws = (SystemStore) o;
203:                                SystemDatabase wd = SystemDatabase
204:                                        .newInstance();
205:
206:                                //
207:                                Connection conn = SystemStore.getConnection(ws);
208:
209:                                //
210:                                wd.dropAllEntities(conn, ws);
211:
212:                                //
213:                                wd.createAllEntities(conn, ws);
214:
215:                                //
216:                                SystemStore
217:                                        .createSystemEntry(wd, ws, conn,
218:                                                actualDatabaseClassName,
219:                                                actualAppServerClassName,
220:                                                sessionLocation, wrongDeploys,
221:                                                adminContextPath, machOfOrig,
222:                                                permDir,
223:                                                new BigDecimal(MiscHelper
224:                                                        .currentUTC()),
225:                                                (new Boolean(configReset))
226:                                                        .booleanValue());
227:
228:                                //
229:                                ws.commit(conn);
230:                                SystemStore.closeSQLObjects(conn, null, null);
231:
232:                                //
233:                                SystemStore.initialize();
234:
235:                                //
236:                                inResponse
237:                                        .sendRedirect(ConsolePageParameters.SERVLET_CONSOLE);
238:                            } else {
239:                                renderConsolePageContext(inResponse,
240:                                        new SystemSetupContext(), null,
241:                                        PageSetupContext.newPageSetupContext());
242:                            }
243:                        } else {
244:                            renderConsolePageContext(inResponse,
245:                                    new SystemSetupContext(), null,
246:                                    PageSetupContext.newPageSetupContext());
247:                        }
248:                    }
249:                } else if (!SystemStore.isCorrectlyInitialized()) {
250:                    throw new UnexpectedSystemException(
251:                            "Data Store Not Available");
252:                } else {
253:                    generalService(inRequest, inResponse);
254:                }
255:            }
256:
257:            private void generalService(HttpServletRequest inRequest,
258:                    HttpServletResponse inResponse) throws IOException,
259:                    ServletException {
260:
261:                ParameterSet ps = ParameterHelper.getParameterSet(inRequest);
262:                SecurityLifecycle uaaac = SecurityLifecycleHelper
263:                        .getSecurityLifecycle();
264:                UserHolderContext uhc = SecurityLifecycleHelper
265:                        .getUserHolderContext(inRequest, ps);
266:
267:                UserHolder user = uaaac.getUser(uhc);
268:                UserIdentity userId = user.getUserIdentity();
269:                SubmitActionContext sac = SubmitActionContext.newInstance(ps);
270:
271:                boolean loginPage = inRequest.getRequestURI().equals(
272:                        ConsolePageParameters.SERVLET_CONSOLE);
273:
274:                //MiscHelper.println("loginPage = " + loginPage);
275:                //MiscHelper.println("loginRequired = " + isLoginRequired());
276:                //MiscHelper.println("user.isValid() = " + user.isValid());
277:
278:                if (!checkBrowser(inRequest)) {
279:                    throw new UnexpectedSystemException(
280:                            "checkBrowser false not implemented");
281:                } else if (!checkMethod(inRequest, user)) {
282:                    throw new UnexpectedSystemException(
283:                            "checkMethod false not implemented");
284:                } else if (!checkProtocol(inRequest)) {
285:                    throw new UnexpectedSystemException(
286:                            "checkProtocol false not implemented");
287:                } else if ((!userId.isValid() || userId.isAnonymous())
288:                        && isLoginRequired()) {
289:
290:                    if (!loginPage) {
291:                        //MiscHelper.println("Login failed, going to console page");
292:                        inResponse
293:                                .sendRedirect(ConsolePageParameters.SERVLET_CONSOLE);
294:                    } else {
295:
296:                        //if (WorkflowStore.isInitialized()) {
297:
298:                        //MiscHelper.println("<!-------------------------------->");
299:                        //SystemDatabase wd = SystemDatabase.newInstance();
300:                        //
301:                        //SelectStatement wss =
302:                        //    SelectStatement.createOrderByColumn(
303:                        //        SystemDatabase.C_VERSION_T_SYSTEM,
304:                        //        wd.createSystemTable(), null);
305:                        //
306:                        //wss.addSelectColumn(
307:                        //    WorkflowDatabase.C_VERSION_T_SYSTEM,
308:                        //    wd.createSystemTable());
309:                        //
310:                        //SystemStore ws = SystemStore.getSystemStore();
311:                        //
312:                        //Connection conn = null;
313:                        //try {
314:                        //    conn = SystemStore.getConnection(ws);
315:                        //    ws.execute(wss, conn);
316:                        //    MiscHelper.println(
317:                        //        "VERSION = " + wss.getResults().getDecimal(0,0));
318:                        //}
319:                        //finally {
320:                        //    SystemStore.closeSQLObjects(conn, null, null);
321:                        //}
322:                        //
323:                        //MiscHelper.println("<!-------------------------------->");
324:
325:                        ConsoleTemplateContext ctc = uaaac.getFailedLoginPage(
326:                                inRequest, ps, sac, user);
327:                        renderConsolePageContext(inResponse, ctc, null,
328:                                PageSetupContext.newPageSetupContext());
329:                        //}
330:                        //throw new UnexpectedSystemException(
331:                        //    "LoginPage not implemented");
332:                    }
333:                }
334:                //else if (!checkAccess(user)) {
335:                //    throw new UnexpectedSystemException(
336:                //        "checkAccess false not implemented");
337:                //}
338:                else if (userId.isValid() && !checkParameters(sac)) {
339:                    throw new UnexpectedSystemException(
340:                            "checkParameters false not implemented");
341:                } else {
342:                    ConsolePageSession localCps = ConsolePageSessionFactory
343:                            .getConsoleSession(inRequest, user);
344:                    if (checkAccess(localCps)) {
345:                        synchronized (localCps) {
346:                            //
347:                            //
348:                            PageSetupContext psc = localCps
349:                                    .getPageSetupContext();
350:                            psc.resetForReuse();
351:                            //
352:                            //
353:                            String sequenceCode = localCps
354:                                    .getCurrentSequenceCode();
355:                            //MiscHelper.println("sequenceCode = "
356:                            //    + sac.getSequenceCode());
357:                            if (ps
358:                                    .isParameterPresent(SubmitActionContext.RECORDER)
359:                                    && ps
360:                                            .isParameterPresent(SubmitActionContext.TREE_STATE)
361:                                    && localCps.isRecordingMacroState()) {
362:                                //
363:                                ConsoleMacro cm = localCps
364:                                        .getCurrentMacroAsMacro();
365:                                cm
366:                                        .processRecordCommands(
367:                                                ps
368:                                                        .getParameter(SubmitActionContext.RECORDER),
369:                                                ps
370:                                                        .getParameter(SubmitActionContext.FROM_HANDLE),
371:                                                ps
372:                                                        .getParameter(SubmitActionContext.ALIAS_FROM_HANDLE),
373:                                                ps
374:                                                        .getParameter(SubmitActionContext.FROM_PAGE),
375:                                                ps
376:                                                        .getParameter(SubmitActionContext.GO_TO_PAGE));//,
377:                                //ps.getParameter(
378:                                //    SubmitActionContext.ORIG_TREE_STATE));
379:                            }
380:                            //MiscHelper.println("recorder = "
381:                            //    + ps.getParameter(SubmitActionContext.RECORDER));
382:                            if (!localCps.isCurrentConsolePagePresent()
383:                                    || checkSequenceCode(sac, sequenceCode)) {
384:
385:                                if (ps
386:                                        .isParameterPresent(SubmitActionContext.TREE_STATE)
387:                                        && ps
388:                                                .isParameterPresent(SubmitActionContext.SUB_SECTION_POSITION)) {
389:                                    //
390:                                    String aliasFromHandle = ps
391:                                            .getParameter(SubmitActionContext.ALIAS_FROM_HANDLE);
392:                                    if (!aliasFromHandle
393:                                            .equals(SubmitActionContext.NULL_HANDLE)) {
394:                                        //
395:                                        ConsolePageContext fromCpc = localCps
396:                                                .getConsolePageContext(aliasFromHandle);
397:                                        //if (!localCps.isReplayingMacroState()) {
398:                                        fromCpc
399:                                                .setTreeState(ps
400:                                                        .getParameter(SubmitActionContext.TREE_STATE));
401:                                        //}
402:                                        //MiscHelper.println("ps.treeState = "
403:                                        //    + ps.getParameter(
404:                                        //        SubmitActionContext.TREE_STATE));
405:                                        //
406:                                        fromCpc
407:                                                .setSubSectionPosition(ps
408:                                                        .getParameter(SubmitActionContext.SUB_SECTION_POSITION));
409:                                    }
410:                                }
411:
412:                                //
413:                                //
414:                                if (localCps.isReplayingMacroState()) {
415:                                    ConsoleMacro cm = localCps
416:                                            .getCurrentMacroAsMacro();
417:                                    //if (!cm.isDoneRunning()) {
418:                                    cm.initializeParameters(ps);
419:                                    //cm.preIncrementCommand(
420:                                    //    localCps.getCurrentApplicationRootHolder());
421:                                    //}
422:                                }
423:                                //
424:                                //
425:                                ConsolePageContext cpc = process(localCps,
426:                                        user, ps, sac);
427:                                //
428:                                if (localCps.isReplayingMacroState()) {
429:                                    ConsoleMacro cm = localCps
430:                                            .getCurrentMacroAsMacro();
431:                                    cm.preIncrementCommand(localCps
432:                                            .getCurrentApplicationRootHolder());
433:                                }
434:                                //
435:                                //String nonMacroTreeState = cpc.getTreeState();
436:
437:                                //
438:                                if (localCps.isReplayingMacroState()) {
439:                                    ConsoleMacro cm = localCps
440:                                            .getCurrentMacroAsMacro();
441:                                    if (cm.isDoneRunning()) {
442:                                        psc.setReplayMode(false);
443:                                        psc.setFirstReplayMessage(false);
444:                                        psc.setCurrentReplayCommand(0);
445:                                        psc.setTotalReplayCommands(0);
446:                                        //
447:                                        localCps.setMacroStateAsInactive();
448:                                    }
449:                                    //else {
450:                                    //    psc.setReplayMode(true);
451:                                    //    psc.setFirstReplayMessage(!cm.isMacroReset());
452:                                    //    psc.setCurrentReplayCommand(
453:                                    //        cm.getCurrentIndex());
454:                                    //    psc.setTotalReplayCommands(
455:                                    //        cm.getMacroCommandCount());
456:                                    //    //
457:                                    //    ConsoleMacro localCm =
458:                                    //        localCps.getCurrentMacroAsMacro();
459:                                    //    cpc.setTreeState(localCm.getTreeState());
460:                                    //    //
461:                                    //    cm.generateMacroCommands(
462:                                    //        psc, localCps, null, null, null, null);
463:                                    //    cm.incrementCommand();
464:                                    //}
465:                                } else {
466:                                    //PageSetupContext psc = cs.getPageSetupContext();
467:                                    psc.setReplayMode(false);
468:                                    psc.setFirstReplayMessage(false);
469:                                    psc.setCurrentReplayCommand(0);
470:                                    psc.setTotalReplayCommands(0);
471:                                }
472:
473:                                //if (cs.isReplayingMacroState()) {
474:                                //}
475:                                //String handle = cpc.getHandle();
476:                                //if (!handle.equals(ConsolePageContext.NULL_HANDLE)) {
477:                                //    if (!cs.isConsolePageContextPresent(handle)) {
478:                                //        cs.registerConsolePageContext(handle, cpc);
479:                                //    }
480:                                //}
481:                                //
482:                                if (cpc.isOutputText()) {
483:                                    localCps.incrementCurrentSequenceCode();
484:                                    localCps.setCurrentConsolePage(inRequest
485:                                            .getRequestURI());
486:                                }
487:                                //
488:                                //
489:                                //
490:                                localCps.prepareConsolePageContentUsage();
491:                                renderConsolePageContext(inResponse, cpc,
492:                                        localCps, localCps
493:                                                .getPageSetupContext());
494:                                localCps.commitConsolePageContentUsage();
495:
496:                                //if (cs.isReplayingMacroState()) {
497:                                //    cpc.setTreeState(nonMacroTreeState);
498:                                //}
499:                            } else {
500:                                ConsolePageContext cpc = ContinueSessionConsolePageContext
501:                                        .newInstance(localCps);
502:                                localCps.prepareConsolePageContentUsage();
503:                                renderConsolePageContext(inResponse, cpc,
504:                                        localCps, localCps
505:                                                .getPageSetupContext());
506:                                localCps.commitConsolePageContentUsage();
507:                                //throw new UnexpectedSystemException(
508:                                //    "Back protection not implemented");
509:                            }
510:                            //
511:                            //
512:                            //
513:                            //
514:                            MiscHelper.profileMemory();
515:                            //
516:                            //
517:                            if (localCps.getCurrentApplicationRootHolder() != null) {
518:                                //
519:                                RootConceptTagHolder localRcth = localCps
520:                                        .getCurrentApplicationRootHolder();
521:                                //
522:                                //
523:                                ConceptTagPreferences localCtp = localRcth
524:                                        .getPreferences();
525:                                StudioConceptTagCreParInfoContextHolder localScpch = localCtp
526:                                        .getCreationParameters();
527:                                StudioConceptTagUsabilityContext localSctuc = localCps
528:                                        .getStudioUsability();
529:                                //
530:                                MiscHelper
531:                                        .writeMessage(
532:                                                this ,
533:                                                "Concept Tag Selector Count = "
534:                                                        + localSctuc
535:                                                                .getConceptTagSelectorCount());
536:                                MiscHelper
537:                                        .writeMessage(
538:                                                this ,
539:                                                "Constraint Sac Count = "
540:                                                        + localSctuc
541:                                                                .getConstraintSacCount());
542:                                MiscHelper
543:                                        .writeMessage(
544:                                                this ,
545:                                                "Creation Parameter Count = "
546:                                                        + localScpch
547:                                                                .getCreationParameterContextCount());
548:                                MiscHelper
549:                                        .writeMessage(
550:                                                this ,
551:                                                "Web Page View Pop Up Count = "
552:                                                        + psc
553:                                                                .getWebPageViewPopUpCount());
554:                                MiscHelper.writeMessage(this ,
555:                                        "ConsolePageSession = " + localCps);
556:                                //
557:                                //MiscHelper.println("BaseConsoleServlet remove cpcs");
558:                                //MiscHelper.println("BaseConsoleServlet remove cpcs");
559:                                //MiscHelper.println("BaseConsoleServlet remove cpcs");
560:                                //MiscHelper.println("BaseConsoleServlet remove cpcs");
561:                                //MiscHelper.println("BaseConsoleServlet remove cpcs");
562:                                //localCps.removeCachedConsolePageContextHandles();
563:                                //
564:                                //
565:                                //
566:                                //
567:                                //Runtime rt = Runtime.getRuntime();
568:                                //rt.gc();
569:                            }
570:                        }
571:                    } else {
572:                        throw new UnexpectedSystemException(
573:                                "checkAccess false not implemented");
574:                    }
575:                }
576:                //
577:            }
578:
579:            private void renderConsolePageContext(
580:                    HttpServletResponse inResponse,
581:                    ConsoleTemplateContext inCpc, ConsolePageSession inCps,
582:                    PageSetupContext inPsc) throws IOException {
583:
584:                try {
585:                    if (inCpc.isOutputText()) {
586:                        //
587:                        PrintWriter pw = inResponse.getWriter();
588:                        //
589:                        inCpc.prepareForReuse();
590:                        //
591:                        //
592:                        if (inCps != null && inCps.isReplayingMacroState()) {
593:                            //
594:                            ConsoleMacro localCm = inCps
595:                                    .getCurrentMacroAsMacro();
596:                            //
597:                            if (inCps.getCurrentApplicationRootHolder() != null) {
598:                                localCm
599:                                        .loadRcthConstraintBuilderIfPresent(
600:                                                inPsc,
601:                                                inCps
602:                                                        .getCurrentApplicationRootHolder());
603:                            }
604:                        }
605:                        //
606:                        //
607:                        inCpc.setMetaMode(true);
608:                        inCpc.createConsolePage(null, inPsc);
609:                        //
610:                        //
611:                        //
612:                        //
613:                        //
614:                        if (inCps != null && inCps.isReplayingMacroState()) {
615:                            ConsoleMacro localCm = inCps
616:                                    .getCurrentMacroAsMacro();
617:                            inPsc.setReplayMode(true);
618:                            inPsc
619:                                    .setFirstReplayMessage(!localCm
620:                                            .isMacroReset());
621:                            inPsc.setCurrentReplayCommand(localCm
622:                                    .getCurrentIndex());
623:                            inPsc.setTotalReplayCommands(localCm
624:                                    .getMacroCommandCount());
625:                            //
626:                            //ConsoleMacro localCm =
627:                            //    localCps.getCurrentMacroAsMacro();
628:                            //inCpc.setTreeState(localCm.getTreeState());
629:                            //
630:                            localCm.generateMacroCommands(inPsc, inCps, inCps
631:                                    .getCurrentApplicationRootHolder(), null,
632:                                    null, null, null, null);
633:                            localCm.postIncrementCommand(inCps
634:                                    .getCurrentApplicationRootHolder());
635:                        }
636:                        //
637:                        //
638:                        //
639:                        //
640:                        //
641:                        inCpc.considerDefaultSettings();
642:                        //
643:                        inCpc.setMetaMode(false);
644:                        inCpc.createConsolePage(pw, inPsc);
645:                        //
646:                        pw.flush();
647:                        pw.close();
648:                    } else {
649:                        String filename = inCpc.getOutputFileName();
650:                        String mimeType = inCpc.getMimeType();
651:                        if (filename != null) {
652:                            inResponse.setHeader("Content-Disposition",
653:                                    "filename=\"" + filename + "\"");
654:                        }
655:                        if (mimeType != null) {
656:                            inResponse.setContentType(mimeType);
657:                        }
658:                        //
659:                        OutputStream os = inResponse.getOutputStream();
660:                        byte content[] = inCpc.getBinaryContent();
661:                        os.write(content);
662:                        os.flush();
663:                        os.close();
664:                    }
665:                    //
666:                    inCpc.prepareForReuse();
667:                } catch (RuntimeException re) {
668:                    MiscHelper.writeMessage(this , re);
669:                    throw re;
670:                } catch (IOException ioe) {
671:                    MiscHelper.writeMessage(this , ioe);
672:                    throw ioe;
673:                }
674:            }
675:
676:            public abstract ConsolePageContext process(
677:                    ConsolePageSession inCps, UserHolder inUser,
678:                    ParameterSet inPs, SubmitActionContext inSac)
679:                    throws IOException, ServletException;
680:
681:            protected void saveProjectSystem(ProjectSystem inPs,
682:                    UserIdentity inUi) {
683:
684:                ProjectService projectService = ProjectServiceCallerFactory
685:                        .getProjectService();
686:                //
687:                //RootConceptTagHolder dummyRcth =
688:                //    GovernorCallHelper.createGovernorRequest("dummy", "dummy");
689:                //GovernorCall dummyGc =
690:                //    (GovernorCall)dummyRcth.getFirstChildConceptTag();
691:                //
692:                SystemEntityUpdatesContext seuc = SystemEntityUpdatesContext
693:                        .newInstance(null, true, GovernorCallHelper
694:                                .getLocalDummyCharacteristic(), 0);
695:                SimpleSecurityAudit ssa = SimpleSecurityAudit.newInstance(inUi,
696:                        new BigDecimal(0), "", MiscHelper
697:                                .fromTimeToString(MiscHelper.currentUTC()),
698:                        SecurityAuditHelper.SEVERITY_LEVEL__INFORMATION,
699:                        new HashMap(), new HashMap(), "", new BigDecimal(0),
700:                        new HashMap(), new HashMap(), "", false);
701:                ProjectSystemUpdates psu = inPs.getSystemEntityUpdates(seuc,
702:                        ssa);
703:                //
704:                //SystemEntityPropertiesUpdates sepu = psu.getPropertyUpdates();
705:                //DocumentFileSystemRootUpdates dsru = psu.getWebDocUpdates();
706:                //MiscHelper.println("ConScrSer,savProSys psu = " + psu.getVersion());
707:                //MiscHelper.println("ConScrSer,savProSys sepu = " + sepu.getVersion());
708:                //MiscHelper.println("ConScrSer,savProSys dsru = " + dsru.getVersion());
709:                //
710:                projectService.saveProjectSystem(psu);
711:            }
712:
713:            //protected final static ConceptTagInitializer getHandleConceptTagParent(
714:            //    RootConceptTagHolder inRcth, ConceptTagInitializer inCti,
715:            //    String inCode, StringBuffer inPrefix) {
716:            //    
717:            //    ConceptTagInitializer outValue = null;
718:            //    
719:            //    if (inPrefix.length() < inCode.length()) {
720:            //        //do nothing, already correct
721:            //        outValue = inCti;
722:            //    }
723:            //    else {
724:            //        ConceptTagPreferences ctp = inRcth.getConceptTagPreferences();
725:            //        String hc = ctp.getHandleConjunction();
726:            //        int lastIndex = inCode.lastIndexOf(hc);
727:            //        if (lastIndex != -1) {
728:            //            String parentCode = inCode.substring(0, lastIndex);
729:            //            inPrefix.delete(0, inPrefix.length());
730:            //            outValue = ConceptTagHelper.getNearestConceptTag(
731:            //                inRcth, parentCode, inPrefix);
732:            //        }
733:            //        else {
734:            //            throw new UnexpectedSystemException(
735:            //                "No parent for " + inCode);
736:            //        }
737:            //    }
738:            //    
739:            //    return outValue;
740:            //}
741:
742:            protected void accountForRcthTextChanges(ConsolePageSession inCps,
743:                    ParameterSet inPs) {
744:                //
745:                RootConceptTagHolder localRcth = inCps
746:                        .getCurrentApplicationRootHolder();
747:                ConceptTagPreferences localCtp = localRcth.getPreferences();
748:                //
749:                if (localRcth != null) {
750:                    //
751:                    HashMap studioEditInputMap = new HashMap();
752:                    HashMap studioEditInputOtherMap = new HashMap();
753:                    //
754:                    Iterator paramNames = inPs.getParameterNames();
755:                    while (paramNames.hasNext()) {
756:                        String nextParamNam = (String) paramNames.next();
757:                        //MiscHelper.println("BasConServ accFrtc " + nextParamNam);
758:                        String nextParamVal = inPs.getParameter(nextParamNam);
759:                        //
760:                        ArrayList nextParamHandle = MiscHelper.parseHandle(
761:                                nextParamNam,
762:                                ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR);
763:                        //
764:                        Integer studioEditInputIndex = null;
765:                        Integer studioEditInputOtherIndex = null;
766:                        Integer commonStudioIndex = null;
767:                        Integer lastComponentIndex = null;
768:                        for (int i = 0; i < nextParamHandle.size(); i++) {
769:                            String nextLinkPart = (String) nextParamHandle
770:                                    .get(i);
771:                            if (ConsoleTemplateSession
772:                                    .isToggleLinkStudioEditInput(nextLinkPart)) {
773:                                //
774:                                studioEditInputIndex = new Integer(i);
775:                                commonStudioIndex = studioEditInputIndex;
776:                                break;
777:                            } else if (ConsoleTemplateSession
778:                                    .isToggleLinkStudioEditInputOther(nextLinkPart)) {
779:                                //
780:                                studioEditInputOtherIndex = new Integer(i);
781:                                commonStudioIndex = studioEditInputOtherIndex;
782:                                break;
783:                            } else if (!ConsoleTemplateSession
784:                                    .isToggleLinkPartNormal(nextLinkPart)) {
785:                                //
786:                                lastComponentIndex = new Integer(i);
787:                            } else {
788:                                //
789:                            }
790:                        }
791:                        //
792:                        //
793:                        //
794:                        if (commonStudioIndex != null) {
795:                            //
796:                            //
797:                            //
798:                            ArrayList targetHandleList = new ArrayList();
799:                            for (int i = lastComponentIndex.intValue() + 1; i < commonStudioIndex
800:                                    .intValue(); i++) {
801:                                //
802:                                targetHandleList.add(nextParamHandle.get(i));
803:                            }
804:
805:                            //int childIndex = Integer.parseInt(
806:                            //    ((String)targetHandleList.get(
807:                            //        targetHandleList.size() - 1)));
808:                            //targetHandleList.remove(targetHandleList.size() - 1);
809:                            String fullHandle = MiscHelper.reassembleHandle(
810:                                    targetHandleList, localCtp
811:                                            .getHandleConjunction());
812:                            if (studioEditInputIndex != null) {
813:                                studioEditInputMap
814:                                        .put(fullHandle, nextParamVal);
815:                            } else if (studioEditInputOtherIndex != null) {
816:                                studioEditInputOtherMap.put(fullHandle,
817:                                        nextParamVal);
818:                            } else {
819:                                throw UnexpectedSystemException.unknownState();
820:                            }
821:                        }
822:                    }
823:                    //
824:                    //
825:                    //
826:                    Iterator handleIter = studioEditInputMap.keySet()
827:                            .iterator();
828:                    while (handleIter.hasNext()) {
829:                        String nextHandle = (String) handleIter.next();
830:                        //
831:                        int lastHc = nextHandle.lastIndexOf(localCtp
832:                                .getHandleConjunction());
833:                        int childIndex = Integer.parseInt(nextHandle
834:                                .substring(lastHc + 1));
835:                        String nextParentHandle = nextHandle.substring(0,
836:                                lastHc);
837:                        //
838:                        String nextHandleValue = (String) studioEditInputMap
839:                                .get(nextHandle);
840:                        if (studioEditInputOtherMap.containsKey(nextHandle)) {
841:                            String nextHandleOtherValue = (String) studioEditInputOtherMap
842:                                    .get(nextHandle);
843:                            if (nextHandleValue
844:                                    .startsWith(ConsoleTemplateContext.DIRECT_TEXT_PREFIX)) {
845:                                //
846:                                nextHandleValue = nextHandleValue
847:                                        .substring(ConsoleTemplateContext.DIRECT_TEXT_PREFIX
848:                                                .length());
849:                                ConceptTagCharacteristic nextCtchar = localRcth
850:                                        .getCharacteristic(nextParentHandle);
851:                                if (!nextCtchar.getValueAsString(childIndex,
852:                                        null).equals(nextHandleValue)) {
853:                                    //
854:                                    nextCtchar.replaceValueAndRemoveLocalFiles(
855:                                            childIndex, nextHandleValue);
856:                                }
857:                            } else if (nextHandleValue
858:                                    .startsWith(ConsoleTemplateContext.OTHER_TEXT_PREFIX)) {
859:                                //
860:                                ConceptTagCharacteristic nextCtchar = localRcth
861:                                        .getCharacteristic(nextParentHandle);
862:                                if (!nextCtchar.getValueAsString(childIndex,
863:                                        null).equals(nextHandleOtherValue)) {
864:                                    //
865:                                    nextCtchar.replaceValueAndRemoveLocalFiles(
866:                                            childIndex, nextHandleOtherValue);
867:                                }
868:                            } else {
869:                                throw UnexpectedSystemException.unknownState();
870:                            }
871:                        } else {
872:                            ConceptTagCharacteristic nextCtchar = localRcth
873:                                    .getCharacteristic(nextParentHandle);
874:                            if (!nextCtchar.getValueAsString(childIndex, null)
875:                                    .equals(nextHandleValue)) {
876:                                //
877:                                nextCtchar.replaceValueAndRemoveLocalFiles(
878:                                        childIndex, nextHandleValue);
879:                            }
880:                        }
881:
882:                    }
883:                } else {
884:                    throw UnexpectedSystemException.unknownState();
885:                }
886:            }
887:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.