UpdateProcess.java
上传用户:ahit0551
上传日期:2009-04-15
资源大小:2345k
文件大小:3k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. package name.xio.xiorkflow.web;
  2. import java.io.IOException;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.servlet.http.HttpServletResponse;
  5. import name.xio.xiorkflow.domain.Process;
  6. import name.xio.xiorkflow.domain.ProcessResult;
  7. import name.xio.xiorkflow.domain.logic.ProcessService;
  8. import name.xio.xml.SimpleXMLWorkShop;
  9. import org.apache.commons.logging.Log;
  10. import org.apache.commons.logging.LogFactory;
  11. import org.jdom.Document;
  12. import org.jdom.JDOMException;
  13. import org.springframework.web.servlet.ModelAndView;
  14. import org.springframework.web.servlet.mvc.Controller;
  15. public class UpdateProcess implements Controller {
  16.     public ModelAndView handleRequest(HttpServletRequest request,
  17.             HttpServletResponse response) throws Exception {
  18.         request.setCharacterEncoding("UTF-8");
  19.         String name = request.getParameter("name");
  20.         String xml = request.getParameter("xml");
  21.         log.info("update process:" + name);
  22.         ProcessResult processResult = new ProcessResult();
  23.         Document doc;
  24.         try {
  25.             doc = SimpleXMLWorkShop.str2Doc(xml);
  26.         } catch (IOException e) {
  27.             processResult.setStatus(ProcessService.IO_ERROR);
  28.             processResult.setMes(e.getMessage());
  29.             doc = null;
  30.             log.warn("io error on onupdateprocess str2Doc:" + e.getMessage());
  31.             log.warn(xml);
  32.         } catch (JDOMException e) {
  33.             processResult.setStatus(ProcessService.XML_PARSER_ERROR);
  34.             processResult.setMes(e.getMessage());
  35.             doc = null;
  36.             log.warn("jdom error onupdateprocess str2Doc:" + e.getMessage());
  37.             log.warn(xml);
  38.         }
  39.         if (doc != null) {
  40.             Process process = new Process();
  41.             process.setName(name);
  42.             process.setDoc(doc);
  43.             processResult = this.getProcessService().updateProcess(process);
  44.         }
  45.         response.setContentType("text/xml");
  46.         response.setHeader("Cache-Control", "no-cache");
  47.         SimpleXMLWorkShop.outputXML(ProcessResult.convertXml(processResult),
  48.                 response.getOutputStream());
  49.         //not redirect to other view,it processed on response
  50.         return null;
  51.     }
  52.     /**
  53.      * @return Returns the processService.
  54.      */
  55.     public ProcessService getProcessService() {
  56.         return processService;
  57.     }
  58.     /**
  59.      * @param processService The processService to set.
  60.      */
  61.     public void setProcessService(ProcessService processService) {
  62.         this.processService = processService;
  63.     }
  64.     private Log log = LogFactory.getLog(UpdateProcess.class);
  65.     private ProcessService processService;
  66. }