Source Code Cross Referenced for DefaultAction.java in  » Portal » mypersonalizer » es » udc » mypersonalizer » kernel » controller » actions » 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 » Portal » mypersonalizer » es.udc.mypersonalizer.kernel.controller.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /export/home/cvsroot/MyPersonalizerRepository/MyPersonalizer/Subsystems/Kernel/Sources/es/udc/mypersonalizer/kernel/controller/actions/DefaultAction.java,v 1.1.1.1 2004/03/25 12:08:38 fbellas Exp $
003:         * $Revision: 1.1.1.1 $
004:         * $Date: 2004/03/25 12:08:38 $
005:         *
006:         * =============================================================================
007:         *
008:         * Copyright (c) 2003, The MyPersonalizer Development Group
009:         * (http://www.tic.udc.es/~fbellas/mypersonalizer/index.html) at 
010:         * University Of A Coruna
011:         * All rights reserved.
012:         *
013:         * Redistribution and use in source and binary forms, with or without
014:         * modification, are permitted provided that the following conditions are met:
015:         *
016:         *  - Redistributions of source code must retain the above copyright notice, 
017:         *    this list of conditions and the following disclaimer.
018:         *
019:         *  - Redistributions in binary form must reproduce the above copyright notice,
020:         *    this list of conditions and the following disclaimer in the documentation
021:         *    and/or other materials provided with the distribution.
022:         *
023:         *  - Neither the name of the University Of A Coruna nor the names of its 
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 "AS IS" 
028:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
029:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
030:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
031:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
032:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
033:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
034:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
035:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
036:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
037:         * POSSIBILITY OF SUCH DAMAGE.
038:         *
039:         */
040:
041:        package es.udc.mypersonalizer.kernel.controller.actions;
042:
043:        import javax.servlet.http.HttpServletRequest;
044:        import javax.servlet.http.HttpServletResponse;
045:        import org.apache.struts.action.Action;
046:        import org.apache.struts.action.ActionForm;
047:        import org.apache.struts.action.ActionForward;
048:        import org.apache.struts.action.ActionMapping;
049:
050:        import es.udc.mypersonalizer.kernel.log.Log;
051:        import es.udc.mypersonalizer.kernel.log.LogManager;
052:        import es.udc.mypersonalizer.kernel.log.LogNamingConventions;
053:        import es.udc.mypersonalizer.kernel.util.exceptions.IllegalConcurrentAccessException;
054:
055:        /**
056:         * Template action for stuts action classes that implements some of
057:         * the functionality needed for all subclasses like exception handling. <p>
058:         * 
059:         * If during execution of the action, an 
060:         * <code>IllegalConcurrentAccessException</code> is thrown, it tries to find an
061:         * <code>ActionForward</code> with name "IllegalConcurrentAccess" and returns it. 
062:         * In case of any other exception, it tries to find an
063:         * <code>ActionForward</code> with name "InternalError" and returns it.
064:         * 
065:         * @author Daniel Fernandez
066:         * @author Fernando Bellas
067:         * @since 1.0
068:         */
069:        public abstract class DefaultAction extends Action {
070:
071:            /** 
072:             * The global forward name for the Illegal Concurrent Access page.<p>
073:             * This name must be "IllegalConcurrentAccess".
074:             */
075:            public static final String ILLEGAL_CONCURRENT_ACCESS_GLOBAL_FORWARD = "IllegalConcurrentAccess";
076:
077:            /** 
078:             * The global forward name for the Internal Error page.<p>
079:             * This name must be "InternalError".
080:             */
081:            public static final String INTERNAL_ERROR_GLOBAL_FORWARD = "InternalError";
082:
083:            /** 
084:             * The per-action forward name for the success page. If an action is able to
085:             * execute all of its tasks correctly, it performs a forward to the
086:             * mandatory struts forward named "Success".<p>
087:             *
088:             * Every controller action must have a forward named "Success".
089:             */
090:            public static final String ACTION_SUCCESS_FORWARD = "Success";
091:
092:            /** 
093:             * The per-action forward name for the fail page. This forward is needed
094:             * in case an action can fail (without generation an exception). For 
095:             * example, due to a bad data input, the user should have to be informed
096:             * of the problem without generating an exception, just a warning of any
097:             * kind.<p>
098:             * This forward identifies the page which will report the errors, and
099:             * only actions which can fail without generating severe exception 
100:             * conditions must define it.
101:             */
102:            public static final String ACTION_FAIL_FORWARD = "Fail";
103:
104:            /**
105:             * This is the path of the action that executes MainPageAction.<p>
106:             * Must be set to "/MainPage.do"
107:             */
108:            public static final String MAIN_PAGE_FORWARD_PATH = "/MainPage.do";
109:
110:            /**
111:             * Default prefix for error messages keys in localized resource files.<p>
112:             *
113:             * This prefix is "<code>ErrorMessages.</code>".
114:             */
115:            public static final String ERROR_MESSAGES_PREFIX = "ErrorMessages.";
116:
117:            /**
118:             * The mypersonalizer log name. 
119:             */
120:            private static final String MYPERSONALIZER_LOG_NAME = LogNamingConventions.MYPERSONALIZER;
121:
122:            /**
123:             * Executes an action calling doExecute. If an exception is 
124:             * thrown, it executes doOnError.
125:             * 
126:             * @return an ActionForward with the result of the action
127:             * @param mapping the action's ActionMapping
128:             * @param form the ActionForm associatied with this class
129:             * @param request the request object
130:             * @param response the response object
131:             */
132:            public ActionForward execute(ActionMapping mapping,
133:                    ActionForm form, HttpServletRequest request,
134:                    HttpServletResponse response) {
135:
136:                ActionForward actionForward = null;
137:
138:                try {
139:                    actionForward = doExecute(mapping, form, request, response);
140:                } catch (Exception e) {
141:                    actionForward = doOnError(mapping, form, request, response,
142:                            e);
143:                }
144:
145:                return actionForward;
146:            }
147:
148:            /**
149:             * Executes the action
150:             * 
151:             * @return an ActionForward with the result of the action
152:             * @param mapping the action's ActionMapping
153:             * @param form the ActionForm associatied with this class
154:             * @param request the request object
155:             * @param response the response object
156:             * @throws Exception Any exception can be thrown by the action. However,
157:             *      it is recommended to handle all exceptions and provide meaningful
158:             *      information to the final user.
159:             */
160:            protected abstract ActionForward doExecute(ActionMapping mapping,
161:                    ActionForm form, HttpServletRequest request,
162:                    HttpServletResponse response) throws Exception;
163:
164:            /**
165:             * Performs whichever necessary actions to handle an exception
166:             * thrown during execution
167:             * 
168:             * @return an ActionForward with exception-handling page
169:             * @param mapping the action's ActionMapping
170:             * @param form the ActionForm associatied with this class
171:             * @param request the request object
172:             * @param response the response object
173:             * @param exception the exception to process
174:             */
175:            protected ActionForward doOnError(ActionMapping mapping,
176:                    ActionForm form, HttpServletRequest request,
177:                    HttpServletResponse response, Exception exception) {
178:
179:                Log mypersonalizerLog = LogManager
180:                        .getLog(MYPERSONALIZER_LOG_NAME);
181:
182:                request.setAttribute("exception", exception);
183:
184:                if (exception instanceof  IllegalConcurrentAccessException) {
185:
186:                    mypersonalizerLog.write(
187:                            "An illegal concurrent access happened", exception,
188:                            this .getClass());
189:
190:                    return mapping
191:                            .findForward(ILLEGAL_CONCURRENT_ACCESS_GLOBAL_FORWARD);
192:
193:                } else {
194:
195:                    mypersonalizerLog.write("An internal error happened",
196:                            exception, this.getClass());
197:
198:                    return mapping.findForward(INTERNAL_ERROR_GLOBAL_FORWARD);
199:
200:                }
201:            }
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.