Source Code Cross Referenced for JSPManager.java in  » Content-Management-System » dspace » org » dspace » app » webui » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » dspace » org.dspace.app.webui.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JSPManager.java
003:         *
004:         * Version: $Revision: 1671 $
005:         *
006:         * Date: $Date: 2006-11-10 16:26:30 -0600 (Fri, 10 Nov 2006) $
007:         *
008:         * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
009:         * Institute of Technology.  All rights reserved.
010:         *
011:         * Redistribution and use in source and binary forms, with or without
012:         * modification, are permitted provided that the following conditions are
013:         * met:
014:         *
015:         * - Redistributions of source code must retain the above copyright
016:         * notice, this list of conditions and the following disclaimer.
017:         *
018:         * - Redistributions in binary form must reproduce the above copyright
019:         * notice, this list of conditions and the following disclaimer in the
020:         * documentation and/or other materials provided with the distribution.
021:         *
022:         * - Neither the name of the Hewlett-Packard Company nor the name of the
023:         * Massachusetts Institute of Technology nor the names of their
024:         * contributors may be used to endorse or promote products derived from
025:         * this software without specific prior written permission.
026:         *
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028:         * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031:         * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033:         * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034:         * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036:         * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037:         * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038:         * DAMAGE.
039:         */
040:        package org.dspace.app.webui.util;
041:
042:        import java.io.IOException;
043:
044:        import javax.servlet.ServletException;
045:        import javax.servlet.http.HttpServletRequest;
046:        import javax.servlet.http.HttpServletResponse;
047:
048:        import org.apache.log4j.Logger;
049:        import org.dspace.authorize.AuthorizeException;
050:        import org.dspace.core.Context;
051:        import org.dspace.core.LogManager;
052:
053:        /**
054:         * Methods for displaying UI pages to the user.
055:         * 
056:         * @author Robert Tansley
057:         * @version $Revision: 1671 $
058:         */
059:        public class JSPManager {
060:            /*
061:             * All displaying of UI pages should be performed using this manager for
062:             * future-proofing, since any future localisation effort will probably use
063:             * this manager.
064:             */
065:
066:            /** log4j logger */
067:            private static Logger log = Logger.getLogger(JSPManager.class);
068:
069:            /**
070:             * Forwards control of the request to the display JSP passed in.
071:             * 
072:             * @param request
073:             *            current servlet request object
074:             * @param response
075:             *            current servlet response object
076:             * @param jsp
077:             *            the JSP page to display, relative to the webapps directory
078:             */
079:            public static void showJSP(HttpServletRequest request,
080:                    HttpServletResponse response, String jsp)
081:                    throws ServletException, IOException {
082:                if (log.isDebugEnabled()) {
083:                    log.debug(LogManager.getHeader((Context) request
084:                            .getAttribute("dspace.context"), "view_jsp", jsp));
085:                }
086:
087:                // For the moment, a simple forward
088:                request.getRequestDispatcher(jsp).forward(request, response);
089:            }
090:
091:            /**
092:             * Display an internal server error message - for example, a database error
093:             * 
094:             * @param request
095:             *            the HTTP request
096:             * @param response
097:             *            the HTTP response
098:             */
099:            public static void showInternalError(HttpServletRequest request,
100:                    HttpServletResponse response) throws ServletException,
101:                    IOException {
102:                response
103:                        .setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
104:                showJSP(request, response, "/error/internal.jsp");
105:            }
106:
107:            /**
108:             * Display an integrity error message. Use when the POSTed data from a
109:             * request doesn't make sense.
110:             * 
111:             * @param request
112:             *            the HTTP request
113:             * @param response
114:             *            the HTTP response
115:             */
116:            public static void showIntegrityError(HttpServletRequest request,
117:                    HttpServletResponse response) throws ServletException,
118:                    IOException {
119:                response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
120:                showJSP(request, response, "/error/integrity.jsp");
121:            }
122:
123:            /**
124:             * Display an authorization failed error message. The exception should be
125:             * passed in if possible so that the error message can be descriptive.
126:             * 
127:             * @param request
128:             *            the HTTP request
129:             * @param response
130:             *            the HTTP response
131:             * @param exception
132:             *            the AuthorizeException leading to this error, passing in
133:             *            <code>null</code> will display default error message
134:             */
135:            public static void showAuthorizeError(HttpServletRequest request,
136:                    HttpServletResponse response, AuthorizeException exception)
137:                    throws ServletException, IOException {
138:                // FIXME: Need to work out which error message to display?
139:                response.setStatus(HttpServletResponse.SC_FORBIDDEN);
140:                showJSP(request, response, "/error/authorize.jsp");
141:            }
142:
143:            /**
144:             * Display an "invalid ID" error message. Passing in information about the
145:             * bad ID and what the ID was supposed to represent (collection etc.) should
146:             * result in a more descriptive and helpful error message.
147:             * 
148:             * @param request
149:             *            the HTTP request
150:             * @param response
151:             *            the HTTP response
152:             * @param badID
153:             *            the bad identifier, or <code>null</code>
154:             * @param type
155:             *            the type of object, from
156:             *            <code>org.dspace.core.Constants</code>, or <code>-1</code>
157:             *            for a default message
158:             */
159:            public static void showInvalidIDError(HttpServletRequest request,
160:                    HttpServletResponse response, String badID, int type)
161:                    throws ServletException, IOException {
162:                request.setAttribute("bad.id", badID);
163:                response.setStatus(HttpServletResponse.SC_NOT_FOUND);
164:
165:                if (type != -1) {
166:                    request.setAttribute("bad.type", new Integer(type));
167:                }
168:
169:                showJSP(request, response, "/error/invalid-id.jsp");
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.