Exemplo n.º 1
0
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {
    String result = "";

    try {
      String action = req.getParameter("action");
      if (action == null) {
        result =
            "<html><head>"
                + "<title>Worklet Dynamic Process Selection and Exception Service</title>"
                + "</head><body>"
                + "<H3>Welcome to the Worklet Dynamic Process Selection and "
                + "Exception Service \"Gateway\"</H3>"
                + "<p> The Worklet Gateway acts as a bridge between the Worklet "
                + "Service and the external RDREditor (it isn't meant to be browsed "
                + " to directly). It provides the "
                + "functionality to trigger a running worklet replacement "
                + "due to an addtion to the ruleset (by the editor).</p>"
                + "</body></html>";
      } else if (action.equalsIgnoreCase("replace")) {
        _log.info("Received a request from the Rules Editor to replace " + "a running worklet.");

        String itemID = req.getParameter("itemID");
        int exType = Integer.parseInt(req.getParameter("exType"));

        // get the service instance and call replace
        if (exType == WorkletService.XTYPE_SELECTION) {
          WorkletService ws = WorkletService.getInstance();
          result = ws.replaceWorklet(itemID);
        } else {
          String caseID = req.getParameter("caseID");
          String trigger = req.getParameter("trigger");
          ExceptionService ex = ExceptionService.getInst();
          result = ex.replaceWorklet(exType, caseID, itemID, trigger);
        }
      } else if (action.equalsIgnoreCase("refresh")) {
        String specID = req.getParameter("specid");
        String specVersion = req.getParameter("specversion");
        String specURI = req.getParameter("specuri");
        WorkletService ws = WorkletService.getInstance();
        ws.refreshRuleSet(new YSpecificationID(specID, specVersion, specURI));
      }

      // generate the output
      OutputStreamWriter outputWriter = ServletUtils.prepareResponse(res);
      ServletUtils.finalizeResponse(outputWriter, result);

    } catch (Exception e) {
      _log.error("Exception in doPost()", e);
    }
  }
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {

    OutputStreamWriter outputWriter = ServletUtils.prepareResponse(response);
    StringBuilder output = new StringBuilder();
    output.append("<response>");
    output.append(processPostQuery(request));
    output.append("</response>");
    if (_engine.enginePersistenceFailure()) {
      _log.fatal("************************************************************");
      _log.fatal("A failure has occurred whilst persisting workflow state to the");
      _log.fatal("database. Check the status of the database connection defined");
      _log.fatal("for the YAWL service, and restart the YAWL web application.");
      _log.fatal("Further information may be found within the Tomcat log files.");
      _log.fatal("************************************************************");
      response.sendError(500, "Database persistence failure detected");
    }
    outputWriter.write(output.toString());
    outputWriter.flush();
    outputWriter.close();
    // todo find out how to provide a meaningful 500 message in the format of  a fault message.
  }