Ejemplo n.º 1
0
  public void init() {
    if (!Library.wsInitialised) {
      try {
        ServletContext context = getServletContext();

        Library.setHomeDir(context.getRealPath("/"));
        Library.setRepositoryDir(context.getInitParameter("Repository"));

        String persistStr = context.getInitParameter("EnablePersistence");
        Library.setPersist(persistStr.equalsIgnoreCase("TRUE"));

        String engineURI = context.getInitParameter("InterfaceB_BackEnd");
        WorkletService.getInstance().initEngineURI(engineURI);

        WorkletService.getInstance().completeInitialisation();
        ExceptionService.getInst().completeInitialisation();
      } catch (Exception e) {
        _log.error("Gateway Initialisation Exception", e);
      } finally {
        Library.setServicetInitialised();
      }
    }
  }
Ejemplo n.º 2
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);
    }
  }