Source Code Cross Referenced for StrutsExceptionHandler.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » web » 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 » ERP CRM Financial » Kuali Financial System » edu.iu.uis.eden.web 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.web;
018:
019:        import java.util.Collection;
020:        import java.util.Iterator;
021:
022:        import javax.servlet.ServletException;
023:        import javax.servlet.http.HttpServletRequest;
024:        import javax.servlet.http.HttpServletResponse;
025:
026:        import org.apache.struts.Globals;
027:        import org.apache.struts.action.ActionForm;
028:        import org.apache.struts.action.ActionForward;
029:        import org.apache.struts.action.ActionMapping;
030:        import org.apache.struts.action.ActionMessage;
031:        import org.apache.struts.action.ActionMessages;
032:        import org.apache.struts.action.ExceptionHandler;
033:        import org.apache.struts.config.ExceptionConfig;
034:
035:        import edu.iu.uis.eden.WorkflowServiceError;
036:        import edu.iu.uis.eden.WorkflowServiceErrorException;
037:        import edu.iu.uis.eden.routetemplate.WorkflowAttributeValidationError;
038:        import edu.iu.uis.eden.validation.ValidationResult;
039:        import edu.iu.uis.eden.validation.ValidationResults;
040:
041:        /**
042:         * Catches exceptions throw from Workflow Actions If exception is of type 
043:         * WorkflowServiceErrorException any WorkflowServiceErrors saved on the exception 
044:         * are stripped off of the exception put into ActionMessages in the Error que and 
045:         * the request is directed back to the original ActionMapping input page. Other 
046:         * exceptions are logged and directed to the mapped jsp according to the
047:         * exception handler mapping.
048:         * 
049:         * @author rkirkend
050:         * @author temay
051:         * @author ewestfal
052:         */
053:        public class StrutsExceptionHandler extends ExceptionHandler {
054:
055:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
056:                    .getLogger(StrutsExceptionHandler.class);
057:
058:            public ActionForward execute(Exception e,
059:                    ExceptionConfig exceptionConfig, ActionMapping mapping,
060:                    ActionForm form, HttpServletRequest request,
061:                    HttpServletResponse response) throws ServletException {
062:
063:                if (e instanceof  WorkflowServiceErrorException
064:                        || e.getCause() instanceof  WorkflowServiceErrorException) {
065:                    WorkflowServiceErrorException serviceException = null;
066:                    if (!(e instanceof  WorkflowServiceErrorException)) {
067:                        serviceException = (WorkflowServiceErrorException) e
068:                                .getCause();
069:                    } else {
070:                        serviceException = (WorkflowServiceErrorException) e;
071:                    }
072:
073:                    Collection serviceErrors = serviceException
074:                            .getServiceErrors();
075:                    saveServiceErrors(serviceErrors, request);
076:                } else {
077:                    LOG.error(
078:                            "Mapping " + mapping.getPath() + " threw error: ",
079:                            e);
080:                    saveServiceErrors("general.workflow.error", e, request);
081:                }
082:
083:                if (mapping.getInputForward() != null
084:                        && mapping.getInputForward().getPath() != null) {
085:                    return mapping.getInputForward();
086:                } else if (request.getParameter("inputPage") != null
087:                        && request.getParameter("inputPage").length() > 0) {
088:                    mapping.setInput(request.getParameter("inputPage"));
089:                    return mapping.getInputForward();
090:                } else if (mapping.getPath() != null) {
091:                    return new ActionForward(mapping.getPath());
092:                } else {
093:                    request.setAttribute("WORKFLOW_ERROR", e.getMessage());
094:                    return mapping.findForward("WorkflowError");
095:                }
096:            }
097:
098:            protected void saveServiceErrors(Collection srvErrors,
099:                    HttpServletRequest request) {
100:                ActionMessages messages = new ActionMessages();
101:                Iterator errors = srvErrors.iterator();
102:                while (errors.hasNext()) {
103:                    Object errorObject = errors.next();
104:                    if (errorObject instanceof  WorkflowServiceError) {
105:                        WorkflowServiceError err = (WorkflowServiceError) errorObject;
106:                        if (err.getArg1() == null && err.getArg2() == null) {
107:                            messages.add(Globals.ERROR_KEY, new ActionMessage(
108:                                    err.getKey()));
109:                        } else if (err.getArg1() != null
110:                                && err.getArg2() == null) {
111:                            messages.add(Globals.ERROR_KEY, new ActionMessage(
112:                                    err.getKey(), err.getArg1()));
113:                        } else {
114:                            messages
115:                                    .add(Globals.ERROR_KEY, new ActionMessage(
116:                                            err.getKey(), err.getArg1(), err
117:                                                    .getArg2()));
118:                        }
119:                    } else if (errorObject instanceof  ValidationResults) {
120:                        ValidationResults results = (ValidationResults) errorObject;
121:                        for (Iterator iterator = results.getValidationResults()
122:                                .iterator(); iterator.hasNext();) {
123:                            ValidationResult result = (ValidationResult) iterator
124:                                    .next();
125:                            messages.add(Globals.ERROR_KEY,
126:                                    new ActionMessage("general.message", result
127:                                            .getErrorMessage()));
128:                        }
129:                    } else if (errorObject instanceof  WorkflowAttributeValidationError) {
130:                        WorkflowAttributeValidationError error = (WorkflowAttributeValidationError) errorObject;
131:                        messages.add(Globals.ERROR_KEY, new ActionMessage(error
132:                                .getKey(), error.getMessage()));
133:                    }
134:                }
135:                request.setAttribute("workflowServiceError", messages);
136:            }
137:
138:            protected void saveServiceErrors(String key, Exception e,
139:                    HttpServletRequest request) {
140:                ActionMessages messages = new ActionMessages();
141:                messages.add(Globals.ERROR_KEY, new ActionMessage(key, e
142:                        .getMessage()));
143:                request.setAttribute("exceptionError", messages);
144:            }
145:
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.