KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > service > webservice > HandlersDetailsAction


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id$
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.service.webservice;
27
28 import java.io.IOException JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.Collection JavaDoc;
31 import java.util.HashMap JavaDoc;
32
33 import javax.servlet.ServletException JavaDoc;
34 import javax.servlet.http.HttpServletRequest JavaDoc;
35 import javax.servlet.http.HttpServletResponse JavaDoc;
36
37 import org.allesta.wsabi.j2ee.Handler;
38 import org.allesta.wsabi.j2ee.PortComponent;
39 import org.allesta.wsabi.j2ee.WebServiceDescription;
40 import org.allesta.wsabi.j2ee.provider.GenericDomainCapableProvider;
41 import org.allesta.wsabi.j2ee.provider.jonas.JonasProvider;
42 import org.apache.struts.action.ActionForm;
43 import org.apache.struts.action.ActionForward;
44 import org.apache.struts.action.ActionMapping;
45 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
46 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
47
48 /**
49  * @author Vivek Lakshmanan
50  */

51
52 public class HandlersDetailsAction extends JonasBaseAction {
53
54     public ActionForward executeAction(ActionMapping p_Mapping,
55             ActionForm p_Form, HttpServletRequest JavaDoc p_Request,
56             HttpServletResponse JavaDoc p_Response) throws IOException JavaDoc,
57             ServletException JavaDoc {
58         // Id for the portcomponent selected by the user.
59
String JavaDoc wsPCId = p_Request.getParameter("pcselect");
60         // Selected web service description
61
String JavaDoc wsdId = p_Request.getParameter("wsdselect");
62         // Handler chosen by the user.
63
String JavaDoc handlerId = p_Request.getParameter("handlerselect");
64
65         try {
66             GenericDomainCapableProvider jonasProvider = new JonasProvider();
67             jonasProvider.initialize(m_WhereAreYou.getCurrentJonasServerName(),
68                     null);
69             WebServiceDescription wsd = jonasProvider
70                     .getWebServiceDescription(wsdId);
71             PortComponent pc = null;
72             int wsdPortComponentCount = wsd.getPortComponentCount();
73             // Find the port component selected by the user.
74
for (int i = 0; i < wsdPortComponentCount; i++) {
75                 if (wsPCId.equals(((PortComponent) wsd.getPortComponent(i))
76                         .getId())) {
77                     pc = (PortComponent) wsd.getPortComponent(i);
78                     break;
79                 }
80             }
81             Handler handler = null;
82             for (int i = 0; i < pc.getHandlerCount(); i++) {
83                 if (pc.getHandler(i).getId().equals(handlerId)) {
84                     handler = pc.getHandler(i);
85                 }
86             }
87             // HashMap to hold parameters for forwards to
88
// ActionPortComponentsDetails.
89
HashMap JavaDoc forwardMap = new HashMap JavaDoc();
90             forwardMap.put("pcselect", wsPCId);
91             forwardMap.put("wsdselect", wsdId);
92             p_Request.setAttribute("paramMap", forwardMap);
93
94             // Create ArrayLists for lists to be displayed about soap
95
// headers, soap roles and init-params.
96
ArrayList JavaDoc soapHeaders = new ArrayList JavaDoc();
97             for (int i = 0; i < handler.getSoapHeaderCount(); i++) {
98                 soapHeaders.add(handler.getSoapHeader(i).toString());
99             }
100
101             ArrayList JavaDoc soapRoles = new ArrayList JavaDoc();
102             for (int i = 0; i < handler.getSoapRoleCount(); i++) {
103                 soapRoles.add(handler.getSoapRole(i));
104             }
105
106             ArrayList JavaDoc initParams = new ArrayList JavaDoc();
107             for (int i = 0; i < handler.getInitParamCount(); i++) {
108                 initParams.add(handler.getInitParam(i));
109             }
110
111             p_Request.setAttribute("portComponent", pc);
112             p_Request.setAttribute("webServiceDescription", wsd);
113             p_Request.setAttribute("handler", handler);
114             p_Request.setAttribute("soapHeaders", soapHeaders);
115             p_Request.setAttribute("soapRoles", soapRoles);
116             p_Request.setAttribute("initParams", initParams);
117             // Force the node selected in tree
118
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
119                     + WhereAreYou.NODE_SEPARATOR + "services"
120                     + WhereAreYou.NODE_SEPARATOR + "WebService"
121                     + WhereAreYou.NODE_SEPARATOR + wsd.getId()
122                     + WhereAreYou.NODE_SEPARATOR + pc.getId()
123                     + WhereAreYou.NODE_SEPARATOR + handler.getId(), true);
124
125         } catch (Throwable JavaDoc t) {
126             addGlobalError(t);
127             saveErrors(p_Request, m_Errors);
128             return (p_Mapping.findForward("Global Error"));
129         }
130
131         // Forward to jsp.
132
return (p_Mapping.findForward("Handlers Details"));
133     }
134
135 }
136
Popular Tags