| CODENOTIFIER | HelpYou are not signed inSign in |
Project: PEtALS
Revision: 8840
Author: mcarpentier
Date: 06 Aug 2008 12:44:08
Changes:Added an ajax sample client for the webconsole
Files:| ... | ...@@ -0,0 +1,2 @@ | |
| 1 | -remove this temp folder from SVN, and make svn embed the channelclient | |
| 2 | -make the channel client port settable, and build a page in the webconsole so users can configure the channelclient access. | |
| 0 | 3 | \ No newline at end of file |
| ... | ...@@ -0,0 +1,15 @@ | |
| 1 | <%@page import="org.ow2.petals.tools.webadmin.ui.infra.session.AdminSession"%> | |
| 2 | <%@page import="org.ow2.petals.tools.webadmin.ui.infra.bean.InfoBean"%> | |
| 3 | ||
| 4 | <% AdminSession aS = AdminSession.getAdminSession(request.getSession()); | |
| 5 | if (aS.getInfoBean().hasInfo()) {%> | |
| 6 | <script> | |
| 7 | var msg = '<%=aS.getInfoBean().getMessage()%>'; | |
| 8 | if (msg != '') { | |
| 9 | alert(msg); | |
| 10 | } | |
| 11 | </script> | |
| 12 | <%aS.getInfoBean().reset(); %> | |
| 13 | <% | |
| 14 | } | |
| 15 | %> | |
| 0 | 16 | \ No newline at end of file |
| ... | ...@@ -41,9 +41,14 @@ | |
| 41 | 41 | <dependency> |
| 42 | 42 | <groupId>org.ow2.petals</groupId> |
| 43 | 43 | <artifactId>petals-datacollector</artifactId> |
| 44 | <version>1.1</version> | |
| 44 | <version>1.2-SNAPSHOT</version> | |
| 45 | 45 | </dependency> |
| 46 | ||
| 46 | <dependency> | |
| 47 | <groupId>org.ow2.petals</groupId> | |
| 48 | <artifactId>petals-channelclient-jmxclient</artifactId> | |
| 49 | <version>1.0-SNAPSHOT</version> | |
| 50 | </dependency> | |
| 51 | ||
| 47 | 52 | <!-- JuddiAdmin --> |
| 48 | 53 | <dependency> |
| 49 | 54 | <groupId>juddi.jaxr</groupId> |
| ... | ...@@ -138,7 +143,15 @@ | |
| 138 | 143 | <groupId>log4j</groupId> |
| 139 | 144 | <artifactId>log4j</artifactId> |
| 140 | 145 | <version>1.2.14</version> |
| 141 | </dependency> | |
| 146 | </dependency> | |
| 147 | ||
| 148 | <!-- Ajax : DWR --> | |
| 149 | <dependency> | |
| 150 | <groupId>org.directwebremoting</groupId> | |
| 151 | <artifactId>dwr</artifactId> | |
| 152 | <version>3.0.M1</version> | |
| 153 | </dependency> | |
| 154 | ||
| 142 | 155 | |
| 143 | 156 | <!-- Tests --> |
| 144 | 157 | <dependency> |
| ... | ...@@ -0,0 +1,67 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2008 EBM WebSourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | * ------------------------------------------------------------------------- | |
| 19 | * $Id$ | |
| 20 | * ------------------------------------------------------------------------- | |
| 21 | */ | |
| 22 | ||
| 23 | package org.ow2.petals.tools.webadmin.util; | |
| 24 | ||
| 25 | import org.ow2.petals.tools.webadmin.datacollector.exception.DataCollectorException; | |
| 26 | ||
| 27 | /** | |
| 28 | * Deals with all exceptions raised by the channel client helper | |
| 29 | * | |
| 30 | * @author mcarpentier - EBM WebSourcing | |
| 31 | * | |
| 32 | */ | |
| 33 | public class ChannelClientHelperException extends DataCollectorException { | |
| 34 | ||
| 35 | private static final long serialVersionUID = 1L; | |
| 36 | ||
| 37 | public ChannelClientHelperException() { | |
| 38 | super(); | |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * @param message | |
| 43 | * the raw message explaining the cause of the error | |
| 44 | */ | |
| 45 | public ChannelClientHelperException(String message) { | |
| 46 | super(message); | |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * @param message | |
| 51 | * the raw message explaining the cause of the error | |
| 52 | * @param e | |
| 53 | * the exception | |
| 54 | */ | |
| 55 | public ChannelClientHelperException(String message, Throwable e) { | |
| 56 | super(message, e); | |
| 57 | } | |
| 58 | ||
| 59 | /** | |
| 60 | * @param e | |
| 61 | * the exception | |
| 62 | */ | |
| 63 | public ChannelClientHelperException(Throwable e) { | |
| 64 | super(e); | |
| 65 | } | |
| 66 | ||
| 67 | } |
| ... | ...@@ -1,3 +1,23 @@ | |
| 1 | function getInstance(objId) { | |
| 2 | // Retourne un pointeur sur l'objet DOM, retourne false si l'objet n'existe pas | |
| 3 | if(document.getElementById) return document.getElementById(objId); | |
| 4 | else if(document.all) return document.all[objId]; | |
| 5 | else return false; | |
| 6 | } | |
| 7 | ||
| 8 | function DOM() { | |
| 9 | var elements = new Array(); | |
| 10 | for (var i = 0; i < arguments.length; i++) { | |
| 11 | var element = arguments[i]; | |
| 12 | if (typeof element == 'string') | |
| 13 | element = getInstance(element); | |
| 14 | if (arguments.length == 1) | |
| 15 | return element; | |
| 16 | elements.push(element); | |
| 17 | } | |
| 18 | return elements; | |
| 19 | } | |
| 20 | ||
| 1 | 21 | function openClose(id,mode) |
| 2 | 22 | { |
| 3 | 23 | if(document.getElementById) { |
| ... | ...@@ -19,9 +19,14 @@ | |
| 19 | 19 | <span class="span_navmenu_off">jUDDI Admin | </span> |
| 20 | 20 | <%} %> |
| 21 | 21 | <% if (adminSession.getUser().isMonitoring()) {%> |
| 22 | <a href="showMonitoringWelcome.do" title="Monitoring" class="<%=AdminSession.MONITORING.equalsIgnoreCase(adminSession.getSelectedMenu()) ? "navmenu_active" : "navmenu" %>">Monitoring</a> | |
| 22 | <a href="showMonitoringWelcome.do" title="Monitoring" class="<%=AdminSession.MONITORING.equalsIgnoreCase(adminSession.getSelectedMenu()) ? "navmenu_active" : "navmenu" %>">Monitoring</a> | | |
| 23 | 23 | <%} else {%> |
| 24 | <span class="span_navmenu_off">Monitoring</span> | |
| 24 | <span class="span_navmenu_off">Monitoring | </span> | |
| 25 | <%} | |
| 26 | if (adminSession.getUser().isAdmin()) {%> | |
| 27 | <a href="showChannelClient.do" title="Test Client" class="<%=AdminSession.CHANNEL_CLIENT.equalsIgnoreCase(adminSession.getSelectedMenu()) ? "navmenu_active" : "navmenu" %>">Test</a> | |
| 28 | <%} else {%> | |
| 29 | <span class="span_navmenu_off">Test</span> | |
| 25 | 30 | <%} %> |
| 26 | 31 | </div> |
| 27 | 32 | <div id="logged"> |
| ... | ...@@ -0,0 +1,111 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2007 EBM Websourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | * ------------------------------------------------------------------------- | |
| 19 | * $Id$ | |
| 20 | * ------------------------------------------------------------------------- | |
| 21 | */ | |
| 22 | ||
| 23 | package org.ow2.petals.tools.webadmin.ui.channelclient; | |
| 24 | ||
| 25 | import static org.ow2.petals.tools.webadmin.util.ChannelClientHelper.SE_CLIENT_STATE_NOTFOUND; | |
| 26 | ||
| 27 | import javax.servlet.ServletContext; | |
| 28 | import javax.servlet.http.HttpServletRequest; | |
| 29 | import javax.servlet.http.HttpServletResponse; | |
| 30 | ||
| 31 | import org.apache.log4j.Logger; | |
| 32 | import org.apache.struts.action.ActionForm; | |
| 33 | import org.apache.struts.action.ActionForward; | |
| 34 | import org.apache.struts.action.ActionMapping; | |
| 35 | import org.apache.struts.action.DynaActionForm; | |
| 36 | import org.ow2.petals.tools.webadmin.datacollector.client.exception.DataCollectorClientException; | |
| 37 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorClientDoesNotExistException; | |
| 38 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorServerException; | |
| 39 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorServerNotInitializedException; | |
| 40 | import org.ow2.petals.tools.webadmin.ui.infra.action.ChannelClientAction; | |
| 41 | import org.ow2.petals.tools.webadmin.ui.infra.bean.InfoBean; | |
| 42 | import org.ow2.petals.tools.webadmin.ui.infra.session.AdminSession; | |
| 43 | import org.ow2.petals.tools.webadmin.util.DataCollectorHelper; | |
| 44 | import org.ow2.petals.tools.webadmin.util.ChannelClientHelper; | |
| 45 | import org.ow2.petals.tools.webadmin.util.ChannelClientHelperException; | |
| 46 | import org.ow2.petals.tools.webadmin.util.StringHelper; | |
| 47 | ||
| 48 | /** | |
| 49 | * Start the channel client on PEtALS | |
| 50 | * | |
| 51 | * @author mcarpentier - EBM Websourcing | |
| 52 | * | |
| 53 | */ | |
| 54 | public class StartChannelClient extends ChannelClientAction { | |
| 55 | ||
| 56 | private static final String actionTitle = "get PEtALS channel client"; | |
| 57 | ||
| 58 | final Logger log = Logger.getLogger(StartChannelClient.class); | |
| 59 | ||
| 60 | @Override | |
| 61 | public ActionForward executeChannelClientActionAuthentified(ActionMapping actionMapping, | |
| 62 | ActionForm actionForm, HttpServletRequest servletRequest, | |
| 63 | HttpServletResponse servletResponse) { | |
| 64 | final AdminSession adminSession = AdminSession.getAdminSession(servletRequest.getSession()); | |
| 65 | ||
| 66 | /** set navigation info* */ | |
| 67 | adminSession.setSelectedMenu(AdminSession.CHANNEL_CLIENT); | |
| 68 | ||
| 69 | final String server = servletRequest.getParameter("server"); | |
| 70 | ||
| 71 | if (StringHelper.isNotNullAndNotEmpty(server)) { | |
| 72 | final DynaActionForm channelClientFormDisplay = (DynaActionForm) actionForm; | |
| 73 | channelClientFormDisplay.set("server", server); | |
| 74 | try { | |
| 75 | if (SE_CLIENT_STATE_NOTFOUND.equalsIgnoreCase(ChannelClientHelper | |
| 76 | .getChannelClientState(server))) { | |
| 77 | final ServletContext context = servletRequest.getSession().getServletContext(); | |
| 78 | String reqPath = servletRequest.getContextPath(); | |
| 79 | reqPath = reqPath.substring(reqPath.lastIndexOf("/") + 1); | |
| 80 | final String realContextPath = context | |
| 81 | .getRealPath(servletRequest.getContextPath()); | |
| 82 | final String rootPath = realContextPath.substring(0, realContextPath | |
| 83 | .lastIndexOf(reqPath)); | |
| 84 | ChannelClientHelper.InstallChannelClient(server, servletRequest.getRequestURL() | |
| 85 | .toString(),rootPath); | |
| 86 | } | |
| 87 | ChannelClientHelper.StartChannelClient(server); | |
| 88 | /** refresh datas from PEtALS * */ | |
| 89 | adminSession.setDomain(DataCollectorHelper.updateDomainInfo(true)); | |
| 90 | } catch (ChannelClientHelperException e) { | |
| 91 | this.fillInfoBean(adminSession, e.getMessage(), InfoBean.ERROR_MESSAGE); | |
| 92 | this.log.error("Error : can't " + actionTitle, e); | |
| 93 | } catch (DataCollectorServerException e) { | |
| 94 | this.fillInfoBean(adminSession, e.getMessage(), InfoBean.ERROR_MESSAGE); | |
| 95 | this.log.error("Error : can't " + actionTitle, e); | |
| 96 | } catch (DataCollectorClientException e) { | |
| 97 | this.fillInfoBean(adminSession, e.getMessage(), InfoBean.ERROR_MESSAGE); | |
| 98 | this.log.error("Error : can't " + actionTitle, e); | |
| 99 | } catch (DataCollectorServerNotInitializedException e) { | |
| 100 | this.fillInfoBean(adminSession, e.getMessage(), InfoBean.ERROR_MESSAGE); | |
| 101 | this.log.error("Error : can't " + actionTitle, e); | |
| 102 | } catch (DataCollectorClientDoesNotExistException e) { | |
| 103 | this.fillInfoBean(adminSession, e.getMessage(), InfoBean.ERROR_MESSAGE); | |
| 104 | this.log.error("Error : can't " + actionTitle, e); | |
| 105 | } | |
| 106 | } | |
| 107 | ||
| 108 | return actionMapping.findForward("success"); | |
| 109 | } | |
| 110 | ||
| 111 | } |
| ... | ...@@ -0,0 +1,216 @@ | |
| 1 | /** | |
| 2 | * Deals with all sample client javascript functions | |
| 3 | * @author mcarpentier | |
| 4 | * | |
| 5 | */ | |
| 6 | ||
| 7 | /** | |
| 8 | * send a message regarding forms parameters | |
| 9 | * todo: make it generic | |
| 10 | */ | |
| 11 | function sendMessage() { | |
| 12 | var serverName = document.forms[0].server.value; | |
| 13 | var interfaceName = document.forms[0].interface.value; | |
| 14 | var serviceName = document.forms[0].service.value; | |
| 15 | var operation = document.forms[0].operation.value; | |
| 16 | var endpoint = document.forms[0].endpoint.value; | |
| 17 | var mep = document.forms[0].mep.value; | |
| 18 | var content = document.forms[0].content.value; | |
| 19 | var async = document.forms[0].async.value; | |
| 20 | if (async == 1) { | |
| 21 | SendAjaxMessage.sendASyncMessage(serverName, interfaceName, | |
| 22 | serviceName, endpoint, operation, mep, content); | |
| 23 | } else { | |
| 24 | SendAjaxMessage.sendSyncMessage(serverName, interfaceName, serviceName, | |
| 25 | endpoint, operation, mep, content, gotMsgResponse); | |
| 26 | } | |
| 27 | } | |
| 28 | /** | |
| 29 | * callback function for sendMessage | |
| 30 | * @param data: the response, a {@link ChannelClientMessageLVO} | |
| 31 | */ | |
| 32 | function gotMsgResponse(data) { | |
| 33 | if (data != null) { | |
| 34 | displayChannelClientResponse(data); | |
| 35 | } | |
| 36 | } | |
| 37 | ||
| 38 | /** | |
| 39 | * parse java error adn display it as a {@link ChannelClientMessageLVO} | |
| 40 | */ | |
| 41 | function errorHandler(data, ex) { | |
| 42 | var stack; | |
| 43 | stack = '<b>' + ex.javaClassName + ':' + ex.message + '</b>\n'; | |
| 44 | var currentException = ex; | |
| 45 | var srcLine; | |
| 46 | while (currentException != null) { | |
| 47 | if (currentException.stackTrace != null) { | |
| 48 | for ( var i = 0; i < currentException.stackTrace.length; i++) { | |
| 49 | if (currentException.stackTrace[i].lineNumber == -2) { | |
| 50 | srcLine = '(native method)' | |
| 51 | } else if (currentException.stackTrace[i].lineNumber == -1) { | |
| 52 | srcLine = '(Unknown source)' | |
| 53 | } else { | |
| 54 | srcLine = '(' + currentException.stackTrace[i].fileName | |
| 55 | + ':' + currentException.stackTrace[i].lineNumber | |
| 56 | + ')'; | |
| 57 | } | |
| 58 | ||
| 59 | stack = stack + ' at:' | |
| 60 | + currentException.stackTrace[i].className + '.' | |
| 61 | + currentException.stackTrace[i].methodName + srcLine | |
| 62 | + '<br />'; | |
| 63 | } | |
| 64 | } | |
| 65 | if (currentException.cause != null) { | |
| 66 | stack = stack + '<b>Caused by:' | |
| 67 | + currentException.cause.javaClassName + '</b>\n'; | |
| 68 | } | |
| 69 | currentException = currentException.cause | |
| 70 | } | |
| 71 | ||
| 72 | var res = { | |
| 73 | destInterface:'?', | |
| 74 | destEndpoint:'?', | |
| 75 | destService:'?', | |
| 76 | type:'exception', | |
| 77 | content:stack | |
| 78 | }; | |
| 79 | ||
| 80 | displayChannelClientResponse(res); | |
| 81 | } | |
| 82 | ||
| 83 | function displayChannelClientResponse(data) { | |
| 84 | DOM('mainresponsecontent').innerHTML = data.content; | |
| 85 | addInboxResponse(data) | |
| 86 | } | |
| 87 | ||
| 88 | /** | |
| 89 | * view send panel | |
| 90 | */ | |
| 91 | function viewSend() { | |
| 92 | DOM('sendMenuItem').className = 'current'; | |
| 93 | DOM('inboxMenuItem').className = ''; | |
| 94 | DOM('sendPanel').style.display = "block"; | |
| 95 | DOM('inboxPanel').style.display = "none"; | |
| 96 | } | |
| 97 | ||
| 98 | /** | |
| 99 | * view inbox panel | |
| 100 | */ | |
| 101 | function viewInbox() { | |
| 102 | DOM('sendMenuItem').className = ''; | |
| 103 | DOM('inboxMenuItem').className = 'current'; | |
| 104 | DOM('sendPanel').style.display = "none"; | |
| 105 | DOM('inboxPanel').style.display = "block"; | |
| 106 | } | |
| 107 | ||
| 108 | /** | |
| 109 | * add a response to the inbox panel | |
| 110 | */ | |
| 111 | function addInboxResponse(data) { | |
| 112 | changeNbResponses(1); | |
| 113 | ||
| 114 | //clone sample response | |
| 115 | var sampleDT = DOM('sampleDT').cloneNode(true); | |
| 116 | sampleDT.id = ''; | |
| 117 | sampleDT.className = 'unreadresponse'; | |
| 118 | var sampleDD = DOM('sampleDD').cloneNode(true); | |
| 119 | sampleDD.id = ''; | |
| 120 | sampleDD.className = ''; | |
| 121 | ||
| 122 | sampleDT.onclick = function() { | |
| 123 | toggleMenuDisplay(sampleDT); | |
| 124 | return false; | |
| 125 | } | |
| 126 | ||
| 127 | sampleDT.getElementsByTagName("td")[0].innerHTML = data.destInterface | |
| 128 | + ' | ' + data.destService + ' | ' + data.destEndpoint; | |
| 129 | sampleDT.getElementsByTagName("td")[1].innerHTML = data.type.toLowerCase(); | |
| 130 | if ((equalsIgnoreCase(data.type,'done')) || (equalsIgnoreCase(data.type,'out'))) { | |
| 131 | sampleDT.getElementsByTagName("td")[1].className='status_done'; | |
| 132 | } else { | |
| 133 | sampleDT.getElementsByTagName("td")[1].className='status_error'; | |
| 134 | } | |
| 135 | var temps = new Date(); | |
| 136 | var ms = temps.getMilliseconds(); | |
| 137 | var s = temps.getSeconds(); | |
| 138 | var h = temps.getHours(); | |
| 139 | var m = temps.getMinutes(); | |
| 140 | sampleDT.getElementsByTagName("td")[2].innerHTML=h+':'+m+':'+s+'.'+ms; | |
| 141 | sampleDD.getElementsByTagName("pre")[0].innerHTML = data.content; | |
| 142 | DOM('inboxResponses').insertBefore(sampleDD,DOM('inboxResponses').firstChild); | |
| 143 | DOM('inboxResponses').insertBefore(sampleDT,DOM('inboxResponses').firstChild); | |
| 144 | // DOM('inboxResponses').appendChild(sampleDT); | |
| 145 | // DOM('inboxResponses').appendChild(sampleDD); | |
| 146 | ||
| 147 | return; | |
| 148 | ||
| 149 | } | |
| 150 | ||
| 151 | /** | |
| 152 | * add (+/-)n responses to response menu item label | |
| 153 | * @param num (+/-)n responses to add | |
| 154 | */ | |
| 155 | function changeNbResponses(num) { | |
| 156 | var itemTxt = DOM('inboxMenuItem').getElementsByTagName('a')[0].innerHTML; | |
| 157 | var nbResponse = 0; | |
| 158 | if (itemTxt.length > 6) { | |
| 159 | nbResponse = parseInt(itemTxt.substring(7, itemTxt.length - 1)); | |
| 160 | } | |
| 161 | nbResponse = nbResponse + num; | |
| 162 | if (nbResponse == 0) { | |
| 163 | DOM('inboxMenuItem').getElementsByTagName('a')[0].innerHTML = 'Inbox'; | |
| 164 | } else { | |
| 165 | DOM('inboxMenuItem').getElementsByTagName('a')[0].innerHTML = 'Inbox (' + nbResponse + ')'; | |
| 166 | ||
| 167 | } | |
| 168 | } | |
| 169 | ||
| 170 | /** | |
| 171 | * delete a response | |
| 172 | * @param nodeElem | |
| 173 | * @return | |
| 174 | */ | |
| 175 | function deleteResponse(nodeElem) { | |
| 176 | var myDD = null; | |
| 177 | for ( var i = 0, elem; elem = nodeElem.parentNode.childNodes[i]; i++) { | |
| 178 | if (elem == nodeElem) { | |
| 179 | myDD = nodeElem.parentNode.childNodes[i + 1]; | |
| 180 | } | |
| 181 | } | |
| 182 | if (nodeElem.className == 'unreadresponse') { | |
| 183 | changeNbResponses(-1); | |
| 184 | } | |
| 185 | nodeElem.parentNode.removeChild(myDD); | |
| 186 | nodeElem.parentNode.removeChild(nodeElem); | |
| 187 | } | |
| 188 | ||
| 189 | /** | |
| 190 | * display or hide message details in inbox panel | |
| 191 | * @param nodeElem | |
| 192 | * @return | |
| 193 | */ | |
| 194 | function toggleMenuDisplay(nodeElem) { | |
| 195 | var myDD = null; | |
| 196 | for ( var i = 0, elem; elem = nodeElem.parentNode.childNodes[i]; i++) { | |
| 197 | if (elem == nodeElem) { | |
| 198 | myDD = nodeElem.parentNode.childNodes[i + 1]; | |
| 199 | } | |
| 200 | } | |
| 201 | for ( var i = 0, elem; elem = nodeElem.parentNode | |
| 202 | .getElementsByTagName("dd")[i]; i++) { | |
| 203 | if (myDD != elem) { | |
| 204 | elem.style.display = 'none'; | |
| 205 | } | |
| 206 | } | |
| 207 | myDD.style.display = (myDD.style.display == 'none' ? 'block' : 'none'); | |
| 208 | if (nodeElem.className == 'unreadresponse') { | |
| 209 | changeNbResponses(-1); | |
| 210 | nodeElem.className = 'readresponse'; | |
| 211 | } | |
| 212 | } | |
| 213 | ||
| 214 | function equalsIgnoreCase(arg,arg2) { | |
| 215 | return (new String(arg.toLowerCase()) == (new String(arg2)).toLowerCase()); | |
| 216 | } |
| ... | ...@@ -0,0 +1,173 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2005-2006 EBM WebSourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | * ------------------------------------------------------------------------- | |
| 19 | * $Id: SourceHelper.java 94 2006-03-26 17:11:05Z alouis $ | |
| 20 | * ------------------------------------------------------------------------- | |
| 21 | */ | |
| 22 | ||
| 23 | package org.ow2.petals.tools.webadmin.util; | |
| 24 | ||
| 25 | import static org.ow2.petals.jmx.api.IPetalsAdminService.EntityStates.STATE_STARTED; | |
| 26 | ||
| 27 | import java.io.File; | |
| 28 | import java.io.IOException; | |
| 29 | import java.net.InetAddress; | |
| 30 | import java.net.UnknownHostException; | |
| 31 | ||
| 32 | import org.apache.log4j.Logger; | |
| 33 | import org.ow2.petals.tools.webadmin.cron.CollectorManager; | |
| 34 | import org.ow2.petals.tools.webadmin.datacollector.client.CollectorClient; | |
| 35 | import org.ow2.petals.tools.webadmin.datacollector.client.exception.DataCollectorClientException; | |
| 36 | import org.ow2.petals.tools.webadmin.datacollector.server.CollectorServer; | |
| 37 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorClientDoesNotExistException; | |
| 38 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorServerException; | |
| 39 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorServerNotInitializedException; | |
| 40 | ||
| 41 | /** | |
| 42 | * | |
| 43 | * @author mcarpentier - EBM WebSourcing | |
| 44 | * | |
| 45 | */ | |
| 46 | public final class ChannelClientHelper { | |
| 47 | ||
| 48 | final static Logger log = Logger.getLogger(ChannelClientHelper.class); | |
| 49 | ||
| 50 | public static final String PETALS_SE_CLIENT_JMX = "petals-bc-channelclient"; | |
| 51 | ||
| 52 | private static final String SE_CLIENT_FILENAME = "petals-bc-channelclient-1.0-SNAPSHOT.zip"; | |
| 53 | ||
| 54 | public static final String SE_CLIENT_STATE_NOTFOUND = "se-not-found"; | |
| 55 | ||
| 56 | private ChannelClientHelper() { | |
| 57 | super(); | |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 | * Try to reach petals channel client | |
| 62 | * | |
| 63 | * @param server | |
| 64 | * @return | |
| 65 | * @throws ChannelClientHelperException | |
| 66 | */ | |
| 67 | public static String getChannelClientState(String server) throws ChannelClientHelperException { | |
| 68 | String result = null; | |
| 69 | try { | |
| 70 | final CollectorServer collector = CollectorManager.getCollector(); | |
| 71 | CollectorClient cc = collector.getCollectorClient(server); | |
| 72 | if (cc.getAdminService().getComponentByName(PETALS_SE_CLIENT_JMX) == null) { | |
| 73 | result = SE_CLIENT_STATE_NOTFOUND; | |
| 74 | } else { | |
| 75 | String state = cc.getAdminService().getComponentState(PETALS_SE_CLIENT_JMX); | |
| 76 | if (STATE_STARTED.equalsIgnoreCase(state)) { | |
| 77 | if (!cc.isChannelClientReachable()) { | |
| 78 | throw new ChannelClientHelperException( | |
| 79 | "An internal error has occured: the PEtALS Test Client for this server is running, but it can't be reached via JMX"); | |
| 80 | } | |
| 81 | } | |
| 82 | return state; | |
| 83 | } | |
| 84 | } catch (DataCollectorServerException e) { | |
| 85 | throw new ChannelClientHelperException(e); | |
| 86 | } catch (DataCollectorClientDoesNotExistException e) { | |
| 87 | throw new ChannelClientHelperException( | |
| 88 | "Can't reach PEtALS client, your server list must be out of date", e); | |
| 89 | } catch (DataCollectorServerNotInitializedException e) { | |
| 90 | throw new ChannelClientHelperException(e); | |
| 91 | } catch (DataCollectorClientException e) { | |
| 92 | throw new ChannelClientHelperException(e); | |
| 93 | } | |
| 94 | return result; | |
| 95 | } | |
| 96 | ||
| 97 | /** | |
| 98 | * Start the channel client installed on PEtALS | |
| 99 | * | |
| 100 | * @param server | |
| 101 | * @throws ChannelClientHelperException | |
| 102 | */ | |
| 103 | public static void StartChannelClient(String server) throws ChannelClientHelperException { | |
| 104 | try { | |
| 105 | final CollectorServer collector = CollectorManager.getCollector(); | |
| 106 | collector.getCollectorClient(server).getAdminService().startComponent( | |
| 107 | PETALS_SE_CLIENT_JMX); | |
| 108 | } catch (DataCollectorServerException e) { | |
| 109 | throw new ChannelClientHelperException(e); | |
| 110 | } catch (DataCollectorClientException e) { | |
| 111 | throw new ChannelClientHelperException(e); | |
| 112 | } catch (DataCollectorClientDoesNotExistException e) { | |
| 113 | throw new ChannelClientHelperException(e); | |
| 114 | } catch (DataCollectorServerNotInitializedException e) { | |
| 115 | throw new ChannelClientHelperException(e); | |
| 116 | } | |
| 117 | } | |
| 118 | ||
| 119 | /** | |
| 120 | * Install the channel client | |
| 121 | * | |
| 122 | * @param serverName | |
| 123 | * @param requestURL | |
| 124 | * @throws ChannelClientHelperException | |
| 125 | */ | |
| 126 | public static void InstallChannelClient(String serverName, String requestURL,String rootPath) | |
| 127 | throws ChannelClientHelperException { | |
| 128 | try { | |
| 129 | final CollectorServer collector = CollectorManager.getCollector(); | |
| 130 | ||
| 131 | final int lastSeparator = requestURL.lastIndexOf("/") + 1; | |
| 132 | ||
| 133 | File f = new File(rootPath +"temp/" + SE_CLIENT_FILENAME); | |
| 134 | System.out.println(f.getAbsolutePath()); | |
| 135 | if (!f.exists()) { | |
| 136 | throw new ChannelClientHelperException("ChannelClient BC File has not been installed into the webconsole : "+"temp/" + SE_CLIENT_FILENAME); | |
| 137 | } | |
| 138 | ||
| 139 | String httpUrl = requestURL.substring(0, lastSeparator) + "temp/" + SE_CLIENT_FILENAME; | |
| 140 | ||
| 141 | /** | |
| 142 | * try to replace possible "localhost" in the URL by the IP address * | |
| 143 | */ | |
| 144 | InetAddress in = InetAddress.getLocalHost(); | |
| 145 | String iPaddress = ""; | |
| 146 | InetAddress[] all = InetAddress.getAllByName(in.getHostName()); | |
| 147 | for (int i = 0; (i < all.length) && (StringHelper.isNullOrEmpty(iPaddress)); i++) { | |
| 148 | InetAddress ia = all[i]; | |
| 149 | if (ia.isReachable(5000)) { | |
| 150 | iPaddress = ia.getHostAddress(); | |
| 151 | } | |
| 152 | } | |
| 153 | if (StringHelper.isNotNullAndNotEmpty(iPaddress)) { | |
| 154 | httpUrl = httpUrl.replace("localhost", iPaddress); | |
| 155 | } | |
| 156 | ||
| 157 | collector.getCollectorClient(serverName).getInstallService().installComponent(httpUrl); | |
| 158 | } catch (DataCollectorServerException e) { | |
| 159 | throw new ChannelClientHelperException(e); | |
| 160 | } catch (DataCollectorClientException e) { | |
| 161 | throw new ChannelClientHelperException(e); | |
| 162 | } catch (DataCollectorClientDoesNotExistException e) { | |
| 163 | throw new ChannelClientHelperException(e); | |
| 164 | } catch (DataCollectorServerNotInitializedException e) { | |
| 165 | throw new ChannelClientHelperException(e); | |
| 166 | } catch (UnknownHostException e) { | |
| 167 | throw new ChannelClientHelperException(e); | |
| 168 | } catch (IOException e) { | |
| 169 | throw new ChannelClientHelperException(e); | |
| 170 | } | |
| 171 | ||
| 172 | } | |
| 173 | } |
| ... | ...@@ -192,7 +192,7 @@ | |
| 192 | 192 | // loop list items |
| 193 | 193 | for (var i = 0, li; li = self.menuElements[i]; i++) |
| 194 | 194 | { |
| 195 | if (isFolder(li)) | |
| 195 | if ((isFolder(li)) || (li.className == "s-serv") || (li.className == "folder closed")) | |
| 196 | 196 | { |
| 197 | 197 | li.className = "folder closed"; // default is closed |
| 198 | 198 | } |
| ... | ...@@ -0,0 +1,97 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2007 EBM Websourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | * ------------------------------------------------------------------------- | |
| 19 | * $Id$ | |
| 20 | * ------------------------------------------------------------------------- | |
| 21 | */ | |
| 22 | ||
| 23 | package org.ow2.petals.tools.webadmin.ui.channelclient; | |
| 24 | ||
| 25 | import javax.servlet.http.HttpServletRequest; | |
| 26 | import javax.servlet.http.HttpServletResponse; | |
| 27 | ||
| 28 | import org.apache.log4j.Logger; | |
| 29 | import org.apache.struts.action.ActionForm; | |
| 30 | import org.apache.struts.action.ActionForward; | |
| 31 | import org.apache.struts.action.ActionMapping; | |
| 32 | import org.apache.struts.action.DynaActionForm; | |
| 33 | import org.ow2.petals.tools.webadmin.cron.CollectorManager; | |
| 34 | import org.ow2.petals.tools.webadmin.datacollector.client.exception.DataCollectorClientException; | |
| 35 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorClientDoesNotExistException; | |
| 36 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorServerException; | |
| 37 | import org.ow2.petals.tools.webadmin.datacollector.server.exception.DataCollectorServerNotInitializedException; | |
| 38 | import org.ow2.petals.tools.webadmin.ui.infra.action.ChannelClientAction; | |
| 39 | import org.ow2.petals.tools.webadmin.ui.infra.bean.DomainLVO; | |
| 40 | import org.ow2.petals.tools.webadmin.ui.infra.bean.InfoBean; | |
| 41 | import org.ow2.petals.tools.webadmin.ui.infra.session.AdminSession; | |
| 42 | import org.ow2.petals.tools.webadmin.util.DataCollectorHelper; | |
| 43 | ||
| 44 | /** | |
| 45 | * @author mcarpentier - EBM Websourcing | |
| 46 | */ | |
| 47 | public class ShowMenu extends ChannelClientAction { | |
| 48 | ||
| 49 | private static final String actionTitle = "get PEtALS components"; | |
| 50 | ||
| 51 | final Logger log = Logger.getLogger(ShowMenu.class); | |
| 52 | ||
| 53 | @Override | |
| 54 | public ActionForward executeChannelClientActionAuthentified(ActionMapping iActionMapping, | |