01: package org.emforge.jbpm.web;
02:
03: import java.io.IOException;
04: import java.io.OutputStream;
05:
06: import javax.servlet.ServletException;
07: import javax.servlet.http.HttpServletRequest;
08: import javax.servlet.http.HttpServletResponse;
09:
10: import org.apache.commons.logging.Log;
11: import org.apache.commons.logging.LogFactory;
12: import org.emforge.BpmService;
13: import org.emforge.jbpm.web.bean.WorkflowController;
14:
15: import ru.emdev.EmForge.util.Helper;
16:
17: public class ProcessIconServlet extends javax.servlet.http.HttpServlet
18: implements javax.servlet.Servlet {
19: private static final long serialVersionUID = -9120338949070596320L;
20:
21: protected final Log logger = LogFactory.getLog(getClass());
22:
23: /* (non-Java-doc)
24: * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
25: */
26: protected void doGet(HttpServletRequest i_request,
27: HttpServletResponse o_response) throws ServletException,
28: IOException {
29: long workflowId = Long.parseLong(i_request
30: .getParameter(WorkflowController.WORKFLOW_ID_ATTR));
31:
32: BpmService bpmService = Helper.getBpmService(i_request);
33:
34: try {
35: byte[] bytes = bpmService.getWorkflowIcon(workflowId);
36: OutputStream out = o_response.getOutputStream();
37: out.write(bytes);
38: out.flush();
39: } catch (RuntimeException e) {
40: logger.info("Probably workflow #" + workflowId
41: + " has no process icon");
42: }
43: }
44: }
|