Source Code Cross Referenced for HookAction.java in  » Workflow-Engines » bonita-v3.1 » hero » struts » 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 » Workflow Engines » bonita v3.1 » hero.struts.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package hero.struts.actions;
002:
003:        import java.io.IOException;
004:        import javax.servlet.ServletException;
005:        import javax.servlet.http.HttpServletRequest;
006:        import javax.servlet.http.HttpSession;
007:        import javax.servlet.http.HttpServletResponse;
008:        import org.apache.struts.action.ActionError;
009:        import org.apache.struts.action.ActionErrors;
010:        import org.apache.struts.action.ActionForm;
011:        import org.apache.struts.action.ActionMapping;
012:        import org.apache.struts.action.ActionForward;
013:        import hero.struts.forms.*;
014:        import hero.interfaces.*;
015:        import java.util.Vector;
016:
017:        /**
018:         * <strong>HookAction</strong>
019:         * Action that allows the user to add a new hook.
020:         * This action can be forward project or activity pages
021:         *
022:         *@author valdes@loria.fr
023:         */
024:        public class HookAction extends AbstStrutsActionBase {
025:
026:            public boolean authenticate(String username, String password) {
027:                return (true);
028:            }
029:
030:            /**
031:             * @param mapping The ActionMapping used to select this instance
032:             * @param actionForm The optional AbstActionFormBase bean for this request (if any)
033:             * @param request The HTTP request we are processing
034:             * @param response The HTTP response we are creating
035:             * @exception IOException if an input/output error occurs
036:             * @exception ServletException if a servlet exception occurs
037:             */
038:            public ActionForward perform(ActionMapping mapping,
039:                    ActionForm form, HttpServletRequest request,
040:                    HttpServletResponse response) throws IOException,
041:                    ServletException {
042:
043:                // Create the container for any errors that occur
044:                ActionErrors errors = new ActionErrors();
045:                ActionForward actionForward = mapping.findForward(EDITACTIVITY);
046:
047:                String action = request.getParameter("hookAction");
048:                String hookName = request.getParameter("name");
049:                HttpSession session = request.getSession();
050:                String project = (String) session.getAttribute("projectname");
051:                try {
052:                    hero.interfaces.ProjectSessionLocalHome projecth = (ProjectSessionLocalHome) hero.interfaces.ProjectSessionUtil
053:                            .getLocalHome();
054:                    hero.interfaces.ProjectSessionLocal projectsession = projecth
055:                            .create();
056:                    projectsession.initProject(project);
057:
058:                    if (!isCancelled(request)) {
059:                        if (action.equals("EditNode")
060:                                || action.equals("EditNode2")) {
061:                            request.getSession(true).setAttribute("inter",
062:                                    "false");
063:                            // Forward control to the specified 'success' URI specified in the structs-config.xml
064:                            actionForward = mapping.findForward(EDITACTIVITY);
065:                        }
066:                        if (action.equals("Edit") || action.equals("Edit2")) {
067:                            request.getSession(true).setAttribute("inter",
068:                                    "false");
069:                            // Forward control to the specified 'success' URI specified in the structs-config.xml
070:                            actionForward = mapping.findForward(CONFIGPROJECT);
071:                        }
072:                        if (action.equals("AddNode")) {
073:                            String name = (String) session
074:                                    .getAttribute("nodename");
075:                            String event = request.getParameter("event");
076:                            String type = request.getParameter("type");
077:                            if (hookName.length() != 0 && event.length() != 0) {
078:                                int hookType = 0;
079:                                if (type.equals("Java"))
080:                                    hookType = 0;
081:                                if (type.equals("Tcl"))
082:                                    hookType = 4;
083:                                if (type.equals("BeanShell"))
084:                                    hookType = 5;
085:
086:                                projectsession.addNodeHook(name, hookName,
087:                                        event, hookType);
088:                                request.getSession(true).setAttribute("node",
089:                                        projectsession.getStrutsNode(name));
090:                            } else
091:                                errors.add("hook_error", new ActionError(
092:                                        "error.hookparameter.mismatch"));
093:                            // Forward control to the specified 'success' URI specified in the structs-config.xml
094:                            actionForward = mapping.findForward(EDITACTIVITY);
095:                        }
096:                        if (action.equals("AddNode2")) {
097:                            String name = (String) session
098:                                    .getAttribute("nodename");
099:                            String event = request.getParameter("event");
100:                            String type = request.getParameter("type");
101:
102:                            if (hookName.length() != 0 && event.length() != 0) {
103:                                int hookType = 0;
104:                                String firstValue = "";
105:                                if (type.equals("InteractionBS"))
106:                                    hookType = 6;
107:
108:                                if (event.equals("afterStart"))
109:                                    firstValue = Constants.AFTERSTART;
110:                                if (event.equals("beforeStart"))
111:                                    firstValue = Constants.BEFORESTART;
112:                                if (event.equals("afterTerminate"))
113:                                    firstValue = Constants.AFTERTERMINATE;
114:                                if (event.equals("beforeTerminate"))
115:                                    firstValue = Constants.BEFORETERMINATE;
116:                                if (event.equals("anticipate"))
117:                                    firstValue = Constants.ANTICIPATE;
118:                                if (event.equals("onCancel"))
119:                                    firstValue = Constants.ONCANCEL;
120:
121:                                projectsession.addNodeInterHook(name, hookName,
122:                                        event, hookType, firstValue);
123:                                request.getSession(true).setAttribute("node",
124:                                        projectsession.getStrutsNode(name));
125:                                request.getSession(true).setAttribute(
126:                                        "hookName", hookName);
127:                                HookForm hookForm = (HookForm) form;
128:                                hookForm.setValue(firstValue);
129:                                Vector interhooks = new Vector(projectsession
130:                                        .getNodeInterHooks(name));
131:                                request.getSession(true).setAttribute(
132:                                        "interhooks", interhooks);
133:                            } else
134:                                errors.add("hook_error", new ActionError(
135:                                        "error.interhook.mismatch"));
136:                            // Forward control to the specified 'success' URI specified in the structs-config.xml
137:                            actionForward = mapping.findForward(EDITACTIVITY);
138:                            request.getSession(true).setAttribute("inter",
139:                                    "true");
140:                        }
141:                        if (action.equals("editScript")) {
142:                            request.getSession(true).setAttribute("inter",
143:                                    "false");
144:                            String name = (String) session
145:                                    .getAttribute("nodename");
146:                            request.getSession(true).setAttribute(
147:                                    "scri",
148:                                    projectsession.getNodeInterHookValue(name,
149:                                            hookName));
150:                            request.getSession(true).setAttribute("hoName",
151:                                    hookName);
152:                            actionForward = mapping.findForward(EDITACTIVITY);
153:                        }
154:                        if (action.equals("addEditScript")) {
155:                            request.getSession(true).setAttribute("inter",
156:                                    "false");
157:                            HookForm hookForm = (HookForm) form;
158:                            String value = hookForm.getValue();
159:                            request.getSession(true).setAttribute("val",
160:                                    hookForm.getValue());
161:                            String name = (String) session
162:                                    .getAttribute("nodename");
163:                            hookName = (String) request.getSession(true)
164:                                    .getAttribute("hoName");
165:                            projectsession.setNodeInterHookValue(name,
166:                                    hookName, value);
167:                            Vector interhooks = new Vector(projectsession
168:                                    .getNodeInterHooks(name));
169:                            request.getSession(true).setAttribute("interhooks",
170:                                    interhooks);
171:                            actionForward = mapping.findForward(EDITACTIVITY);
172:                        }
173:
174:                        if (action.equals("editProjectScript")) {
175:                            request.getSession(true).setAttribute("inter",
176:                                    "false");
177:                            request.getSession(true).setAttribute("scri",
178:                                    projectsession.getInterHookValue(hookName));
179:                            request.getSession(true).setAttribute("hoName",
180:                                    hookName);
181:                            request.getSession(true).setAttribute("project",
182:                                    projectsession);
183:                            System.out.println("PROJECTSEEION");
184:                            System.out.println(projectsession);
185:                            actionForward = mapping.findForward(CONFIGPROJECT);
186:                        }
187:                        if (action.equals("addEditProjectScript")) {
188:                            HookForm hookFo = (HookForm) form;
189:                            String value = hookFo.getValue();
190:                            hookName = (String) request.getSession(true)
191:                                    .getAttribute("hoName");
192:                            request.getSession(true).setAttribute("inter",
193:                                    "false");
194:                            projectsession.setInterHookValue(hookName, value);
195:                            session.setAttribute("interHooks", new Vector(
196:                                    projectsession.getInterHooks()));
197:                            actionForward = mapping.findForward(CONFIGPROJECT);
198:                        }
199:
200:                        if (action.equals("AddNodeHook")) {
201:                            HookForm hookForm = (HookForm) form;
202:                            String value = hookForm.getValue();
203:                            String name = (String) session
204:                                    .getAttribute("nodename");
205:                            hookName = (String) request.getSession(true)
206:                                    .getAttribute("hookName");
207:                            try {
208:                                projectsession.setNodeInterHookValue(name,
209:                                        hookName, value);
210:                                request.getSession(true).setAttribute("node",
211:                                        projectsession.getStrutsNode(name));
212:                            } catch (NumberFormatException etype) {
213:                                errors.add("hook_error", new ActionError(
214:                                        "error.hooktype.mismatch"));
215:                            }
216:                            request.getSession(true).setAttribute("inter",
217:                                    "false");
218:                            actionForward = mapping.findForward(EDITACTIVITY);
219:                        }
220:                        if (action.equals("AddHook")) {
221:                            HookForm hookForm = (HookForm) form;
222:                            String value = hookForm.getValue();
223:                            hookName = (String) request.getSession(true)
224:                                    .getAttribute("hookName");
225:                            try {
226:                                projectsession.setInterHookValue(hookName,
227:                                        value);
228:                                request.getSession(true).setAttribute(
229:                                        "project", projectsession);
230:                                session.setAttribute("interHooks", new Vector(
231:                                        projectsession.getInterHooks()));
232:                            } catch (NumberFormatException etype) {
233:                                errors.add("hook_error", new ActionError(
234:                                        "error.hooktype.mismatch"));
235:                            }
236:                            request.getSession(true).setAttribute("inter",
237:                                    "false");
238:                            actionForward = mapping.findForward(CONFIGPROJECT);
239:                        }
240:                        if (action.equals("Add")) {
241:                            String event = request.getParameter("event");
242:                            String type = request.getParameter("type");
243:                            if (hookName.length() != 0 && event.length() != 0) {
244:                                int hookType = 0;
245:                                if (type.equals("Java"))
246:                                    hookType = 0;
247:                                if (type.equals("Tcl"))
248:                                    hookType = 4;
249:                                if (type.equals("BeanShell"))
250:                                    hookType = 5;
251:
252:                                projectsession.addHook(hookName, event,
253:                                        hookType);
254:                                request.getSession(true).setAttribute(
255:                                        "project", projectsession);
256:                            } else
257:                                errors.add("hook_error", new ActionError(
258:                                        "error.hookparameter.mismatch"));
259:                            // Forward control to the specified 'success' URI specified in the structs-config.xml
260:                            actionForward = mapping.findForward(CONFIGPROJECT);
261:                        }
262:                        if (action.equals("Add2")) {
263:                            String event = request.getParameter("event");
264:                            String type = request.getParameter("type");
265:
266:                            if (hookName.length() != 0 && event.length() != 0) {
267:                                int hookType = 0;
268:                                String firstValue = "";
269:                                if (type.equals("InteractionBS"))
270:                                    hookType = 6;
271:
272:                                if (event.equals("afterStart"))
273:                                    firstValue = Constants.AFTERSTART;
274:                                if (event.equals("beforeStart"))
275:                                    firstValue = Constants.BEFORESTART;
276:                                if (event.equals("afterTerminate"))
277:                                    firstValue = Constants.AFTERTERMINATE;
278:                                if (event.equals("beforeTerminate"))
279:                                    firstValue = Constants.BEFORETERMINATE;
280:                                if (event.equals("onCancel"))
281:                                    firstValue = Constants.ONCANCEL;
282:                                if (event.equals("anticipate"))
283:                                    firstValue = Constants.ANTICIPATE;
284:
285:                                projectsession.addInterHook(hookName, event,
286:                                        hookType, firstValue);
287:                                request.getSession(true).setAttribute(
288:                                        "project", projectsession);
289:                                request.getSession(true).setAttribute(
290:                                        "hookName", hookName);
291:                                HookForm hookForm = (HookForm) form;
292:                                hookForm.setValue(firstValue);
293:
294:                            } else
295:                                errors.add("hook_error", new ActionError(
296:                                        "error.interhook.mismatch"));
297:                            // Forward control to the specified 'success' URI specified in the structs-config.xml
298:                            session.setAttribute("interHooks", new Vector(
299:                                    projectsession.getInterHooks()));
300:                            actionForward = mapping.findForward(CONFIGPROJECT);
301:                            request.getSession(true).setAttribute("inter",
302:                                    "true");
303:                        }
304:                        if (action.equals("DeleteNode")) {
305:                            String name = (String) session
306:                                    .getAttribute("nodename");
307:                            projectsession.deleteNodeInterHook(name, hookName);
308:                            Vector interhooks = new Vector(projectsession
309:                                    .getNodeInterHooks(name));
310:                            request.getSession(true).setAttribute("interhooks",
311:                                    interhooks);
312:                            request.getSession(true).setAttribute("node",
313:                                    projectsession.getStrutsNode(name));
314:                            request.getSession(true).setAttribute("inter",
315:                                    "false");
316:                            // Forward control to the specified 'success' URI specified in the structs-config.xml
317:                            actionForward = mapping.findForward(EDITACTIVITY);
318:                        }
319:                        if (action.equals("Delete")) {
320:                            projectsession.deleteInterHook(hookName);
321:                            request.getSession(true).setAttribute("project",
322:                                    projectsession);
323:                            request.getSession(true).setAttribute("inter",
324:                                    "false");
325:                            // Forward control to the specified 'success' URI specified in the structs-config.xml
326:                            session.setAttribute("interHooks", new Vector(
327:                                    projectsession.getInterHooks()));
328:                            actionForward = mapping.findForward(CONFIGPROJECT);
329:                        }
330:                    } else if (action.equals("AddHook"))
331:                        actionForward = mapping.findForward(CONFIGPROJECT);
332:                    else if (action.equals("AddNodeHook"))
333:                        request.getSession(true).setAttribute("inter", "false");
334:                } catch (Exception e) {
335:                    errors.add("hook_error", new ActionError(
336:                            "error.interhook.mismatch"));
337:                    if (action.equals("Add") || action.equals("Add2"))
338:                        actionForward = mapping.findForward(CONFIGPROJECT);
339:                }
340:
341:                if (!errors.empty()) {
342:                    saveErrors(request, errors);
343:                }
344:                // Forward control to the appropriate URI as determined by the action.
345:                return (actionForward);
346:            }
347:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.