KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jonasadmin > test > catalina > ConnectorUtils


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 1any 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: ConnectorUtils.java,v 1.2 2005/07/12 08:16:52 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jonasadmin.test.catalina;
27
28 import java.io.IOException JavaDoc;
29 import java.net.ServerSocket JavaDoc;
30
31 import org.xml.sax.SAXException JavaDoc;
32
33 import com.meterware.httpunit.SubmitButton;
34 import com.meterware.httpunit.WebConversation;
35 import com.meterware.httpunit.WebForm;
36 import com.meterware.httpunit.WebLink;
37 import com.meterware.httpunit.WebResponse;
38
39 /**
40  * Class for using connectors from jonasAdmin, for example create a new connector.
41  * @author Paul Kemler
42  *
43  */

44 public class ConnectorUtils {
45
46     /**
47      * NAME of FRAME content
48      */

49     protected static final String JavaDoc FRAME_CONTENT = "content";
50
51     /**
52      * NAME of FRAME tree
53      */

54     protected static final String JavaDoc FRAME_TREE = "tree";
55
56     /**
57      * URL of the Catalina connectors
58      */

59     private static final String JavaDoc URL_JONASADMIN_CATALINA_CONNECTOR = "ListCatalinaConnectors.do";
60
61     /**
62      * URL for creating a catalina connector
63      */

64     private static final String JavaDoc URL_JONASADMIN_CREATE_CATALINA_CONNECTOR = "CreateCatalinaConnector.do";
65
66     /**
67      * Create a new connector
68      * @param wc logged to jonasAdmin
69      * @return port of the new connector
70      * @throws Exception if an error occurs
71      */

72     public static String JavaDoc createNewConnector(WebConversation wc) throws Exception JavaDoc {
73         // Call method createNewConnector(WebConversation wc, String protocol)
74
return createNewConnector(wc, "http");
75     }
76
77     /**
78      * Create a new connector
79      * @param wc logged to jonasAdmin
80      * @param protocol protocol to create ("http", "https" or "ajp")
81      * @return port of the new connector
82      * @throws Exception if an error occurs
83      */

84     public static String JavaDoc createNewConnector(WebConversation wc, String JavaDoc protocol) throws Exception JavaDoc {
85         WebResponse wr = null;
86         WebLink link = null;
87         WebForm form = null;
88         String JavaDoc portText = null;
89
90         // Go to connector page
91
wr = getConnectorPage(wc);
92
93         // Go to CreateCatalinaConnector.do?type= <protocol>
94
link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_CREATE_CATALINA_CONNECTOR + "?type="
95                 + protocol);
96         link.click();
97         wr = wc.getFrameContents(FRAME_CONTENT);
98
99         portText = "" + findPort();
100
101         if (protocol.equals("http")) {
102
103             form = wr.getForms()[0];
104             String JavaDoc maxSpareThreadsText = form.getParameterValue("maxSpareThreadsText");
105             String JavaDoc URIEncoding = form.getParameterValue("URIEncoding");
106             String JavaDoc minSpareThreadsText = form.getParameterValue("minSpareThreadsText");
107             String JavaDoc address = form.getParameterValue("address");
108             String JavaDoc tcpNoDelay = form.getParameterValue("tcpNoDelay");
109             String JavaDoc maxThreadsText = form.getParameterValue("maxThreadsText");
110             String JavaDoc xpoweredBy = form.getParameterValue("xpoweredBy");
111             String JavaDoc connectorType = form.getParameterValue("connectorType");
112             String JavaDoc objectName = form.getParameterValue("objectName");
113             String JavaDoc secure = form.getParameterValue("secure");
114             String JavaDoc action = form.getParameterValue("action");
115             String JavaDoc save = form.getParameterValue("save");
116             String JavaDoc emptySessionPath = form.getParameterValue("emptySessionPath");
117             String JavaDoc acceptCountText = form.getParameterValue("acceptCountText");
118             String JavaDoc bufferSizeText = form.getParameterValue("bufferSizeText");
119             String JavaDoc proxyName = form.getParameterValue("proxyName");
120             String JavaDoc useBodyEncodingForURI = form.getParameterValue("useBodyEncodingForURI");
121             String JavaDoc connTimeOutText = form.getParameterValue("connTimeOutText");
122             String JavaDoc debugLvl = form.getParameterValue("debugLvl");
123             String JavaDoc redirectPortText = form.getParameterValue("redirectPortText");
124             String JavaDoc enableLookups = form.getParameterValue("enableLookups");
125             String JavaDoc allowTrace = form.getParameterValue("allowTrace");
126             String JavaDoc maxProcessorsText = form.getParameterValue("maxProcessorsText");
127             String JavaDoc minProcessorsText = form.getParameterValue("minProcessorsText");
128             String JavaDoc proxyPortText = form.getParameterValue("proxyPortText");
129             String JavaDoc maxPostSizeText = form.getParameterValue("maxPostSizeText");
130
131             createNewHttpConnector(form, maxSpareThreadsText, URIEncoding, portText, minSpareThreadsText, address,
132                     tcpNoDelay, maxThreadsText, xpoweredBy, connectorType, objectName, secure, action, save,
133                     emptySessionPath, acceptCountText, bufferSizeText, proxyName, useBodyEncodingForURI,
134                     connTimeOutText, debugLvl, redirectPortText, enableLookups, allowTrace, maxProcessorsText,
135                     minProcessorsText, proxyPortText, maxPostSizeText);
136         } else if (protocol.equals("https")) {
137             form = wr.getForms()[0];
138             String JavaDoc maxSpareThreadsText = form.getParameterValue("maxSpareThreadsText");
139             String JavaDoc keystorePass = form.getParameterValue("keystorePass");
140             String JavaDoc URIEncoding = form.getParameterValue("URIEncoding");
141             String JavaDoc minSpareThreadsText = form.getParameterValue("minSpareThreadsText");
142             String JavaDoc address = form.getParameterValue("address");
143             String JavaDoc keystoreType = form.getParameterValue("keystoreType");
144             String JavaDoc algorithm = form.getParameterValue("algorithm");
145             String JavaDoc tcpNoDelay = form.getParameterValue("tcpNoDelay");
146             String JavaDoc maxThreadsText = form.getParameterValue("maxThreadsText");
147             String JavaDoc xpoweredBy = form.getParameterValue("xpoweredBy");
148             String JavaDoc connectorType = form.getParameterValue("connectorType");
149             String JavaDoc sslProtocol = form.getParameterValue("sslProtocol");
150             String JavaDoc objectName = form.getParameterValue("objectName");
151             String JavaDoc secure = form.getParameterValue("secure");
152             String JavaDoc action = form.getParameterValue("action");
153             String JavaDoc save = form.getParameterValue("save");
154             String JavaDoc emptySessionPath = form.getParameterValue("emptySessionPath");
155             String JavaDoc keystoreFile = form.getParameterValue("keystoreFile");
156             String JavaDoc acceptCountText = form.getParameterValue("acceptCountText");
157             String JavaDoc bufferSizeText = form.getParameterValue("bufferSizeText");
158             String JavaDoc proxyName = form.getParameterValue("proxyName");
159             String JavaDoc useBodyEncodingForURI = form.getParameterValue("useBodyEncodingForURI");
160             String JavaDoc connTimeOutText = form.getParameterValue("connTimeOutText");
161             String JavaDoc debugLvl = form.getParameterValue("debugLvl");
162             String JavaDoc redirectPortText = form.getParameterValue("redirectPortText");
163             String JavaDoc enableLookups = form.getParameterValue("enableLookups");
164             String JavaDoc clientAuth = form.getParameterValue("clientAuth");
165             String JavaDoc allowTrace = form.getParameterValue("allowTrace");
166             String JavaDoc maxProcessorsText = form.getParameterValue("maxProcessorsText");
167             String JavaDoc minProcessorsText = form.getParameterValue("minProcessorsText");
168             String JavaDoc ciphers = form.getParameterValue("ciphers");
169             String JavaDoc proxyPortText = form.getParameterValue("proxyPortText");
170             String JavaDoc maxPostSizeText = form.getParameterValue("maxPostSizeText");
171
172             createNewHttpsConnector(form, maxSpareThreadsText, keystorePass, URIEncoding, portText,
173                     minSpareThreadsText, address, keystoreType, algorithm, tcpNoDelay, maxThreadsText, xpoweredBy,
174                     connectorType, sslProtocol, objectName, secure, action, save, emptySessionPath, keystoreFile,
175                     acceptCountText, bufferSizeText, proxyName, useBodyEncodingForURI, connTimeOutText, debugLvl,
176                     redirectPortText, enableLookups, clientAuth, allowTrace, maxProcessorsText, minProcessorsText,
177                     ciphers, proxyPortText, maxPostSizeText);
178         } else if (protocol.equals("ajp")) {
179             form = wr.getForms()[0];
180             String JavaDoc maxSpareThreadsText = form.getParameterValue("maxSpareThreadsText");
181             String JavaDoc URIEncoding = form.getParameterValue("URIEncoding");
182             String JavaDoc minSpareThreadsText = form.getParameterValue("minSpareThreadsText");
183             String JavaDoc address = form.getParameterValue("address");
184             String JavaDoc tcpNoDelay = form.getParameterValue("tcpNoDelay");
185             String JavaDoc maxThreadsText = form.getParameterValue("maxThreadsText");
186             String JavaDoc xpoweredBy = form.getParameterValue("xpoweredBy");
187             String JavaDoc connectorType = form.getParameterValue("connectorType");
188             String JavaDoc objectName = form.getParameterValue("objectName");
189             String JavaDoc secure = form.getParameterValue("secure");
190             String JavaDoc action = form.getParameterValue("action");
191             String JavaDoc save = form.getParameterValue("save");
192             String JavaDoc emptySessionPath = form.getParameterValue("emptySessionPath");
193             String JavaDoc acceptCountText = form.getParameterValue("acceptCountText");
194             String JavaDoc bufferSizeText = form.getParameterValue("bufferSizeText");
195             String JavaDoc useBodyEncodingForURI = form.getParameterValue("useBodyEncodingForURI");
196             String JavaDoc connTimeOutText = form.getParameterValue("connTimeOutText");
197             String JavaDoc debugLvl = form.getParameterValue("debugLvl");
198             String JavaDoc redirectPortText = form.getParameterValue("redirectPortText");
199             String JavaDoc enableLookups = form.getParameterValue("enableLookups");
200             String JavaDoc allowTrace = form.getParameterValue("allowTrace");
201             String JavaDoc maxProcessorsText = form.getParameterValue("maxProcessorsText");
202             String JavaDoc minProcessorsText = form.getParameterValue("minProcessorsText");
203             String JavaDoc maxPostSizeText = form.getParameterValue("maxPostSizeText");
204
205             createNewAjpConnector(form, maxSpareThreadsText, URIEncoding, portText, minSpareThreadsText, address,
206                     tcpNoDelay, maxThreadsText, xpoweredBy, connectorType, objectName, secure, action, save,
207                     emptySessionPath, acceptCountText, bufferSizeText, useBodyEncodingForURI, connTimeOutText,
208                     debugLvl, redirectPortText, enableLookups, allowTrace, maxProcessorsText, minProcessorsText,
209                     maxPostSizeText);
210         }
211         return portText;
212     }
213
214     /**
215      * Get connector page when it is catalina
216      * @param wc logged to jonasAdmin with catalina
217      * @return WebResponse: content frame with list of connectors
218      * @throws SAXException if an error occurs when link is matched or clicked
219      * @throws IOException if an error occurs when link is clicked
220      */

221     public static WebResponse getConnectorPage(WebConversation wc) throws SAXException JavaDoc, IOException JavaDoc {
222         // Go to connector page (ListCatalinaConnectors.do)
223
WebResponse wr;
224         WebLink link;
225
226         wr = wc.getFrameContents(FRAME_TREE);
227         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_CATALINA_CONNECTOR);
228         if (link == null) {
229             throw new IllegalStateException JavaDoc("No link found for link : '" + URL_JONASADMIN_CATALINA_CONNECTOR + "'.");
230         }
231         link.click();
232
233         wr = wc.getFrameContents(FRAME_CONTENT);
234         return wr;
235     }
236
237     /**
238      * Get a free port
239      * @return number of a free port
240      * @throws Exception if an error occurs to find a port
241      */

242     private static int findPort() throws Exception JavaDoc {
243         int port = 0;
244
245         ServerSocket JavaDoc ss;
246         ss = new ServerSocket JavaDoc(port); // free port if port == 0
247
port = ss.getLocalPort();
248         ss.close();
249         return port;
250     }
251
252     /**
253      * Create New Http Connector
254      * @param form Web Form to create http connector
255      * @param maxSpareThreadsText a string
256      * @param URIEncoding a string
257      * @param portText a string
258      * @param minSpareThreadsText a string
259      * @param address a string
260      * @param tcpNoDelay a string
261      * @param maxThreadsText a string
262      * @param xpoweredBy a string
263      * @param connectorType a string
264      * @param objectName a string
265      * @param secure a string
266      * @param action a string
267      * @param save a string
268      * @param emptySessionPath a string
269      * @param acceptCountText a string
270      * @param bufferSizeText a string
271      * @param proxyName a string
272      * @param useBodyEncodingForURI a string
273      * @param connTimeOutText a string
274      * @param debugLvl a string
275      * @param redirectPortText a string
276      * @param enableLookups a string
277      * @param allowTrace a string
278      * @param maxProcessorsText a string
279      * @param minProcessorsText a string
280      * @param proxyPortText a string
281      * @param maxPostSizeText a string
282      * @throws Exception if an error occurs when button is clicked.
283      */

284     public static void createNewHttpConnector(WebForm form, String JavaDoc maxSpareThreadsText, String JavaDoc URIEncoding,
285             String JavaDoc portText, String JavaDoc minSpareThreadsText, String JavaDoc address, String JavaDoc tcpNoDelay, String JavaDoc maxThreadsText,
286             String JavaDoc xpoweredBy, String JavaDoc connectorType, String JavaDoc objectName, String JavaDoc secure, String JavaDoc action, String JavaDoc save,
287             String JavaDoc emptySessionPath, String JavaDoc acceptCountText, String JavaDoc bufferSizeText, String JavaDoc proxyName,
288             String JavaDoc useBodyEncodingForURI, String JavaDoc connTimeOutText, String JavaDoc debugLvl, String JavaDoc redirectPortText,
289             String JavaDoc enableLookups, String JavaDoc allowTrace, String JavaDoc maxProcessorsText, String JavaDoc minProcessorsText,
290             String JavaDoc proxyPortText, String JavaDoc maxPostSizeText) throws Exception JavaDoc {
291
292         SubmitButton button = null;
293
294         form.setParameter("maxSpareThreadsText", maxSpareThreadsText);
295         form.setParameter("URIEncoding", URIEncoding);
296         form.setParameter("portText", portText);
297         form.setParameter("minSpareThreadsText", minSpareThreadsText);
298         form.setParameter("address", address);
299         form.setParameter("tcpNoDelay", tcpNoDelay);
300         form.setParameter("maxThreadsText", maxThreadsText);
301         form.setParameter("xpoweredBy", xpoweredBy);
302         form.setParameter("connectorType", connectorType);
303         form.setParameter("objectName", objectName);
304         form.setParameter("secure", secure);
305         form.setParameter("action", action);
306         form.setParameter("save", save);
307         form.setParameter("emptySessionPath", emptySessionPath);
308         form.setParameter("acceptCountText", acceptCountText);
309         form.setParameter("bufferSizeText", bufferSizeText);
310         form.setParameter("proxyName", proxyName);
311         form.setParameter("useBodyEncodingForURI", useBodyEncodingForURI);
312         form.setParameter("connTimeOutText", connTimeOutText);
313         form.setParameter("debugLvl", debugLvl);
314         form.setParameter("redirectPortText", redirectPortText);
315         form.setParameter("enableLookups", enableLookups);
316         form.setParameter("allowTrace", allowTrace);
317         form.setParameter("maxProcessorsText", maxProcessorsText);
318         form.setParameter("minProcessorsText", minProcessorsText);
319         form.setParameter("proxyPortText", proxyPortText);
320         form.setParameter("maxPostSizeText", maxPostSizeText);
321
322         button = form.getSubmitButton("btn_apply");
323         button.click();
324     }
325
326     /**
327      * Create New Https Connector
328      * @param form Web Form to create https connector
329      * @param maxSpareThreadsText a string
330      * @param keystorePass a string
331      * @param URIEncoding a string
332      * @param portText a string
333      * @param minSpareThreadsText a string
334      * @param address a string
335      * @param keystoreType a string
336      * @param algorithm a string
337      * @param tcpNoDelay a string
338      * @param maxThreadsText a string
339      * @param xpoweredBy a string
340      * @param connectorType a string
341      * @param sslProtocol a string
342      * @param objectName a string
343      * @param secure a string
344      * @param action a string
345      * @param save a string
346      * @param emptySessionPath a string
347      * @param keystoreFile a string
348      * @param acceptCountText a string
349      * @param bufferSizeText a string
350      * @param proxyName a string
351      * @param useBodyEncodingForURI a string
352      * @param connTimeOutText a string
353      * @param debugLvl a string
354      * @param redirectPortText a string
355      * @param enableLookups a string
356      * @param clientAuth a string
357      * @param allowTrace a string
358      * @param maxProcessorsText a string
359      * @param minProcessorsText a string
360      * @param ciphers a string
361      * @param proxyPortText a string
362      * @param maxPostSizeText a string
363      * @throws Exception if an error occurs when button is clicked.
364      */

365     public static void createNewHttpsConnector(WebForm form, String JavaDoc maxSpareThreadsText, String JavaDoc keystorePass,
366             String JavaDoc URIEncoding, String JavaDoc portText, String JavaDoc minSpareThreadsText, String JavaDoc address, String JavaDoc keystoreType,
367             String JavaDoc algorithm, String JavaDoc tcpNoDelay, String JavaDoc maxThreadsText, String JavaDoc xpoweredBy, String JavaDoc connectorType,
368             String JavaDoc sslProtocol, String JavaDoc objectName, String JavaDoc secure, String JavaDoc action, String JavaDoc save, String JavaDoc emptySessionPath,
369             String JavaDoc keystoreFile, String JavaDoc acceptCountText, String JavaDoc bufferSizeText, String JavaDoc proxyName,
370             String JavaDoc useBodyEncodingForURI, String JavaDoc connTimeOutText, String JavaDoc debugLvl, String JavaDoc redirectPortText,
371             String JavaDoc enableLookups, String JavaDoc clientAuth, String JavaDoc allowTrace, String JavaDoc maxProcessorsText,
372             String JavaDoc minProcessorsText, String JavaDoc ciphers, String JavaDoc proxyPortText, String JavaDoc maxPostSizeText) throws Exception JavaDoc {
373
374         SubmitButton button = null;
375
376         form.setParameter("maxSpareThreadsText", maxSpareThreadsText);
377         form.setParameter("keystorePass", keystorePass);
378         form.setParameter("URIEncoding", URIEncoding);
379         form.setParameter("portText", portText);
380         form.setParameter("minSpareThreadsText", minSpareThreadsText);
381         form.setParameter("address", address);
382         form.setParameter("keystoreType", keystoreType);
383         form.setParameter("algorithm", algorithm);
384         form.setParameter("tcpNoDelay", tcpNoDelay);
385         form.setParameter("maxThreadsText", maxThreadsText);
386         form.setParameter("xpoweredBy", xpoweredBy);
387         form.setParameter("connectorType", connectorType);
388         form.setParameter("sslProtocol", sslProtocol);
389         form.setParameter("objectName", objectName);
390         form.setParameter("secure", secure);
391         form.setParameter("action", action);
392         form.setParameter("save", save);
393         form.setParameter("emptySessionPath", emptySessionPath);
394         form.setParameter("keystoreFile", keystoreFile);
395         form.setParameter("acceptCountText", acceptCountText);
396         form.setParameter("bufferSizeText", bufferSizeText);
397         form.setParameter("proxyName", proxyName);
398         form.setParameter("useBodyEncodingForURI", useBodyEncodingForURI);
399         form.setParameter("connTimeOutText", connTimeOutText);
400         form.setParameter("debugLvl", debugLvl);
401         form.setParameter("redirectPortText", redirectPortText);
402         form.setParameter("enableLookups", enableLookups);
403         form.setParameter("clientAuth", clientAuth);
404         form.setParameter("allowTrace", allowTrace);
405         form.setParameter("maxProcessorsText", maxProcessorsText);
406         form.setParameter("minProcessorsText", minProcessorsText);
407         form.setParameter("ciphers", ciphers);
408         form.setParameter("proxyPortText", proxyPortText);
409         form.setParameter("maxPostSizeText", maxPostSizeText);
410
411         button = form.getSubmitButton("btn_apply");
412         button.click();
413     }
414
415     /**
416      * Create New Ajp Connector
417      * @param form Web Form to create ajp connector
418      * @param maxSpareThreadsText a string
419      * @param URIEncoding a string
420      * @param portText a string
421      * @param minSpareThreadsText a string
422      * @param address a string
423      * @param tcpNoDelay a string
424      * @param maxThreadsText a string
425      * @param xpoweredBy a string
426      * @param connectorType a string
427      * @param objectName a string
428      * @param secure a string
429      * @param action a string
430      * @param save a string
431      * @param emptySessionPath a string
432      * @param acceptCountText a string
433      * @param bufferSizeText a string
434      * @param useBodyEncodingForURI a string
435      * @param connTimeOutText a string
436      * @param debugLvl a string
437      * @param redirectPortText a string
438      * @param enableLookups a string
439      * @param allowTrace a string
440      * @param maxProcessorsText a string
441      * @param minProcessorsText a string
442      * @param maxPostSizeText a string
443      * @throws Exception if an error occurs when button is clicked.
444      */

445     public static void createNewAjpConnector(WebForm form, String JavaDoc maxSpareThreadsText, String JavaDoc URIEncoding,
446             String JavaDoc portText, String JavaDoc minSpareThreadsText, String JavaDoc address, String JavaDoc tcpNoDelay, String JavaDoc maxThreadsText,
447             String JavaDoc xpoweredBy, String JavaDoc connectorType, String JavaDoc objectName, String JavaDoc secure, String JavaDoc action, String JavaDoc save,
448             String JavaDoc emptySessionPath, String JavaDoc acceptCountText, String JavaDoc bufferSizeText, String JavaDoc useBodyEncodingForURI,
449             String JavaDoc connTimeOutText, String JavaDoc debugLvl, String JavaDoc redirectPortText, String JavaDoc enableLookups, String JavaDoc allowTrace,
450             String JavaDoc maxProcessorsText, String JavaDoc minProcessorsText, String JavaDoc maxPostSizeText) throws Exception JavaDoc {
451
452         SubmitButton button = null;
453
454         form.setParameter("maxSpareThreadsText", maxSpareThreadsText);
455         form.setParameter("URIEncoding", URIEncoding);
456         form.setParameter("portText", portText);
457         form.setParameter("minSpareThreadsText", minSpareThreadsText);
458         form.setParameter("address", address);
459         form.setParameter("tcpNoDelay", tcpNoDelay);
460         form.setParameter("maxThreadsText", maxThreadsText);
461         form.setParameter("xpoweredBy", xpoweredBy);
462         form.setParameter("connectorType", connectorType);
463         form.setParameter("objectName", objectName);
464         form.setParameter("secure", secure);
465         form.setParameter("action", action);
466         form.setParameter("save", save);
467         form.setParameter("emptySessionPath", emptySessionPath);
468         form.setParameter("acceptCountText", acceptCountText);
469         form.setParameter("bufferSizeText", bufferSizeText);
470         form.setParameter("useBodyEncodingForURI", useBodyEncodingForURI);
471         form.setParameter("connTimeOutText", connTimeOutText);
472         form.setParameter("debugLvl", debugLvl);
473         form.setParameter("redirectPortText", redirectPortText);
474         form.setParameter("enableLookups", enableLookups);
475         form.setParameter("allowTrace", allowTrace);
476         form.setParameter("maxProcessorsText", maxProcessorsText);
477         form.setParameter("minProcessorsText", minProcessorsText);
478         form.setParameter("maxPostSizeText", maxPostSizeText);
479
480         button = form.getSubmitButton("btn_apply");
481         button.click();
482     }
483
484     /**
485      * Remove a connector
486      * @param wc logged to jonasAdmin
487      * @param port port number of the connector to remove
488      * @throws Exception if an error occurs when connector is deleted
489      */

490     public static void deleteConnector(WebConversation wc, String JavaDoc port) throws Exception JavaDoc {
491         String JavaDoc[] tabPort = {port};
492         deleteConnectors(wc, tabPort);
493     }
494
495     /**
496      * Remove connectors
497      * @param wc logged to jonasAdmin
498      * @param port port number of the connector to remove
499      * @throws Exception if an error occurs
500      */

501     public static void deleteConnectors(WebConversation wc, String JavaDoc[] tabPort) throws Exception JavaDoc {
502         WebResponse wr = null;
503         WebForm form = null;
504         WebLink link = null;
505         SubmitButton button = null;
506
507         String JavaDoc action = "";
508
509         wr = getConnectorPage(wc);
510
511         // Select connectors to remove
512
form = wr.getForms()[0];
513         action = form.getParameterValue("action");
514         for (int i = 0; i < tabPort.length; i++) {
515             form.setCheckbox("selectedItems", "jonas:type=Connector,port=" + tabPort[i], true);
516         }
517
518         // Choose remove action
519
link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "remove");
520         link.click();
521         wr = wc.getFrameContents(FRAME_CONTENT);
522
523         // Confirm
524
form = wr.getForms()[0];
525         button = form.getSubmitButton("btnSubmit");
526         button.click();
527     }
528
529     /**
530      * Modify a connector
531      * @param wc logged to jonasAdmin
532      * @param port number of the port of the connector to modify
533      * @param acceptCountText a string
534      * @param maxPostSizeText a string
535      * @param connTimeOutText a string
536      * @param URIEncoding a string
537      * @param bufferSizeText a string
538      * @param address a string
539      * @param redirectPortText a string
540      * @param maxThreadsText a string
541      * @param minSpareThreadsText a string
542      * @param maxSpareThreadsText a string
543      * @param proxyName a string
544      * @param proxyPortText a string
545      * @throws Exception if an error occurs
546      */

547     public static void modifyHttpConnector(WebForm form, String JavaDoc acceptCountText, String JavaDoc maxPostSizeText,
548             String JavaDoc connTimeOutText, String JavaDoc URIEncoding, String JavaDoc bufferSizeText, String JavaDoc address, String JavaDoc redirectPortText,
549             String JavaDoc maxThreadsText, String JavaDoc minSpareThreadsText, String JavaDoc maxSpareThreadsText, String JavaDoc proxyName,
550             String JavaDoc proxyPortText, String JavaDoc allowTrace, String JavaDoc emptySessionPath, String JavaDoc enableLookups,
551             String JavaDoc useBodyEncodingForURI, String JavaDoc xpoweredBy, String JavaDoc tcpNoDelay, String JavaDoc debugLvl) throws Exception JavaDoc {
552
553         SubmitButton button = null;
554
555         String JavaDoc objectName = null;
556         String JavaDoc action = null;
557         String JavaDoc save = null;
558         String JavaDoc connectorType = null;
559         String JavaDoc portText = null;
560
561         // get hidden params
562
objectName = form.getParameterValue("objectName");
563         action = form.getParameterValue("action");
564         save = form.getParameterValue("save");
565         connectorType = form.getParameterValue("connectorType");
566         portText = form.getParameterValue("portText");
567
568         form.setParameter("objectName", objectName);
569         form.setParameter("action", action);
570         form.setParameter("save", save);
571         form.setParameter("connectorType", connectorType);
572         form.setParameter("portText", portText);
573         form.setParameter("acceptCountText", acceptCountText);
574         form.setParameter("maxPostSizeText", maxPostSizeText);
575         form.setParameter("connTimeOutText", connTimeOutText);
576         form.setParameter("URIEncoding", URIEncoding);
577         form.setParameter("bufferSizeText", bufferSizeText);
578         form.setParameter("address", address);
579         form.setParameter("redirectPortText", redirectPortText);
580         form.setParameter("maxThreadsText", maxThreadsText);
581         form.setParameter("minSpareThreadsText", minSpareThreadsText);
582         form.setParameter("maxSpareThreadsText", maxSpareThreadsText);
583         form.setParameter("proxyName", proxyName);
584         form.setParameter("proxyPortText", proxyPortText);
585         form.setParameter("allowTrace", allowTrace);
586         form.setParameter("emptySessionPath", emptySessionPath);
587         form.setParameter("enableLookups", enableLookups);
588         form.setParameter("useBodyEncodingForURI", useBodyEncodingForURI);
589         form.setParameter("xpoweredBy", xpoweredBy);
590         form.setParameter("tcpNoDelay", tcpNoDelay);
591         form.setParameter("debugLvl", debugLvl);
592
593         button = form.getSubmitButton("btn_apply");
594         button.click();
595     }
596 }
597
Popular Tags