Source Code Cross Referenced for PortletExceptionResponseStrategy.java in  » J2EE » wicket » wicket » protocol » http » portlet » 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 » J2EE » wicket » wicket.protocol.http.portlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ==============================================================================
003:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
004:         * use this file except in compliance with the License. You may obtain a copy of
005:         * the License at
006:         * 
007:         * http://www.apache.org/licenses/LICENSE-2.0
008:         * 
009:         * Unless required by applicable law or agreed to in writing, software
010:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
011:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
012:         * License for the specific language governing permissions and limitations under
013:         * the License.
014:         */
015:        package wicket.protocol.http.portlet;
016:
017:        /**
018:         * Portlet implementation of
019:         * {@link wicket.request.compound.IExceptionResponseStrategy}. Depending on the
020:         * setting it returns a (pluggable) exception page or a blank page, and it
021:         * passes the exception through to the current request cycle by calling
022:         * {@link wicket.RequestCycle#onRuntimeException(Page, RuntimeException)}.
023:         * 
024:         * @author Janne Hietamäki
025:         * @author Eelco Hillenius
026:         * @author Johan Compagner
027:         * @author Igor Vaynberg (ivaynberg)
028:         */
029:
030:        import wicket.Application;
031:        import wicket.IPageFactory;
032:        import wicket.IRequestTarget;
033:        import wicket.Page;
034:        import wicket.RequestCycle;
035:        import wicket.RestartResponseAtInterceptPageException;
036:        import wicket.Session;
037:        import wicket.WicketRuntimeException;
038:        import wicket.authorization.AuthorizationException;
039:        import wicket.protocol.http.portlet.pages.ExceptionErrorPortletPage;
040:        import wicket.request.compound.IExceptionResponseStrategy;
041:        import wicket.request.target.component.IPageRequestTarget;
042:        import wicket.settings.IExceptionSettings;
043:
044:        /**
045:         * @author Janne Hietamäki
046:         * 
047:         */
048:        public class PortletExceptionResponseStrategy implements 
049:                IExceptionResponseStrategy {
050:            /**
051:             * Construct.
052:             */
053:            public PortletExceptionResponseStrategy() {
054:            }
055:
056:            /**
057:             * @see wicket.request.compound.IExceptionResponseStrategy#respond(wicket.RequestCycle,
058:             *      java.lang.RuntimeException)
059:             */
060:            public final void respond(final RequestCycle requestCycle,
061:                    final RuntimeException e) {
062:                // If application doesn't want debug info showing up for users
063:                final Session session = requestCycle.getSession();
064:                final Application application = session.getApplication();
065:                final IExceptionSettings settings = application
066:                        .getExceptionSettings();
067:                final Page responsePage = requestCycle.getResponsePage();
068:
069:                Page override = onRuntimeException(responsePage, e);
070:                if (override != null) {
071:                    requestCycle.setResponsePage(override);
072:                } else if (e instanceof  AuthorizationException) {
073:                    // are authorization exceptions always thrown before the real
074:                    // render?
075:                    // else we need to make a page (see below) or set it hard to a
076:                    // redirect.
077:                    Class accessDeniedPageClass = application
078:                            .getApplicationSettings().getAccessDeniedPage();
079:
080:                    throw new RestartResponseAtInterceptPageException(
081:                            accessDeniedPageClass);
082:                } else if (settings.getUnexpectedExceptionDisplay() != IExceptionSettings.SHOW_NO_EXCEPTION_PAGE) {
083:                    Class internalErrorPageClass = application
084:                            .getApplicationSettings().getInternalErrorPage();
085:                    Class responseClass = responsePage != null ? responsePage
086:                            .getClass() : null;
087:
088:                    if (responseClass != internalErrorPageClass
089:                            && settings.getUnexpectedExceptionDisplay() == IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE) {
090:                        // Show internal error page
091:                        final IPageFactory pageFactory;
092:                        IRequestTarget requestTarget = requestCycle
093:                                .getRequestTarget();
094:                        if (requestTarget instanceof  IPageRequestTarget) {
095:                            pageFactory = session
096:                                    .getPageFactory(((IPageRequestTarget) requestTarget)
097:                                            .getPage());
098:                        } else {
099:                            pageFactory = session.getPageFactory();
100:                        }
101:                        requestCycle.setResponsePage(pageFactory
102:                                .newPage(internalErrorPageClass));
103:                    } else if (responseClass != ExceptionErrorPortletPage.class) {
104:                        // Show full details
105:                        requestCycle
106:                                .setResponsePage(new ExceptionErrorPortletPage(
107:                                        e, responsePage));
108:                    } else {
109:                        // give up while we're ahead!
110:                        throw new WicketRuntimeException(
111:                                "Internal Error: Could not render error page "
112:                                        + internalErrorPageClass, e);
113:                    }
114:                }
115:            }
116:
117:            /**
118:             * This method is called when a runtime exception is thrown, just before the
119:             * actual handling of the runtime exception. This implemention passes the
120:             * call through to
121:             * {@link RequestCycle#onRuntimeException(Page, RuntimeException)}. Note
122:             * that if you override this method or provide a whole new implementation of
123:             * {@link IExceptionResponseStrategy} alltogether,
124:             * {@link RequestCycle#onRuntimeException(Page, RuntimeException)} will not
125:             * be supported.
126:             * 
127:             * @param page
128:             *            Any page context where the exception was thrown
129:             * @param e
130:             *            The exception
131:             * @return Any error page to redirect to
132:             */
133:            protected Page onRuntimeException(final Page page,
134:                    final RuntimeException e) {
135:                return RequestCycle.get().onRuntimeException(page, e);
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.