KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencrx > kernel > workflow > servlet > WorkflowControllerServlet


1 /*
2  * ====================================================================
3  * Project: opencrx, http://www.opencrx.org/
4  * Name: $Id: WorkflowControllerServlet.java,v 1.8 2006/04/02 00:34:25 wfro Exp $
5  * Description: openCRX EventHandler
6  * Revision: $Revision: 1.8 $
7  * Owner: CRIXP AG, Switzerland, http://www.crixp.com
8  * Date: $Date: 2006/04/02 00:34:25 $
9  * ====================================================================
10  *
11  * This software is published under the BSD license
12  * as listed below.
13  *
14  * Copyright (c) 2004-2005, CRIXP Corp., Switzerland
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  *
21  * * Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  *
24  * * Redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in
26  * the documentation and/or other materials provided with the
27  * distribution.
28  *
29  * * Neither the name of CRIXP Corp. nor the names of the contributors
30  * to openCRX may be used to endorse or promote products derived
31  * from this software without specific prior written permission
32  *
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
35  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
36  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
37  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
39  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
41  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
43  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46  * POSSIBILITY OF SUCH DAMAGE.
47  *
48  * ------------------
49  *
50  * This product includes software developed by the Apache Software
51  * Foundation (http://www.apache.org/).
52  *
53  * This product includes software developed by contributors to
54  * openMDX (http://www.openmdx.org/)
55  */

56 package org.opencrx.kernel.workflow.servlet;
57
58 import java.io.IOException JavaDoc;
59 import java.io.PrintWriter JavaDoc;
60 import java.net.HttpURLConnection JavaDoc;
61 import java.net.MalformedURLException JavaDoc;
62 import java.net.URL JavaDoc;
63 import java.net.URLDecoder JavaDoc;
64 import java.util.ArrayList JavaDoc;
65 import java.util.Arrays JavaDoc;
66 import java.util.Date JavaDoc;
67 import java.util.HashSet JavaDoc;
68 import java.util.Iterator JavaDoc;
69 import java.util.List JavaDoc;
70 import java.util.Set JavaDoc;
71
72 import javax.naming.Context JavaDoc;
73 import javax.naming.InitialContext JavaDoc;
74 import javax.naming.NamingException JavaDoc;
75 import javax.servlet.ServletConfig JavaDoc;
76 import javax.servlet.ServletException JavaDoc;
77 import javax.servlet.http.HttpServlet JavaDoc;
78 import javax.servlet.http.HttpServletRequest JavaDoc;
79 import javax.servlet.http.HttpServletResponse JavaDoc;
80
81 import org.opencrx.kernel.generic.SecurityKeys;
82 import org.opencrx.kernel.workflow1.cci.WfProcess;
83 import org.openmdx.base.accessor.generic.view.Manager_1;
84 import org.openmdx.base.accessor.jmi.cci.JmiServiceException;
85 import org.openmdx.base.accessor.jmi.cci.RefPackage_1_0;
86 import org.openmdx.base.accessor.jmi.spi.RefRootPackage_1;
87 import org.openmdx.base.exception.ServiceException;
88 import org.openmdx.compatibility.application.dataprovider.transport.ejb.cci.Dataprovider_1ConnectionFactoryImpl;
89 import org.openmdx.compatibility.base.dataprovider.cci.QualityOfService;
90 import org.openmdx.compatibility.base.dataprovider.cci.RequestCollection;
91 import org.openmdx.compatibility.base.dataprovider.cci.ServiceHeader;
92 import org.openmdx.compatibility.base.dataprovider.transport.adapter.Provider_1;
93 import org.openmdx.compatibility.base.dataprovider.transport.cci.Dataprovider_1_1Connection;
94 import org.openmdx.compatibility.base.dataprovider.transport.cci.Provider_1_0;
95 import org.openmdx.compatibility.base.dataprovider.transport.delegation.Connection_1;
96 import org.openmdx.compatibility.base.naming.Path;
97 import org.openmdx.kernel.exception.BasicException;
98 import org.openmdx.model1.accessor.basic.spi.Model_1;
99 import org.openmdx.uses.java.net.URLEncoder;
100
101 /**
102  * The SubscriptionHandler 'listens' (polls periodically the audit entries)
103  * for object modifications. For each subscription (i.e. topic target
104  * pattern) which's filter (object identity and attribute filters) matches
105  * the modified object, the corresponding workflows are executed.
106  */

107 public class WorkflowControllerServlet
108     extends HttpServlet JavaDoc {
109
110     public class WorkflowMonitor
111        implements Runnable JavaDoc {
112         
113         public WorkflowMonitor(
114             long pingRate,
115             List JavaDoc monitoredURLs
116         ) {
117             this.pingRate = pingRate;
118             this.monitoredURLs = monitoredURLs;
119         }
120         
121         public void run(
122         ) {
123             while(true) {
124                 try {
125                     for(
126                         Iterator JavaDoc i = this.monitoredURLs.iterator();
127                         i.hasNext();
128                     ) {
129                         URL JavaDoc url = (URL JavaDoc)i.next();
130                         try {
131                             HttpURLConnection JavaDoc connection = (HttpURLConnection JavaDoc)url.openConnection();
132                             connection.setInstanceFollowRedirects(false);
133                             connection.setDoInput(true);
134                             connection.setDoOutput(true);
135                             connection.setRequestMethod("POST");
136                             int rc = connection.getResponseCode();
137                             if(rc != HttpURLConnection.HTTP_OK) {
138                                 System.out.println(new Date JavaDoc().toString() + ": openCRX/WorkflowController: response code for " + url + " " + rc);
139                             }
140                         }
141                         catch(IOException JavaDoc e) {
142                             new ServiceException(e).log();
143                         }
144                     }
145                     try {
146                         Thread.sleep(this.pingRate * 60000L);
147                     }
148                     catch (InterruptedException JavaDoc e) {}
149                 }
150                 catch(Exception JavaDoc e) {}
151             }
152         }
153         
154         private final List JavaDoc monitoredURLs;
155         private final long pingRate;
156         
157     }
158     
159     //-------------------------------------------------------------------------
160
private RefPackage_1_0 createDataPkg(
161         ServiceHeader header
162     ) throws ServiceException {
163         Provider_1_0 provider = new Provider_1(
164           new RequestCollection(
165             header,
166             this.connectionData
167           ),
168           false
169         );
170         Manager_1 manager = new Manager_1(
171           new Connection_1(
172             provider,
173             false
174           )
175         );
176         RefPackage_1_0 rootPkg = new RefRootPackage_1(manager);
177         return rootPkg;
178     }
179
180     //-----------------------------------------------------------------------
181
public void init(
182         ServletConfig JavaDoc config
183     ) throws ServletException JavaDoc {
184
185         super.init(config);
186         
187         // initialize model repository
188
int ii = 0;
189         List JavaDoc modelPackages = new ArrayList JavaDoc();
190         while(getInitParameter("modelPackage[" + ii + "]") != null) {
191             modelPackages.add(
192               getInitParameter("modelPackage[" + ii + "]")
193             );
194             ii++;
195         }
196         try {
197             new Model_1().addModels(modelPackages);
198         }
199         catch(Exception JavaDoc e) {
200             System.out.println("can not initialize model repository " + e.getMessage());
201             System.out.println(new ServiceException(e).getCause());
202         }
203
204         Context JavaDoc initialContext;
205         try {
206             initialContext = new InitialContext JavaDoc();
207         } catch (NamingException JavaDoc e) {
208             throw new ServletException JavaDoc("can not get the initial context", e);
209         }
210       
211         // Get set of segments to be monitored
212
Set JavaDoc segmentNames = new HashSet JavaDoc();
213         try {
214             this.connectionData = Dataprovider_1ConnectionFactoryImpl.createGenericConnection(
215                 initialContext.lookup("java:comp/env/ejb/data")
216             );
217             RefPackage_1_0 dataPkg = this.createDataPkg(
218                 new ServiceHeader(SecurityKeys.ROOT_PRINCIPAL, null, false, new QualityOfService())
219             );
220             Set JavaDoc excludeRealms = new HashSet JavaDoc();
221             for(ii = 0; ii < 100; ii++) {
222                 if(this.getInitParameter("excludeRealm[" + ii + "]") != null) {
223                     excludeRealms.add(
224                         this.getInitParameter("excludeRealm[" + ii + "]")
225                     );
226                 }
227             }
228             org.openmdx.security.realm1.cci.Segment realmSegment =
229                 (org.openmdx.security.realm1.cci.Segment)dataPkg.refObject(
230                     this.getInitParameter("realmSegment")
231                 );
232             for(Iterator JavaDoc i = realmSegment.getRealm().iterator(); i.hasNext(); ) {
233                 org.openmdx.security.realm1.cci.Realm realm = (org.openmdx.security.realm1.cci.Realm)i.next();
234                 if(!excludeRealms.contains(realm.getName())) {
235                     segmentNames.add(realm.getName());
236                 }
237             }
238         }
239         catch(Exception JavaDoc e) {
240             throw new ServletException JavaDoc("Error occured while retrieving realms", e);
241         }
242         
243         // Create a path to be monitored from each configured path and provider/segment
244
this.configuredPaths = new ArrayList JavaDoc();
245         String JavaDoc providerName = new Path(this.getInitParameter("realmSegment")).get(2);
246         for(Iterator JavaDoc j = segmentNames.iterator(); j.hasNext(); ) {
247             String JavaDoc segmentName = (String JavaDoc)j.next();
248             ii = 0;
249             while(this.getInitParameter("path[" + ii + "]") != null) {
250                 this.configuredPaths.add(
251                     this.getInitParameter("path[" + ii + "]") + "/execute?provider=" + providerName + "&segment=" + segmentName
252                 );
253                 ii++;
254             }
255         }
256         this.monitoredURLs = new ArrayList JavaDoc();
257     }
258
259     //-----------------------------------------------------------------------
260
/**
261      * @return Returns the activityPkg.
262      */

263     protected static org.opencrx.kernel.workflow1.cci.workflow1Package getWorkflowPkg(
264         RefPackage_1_0 rootPkg
265     ) {
266         return (org.opencrx.kernel.workflow1.cci.workflow1Package)rootPkg.refPackage(
267             org.opencrx.kernel.workflow1.cci.workflow1Package.class.getName()
268         );
269     }
270
271     //-----------------------------------------------------------------------
272
/**
273      * @return Returns the activitySegment.
274      */

275     protected static org.opencrx.kernel.workflow1.cci.Segment getWorkflowSegment(
276         RefPackage_1_0 rootPkg,
277         String JavaDoc providerName,
278         String JavaDoc segmentName
279     ) {
280         return (org.opencrx.kernel.workflow1.cci.Segment) rootPkg.refObject(
281             "xri:@openmdx:org.opencrx.kernel.workflow1/provider/"
282             + providerName + "/segment/" + segmentName
283         );
284     }
285
286     //-----------------------------------------------------------------------
287
protected static org.opencrx.kernel.workflow1.cci.Topic initTopic(
288         RefPackage_1_0 rootPkg,
289         org.opencrx.kernel.workflow1.cci.workflow1Package workflowPkg,
290         org.opencrx.kernel.workflow1.cci.Segment workflowSegment,
291         String JavaDoc id,
292         String JavaDoc name,
293         String JavaDoc description,
294         String JavaDoc topicPathPattern,
295         WfProcess[] actions
296     ) {
297         org.opencrx.kernel.workflow1.cci.Topic topic = null;
298         try {
299             topic = workflowSegment.getTopic(id);
300         }
301         catch(JmiServiceException e) {
302             if(e.getExceptionCode() != BasicException.Code.NOT_FOUND) {
303                 throw e;
304             }
305             rootPkg.refBegin();
306             topic = workflowPkg.getTopicClass().createTopic();
307             topic.setName(name);
308             topic.setDescription(description);
309             topic.setTopicPathPattern(topicPathPattern);
310             topic.getPerformAction().addAll(
311                 Arrays.asList(actions)
312             );
313             topic.getOwningGroup().addAll(
314                 workflowSegment.getOwningGroup()
315             );
316             workflowSegment.addTopic(
317                 id,
318                 topic
319             );
320             rootPkg.refCommit();
321         }
322         return topic;
323     }
324     
325     //-----------------------------------------------------------------------
326
protected static org.opencrx.kernel.workflow1.cci.WfProcess initWorkflow(
327         RefPackage_1_0 rootPkg,
328         org.opencrx.kernel.workflow1.cci.workflow1Package workflowPkg,
329         org.opencrx.kernel.workflow1.cci.Segment workflowSegment,
330         String JavaDoc id,
331         String JavaDoc name,
332         String JavaDoc description,
333         Boolean JavaDoc isSynchronous
334     ) {
335         org.opencrx.kernel.workflow1.cci.WfProcess process = null;
336         try {
337             process = (org.opencrx.kernel.workflow1.cci.WfProcess)workflowSegment.getWfProcess(id);
338         }
339         catch(JmiServiceException e) {
340             if(e.getExceptionCode() != BasicException.Code.NOT_FOUND) {
341                 throw e;
342             }
343             rootPkg.refBegin();
344             process = workflowPkg.getWfProcessClass().createWfProcess();
345             process.setName(name);
346             process.setDescription(description);
347             process.setSynchronous(isSynchronous);
348             process.setPriority((short)0);
349             process.getOwningGroup().addAll(
350                 workflowSegment.getOwningGroup()
351             );
352             workflowSegment.addWfProcess(
353                 id,
354                 process
355             );
356             rootPkg.refCommit();
357         }
358         return process;
359     }
360     
361     //-----------------------------------------------------------------------
362
public static void initWorkflows(
363         RefPackage_1_0 rootPkg,
364         String JavaDoc providerName,
365         String JavaDoc segmentName
366     ) throws ServiceException {
367         org.opencrx.kernel.workflow1.cci.workflow1Package workflowPkg = getWorkflowPkg(
368             rootPkg
369         );
370         org.opencrx.kernel.workflow1.cci.Segment workflowSegment = getWorkflowSegment(
371             rootPkg,
372             providerName,
373             segmentName
374         );
375         // ExportMailWorkflow
376
initWorkflow(
377             rootPkg,
378             workflowPkg,
379             workflowSegment,
380             WORKFLOW_EXPORT_MAIL,
381             org.opencrx.mail.workflow.ExportMailWorkflow.class.getName(),
382             "Export mails",
383             Boolean.FALSE
384         );
385         // SendMailWorkflow
386
initWorkflow(
387             rootPkg,
388             workflowPkg,
389             workflowSegment,
390             WORKFLOW_SEND_MAIL,
391             org.opencrx.mail.workflow.SendMailWorkflow.class.getName(),
392             "Send mails",
393             Boolean.FALSE
394         );
395         // SendMailNotificationWorkflow
396
WfProcess sendMailNotificationWorkflow = initWorkflow(
397             rootPkg,
398             workflowPkg,
399             workflowSegment,
400             WORKFLOW_SEND_MAIL_NOTIFICATION,
401             org.opencrx.mail.workflow.SendMailNotificationWorkflow.class.getName(),
402             "Send mail notifications",
403             Boolean.FALSE
404         );
405         // SendAlert
406
WfProcess sendAlertWorkflow = initWorkflow(
407             rootPkg,
408             workflowPkg,
409             workflowSegment,
410             WORKFLOW_SEND_ALERT,
411             org.opencrx.kernel.workflow.SendAlert.class.getName(),
412             "Send alert",
413             Boolean.TRUE
414         );
415         // PrintConsole
416
initWorkflow(
417             rootPkg,
418             workflowPkg,
419             workflowSegment,
420             WORKFLOW_PRINT_CONSOLE,
421             org.opencrx.kernel.workflow.PrintConsole.class.getName(),
422             "Print to console",
423             Boolean.TRUE
424         );
425         WfProcess[] actions = new WfProcess[]{
426             sendAlertWorkflow,
427             sendMailNotificationWorkflow
428         };
429         initTopic(
430             rootPkg,
431             workflowPkg,
432             workflowSegment,
433             "AccountModifications",
434             "Account Modifications",
435             "Send alert for modified accounts",
436             "xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/account/:*",
437             actions
438         );
439         initTopic(
440             rootPkg,
441             workflowPkg,
442             workflowSegment,
443             "ActivityFollowUpModifications",
444             "Activity Follow Up Modifications",
445             "Send alert for modified activity follow ups",
446             "xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/followUp/:*",
447             actions
448         );
449         initTopic(
450             rootPkg,
451             workflowPkg,
452             workflowSegment,
453             "ActivityModifications",
454             "Activity Modifications",
455             "Send alert for modified activities",
456             "xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*",
457             actions
458         );
459         initTopic(
460             rootPkg,
461             workflowPkg,
462             workflowSegment,
463             "BookingModifications",
464             "Booking Modifications",
465             "Send alert for modified bookings",
466             "xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/booking/:*",
467             actions
468         );
469         initTopic(
470             rootPkg,
471             workflowPkg,
472             workflowSegment,
473             "Competitor Modifications",
474             "Competitor Modifications",
475             "Send alert for modified competitors",
476             "xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/competitor/:*",
477             actions
478         );
479         initTopic(
480             rootPkg,
481             workflowPkg,
482             workflowSegment,
483             "CompoundBookingModifications",
484             "Compound Booking Modifications",
485             "Send alert for modified compound bookings",
486             "xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/cb/:*",
487             actions
488         );
489         initTopic(
490             rootPkg,
491             workflowPkg,
492             workflowSegment,
493             "InvoiceModifications",
494             "Invoice Modifications",
495             "Send alert for modified invoices",
496             "xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/invoice/:*",
497             actions
498         );
499         initTopic(
500             rootPkg,
501             workflowPkg,
502             workflowSegment,
503             "LeadModifications",
504             "Lead Modifications",
505             "Send alert for modified leads",
506             "xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/lead/:*",
507             actions
508         );
509         initTopic(
510             rootPkg,
511             workflowPkg,
512             workflowSegment,
513             "OpportunityModifications",
514             "Opportunity Modifications",
515             "Send alert for modified opportunities",
516             "xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/opportunity/:*",
517             actions
518         );
519         initTopic(
520             rootPkg,
521             workflowPkg,
522             workflowSegment,
523             "OrganizationModifications",
524             "Organization Modifications",
525             "Send alert for modified organizations",
526             "xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/organization/:*",
527             actions
528         );
529         initTopic(
530             rootPkg,
531             workflowPkg,
532             workflowSegment,
533             "ProductModifications",
534             "Product Modifications",
535             "Send alert for modified products",
536             "xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*",
537             actions
538         );
539         initTopic(
540             rootPkg,
541             workflowPkg,
542             workflowSegment,
543             "QuoteModifications",
544             "Quote Modifications",
545             "Send alert for modified quotes",
546             "xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/quote/:*",
547             actions
548         );
549         initTopic(
550             rootPkg,
551             workflowPkg,
552             workflowSegment,
553             "SalesOrderModifications",
554             "Sales Order Modifications",
555             "Send alert for modified sales orders",
556             "xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/salesOrder/:*",
557             actions
558         );
559     }
560     
561     //-----------------------------------------------------------------------
562
private URL JavaDoc getMonitoredURL(
563         String JavaDoc path,
564         HttpServletRequest JavaDoc req
565     ) throws MalformedURLException JavaDoc {
566         String JavaDoc requestURL = req.getRequestURL().toString();
567         return new URL JavaDoc(
568             requestURL.substring(0, requestURL.indexOf(req.getServletPath())) + path
569         );
570     }
571     
572     //-----------------------------------------------------------------------
573
protected void handleRequest(
574         HttpServletRequest JavaDoc req,
575         HttpServletResponse JavaDoc res
576     ) throws ServletException JavaDoc, IOException JavaDoc {
577         
578         // Start monitor
579
if(this.workflowMonitor == null) {
580             this.workflowMonitor = new Thread JavaDoc(
581                 new WorkflowMonitor(
582                     this.pingRate,
583                     this.monitoredURLs
584                 )
585             );
586             this.workflowMonitor.start();
587         }
588         
589         // Add/remove to activeURLs
590
if(COMMAND_START.equals(req.getPathInfo())) {
591             for(
592                 Iterator JavaDoc i = this.configuredPaths.iterator();
593                 i.hasNext();
594             ) {
595                 String JavaDoc path = (String JavaDoc)i.next();
596                 if(URLEncoder.encode(path.toString(), "UTF-8").equals(req.getQueryString())) {
597                     this.monitoredURLs.add(
598                         this.getMonitoredURL(path, req)
599                     );
600                     break;
601                 }
602             }
603         }
604         else if(COMMAND_STOP.equals(req.getPathInfo())) {
605             URL JavaDoc monitoredURL = this.getMonitoredURL(
606                 URLDecoder.decode(req.getQueryString(), "UTF-8"),
607                 req
608             );
609             for(
610                 Iterator JavaDoc i = this.monitoredURLs.iterator();
611                 i.hasNext();
612             ) {
613                 URL JavaDoc url = (URL JavaDoc)i.next();
614                 if(url.equals(monitoredURL)) {
615                     i.remove();
616                     break;
617                 }
618             }
619         }
620         else if(COMMAND_SLOWDOWN_PING_RATE.equals(req.getPathInfo())) {
621             this.pingRate++;
622         }
623         else if(COMMAND_SPEEDUP_PING_RATE.equals(req.getPathInfo())) {
624             if(this.pingRate > 1) {
625                 this.pingRate--;
626             }
627         }
628         
629         // List status
630
PrintWriter JavaDoc out = res.getWriter();
631         out.println("<h2>openCRX Workflow Controller</h2>");
632         out.println("<table>");
633         for(
634             Iterator JavaDoc i = this.configuredPaths.iterator();
635             i.hasNext();
636         ) {
637             String JavaDoc path = (String JavaDoc)i.next();
638             boolean active = this.monitoredURLs.contains(this.getMonitoredURL(path, req));
639             out.println("<tr>");
640             out.println("<td>" + path + "</td><td><a HREF=\"" + req.getContextPath() + req.getServletPath() + (active ? "/stop" : "/start") + "?" + URLEncoder.encode(path.toString(), "UTF-8") + "\">" + (active ? "Turn Off" : "Turn On") + "</a></td>");
641             out.println("</tr>");
642         }
643         out.println("</table>");
644         out.println("<h3>Set ping rate</h3>");
645         out.println("Current ping rate: 1 ping every " + this.pingRate + " minute(s)");
646         out.println("<br /><a HREF=\"" + req.getContextPath() + req.getServletPath() + "/speedup\">Speed up ping rate</a>");
647         out.println("<br /><a HREF=\"" + req.getContextPath() + req.getServletPath() + "/slowdown\">Slow down ping rate</a>");
648     }
649
650     //-----------------------------------------------------------------------
651
protected void doGet(
652         HttpServletRequest JavaDoc req,
653         HttpServletResponse JavaDoc res
654     ) throws ServletException JavaDoc, IOException JavaDoc {
655         this.handleRequest(
656             req,
657             res
658         );
659     }
660         
661     //-----------------------------------------------------------------------
662
protected void doPost(
663         HttpServletRequest JavaDoc req,
664         HttpServletResponse JavaDoc res
665     ) throws ServletException JavaDoc, IOException JavaDoc {
666         this.handleRequest(
667             req,
668             res
669         );
670     }
671         
672     //-----------------------------------------------------------------------
673
// Members
674
//-----------------------------------------------------------------------
675
private static final long serialVersionUID = -2397456308895573603L;
676     private static final String JavaDoc COMMAND_START = "/start";
677     private static final String JavaDoc COMMAND_STOP = "/stop";
678     private static final String JavaDoc COMMAND_SLOWDOWN_PING_RATE = "/slowdown";
679     private static final String JavaDoc COMMAND_SPEEDUP_PING_RATE = "/speedup";
680
681     public static final String JavaDoc WORKFLOW_EXPORT_MAIL = "ExportMail";
682     public static final String JavaDoc WORKFLOW_SEND_MAIL = "SendMail";
683     public static final String JavaDoc WORKFLOW_SEND_MAIL_NOTIFICATION = "SendMailNotification";
684     public static final String JavaDoc WORKFLOW_SEND_ALERT = "SendAlert";
685     public static final String JavaDoc WORKFLOW_PRINT_CONSOLE = "PrintConsole";
686     
687     private List JavaDoc configuredPaths = null;
688     private List JavaDoc monitoredURLs = null;
689     private Thread JavaDoc workflowMonitor = null;
690     private long pingRate = 1L; // ping handler every X minutes
691
private Dataprovider_1_1Connection connectionData = null;
692     
693 }
694
695 //--- End of File -----------------------------------------------------------
696
Popular Tags