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


0001:        /*
0002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
0003:         *
0004:         * Distributable under LGPL license.
0005:         * See terms of license at gnu.org.
0006:         */
0007:
0008:        package org.jfolder.console.web.base;
0009:
0010:        //base classes
0011:        import java.io.IOException;
0012:        import java.io.OutputStream;
0013:        import java.util.ArrayList;
0014:        import java.util.HashMap;
0015:        import javax.servlet.ServletException;
0016:        import org.w3c.dom.Node;
0017:
0018:        //project specific classes
0019:        import org.jfolder.common.UnexpectedSystemException;
0020:        import org.jfolder.common.entity.SystemEntityTagHelper;
0021:        import org.jfolder.common.entity.SystemEntityUpdatesContext;
0022:        import org.jfolder.common.entity.properties.SystemEntityProperties;
0023:        import org.jfolder.common.files.BaseVirtualFileSystemHolder;
0024:        import org.jfolder.common.files.SimpleVirtualFileSystemProperties;
0025:        import org.jfolder.common.files.VirtualFileSystemDirectory;
0026:        import org.jfolder.common.files.VirtualFileSystemFile;
0027:        import org.jfolder.common.files.VirtualFileSystemHolder;
0028:        import org.jfolder.common.function.WebPageTagHelper;
0029:        import org.jfolder.common.function.WebPageTagPreferences;
0030:        import org.jfolder.common.tagging.ConceptRollupTag;
0031:        import org.jfolder.common.tagging.ConceptTag;
0032:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
0033:        import org.jfolder.common.tagging.ConceptTagMessageHolder;
0034:        import org.jfolder.common.tagging.ConceptTagPreferences;
0035:        import org.jfolder.common.tagging.ConceptTagSetContext;
0036:        import org.jfolder.common.tagging.RootConceptTagHolder;
0037:        import org.jfolder.common.utils.misc.MiscHelper;
0038:        import org.jfolder.common.utils.web.ParameterSet;
0039:        import org.jfolder.common.web.template.ConsoleParameterContext;
0040:        import org.jfolder.common.web.template.CreationResultParameterContext;
0041:        import org.jfolder.common.web.template.SubmitActionContext;
0042:        import org.jfolder.common.web.template.SubmitActionParameters;
0043:        import org.jfolder.console.base.BaseConsoleServlet;
0044:        import org.jfolder.console.base.ConsolePageContext;
0045:        import org.jfolder.console.base.ConsolePageMessageHolder;
0046:        import org.jfolder.console.base.ConsolePageSession;
0047:        import org.jfolder.console.base.NamesForParentCpc;
0048:        import org.jfolder.console.macro.ConsoleMacroTagHelper;
0049:        import org.jfolder.dms.model.v1.DocumentFileSystemRootTag;
0050:        import org.jfolder.engines.call.GovernorCall;
0051:        import org.jfolder.engines.call.GovernorCallHelper;
0052:        import org.jfolder.platforms.servers.base.SystemServer;
0053:        import org.jfolder.platforms.servers.base.SystemServerFactory;
0054:        import org.jfolder.platforms.stores.base.SystemStore;
0055:        import org.jfolder.project.model.ProjectSystem;
0056:        import org.jfolder.project.model.ProjectSystemHelper;
0057:        import org.jfolder.security.model.SimpleUserIdentity;
0058:        import org.jfolder.security.model.UserHolder;
0059:        import org.jfolder.security.model.UserIdentity;
0060:        import org.jfolder.services.config.ConfigService;
0061:        import org.jfolder.services.config.ConfigServiceCallerFactory;
0062:        import org.jfolder.services.dms.DMSServiceBean;
0063:        import org.jfolder.services.project.ProjectService;
0064:        import org.jfolder.services.project.ProjectServiceCallerFactory;
0065:
0066:        //other classes
0067:
0068:        public class ConsoleScreenServlet extends BaseConsoleServlet {
0069:
0070:            public ConsoleScreenServlet() {
0071:            }
0072:
0073:            //public void validateAccess(HttpServletRequest inRequest,
0074:            //    HttpServletResponse inResponse, UserHolder inUser)
0075:            //    throws IOException, ServletException {
0076:            //    
0077:            //    if (inUser.isValid()) {
0078:            //        process(inRequest, inResponse, inUser);
0079:            //    }
0080:            //    else {
0081:            //        RequestDispatcher rd = inRequest.getRequestDispatcher(
0082:            //            ConsolePageParameters.JSP_CONSOLE_PAGE_LOGIN_SCREEN);
0083:            //        rd.forward(inRequest, inResponse);
0084:            //    }
0085:            //}
0086:
0087:            protected boolean checkAccess(ConsolePageSession inCps)
0088:                    throws IOException, ServletException {
0089:
0090:                boolean outValue = false;
0091:
0092:                outValue = (inCps.isDeveloper() || inCps.isAdministrator());
0093:
0094:                return outValue;
0095:            }
0096:
0097:            //TO DO: validate login, make sure non-zero length username and password
0098:            //TO DO: enable ssl for the entire session
0099:            //TO DO: should I differentiate between a get and a post?
0100:            public ConsolePageContext process(ConsolePageSession inCps,
0101:                    UserHolder inUser, ParameterSet inPs,
0102:                    SubmitActionContext inSac) throws IOException,
0103:                    ServletException {
0104:
0105:                ConsolePageContext outValue = null;
0106:
0107:                //
0108:
0109:                outValue = ConsoleScreenContext.newInstance(inCps);
0110:
0111:                if (inSac.isAction(SubmitActionParameters.LOGIN)) {
0112:                    //MiscHelper.println("LOGIN action received");
0113:                    //MiscHelper.println("User = " + inUser.getName());
0114:                    //inCps.getMessageHolder().setInformationHeader("Welcome");
0115:                    //inCs.getMessageHolder().createSubMessage().setInformationHeader(
0116:                    //    "Welcome");
0117:                } else if (inSac.isAction(SubmitActionParameters.RESET_CONFIG)) {
0118:
0119:                    //throw UnexpectedSystemException.notImplemented();
0120:                    if (inCps.isAdministrator() && SystemStore.isConfigReset()) {
0121:                        ConfigService cs = ConfigServiceCallerFactory
0122:                                .getConfigService();
0123:                        cs.resetCurrentConfig();
0124:                    } else {
0125:                        inCps
0126:                                .getMessageHolder()
0127:                                .setWarningHeader(
0128:                                        "The system does not allow resetting of the configuration");
0129:                    }
0130:                } else if (inSac
0131:                        .isAction(SubmitActionParameters.START_RECORDING)) {
0132:                    inCps.setMacroStateAsRecording();
0133:                    inCps
0134:                            .setCurrentMacro(ConsoleMacroTagHelper
0135:                                    .getEmptyMacro());
0136:                    //throw UnexpectedSystemException.notImplemented();
0137:                } else if (inSac
0138:                        .isAction(SubmitActionParameters.STOP_RECORDING)) {
0139:                    //
0140:                    byte macroContent[] = ConceptRollupTag.getRollupFromList(
0141:                            inCps.getCurrentMacro(), null);
0142:                    OutputStream os = outValue.getOutputStream();
0143:                    os.write(macroContent, 0, macroContent.length);
0144:                    os.flush();
0145:                    os.close();
0146:                    //String appName = inSac.getFirstParameter();
0147:                    outValue.setOutputText(false);
0148:                    outValue.setOutputFileName(MiscHelper.literalReplace(
0149:                            "ConsoleMacro.zip", "/", "_"));
0150:                    outValue.setMimeType("application/download");
0151:                    //
0152:                    inCps.setMacroStateAsInactive();
0153:                    inCps.setCurrentMacro(null);
0154:                } else if (inSac
0155:                        .isAction(SubmitActionParameters.START_REPLAYING)) {
0156:                    //throw UnexpectedSystemException.notImplemented();
0157:                    //String uploadParameter = inSac.getParameter(inSac.FIRST_INPUT);
0158:                    //byte uploadContent[] = inPs.getParameterAsUpload(uploadParameter);
0159:                    //RootConceptTagHolder macroRcth =
0160:                    //    ConceptRollupTag.getRootHolderFromList(uploadContent);
0161:
0162:                    //
0163:                    String startDescription = null;
0164:                    String endDescription = null;
0165:                    //
0166:                    if (inSac.getParameter(ConsoleParameterContext.FIRST_INPUT)
0167:                            .length() > 0) {
0168:                        //
0169:                        startDescription = inSac
0170:                                .getParameter(ConsoleParameterContext.FIRST_INPUT);
0171:                    }
0172:                    //
0173:                    if (inSac
0174:                            .getParameter(ConsoleParameterContext.SECOND_INPUT)
0175:                            .length() > 0) {
0176:                        //
0177:                        endDescription = inSac
0178:                                .getParameter(ConsoleParameterContext.SECOND_INPUT);
0179:                    }
0180:                    //
0181:                    //String appToPreUndeploy = null;
0182:                    if (inSac.getParameter(ConsoleParameterContext.THIRD_INPUT)
0183:                            .length() > 0) {
0184:                        //
0185:                        String appToPreUndeploy = inSac
0186:                                .getParameter(ConsoleParameterContext.THIRD_INPUT);
0187:                        //
0188:                        if (startDescription == null) {
0189:                            deleteProjectSystemIfPresent(inCps,
0190:                                    SubmitActionParameters.USER,
0191:                                    appToPreUndeploy);
0192:                        }
0193:                        //
0194:                        if (endDescription == null) {
0195:                            deleteProjectSystemIfPresent(inCps,
0196:                                    SubmitActionParameters.SERVER,
0197:                                    appToPreUndeploy);
0198:                        }
0199:                        //
0200:                        //
0201:                        //
0202:                        if (inSac.getParameter(
0203:                                ConsoleParameterContext.FOURTH_INPUT).length() > 0) {
0204:                            //
0205:                            byte importPsContent[] = inPs
0206:                                    .getParameterAsUpload(inSac
0207:                                            .getParameter(ConsoleParameterContext.FOURTH_INPUT));
0208:                            //
0209:                            if (importPsContent != null) {
0210:                                //
0211:                                //
0212:                                RootConceptTagHolder importPsRcth = ConceptRollupTag
0213:                                        .getRootHolderFromList(importPsContent);
0214:                                //
0215:                                ConceptTag importPsCt = importPsRcth
0216:                                        .getFirstChildConceptTag();
0217:                                //
0218:                                deleteProjectSystemIfPresent(inCps,
0219:                                        SubmitActionParameters.USER,
0220:                                        appToPreUndeploy);
0221:                                createOrImportApplication(inCps,
0222:                                        SubmitActionParameters.USER,
0223:                                        appToPreUndeploy,
0224:                                        ((ProjectSystem) importPsCt));
0225:                                inCps.reloadProjectSystems();
0226:                            }
0227:                        }
0228:                        //
0229:                        //
0230:                        //
0231:                        //
0232:                        HashMap variables = new HashMap();
0233:                        variables.put(ConsoleMacroTagHelper.APPLICATION,
0234:                                appToPreUndeploy);
0235:                        //
0236:                        inCps.getCurrentMacroAsMacro().reset(startDescription,
0237:                                endDescription, variables);
0238:                        inCps
0239:                                .setMacroStateAsReplaying(inSac
0240:                                        .getParameter(ConsoleParameterContext.FIFTH_INPUT));
0241:                    } else {
0242:                        ConsolePageMessageHolder localCpmh = inCps
0243:                                .getMessageHolder();
0244:                        localCpmh.createSubMessage().setInformationHeader(
0245:                                "No Application Name Specified");
0246:                    }
0247:                    //
0248:                    //
0249:                    //
0250:                    //
0251:                    //
0252:                    //
0253:                    //inCps.setCurrentMacro(macroRcth);
0254:                } else if (inSac
0255:                        .isAction(SubmitActionParameters.STOP_REPLAYING)) {
0256:                    inCps.setMacroStateAsInactive();
0257:                    inCps.setCurrentMacro(null);
0258:                } else if (inSac.isAction(SubmitActionParameters.DO_NOTHING)) {
0259:                    //
0260:                    //
0261:                    //
0262:                    //
0263:                    //
0264:                    CreationResultParameterContext crpc = CreationResultParameterContext
0265:                            .newInstance(inPs);
0266:                    MiscHelper
0267:                            .println("ConScrServ 1 = "
0268:                                    + crpc
0269:                                            .getParameter(ConsoleParameterContext.FIRST_INPUT));
0270:                    MiscHelper
0271:                            .println("ConScrServ 2 = "
0272:                                    + crpc
0273:                                            .getParameter(ConsoleParameterContext.SECOND_INPUT));
0274:                } else if (inSac.isAction(SubmitActionParameters.CREATE,
0275:                        SubmitActionParameters.WEB_PAGE)) {
0276:                    //
0277:                    String appType = inSac
0278:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0279:                    String appName = inSac
0280:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0281:                    String dirName = inSac
0282:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0283:                    String webPage = inSac
0284:                            .getParameter(ConsoleParameterContext.FOURTH_INPUT);
0285:                    //MiscHelper.println("ConScrServ,appName = " + appName);
0286:                    //MiscHelper.println("ConScrServ,dirName = " + dirName);
0287:                    //MiscHelper.println("ConScrServ,webPage = " + webPage);
0288:                    //
0289:                    ProjectSystem ps = null;
0290:                    if (SubmitActionParameters.USER.equals(appType)) {
0291:                        ps = inCps.getUserProjectSystem(appName);
0292:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0293:                        ps = inCps.getServerProjectSystem(appName);
0294:                    } else {
0295:                        throw UnexpectedSystemException.unknownState();
0296:                    }
0297:                    //
0298:                    ArrayList subDirs = inCps.getWebDocsDirs(ps);
0299:                    //
0300:                    //
0301:                    if (!isFileAreaAvailable(subDirs, dirName, webPage, inCps)) {
0302:                        //
0303:                    } else {
0304:                        for (int i = 0; i < subDirs.size(); i++) {
0305:                            VirtualFileSystemHolder nextVsh = (VirtualFileSystemHolder) subDirs
0306:                                    .get(i);
0307:                            nextVsh.getOrCreateAbsoluteDirectory(dirName);
0308:                        }
0309:                        //VirtualFileSystemHolder webDocsVsh = ps.getWebDocs();
0310:                        VirtualFileSystemHolder targetWebDocsVsh = ps
0311:                                .getWebDocs().getOrCreateAbsoluteDirectory(
0312:                                        dirName);
0313:                        VirtualFileSystemHolder targetWebDocsPropertiesVsh = ps
0314:                                .getWebDocsProperties()
0315:                                .getOrCreateAbsoluteDirectory(dirName);
0316:                        //
0317:                        RootConceptTagHolder rcth = WebPageTagHelper
0318:                                .getRootHolder((Node) null,
0319:                                        ConceptTagSetContext.newInstance());
0320:                        byte fileContent[] = ConceptRollupTag
0321:                                .getRollupFromList(rcth, null);
0322:                        //
0323:                        targetWebDocsVsh.createFile(webPage, fileContent);
0324:                        SimpleVirtualFileSystemProperties targetProps = ps
0325:                                .getWebDocProperty(true, false, false, false,
0326:                                        false, null);
0327:                        targetWebDocsPropertiesVsh.createFile(webPage,
0328:                                targetProps.toByteArray());
0329:                        //
0330:                        UserIdentity ui = inCps.getUserHolder()
0331:                                .getUserIdentity();
0332:                        saveProjectSystem(ps, ui);
0333:                    }
0334:                }
0335:                //else if (inSac.isAction(SubmitActionParameters.UPLOAD,
0336:                //    SubmitActionParameters.WEB_FILE)) {
0337:                //    //
0338:                //    MiscHelper.println("ConScrServ REMOVE THIS TEST ACTION");
0339:                //    //
0340:                //    String fileParameterName = inSac.getParameter(inSac.FOURTH_INPUT);
0341:                //    byte fileContent[] = inPs.getParameterAsUpload(
0342:                //        fileParameterName);
0343:                //    String fileName = inPs.getUploadParameterName(
0344:                //        fileParameterName);
0345:                //    //
0346:                //    RootConceptTagHolder nextSourceRcth =
0347:                //        ConceptRollupTag.getRootHolderFromList(fileContent);
0348:                //    //
0349:                //    String s = SpecializedWebPageWriterHandler.reformatWebPage(
0350:                //        nextSourceRcth, false);
0351:                //    byte b[] = MiscHelper.fromStringToBytes(s);
0352:                //    //
0353:                //    OutputStream os = outValue.getOutputStream();
0354:                //    os.write(b, 0, b.length);
0355:                //    os.flush();
0356:                //    os.close();
0357:                //    //
0358:                //    outValue.setOutputText(false);
0359:                //    outValue.setOutputFileName("sample.txt");
0360:                //    outValue.setMimeType("text/plain");
0361:                //    
0362:                //}
0363:                else if (inSac.isAction(SubmitActionParameters.UPLOAD,
0364:                        SubmitActionParameters.WEB_FILE)) {
0365:                    //
0366:                    String appType = inSac
0367:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0368:                    String appName = inSac
0369:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0370:                    String directory = inSac
0371:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0372:                    String fileParameterName = inSac
0373:                            .getParameter(ConsoleParameterContext.FOURTH_INPUT);
0374:                    //
0375:                    ProjectSystem ps = null;
0376:                    if (SubmitActionParameters.USER.equals(appType)) {
0377:                        ps = inCps.getUserProjectSystem(appName);
0378:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0379:                        ps = inCps.getServerProjectSystem(appName);
0380:                    } else {
0381:                        throw UnexpectedSystemException.unknownState();
0382:                    }
0383:                    //
0384:                    //
0385:                    if (inPs.isParameterUpload(fileParameterName)) {
0386:                        byte fileContent[] = inPs
0387:                                .getParameterAsUpload(fileParameterName);
0388:                        String fileName = inPs
0389:                                .getUploadParameterName(fileParameterName);
0390:                        ArrayList subDirs = inCps.getWebDocsDirs(ps);
0391:                        //
0392:                        //
0393:                        if (!isFileAreaAvailable(subDirs, directory, fileName,
0394:                                inCps)) {
0395:                            //
0396:                        } else {
0397:                            for (int i = 0; i < subDirs.size(); i++) {
0398:                                VirtualFileSystemHolder nextVsh = (VirtualFileSystemHolder) subDirs
0399:                                        .get(i);
0400:                                nextVsh.getOrCreateAbsoluteDirectory(directory);
0401:                            }
0402:                            //VirtualFileSystemHolder fileVsh =
0403:                            //    projectSystem.getWebDocs();
0404:                            VirtualFileSystemHolder targetWebDocsVsh = ps
0405:                                    .getWebDocs().getOrCreateAbsoluteDirectory(
0406:                                            directory);
0407:                            VirtualFileSystemHolder targetWebDocsPropertiesVsh = ps
0408:                                    .getWebDocsProperties()
0409:                                    .getOrCreateAbsoluteDirectory(directory);
0410:                            //
0411:                            targetWebDocsVsh.createFile(fileName, fileContent);
0412:                            String fileMimeType = getServletContext()
0413:                                    .getMimeType(fileName);
0414:                            SimpleVirtualFileSystemProperties targetProps = ps
0415:                                    .getWebDocProperty(false, false,
0416:                                            fileMimeType.startsWith("text/"),
0417:                                            false, false, null);
0418:                            targetWebDocsPropertiesVsh.createFile(fileName,
0419:                                    targetProps.toByteArray());
0420:                            //
0421:                            UserIdentity ui = inCps.getUserHolder()
0422:                                    .getUserIdentity();
0423:                            saveProjectSystem(ps, ui);
0424:                        }
0425:                    }
0426:                } else if (inSac.isAction(SubmitActionParameters.DELETE,
0427:                        SubmitActionParameters.WEB_PAGE)
0428:                        || inSac.isAction(SubmitActionParameters.DELETE,
0429:                                SubmitActionParameters.WEB_FILE)) {
0430:                    //
0431:                    String appType = inSac
0432:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0433:                    String appName = inSac
0434:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0435:                    String dirName = inSac
0436:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0437:                    String file = inSac
0438:                            .getParameter(ConsoleParameterContext.FOURTH_INPUT);
0439:                    //
0440:                    ProjectSystem ps = null;
0441:                    if (SubmitActionParameters.USER.equals(appType)) {
0442:                        ps = inCps.getUserProjectSystem(appName);
0443:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0444:                        ps = inCps.getServerProjectSystem(appName);
0445:                    } else {
0446:                        throw UnexpectedSystemException.unknownState();
0447:                    }
0448:                    //
0449:                    VirtualFileSystemHolder webDocsDir = ps.getWebDocs()
0450:                            .getOrCreateAbsoluteDirectory(dirName);
0451:                    webDocsDir.removeFile(file);
0452:                    //
0453:                    VirtualFileSystemHolder webDocsPropertiesDir = ps
0454:                            .getWebDocsProperties()
0455:                            .getOrCreateAbsoluteDirectory(dirName);
0456:                    webDocsPropertiesDir.removeFile(file);
0457:                    //
0458:                    UserIdentity ui = inCps.getUserHolder().getUserIdentity();
0459:                    saveProjectSystem(ps, ui);
0460:                } else if (inSac.isAction(SubmitActionParameters.DELETE,
0461:                        SubmitActionParameters.DIRECTORY)) {
0462:                    //
0463:                    String appType = inSac
0464:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0465:                    String appName = inSac
0466:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0467:                    String dirName = inSac
0468:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0469:                    //
0470:                    ArrayList dirList = BaseVirtualFileSystemHolder
0471:                            .parseDirectoryName(dirName);
0472:                    String deleteDir = (String) dirList.get(dirList.size() - 1);
0473:                    dirList.remove(dirList.size() - 1);
0474:                    String parentDirName = BaseVirtualFileSystemHolder
0475:                            .parseDirectoryArray(dirList);
0476:                    //
0477:                    //
0478:                    ProjectSystem projectSystem = null;
0479:                    if (SubmitActionParameters.USER.equals(appType)) {
0480:                        projectSystem = inCps.getUserProjectSystem(appName);
0481:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0482:                        projectSystem = inCps.getServerProjectSystem(appName);
0483:                    } else {
0484:                        throw UnexpectedSystemException.unknownState();
0485:                    }
0486:                    //
0487:                    //
0488:                    ArrayList subDirs = inCps.getWebDocsDirs(projectSystem);
0489:                    //
0490:                    for (int i = 0; i < subDirs.size(); i++) {
0491:                        VirtualFileSystemHolder nextVsh = (VirtualFileSystemHolder) subDirs
0492:                                .get(i);
0493:                        VirtualFileSystemHolder parentDir = nextVsh
0494:                                .getOrCreateAbsoluteDirectory(parentDirName);
0495:                        if (parentDir.isDirectoryPresent(deleteDir)) {
0496:                            parentDir.removeDirectory(deleteDir);
0497:                        }
0498:                    }
0499:                    //
0500:                    UserIdentity ui = inCps.getUserHolder().getUserIdentity();
0501:                    saveProjectSystem(projectSystem, ui);
0502:                } else if (inSac.isAction(SubmitActionParameters.RETURN)) {
0503:                    //
0504:                    //
0505:                    //
0506:                    //
0507:                    System.gc();
0508:                    MiscHelper.writeMessage(this ,
0509:                            "About to remove from Cpc cache");
0510:                    MiscHelper.profileMemory();
0511:                    System.gc();
0512:                    //
0513:                    if (inCps.getCurrentApplicationWebDocType() != null
0514:                            && inCps.getCurrentApplicationWebDocType().equals(
0515:                                    SubmitActionParameters.WEB_PAGE)) {
0516:                        //
0517:                        //
0518:                        String localCpcHandle = NamesForParentCpc
0519:                                .getDevelopWebPageCpcName(inCps);
0520:                        if (inCps.isConsolePageContextPresent(localCpcHandle)) {
0521:                            //inCps.registerConsolePageContext(
0522:                            //    NamesForParentCpc.getDevelopWebPageCpcName(
0523:                            //        inCps), outValue);
0524:                            inCps.removeConsolePageContext(localCpcHandle);
0525:                        }
0526:                    }
0527:                    //
0528:                    System.gc();
0529:                    MiscHelper.writeMessage(this , "Removed Cpc from cache");
0530:                    MiscHelper.profileMemory();
0531:                    System.gc();
0532:                    //
0533:                    //
0534:                    inCps.setCurrentApplication(null, null, null, null, null,
0535:                            null, null, null);
0536:                    //
0537:                    System.gc();
0538:                    MiscHelper.writeMessage(this , "Removed Rcth from cache");
0539:                    System.gc();
0540:                    MiscHelper.profileMemory();
0541:                    System.gc();
0542:                    //MiscHelper.println("RETURN FROM STUDIO");
0543:                    //inCs.removeCachedConsolePageContextHandles();
0544:                } else if (inSac.isAction(SubmitActionParameters.EXPORT,
0545:                        SubmitActionParameters.APPLICATION)) {
0546:
0547:                    //
0548:                    String appType = inSac
0549:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0550:                    String appName = inSac
0551:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0552:                    ConceptTagCharacteristic psCtchar = null;
0553:                    if (SubmitActionParameters.USER.equals(appType)) {
0554:                        psCtchar = inCps
0555:                                .getUserProjectSystemCharacteristic(appName);
0556:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0557:                        psCtchar = inCps
0558:                                .getServerProjectSystemCharacteristic(appName);
0559:                    } else {
0560:                        throw UnexpectedSystemException.unknownState();
0561:                    }
0562:                    //
0563:                    RootConceptTagHolder candidateRcth = SystemEntityTagHelper
0564:                            .getGovernorCall();
0565:                    ConceptTagCharacteristic candidateCtchar = candidateRcth
0566:                            .getFirstCharacteristic();
0567:                    for (int i = (candidateCtchar.getValueLength() - 1); i >= 0; i--) {
0568:                        candidateCtchar.removeValueWithLocalFiles(i);
0569:                    }
0570:                    //
0571:                    psCtchar.copyTo(candidateCtchar);
0572:                    //
0573:                    byte candidateContent[] = ConceptRollupTag
0574:                            .getRollupFromList(candidateRcth, null);
0575:                    OutputStream os = outValue.getOutputStream();
0576:                    os.write(candidateContent, 0, candidateContent.length);
0577:                    os.flush();
0578:                    os.close();
0579:                    //String appName = inSac.getFirstParameter();
0580:                    outValue.setOutputText(false);
0581:                    outValue.setOutputFileName(MiscHelper.literalReplace(
0582:                            appName + ".zip", "/", "_"));
0583:                    outValue.setMimeType("application/download");
0584:                    //ProjectApplicationSet pas = inCs.getProjectApplicationSet();
0585:                    //MiscHelper.println("RETURN FROM STUDIO");
0586:                    //pas.exportApplication(appName, outValue.getOutputStream());
0587:                    //throw UnexpectedSystemException.notImplemented();
0588:                } else if (inSac.isAction(SubmitActionParameters.IMPORT,
0589:                        SubmitActionParameters.APPLICATION)) {
0590:
0591:                    //String appName = inSac.getFirstParameter();
0592:                    String appType = inSac
0593:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0594:                    String fileParameter = inSac
0595:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0596:                    //String fileParameter = inSac.getParameter(inSac.FIRST_INPUT);
0597:
0598:                    byte appContent[] = inPs
0599:                            .getParameterAsUpload(fileParameter);
0600:                    //ByteArrayInputStream bais = new ByteArrayInputStream(appContent);
0601:                    //
0602:                    String appName = inPs.getUploadParameterName(fileParameter);
0603:                    if (appName.lastIndexOf("/") != -1) {
0604:                        appName = appName
0605:                                .substring(appName.lastIndexOf("/") + 1);
0606:                    }
0607:                    if (appName.lastIndexOf("\\") != -1) {
0608:                        appName = appName
0609:                                .substring(appName.lastIndexOf("\\") + 1);
0610:                    }
0611:                    if (appName.lastIndexOf(".") != -1) {
0612:                        appName = appName
0613:                                .substring(0, appName.lastIndexOf("."));
0614:                    }
0615:                    //
0616:                    RootConceptTagHolder importRcth = ConceptRollupTag
0617:                            .getRootHolderFromList(appContent);
0618:                    ProjectSystem importPs = ((ProjectSystem) importRcth
0619:                            .getFirstChildConceptTag());
0620:                    //ProjectApplicationSet pas = inCs.getProjectApplicationSet();
0621:                    //
0622:                    ////MiscHelper.println("RETURN FROM STUDIO");
0623:                    //pas.importApplication(appName, bais);
0624:                    //inCs.saveProjectApplicationSet();
0625:                    if (!inCps.isUserProjectSystemPresent(appName)) {
0626:                        //deleteProjectSystemIfPresent(inCps, appType, appName);
0627:                        createOrImportApplication(inCps, appType, appName,
0628:                                importPs);
0629:                        inCps.reloadProjectSystems();
0630:                    } else {
0631:                        ConsolePageMessageHolder nextCpmh = inCps
0632:                                .getMessageHolder().createSubMessage();
0633:                        nextCpmh
0634:                                .setErrorHeader("Action Cancelled: Application '"
0635:                                        + appName
0636:                                        + "' already exists, please delete it first");
0637:                    }
0638:                    //throw UnexpectedSystemException.notImplemented();
0639:                } else if (inSac.isAction(SubmitActionParameters.UPDATE,
0640:                        SubmitActionParameters.PROPERTY)) {
0641:
0642:                    String appType = inSac
0643:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0644:                    String appName = inSac
0645:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0646:                    //
0647:                    String propName = inSac
0648:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0649:                    String propValue = inSac
0650:                            .getParameter(ConsoleParameterContext.FOURTH_INPUT);
0651:                    String propRegEx = inSac
0652:                            .getParameter(ConsoleParameterContext.FIFTH_INPUT);
0653:                    String propDesc = inSac
0654:                            .getParameter(ConsoleParameterContext.SIXTH_INPUT);
0655:                    String propErrMess = inSac
0656:                            .getParameter(ConsoleParameterContext.SEVENTH_INPUT);
0657:                    //
0658:                    //
0659:                    ProjectSystem projectSystem = null;
0660:                    if (SubmitActionParameters.USER.equals(appType)) {
0661:                        projectSystem = inCps.getUserProjectSystem(appName);
0662:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0663:                        projectSystem = inCps.getServerProjectSystem(appName);
0664:                    } else {
0665:                        throw UnexpectedSystemException.unknownState();
0666:                    }
0667:                    //
0668:                    //
0669:                    SystemEntityProperties sepValues = projectSystem
0670:                            .getUserPropertiesValues();
0671:                    SystemEntityProperties sepRegExs = projectSystem
0672:                            .getUserPropertiesRegExes();
0673:                    SystemEntityProperties sepDescs = projectSystem
0674:                            .getUserPropertiesDescriptions();
0675:                    SystemEntityProperties sepErrMess = projectSystem
0676:                            .getUserPropertiesErrorMessages();
0677:                    //
0678:                    if (!sepValues.isValidPropertyName(propName)) {
0679:                        ConsolePageMessageHolder nextCpmh = inCps
0680:                                .getMessageHolder().createSubMessage();
0681:                        nextCpmh.setErrorHeader("Action Cancelled: property '"
0682:                                + propName + "' does not have a valid name");
0683:                    } else if (!sepValues.isValidPropertyValue(propValue)) {
0684:                        ConsolePageMessageHolder nextCpmh = inCps
0685:                                .getMessageHolder().createSubMessage();
0686:                        nextCpmh.setErrorHeader("Action Cancelled: property '"
0687:                                + propName + "' does not have a valid value '"
0688:                                + propValue + "'");
0689:                    } else if (sepValues.isPropertyPresent(propName)) {
0690:                        //
0691:                        sepValues.removeProperty(propName);
0692:                        sepRegExs.removeProperty(propName);
0693:                        sepDescs.removeProperty(propName);
0694:                        sepErrMess.removeProperty(propName);
0695:                        //
0696:                        sepValues.createProperty(propName, propValue);
0697:                        sepRegExs.createProperty(propName, propRegEx);
0698:                        sepDescs.createProperty(propName, propDesc);
0699:                        sepErrMess.createProperty(propName, propErrMess);
0700:                        //
0701:                        UserIdentity ui = inCps.getUserHolder()
0702:                                .getUserIdentity();
0703:                        saveProjectSystem(projectSystem, ui);
0704:                    } else {
0705:                        ConsolePageMessageHolder nextCpmh = inCps
0706:                                .getMessageHolder().createSubMessage();
0707:                        nextCpmh.setErrorHeader("Action Cancelled: property '"
0708:                                + propName
0709:                                + "' does not exist for application '"
0710:                                + appName + "'");
0711:                    }
0712:                } else if (inSac.isAction(SubmitActionParameters.DELETE,
0713:                        SubmitActionParameters.PROPERTY)) {
0714:
0715:                    String appType = inSac
0716:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0717:                    String appName = inSac
0718:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0719:                    String propName = inSac
0720:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0721:                    //
0722:                    //
0723:                    //
0724:                    ProjectSystem projectSystem = null;
0725:                    if (SubmitActionParameters.USER.equals(appType)) {
0726:                        projectSystem = inCps.getUserProjectSystem(appName);
0727:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0728:                        projectSystem = inCps.getServerProjectSystem(appName);
0729:                    } else {
0730:                        throw UnexpectedSystemException.unknownState();
0731:                    }
0732:                    //
0733:                    //
0734:                    SystemEntityProperties sepValues = projectSystem
0735:                            .getUserPropertiesValues();
0736:                    SystemEntityProperties sepRegExs = projectSystem
0737:                            .getUserPropertiesRegExes();
0738:                    SystemEntityProperties sepDescs = projectSystem
0739:                            .getUserPropertiesDescriptions();
0740:                    SystemEntityProperties sepErrMess = projectSystem
0741:                            .getUserPropertiesErrorMessages();
0742:                    //
0743:                    if (sepValues.isPropertyPresent(propName)) {
0744:                        //
0745:                        sepValues.removeProperty(propName);
0746:                        sepRegExs.removeProperty(propName);
0747:                        sepDescs.removeProperty(propName);
0748:                        sepErrMess.removeProperty(propName);
0749:                        //
0750:                        UserIdentity ui = inCps.getUserHolder()
0751:                                .getUserIdentity();
0752:                        saveProjectSystem(projectSystem, ui);
0753:                    } else {
0754:                        ConsolePageMessageHolder nextCpmh = inCps
0755:                                .getMessageHolder().createSubMessage();
0756:                        nextCpmh.setErrorHeader("Action Cancelled: property '"
0757:                                + propName
0758:                                + "' does not exist for application '"
0759:                                + appName + "'");
0760:                    }
0761:                } else if (inSac.isAction(SubmitActionParameters.CREATE,
0762:                        SubmitActionParameters.PROPERTY)) {
0763:
0764:                    String appType = inSac
0765:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0766:                    String appName = inSac
0767:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0768:                    //
0769:                    String propName = inSac
0770:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0771:                    String propValue = inSac
0772:                            .getParameter(ConsoleParameterContext.FOURTH_INPUT);
0773:                    String propRegEx = inSac
0774:                            .getParameter(ConsoleParameterContext.FIFTH_INPUT);
0775:                    String propDesc = inSac
0776:                            .getParameter(ConsoleParameterContext.SIXTH_INPUT);
0777:                    String propErrMess = inSac
0778:                            .getParameter(ConsoleParameterContext.SEVENTH_INPUT);
0779:                    //
0780:                    //
0781:                    ProjectSystem projectSystem = null;
0782:                    if (SubmitActionParameters.USER.equals(appType)) {
0783:                        projectSystem = inCps.getUserProjectSystem(appName);
0784:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0785:                        projectSystem = inCps.getServerProjectSystem(appName);
0786:                    } else {
0787:                        throw UnexpectedSystemException.unknownState();
0788:                    }
0789:                    //
0790:                    //
0791:                    SystemEntityProperties sepValues = projectSystem
0792:                            .getUserPropertiesValues();
0793:                    SystemEntityProperties sepRegExs = projectSystem
0794:                            .getUserPropertiesRegExes();
0795:                    SystemEntityProperties sepDescs = projectSystem
0796:                            .getUserPropertiesDescriptions();
0797:                    SystemEntityProperties sepErrMess = projectSystem
0798:                            .getUserPropertiesErrorMessages();
0799:                    //
0800:                    if (!sepValues.isValidPropertyName(propName)) {
0801:                        ConsolePageMessageHolder nextCpmh = inCps
0802:                                .getMessageHolder().createSubMessage();
0803:                        nextCpmh.setErrorHeader("Action Cancelled: property '"
0804:                                + propName + "' does not have a valid name");
0805:                    } else if (!sepValues.isValidPropertyValue(propValue)) {
0806:                        ConsolePageMessageHolder nextCpmh = inCps
0807:                                .getMessageHolder().createSubMessage();
0808:                        nextCpmh.setErrorHeader("Action Cancelled: property '"
0809:                                + propName + "' does not have a valid value '"
0810:                                + propValue + "'");
0811:                    } else if (!sepValues.isPropertyPresent(propName)) {
0812:                        //
0813:                        sepValues.createProperty(propName, propValue);
0814:                        sepRegExs.createProperty(propName, propRegEx);
0815:                        sepDescs.createProperty(propName, propDesc);
0816:                        sepErrMess.createProperty(propName, propErrMess);
0817:                        //
0818:                        UserIdentity ui = inCps.getUserHolder()
0819:                                .getUserIdentity();
0820:                        saveProjectSystem(projectSystem, ui);
0821:                    } else {
0822:                        ConsolePageMessageHolder nextCpmh = inCps
0823:                                .getMessageHolder().createSubMessage();
0824:                        nextCpmh.setErrorHeader("Action Cancelled: property '"
0825:                                + propName
0826:                                + "' already exist for application '" + appName
0827:                                + "'");
0828:                    }
0829:                } else if (inSac.isAction(SubmitActionParameters.UPDATE,
0830:                        SubmitActionParameters.DESCRIPTION)) {
0831:
0832:                    String appType = inSac
0833:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0834:                    String appName = inSac
0835:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0836:                    String description = inSac
0837:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0838:                    //
0839:                    //
0840:                    ProjectSystem projectSystem = null;
0841:                    if (SubmitActionParameters.USER.equals(appType)) {
0842:                        projectSystem = inCps.getUserProjectSystem(appName);
0843:                    } else if (SubmitActionParameters.SERVER.equals(appType)) {
0844:                        projectSystem = inCps.getServerProjectSystem(appName);
0845:                    } else {
0846:                        throw UnexpectedSystemException.unknownState();
0847:                    }
0848:                    //
0849:                    projectSystem.setDescription(description);
0850:                    //
0851:                    UserIdentity ui = inCps.getUserHolder().getUserIdentity();
0852:                    saveProjectSystem(projectSystem, ui);
0853:                    //SystemEntityUpdatesContext seuc =
0854:                    //    SystemEntityUpdatesContext.newInstance(
0855:                    //        null, true, dummyGc.addPrepareArgumentAsSEntity(), 0);
0856:                    //SimpleSecurityAudit ssa =
0857:                    //    SimpleSecurityAudit.newInstance(ui, 0, "Create", "Start",
0858:                    //        MiscHelper.currentGMT(), null, null, false);
0859:                    //ProjectSystemUpdates psu =
0860:                    //    projectSystem.getSystemEntityUpdates(seuc, ssa);
0861:                    //ps.saveProjectSystem(psu);
0862:                    //ProjectApplicationSet pas = inCs.getProjectApplicationSet();
0863:                    //ProjectApplication pa = pas.getApplication(appName);
0864:                    //pa.setDescription(description);
0865:                    //inCs.saveProjectApplicationSet();
0866:                    //throw UnexpectedSystemException.notImplemented();
0867:                } else if (inSac.isAction(SubmitActionParameters.CREATE,
0868:                        SubmitActionParameters.APPLICATION)) {
0869:                    //
0870:                    String appType = inSac
0871:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0872:                    String appName = inSac
0873:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0874:                    //MiscHelper.println("ConsoleScreenServlet Cre-appNa = " + appName);
0875:                    //ProjectService ps =
0876:                    //    ProjectServiceCallerFactory.getProjectService();
0877:                    //RootConceptTagHolder dummyRcth =
0878:                    //    GovernorCallHelper.createGovernorRequest("dummy", "dummy");
0879:                    //GovernorCall dummyGc =
0880:                    //    (GovernorCall)dummyRcth.getFirstChildConceptTag();
0881:                    //
0882:                    createOrImportApplication(inCps, appType, appName, null);
0883:                } else if (inSac.isAction(SubmitActionParameters.DELETE,
0884:                        SubmitActionParameters.APPLICATION)) {
0885:                    //
0886:                    String appType = inSac
0887:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0888:                    String appName = inSac
0889:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0890:                    //
0891:                    deleteProjectSystemIfPresent(inCps, appType, appName);
0892:                } else if (inSac.isAction(SubmitActionParameters.MARK,
0893:                        SubmitActionParameters.APPLICATION,
0894:                        SubmitActionParameters.DEPLOY_VISIBLE)) {
0895:                    //
0896:                    String appType = inSac
0897:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0898:                    String appName = inSac
0899:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0900:                    //
0901:                    if (appType.equals(SubmitActionParameters.USER)) {
0902:                        ProjectSystem projectSystem = inCps
0903:                                .getUserProjectSystem(appName);
0904:                        UserIdentity ui = inCps.getUserHolder()
0905:                                .getUserIdentity();
0906:                        if (!projectSystem.isDeployVisible()) {
0907:                            projectSystem.setDeployVisible(true);
0908:                            saveProjectSystem(projectSystem, ui);
0909:                        } else {
0910:                            throw UnexpectedSystemException.unknownState();
0911:                        }
0912:                    } else if (appType.equals(SubmitActionParameters.SERVER)) {
0913:                        ProjectSystem projectSystem = inCps
0914:                                .getServerProjectSystem(appName);
0915:                        UserIdentity ui = inCps.getUserHolder()
0916:                                .getUserIdentity();
0917:                        if (!projectSystem.isDeployVisible()) {
0918:                            projectSystem.setDeployVisible(true);
0919:                            SystemServer ss = SystemServerFactory
0920:                                    .getSystemServer();
0921:                            ConceptTagPreferences wpCtp = new WebPageTagPreferences();
0922:                            ss.deployProject(projectSystem, wpCtp);
0923:                            saveProjectSystem(projectSystem, ui);
0924:                        } else {
0925:                            throw UnexpectedSystemException.unknownState();
0926:                        }
0927:                    } else {
0928:                        throw UnexpectedSystemException.unknownState();
0929:                    }
0930:                } else if (inSac.isAction(SubmitActionParameters.MARK,
0931:                        SubmitActionParameters.APPLICATION,
0932:                        SubmitActionParameters.DEPLOY_NOT_VISIBLE)) {
0933:                    //
0934:                    String appType = inSac
0935:                            .getParameter(ConsoleParameterContext.FIRST_INPUT);
0936:                    String appName = inSac
0937:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0938:                    //
0939:                    if (appType.equals(SubmitActionParameters.USER)) {
0940:                        ProjectSystem projectSystem = inCps
0941:                                .getUserProjectSystem(appName);
0942:                        UserIdentity ui = inCps.getUserHolder()
0943:                                .getUserIdentity();
0944:                        if (projectSystem.isDeployVisible()) {
0945:                            projectSystem.setDeployVisible(false);
0946:                            saveProjectSystem(projectSystem, ui);
0947:                        } else {
0948:                            throw UnexpectedSystemException.unknownState();
0949:                        }
0950:                    } else if (appType.equals(SubmitActionParameters.SERVER)) {
0951:                        ProjectSystem projectSystem = inCps
0952:                                .getServerProjectSystem(appName);
0953:                        UserIdentity ui = inCps.getUserHolder()
0954:                                .getUserIdentity();
0955:                        if (projectSystem.isDeployVisible()) {
0956:                            projectSystem.setDeployVisible(false);
0957:                            SystemServer ss = SystemServerFactory
0958:                                    .getSystemServer();
0959:                            ss.undeployProject(projectSystem);
0960:                            saveProjectSystem(projectSystem, ui);
0961:                        } else {
0962:                            throw UnexpectedSystemException.unknownState();
0963:                        }
0964:                    } else {
0965:                        throw UnexpectedSystemException.unknownState();
0966:                    }
0967:                } else if (inSac
0968:                        .isAction(SubmitActionParameters.COPY_TO_SERVER)) {
0969:                    String userName = inCps.getUserHolder().getUserIdentity()
0970:                            .getName();
0971:                    if (!inSac
0972:                            .getParameter(ConsoleParameterContext.FIRST_INPUT)
0973:                            .equals("")) {
0974:                        //
0975:                        userName = inSac
0976:                                .getParameter(ConsoleParameterContext.FIRST_INPUT);
0977:                    }
0978:                    String projectName = inSac
0979:                            .getParameter(ConsoleParameterContext.SECOND_INPUT);
0980:                    String deployDir = inSac
0981:                            .getParameter(ConsoleParameterContext.THIRD_INPUT);
0982:                    String deployVisible = inSac
0983:                            .getParameter(ConsoleParameterContext.FOURTH_INPUT);
0984:                    //
0985:                    if (deployVisible
0986:                            .equals(SubmitActionParameters.DEPLOY_NOT_VISIBLE)
0987:                            || deployVisible
0988:                                    .equals(SubmitActionParameters.DEPLOY_VISIBLE)) {
0989:                        //
0990:                        ProjectService projectService = ProjectServiceCallerFactory
0991:                                .getProjectService();
0992:                        //
0993:                        UserIdentity localUi = inCps.getUserHolder()
0994:                                .getUserIdentity();
0995:                        UserIdentity ui = SimpleUserIdentity.newInstance(
0996:                                userName, localUi.getSecurityType(), true,
0997:                                false);
0998:                        //
0999:                        //
1000:                        boolean shouldBeDeployed = deployVisible
1001:                                .equals(SubmitActionParameters.DEPLOY_VISIBLE);
1002:                        //
1003:                        //
1004:                        ProjectSystem sourceProjectSystem = projectService
1005:                                .accessProjectSystem(GovernorCallHelper
1006:                                        .getLocalDummyCharacteristic(), 0, ui,
1007:                                        false, projectName);
1008:                        //
1009:                        ProjectSystem destProjectSystem = projectService
1010:                                .accessProjectSystem(GovernorCallHelper
1011:                                        .getLocalDummyCharacteristic(), 0,
1012:                                        null, true, deployDir);
1013:                        //
1014:                        //
1015:                        SystemServer ss = SystemServerFactory.getSystemServer();
1016:                        if (destProjectSystem.isDeployed()
1017:                                && destProjectSystem.isActive()
1018:                                && destProjectSystem.isDeployVisible()) {
1019:                            //
1020:                            ss.undeployProject(destProjectSystem);
1021:                        }
1022:                        //
1023:                        //
1024:                        destProjectSystem.setName(deployDir);
1025:                        destProjectSystem.setDeployVisible(shouldBeDeployed);
1026:                        destProjectSystem.setActive(true);
1027:                        //destProjectSystem.getWebDocs().createDirectory("Images");
1028:                        //destProjectSystem.getWebDocsProperties().createDirectory(
1029:                        //    "Images");
1030:                        //destProjectSystem.getWebDocs().removeDirectory("Images");
1031:                        //destProjectSystem.getWebDocsProperties().removeDirectory(
1032:                        //    "Images");
1033:                        ProjectSystemHelper.copyTo(sourceProjectSystem,
1034:                                destProjectSystem);
1035:                        //
1036:                        saveProjectSystem(destProjectSystem, localUi);
1037:                        inCps.reloadProjectSystems();
1038:                        //
1039:                        //
1040:                        //
1041:                        if (destProjectSystem.isDeployed()) {
1042:                            ConceptTagPreferences wpCtp = new WebPageTagPreferences();
1043:                            ss.deployProject(destProjectSystem, wpCtp);
1044:                        }
1045:                    }
1046:                    //else if (deployVisible.equals(
1047:                    //    SubmitActionParameters.DEPLOY_VISIBLE)) {
1048:                    //    //
1049:                    //    throw UnexpectedSystemException.notImplemented();
1050:                    //}
1051:                    else {
1052:                        throw UnexpectedSystemException.unknownState();
1053:                    }
1054:                } else {
1055:                    inSac.unknownAction();
1056:                }
1057:
1058:                //
1059:                //
1060:                //testDMS();
1061:
1062:                return outValue;
1063:
1064:            }
1065:
1066:            private ProjectSystem createOrImportApplication(
1067:                    ConsolePageSession inCps, String inAppType,
1068:                    String inAppName, ProjectSystem inImportPs) {
1069:                //
1070:                //
1071:                ProjectSystem outValue = null;
1072:                //
1073:                UserIdentity ui = inCps.getUserHolder().getUserIdentity();
1074:                //
1075:                //ProjectSystem projectSystem = ps.accessProjectSystem(
1076:                //    dummyGc.addPrepareArgumentAsSEntity(),
1077:                //    0, ui, false, appName);
1078:                if (inAppType.equals(SubmitActionParameters.USER)) {
1079:                    //
1080:                    ConceptTagCharacteristic localCtchar[] = new ConceptTagCharacteristic[1];
1081:                    //
1082:                    outValue = accessProjectSystem(ui, false, inAppName,
1083:                            localCtchar);
1084:                    //
1085:                    outValue.setName(inAppName);
1086:                    outValue.setActive(true);
1087:                    //
1088:                    outValue.resetToDefault();
1089:                    //
1090:                    //
1091:                    if (inImportPs != null) {
1092:                        ProjectSystemHelper.copyTo(inImportPs, outValue);
1093:                    }
1094:                    //
1095:                    saveProjectSystem(outValue, ui);
1096:                    //SystemEntityUpdatesContext seuc =
1097:                    //    SystemEntityUpdatesContext.newInstance(
1098:                    //        null, true, dummyGc.addPrepareArgumentAsSEntity(), 0);
1099:                    //SimpleSecurityAudit ssa =
1100:                    //    SimpleSecurityAudit.newInstance(ui, 0, "Create", "Start",
1101:                    //        MiscHelper.currentGMT(), null, null, false);
1102:                    //ProjectSystemUpdates psu =
1103:                    //    projectSystem.getSystemEntityUpdates(seuc, ssa);
1104:                    //ps.saveProjectSystem(psu);
1105:                    //
1106:                    inCps.addUserProjectSystem(outValue, localCtchar[0]);
1107:                    inCps.reloadProjectSystems();
1108:                    //
1109:                    //ProjectApplicationSet pas = inCs.getProjectApplicationSet();
1110:                    //pas.createDefaultApplication(appName);
1111:                    //RootConceptTagHolder rcth =
1112:                    //    WorkflowTemplateTagHelper.getRootConceptTagHolder(
1113:                    //        (Node)null, null, null, null);
1114:                    //ProjectApplication pa = pas.getApplication(appName);
1115:                    //pa.getScript().setContent(rcth.getXMLRepresentation());
1116:                    ////
1117:                    //inCs.saveProjectApplicationSet();
1118:                    //throw UnexpectedSystemException.notImplemented();
1119:                } else {
1120:                    throw UnexpectedSystemException.unknownState();
1121:                }
1122:
1123:                return outValue;
1124:            }
1125:
1126:            private final static void testDMS() {
1127:                //
1128:                //
1129:                MiscHelper
1130:                        .println("ConScrServ (TEST_AREA, TEST_AREA, TEST_AREA)");
1131:                DocumentFileSystemRootTag localTestDfsr = ((DocumentFileSystemRootTag) DMSServiceBean
1132:                        .getEmptyTestRoot());
1133:                VirtualFileSystemDirectory localTestVfsd = localTestDfsr
1134:                        .createDirectory("BubbaDir");
1135:                VirtualFileSystemFile localTestVfsf = localTestVfsd.createFile(
1136:                        "BubbaFile", (new byte[] {}));
1137:                String testDfsrString = null;
1138:                testDfsrString = localTestDfsr.toString();
1139:                MiscHelper
1140:                        .println("ConScrServ (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)");
1141:                MiscHelper.println(testDfsrString);
1142:                //
1143:                SystemEntityUpdatesContext localTestSeuc = null;
1144:                //
1145:                localTestSeuc = localTestDfsr.getUpdatesContext(true);
1146:                localTestDfsr.getSystemEntityUpdates(localTestSeuc);
1147:                //
1148:                localTestDfsr.removeDirectory("BubbaDir");
1149:                testDfsrString = localTestDfsr.toString();
1150:                MiscHelper
1151:                        .println("ConScrServ (2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)");
1152:                MiscHelper.println(testDfsrString);
1153:                //
1154:                //
1155:                localTestSeuc = localTestDfsr.getUpdatesContext(true);
1156:                localTestDfsr.getSystemEntityUpdates(localTestSeuc);
1157:                //
1158:                localTestVfsd = localTestDfsr.createDirectory("BubbaDir");
1159:                localTestVfsf = localTestVfsd.createFile("BubbaFile",
1160:                        (new byte[] {}));
1161:                testDfsrString = localTestDfsr.toString();
1162:                MiscHelper
1163:                        .println("ConScrServ (3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)");
1164:                MiscHelper.println(testDfsrString);
1165:                //
1166:                //
1167:                localTestSeuc = localTestDfsr.getUpdatesContext(true);
1168:                localTestDfsr.getSystemEntityUpdates(localTestSeuc);
1169:                //
1170:                //localTestVfsd = localTestDfsr.createDirectory("BubbaDir");
1171:                localTestVfsd.updateFile("BubbaFile", (new byte[] {}));
1172:                testDfsrString = localTestDfsr.toString();
1173:                MiscHelper
1174:                        .println("ConScrServ (4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4)");
1175:                MiscHelper.println(testDfsrString);
1176:                //
1177:                //
1178:                localTestSeuc = localTestDfsr.getUpdatesContext(true);
1179:                localTestDfsr.getSystemEntityUpdates(localTestSeuc);
1180:                //
1181:                //localTestVfsd = localTestDfsr.createDirectory("BubbaDir");
1182:                localTestVfsd.updateFile("BubbaFile", (new byte[] { 'a' }));
1183:                testDfsrString = localTestDfsr.toString();
1184:                MiscHelper
1185:                        .println("ConScrServ (5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)");
1186:                MiscHelper.println(testDfsrString);
1187:                //
1188:                MiscHelper
1189:                        .println("ConScrServ (TEST_AREA, TEST_AREA, TEST_AREA)");
1190:            }
1191:
1192:            private boolean isFileAreaAvailable(ArrayList inSubDirs,
1193:                    String inDirectory, String inFileName,
1194:                    ConsolePageSession inCps) {
1195:                //
1196:                boolean outValue = true;
1197:
1198:                for (int i = 0; i < inSubDirs.size(); i++) {
1199:                    VirtualFileSystemHolder nextDir = (VirtualFileSystemHolder) inSubDirs
1200:                            .get(i);
1201:                    outValue &= isFileAreaAvailable(nextDir, inDirectory,
1202:                            inFileName, inCps);
1203:                    if (!outValue) {
1204:                        break;
1205:                    }
1206:                }
1207:
1208:                return outValue;
1209:            }
1210:
1211:            private boolean isFileAreaAvailable(
1212:                    VirtualFileSystemHolder inRootVsh, String inDirectory,
1213:                    String inFileName, ConsolePageSession inCps) {
1214:
1215:                boolean outValue = false;
1216:
1217:                if (inRootVsh.isFileBlockingAbsoluteDirectory(inDirectory)) {
1218:                    ConsolePageMessageHolder nextCpmh = inCps
1219:                            .getMessageHolder().createSubMessage();
1220:                    nextCpmh
1221:                            .setErrorHeader("Action Cancelled: Proposed directory '"
1222:                                    + inDirectory + "' would overwrite a file");
1223:                } else {
1224:                    //
1225:                    //inRootVsh.isAbsoluteDirectoryPresent(inDirectory);
1226:                    //VirtualSystemHolder targetVsh =
1227:                    //    inRootVsh.getOrCreateAbsoluteDirectory(inDirectory);
1228:                    //
1229:                    boolean fileObstructed = inRootVsh
1230:                            .isAbsoluteDirectoryPresent(inDirectory)
1231:                            && (inRootVsh
1232:                                    .getOrCreateAbsoluteDirectory(inDirectory)
1233:                                    .isDirectoryOrFilePresent(inFileName));
1234:                    //
1235:                    if (fileObstructed) {
1236:                        ConsolePageMessageHolder nextCpmh = inCps
1237:                                .getMessageHolder().createSubMessage();
1238:                        nextCpmh
1239:                                .setErrorHeader("Action Cancelled: Proposed file '"
1240:                                        + inFileName
1241:                                        + "' would overwrite a file or directory");
1242:                    } else if (!BaseVirtualFileSystemHolder
1243:                            .isDirectoryPathValid(inDirectory)) {
1244:                        //
1245:                        ConsolePageMessageHolder nextCpmh = inCps
1246:                                .getMessageHolder().createSubMessage();
1247:                        nextCpmh
1248:                                .setErrorHeader("Action Cancelled: Proposed directory '"
1249:                                        + inDirectory + "' has an invalid name");
1250:                    } else if (!BaseVirtualFileSystemHolder
1251:                            .isFileNameValid(inFileName)) {
1252:                        //
1253:                        ConsolePageMessageHolder nextCpmh = inCps
1254:                                .getMessageHolder().createSubMessage();
1255:                        nextCpmh
1256:                                .setErrorHeader("Action Cancelled: Proposed file '"
1257:                                        + inFileName + "' has an invalid name");
1258:                    } else {
1259:                        outValue = true;
1260:                    }
1261:                }
1262:
1263:                return outValue;
1264:            }
1265:
1266:            private ProjectSystem accessProjectSystem(UserIdentity inUi,
1267:                    boolean inDeployed, String inName,
1268:                    ConceptTagCharacteristic inCtchar[]) {
1269:                //
1270:
1271:                ProjectSystem outValue = null;
1272:
1273:                ProjectService ps = ProjectServiceCallerFactory
1274:                        .getProjectService();
1275:                RootConceptTagHolder dummyRcth = GovernorCallHelper
1276:                        .createGovernorRequest("dummy", "dummy");
1277:                GovernorCall dummyGc = (GovernorCall) dummyRcth
1278:                        .getFirstChildConceptTag();
1279:                //
1280:                //UserIdentity ui = inCs.getUserHolder().getUserIdentity();
1281:                //
1282:                inCtchar[0] = dummyGc.addPrepareArgumentAsSEntity();
1283:                outValue = ps.accessProjectSystem(inCtchar[0], 0, inUi,
1284:                        inDeployed, inName);
1285:
1286:                return outValue;
1287:            }
1288:
1289:            //
1290:            //
1291:            //
1292:            private void deleteProjectSystemIfPresent(ConsolePageSession inCps,
1293:                    String inType, String inName) {
1294:                //
1295:                //
1296:                //
1297:                //
1298:                UserIdentity ui = inCps.getUserHolder().getUserIdentity();
1299:                //
1300:                ProjectSystem projectSystem = null;
1301:                if (SubmitActionParameters.USER.equals(inType)) {
1302:                    if (inCps.isUserProjectSystemPresent(inName)) {
1303:                        projectSystem = inCps.getUserProjectSystem(inName);
1304:                    }
1305:                } else if (SubmitActionParameters.SERVER.equals(inType)) {
1306:                    if (inCps.isServerProjectSystemPresent(inName)) {
1307:                        projectSystem = inCps.getServerProjectSystem(inName);
1308:                    }
1309:                } else {
1310:                    throw UnexpectedSystemException.unknownState();
1311:                }
1312:                //
1313:                if (projectSystem != null) {
1314:
1315:                    //
1316:                    if (projectSystem.isDeployed()
1317:                            && projectSystem.isDeployVisible()) {
1318:                        SystemServer ss = SystemServerFactory.getSystemServer();
1319:                        ss.undeployProject(projectSystem);
1320:                    }
1321:                    //
1322:                    projectSystem.resetToDefault();
1323:                    projectSystem.setActive(false);
1324:                    //if (true) {
1325:                    //    throw UnexpectedSystemException.unknownState();
1326:                    //}
1327:                    saveProjectSystem(projectSystem, ui);
1328:                    //
1329:                    if (projectSystem.isDeployed()) {
1330:                        //SystemServer ss = SystemServerFactory.getSystemServer();
1331:                        //ss.undeployProject(projectSystem);
1332:                        //
1333:                        inCps.removeServerProjectSystem(inName);
1334:                    } else {
1335:                        inCps.removeUserProjectSystem(inName);
1336:                    }
1337:                    inCps.reloadProjectSystems();
1338:                }
1339:            }
1340:
1341:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.