1 4 5 9 10 package org.openlaszlo.servlets.responders; 11 12 import java.io.*; 13 import java.util.*; 14 import java.net.*; 15 import javax.servlet.*; 16 import javax.servlet.http.*; 17 import org.openlaszlo.compiler.*; 18 import org.openlaszlo.connection.*; 19 import org.openlaszlo.utils.*; 20 import org.apache.log4j.*; 21 22 23 public class ResponderAGENTMESSAGE extends ResponderConnectionAgent 24 { 25 private static boolean mIsInitialized = false; 26 private static Logger mLogger = Logger.getLogger(ResponderAGENTMESSAGE.class); 27 28 protected void respondAgent(HttpServletRequest req, HttpServletResponse res, 29 ConnectionGroup group) throws IOException 30 { 31 String to = req.getParameter("to"); 32 String msg = req.getParameter("msg"); 33 String range = req.getParameter("range"); 34 String dset = req.getParameter("dset"); 35 36 if (isEmpty(to)) { 37 replyWithXMLStatus(res, "missing 'to' parameter", SC_MISSING_PARAMETER); 38 return; 39 } 40 41 if (isEmpty(dset)) { 42 replyWithXMLStatus(res, "missing 'dset' parameter", SC_MISSING_PARAMETER); 43 return; 44 } 45 46 if (msg == null) { 47 replyWithXMLStatus(res, "missing 'msg' parameter", SC_MISSING_PARAMETER); 48 return; 49 } 50 51 mLogger.debug("to='" + to + "',range='" + range + "', msg='" + msg + "'"); 52 53 String xml = "<resultset s=\"0\">" + 56 "<root dset=\"" + dset + "\">" + 57 msg + 58 "</root>" + 59 "</resultset>"; 60 61 int count = group.sendMessage(to, xml, range, null); 62 63 replyWithXMLStatus(res, (count > 0 64 ? "message sent" 65 : "no one specified connected (range: " + range + ")")); 66 } 67 68 private boolean isEmpty(String str) { 69 return str==null || str.equals(""); 70 } 71 } 72 | Popular Tags |