01: /******************************************************************************
02: * ResponderINFO_XML.java
03: * ****************************************************************************/package org.openlaszlo.servlets.responders;
04:
05: import java.io.*;
06: import java.net.URL;
07: import java.util.Hashtable;
08: import java.util.Properties;
09: import javax.servlet.ServletConfig;
10: import javax.servlet.ServletException;
11: import javax.servlet.ServletOutputStream;
12: import javax.servlet.http.HttpServletRequest;
13: import javax.servlet.http.HttpServletResponse;
14: import org.openlaszlo.media.MimeType;
15: import org.openlaszlo.utils.FileUtils;
16: import org.openlaszlo.utils.LZHttpUtils;
17: import org.openlaszlo.utils.StringUtils;
18: import org.openlaszlo.compiler.CompilationError;
19: import org.apache.log4j.Logger;
20:
21: public final class ResponderINFO_XML extends ResponderCompile {
22: private static Logger mLogger = Logger
23: .getLogger(ResponderINFO_XML.class);
24:
25: public void init(String reqName, ServletConfig config,
26: Properties prop) throws ServletException, IOException {
27: super .init(reqName, config, prop);
28: }
29:
30: /**
31: * @param fileName Full pathname to file from request.
32: */
33: protected void respondImpl(String fileName, HttpServletRequest req,
34: HttpServletResponse res) throws IOException {
35: ServletOutputStream output = null;
36:
37: if (fileName.endsWith(".lzo")) {
38: fileName = StringUtils.setCharAt(fileName, fileName
39: .length() - 1, 'x');
40: }
41:
42: // Compile the file and send it out
43: try {
44: mLogger.info("Requesting info_xml for " + fileName);
45:
46: output = res.getOutputStream();
47: Properties props = initCMgrProperties(req);
48: String info = mCompMgr.getInfoXML(fileName, props);
49: res.setContentType(MimeType.XML);
50:
51: output.print(info);
52:
53: } catch (Exception e) {
54: respondWithException(res, e);
55: } finally {
56: FileUtils.close(output);
57: }
58: }
59:
60: public int getMimeType() {
61: return MIME_TYPE_XML;
62: }
63:
64: protected void handleCompilationError(CompilationError e,
65: HttpServletRequest req, HttpServletResponse res)
66: throws IOException {
67: respondWithErrorXML(res, e.getMessage());
68: }
69: }
|