01: /******************************************************************************
02: * ResponderSOAPINFO.java
03: * ****************************************************************************/package org.openlaszlo.servlets.responders;
04:
05: import java.io.*;
06: import javax.servlet.http.HttpServletRequest;
07: import javax.servlet.http.HttpServletResponse;
08: import javax.servlet.ServletOutputStream;
09: import org.openlaszlo.data.json.SOAPDataSource;
10: import org.openlaszlo.utils.FileUtils;
11: import org.apache.log4j.Logger;
12:
13: public final class ResponderSOAPINFO extends ResponderAdmin {
14: private static Logger mLogger = Logger
15: .getLogger(ResponderSOAPINFO.class);
16:
17: boolean ok(String opt) {
18: return opt != null && opt.equals("1");
19: }
20:
21: /**
22: * If "service" param exists, returns service information. An url encoded
23: * name for the service is included in the standard XML lzt=soapinfo under
24: * <service name="NAME" urlname="URL_ENCODED_NAME" />.
25: */
26: protected void respondAdmin(HttpServletRequest req,
27: HttpServletResponse res) throws IOException {
28: res.setContentType("text/xml");
29: ServletOutputStream out = res.getOutputStream();
30: try {
31: if (ok(req.getParameter("clear"))) {
32: SOAPDataSource.clearLoadInfo();
33: }
34: String service = req.getParameter("service");
35: StringBuffer sb = new StringBuffer();
36: if (service != null && !service.equals("")) {
37: SOAPDataSource.serviceXML(sb, service);
38: } else {
39: SOAPDataSource.toXML(sb);
40: }
41: out.println(sb.toString());
42: } finally {
43: FileUtils.close(out);
44: }
45: }
46:
47: public int getMimeType() {
48: return MIME_TYPE_XML;
49: }
50: }
|