001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id$
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.webservice;
027:
028: import java.io.IOException;
029: import java.util.ArrayList;
030: import java.util.Collection;
031: import java.util.HashMap;
032:
033: import javax.servlet.ServletException;
034: import javax.servlet.http.HttpServletRequest;
035: import javax.servlet.http.HttpServletResponse;
036:
037: import org.allesta.wsabi.j2ee.Handler;
038: import org.allesta.wsabi.j2ee.PortComponent;
039: import org.allesta.wsabi.j2ee.WebServiceDescription;
040: import org.allesta.wsabi.j2ee.provider.GenericDomainCapableProvider;
041: import org.allesta.wsabi.j2ee.provider.jonas.JonasProvider;
042: import org.apache.struts.action.ActionForm;
043: import org.apache.struts.action.ActionForward;
044: import org.apache.struts.action.ActionMapping;
045: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
046: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
047:
048: /**
049: * @author Vivek Lakshmanan
050: */
051:
052: public class HandlersDetailsAction extends JonasBaseAction {
053:
054: public ActionForward executeAction(ActionMapping p_Mapping,
055: ActionForm p_Form, HttpServletRequest p_Request,
056: HttpServletResponse p_Response) throws IOException,
057: ServletException {
058: // Id for the portcomponent selected by the user.
059: String wsPCId = p_Request.getParameter("pcselect");
060: // Selected web service description
061: String wsdId = p_Request.getParameter("wsdselect");
062: // Handler chosen by the user.
063: String handlerId = p_Request.getParameter("handlerselect");
064:
065: try {
066: GenericDomainCapableProvider jonasProvider = new JonasProvider();
067: jonasProvider.initialize(m_WhereAreYou
068: .getCurrentJonasServerName(), null);
069: WebServiceDescription wsd = jonasProvider
070: .getWebServiceDescription(wsdId);
071: PortComponent pc = null;
072: int wsdPortComponentCount = wsd.getPortComponentCount();
073: // Find the port component selected by the user.
074: for (int i = 0; i < wsdPortComponentCount; i++) {
075: if (wsPCId.equals(((PortComponent) wsd
076: .getPortComponent(i)).getId())) {
077: pc = (PortComponent) wsd.getPortComponent(i);
078: break;
079: }
080: }
081: Handler handler = null;
082: for (int i = 0; i < pc.getHandlerCount(); i++) {
083: if (pc.getHandler(i).getId().equals(handlerId)) {
084: handler = pc.getHandler(i);
085: }
086: }
087: // HashMap to hold parameters for forwards to
088: // ActionPortComponentsDetails.
089: HashMap forwardMap = new HashMap();
090: forwardMap.put("pcselect", wsPCId);
091: forwardMap.put("wsdselect", wsdId);
092: p_Request.setAttribute("paramMap", forwardMap);
093:
094: // Create ArrayLists for lists to be displayed about soap
095: // headers, soap roles and init-params.
096: ArrayList soapHeaders = new ArrayList();
097: for (int i = 0; i < handler.getSoapHeaderCount(); i++) {
098: soapHeaders.add(handler.getSoapHeader(i).toString());
099: }
100:
101: ArrayList soapRoles = new ArrayList();
102: for (int i = 0; i < handler.getSoapRoleCount(); i++) {
103: soapRoles.add(handler.getSoapRole(i));
104: }
105:
106: ArrayList initParams = new ArrayList();
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(
119: getTreeBranchName(DEPTH_SERVER)
120: + WhereAreYou.NODE_SEPARATOR + "services"
121: + WhereAreYou.NODE_SEPARATOR + "WebService"
122: + WhereAreYou.NODE_SEPARATOR + wsd.getId()
123: + WhereAreYou.NODE_SEPARATOR + pc.getId()
124: + WhereAreYou.NODE_SEPARATOR
125: + handler.getId(), true);
126:
127: } catch (Throwable t) {
128: addGlobalError(t);
129: saveErrors(p_Request, m_Errors);
130: return (p_Mapping.findForward("Global Error"));
131: }
132:
133: // Forward to jsp.
134: return (p_Mapping.findForward("Handlers Details"));
135: }
136:
137: }
|