Source Code Cross Referenced for CreateStiqPageResponder.java in  » Testing » StoryTestIQ » fitnesse » responders » editing » 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 » Testing » StoryTestIQ » fitnesse.responders.editing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
002:        // Released under the terms of the GNU General Public License version 2 or later.
003:        package fitnesse.responders.editing;
004:
005:        import fitnesse.FitNesseContext;
006:        import fitnesse.Responder;
007:        import fitnesse.authentication.SecureOperation;
008:        import fitnesse.authentication.SecureWriteOperation;
009:        import fitnesse.components.SaveRecorder;
010:        import fitnesse.html.HtmlUtil;
011:        import fitnesse.http.Request;
012:        import fitnesse.http.Response;
013:        import fitnesse.http.SimpleResponse;
014:        import fitnesse.responders.ErrorResponder;
015:        import fitnesse.responders.SecureResponder;
016:        import fitnesse.responders.refactoring.NewStiqPageResponder;
017:        import fitnesse.util.PropertiesUtil;
018:        import fitnesse.wiki.PageCrawler;
019:        import fitnesse.wiki.PageData;
020:        import fitnesse.wiki.PathParser;
021:        import fitnesse.wiki.WikiPage;
022:        import fitnesse.wiki.WikiPagePath;
023:        import fitnesse.wikitext.widgets.TagSuiteWidget;
024:        import fitnesse.wikitext.widgets.WikiWordWidget;
025:
026:        public class CreateStiqPageResponder implements  SecureResponder {
027:
028:            public static String RESPONDER_KEY = "createStiqPage";
029:
030:            public Response makeResponse(FitNesseContext context,
031:                    Request request) throws Exception {
032:                Response response = null;
033:                String resource = request.getResource();
034:                String testPageName = ((String) request
035:                        .getInput(NewStiqPageResponder.STIQ_PAGE_NAME_INPUT_NAME))
036:                        .trim();
037:                String testPageType = (String) request
038:                        .getInput(NewStiqPageResponder.STIQ_PAGE_TYPE_SELECT_NAME);
039:
040:                WikiPage parentPage = getPage(resource, context);
041:                if (parentPage == null) {
042:                    return makeErrorMessageResponder(testPageName,
043:                            "Parent page does not exist.").makeResponse(
044:                            context, request);
045:                }
046:                if (testPageName == null
047:                        || !WikiWordWidget.isSingleWikiWord(testPageName)) {
048:                    return makeErrorMessageResponder(
049:                            testPageName,
050:                            "Page name '" + testPageName + "' is not a "
051:                                    + getWikiWordLink() + ".").makeResponse(
052:                            context, request);
053:                }
054:                if (pageExists(context, request, testPageName)) {
055:                    return makeErrorMessageResponder(testPageName,
056:                            "Page already exists.").makeResponse(context,
057:                            request);
058:                }
059:                if (!NewStiqPageResponder.STIQ_PAGE_TYPES
060:                        .contains(testPageType)) {
061:                    return makeErrorMessageResponder(testPageName,
062:                            "Illegal test type.")
063:                            .makeResponse(context, request);
064:                }
065:
066:                WikiPage testPage = parentPage.addChildPage(testPageName);
067:                String user = request.getAuthorizationUsername();
068:                PageData data = testPage.getData();
069:                String responseRedirect = request.getResource();
070:
071:                // Create default content based on type
072:                if (NewStiqPageResponder.STIQ_PAGE_TYPE_TEST
073:                        .equals(testPageType)) {
074:                    data.setContent("| Test description |\n\n");
075:                    data.setAttribute(WikiPage.STIQ_TEST);
076:                } else if (NewStiqPageResponder.STIQ_PAGE_TYPE_TEST_SUITE
077:                        .equals(testPageType)) {
078:                    data.setContent("!suite\n");
079:                    data.setAttribute(WikiPage.STIQ_SUITE);
080:                } else if (NewStiqPageResponder.STIQ_PAGE_TYPE_COMPONENT
081:                        .equals(testPageType)) {
082:                    data
083:                            .setContent("| comment | Component description | |\n\n");
084:                    data.setAttribute(WikiPage.STIQ_COMPONENT);
085:                } else if (NewStiqPageResponder.STIQ_PAGE_TYPE_COMPONENT_SUITE
086:                        .equals(testPageType)) {
087:                    data.setContent("!components\n");
088:                    data.setAttribute(WikiPage.STIQ_SUITE);
089:                } else if (NewStiqPageResponder.STIQ_PAGE_TYPE_CONTAINER
090:                        .equals(testPageType)) {
091:                    data.setContent("!contents\n");
092:                } else if (NewStiqPageResponder.STIQ_PAGE_TYPE_TAG_SUITE
093:                        .equals(testPageType)) {
094:                    data.setContent("!tagsuite "
095:                            + getTagsuiteStartPageDefault() + " "
096:                            + getTagsuiteTagDefault() + "\n");
097:                    data.setAttribute(WikiPage.STIQ_SUITE);
098:                }
099:                setData(data, user);
100:                testPage.commit(data);
101:
102:                response = new SimpleResponse();
103:                response.redirect(responseRedirect);
104:                return response;
105:            }
106:
107:            private boolean pageExists(FitNesseContext context,
108:                    Request request, String testPageName) {
109:                String parentName = request.getResource();
110:                boolean exists = true;
111:
112:                if (testPageName != null
113:                        && WikiWordWidget.isSingleWikiWord(testPageName)) {
114:                    PageCrawler pageCrawler = context.root.getPageCrawler();
115:                    WikiPagePath subjectPath = PathParser.parse(parentName);
116:                    WikiPage subjectPage;
117:                    try {
118:                        subjectPage = pageCrawler.getPage(context.root,
119:                                subjectPath);
120:                        if (subjectPage != null) {
121:                            WikiPagePath parentPath = subjectPath.parentPath();
122:                            WikiPage parent = pageCrawler.getPage(context.root,
123:                                    parentPath);
124:                            exists = pageCrawler.pageExists(parent, PathParser
125:                                    .parse(testPageName));
126:                        }
127:                    } catch (Exception e) {
128:                        exists = false;
129:                    }
130:                }
131:                return exists;
132:            }
133:
134:            private Responder makeErrorMessageResponder(String testPageName,
135:                    String message) throws Exception {
136:                return new ErrorResponder("Cannot create " + testPageName
137:                        + HtmlUtil.BR + message);
138:            }
139:
140:            private WikiPage getPage(String resource, FitNesseContext context)
141:                    throws Exception {
142:                WikiPagePath path = PathParser.parse(resource);
143:                PageCrawler pageCrawler = context.root.getPageCrawler();
144:                WikiPage page = pageCrawler.getPage(context.root, path);
145:                return page;
146:            }
147:
148:            private void setData(PageData data, String user) throws Exception {
149:                SaveRecorder.pageSaved(data);
150:                if (user != null)
151:                    data.setAttribute(WikiPage.LAST_MODIFYING_USER, user);
152:                else
153:                    data.removeAttribute(WikiPage.LAST_MODIFYING_USER);
154:            }
155:
156:            public SecureOperation getSecureOperation() {
157:                return new SecureWriteOperation();
158:            }
159:
160:            private String getWikiWordLink() {
161:                return "<a href=\"http://storytestiq.solutionsiq.com/wiki/WikiWord\" target=\"STIQ Help\">WikiWord</a>";
162:            }
163:
164:            private String getTagsuiteStartPageDefault() {
165:                return PropertiesUtil.getProperty(
166:                        TagSuiteWidget.DEFAULT_START_PAGE_PROPERTY,
167:                        TagSuiteWidget.DEFAULT_START_PAGE_DEFAULT).trim();
168:            }
169:
170:            private String getTagsuiteTagDefault() {
171:                return PropertiesUtil.getProperty(
172:                        TagSuiteWidget.DEFAULT_TAG_PROPERTY,
173:                        TagSuiteWidget.DEFAULT_TAG_DEFAULT).trim();
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.